I am doing my first steps in coding an app. My first app is an easy table tennis app. I have a lot of statistical information to write to the FIT file but I want to do the basics first: writing the heart rate. Therefore I have done this:
using Toybox.ActivityRecording as Rec;
using Toybox.Sensor as Snsr;
class TableTennisView extends Ui.View {
var session;
var heartRateFitField;
function initialize() {
View.initialize();
Snsr.setEnabledSensors( [Snsr.SENSOR_HEARTRATE] );
Snsr.enableSensorEvents( method(:onSnsr) );
}
function onSnsr(sensor_info)
{
var HR = sensor_info.heartRate;
if (session != null && session.isRecording() && HR != null) {
heartRateFitField.setData(HR);
}
}
function onUpdate(dc) {
if ( ( session == null ) || ( session.isRecording() == false ) ) {
var sessionOptions = {:sport => Rec.SPORT_TENNIS,:subSport => Rec.SUB_SPORT_MATCH, :name => "Tischtennis"};
session = Rec.createSession(sessionOptions);
Sys.println(session);
heartRateFitField = session.createField("Heart Rate", 0, Rec.Session.DATA_TYPE_UINT8, {:mesgType => Rec.Session.MESG_TYPE_RECORD, :units => "bpm"});
session.start();
}
}
}
Nevertheless, I get this failure during runtime for the createField-line:
Failed invoking <symbol>
UnexpectedTypeException: Expected Number/Float/Boolean/Long/Double, given Class definition
I have tried really a lot of things to get that running, but it will not work. Can someone point me in the right direction?