Skip to content

Commit

Permalink
Revert "handling ERG mode for VFSPINBIKE"
Browse files Browse the repository at this point in the history
This reverts commit e881ce5.
  • Loading branch information
cagnulein committed Dec 20, 2024
1 parent e881ce5 commit ca5fb75
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/devices/bluetoothdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void bluetoothdevice::setVirtualDevice(virtualdevice *virtualDevice, VIRTUAL_DEV
}

// keiser m3i has a separate management of this, so please check it
void bluetoothdevice::update_metrics(bool watt_calc, const double watts, const bool from_accessory, double resistance) {
void bluetoothdevice::update_metrics(bool watt_calc, const double watts, const bool from_accessory) {

QDateTime current = QDateTime::currentDateTime();
double deltaTime = (((double)_lastTimeUpdate.msecsTo(current)) / ((double)1000.0));
Expand All @@ -188,7 +188,7 @@ void bluetoothdevice::update_metrics(bool watt_calc, const double watts, const b
watt_calc = false;

if(deviceType() == bluetoothdevice::BIKE && !from_accessory) // append only if it's coming from the bike, not from the power sensor
_ergTable.collectData(Cadence.value(), m_watt.value(), resistance);
_ergTable.collectData(Cadence.value(), m_watt.value(), Resistance.value());

if (!_firstUpdate && !paused) {
if (currentSpeed().value() > 0.0 || settings.value(QZSettings::continuous_moving, true).toBool()) {
Expand Down
2 changes: 1 addition & 1 deletion src/devices/bluetoothdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ class bluetoothdevice : public QObject {
* @param watt_calc ??
* @param watts ?. Unit: watts
*/
void update_metrics(bool watt_calc, const double watts, const bool from_accessory = false, double resistance = Resistance.value());
void update_metrics(bool watt_calc, const double watts, const bool from_accessory = false);

/**
* @brief update_hr_from_external Updates heart rate from Garmin Companion App or Apple Watch
Expand Down
17 changes: 4 additions & 13 deletions src/devices/ftmsbike/ftmsbike.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ void ftmsbike::update() {
// gattWriteCharacteristic.isValid() &&
// gattNotify1Characteristic.isValid() &&
/*initDone*/) {
// here the bike that doesn't have ERG mode, so i'm using inclination to recreate a resistance value
update_metrics(false, watts(), false, (VFSPINBIKE ? Inclination.value() * 10.0 : Resistance.value()));
update_metrics(false, watts());

// updating the treadmill console every second
if (sec1Update++ == (500 / refresh->interval())) {
Expand Down Expand Up @@ -363,11 +362,9 @@ void ftmsbike::update() {
lastGearValue = gears();

if (requestPower != -1) {
if(!VFSPINBIKE) { // this bike doesn't handle ERG mode
qDebug() << QStringLiteral("writing power") << requestPower;
init();
forcePower(requestPower);
}
qDebug() << QStringLiteral("writing power") << requestPower;
init();
forcePower(requestPower);
requestPower = -1;
}
if (requestStart != -1) {
Expand Down Expand Up @@ -1114,12 +1111,6 @@ void ftmsbike::ftmsCharacteristicChanged(const QLowEnergyCharacteristic &charact
b[1] = power & 0xFF;
b[2] = power >> 8;
qDebug() << "applying gears mod" << gears() << gearsZwiftRatio() << power;

// this bike doesn't handle erg mode
if(VFSPINBIKE) {
forceResistance(((double)resistanceFromPowerRequest(power)) / 10.0);
return;
}
}

writeCharacteristic((uint8_t*)b.data(), b.length(), "injectWrite ", false, true);
Expand Down

0 comments on commit ca5fb75

Please sign in to comment.