diff --git a/src/solef80treadmill.cpp b/src/solef80treadmill.cpp index ab784b097..abbcc35ba 100644 --- a/src/solef80treadmill.cpp +++ b/src/solef80treadmill.cpp @@ -312,16 +312,21 @@ void solef80treadmill::update() { writeCharacteristic(noop2, sizeof(noop2), QStringLiteral("noop2"), false, true); } + int max_speed_loop = 0; + if(requestSpeed != -1) { + max_speed_loop = (fabs(requestSpeed - currentSpeed().value()) * 10.0) - 1; + } + do { if (requestSpeed != -1) { if (requestSpeed != currentSpeed().value() && requestSpeed >= 0 && requestSpeed <= 22) { - emit debug(QStringLiteral("writing speed ") + QString::number(requestSpeed)); + emit debug(QStringLiteral("writing speed ") + QString::number(requestSpeed) + " " + QString::number(max_speed_loop)); forceSpeed(requestSpeed); } // i have to do the reset on when the speed is equal to the current // requestSpeed = -1; } - } while (requestSpeed != -1 && sole_treadmill_inclination_fast); + } while (requestSpeed != -1 && sole_treadmill_inclination_fast && max_speed_loop); do { if (requestInclination != -100) { @@ -364,18 +369,32 @@ void solef80treadmill::update() { if (requestStop != -1) { emit debug(QStringLiteral("stopping...")); - uint8_t stop[] = {0x5b, 0x02, 0x03, 0x06, 0x5d}; - uint8_t stop1[] = {0x5b, 0x02, 0x03, 0x07, 0x5d}; - uint8_t stop2[] = {0x5b, 0x04, 0x00, 0x32, 0x4f, 0x4b, 0x5d}; - - if (gattCustomService) { - writeCharacteristic(stop, sizeof(stop), QStringLiteral("stop"), false, true); - writeCharacteristic(stop, sizeof(stop), QStringLiteral("stop"), false, true); - writeCharacteristic(stop, sizeof(stop), QStringLiteral("stop"), false, true); - writeCharacteristic(stop2, sizeof(stop2), QStringLiteral("stop"), false, true); - writeCharacteristic(stop1, sizeof(stop1), QStringLiteral("stop"), false, true); - writeCharacteristic(stop1, sizeof(stop1), QStringLiteral("stop"), false, true); - writeCharacteristic(stop1, sizeof(stop1), QStringLiteral("stop"), false, true); + if(treadmill_type == F63) { + uint8_t stop[] = {0x5b, 0x02, 0xf1, 0x06, 0x5d}; + uint8_t stop1[] = {0x5b, 0x02, 0x03, 0x06, 0x5d}; + + if (gattCustomService) { + writeCharacteristic(stop, sizeof(stop), QStringLiteral("stop"), false, true); + writeCharacteristic(stop, sizeof(stop), QStringLiteral("stop"), false, true); + writeCharacteristic(stop1, sizeof(stop1), QStringLiteral("stop"), false, true); + writeCharacteristic(stop1, sizeof(stop1), QStringLiteral("stop"), false, true); + writeCharacteristic(stop1, sizeof(stop1), QStringLiteral("stop"), false, true); + writeCharacteristic(stop1, sizeof(stop1), QStringLiteral("stop"), false, true); + } + } else { + uint8_t stop[] = {0x5b, 0x02, 0x03, 0x06, 0x5d}; + uint8_t stop1[] = {0x5b, 0x02, 0x03, 0x07, 0x5d}; + uint8_t stop2[] = {0x5b, 0x04, 0x00, 0x32, 0x4f, 0x4b, 0x5d}; + + if (gattCustomService) { + writeCharacteristic(stop, sizeof(stop), QStringLiteral("stop"), false, true); + writeCharacteristic(stop, sizeof(stop), QStringLiteral("stop"), false, true); + writeCharacteristic(stop, sizeof(stop), QStringLiteral("stop"), false, true); + writeCharacteristic(stop2, sizeof(stop2), QStringLiteral("stop"), false, true); + writeCharacteristic(stop1, sizeof(stop1), QStringLiteral("stop"), false, true); + writeCharacteristic(stop1, sizeof(stop1), QStringLiteral("stop"), false, true); + writeCharacteristic(stop1, sizeof(stop1), QStringLiteral("stop"), false, true); + } } requestStop = -1;