Compare commits

...

7 Commits

Author SHA1 Message Date
Roberto Viola
0d0118e13e Update project.pbxproj 2025-06-16 10:46:35 +02:00
Roberto Viola
e3f9ccc848 trying to restore thing 2025-06-16 10:23:28 +02:00
Roberto Viola
31a74b9304 trying to get the right issue 2025-06-13 15:28:57 +02:00
Roberto Viola
5c39eb98d9 fixing build 2025-06-13 13:14:58 +02:00
Roberto Viola
ba50727563 Update homeform.cpp 2025-06-13 13:08:23 +02:00
Roberto Viola
b02c5e6a67 Update wahookickrsnapbike.h 2025-06-13 13:04:55 +02:00
Roberto Viola
349e6fd2b9 reverting to eb540dc579/src/devices/wahookickrsnapbike/wahookickrsnapbike.cpp 2025-06-13 13:00:39 +02:00
3 changed files with 27 additions and 69 deletions

View File

@@ -4381,7 +4381,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "../src/ios/qdomyos-zwift.entitlements";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1100;
CURRENT_PROJECT_VERSION = 1103;
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = NO;
GCC_PREPROCESSOR_DEFINITIONS = "ADB_HOST=1";
@@ -4575,7 +4575,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "../src/ios/qdomyos-zwift.entitlements";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1100;
CURRENT_PROJECT_VERSION = 1103;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = NO;
@@ -4805,7 +4805,7 @@
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1100;
CURRENT_PROJECT_VERSION = 1103;
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -4901,7 +4901,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1100;
CURRENT_PROJECT_VERSION = 1103;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 6335M7T29D;
ENABLE_BITCODE = YES;
@@ -4993,7 +4993,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1100;
CURRENT_PROJECT_VERSION = 1103;
DEVELOPMENT_ASSET_PATHS = "\"watchkit Extension/Preview Content\"";
ENABLE_BITCODE = YES;
ENABLE_PREVIEWS = YES;
@@ -5109,7 +5109,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = "watchkit Extension/WatchKit Extension.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1100;
CURRENT_PROJECT_VERSION = 1103;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"watchkit Extension/Preview Content\"";
ENABLE_BITCODE = YES;

View File

