Skip to content

Commit

Permalink
Rowing With Zwift Avatar Keeps Moving When You Stop #1671
Browse files Browse the repository at this point in the history
  • Loading branch information
cagnulein committed Oct 2, 2023
1 parent 14546d4 commit 1ecee4c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,7 @@ void bluetooth::deviceDiscovered(const QBluetoothDeviceInfo &device) {
b.name().toUpper().startsWith(QStringLiteral("KS-WLT")) || // KS-WLT-W1
b.name().toUpper().startsWith(QStringLiteral("I-ROWER")) ||
b.name().toUpper().startsWith(QStringLiteral("SF-RW")) ||
b.name().toUpper().startsWith(QStringLiteral("DFIT-L-R")) ||
!b.name().compare(ftms_rower, Qt::CaseInsensitive) ||
(b.name().toUpper().startsWith(QStringLiteral("PM5")) &&
b.name().toUpper().endsWith(QStringLiteral("ROW")))) &&
Expand Down
14 changes: 11 additions & 3 deletions src/ftmsrower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,11 @@ void ftmsrower::characteristicChanged(const QLowEnergyCharacteristic &characteri

if (!Flags.moreData) {

if (WATER_ROWER && lastStroke.secsTo(QDateTime::currentDateTime()) > 3) {
if ((WATER_ROWER || DFIT_L_R) && lastStroke.secsTo(QDateTime::currentDateTime()) > 3) {
qDebug() << "Resetting cadence!";
Cadence = 0;
m_watt = 0;
Speed = 0;
} else {
Cadence = ((uint8_t)newValue.at(index)) / cadence_divider;
}
Expand Down Expand Up @@ -241,8 +243,10 @@ void ftmsrower::characteristicChanged(const QLowEnergyCharacteristic &characteri
index += 2;
emit debug(QStringLiteral("Current Pace: ") + QString::number(instantPace));

Speed = (60.0 / instantPace) *
if((DFIT_L_R && Cadence.value() > 0) || !DFIT_L_R) {
Speed = (60.0 / instantPace) *
30.0; // translating pace (min/500m) to km/h in order to match the pace function in the rower.cpp
}
emit debug(QStringLiteral("Current Speed: ") + QString::number(Speed.value()));
}

Expand All @@ -260,7 +264,8 @@ void ftmsrower::characteristicChanged(const QLowEnergyCharacteristic &characteri
((double)(((uint16_t)((uint8_t)newValue.at(index + 1)) << 8) | (uint16_t)((uint8_t)newValue.at(index))));
index += 2;
if (!filterWattNull || watt != 0) {
m_watt = watt;
if((DFIT_L_R && Cadence.value() > 0) || !DFIT_L_R)
m_watt = watt;
}
emit debug(QStringLiteral("Current Watt: ") + QString::number(m_watt.value()));
}
Expand Down Expand Up @@ -574,6 +579,9 @@ void ftmsrower::deviceDiscovered(const QBluetoothDeviceInfo &device) {
} else if (device.name().toUpper().startsWith(QStringLiteral("S4 COMMS"))) {
WATER_ROWER = true;
qDebug() << "WATER_ROWER found!";
} else if (device.name().toUpper().startsWith(QStringLiteral("DFIT-L-R"))) {
DFIT_L_R = true;
qDebug() << "DFIT_L_R found!";
} else if (device.name().toUpper().startsWith(QStringLiteral("PM5"))) {
PM5 = true;
qDebug() << "PM5 found!";
Expand Down
1 change: 1 addition & 0 deletions src/ftmsrower.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ftmsrower : public rower {
bool PM5 = false;

bool WATER_ROWER = false;
bool DFIT_L_R = false;
QDateTime lastStroke = QDateTime::currentDateTime();
double lastStrokesCount = 0;

Expand Down

0 comments on commit 1ecee4c

Please sign in to comment.