Fix sensors

Signed-off-by: Vasiliy Doylov <nekodevelopper@gmail.com>
This commit is contained in:
Vasiliy Doylov 2025-03-02 17:06:32 +03:00
parent 7e3f0747b2
commit 098d5820c9
Signed by: NekoCWD
GPG key ID: B7BE22D44474A582

View file

@ -29,6 +29,8 @@ public class TheCatTools.Window : Adw.ApplicationWindow {
[GtkChild] [GtkChild]
private unowned GUI.BoubleCircle circle; private unowned GUI.BoubleCircle circle;
private SSC.SensorAccelerometer accel; private SSC.SensorAccelerometer accel;
private SSC.SensorGyroscope gyro;
async void start_sensors() { async void start_sensors() {
try { try {
@ -41,13 +43,20 @@ public class TheCatTools.Window : Adw.ApplicationWindow {
var x_angle = rad2deg(Math.atan2(x, z)); var x_angle = rad2deg(Math.atan2(x, z));
var y_angle = rad2deg(Math.atan2(y, z)); var y_angle = rad2deg(Math.atan2(y, z));
message("%f\t%f\t%f", x, y, z);
message("%f\t%f", x_angle, y_angle);
hbar.bubble.value_x = (float) x_angle; hbar.bubble.value_x = (float) x_angle;
vbar.bubble.value_x = (float) y_angle; vbar.bubble.value_x = (float) y_angle;
circle.bubble.value_x = (float) x_angle; circle.bubble.value_x = (float) x_angle;
circle.bubble.value_y = (float) y_angle; circle.bubble.value_y = (float) y_angle;
}); });
gyro = new SSC.SensorGyroscope.sync(null);
message("Sensor created");
if (accel == null)
message("Sensor is NULL");
gyro.open_sync();
gyro.measurement.connect((x, y, z) => {
message("%f\t%f\t%f m/s", x, y, z);
});
} catch (Error err) { } catch (Error err) {
message("Failed to open Sensor %s", err.message); message("Failed to open Sensor %s", err.message);
} }