You are here: Forum Home → ANT Developers Forums → ANT+ FIT Forum Has Moved → Thread
void FitActivityCreator::writeRecord(int timeNow,
double averageHr1sec, double averageCadence1sec, double averageSpeed1sec, double averagePower1sec) {
if (!fileIsOpen)
return;
fit::RecordMesg recordMesg;
recordMesg.SetTimestamp(secStartedWorkout+timeNow);
if (averageHr1sec != -1) {
recordMesg.SetHeartRate((int)(averageHr1sec + 0.5));
}
if (averageCadence1sec != -1) {
recordMesg.SetCadence((int)(averageCadence1sec + 0.5));
}
if (averageSpeed1sec != -1) {
qDebug() << "##Writing speed:" << averageSpeed1sec;
double speedms = averageSpeed1sec*convertKphToMs;
recordMesg.SetSpeed(speedms);
// Compute Accumulated Distance
if (averageSpeed1sec > 0) {
int timeSec = timeNow - timeSecLastWriteRecord;
double timeHrs = timeSec/3600.0;
double distanceM = averageSpeed1sec * timeHrs *1000;
accumulatedDistance += distanceM;
recordMesg.SetDistance(accumulatedDistance);
}
else {
recordMesg.SetDistance(accumulatedDistance);
}
timeSecLastWriteRecord = timeNow;
}
if (averagePower1sec != -1) {
qDebug() << "##Writing power:" << averagePower1sec;
recordMesg.SetPower((int)(averagePower1sec + 0.5));
}
//% right pedal - TO TEST
// recordMesg.SetLeftRightBalance(0.60);
encode.Write(recordMesg);
}
——————————————————
Free Indoor Cycling Software - https://maximumtrainer.com