From 7b1044a63425c81131ce76600a154d202bb6cb95 Mon Sep 17 00:00:00 2001 From: Roberto Viola Date: Thu, 12 Oct 2023 14:18:24 +0200 Subject: [PATCH] tdf4 change gears without manual workout #1697 --- src/proformwifibike.cpp | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/proformwifibike.cpp b/src/proformwifibike.cpp index f1cc04e42..20eb226d3 100644 --- a/src/proformwifibike.cpp +++ b/src/proformwifibike.cpp @@ -502,23 +502,25 @@ void proformwifibike::characteristicChanged(const QString &newValue) { QJsonValue code = key.value("code"); QJsonValue name = key.value("name"); QJsonValue held = key.value("held"); - double value = 0; - if (name.toString().contains(QStringLiteral("LEFT EXTERNAL GEAR DOWN"))) { - qDebug() << "LEFT EXTERNAL GEAR DOWN"; - value = -0.5; - } else if (name.toString().contains(QStringLiteral("LEFT EXTERNAL GEAR UP"))) { - qDebug() << "LEFT EXTERNAL GEAR UP"; - value = 0.5; - } else if (name.toString().contains(QStringLiteral("RIGHT EXTERNAL GEAR UP"))) { - qDebug() << "RIGHT EXTERNAL GEAR UP"; - value = 5.0; - } else if (name.toString().contains(QStringLiteral("RIGHT EXTERNAL GEAR DOWN"))) { - qDebug() << "RIGHT EXTERNAL GEAR DOWN"; - value = -5.0; - } - if (value != 0.0) { - forceResistance(currentInclination().value() + value); // to force an immediate change - setGears(gears() + value); + if(held.toString().contains(QStirngLiteral("-1"))) { + double value = 0; + if (name.toString().contains(QStringLiteral("LEFT EXTERNAL GEAR DOWN"))) { + qDebug() << "LEFT EXTERNAL GEAR DOWN"; + value = -0.5; + } else if (name.toString().contains(QStringLiteral("LEFT EXTERNAL GEAR UP"))) { + qDebug() << "LEFT EXTERNAL GEAR UP"; + value = 0.5; + } else if (name.toString().contains(QStringLiteral("RIGHT EXTERNAL GEAR UP"))) { + qDebug() << "RIGHT EXTERNAL GEAR UP"; + value = 5.0; + } else if (name.toString().contains(QStringLiteral("RIGHT EXTERNAL GEAR DOWN"))) { + qDebug() << "RIGHT EXTERNAL GEAR DOWN"; + value = -5.0; + } + if (value != 0.0) { + forceResistance(currentInclination().value() + value); // to force an immediate change + setGears(gears() + value); + } } } }