mirror of
https://github.com/cagnulein/qdomyos-zwift.git
synced 2026-02-18 00:17:41 +01:00
Compare commits
7 Commits
opencv_and
...
pelotonbik
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df3068a003 | ||
|
|
00425a5c0d | ||
|
|
e5d753aeb1 | ||
|
|
1da8cf3338 | ||
|
|
723009261b | ||
|
|
0c465e41fc | ||
|
|
f05b201595 |
@@ -85,10 +85,6 @@
|
||||
android:name=".ScreenCaptureService"
|
||||
android:foregroundServiceType="mediaProjection" />
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.mlkit.vision.DEPENDENCIES"
|
||||
android:value="ocr" />
|
||||
|
||||
<activity android:name="org.cagnulen.qdomyoszwift.MyActivity" />
|
||||
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
||||
</application>
|
||||
|
||||
@@ -22,7 +22,7 @@ dependencies {
|
||||
compile 'com.rvalerio:fgchecker:1.1.0'
|
||||
implementation "androidx.core:core-ktx:+"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0"
|
||||
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:18.0.2'
|
||||
implementation 'com.google.mlkit:text-recognition:16.0.0-beta6'
|
||||
implementation 'com.google.android.play:core:1.8.2'
|
||||
|
||||
def appcompat_version = "1.3.1"
|
||||
|
||||
54
src/android/src/ShellRuntime.java
Normal file
54
src/android/src/ShellRuntime.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package org.cagnulen.qdomyoszwift;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class ShellRuntime {
|
||||
private static final String LOG_TAG = "QZ:Shell";
|
||||
|
||||
private static final Runtime runtime = Runtime.getRuntime();
|
||||
private static String sh = null;
|
||||
|
||||
static String lastLine;
|
||||
|
||||
public static String lastOutput() {
|
||||
return lastLine;
|
||||
}
|
||||
|
||||
public static void execAndGetOutput(String command) throws IOException {
|
||||
Process proc = exec(command);
|
||||
BufferedReader is = new BufferedReader(new InputStreamReader(proc.getInputStream()));
|
||||
String line;
|
||||
lastLine = "";
|
||||
while ((line = is.readLine()) != null) {
|
||||
//Log.d(LOG_TAG, line);
|
||||
lastLine = lastLine + line;
|
||||
}
|
||||
}
|
||||
|
||||
public static Process exec(String command) throws IOException {
|
||||
String[] cmd = {getSh(), "-c", " " + command};
|
||||
return runtime.exec(cmd);
|
||||
}
|
||||
|
||||
private static String getSh() {
|
||||
if(sh == null) {
|
||||
sh = "/bin/sh";
|
||||
|
||||
try {
|
||||
execAndGetOutput("ls");
|
||||
} catch (final Exception ex) {
|
||||
Log.w(LOG_TAG, "Calling " + sh + " failed", ex);
|
||||
sh = "/system/bin/sh";
|
||||
}
|
||||
|
||||
Log.d(LOG_TAG, "Using sh: " + sh);
|
||||
}
|
||||
|
||||
return sh;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <QThread>
|
||||
|
||||
class androidadblog : public QThread
|
||||
{
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
@@ -376,11 +376,11 @@ homeform::homeform(QQmlApplicationEngine *engine, bluetooth *bl) {
|
||||
stravaWorkoutName = QLatin1String("");
|
||||
movieFileName = QUrl("");
|
||||
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_MAC) && !defined(Q_OS_IOS))
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_MAC) && !defined(Q_OS_IOS)) || defined(PELOTONBIKE)
|
||||
#ifndef STEAM_STORE
|
||||
connect(engine, &QQmlApplicationEngine::quit, &QGuiApplication::quit);
|
||||
connect(&tLicense, &QTimer::timeout, this, &homeform::licenseTimeout);
|
||||
tLicense.start(600000);
|
||||
tLicense.start(1200000);
|
||||
licenseRequest();
|
||||
#endif
|
||||
#endif
|
||||
@@ -5643,7 +5643,7 @@ int homeform::preview_workout_points() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_MAC) && !defined(Q_OS_IOS))
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_MAC) && !defined(Q_OS_IOS)) || defined(PELOTONBIKE)
|
||||
void homeform::licenseReply(QNetworkReply *reply) {
|
||||
QString r = reply->readAll();
|
||||
qDebug() << r;
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include <QQuickItemGrabResult>
|
||||
#include <QTextToSpeech>
|
||||
|
||||
#define PELOTONBIKE
|
||||
|
||||
class DataObject : public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
@@ -653,7 +655,7 @@ class homeform : public QObject {
|
||||
QTextToSpeech m_speech;
|
||||
int tts_summary_count = 0;
|
||||
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_MAC) && !defined(Q_OS_IOS))
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_MAC) && !defined(Q_OS_IOS)) || defined(PELOTONBIKE)
|
||||
QTimer tLicense;
|
||||
QNetworkAccessManager *mgr = nullptr;
|
||||
void licenseRequest();
|
||||
@@ -728,7 +730,7 @@ class homeform : public QObject {
|
||||
void pelotonOffset_Minus();
|
||||
int pelotonOffset() { return (trainProgram ? trainProgram->offsetElapsedTime() : 0); }
|
||||
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_MAC) && !defined(Q_OS_IOS))
|
||||
#if defined(Q_OS_WIN) || (defined(Q_OS_MAC) && !defined(Q_OS_IOS)) || defined(PELOTONBIKE)
|
||||
void licenseReply(QNetworkReply *reply);
|
||||
void licenseTimeout();
|
||||
#endif
|
||||
|
||||
@@ -57,6 +57,46 @@ void pelotonbike::update() {
|
||||
"org/cagnulen/qdomyoszwift/ScreenCaptureService", "getLastText");
|
||||
QString t = text.toString();
|
||||
qDebug() << "OCR" << t;
|
||||
|
||||
QStringList list = t.split('\n');
|
||||
bool waitCadence = false;
|
||||
bool waitPower = false;
|
||||
bool waitResistance = false;
|
||||
bool waitSpeed = false;
|
||||
foreach(QString l, list) {
|
||||
if(l.startsWith("CADENCE")) {
|
||||
waitCadence = true;
|
||||
} else if(l.startsWith("RESISTANCE")) {
|
||||
waitResistance = true;
|
||||
} else if(l.startsWith("OUTPUT")) {
|
||||
waitPower = true;
|
||||
} else if(l.startsWith("SPEED")) {
|
||||
waitSpeed = true;
|
||||
} else if(waitCadence) {
|
||||
waitCadence = false;
|
||||
Cadence = l.toInt();
|
||||
} else if(waitPower) {
|
||||
waitPower = false;
|
||||
m_watt = l.toInt();
|
||||
} else if(waitResistance) {
|
||||
waitResistance = false;
|
||||
Resistance = l.toInt();
|
||||
} else if(waitSpeed) {
|
||||
waitSpeed = false;
|
||||
Speed = l.split(" ").first().toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
QAndroidJniObject adb = QAndroidJniObject::callStaticObjectMethod<jstring>(
|
||||
"org/cagnulen/qdomyoszwift/ShellRuntime", "lastOutput");
|
||||
QString tAdb = adb.toString();
|
||||
qDebug() << "ADB lastOutput" << tAdb;
|
||||
|
||||
QString command = "logcat -d | grep \"V1Callback\"";
|
||||
QAndroidJniObject commandString = QAndroidJniObject::fromString(command);
|
||||
QAndroidJniObject::callStaticMethod<void>(
|
||||
"org/cagnulen/qdomyoszwift/ShellRuntime", "execAndGetOutput","(Ljava/lang/String;)V", commandString.object<jstring>());
|
||||
|
||||
#endif
|
||||
|
||||
QString heartRateBeltName =
|
||||
|
||||
@@ -673,6 +673,7 @@ DISTFILES += \
|
||||
$$PWD/android/src/MediaProjection.java \
|
||||
$$PWD/android/src/NotificationUtils.java \
|
||||
$$PWD/android/src/ScreenCaptureService.java \
|
||||
$$PWD/android/src/ShellRuntime.java \
|
||||
.clang-format \
|
||||
AppxManifest.xml \
|
||||
android/AndroidManifest.xml \
|
||||
|
||||
Reference in New Issue
Block a user