@@ -219,16 +219,10 @@ void wahookickrsnapbike::update() {
}
QThread::msleep(700);
QByteArray d = setWheelCircumference(wheelCircumference::gearsToWheelDiameter(gears()));
uint8_t e[20];
setGears(settings.value(QZSettings::gears_current_value, QZSettings::default_gears_current_value).toDouble());
memcpy(e, d.constData(), d.length());
writeCharacteristic(e, d.length(), "setWheelCircumference", false, true);
// required to the SS2K only one time
Resistance = 0;
emit resistanceRead(Resistance.value());
initRequest = false;
initRequest = false;
} else if (
#ifndef Q_OS_IOS
bluetoothDevice.isValid() &&
@@ -271,7 +265,10 @@ void wahookickrsnapbike::update() {
inclinationChanged(requestInclination, requestInclination);
Inclination = requestInclination; // the bike is not sending back the inclination?
requestInclination = -100;
} else if (lastGearValue != gears()) {
inclinationChanged(lastGrade, lastGrade);
}
lastGearValue = gears();
} else if (requestResistance != -1 && KICKR_BIKE == false) {
if (requestResistance > 100) {
requestResistance = 100;
@@ -289,30 +286,18 @@ void wahookickrsnapbike::update() {
memcpy(b, a.constData(), a.length());
writeCharacteristic(b, a.length(), "setResistance", false, false);
} else if (requestResistance != currentResistance().value() &&
((virtualBike && !virtualBike->ftmsDeviceConnected()) || !virtualBike)) {
emit debug(QStringLiteral("writing resistance ") + QString::number(lastForcedResistance));
QByteArray a = setResistanceMode(((double)lastForcedResistance) / 100.0);
((virtualBike && !virtualBike->ftmsDeviceConnected()) || !virtualBike) && lastGearValue != gears()) {
emit debug(QStringLiteral("writing resistance due to gears changed ") + QString::number(lastForcedResistance));
QByteArray a = setResistanceMode(((double)lastForcedResistance + (gears() - lastGearValue)) / 100.0);
uint8_t b[20];
memcpy(b, a.constData(), a.length());
writeCharacteristic(b, a.length(), "setResistance", false, false);
} else if (virtualBike && virtualBike->ftmsDeviceConnected() && lastGearValue != gears()) {
inclinationChanged(lastGrade, lastGrade);
}
lastGearValue = gears();
requestResistance = -1;
}
if (lastGearValue != gears()) {
if(KICKR_SNAP) {
inclinationChanged(lastGrade, lastGrade);
} else {
QByteArray a = setWheelCircumference(wheelCircumference::gearsToWheelDiameter(gears()));
uint8_t b[20];
memcpy(b, a.constData(), a.length());
writeCharacteristic(b, a.length(), "setWheelCircumference", false, false);
lastGrade = 999; // to force a change
}
}
lastGearValue = gears();
if (requestStart != -1) {
emit debug(QStringLiteral("starting..."));
@@ -803,7 +788,7 @@ void wahookickrsnapbike::serviceScanDone(void) {
QSettings settings;
settings.setValue(QZSettings::ftms_bike, bluetoothDevice.name());
settings.sync();
if(homeform::singleton())
if(homeform::singleton())
homeform::singleton()->setToastRequested("Zwift Hub device found, please restart the app to enjoy virtual gearing!");
return;
}
@@ -824,13 +809,13 @@ void wahookickrsnapbike::error(QLowEnergyController::Error err) {
void wahookickrsnapbike::deviceDiscovered(const QBluetoothDeviceInfo &device) {
emit debug(QStringLiteral("Found new device: ") + device.name() + QStringLiteral(" (") +
device.address().toString() + ')');
if (device.name().toUpper().startsWith("WAHOO KICKR")) {
WAHOO_KICKR = true;
qDebug() << "WAHOO KICKR workaround activated";
} else if(device.name().toUpper().startsWith("KICKR BIKE")) {
KICKR_BIKE = true;
qDebug() << "KICKR BIKE workaround activated";
if (device.name().toUpper().startsWith("WAHOO KICKR")) {
WAHOO_KICKR = true;
qDebug() << "WAHOO KICKR workaround activated";
} else if(device.name().toUpper().startsWith("KICKR BIKE")) {
KICKR_BIKE = true;
qDebug() << "KICKR BIKE workaround activated";
} else if(device.name().toUpper().startsWith("KICKR SNAP")) {
KICKR_SNAP = true;
qDebug() << "KICKR SNAP workaround activated";
@@ -916,41 +901,17 @@ void wahookickrsnapbike::controllerStateChanged(QLowEnergyController::Controller
void wahookickrsnapbike::inclinationChanged(double grade, double percentage) {
Q_UNUSED(percentage);
if(lastCommandErgMode) {
lastGrade = grade + 1; // to force a refresh
initRequest = true;
qDebug() << "avoid sending this command, since I have first to restore the setSimGrade";
return;
}
if(lastGrade == grade) {
qDebug() << "grade is already set to " << grade << "skipping";
return;
}
lastGrade = grade;
Inclination = grade;
emit debug(QStringLiteral("writing inclination ") + QString::number(grade));
QSettings settings;
double g = grade;
if(KICKR_SNAP) {
g += gears() * 0.5;
qDebug() << "adding gear offset so " << g;
}
g += gears();
QByteArray a = setSimGrade(g);
uint8_t b[20];
memcpy(b, a.constData(), a.length());
writeCharacteristic(b, a.length(), "setSimGrade", false, false);
lastCommandErgMode = false;
}
bool wahookickrsnapbike::inclinationAvailableByHardware() {
return KICKR_BIKE;
}
double wahookickrsnapbike::maxGears() {
wheelCircumference::GearTable g;
return g.maxGears;
}
double wahookickrsnapbike::minGears() {
return 1;
}
}

View File

@@ -26,7 +26,6 @@
#include <QObject>
#include <QString>
#include "wheelcircumference.h"
#include "devices/bike.h"
#include "virtualdevices/virtualbike.h"
@@ -43,8 +42,6 @@ class wahookickrsnapbike : public bike {
bool connected() override;
resistance_t maxResistance() override { return 100; }
bool inclinationAvailableByHardware() override;
double maxGears() override;
double minGears() override;
enum OperationCode : uint8_t {
_unlock = 32,
@@ -62,7 +59,7 @@ class wahookickrsnapbike : public bike {
// Variabili per iOS (pubbliche per permettere all'implementazione iOS di impostarle)
bool zwift_found = false;
bool wahoo_found = false;
// Wrapper per characteristicChanged che accetta direttamente QBluetoothUuid
void handleCharacteristicValueChanged(const QBluetoothUuid &uuid, const QByteArray &newValue);