diff --git a/src/ANT.cpp b/src/ANT.cpp index bdf511469..b8500e40a 100644 --- a/src/ANT.cpp +++ b/src/ANT.cpp @@ -179,6 +179,11 @@ bool ANT::modeERGO(void) const return mode==RT_MODE_ERGO; } +bool ANT::modeSLOPE(void) const +{ + return mode==RT_MODE_SLOPE; +} + double ANT::channelValue2(int channel) { return antChannel[channel]->channelValue2(); @@ -291,6 +296,15 @@ void ANT::refreshFecLoad() sendMessage(ANTMessage::fecSetTargetPower(fecChannel, (int)load)); } +void ANT::refreshFecGradient() +{ + if (fecChannel == -1) + return; + + if (antChannel[fecChannel]->capabilities() & FITNESS_EQUIPMENT_SIMUL_MODE_CAPABILITY) + sendMessage(ANTMessage::fecSetTrackResistance(fecChannel, gradient, currentRollingResistance)); +} + void ANT::requestFecCapabilities() { sendMessage(ANTMessage::fecRequestCapabilities(fecChannel)); diff --git a/src/ANT.h b/src/ANT.h index 5ac4cf023..686ab4dd2 100644 --- a/src/ANT.h +++ b/src/ANT.h @@ -403,6 +403,7 @@ public: int rawWrite(uint8_t *bytes, int size); bool modeERGO(void) const; + bool modeSLOPE(void) const; // channels update our telemetry double channelValue(int channel); @@ -458,6 +459,7 @@ public: void setFecChannel(int channel); void refreshFecLoad(); + void refreshFecGradient(); void requestFecCapabilities(); void setVortexData(int channel, int id); diff --git a/src/ANTChannel.cpp b/src/ANTChannel.cpp index 177fc23f3..606c69234 100644 --- a/src/ANTChannel.cpp +++ b/src/ANTChannel.cpp @@ -684,10 +684,13 @@ void ANTChannel::broadcastEvent(unsigned char *ant_message) parent->setFecChannel(number); // we don't seem to receive ACK messages, so use this workaround - // to ensure load is always set correctly - if ((fecRefreshCounter++ % 10) == 0 && parent->modeERGO()) + // to ensure load/gradient is always set correctly + if ((fecRefreshCounter++ % 10) == 0) { - parent->refreshFecLoad(); + if (parent->modeERGO()) + parent->refreshFecLoad(); + else if (parent->modeSLOPE()) + parent->refreshFecGradient(); } if (antMessage.data_page == FITNESS_EQUIPMENT_TRAINER_SPECIFIC_PAGE)