Hi,
I am new to Connect IQ programming. I am trying to implement a data field for bike power.
I started with the DataField example generated by the VS Code Monkey C extension and implemented a very simple field with the power data from Activity.Info that gets provided in compute(). I am also trying to access the values provided by BikePower (and later maybe BikePowerListener), but that doesn't seem to work.
I exported a FIT file from my last ride that was recorded on a Fenix 6 with Rally RK200 power meter pedals connected.
When I play back the FIT file in the simulator, I can see that the power value in Activity.Info gets updated, but I don't get any data out of BikePower. What am I missing?
Here is the relevant code for reference:
class PowerView extends WatchUi.DataField {
hidden var mValue as Numeric;
hidden var listener as AntPlus.BikePowerListener;
hidden var bikePower as AntPlus.BikePower;
function initialize() {
DataField.initialize();
mValue = 0.0f;
listener = new AntPlus.BikePowerListener();
bikePower = new AntPlus.BikePower(listener);
}
function compute(info as Activity.Info) as Void {
if(info.currentPower != null) {
System.println("info.currentPower: " + info.currentPower);
System.println("bikePower.calculatedPower: " + bikePower.getCalculatedPower());
mValue = info.currentPower as Number;
} else {
mValue = 0.0f;
}
}
}