Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treadmill Modbus GPIO #1889

Open
wants to merge 139 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
5dd9547
starting to create the gpio module
cagnulein Jan 5, 2022
963beca
first very raw release #525
Jan 11, 2022
5c344a5
fixed zwift interface on gpiotreadmill
cagnulein Jan 13, 2022
ab8fe4f
fix build issue #525
cagnulein Jan 14, 2022
d7e6cf5
fix build issue #525
cagnulein Jan 14, 2022
0aa1284
fix gpio delay #525
cagnulein Jan 14, 2022
5aaa37e
Improve the setting of the speed and the slope
Jan 16, 2022
4e81c60
Merge pull request #587 from december-soul/treadmill-gpio
cagnulein Jan 16, 2022
8539fe9
move GPIO worker into thread
december-soul Jan 25, 2022
5e93ea9
Merge branch 'cagnulein:treadmill-gpio' into treadmill-gpio
december-soul Jan 25, 2022
8a56aab
add descructor to clean up thread
december-soul Jan 25, 2022
9d2ef58
Merge branch 'treadmill-gpio' of https://github.com/december-soul/qdo…
december-soul Jan 25, 2022
477f58c
use semaphore to avoid press simultaneously the buttons
december-soul Jan 27, 2022
6aacfe3
Merge pull request #627 from december-soul/treadmill-gpio
cagnulein Jan 27, 2022
8f41a2c
added connectedAndDiscovered(); to gpiotreadmill
cagnulein Jul 27, 2022
283c101
Merge branch 'master' into treadmill-gpio
cagnulein Jul 27, 2022
f195432
Update bluetooth.cpp
cagnulein Jul 28, 2022
f8f8e6c
Local input for headless mode #938
cagnulein Sep 12, 2022
ad4514a
Local input for headless mode #938
cagnulein Sep 12, 2022
4f30516
Merge branch 'master' into treadmill-gpio
cagnulein Sep 12, 2022
7a58c77
Local input for headless mode #938
cagnulein Sep 12, 2022
7d88f9b
Merge branch 'treadmill-gpio' of https://github.com/cagnulein/qdomyos…
cagnulein Sep 12, 2022
70dff0b
Rename consolereader.h to ConsoleReader.h
cagnulein Sep 13, 2022
21349a6
Rename consolereader.cpp to ConsoleReader.cpp
cagnulein Sep 13, 2022
daa8dca
Update main.cpp
cagnulein Sep 13, 2022
6a16672
fixing inclination calls #938
cagnulein Sep 15, 2022
d693743
Local input for headless mode #938
cagnulein Sep 16, 2022
c9b1002
workaround
cagnulein Sep 17, 2022
94f5c37
disabling qml too if the no-gui selector is enabled
cagnulein Sep 19, 2022
d9034ef
Local input for headless mode #938
cagnulein Sep 26, 2022
5b0bd28
Merge branch 'master' into treadmill-modbus
cagnulein Dec 15, 2023
d136b72
Update qdomyos-zwift.pri
cagnulein Dec 15, 2023
f33f06d
modbus porting completed
cagnulein Dec 15, 2023
9e916bd
Update bluetooth.cpp
cagnulein Dec 15, 2023
6761b1b
fixing CI for the other archs
cagnulein Dec 15, 2023
4a91c37
Update qdomyos-zwift.pri
cagnulein Dec 15, 2023
57c951c
fixing android build
cagnulein Dec 15, 2023
3b15f07
Update gpiotreadmill.h
cagnulein Dec 15, 2023
5b59e5d
removed debug
cagnulein Dec 15, 2023
76bc2bd
debug restored
cagnulein Dec 15, 2023
b44e482
fixing linker
cagnulein Dec 15, 2023
7d7fd41
removing consolereader
cagnulein Dec 15, 2023
6ca55b3
Update qdomyos-zwift.pri
cagnulein Dec 15, 2023
af73de3
Update qdomyos-zwift.pri
cagnulein Dec 15, 2023
a80b66b
Update qdomyos-zwift.pri
cagnulein Dec 15, 2023
536f876
Update main.yml
cagnulein Dec 15, 2023
39a6c74
Update main.yml
cagnulein Dec 15, 2023
a06f9f7
Update main.yml
cagnulein Dec 15, 2023
871b403
Update gpiotreadmill.cpp
cagnulein Dec 15, 2023
f41944f
adapting for http://www.chinalctech.com/m/view.php?aid=490&fbclid=IwA…
cagnulein Dec 15, 2023
4210e2b
fixing init and forcing gpio treadmill
cagnulein Dec 15, 2023
b2d666b
Update gpiotreadmill.cpp
cagnulein Dec 16, 2023
d279bc9
crash fixed
cagnulein Dec 16, 2023
a3aa6f9
speeding up the change
cagnulein Dec 16, 2023
9b8e92b
Update gpiotreadmill.h
cagnulein Dec 16, 2023
550b84e
Update gpiotreadmill.h
cagnulein Dec 16, 2023
62df4cc
close gpiotreadmill.cpp
cagnulein Dec 16, 2023
064b34d
minstepspeed to 0.1
cagnulein Dec 17, 2023
a1c8b9b
Merge branch 'treadmill-modbus' of https://github.com/cagnulein/qdomy…
cagnulein Dec 17, 2023
6153f42
Update gpiotreadmill.cpp
cagnulein Dec 17, 2023
0409ade
key pressed
cagnulein Dec 17, 2023
1b13d8d
Update homeform.cpp
cagnulein Dec 17, 2023
d23115e
modbus error handling
cagnulein Dec 17, 2023
b02c9de
Merge branch 'master' into treadmill-modbus
cagnulein Dec 23, 2023
6fda282
Merge branch 'master' into treadmill-modbus
cagnulein Dec 23, 2023
8043b28
first test on CI
cagnulein Jan 1, 2024
6dd8f6c
Update main.yml
cagnulein Jan 1, 2024
c45c842
Update qdomyos-zwift.pri
cagnulein Jan 1, 2024
eeae2ee
mingw-w64-x86_64-protobuf
cagnulein Jan 1, 2024
6afc73f
Update qdomyos-zwift.pri
cagnulein Jan 1, 2024
10f7387
Update main.yml
cagnulein Jan 1, 2024
128812b
adding protobuf to src folder
cagnulein Jan 1, 2024
5057ddb
Update main.yml
cagnulein Jan 1, 2024
5e5ee11
Update main.yml
cagnulein Jan 1, 2024
8dd29e2
adding absl
cagnulein Jan 3, 2024
ffeb51e
absl from mingw
cagnulein Jan 3, 2024
c3b04dc
building protobuf
cagnulein Jan 3, 2024
58270e7
Update main.yml
cagnulein Jan 3, 2024
9b34624
Update main.yml
cagnulein Jan 3, 2024
6663b2c
Update main.yml
cagnulein Jan 3, 2024
06123b5
Update main.yml
cagnulein Jan 4, 2024
c5e53a9
Update main.yml
cagnulein Jan 4, 2024
cae6726
Update main.yml
cagnulein Jan 4, 2024
0e8bab3
Update main.yml
cagnulein Jan 4, 2024
af0abb3
Update main.yml
cagnulein Jan 4, 2024
9413349
Update main.yml
cagnulein Jan 4, 2024
e4e4952
adding mingw64 binary
cagnulein Jan 4, 2024
b059dd6
adding mingw libabsl
cagnulein Jan 4, 2024
9f758dd
Update main.yml
cagnulein Jan 4, 2024
9de579f
builds on mingw
cagnulein Jan 16, 2024
194ca72
required lib for libabsl
cagnulein Jan 16, 2024
efe0cbc
trying to fix mingw build
cagnulein Jan 16, 2024
6621c83
Update main.yml
cagnulein Jan 16, 2024
a3c0bec
Merge branch 'master' into zwift-api-windows
cagnulein Jan 31, 2024
737f1fa
trying to msvc first
cagnulein Jan 31, 2024
f804c01
Update qdomyos-zwift.pri
cagnulein Jan 31, 2024
49f6fa9
trying to put the protobuf lib on the same src dir
cagnulein Jan 31, 2024
323d051
Merge branch 'master' into zwift-api-windows
cagnulein Feb 26, 2024
4876712
again msvc first
cagnulein Feb 26, 2024
24078a9
JLL T550 #2161
cagnulein Feb 26, 2024
187dd9a
Update main.yml
cagnulein Feb 27, 2024
cbf0c91
Update main.yml
cagnulein Feb 27, 2024
7e12ca0
Update qdomyos-zwift.pri
cagnulein Feb 27, 2024
183e7dc
Revert "Update qdomyos-zwift.pri"
cagnulein Feb 27, 2024
dadaece
adding absl on msvc
cagnulein Feb 27, 2024
6603195
building absl inside protobuf for debug
cagnulein Feb 27, 2024
f23dda5
Update qdomyos-zwift.pri
cagnulein Feb 27, 2024
b5f90bd
adding vcpkg
cagnulein Feb 27, 2024
cd0040c
adding submodule
cagnulein Feb 27, 2024
1beb7f6
vcpkg
cagnulein Feb 27, 2024
f0541b7
Update main.yml
cagnulein Feb 27, 2024
d36b28e
Update main.yml
cagnulein Feb 27, 2024
f6bdbfa
Update main.yml
cagnulein Feb 27, 2024
58b4ddd
Update main.yml
cagnulein Feb 27, 2024
d1f51c4
using vcpkg
cagnulein Feb 27, 2024
598a2a6
Update main.yml
cagnulein Feb 27, 2024
d865887
Update qdomyos-zwift.pri
cagnulein Feb 27, 2024
1cdfb1e
Update qdomyos-zwift.pri
cagnulein Feb 27, 2024
9f4ab19
include removing, using vcpkg
cagnulein Feb 27, 2024
eb52fcf
Update main.yml
cagnulein Feb 27, 2024
d5e795f
Update main.yml
cagnulein Feb 27, 2024
4ac43dc
protobuf
cagnulein Feb 27, 2024
4bb2012
Update trainprogram.cpp
cagnulein Feb 27, 2024
c667974
Update main.yml
cagnulein Feb 27, 2024
571fd08
starting to port the same on linux
cagnulein Feb 27, 2024
4c6401e
Update trainprogram.cpp
cagnulein Feb 27, 2024
24bf95a
Update main.yml
cagnulein Feb 28, 2024
d0f2ab2
Update main.yml
cagnulein Feb 28, 2024
5465e30
Merge branch 'master' into zwift-api-windows
cagnulein Feb 29, 2024
97856b7
Update trainprogram.cpp
cagnulein Feb 29, 2024
6b825c6
Update main.yml
cagnulein Feb 29, 2024
d4c5853
Update qdomyos-zwift.pri
cagnulein Feb 29, 2024
70fd6f9
Update main.yml
cagnulein Feb 29, 2024
23c8628
Merge branch 'master' into zwift-api-windows
cagnulein Feb 29, 2024
8bcacf5
Merge branch 'master' into treadmill-modbus
cagnulein Feb 29, 2024
2cba38c
Merge branch 'zwift-api-windows' into treadmill-modbus
cagnulein Feb 29, 2024
e2feffa
fixing includes
cagnulein Feb 29, 2024
0921c7f
gpio modbus enabled by default
cagnulein Apr 14, 2024
c9692ee
Merge branch 'master' into treadmill-modbus
cagnulein Apr 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
61 changes: 56 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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 .
Expand All @@ -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
Expand All @@ -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/*.* .
Expand Down Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 ..
Expand Down Expand Up @@ -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:
Expand Down
89 changes: 89 additions & 0 deletions src/ConsoleReader.cpp
Original file line number Diff line number Diff line change
@@ -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 changes: 21 additions & 0 deletions src/ConsoleReader.h
Original file line number Diff line number Diff line change
@@ -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 */
7 changes: 7 additions & 0 deletions src/Home.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 31 additions & 1 deletion src/devices/bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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());
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -628,6 +630,23 @@ 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);
Expand Down Expand Up @@ -2756,6 +2775,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;
Expand Down Expand Up @@ -3160,6 +3186,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) {
Expand Down
6 changes: 6 additions & 0 deletions src/devices/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/devices/faketreadmill/faketreadmill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,4 @@ void faketreadmill::changeInclinationRequested(double grade, double percentage)
}

bool faketreadmill::connected() { return true; }
double faketreadmill::minStepSpeed() { return 0.1; }
1 change: 1 addition & 0 deletions src/devices/faketreadmill/faketreadmill.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class faketreadmill : public treadmill {
public:
faketreadmill(bool noWriteResistance, bool noHeartService, bool noVirtualDevice);
bool connected() override;
double minStepSpeed();

private:
QTimer *refresh;
Expand Down