Hello! I'm trying to get the accelerometer's data in Garmin connect iq application.
This is the my initialize() function that register DataListener and the callback function.
function initialize() { View.initialize(); var options = { :period => 1, :accelerometer => { :enabled => true, :sampleRate => 25 // maximum 25Hz }, :heartBeatIntervals => { :enabled => true } }; try{ Sensor.registerSensorDataListener(method(:accelCallback), options); } catch(e) { System.println(e.getErrorMessage()); } }
And I found this two. But I don't know what to use and the difference between them.
1. Sensor.SensorData.accelerometerData
function accelCallback(sensorData as Sensor.SensorData) as Void { var view3 = View.findDrawableById("Listen") as Text; view3.setText(Lang.format("$1$", [sensorData.accelerometerData.x[0].format("%d")])); }
2. Sensor Info
var info = Sensor.getInfo(); if (info has :accel and info.accel != null) { System.println(info.accel); // [x, y, z] }
Also, both worked well when I tried to run on a simulator (computer).
But on my real watch(Forerunner 55), the first one does not work. `info has :accel` returns "true" but it is "null".