How to get currentCadence populating values in my App?

Former Member
Former Member

Just started my app, which I will use for rowing. The OOTB rowing app is perfectly good, except I want a companion app on my phone so the Cox can see the data, specifically Stroke Rate and Pace. Once I get the watch app working, I'll create a companion Android app.

So far, I created a v simple app which displays two fields, Heart Rate, and Stroke Rate.

I initialize these in my view

function initialize() {
//View.initialize();

Sensor.setEnabledSensors( [Sensor.SENSOR_HEARTRATE] );
Sensor.enableSensorEvents( method(:onSensor) );

HR = "--";
SPM = "--";
}

In the same class I assign values to these fields

function onSensor(sensorInfo)
{

info = Activity.getActivityInfo();

if (info.currentCadence != null) {
SPM = (info.currentCadence/2).toString();

}

if( sensorInfo.heartRate != null ) {
HR = sensorInfo.heartRate.toString();
}

WatchUi.requestUpdate();
}

When I run my app in the simulator and load a FIT file recorded by the OOTB rowing app, it seems to work, and correctly displays stroke rate and heart rate

But if I load the app on my watch, and start rowing then only the Heart Rate is populated.

What do I need to do to get the App to emit currentCadence values?

Also, is it possible for me to simulate the action of rowing in the Simulator so I can test without having to load on my watch and go use my rowing machine!

Thanks

David

  • Sensor is generally for sensors paired to your device.

    many things in Activity.Info don't change unless you are recording (see the recordSample in the SDK).

    For this, I'm not sure what you'll see though and it could vary by SPORT_*

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    Thanks, I'll look at the recordSample 

  • Not much there except the basics of recording.  Maybe add the display of cadence as a quick test.

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    I looked at the recordSample and added the createSession to my initialize() method, so now my session is recorded on my watch, and when I run my app in the Simulator and load the fit file that was created the app works OK and correctly displays the stroke rate, as recorded by currentCadence.

    But still the App running on the watch shows 0, whilst I am doing the activity....even though it records correctly in the FIT file.

    The code I have to capture the stroke rate is :-

    info = Activity.getActivityInfo();

    if (info.currentCadence != null) {
    SPM = (info.currentCadence/2).toString();
    }

    I did have this in the onSensor method, where I also populate the heart rate variable I am using, the heart rate updates, OK, but not the stroke rate. 

    So I move the code into the onUpdate() method, but same behaviour, it records the cadence OK to the FIT file, but the UI only updates when I play the FIT file back through the simulator, not when I run on the watch.

    Any suggestions?

    Thanks

    David

  • Instead of Sensor.Info, use Activity.Info.currentCadence

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    I was using Activity.Info, (in a slightly roundabout way) I had 

    info = Activity.getActivityInfo();

    if (info.currentCadence != null) {
    SPM = (info.currentCadence/2).toString();
    }

    I've simplified this to 

    if (Activity.Info.currentCadence != null) {
    SPM = Activity.Info.currentCadence.toString();
    }

    But still not displaying on the watch UI, except when replaying a FIT file in the simulator.

  • What sport?  And have you tried just going for a walk where there should be a cadence?

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    Sport is ROWING,  in my initialize() method I have set :-

    session = ActivityRecording.createSession({
    :name=>"StrokeMeter",
    :sport=>ActivityRecording.SPORT_ROWING

    Which I think is working OK, because the data in the FIT file looks correct

    Thanks

    David