Skip to content

Commit 1625dd2

Browse files
committed
Fix: Initialize lastGearValue to prevent unwanted setResistance on init (#4018)
Problem: - lastGearValue was initialized to -1 (default) - During init, it was not set to the current gears() value - On first update after init, the condition "lastGearValue != gears()" was always true (-1 != 0) - This caused an unwanted setResistance command (0x40 0x5b 0x3f) to be sent immediately after setSimMode Solution: - Initialize lastGearValue = gears() during init (line 264) - This prevents false gear change detection on first update - setResistance is now only sent when there's an actual gear change Fixes issue #4018 - Resistance Changes when Virtual Shifting
1 parent bb16ecc commit 1625dd2

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

src/devices/wahookickrsnapbike/wahookickrsnapbike.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ void wahookickrsnapbike::update() {
261261
// required to the SS2K only one time
262262
Resistance = 0;
263263
emit resistanceRead(Resistance.value());
264+
lastGearValue = gears(); // Initialize to prevent false gear change detection on first update
264265
initRequest = false;
265266
} else if (m_control &&
266267
(bluetoothDevice.isValid() && m_control->state() == QLowEnergyController::DiscoveredState)

0 commit comments

Comments
 (0)