ANT FE-C Add periodic refresh of gradient in slope mode

As per the refresh in ergo mode, this is a workaround for
missing acknowledgements.
This commit is contained in:
Jon Escombe
2015-11-05 13:16:53 +00:00
parent eded6f5b4d
commit fc4ce118bc
3 changed files with 22 additions and 3 deletions

View File

@@ -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));

View File

@@ -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);

View File

@@ -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)