Skip to content

Commit

Permalink
Proform Treadmill 8.5 #1955
Browse files Browse the repository at this point in the history
  • Loading branch information
cagnulein committed Jan 5, 2024
1 parent 85e9d0f commit 0d48bab
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 5 deletions.
133 changes: 130 additions & 3 deletions src/proformtreadmill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ void proformtreadmill::forceIncline(double incline) {
bool nordictrack_s20_treadmill = settings.value(QZSettings::nordictrack_s20_treadmill,
QZSettings::default_nordictrack_s20_treadmill).toBool();
bool proform_treadmill_l6_0s = settings.value(QZSettings::proform_treadmill_l6_0s, QZSettings::default_proform_treadmill_l6_0s).toBool();
bool proform_8_5_treadmill = settings.value(QZSettings::proform_8_5_treadmill, QZSettings::default_proform_8_5_treadmill).toBool();

if (proform_treadmill_1800i) {
uint8_t i = abs(incline * 10);
Expand All @@ -99,7 +100,7 @@ void proformtreadmill::forceIncline(double incline) {

if (norditrack_s25i_treadmill) {
write[14] = write[11] + write[12] + 0x11;
} else if (proform_treadmill_8_0 || proform_treadmill_9_0 || proform_treadmill_se || proform_treadmill_z1300i || proform_treadmill_l6_0s || norditrack_s25_treadmill) {
} else if (proform_treadmill_8_0 || proform_treadmill_9_0 || proform_treadmill_se || proform_treadmill_z1300i || proform_treadmill_l6_0s || norditrack_s25_treadmill || proform_8_5_treadmill) {
write[14] = write[11] + write[12] + 0x12;
} else if (!nordictrack_t65s_treadmill && !nordictrack_s30_treadmill && !nordictrack_s20_treadmill && !nordictrack_t65s_83_treadmill) {
for (uint8_t i = 0; i < 7; i++) {
Expand Down Expand Up @@ -141,6 +142,7 @@ void proformtreadmill::forceSpeed(double speed) {
bool nordictrack_s20_treadmill = settings.value(QZSettings::nordictrack_s20_treadmill,
QZSettings::default_nordictrack_s20_treadmill).toBool();
bool proform_treadmill_l6_0s = settings.value(QZSettings::proform_treadmill_l6_0s, QZSettings::default_proform_treadmill_l6_0s).toBool();
bool proform_8_5_treadmill = settings.value(QZSettings::proform_8_5_treadmill, QZSettings::default_proform_8_5_treadmill).toBool();

uint8_t noOpData7[] = {0xfe, 0x02, 0x0d, 0x02};
uint8_t write[] = {0xff, 0x0d, 0x02, 0x04, 0x02, 0x09, 0x04, 0x09, 0x02, 0x01,
Expand All @@ -152,7 +154,7 @@ void proformtreadmill::forceSpeed(double speed) {
if (norditrack_s25i_treadmill) {
write[14] = write[11] + write[12] + 0x11;
} else if (proform_treadmill_8_0 || proform_treadmill_9_0 || proform_treadmill_se || proform_treadmill_cadence_lt ||
proform_treadmill_z1300i || proform_treadmill_l6_0s || norditrack_s25_treadmill) {
proform_treadmill_z1300i || proform_treadmill_l6_0s || norditrack_s25_treadmill || proform_8_5_treadmill) {
write[14] = write[11] + write[12] + 0x11;
} else if (!nordictrack_t65s_treadmill && !nordictrack_s30_treadmill && !nordictrack_s20_treadmill && !nordictrack_t65s_83_treadmill) {
for (uint8_t i = 0; i < 7; i++) {
Expand Down Expand Up @@ -223,6 +225,7 @@ void proformtreadmill::update() {
bool nordictrack_s20_treadmill = settings.value(QZSettings::nordictrack_s20_treadmill,
QZSettings::default_nordictrack_s20_treadmill).toBool();
bool proform_treadmill_l6_0s = settings.value(QZSettings::proform_treadmill_l6_0s, QZSettings::default_proform_treadmill_l6_0s).toBool();
bool proform_8_5_treadmill = settings.value(QZSettings::proform_8_5_treadmill, QZSettings::default_proform_8_5_treadmill).toBool();
// bool proform_treadmill_995i = settings.value(QZSettings::proform_treadmill_995i,
// QZSettings::default_proform_treadmill_995i).toBool();

Expand Down Expand Up @@ -558,6 +561,69 @@ void proformtreadmill::update() {
if (counterPoll > 5) {
counterPoll = 0;
}
} else if (norditrack_s25i_treadmill) {
uint8_t noOpData1[] = {0xfe, 0x02, 0x19, 0x03};
uint8_t noOpData2[] = {0x00, 0x12, 0x02, 0x04, 0x02, 0x15, 0x04, 0x15, 0x02, 0x00, 0x0f, 0x80, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t noOpData3[] = {0xff, 0x07, 0x00, 0x00, 0x00, 0x80, 0x00, 0x10, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t noOpData4[] = {0xfe, 0x02, 0x17, 0x03};
uint8_t noOpData5[] = {0x00, 0x12, 0x02, 0x04, 0x02, 0x13, 0x04, 0x13, 0x02, 0x00, 0x0d, 0x13, 0x96, 0x31, 0x00, 0x00, 0x40, 0x10, 0x00, 0x80};
uint8_t noOpData6[] = {0xff, 0x05, 0x18, 0x00, 0x00, 0x01, 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

switch (counterPoll) {
case 0:
writeCharacteristic(noOpData1, sizeof(noOpData1), QStringLiteral("noOp"));
break;
case 1:
writeCharacteristic(noOpData2, sizeof(noOpData2), QStringLiteral("noOp"));
break;
case 2:
writeCharacteristic(noOpData3, sizeof(noOpData3), QStringLiteral("noOp"), false, true);
if (requestInclination != -100) {
if (requestInclination < 0)
requestInclination = 0;
if (requestInclination != currentInclination().value() && requestInclination >= 0 &&
requestInclination <= 15) {
emit debug(QStringLiteral("writing incline ") + QString::number(requestInclination));
forceIncline(requestInclination);
}
requestInclination = -100;
}
if (requestSpeed != -1) {
if (requestSpeed != currentSpeed().value() && requestSpeed >= 0 && requestSpeed <= 22) {
emit debug(QStringLiteral("writing speed ") + QString::number(requestSpeed));
forceSpeed(requestSpeed);
}
requestSpeed = -1;
}
break;
case 3:
writeCharacteristic(noOpData4, sizeof(noOpData4), QStringLiteral("noOp"));
break;
case 4:
writeCharacteristic(noOpData5, sizeof(noOpData5), QStringLiteral("noOp"));
break;
case 5:
writeCharacteristic(noOpData6, sizeof(noOpData6), QStringLiteral("noOp"));

if (requestStart != -1) {
emit debug(QStringLiteral("starting..."));

// btinit();

requestStart = -1;
emit tapeStarted();
}
if (requestStop != -1) {
emit debug(QStringLiteral("stopping..."));
// writeCharacteristic(initDataF0C800B8, sizeof(initDataF0C800B8), "stop tape");
requestStop = -1;
}
break;
}
counterPoll++;
if (counterPoll > 5) {
counterPoll = 0;
}
} else if (norditrack_s25i_treadmill) {
uint8_t noOpData1[] = {0xfe, 0x02, 0x19, 0x03};
uint8_t noOpData2[] = {0x00, 0x12, 0x02, 0x04, 0x02, 0x15, 0x04, 0x15, 0x02, 0x00,
Expand Down Expand Up @@ -1566,6 +1632,7 @@ void proformtreadmill::btinit() {
bool nordictrack_s20_treadmill = settings.value(QZSettings::nordictrack_s20_treadmill,
QZSettings::default_nordictrack_s20_treadmill).toBool();
bool proform_treadmill_l6_0s = settings.value(QZSettings::proform_treadmill_l6_0s, QZSettings::default_proform_treadmill_l6_0s).toBool();
bool proform_8_5_treadmill = settings.value(QZSettings::proform_8_5_treadmill, QZSettings::default_proform_8_5_treadmill).toBool();

// bool proform_treadmill_995i = settings.value(QZSettings::proform_treadmill_995i,
// QZSettings::default_proform_treadmill_995i).toBool();
Expand Down Expand Up @@ -1724,6 +1791,66 @@ void proformtreadmill::btinit() {
QThread::msleep(sleepms);
writeCharacteristic(noOpData6, sizeof(noOpData6), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
} else if (proform_8_5_treadmill) {
uint8_t initData1[] = {0xfe, 0x02, 0x08, 0x02};
uint8_t initData2[] = {0xff, 0x08, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0x81, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t initData3[] = {0xfe, 0x02, 0x08, 0x02};
uint8_t initData4[] = {0xff, 0x08, 0x02, 0x04, 0x02, 0x04, 0x04, 0x04, 0x80, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t initData5[] = {0xfe, 0x02, 0x08, 0x02};
uint8_t initData6[] = {0xff, 0x08, 0x02, 0x04, 0x02, 0x04, 0x04, 0x04, 0x88, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t initData7[] = {0xfe, 0x02, 0x0a, 0x02};
uint8_t initData8[] = {0xff, 0x0a, 0x02, 0x04, 0x02, 0x06, 0x02, 0x06, 0x82, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t initData9[] = {0xfe, 0x02, 0x0a, 0x02};
uint8_t initData10[] = {0xff, 0x0a, 0x02, 0x04, 0x02, 0x06, 0x02, 0x06, 0x84, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t initData11[] = {0xfe, 0x02, 0x08, 0x02};
uint8_t initData12[] = {0xff, 0x08, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0x95, 0x9b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t initData13[] = {0xfe, 0x02, 0x2c, 0x04};
uint8_t initData14[] = {0x00, 0x12, 0x02, 0x04, 0x02, 0x28, 0x04, 0x28, 0x90, 0x07, 0x01, 0x72, 0xf4, 0x74, 0xf2, 0x7e, 0x08, 0x80, 0x1e, 0xaa};
uint8_t initData15[] = {0x01, 0x12, 0x3c, 0xcc, 0x5a, 0xe6, 0x90, 0x08, 0xa6, 0x42, 0xe4, 0x84, 0x22, 0xce, 0x98, 0x30, 0xce, 0x9a, 0x2c, 0xfc};
uint8_t initData16[] = {0xff, 0x08, 0x8a, 0x56, 0x20, 0x98, 0x02, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
uint8_t initData17[] = {0xfe, 0x02, 0x19, 0x03};
uint8_t initData18[] = {0x00, 0x12, 0x02, 0x04, 0x02, 0x15, 0x04, 0x15, 0x02, 0x00, 0x0f, 0x00, 0x10, 0x00, 0xd8, 0x1c, 0x48, 0x00, 0x00, 0xe0};
uint8_t initData19[] = {0xff, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x08, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

writeCharacteristic(initData1, sizeof(initData1), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData2, sizeof(initData2), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData3, sizeof(initData3), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData4, sizeof(initData4), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData5, sizeof(initData5), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData6, sizeof(initData6), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData7, sizeof(initData7), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData8, sizeof(initData8), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData9, sizeof(initData9), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData10, sizeof(initData10), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData11, sizeof(initData11), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData12, sizeof(initData12), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData13, sizeof(initData13), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData14, sizeof(initData14), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData15, sizeof(initData15), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData16, sizeof(initData16), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData17, sizeof(initData17), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData18, sizeof(initData18), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(initData19, sizeof(initData19), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);

} else if (proform_pro_1000_treadmill) {
uint8_t initData1[] = {0xfe, 0x02, 0x08, 0x02};
uint8_t initData2[] = {0xff, 0x08, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0x81, 0x87,
Expand Down Expand Up @@ -1793,7 +1920,7 @@ void proformtreadmill::btinit() {
writeCharacteristic(noOpData5, sizeof(noOpData5), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
writeCharacteristic(noOpData6, sizeof(noOpData6), QStringLiteral("init"), false, false);
QThread::msleep(sleepms);
QThread::msleep(sleepms);
} else if (proform_treadmill_z1300i) {
uint8_t initData1[] = {0xfe, 0x02, 0x08, 0x02};
uint8_t initData2[] = {0xff, 0x08, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0x81, 0x87,
Expand Down
4 changes: 3 additions & 1 deletion src/qzsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,9 @@ const QString QZSettings::zwift_password = QStringLiteral("zwift_password");
const QString QZSettings::default_zwift_password = QStringLiteral("");
const QString QZSettings::garmin_bluetooth_compatibility = QStringLiteral("garmin_bluetooth_compatibility");
const QString QZSettings::norditrack_s25_treadmill = QStringLiteral("norditrack_s25_treadmill");
const QString QZSettings::proform_8_5_treadmill = QStringLiteral("proform_8_5_treadmill");

const uint32_t allSettingsCount = 583;
const uint32_t allSettingsCount = 584;

QVariant allSettings[allSettingsCount][2] = {
{QZSettings::cryptoKeySettingsProfiles, QZSettings::default_cryptoKeySettingsProfiles},
Expand Down Expand Up @@ -1287,6 +1288,7 @@ QVariant allSettings[allSettingsCount][2] = {
{QZSettings::zwift_password, QZSettings::default_zwift_password},
{QZSettings::garmin_bluetooth_compatibility, QZSettings::default_garmin_bluetooth_compatibility},
{QZSettings::norditrack_s25_treadmill, QZSettings::default_norditrack_s25_treadmill},
{QZSettings::proform_8_5_treadmill, QZSettings::default_proform_8_5_treadmill},
};

void QZSettings::qDebugAllSettings(bool showDefaults) {
Expand Down
3 changes: 3 additions & 0 deletions src/qzsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,9 @@ class QZSettings {
static const QString norditrack_s25_treadmill;
static constexpr int default_norditrack_s25_treadmill = false;

static const QString proform_8_5_treadmill;
static constexpr int default_proform_8_5_treadmill = false;

/**
* @brief Write the QSettings values using the constants from this namespace.
* @param showDefaults Optionally indicates if the default should be shown with the key.
Expand Down
16 changes: 15 additions & 1 deletion src/settings.qml
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ import QtQuick.Dialogs 1.0
// from version 2.16.31
property bool garmin_bluetooth_compatibility: false
property bool norditrack_s25_treadmill: false
property bool proform_8_5_treadmill: false
}

function paddingZeros(text, limit) {
Expand Down Expand Up @@ -5600,7 +5601,20 @@ import QtQuick.Dialogs 1.0
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillWidth: true
onClicked: {settings.nordictrack_10_treadmill = checked; window.settings_restart_to_apply = true; }
}
}
SwitchDelegate {
text: qsTr("Proform 8.5")
spacing: 0
bottomPadding: 0
topPadding: 0
rightPadding: 0
leftPadding: 0
clip: false
checked: settings.proform_8_5_treadmill
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
Layout.fillWidth: true
onClicked: {settings.proform_8_5_treadmill = checked; window.settings_restart_to_apply = true; }
}
SwitchDelegate {
text: qsTr("Proform Pro 1000")
spacing: 0
Expand Down

0 comments on commit 0d48bab

Please sign in to comment.