Hi, I'm new to the Garmin SDK and I tried to follow the API documentation to register the callback for a sensor in a SimpleDataField.
using Toybox.Sensor;
var cadence = 0.0;
function initialize() {
SimpleDataField.initialize();
label = "Cadence";
Sensor.setEnabledSensors([Sensor.SENSOR_BIKECADENCE]);
Sensor.enableSensorEvents(method(:onBikeCadenceUpdate));
}
function compute(info as Activity.Info) as Numeric or Duration or String or Null {
return cadence;
}
function onBikeCadenceUpdate(info as Sensor.Info) {
cadence = info.cadence;
}
Unfortunately enableSensorEvents() generates following error: Invalid '$.Toybox.Lang.Method(info as $.Toybox.Sensor.Info) as Any' passed as parameter 1 of type 'PolyType<Null or ($.Toybox.Lang.Method(info as $.Toybox.Sensor.Info) as Void)>'.