Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/devices/ftmsbike/ftmsbike.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,21 @@ void ftmsbike::ftmsCharacteristicChanged(const QLowEnergyCharacteristic &charact
b[1] = powerRequested & 0xFF;
b[2] = powerRequested >> 8;
}
} else if(b.at(0) == FTMS_SET_TARGET_RESISTANCE_LEVEL && bikeResistanceGain != 1.0) {
if(b.length() == 2) {
uint8_t resistance = (uint8_t)b.at(1);
qDebug() << "applying bikeResistanceGain to FTMS_SET_TARGET_RESISTANCE_LEVEL (1-byte) from" << resistance;
resistance = (uint8_t)qRound(((double)resistance) * bikeResistanceGain);
qDebug() << "to" << resistance;
b[1] = resistance;
} else if(b.length() >= 3) {
uint16_t resistance = (((uint8_t)b.at(1)) + ((uint8_t)b.at(2) << 8));
qDebug() << "applying bikeResistanceGain to FTMS_SET_TARGET_RESISTANCE_LEVEL (2-byte) from" << resistance;
resistance = (uint16_t)qRound(((double)resistance) * bikeResistanceGain);
qDebug() << "to" << resistance;
b[1] = resistance & 0xFF;
b[2] = resistance >> 8;
}
}
// gears on erg mode is quite useless and it's confusing
/* else if(b.at(0) == FTMS_SET_TARGET_POWER && b.length() > 2) {
Expand Down
Loading