Skip to content

Commit

Permalink
Delay in Virtual Gears with Tacx Neo 1 (Issue #2153)
Browse files Browse the repository at this point in the history
  • Loading branch information
cagnulein committed Feb 25, 2024
1 parent 7170e28 commit 102e1d6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/devices/bike.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ void bike::changeResistance(resistance_t resistance) {

void bike::changeInclination(double grade, double percentage) {
qDebug() << QStringLiteral("bike::changeInclination") << autoResistanceEnable << grade << percentage;
if (autoResistanceEnable) {
lastRawRequestedInclinationValue = grade;
if (autoResistanceEnable) {
requestInclination = grade;
}
emit inclinationChanged(grade, percentage);
Expand Down
1 change: 1 addition & 0 deletions src/devices/bike.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class bike : public bluetoothdevice {

double m_gears = 0;
resistance_t lastRawRequestedResistanceValue = -1;
double lastRawRequestedInclinationValue = -100;
uint16_t LastCrankEventTime = 0;
double CrankRevs = 0;

Expand Down
14 changes: 10 additions & 4 deletions src/devices/tacxneo2/tacxneo2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,26 +120,32 @@ void tacxneo2::update() {
// updateDisplay(elapsed);
}

auto virtualBike = this->VirtualBike();

if (requestResistance != -1) {
if (requestResistance != currentResistance().value() || lastGearValue != gears()) {
emit debug(QStringLiteral("writing resistance ") + QString::number(requestResistance));
auto virtualBike = this->VirtualBike();
if (((virtualBike && !virtualBike->ftmsDeviceConnected()) || !virtualBike) &&
(requestPower == 0 || requestPower == -1)) {
requestInclination = requestResistance / 10.0;
}
// forceResistance(requestResistance);;
}
lastGearValue = gears();
}
requestResistance = -1;
}
if (requestInclination != -100) {
emit debug(QStringLiteral("writing inclination ") + QString::number(requestInclination));
forceInclination(requestInclination + gears()); // since this bike doesn't have the concept of resistance,
// i'm using the gears in the inclination
requestInclination = -100;
requestInclination = -100;
} else if((virtualBike && virtualBike->ftmsDeviceConnected()) && lastGearValue != gears() && lastRawRequestedInclinationValue != -100) {
// in order to send the new gear value ASAP
forceInclination(lastRawRequestedInclinationValue + gears()); // since this bike doesn't have the concept of resistance,
// i'm using the gears in the inclination
}

lastGearValue = gears();

if (requestPower != -1) {
changePower(requestPower);
requestPower = -1;
Expand Down

0 comments on commit 102e1d6

Please sign in to comment.