mirror of
https://github.com/cagnulein/qdomyos-zwift.git
synced 2026-02-18 00:17:41 +01:00
Compare commits
152 Commits
android36
...
bowflex-tr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
489e8270eb | ||
|
|
a9f7d526f5 | ||
|
|
a860985914 | ||
|
|
7025b76e72 | ||
|
|
7d2128a702 | ||
|
|
b176689bd3 | ||
|
|
386f5daf8b | ||
|
|
26c02db529 | ||
|
|
aafb26671e | ||
|
|
76a7f10a7c | ||
|
|
512fe92767 | ||
|
|
c21d9add7f | ||
|
|
8849b556f5 | ||
|
|
c9692eec61 | ||
|
|
0921c7f0bb | ||
|
|
e2feffaf48 | ||
|
|
2cba38c900 | ||
|
|
8bcacf5b95 | ||
|
|
23c8628e4b | ||
|
|
70fd6f9097 | ||
|
|
d4c5853561 | ||
|
|
6b825c643a | ||
|
|
97856b752c | ||
|
|
5465e30d3d | ||
|
|
d0f2ab2700 | ||
|
|
24bf95a039 | ||
|
|
4c6401e7b9 | ||
|
|
571fd08d8c | ||
|
|
c667974aa2 | ||
|
|
4bb2012049 | ||
|
|
4ac43dc166 | ||
|
|
d5e795f5d6 | ||
|
|
eb52fcf6de | ||
|
|
9f4ab19e28 | ||
|
|
1cdfb1edef | ||
|
|
d865887311 | ||
|
|
598a2a6d3a | ||
|
|
d1f51c47fb | ||
|
|
58b4ddd07c | ||
|
|
f6bdbfa40d | ||
|
|
d36b28e8fe | ||
|
|
f0541b7bbc | ||
|
|
1beb7f69f3 | ||
|
|
cd0040cee3 | ||
|
|
b5f90bd8f7 | ||
|
|
f23dda50f0 | ||
|
|
6603195996 | ||
|
|
dadaece5c3 | ||
|
|
183e7dc0b6 | ||
|
|
7e12ca0476 | ||
|
|
cbf0c91a4b | ||
|
|
187dd9afc6 | ||
|
|
24078a9dc8 | ||
|
|
487671293f | ||
|
|
323d051c7c | ||
|
|
49f6fa9694 | ||
|
|
f804c01fde | ||
|
|
737f1faf47 | ||
|
|
a3c0bec761 | ||
|
|
6621c83452 | ||
|
|
efe0cbcb4c | ||
|
|
194ca721ab | ||
|
|
9de579ffc7 | ||
|
|
9f758ddbec | ||
|
|
b059dd681b | ||
|
|
e4e49524b8 | ||
|
|
9413349277 | ||
|
|
af0abb30a9 | ||
|
|
0e8bab3f34 | ||
|
|
cae67268a6 | ||
|
|
c5e53a920c | ||
|
|
06123b5347 | ||
|
|
6663b2c057 | ||
|
|
9b3462441a | ||
|
|
58270e7bf9 | ||
|
|
c3b04dcccc | ||
|
|
ffeb51eecc | ||
|
|
8dd29e2f5f | ||
|
|
5e5ee11b37 | ||
|
|
5057ddb3ed | ||
|
|
128812b5cd | ||
|
|
10f7387cfb | ||
|
|
6afc73f6fb | ||
|
|
eeae2ee587 | ||
|
|
c45c842f20 | ||
|
|
6dd8f6c831 | ||
|
|
8043b2807d | ||
|
|
6fda282cf7 | ||
|
|
b02c9de46f | ||
|
|
d23115ea8c | ||
|
|
1b13d8d9fd | ||
|
|
0409ade3f4 | ||
|
|
6153f421cd | ||
|
|
a1c8b9b363 | ||
|
|
064b34ddb3 | ||
|
|
62df4cc48f | ||
|
|
550b84ef98 | ||
|
|
9b8e92b838 | ||
|
|
a3aa6f9eeb | ||
|
|
d279bc916b | ||
|
|
b2d666b06d | ||
|
|
4210e2bbef | ||
|
|
f41944ff05 | ||
|
|
871b403b89 | ||
|
|
a06f9f7cc0 | ||
|
|
39a6c7402e | ||
|
|
536f8766f2 | ||
|
|
a80b66b23d | ||
|
|
af73de3889 | ||
|
|
6ca55b32a8 | ||
|
|
7d7fd41172 | ||
|
|
b44e482e8e | ||
|
|
76bc2bd1ff | ||
|
|
5b59e5d2be | ||
|
|
3b15f078e5 | ||
|
|
57c951ccdc | ||
|
|
4a91c37d9f | ||
|
|
6761b1bd0a | ||
|
|
9e916bdf04 | ||
|
|
f33f06d184 | ||
|
|
d136b72604 | ||
|
|
5b0bd28fe0 | ||
|
|
d9034eff3f | ||
|
|
94f5c37667 | ||
|
|
c9b10026e0 | ||
|
|
d6937433da | ||
|
|
6a16672ab1 | ||
|
|
daa8dca053 | ||
|
|
21349a6e06 | ||
|
|
70dff0b78e | ||
|
|
7d88f9b211 | ||
|
|
7a58c776f9 | ||
|
|
4f3051671e | ||
|
|
ad4514a7e3 | ||
|
|
f8f8e6c7ba | ||
|
|
f195432020 | ||
|
|
283c1015f2 | ||
|
|
8f41a2c8d8 | ||
|
|
6aacfe3cb0 | ||
|
|
477f58cf03 | ||
|
|
9d2ef5822d | ||
|
|
8a56aab0ce | ||
|
|
5e93ea947d | ||
|
|
8539fe91ea | ||
|
|
4e81c60370 | ||
|
|
5aaa37ee02 | ||
|
|
0aa1284898 | ||
|
|
d7e6cf51e9 | ||
|
|
ab8fe4f4a6 | ||
|
|
5c344a5a98 | ||
|
|
963becad7c | ||
|
|
5dd9547121 |
61
.github/workflows/main.yml
vendored
61
.github/workflows/main.yml
vendored
@@ -88,7 +88,7 @@ jobs:
|
||||
|
||||
- uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
install: mingw-w64-x86_64-toolchain mingw-w64-x86_64-qt5-webview
|
||||
install: mingw-w64-x86_64-toolchain mingw-w64-x86_64-qt5-webview mingw-w64-x86_64-protobuf mingw-w64-x86_64-abseil-cpp
|
||||
msystem: mingw64
|
||||
release: false
|
||||
|
||||
@@ -135,6 +135,10 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
#cp "C:/mingw64/bin/libabsl*.*" .
|
||||
#cp "C:/mingw64/lib/libabsl*.*" .
|
||||
#cp "C:/mingw64/bin/libproto*.*" .
|
||||
#cp "C:/mingw64/lib/libproto*.*" .
|
||||
qmake
|
||||
make -j8
|
||||
cd src/debug
|
||||
@@ -146,6 +150,11 @@ jobs:
|
||||
cp "C:/mingw64/bin/libwinpthread-1.dll" .
|
||||
cp "C:/mingw64/bin/libgcc_s_seh-1.dll" .
|
||||
cp "C:/mingw64/bin/libstdc++-6.dll" .
|
||||
cp "C:/mingw64/bin/zlib1.dll" .
|
||||
cp "C:/mingw64/bin/libabsl*.*" .
|
||||
cp "C:/mingw64/lib/libabsl*.*" .
|
||||
cp "C:/mingw64/bin/libproto*.*" .
|
||||
cp "C:/mingw64/lib/libproto*.*" .
|
||||
cp ../../../icons/iOS/iTunesArtwork@2x.png .
|
||||
cp ../../AppxManifest.xml .
|
||||
cp ../../windows/*.py .
|
||||
@@ -162,6 +171,10 @@ jobs:
|
||||
|
||||
- name: Build without python
|
||||
run: |
|
||||
#cp "C:/mingw64/bin/libabsl*.*" .
|
||||
#cp "C:/mingw64/lib/libabsl*.*" .
|
||||
#cp "C:/mingw64/bin/libproto*.*" .
|
||||
#cp "C:/mingw64/lib/libproto*.*" .
|
||||
qmake
|
||||
make -j8
|
||||
cd src/debug
|
||||
@@ -173,6 +186,11 @@ jobs:
|
||||
cp "C:/mingw64/bin/libwinpthread-1.dll" .
|
||||
cp "C:/mingw64/bin/libgcc_s_seh-1.dll" .
|
||||
cp "C:/mingw64/bin/libstdc++-6.dll" .
|
||||
cp "C:/mingw64/bin/zlib1.dll" .
|
||||
cp "C:/mingw64/bin/libabsl*.*" .
|
||||
cp "C:/mingw64/lib/libabsl*.*" .
|
||||
cp "C:/mingw64/bin/libproto*.*" .
|
||||
cp "C:/mingw64/lib/libproto*.*" .
|
||||
cp ../../../icons/iOS/iTunesArtwork@2x.png .
|
||||
cp ../../AppxManifest.xml .
|
||||
cp ../../../windows_openssl/*.* .
|
||||
@@ -406,14 +424,14 @@ jobs:
|
||||
path: "src/qthttpserver"
|
||||
|
||||
- name: Install packages required to run QZ inside workflow
|
||||
run: sudo apt update -y && sudo apt-get install -y qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools qtquickcontrols2-5-dev libqt5bluetooth5 libqt5widgets5 libqt5positioning5 libqt5xml5 qtconnectivity5-dev qtpositioning5-dev libqt5charts5-dev libqt5charts5 libqt5networkauth5-dev libqt5websockets5* libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev
|
||||
run: sudo apt update -y && sudo apt-get install -y qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools qtquickcontrols2-5-dev libqt5bluetooth5 libqt5widgets5 libqt5positioning5 libqt5xml5 qtconnectivity5-dev qtpositioning5-dev libqt5charts5-dev libqt5charts5 libqt5networkauth5-dev libqt5serialbus* libqt5websockets5* libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev libxcb-xkb-dev cmake protobuf-compiler libprotobuf-dev
|
||||
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v3
|
||||
with:
|
||||
version: '5.15.2'
|
||||
host: 'linux'
|
||||
modules: 'qtnetworkauth qtcharts'
|
||||
modules: 'qtnetworkauth qtcharts qtserial'
|
||||
cache: 'true'
|
||||
cache-key-prefix: 'install-qt-action-linux'
|
||||
|
||||
@@ -824,8 +842,23 @@ jobs:
|
||||
echo "${{ secrets.cesiumkey }}" >> inner_templates/googlemaps/cesium-key.js
|
||||
cd ..
|
||||
|
||||
- name: Clone vcpkg
|
||||
run: git clone https://github.com/microsoft/vcpkg.git
|
||||
working-directory: ${{ runner.workspace }}
|
||||
|
||||
- name: Bootstrap vcpkg
|
||||
run: .\vcpkg\bootstrap-vcpkg.bat
|
||||
working-directory: ${{ runner.workspace }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: .\vcpkg\vcpkg install protobuf protobuf-c abseil
|
||||
working-directory: ${{ runner.workspace }}
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
Copy-Item -Path ${{ runner.workspace }}\vcpkg\installed\x64-windows\lib\*.* -Destination . -Verbose
|
||||
Copy-Item -Path ${{ runner.workspace }}\vcpkg\installed\x64-windows\lib\*.* -Destination src/ -Verbose
|
||||
Copy-Item -Path ${{ runner.workspace }}\vcpkg\installed\x64-windows\include\* -Destination src/ -Recurse -Verbose
|
||||
qmake
|
||||
nmake
|
||||
cd src/debug
|
||||
@@ -839,6 +872,7 @@ jobs:
|
||||
cp ../../windows/*.py .
|
||||
cp ../../windows/*.bat .
|
||||
cp ../../../windows_openssl/*.* .
|
||||
Copy-Item -Path ${{ runner.workspace }}\vcpkg\installed\x64-windows\bin\*.* -Destination . -Verbose
|
||||
mkdir adb
|
||||
mkdir python
|
||||
Copy-Item -Path C:\hostedtoolcache\windows\Python\3.7.9\x64 -Destination python -Recurse
|
||||
@@ -849,7 +883,10 @@ jobs:
|
||||
if: matrix.config.python
|
||||
|
||||
- name: Build without python
|
||||
run: |
|
||||
run: |
|
||||
Copy-Item -Path ${{ runner.workspace }}\vcpkg\installed\x64-windows\lib\*.* -Destination . -Verbose
|
||||
Copy-Item -Path ${{ runner.workspace }}\vcpkg\installed\x64-windows\lib\*.* -Destination src/ -Verbose
|
||||
Copy-Item -Path ${{ runner.workspace }}\vcpkg\installed\x64-windows\include\* -Destination src/ -Recurse -Verbose
|
||||
qmake
|
||||
nmake
|
||||
cd src/debug
|
||||
@@ -860,10 +897,11 @@ jobs:
|
||||
windeployqt --qmldir ../../ qdomyos-zwift.exe
|
||||
cp "C:/mingw64/bin/libwinpthread-1.dll" .
|
||||
cp "C:/mingw64/bin/libgcc_s_seh-1.dll" .
|
||||
cp "C:/mingw64/bin/libstdc++-6.dll" .
|
||||
cp "C:/mingw64/bin/libstdc++-6.dll" .
|
||||
cp ../../../icons/iOS/iTunesArtwork@2x.png .
|
||||
cp ../../AppxManifest.xml .
|
||||
cp ../../../windows_openssl/*.* .
|
||||
Copy-Item -Path ${{ runner.workspace }}\vcpkg\installed\x64-windows\bin\*.* -Destination . -Verbose
|
||||
mkdir adb
|
||||
cp ../../adb/* adb/
|
||||
cd ..
|
||||
@@ -930,6 +968,19 @@ jobs:
|
||||
repository: qt-labs/qthttpserver
|
||||
path: "src/qthttpserver"
|
||||
|
||||
- name: Install CMake
|
||||
uses: lukka/get-cmake@latest
|
||||
|
||||
- name: Download protobuf
|
||||
run: |
|
||||
Invoke-WebRequest -Uri "https://github.com/protocolbuffers/protobuf/releases/download/v25.1/protobuf-25.1.zip" -OutFile "protobuf.zip"
|
||||
Expand-Archive protobuf.zip -DestinationPath "protobuf"
|
||||
cd protobuf/protobuf-25.1
|
||||
Invoke-WebRequest -Uri "https://github.com/abseil/abseil-cpp/archive/refs/tags/20230802.1.zip" -OutFile "abseil-cpp.zip"
|
||||
Expand-Archive abseil-cpp.zip -DestinationPath "abseil-temp"
|
||||
cp abseil-temp/abseil-cpp-20230802.1/* third_party/abseil-cpp/
|
||||
cmake -Dprotobuf_BUILD_TESTS=OFF CMakeLists.txt
|
||||
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v3
|
||||
with:
|
||||
|
||||
89
src/ConsoleReader.cpp
Normal file
89
src/ConsoleReader.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
//#if defined(Q_OS_LINUX)
|
||||
#if 1
|
||||
#include "ConsoleReader.h"
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static struct termios oldSettings;
|
||||
static struct termios newSettings;
|
||||
|
||||
/* Initialize new terminal i/o settings */
|
||||
void initTermios(int echo) {
|
||||
tcgetattr(0, &oldSettings); /* grab old terminal i/o settings */
|
||||
newSettings = oldSettings; /* make new settings same as old settings */
|
||||
newSettings.c_lflag &= ~ICANON; /* disable buffered i/o */
|
||||
newSettings.c_lflag &= echo ? ECHO : ~ECHO; /* set echo mode */
|
||||
tcsetattr(0, TCSANOW, &newSettings); /* use these new terminal i/o settings now */
|
||||
}
|
||||
|
||||
/* Restore old terminal i/o settings */
|
||||
void resetTermios(void) { tcsetattr(0, TCSANOW, &oldSettings); }
|
||||
|
||||
/* Read 1 character without echo */
|
||||
char getch(void) { return getchar(); }
|
||||
|
||||
ConsoleReader::ConsoleReader(bluetooth *bt) {
|
||||
bluetoothManager = bt;
|
||||
initTermios(0);
|
||||
}
|
||||
|
||||
ConsoleReader::~ConsoleReader() { resetTermios(); }
|
||||
|
||||
void ConsoleReader::run() {
|
||||
forever {
|
||||
char key = getch();
|
||||
qDebug() << "key pressed" << key;
|
||||
if (key == 'q') {
|
||||
if (bluetoothManager->device() && bluetoothManager->device()->deviceType() == bluetoothdevice::TREADMILL) {
|
||||
double speed = ((treadmill *)bluetoothManager->device())->currentSpeed().value();
|
||||
((treadmill *)bluetoothManager->device())->changeSpeed(speed + 0.5);
|
||||
}
|
||||
} else if (key == 'w') {
|
||||
if (bluetoothManager->device() && bluetoothManager->device()->deviceType() == bluetoothdevice::TREADMILL) {
|
||||
double speed = ((treadmill *)bluetoothManager->device())->currentSpeed().value();
|
||||
((treadmill *)bluetoothManager->device())->changeSpeed(speed - 0.5);
|
||||
}
|
||||
} else if (key == 'a') {
|
||||
if (bluetoothManager->device() && bluetoothManager->device()->deviceType() == bluetoothdevice::TREADMILL) {
|
||||
double inclination = ((treadmill *)bluetoothManager->device())->currentInclination().value();
|
||||
((treadmill *)bluetoothManager->device())->changeInclination(inclination + 0.5, inclination + 0.5);
|
||||
}
|
||||
} else if (key == 's') {
|
||||
if (bluetoothManager->device() && bluetoothManager->device()->deviceType() == bluetoothdevice::TREADMILL) {
|
||||
double inclination = ((treadmill *)bluetoothManager->device())->currentInclination().value();
|
||||
((treadmill *)bluetoothManager->device())->changeInclination(inclination - 0.5, inclination - 0.5);
|
||||
}
|
||||
} else if (key == '1') {
|
||||
if (bluetoothManager->device() && bluetoothManager->device()->deviceType() == bluetoothdevice::TREADMILL) {
|
||||
((treadmill *)bluetoothManager->device())->changeSpeed(5);
|
||||
}
|
||||
} else if (key == '2') {
|
||||
if (bluetoothManager->device() && bluetoothManager->device()->deviceType() == bluetoothdevice::TREADMILL) {
|
||||
double inclination = ((treadmill *)bluetoothManager->device())->currentInclination().value();
|
||||
((treadmill *)bluetoothManager->device())->changeInclination(inclination + 0.5, inclination + 0.5);
|
||||
}
|
||||
} else if (key == '3') {
|
||||
if (bluetoothManager->device() && bluetoothManager->device()->deviceType() == bluetoothdevice::TREADMILL) {
|
||||
((treadmill *)bluetoothManager->device())->changeSpeed(10);
|
||||
}
|
||||
} else if (key == '4') {
|
||||
if (bluetoothManager->device() && bluetoothManager->device()->deviceType() == bluetoothdevice::TREADMILL) {
|
||||
double speed = ((treadmill *)bluetoothManager->device())->currentSpeed().value();
|
||||
((treadmill *)bluetoothManager->device())->changeSpeed(speed - 0.5);
|
||||
}
|
||||
} else if (key == '5') {
|
||||
if (bluetoothManager->device() && bluetoothManager->device()->deviceType() == bluetoothdevice::TREADMILL) {
|
||||
double inclination = ((treadmill *)bluetoothManager->device())->currentInclination().value();
|
||||
((treadmill *)bluetoothManager->device())->changeInclination(inclination - 0.5, inclination - 0.5);
|
||||
}
|
||||
} else if (key == '6') {
|
||||
if (bluetoothManager->device() && bluetoothManager->device()->deviceType() == bluetoothdevice::TREADMILL) {
|
||||
double speed = ((treadmill *)bluetoothManager->device())->currentSpeed().value();
|
||||
((treadmill *)bluetoothManager->device())->changeSpeed(speed + 0.5);
|
||||
}
|
||||
}
|
||||
emit KeyPressed(key);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
21
src/ConsoleReader.h
Normal file
21
src/ConsoleReader.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef CONSOLEREADER_H
|
||||
#define CONSOLEREADER_H
|
||||
|
||||
#include "bluetooth.h"
|
||||
#include <QThread>
|
||||
|
||||
class ConsoleReader : public QThread {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void KeyPressed(char ch);
|
||||
|
||||
public:
|
||||
ConsoleReader(bluetooth *bt);
|
||||
~ConsoleReader();
|
||||
void run();
|
||||
|
||||
private:
|
||||
bluetooth *bluetoothManager;
|
||||
};
|
||||
|
||||
#endif /* CONSOLEREADER_H */
|
||||
@@ -23,6 +23,13 @@ HomeForm{
|
||||
signal plus_clicked(string name)
|
||||
signal minus_clicked(string name)
|
||||
signal largeButton_clicked(string name)
|
||||
signal keyPressed(int key)
|
||||
|
||||
Keys.onPressed: (event)=> {
|
||||
console.log("Keys.onPressed " + event.key)
|
||||
// Emit a signal with the pressed key
|
||||
keyPressed(event.key)
|
||||
}
|
||||
|
||||
Settings {
|
||||
id: settings
|
||||
|
||||
@@ -110,6 +110,7 @@ void bluetooth::finished() {
|
||||
QString nordictrack_2950_ip =
|
||||
settings.value(QZSettings::nordictrack_2950_ip, QZSettings::default_nordictrack_2950_ip).toString();
|
||||
QString tdf_10_ip = settings.value(QZSettings::tdf_10_ip, QZSettings::default_tdf_10_ip).toString();
|
||||
bool gpio_treadmill = settings.value(QStringLiteral("gpio_treadmill"), false).toBool();
|
||||
bool fake_bike =
|
||||
settings.value(QZSettings::applewatch_fakedevice, QZSettings::default_applewatch_fakedevice).toBool();
|
||||
bool fakedevice_elliptical =
|
||||
@@ -118,7 +119,7 @@ void bluetooth::finished() {
|
||||
bool fakedevice_treadmill =
|
||||
settings.value(QZSettings::fakedevice_treadmill, QZSettings::default_fakedevice_treadmill).toBool();
|
||||
// wifi devices on windows
|
||||
if (!nordictrack_2950_ip.isEmpty() || !tdf_10_ip.isEmpty() || fake_bike || fakedevice_elliptical || fakedevice_rower || fakedevice_treadmill) {
|
||||
if (!nordictrack_2950_ip.isEmpty() || !tdf_10_ip.isEmpty() || fake_bike || fakedevice_elliptical || fakedevice_rower || fakedevice_treadmill || gpio_treadmill) {
|
||||
// faking a bluetooth device
|
||||
qDebug() << "faking a bluetooth device for nordictrack_2950_ip";
|
||||
deviceDiscovered(QBluetoothDeviceInfo());
|
||||
@@ -409,6 +410,7 @@ void bluetooth::deviceDiscovered(const QBluetoothDeviceInfo &device) {
|
||||
powerSensorName.startsWith(QStringLiteral("Disabled")) || power_as_bike || power_as_treadmill;
|
||||
bool eliteRizerFound = eliteRizerName.startsWith(QStringLiteral("Disabled"));
|
||||
bool eliteSterzoSmartFound = eliteSterzoSmartName.startsWith(QStringLiteral("Disabled"));
|
||||
bool gpio_treadmill = settings.value(QStringLiteral("gpio_treadmill"), false).toBool();
|
||||
bool fake_bike =
|
||||
settings.value(QZSettings::applewatch_fakedevice, QZSettings::default_applewatch_fakedevice).toBool();
|
||||
bool fakedevice_elliptical =
|
||||
@@ -628,6 +630,25 @@ void bluetooth::deviceDiscovered(const QBluetoothDeviceInfo &device) {
|
||||
emit searchingStop();
|
||||
}
|
||||
this->signalBluetoothDeviceConnected(fakeBike);
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
/*
|
||||
} else if (gpio_treadmill && !gpioTreadmill) {
|
||||
discoveryAgent->stop();
|
||||
gpioTreadmill = new gpiotreadmill(pollDeviceTime, noConsole, noHeartService, 0.8, 0);
|
||||
emit deviceConnected(b);
|
||||
connect(gpioTreadmill, &bluetoothdevice::connectedAndDiscovered, this,
|
||||
&bluetooth::connectedAndDiscovered);
|
||||
connect(gpioTreadmill, &gpiotreadmill::debug, this, &bluetooth::debug);
|
||||
connect(gpioTreadmill, &gpiotreadmill::inclinationChanged, this, &bluetooth::inclinationChanged);
|
||||
// connect(cscBike, SIGNAL(disconnected()), this, SLOT(restart()));
|
||||
// connect(this, SIGNAL(searchingStop()), gpioTreadmill, SLOT(searchingStop())); //NOTE: Commented due
|
||||
// to #358
|
||||
if (!discoveryAgent->isActive()) {
|
||||
emit searchingStop();
|
||||
}
|
||||
this->signalBluetoothDeviceConnected(gpioTreadmill);
|
||||
*/
|
||||
#endif
|
||||
} else if (fakedevice_elliptical && !fakeElliptical) {
|
||||
this->stopDiscovery();
|
||||
fakeElliptical = new fakeelliptical(noWriteResistance, noHeartService, false);
|
||||
@@ -2760,6 +2781,13 @@ void bluetooth::restart() {
|
||||
delete fakeBike;
|
||||
fakeBike = nullptr;
|
||||
}
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
if (gpioTreadmill) {
|
||||
|
||||
delete gpioTreadmill;
|
||||
gpioTreadmill = nullptr;
|
||||
}
|
||||
#endif
|
||||
if (fakeElliptical) {
|
||||
|
||||
delete fakeElliptical;
|
||||
@@ -3164,6 +3192,10 @@ bluetoothdevice *bluetooth::device() {
|
||||
return powerTreadmill;
|
||||
} else if (fakeBike) {
|
||||
return fakeBike;
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
} else if (gpioTreadmill) {
|
||||
return gpioTreadmill;
|
||||
#endif
|
||||
} else if (fakeElliptical) {
|
||||
return fakeElliptical;
|
||||
} else if (fakeRower) {
|
||||
|
||||
@@ -92,6 +92,9 @@
|
||||
#include "devices/proformwifitreadmill/proformwifitreadmill.h"
|
||||
#include "devices/schwinn170bike/schwinn170bike.h"
|
||||
#include "devices/schwinnic4bike/schwinnic4bike.h"
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
#include "gpiotreadmill.h"
|
||||
#endif
|
||||
#include "signalhandler.h"
|
||||
#include "devices/skandikawiribike/skandikawiribike.h"
|
||||
#include "devices/smartrowrower/smartrowrower.h"
|
||||
@@ -187,6 +190,9 @@ class bluetooth : public QObject, public SignalHandler {
|
||||
trxappgateusbelliptical *trxappgateusbElliptical = nullptr;
|
||||
echelonconnectsport *echelonConnectSport = nullptr;
|
||||
yesoulbike *yesoulBike = nullptr;
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID))
|
||||
gpiotreadmill *gpioTreadmill = nullptr;
|
||||
#endif
|
||||
flywheelbike *flywheelBike = nullptr;
|
||||
nordictrackelliptical *nordictrackElliptical = nullptr;
|
||||
nordictrackifitadbtreadmill *nordictrackifitadbTreadmill = nullptr;
|
||||
|
||||
@@ -16,6 +16,122 @@ using namespace std::chrono_literals;
|
||||
extern quint8 QZ_EnableDiscoveryCharsAndDescripttors;
|
||||
#endif
|
||||
|
||||
//#define Q_OS_RASPI 0
|
||||
#ifdef Q_OS_RASPI
|
||||
#include <wiringPi.h>
|
||||
#else
|
||||
#define OUTPUT 1
|
||||
QModbusReply *bowflext216treadmill::lastRequest;
|
||||
QModbusClient *bowflext216treadmill::modbusDevice = nullptr;
|
||||
void bowflext216treadmill::digitalWrite(int pin, int state) {
|
||||
const int server_address = 255;
|
||||
QModbusDataUnit writeUnit(QModbusDataUnit::Coils, pin, 1);
|
||||
writeUnit.setValue(0, state);
|
||||
if(modbusDevice) {
|
||||
QModbusReply* r = nullptr;
|
||||
int retry = 0;
|
||||
do {
|
||||
qDebug() << "modbus sending retry" << retry++;
|
||||
r = modbusDevice->sendWriteRequest(writeUnit, server_address);
|
||||
} while(r == nullptr);
|
||||
}
|
||||
else
|
||||
qDebug() << "modbusDevice nullptr!";
|
||||
|
||||
qDebug() << QStringLiteral("switch pin ") + QString::number(pin) + QStringLiteral(" to ") + QString::number(state);
|
||||
}
|
||||
/*
|
||||
void pinMode(int pin, int state) {
|
||||
qDebug() << QStringLiteral("init pin ") + QString::number(pin) + QStringLiteral(" to ") + QString::number(state);
|
||||
}
|
||||
|
||||
int wiringPiSetup() {
|
||||
return 0;
|
||||
}*/
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
modbusWorkerThreadStartStop::modbusWorkerThreadStartStop(QObject *parent, QString name, uint8_t pin, QSemaphore *semaphore): QThread(parent),
|
||||
name{name}, pin{pin}, semaphore{semaphore}
|
||||
{
|
||||
bowflext216treadmill::digitalWrite(pin, 0);
|
||||
}
|
||||
|
||||
|
||||
void modbusWorkerThreadStartStop::toggle()
|
||||
{
|
||||
this->_toggle = true;
|
||||
}
|
||||
|
||||
void modbusWorkerThreadStartStop::run() {
|
||||
if(_toggle) {
|
||||
_toggle = false;
|
||||
semaphore->acquire();
|
||||
bowflext216treadmill::digitalWrite(pin, 1);
|
||||
QThread::msleep(GPIO_KEEP_MS);
|
||||
bowflext216treadmill::digitalWrite(pin, 0);
|
||||
QThread::msleep(GPIO_REBOUND_MS);
|
||||
semaphore->release();
|
||||
}
|
||||
QThread::msleep(50);
|
||||
}
|
||||
|
||||
|
||||
modbusWorkerThread::modbusWorkerThread(QObject *parent, QString name, uint8_t pinUp, uint8_t pinDown, double step, double currentValue, QSemaphore *semaphore): QThread(parent),
|
||||
name{name}, currentValue{currentValue}, pinUp{pinUp}, pinDown{pinDown}, step{step}, semaphore{semaphore}
|
||||
{
|
||||
//pinMode(pinUp, OUTPUT);
|
||||
//pinMode(pinDown, OUTPUT);
|
||||
bowflext216treadmill::digitalWrite(pinUp, 0);
|
||||
bowflext216treadmill::digitalWrite(pinDown, 0);
|
||||
}
|
||||
|
||||
void modbusWorkerThread::setRequestValue(double request)
|
||||
{
|
||||
this->requestValue = request;
|
||||
}
|
||||
|
||||
void modbusWorkerThread::setCurrentValue(double current)
|
||||
{
|
||||
this->currentValue = current;
|
||||
}
|
||||
|
||||
void modbusWorkerThread::run() {
|
||||
if (requestValue > currentValue) {
|
||||
while (requestValue > currentValue) {
|
||||
qDebug() << QStringLiteral("increasing ") + name + " from " + QString::number(currentValue) + " to " + QString::number(requestValue);
|
||||
semaphore->acquire();
|
||||
bowflext216treadmill::digitalWrite(pinUp, 1);
|
||||
QThread::msleep(GPIO_KEEP_MS);
|
||||
bowflext216treadmill::digitalWrite(pinUp, 0);
|
||||
QThread::msleep(GPIO_REBOUND_MS);
|
||||
semaphore->release();
|
||||
currentValue += step;
|
||||
if(QThread::currentThread()->isInterruptionRequested()) {
|
||||
qDebug() << "Interrupting set " + name;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (requestValue < currentValue) {
|
||||
qDebug() << QStringLiteral("decreasing ") + name + " from " + QString::number(currentValue) + " to " + QString::number(requestValue);
|
||||
semaphore->acquire();
|
||||
bowflext216treadmill::digitalWrite(pinDown, 1);
|
||||
QThread::msleep(GPIO_KEEP_MS);
|
||||
bowflext216treadmill::digitalWrite(pinDown, 0);
|
||||
QThread::msleep(GPIO_REBOUND_MS);
|
||||
semaphore->release();
|
||||
currentValue -= step;
|
||||
if(QThread::currentThread()->isInterruptionRequested()) {
|
||||
qDebug() << "Interrupting set " + name;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
QThread::msleep(50);
|
||||
}
|
||||
|
||||
|
||||
bowflext216treadmill::bowflext216treadmill(uint32_t pollDeviceTime, bool noConsole, bool noHeartService,
|
||||
double forceInitSpeed, double forceInitInclination) {
|
||||
|
||||
@@ -34,12 +150,98 @@ bowflext216treadmill::bowflext216treadmill(uint32_t pollDeviceTime, bool noConso
|
||||
if (forceInitInclination > 0)
|
||||
lastInclination = forceInitInclination;
|
||||
|
||||
/*if (wiringPiSetup() == -1) {
|
||||
qDebug() << QStringLiteral("wiringPiSetup ERROR!");
|
||||
exit(1);
|
||||
}*/
|
||||
|
||||
modbusDevice = new QModbusRtuSerialMaster(this);
|
||||
modbusDevice->setConnectionParameter(QModbusDevice::SerialPortNameParameter,
|
||||
"COM4");
|
||||
modbusDevice->setConnectionParameter(QModbusDevice::SerialParityParameter,
|
||||
QSerialPort::Parity::NoParity);
|
||||
modbusDevice->setConnectionParameter(QModbusDevice::SerialBaudRateParameter,
|
||||
QSerialPort::Baud9600);
|
||||
modbusDevice->setConnectionParameter(QModbusDevice::SerialDataBitsParameter,
|
||||
QSerialPort::Data8);
|
||||
modbusDevice->setConnectionParameter(QModbusDevice::SerialStopBitsParameter,
|
||||
QSerialPort::StopBits::OneStop);
|
||||
|
||||
modbusDevice->setTimeout(50);
|
||||
modbusDevice->setNumberOfRetries(3);
|
||||
|
||||
qDebug() << "modbus Connecting...";
|
||||
|
||||
while (!modbusDevice->connectDevice()) {
|
||||
qDebug() << "modbus Connetion Error. Retrying...";
|
||||
}
|
||||
|
||||
qDebug() << "modbus Connected!";
|
||||
|
||||
//pinMode(OUTPUT_START, OUTPUT);
|
||||
//pinMode(OUTPUT_STOP, OUTPUT);
|
||||
//digitalWrite(OUTPUT_START, 0);
|
||||
//digitalWrite(OUTPUT_STOP, 0);
|
||||
|
||||
semaphore = new QSemaphore(1);
|
||||
speedThread = new modbusWorkerThread(this, "speed", OUTPUT_SPEED_UP, OUTPUT_SPEED_DOWN, SPEED_STEP, forceInitSpeed, semaphore);
|
||||
inclineThread = new modbusWorkerThread(this, "incline", OUTPUT_INCLINE_UP, OUTPUT_INCLINE_DOWN, INCLINATION_STEP, forceInitInclination, semaphore);
|
||||
startThread = new modbusWorkerThreadStartStop(this, "start", OUTPUT_START, semaphore);
|
||||
stopThread = new modbusWorkerThreadStartStop(this, "stop", OUTPUT_STOP, semaphore);
|
||||
|
||||
|
||||
refresh = new QTimer(this);
|
||||
initDone = false;
|
||||
connect(refresh, &QTimer::timeout, this, &bowflext216treadmill::update);
|
||||
refresh->start(500ms);
|
||||
}
|
||||
|
||||
bowflext216treadmill::~bowflext216treadmill() {
|
||||
speedThread->requestInterruption();
|
||||
speedThread->quit();
|
||||
speedThread->wait();
|
||||
delete speedThread;
|
||||
inclineThread->requestInterruption();
|
||||
inclineThread->quit();
|
||||
inclineThread->wait();
|
||||
delete inclineThread;
|
||||
delete semaphore;
|
||||
modbusDevice->disconnectDevice();
|
||||
}
|
||||
|
||||
void bowflext216treadmill::forceSpeed(double requestSpeed) {
|
||||
qDebug() << QStringLiteral("gpiotreadmill.cpp: request set speed ") + QString::number(Speed.value()) + QStringLiteral(" to ") + QString::number(requestSpeed);
|
||||
if (speedThread->isRunning())
|
||||
{
|
||||
speedThread->requestInterruption();
|
||||
speedThread->quit();
|
||||
speedThread->wait();
|
||||
|
||||
}
|
||||
speedThread->setCurrentValue(currentSpeed().value());
|
||||
speedThread->setRequestValue(requestSpeed);
|
||||
speedThread->start();
|
||||
|
||||
Speed = requestSpeed; /* we are on the way to the requested speed */
|
||||
}
|
||||
|
||||
void bowflext216treadmill::forceIncline(double requestIncline) {
|
||||
qDebug() << QStringLiteral("gpiotreadmill.cpp: request set Incline ") + QString::number(Inclination.value()) + QStringLiteral(" to ") + QString::number(requestIncline);
|
||||
|
||||
if (inclineThread->isRunning())
|
||||
{
|
||||
inclineThread->requestInterruption();
|
||||
inclineThread->quit();
|
||||
inclineThread->wait();
|
||||
|
||||
}
|
||||
inclineThread->setCurrentValue(currentInclination().value());
|
||||
inclineThread->setRequestValue(requestIncline);
|
||||
inclineThread->start();
|
||||
|
||||
Inclination = requestIncline; /* we are on the way to the requested incline */
|
||||
}
|
||||
|
||||
void bowflext216treadmill::writeCharacteristic(uint8_t *data, uint8_t data_len, const QString &info, bool disable_log,
|
||||
bool wait_for_response) {
|
||||
QEventLoop loop;
|
||||
@@ -76,12 +278,9 @@ void bowflext216treadmill::writeCharacteristic(uint8_t *data, uint8_t data_len,
|
||||
|
||||
void bowflext216treadmill::updateDisplay(uint16_t elapsed) {}
|
||||
|
||||
void bowflext216treadmill::forceIncline(double requestIncline) {}
|
||||
|
||||
double bowflext216treadmill::minStepSpeed() { return 1.60934 / 10.0; }
|
||||
double bowflext216treadmill::minStepInclination() { return 1.0; }
|
||||
|
||||
void bowflext216treadmill::forceSpeed(double requestSpeed) {}
|
||||
|
||||
void bowflext216treadmill::update() {
|
||||
if (m_control->state() == QLowEnergyController::UnconnectedState) {
|
||||
emit disconnected();
|
||||
@@ -148,19 +347,13 @@ void bowflext216treadmill::update() {
|
||||
}
|
||||
|
||||
if (requestStart != -1) {
|
||||
uint8_t start[] = {0x07, 0x06, 0xcf, 0x00, 0x1f, 0x05, 0x00};
|
||||
emit debug(QStringLiteral("starting..."));
|
||||
if (lastSpeed == 0.0) {
|
||||
lastSpeed = 0.5;
|
||||
}
|
||||
writeCharacteristic(start, sizeof(start), QStringLiteral("start"), false, true);
|
||||
startThread->toggle();
|
||||
|
||||
requestStart = -1;
|
||||
emit tapeStarted();
|
||||
}
|
||||
if (requestStop != -1 || requestPause != -1) {
|
||||
uint8_t stop[] = {0x0a, 0x08, 0x7a, 0x00, 0x19, 0x28, 0x01, 0x32, 0x00, 0x00};
|
||||
emit debug(QStringLiteral("stopping..."));
|
||||
writeCharacteristic(stop, sizeof(stop), QStringLiteral("stop"), false, true);
|
||||
stopThread->toggle();
|
||||
requestStop = -1;
|
||||
requestPause = -1;
|
||||
}
|
||||
@@ -218,7 +411,7 @@ void bowflext216treadmill::characteristicChanged(const QLowEnergyCharacteristic
|
||||
}
|
||||
}
|
||||
emit debug(QStringLiteral("Current speed: ") + QString::number(speed));
|
||||
// emit debug(QStringLiteral("Current incline: ") + QString::number(incline));
|
||||
emit debug(QStringLiteral("Current incline: ") + QString::number(incline));
|
||||
// emit debug(QStringLiteral("Current KCal: ") + QString::number(kcal));
|
||||
// debug("Current Distance: " + QString::number(distance));
|
||||
|
||||
|
||||
@@ -25,20 +25,91 @@
|
||||
#include <QDateTime>
|
||||
#include <QObject>
|
||||
|
||||
#include <QThread>
|
||||
#include <QSemaphore>
|
||||
|
||||
#include <QtSerialBus/QModbusClient>
|
||||
#include <QtSerialBus/QModbusDataUnit>
|
||||
#include <QtSerialBus/QModbusReply>
|
||||
#include <QtSerialBus/QModbusRtuSerialMaster>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
|
||||
#include "treadmill.h"
|
||||
|
||||
class modbusWorkerThreadStartStop : public QThread
|
||||
{
|
||||
public:
|
||||
explicit modbusWorkerThreadStartStop(QObject *parent, QString name = "", uint8_t pin = 0, QSemaphore *semaphore = nullptr);
|
||||
void run();
|
||||
void toggle();
|
||||
private:
|
||||
bool _toggle = false;
|
||||
QString name;
|
||||
uint8_t pin;
|
||||
const uint16_t GPIO_KEEP_MS = 1;
|
||||
const uint16_t GPIO_REBOUND_MS = 175;
|
||||
QSemaphore *semaphore;
|
||||
};
|
||||
|
||||
class modbusWorkerThread : public QThread
|
||||
{
|
||||
public:
|
||||
explicit modbusWorkerThread(QObject *parent, QString name = "", uint8_t pinUp = 0, uint8_t pinDown = 0, double step = 0.0, double currentValue = 0.0, QSemaphore *semaphore = nullptr);
|
||||
void run();
|
||||
void setRequestValue(double request);
|
||||
void setCurrentValue(double current);
|
||||
private:
|
||||
QString name;
|
||||
double requestValue;
|
||||
double currentValue;
|
||||
uint8_t pinUp;
|
||||
uint8_t pinDown;
|
||||
double step;
|
||||
const uint16_t GPIO_KEEP_MS = 1;
|
||||
const uint16_t GPIO_REBOUND_MS = 175;
|
||||
QSemaphore *semaphore;
|
||||
};
|
||||
|
||||
class bowflext216treadmill : public treadmill {
|
||||
Q_OBJECT
|
||||
public:
|
||||
bowflext216treadmill(uint32_t poolDeviceTime = 200, bool noConsole = false, bool noHeartService = false,
|
||||
double forceInitSpeed = 0.0, double forceInitInclination = 0.0);
|
||||
~bowflext216treadmill();
|
||||
bool connected() override;
|
||||
double minStepSpeed() override;
|
||||
double minStepInclination() override;
|
||||
bool autoPauseWhenSpeedIsZero() override;
|
||||
bool autoStartWhenSpeedIsGreaterThenZero() override;
|
||||
bool canHandleSpeedChange() override { return false; }
|
||||
bool canHandleInclineChange() override { return false; }
|
||||
|
||||
static void digitalWrite(int pin, int state);
|
||||
static QModbusReply *lastRequest;
|
||||
static QModbusClient *modbusDevice;
|
||||
|
||||
private:
|
||||
|
||||
const uint8_t OUTPUT_SPEED_UP = 0;
|
||||
const uint8_t OUTPUT_SPEED_DOWN = 1;
|
||||
const uint8_t OUTPUT_INCLINE_UP = 2;
|
||||
const uint8_t OUTPUT_INCLINE_DOWN = 3;
|
||||
const uint8_t OUTPUT_START = 4;
|
||||
const uint8_t OUTPUT_STOP = 5;
|
||||
|
||||
const uint16_t GPIO_KEEP_MS = 50;
|
||||
const uint16_t GPIO_REBOUND_MS = 200;
|
||||
|
||||
const double SPEED_STEP = 1.60934 / 10.0;
|
||||
const double INCLINATION_STEP = 1.0;
|
||||
|
||||
modbusWorkerThread* speedThread;
|
||||
modbusWorkerThread* inclineThread;
|
||||
modbusWorkerThreadStartStop* startThread;
|
||||
modbusWorkerThreadStartStop* stopThread;
|
||||
QSemaphore *semaphore; // my treadmill don't like it if the buttons will be pressed simultanly
|
||||
|
||||
|
||||
double GetSpeedFromPacket(const QByteArray &packet);
|
||||
double GetInclinationFromPacket(const QByteArray &packet);
|
||||
double GetKcalFromPacket(const QByteArray &packet);
|
||||
|
||||
@@ -131,3 +131,4 @@ void faketreadmill::changeInclinationRequested(double grade, double percentage)
|
||||
}
|
||||
|
||||
bool faketreadmill::connected() { return true; }
|
||||
double faketreadmill::minStepSpeed() { return 0.1; }
|
||||
|
||||
@@ -39,6 +39,7 @@ class faketreadmill : public treadmill {
|
||||
public:
|
||||
faketreadmill(bool noWriteResistance, bool noHeartService, bool noVirtualDevice);
|
||||
bool connected() override;
|
||||
double minStepSpeed();
|
||||
|
||||
private:
|
||||
QTimer *refresh;
|
||||
|
||||
366
src/gpiotreadmill.cpp
Normal file
366
src/gpiotreadmill.cpp
Normal file
@@ -0,0 +1,366 @@
|
||||
#include "gpiotreadmill.h"
|
||||
#include "ios/lockscreen.h"
|
||||
#include "keepawakehelper.h"
|
||||
#include "virtualdevices/virtualtreadmill.h"
|
||||
#include <QBluetoothLocalDevice>
|
||||
#include <QDateTime>
|
||||
#include <QFile>
|
||||
#include <QMetaEnum>
|
||||
#include <QSettings>
|
||||
#include <chrono>
|
||||
//#define Q_OS_RASPI 0
|
||||
#ifdef Q_OS_RASPI
|
||||
#include <wiringPi.h>
|
||||
#else
|
||||
#define OUTPUT 1
|
||||
QModbusReply *gpiotreadmill::lastRequest;
|
||||
QModbusClient *gpiotreadmill::modbusDevice = nullptr;
|
||||
void gpiotreadmill::digitalWrite(int pin, int state) {
|
||||
const int server_address = 255;
|
||||
QModbusDataUnit writeUnit(QModbusDataUnit::Coils, pin, 1);
|
||||
writeUnit.setValue(0, state);
|
||||
if(modbusDevice) {
|
||||
QModbusReply* r = nullptr;
|
||||
int retry = 0;
|
||||
do {
|
||||
qDebug() << "modbus sending retry" << retry++;
|
||||
r = modbusDevice->sendWriteRequest(writeUnit, server_address);
|
||||
} while(r == nullptr);
|
||||
}
|
||||
else
|
||||
qDebug() << "modbusDevice nullptr!";
|
||||
|
||||
qDebug() << QStringLiteral("switch pin ") + QString::number(pin) + QStringLiteral(" to ") + QString::number(state);
|
||||
}
|
||||
|
||||
void pinMode(int pin, int state) {
|
||||
qDebug() << QStringLiteral("init pin ") + QString::number(pin) + QStringLiteral(" to ") + QString::number(state);
|
||||
}
|
||||
|
||||
int wiringPiSetup() {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
|
||||
gpioWorkerThread::gpioWorkerThread(QObject *parent, QString name, uint8_t pinUp, uint8_t pinDown, double step, double currentValue, QSemaphore *semaphore): QThread(parent),
|
||||
name{name}, currentValue{currentValue}, pinUp{pinUp}, pinDown{pinDown}, step{step}, semaphore{semaphore}
|
||||
{
|
||||
pinMode(pinUp, OUTPUT);
|
||||
pinMode(pinDown, OUTPUT);
|
||||
gpiotreadmill::digitalWrite(pinUp, 0);
|
||||
gpiotreadmill::digitalWrite(pinDown, 0);
|
||||
}
|
||||
|
||||
void gpioWorkerThread::setRequestValue(double request)
|
||||
{
|
||||
this->requestValue = request;
|
||||
}
|
||||
|
||||
void gpioWorkerThread::run() {
|
||||
if (requestValue > currentValue) {
|
||||
while (requestValue > currentValue) {
|
||||
qDebug() << QStringLiteral("increasing ") + name + " from " + QString::number(currentValue) + " to " + QString::number(requestValue);
|
||||
semaphore->acquire();
|
||||
gpiotreadmill::digitalWrite(pinUp, 1);
|
||||
QThread::msleep(GPIO_KEEP_MS);
|
||||
gpiotreadmill::digitalWrite(pinUp, 0);
|
||||
QThread::msleep(GPIO_REBOUND_MS);
|
||||
semaphore->release();
|
||||
currentValue += step;
|
||||
if(QThread::currentThread()->isInterruptionRequested()) {
|
||||
qDebug() << "Interrupting set " + name;
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (requestValue < currentValue) {
|
||||
qDebug() << QStringLiteral("decreasing ") + name + " from " + QString::number(currentValue) + " to " + QString::number(requestValue);
|
||||
semaphore->acquire();
|
||||
gpiotreadmill::digitalWrite(pinDown, 1);
|
||||
QThread::msleep(GPIO_KEEP_MS);
|
||||
gpiotreadmill::digitalWrite(pinDown, 0);
|
||||
QThread::msleep(GPIO_REBOUND_MS);
|
||||
semaphore->release();
|
||||
currentValue -= step;
|
||||
if(QThread::currentThread()->isInterruptionRequested()) {
|
||||
qDebug() << "Interrupting set " + name;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
QThread::msleep(50);
|
||||
}
|
||||
|
||||
gpiotreadmill::gpiotreadmill(uint32_t pollDeviceTime, bool noConsole, bool noHeartService, double forceInitSpeed,
|
||||
double forceInitInclination) {
|
||||
m_watt.setType(metric::METRIC_WATT);
|
||||
Speed.setType(metric::METRIC_SPEED);
|
||||
this->noConsole = noConsole;
|
||||
this->noHeartService = noHeartService;
|
||||
|
||||
if (wiringPiSetup() == -1) {
|
||||
qDebug() << QStringLiteral("wiringPiSetup ERROR!");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
modbusDevice = new QModbusRtuSerialMaster(this);
|
||||
modbusDevice->setConnectionParameter(QModbusDevice::SerialPortNameParameter,
|
||||
"COM4");
|
||||
modbusDevice->setConnectionParameter(QModbusDevice::SerialParityParameter,
|
||||
QSerialPort::Parity::NoParity);
|
||||
modbusDevice->setConnectionParameter(QModbusDevice::SerialBaudRateParameter,
|
||||
QSerialPort::Baud9600);
|
||||
modbusDevice->setConnectionParameter(QModbusDevice::SerialDataBitsParameter,
|
||||
QSerialPort::Data8);
|
||||
modbusDevice->setConnectionParameter(QModbusDevice::SerialStopBitsParameter,
|
||||
QSerialPort::StopBits::OneStop);
|
||||
|
||||
modbusDevice->setTimeout(50);
|
||||
modbusDevice->setNumberOfRetries(3);
|
||||
|
||||
qDebug() << "modbus Connecting...";
|
||||
|
||||
while (!modbusDevice->connectDevice()) {
|
||||
qDebug() << "modbus Connetion Error. Retrying...";
|
||||
}
|
||||
|
||||
qDebug() << "modbus Connected!";
|
||||
|
||||
|
||||
pinMode(OUTPUT_START, OUTPUT);
|
||||
pinMode(OUTPUT_STOP, OUTPUT);
|
||||
digitalWrite(OUTPUT_START, 0);
|
||||
digitalWrite(OUTPUT_STOP, 0);
|
||||
|
||||
if (forceInitSpeed > 0) {
|
||||
lastSpeed = forceInitSpeed;
|
||||
}
|
||||
|
||||
if (forceInitInclination > 0) {
|
||||
lastInclination = forceInitInclination;
|
||||
}
|
||||
|
||||
semaphore = new QSemaphore(1);
|
||||
speedThread = new gpioWorkerThread(this, "speed", OUTPUT_SPEED_UP, OUTPUT_SPEED_DOWN, SPEED_STEP, forceInitSpeed, semaphore);
|
||||
inclineThread = new gpioWorkerThread(this, "incline", OUTPUT_INCLINE_UP, OUTPUT_INCLINE_DOWN, INCLINATION_STEP, forceInitInclination, semaphore);
|
||||
|
||||
refresh = new QTimer(this);
|
||||
initDone = false;
|
||||
connect(refresh, &QTimer::timeout, this, &gpiotreadmill::update);
|
||||
refresh->start(pollDeviceTime);
|
||||
|
||||
Speed = 1.60934;
|
||||
}
|
||||
|
||||
gpiotreadmill::~gpiotreadmill() {
|
||||
speedThread->requestInterruption();
|
||||
speedThread->quit();
|
||||
speedThread->wait();
|
||||
delete speedThread;
|
||||
inclineThread->requestInterruption();
|
||||
inclineThread->quit();
|
||||
inclineThread->wait();
|
||||
delete inclineThread;
|
||||
delete semaphore;
|
||||
modbusDevice->disconnectDevice();
|
||||
}
|
||||
|
||||
void gpiotreadmill::onReadReady() {
|
||||
|
||||
}
|
||||
|
||||
void gpiotreadmill::changeInclinationRequested(double grade, double percentage) {
|
||||
if (percentage < 0)
|
||||
percentage = 0;
|
||||
changeInclination(grade, percentage);
|
||||
}
|
||||
|
||||
void gpiotreadmill::forceSpeed(double requestSpeed) {
|
||||
qDebug() << QStringLiteral("gpiotreadmill.cpp: request set speed ") + QString::number(Speed.value()) + QStringLiteral(" to ") + QString::number(requestSpeed);
|
||||
if (speedThread->isRunning())
|
||||
{
|
||||
speedThread->requestInterruption();
|
||||
speedThread->quit();
|
||||
speedThread->wait();
|
||||
|
||||
}
|
||||
speedThread->setRequestValue(requestSpeed);
|
||||
speedThread->start();
|
||||
|
||||
Speed = requestSpeed; /* we are on the way to the requested speed */
|
||||
}
|
||||
|
||||
void gpiotreadmill::forceIncline(double requestIncline) {
|
||||
qDebug() << QStringLiteral("gpiotreadmill.cpp: request set Incline ") + QString::number(Inclination.value()) + QStringLiteral(" to ") + QString::number(requestIncline);
|
||||
|
||||
if (inclineThread->isRunning())
|
||||
{
|
||||
inclineThread->requestInterruption();
|
||||
inclineThread->quit();
|
||||
inclineThread->wait();
|
||||
|
||||
}
|
||||
inclineThread->setRequestValue(requestIncline);
|
||||
inclineThread->start();
|
||||
|
||||
Inclination = requestIncline; /* we are on the way to the requested incline */
|
||||
}
|
||||
|
||||
void gpiotreadmill::update() {
|
||||
|
||||
QSettings settings;
|
||||
// ******************************************* virtual treadmill init *************************************
|
||||
if (!firstInit && !virtualTreadMill && !virtualBike) {
|
||||
bool virtual_device_enabled = settings.value("virtual_device_enabled", true).toBool();
|
||||
bool virtual_device_force_bike = settings.value("virtual_device_force_bike", false).toBool();
|
||||
|
||||
emit connectedAndDiscovered();
|
||||
|
||||
if (virtual_device_enabled) {
|
||||
if (!virtual_device_force_bike) {
|
||||
qDebug() << "creating virtual treadmill interface...";
|
||||
virtualTreadMill = new virtualtreadmill(this, noHeartService);
|
||||
connect(virtualTreadMill, &virtualtreadmill::debug, this, &gpiotreadmill::debug);
|
||||
connect(virtualTreadMill, &virtualtreadmill::changeInclination, this,
|
||||
&gpiotreadmill::changeInclinationRequested);
|
||||
} else {
|
||||
qDebug() <<"creating virtual bike interface...";
|
||||
virtualBike = new virtualbike(this);
|
||||
connect(virtualBike, &virtualbike::changeInclination, this, &gpiotreadmill::changeInclinationRequested);
|
||||
}
|
||||
firstInit = 1;
|
||||
}
|
||||
}
|
||||
// ********************************************************************************************************
|
||||
|
||||
// debug("Domyos Treadmill RSSI " + QString::number(bluetoothDevice.rssi()));
|
||||
|
||||
double heart = 0;
|
||||
QString heartRateBeltName =
|
||||
settings.value(QStringLiteral("heart_rate_belt_name"), QStringLiteral("Disabled")).toString();
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
if (settings.value("ant_heart", false).toBool())
|
||||
Heart = (uint8_t)KeepAwakeHelper::heart();
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (heartRateBeltName.startsWith(QStringLiteral("Disabled"))) {
|
||||
|
||||
if (heart == 0) {
|
||||
|
||||
#ifdef Q_OS_IOS
|
||||
#ifndef IO_UNDER_QT
|
||||
lockscreen h;
|
||||
long appleWatchHeartRate = h.heartRate();
|
||||
h.setKcal(KCal.value());
|
||||
h.setDistance(Distance.value());
|
||||
Heart = appleWatchHeartRate;
|
||||
qDebug() << "Current Heart from Apple Watch: " << QString::number(appleWatchHeartRate);
|
||||
#endif
|
||||
#endif
|
||||
} else
|
||||
|
||||
Heart = heart;
|
||||
}
|
||||
}
|
||||
|
||||
if (!firstCharacteristicChanged) {
|
||||
if (watts(settings.value(QStringLiteral("weight"), 75.0).toFloat()))
|
||||
KCal +=
|
||||
((((0.048 * ((double)watts(settings.value(QStringLiteral("weight"), 75.0).toFloat())) + 1.19) *
|
||||
settings.value(QStringLiteral("weight"), 75.0).toFloat() * 3.5) /
|
||||
200.0) /
|
||||
(60000.0 / ((double)lastTimeCharacteristicChanged.msecsTo(
|
||||
QDateTime::currentDateTime())))); //(( (0.048* Output in watts +1.19) * body weight in
|
||||
// kg * 3.5) / 200 ) / 60
|
||||
Distance += ((Speed.value() / (double)3600.0) /
|
||||
((double)1000.0 / (double)(lastTimeCharacteristicChanged.msecsTo(QDateTime::currentDateTime()))));
|
||||
lastTimeCharacteristicChanged = QDateTime::currentDateTime();
|
||||
}
|
||||
|
||||
qDebug() << QStringLiteral("Current speed: ") + QString::number(Speed.value());
|
||||
qDebug() << QStringLiteral("Current incline: ") + QString::number(Inclination.value());
|
||||
qDebug() << QStringLiteral("Current heart: ") + QString::number(Heart.value());
|
||||
qDebug() << QStringLiteral("Current KCal: ") + QString::number(KCal.value());
|
||||
qDebug() << QStringLiteral("Current KCal from the machine: ") + QString::number(KCal.value());
|
||||
qDebug() << QStringLiteral("Current Distance: ") + QString::number(Distance.value());
|
||||
qDebug() << QStringLiteral("Current Distance Calculated: ") + QString::number(Distance.value());
|
||||
|
||||
firstCharacteristicChanged = false;
|
||||
|
||||
update_metrics(true, watts(settings.value(QStringLiteral("weight"), 75.0).toFloat()));
|
||||
|
||||
// updating the treadmill console every second
|
||||
if (sec1Update++ >= (1000 / refresh->interval())) {
|
||||
}
|
||||
|
||||
// byte 3 - 4 = elapsed time
|
||||
// byte 17 = inclination
|
||||
{
|
||||
if (requestSpeed != -1) {
|
||||
if (requestSpeed != currentSpeed().value() && requestSpeed >= 0 && requestSpeed <= 22) {
|
||||
qDebug() << QStringLiteral("writing speed ") + QString::number(requestSpeed);
|
||||
|
||||
forceSpeed(requestSpeed);
|
||||
}
|
||||
requestSpeed = -1;
|
||||
}
|
||||
if (requestInclination != -1) {
|
||||
// only 0.5 steps ara avaiable
|
||||
requestInclination = qRound(requestInclination * 2.0) / 2.0;
|
||||
if (requestInclination != currentInclination().value() && requestInclination >= 0 &&
|
||||
requestInclination <= 15) {
|
||||
qDebug() << QStringLiteral("writing incline ") + QString::number(requestInclination);
|
||||
|
||||
forceIncline(requestInclination);
|
||||
}
|
||||
requestInclination = -1;
|
||||
}
|
||||
if (requestStart != -1) {
|
||||
qDebug() << QStringLiteral("starting...");
|
||||
if (lastSpeed == 0.0) {
|
||||
|
||||
lastSpeed = 0.5;
|
||||
}
|
||||
digitalWrite(OUTPUT_START, 1);
|
||||
QThread::msleep(GPIO_KEEP_MS);
|
||||
digitalWrite(OUTPUT_START, 0);
|
||||
requestStart = -1;
|
||||
emit tapeStarted();
|
||||
}
|
||||
if (requestStop != -1) {
|
||||
qDebug() << QStringLiteral("stopping...");
|
||||
digitalWrite(OUTPUT_STOP, 1);
|
||||
QThread::msleep(GPIO_KEEP_MS);
|
||||
digitalWrite(OUTPUT_STOP, 0);
|
||||
requestStop = -1;
|
||||
}
|
||||
if (requestFanSpeed != -1) {
|
||||
qDebug() << QStringLiteral("changing fan speed...");
|
||||
|
||||
requestFanSpeed = -1;
|
||||
}
|
||||
if (requestIncreaseFan != -1) {
|
||||
qDebug() << QStringLiteral("increasing fan speed...");
|
||||
|
||||
requestIncreaseFan = -1;
|
||||
} else if (requestDecreaseFan != -1) {
|
||||
qDebug() << QStringLiteral("decreasing fan speed...");
|
||||
|
||||
requestDecreaseFan = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool gpiotreadmill::connected() { return true; }
|
||||
|
||||
void *gpiotreadmill::VirtualTreadMill() { return virtualTreadMill; }
|
||||
|
||||
void *gpiotreadmill::VirtualDevice() { return VirtualTreadMill(); }
|
||||
|
||||
void gpiotreadmill::searchingStop() { searchStopped = true; }
|
||||
double gpiotreadmill::minStepSpeed() { return 1.60934 / 10.0; }
|
||||
double gpiotreadmill::minStepInclination() { return 1; }
|
||||
141
src/gpiotreadmill.h
Normal file
141
src/gpiotreadmill.h
Normal file
@@ -0,0 +1,141 @@
|
||||
#ifndef GPIOTREADMILL_H
|
||||
#define GPIOTREADMILL_H
|
||||
|
||||
#include <QBluetoothDeviceDiscoveryAgent>
|
||||
#include <QtBluetooth/qlowenergyadvertisingdata.h>
|
||||
#include <QtBluetooth/qlowenergyadvertisingparameters.h>
|
||||
#include <QtBluetooth/qlowenergycharacteristic.h>
|
||||
#include <QtBluetooth/qlowenergycharacteristicdata.h>
|
||||
|
||||
#include <QtBluetooth/qlowenergycontroller.h>
|
||||
#include <QtBluetooth/qlowenergydescriptordata.h>
|
||||
#include <QtBluetooth/qlowenergyservice.h>
|
||||
#include <QtBluetooth/qlowenergyservicedata.h>
|
||||
|
||||
#include <QtCore/qbytearray.h>
|
||||
|
||||
#ifndef Q_OS_ANDROID
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#else
|
||||
#include <QtGui/qguiapplication.h>
|
||||
#endif
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
#include <QtCore/qscopedpointer.h>
|
||||
#include <QtCore/qtimer.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QSemaphore>
|
||||
|
||||
#include <QtSerialBus/QModbusClient>
|
||||
#include <QtSerialBus/QModbusDataUnit>
|
||||
#include <QtSerialBus/QModbusReply>
|
||||
#include <QtSerialBus/QModbusRtuSerialMaster>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
|
||||
#include "devices/treadmill.h"
|
||||
#include "virtualdevices/virtualbike.h"
|
||||
#include "virtualdevices/virtualtreadmill.h"
|
||||
|
||||
#ifdef Q_OS_IOS
|
||||
#include "ios/lockscreen.h"
|
||||
#endif
|
||||
|
||||
class gpioWorkerThread : public QThread
|
||||
{
|
||||
public:
|
||||
explicit gpioWorkerThread(QObject *parent, QString name = "", uint8_t pinUp = 0, uint8_t pinDown = 0, double step = 0.0, double currentValue = 0.0, QSemaphore *semaphore = nullptr);
|
||||
void run();
|
||||
void setRequestValue(double request);
|
||||
private:
|
||||
QString name;
|
||||
double requestValue;
|
||||
double currentValue;
|
||||
uint8_t pinUp;
|
||||
uint8_t pinDown;
|
||||
double step;
|
||||
const uint16_t GPIO_KEEP_MS = 1;
|
||||
const uint16_t GPIO_REBOUND_MS = 175;
|
||||
QSemaphore *semaphore;
|
||||
};
|
||||
|
||||
|
||||
class gpiotreadmill : public treadmill {
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
gpiotreadmill(uint32_t poolDeviceTime = 200, bool noConsole = false, bool noHeartService = false,
|
||||
double forceInitSpeed = 1.0, double forceInitInclination = 0.0);
|
||||
~gpiotreadmill();
|
||||
bool connected();
|
||||
|
||||
void *VirtualTreadMill();
|
||||
void *VirtualDevice();
|
||||
|
||||
static void digitalWrite(int pin, int state);
|
||||
static QModbusReply *lastRequest;
|
||||
static QModbusClient *modbusDevice;
|
||||
|
||||
double minStepSpeed();
|
||||
double minStepInclination() override;
|
||||
|
||||
private:
|
||||
bool noConsole = false;
|
||||
bool noHeartService = false;
|
||||
uint32_t pollDeviceTime = 200;
|
||||
bool searchStopped = false;
|
||||
uint8_t sec1Update = 0;
|
||||
uint8_t firstInit = 0;
|
||||
QDateTime lastTimeCharacteristicChanged;
|
||||
bool firstCharacteristicChanged = true;
|
||||
|
||||
QTimer *refresh;
|
||||
virtualtreadmill *virtualTreadMill = nullptr;
|
||||
virtualbike *virtualBike = 0;
|
||||
|
||||
bool initDone = false;
|
||||
bool initRequest = false;
|
||||
|
||||
const uint8_t OUTPUT_SPEED_UP = 0;
|
||||
const uint8_t OUTPUT_SPEED_DOWN = 1;
|
||||
const uint8_t OUTPUT_INCLINE_UP = 2;
|
||||
const uint8_t OUTPUT_INCLINE_DOWN = 3;
|
||||
const uint8_t OUTPUT_START = 4;
|
||||
const uint8_t OUTPUT_STOP = 5;
|
||||
|
||||
const uint16_t GPIO_KEEP_MS = 50;
|
||||
//const uint16_t GPIO_REBOUND_MS = 200;
|
||||
|
||||
const double SPEED_STEP = 1.60934 / 10.0;
|
||||
const double INCLINATION_STEP = 1.0;
|
||||
|
||||
void forceSpeed(double requestSpeed);
|
||||
void forceIncline(double requestIncline);
|
||||
gpioWorkerThread* speedThread;
|
||||
gpioWorkerThread* inclineThread;
|
||||
QSemaphore *semaphore; // my treadmill don't like it if the buttons will be pressed simultanly
|
||||
|
||||
#ifdef Q_OS_IOS
|
||||
lockscreen *h = 0;
|
||||
#endif
|
||||
|
||||
Q_SIGNALS:
|
||||
void disconnected();
|
||||
void debug(QString string);
|
||||
void speedChanged(double speed);
|
||||
void packetReceived();
|
||||
|
||||
public slots:
|
||||
void searchingStop();
|
||||
|
||||
private slots:
|
||||
|
||||
void changeInclinationRequested(double grade, double percentage);
|
||||
void onReadReady();
|
||||
|
||||
void update();
|
||||
};
|
||||
|
||||
#endif // GPIOTREADMILL_H
|
||||
@@ -2511,6 +2511,7 @@ void homeform::deviceConnected(QBluetoothDeviceInfo b) {
|
||||
QObject::connect(home, SIGNAL(plus_clicked(QString)), this, SLOT(Plus(QString)));
|
||||
QObject::connect(home, SIGNAL(minus_clicked(QString)), this, SLOT(Minus(QString)));
|
||||
QObject::connect(home, SIGNAL(largeButton_clicked(QString)), this, SLOT(LargeButton(QString)));
|
||||
QObject::connect(home, SIGNAL(keyPressed(int)), this, SLOT(keyPressed(int)));
|
||||
|
||||
emit workoutNameChanged(workoutName());
|
||||
emit instructorNameChanged(instructorName());
|
||||
@@ -2547,6 +2548,17 @@ void homeform::deviceConnected(QBluetoothDeviceInfo b) {
|
||||
}
|
||||
}
|
||||
|
||||
void homeform::keyPressed(int key) {
|
||||
if(key == Qt::Key_A)
|
||||
Plus("speed");
|
||||
else if(key == Qt::Key_S)
|
||||
Minus("speed");
|
||||
else if(key == Qt::Key_D)
|
||||
Plus("inclination");
|
||||
else if(key == Qt::Key_F)
|
||||
Minus("inclination");
|
||||
}
|
||||
|
||||
void homeform::deviceFound(const QString &name) {
|
||||
if (name.trimmed().isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -760,6 +760,7 @@ class homeform : public QObject {
|
||||
void Minus(const QString &);
|
||||
void Plus(const QString &);
|
||||
void LargeButton(const QString &);
|
||||
void keyPressed(int key);
|
||||
void volumeDown();
|
||||
void volumeUp();
|
||||
void keyMediaPrevious();
|
||||
|
||||
27
src/main.cpp
27
src/main.cpp
@@ -66,6 +66,7 @@ bool service_changed = false;
|
||||
bool bike_wheel_revs = false;
|
||||
bool run_cadence_sensor = false;
|
||||
bool nordictrack_10_treadmill = false;
|
||||
bool gpiotreadmill = true;
|
||||
bool reebok_fr30_treadmill = false;
|
||||
QString trainProgram;
|
||||
QString deviceName = QLatin1String("");
|
||||
@@ -132,6 +133,8 @@ QCoreApplication *createApplication(int &argc, char *argv[]) {
|
||||
run_cadence_sensor = true;
|
||||
if (!qstrcmp(argv[i], "-nordictrack-10-treadmill"))
|
||||
nordictrack_10_treadmill = true;
|
||||
if (!qstrcmp(argv[i], "-gpiotreadmill"))
|
||||
gpiotreadmill = true;
|
||||
if (!qstrcmp(argv[i], "-reebok_fr30_treadmill"))
|
||||
reebok_fr30_treadmill = true;
|
||||
if (!qstrcmp(argv[i], "-test-peloton"))
|
||||
@@ -380,20 +383,22 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||
else {
|
||||
settings.setValue(QZSettings::miles_unit, miles);
|
||||
settings.setValue(QZSettings::bluetooth_no_reconnection, bluetooth_no_reconnection);
|
||||
settings.setValue(QZSettings::bluetooth_relaxed, bluetooth_relaxed);
|
||||
settings.setValue(QZSettings::bike_cadence_sensor, bike_cadence_sensor);
|
||||
settings.setValue(QZSettings::bike_power_sensor, bike_power_sensor);
|
||||
settings.setValue(QZSettings::battery_service, battery_service);
|
||||
settings.setValue(QZSettings::service_changed, service_changed);
|
||||
settings.setValue(QZSettings::bike_wheel_revs, bike_wheel_revs);
|
||||
settings.setValue(QZSettings::run_cadence_sensor, run_cadence_sensor);
|
||||
settings.setValue(QZSettings::nordictrack_10_treadmill, nordictrack_10_treadmill);
|
||||
settings.setValue(QZSettings::reebok_fr30_treadmill, reebok_fr30_treadmill);
|
||||
settings.setValue(QStringLiteral("miles_unit"), miles);
|
||||
settings.setValue(QStringLiteral("bluetooth_no_reconnection"), bluetooth_no_reconnection);
|
||||
settings.setValue(QStringLiteral("bluetooth_relaxed"), bluetooth_relaxed);
|
||||
settings.setValue(QStringLiteral("bike_cadence_sensor"), bike_cadence_sensor);
|
||||
settings.setValue(QStringLiteral("bike_power_sensor"), bike_power_sensor);
|
||||
settings.setValue(QStringLiteral("battery_service"), battery_service);
|
||||
settings.setValue(QStringLiteral("service_changed"), service_changed);
|
||||
settings.setValue(QStringLiteral("bike_wheel_revs"), bike_wheel_revs);
|
||||
settings.setValue(QStringLiteral("run_cadence_sensor"), run_cadence_sensor);
|
||||
settings.setValue(QStringLiteral("nordictrack_10_treadmill"), nordictrack_10_treadmill);
|
||||
settings.setValue(QStringLiteral("reebok_fr30_treadmill"), reebok_fr30_treadmill);
|
||||
}
|
||||
#endif
|
||||
|
||||
settings.setValue(QStringLiteral("gpio_treadmill"), gpiotreadmill);
|
||||
|
||||
#ifdef Q_OS_ANDROID
|
||||
if (settings.value(QZSettings::volume_change_gears, QZSettings::default_volume_change_gears).toBool()) {
|
||||
qDebug() << "handling volume keys";
|
||||
|
||||
18
src/qdomyos-zwift.pri
Executable file → Normal file
18
src/qdomyos-zwift.pri
Executable file → Normal file
@@ -3,6 +3,9 @@ QT += bluetooth widgets xml positioning quick networkauth websockets texttospeec
|
||||
QTPLUGIN += qavfmediaplayer
|
||||
QT+= charts
|
||||
|
||||
win32: QT += serialport serialbus
|
||||
linux:!android: QT += serialport serialbus
|
||||
|
||||
qtHaveModule(httpserver) {
|
||||
QT += httpserver
|
||||
DEFINES += Q_HTTPSERVER
|
||||
@@ -30,6 +33,10 @@ CONFIG += qmltypes
|
||||
#win32: CONFIG += webengine
|
||||
#unix:!android: CONFIG += webengine
|
||||
|
||||
win32:DEFINES += _ITERATOR_DEBUG_LEVEL=0
|
||||
win32:LIBS += -llibprotobuf -llibprotoc -labseil_dll -llibprotobuf-lite -L$$PWD
|
||||
unix:!android:LIBS += -lprotoc -lprotobuf -labsl_base
|
||||
|
||||
QML_IMPORT_NAME = org.cagnulein.qdomyoszwift
|
||||
QML_IMPORT_MAJOR_VERSION = 1
|
||||
# Additional import path used to resolve QML modules in Qt Creator's code model
|
||||
@@ -279,6 +286,14 @@ zwiftworkout.cpp
|
||||
macx: SOURCES += macos/lockscreen.mm
|
||||
!ios: SOURCES += mainwindow.cpp charts.cpp
|
||||
|
||||
#gpio treadmill
|
||||
win32: SOURCES += gpiotreadmill.cpp
|
||||
linux:!android: SOURCES += gpiotreadmill.cpp
|
||||
|
||||
#zwift api
|
||||
unix:!android: SOURCES += zwift-api/zwift_messages.pb.cc
|
||||
win32: SOURCES += zwift-api/zwift_messages.pb.cc
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
@@ -718,6 +733,9 @@ windows_zwift_incline_paddleocr_thread.h \
|
||||
zwiftworkout.h
|
||||
|
||||
|
||||
win32: HEADERS += gpiotreadmill.h
|
||||
linux:!android: HEADERS += gpiotreadmill.h
|
||||
|
||||
exists(secret.h): HEADERS += secret.h
|
||||
|
||||
!ios: HEADERS += charts.h
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
#include "windows_zwift_incline_paddleocr_thread.h"
|
||||
#include "windows_zwift_workout_paddleocr_thread.h"
|
||||
#endif
|
||||
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||
#include "zwift-api/zwift_messages.pb.h"
|
||||
#endif
|
||||
#include "localipaddress.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
@@ -654,6 +657,18 @@ void trainprogram::scheduler() {
|
||||
|
||||
float alt = QAndroidJniObject::callStaticMethod<float>("org/cagnulen/qdomyoszwift/ZwiftAPI", "getAltitude", "()F");
|
||||
float distance = QAndroidJniObject::callStaticMethod<float>("org/cagnulen/qdomyoszwift/ZwiftAPI", "getDistance", "()F");
|
||||
#elif !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||
PlayerState state;
|
||||
float alt = 0;
|
||||
float distance = 0;
|
||||
if (state.ParseFromArray(bb.constData(), bb.size())) {
|
||||
// Parsing riuscito, ora puoi accedere ai dati in `state`
|
||||
alt = state.altitude();
|
||||
distance = state.distance();
|
||||
} else {
|
||||
// Errore durante il parsing
|
||||
qDebug() << "Error parsing PlayerState";
|
||||
}
|
||||
#else
|
||||
float alt = 0;
|
||||
float distance = 0;
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
#include "zwift-api/PlayerStateWrapper.h"
|
||||
#include "zwift-api/zwift_client_auth.h"
|
||||
|
||||
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
|
||||
#include "zwift-api/zwift_messages.pb.h"
|
||||
#endif
|
||||
|
||||
class trainrow {
|
||||
public:
|
||||
QTime duration = QTime(0, 0, 0, 0);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user