diff --git a/daemon/src/devices/abstractdevice.h b/daemon/src/devices/abstractdevice.h index 79293e60..2436d58c 100644 --- a/daemon/src/devices/abstractdevice.h +++ b/daemon/src/devices/abstractdevice.h @@ -60,7 +60,8 @@ class AbstractDevice : public QBLEDevice SETTING_DEVICE_DATE, SETTING_DEVICE_TIME, SETTING_DEVICE_UNIT, - SETTING_DISCONNECT_NOTIFICATION + SETTING_DISCONNECT_NOTIFICATION, + SETTING_DEVICE_REALTIME_HRM_MEASUREMENT }; Q_ENUM(Settings) diff --git a/daemon/src/devices/huamidevice.cpp b/daemon/src/devices/huamidevice.cpp index f28b82a8..28f599a7 100644 --- a/daemon/src/devices/huamidevice.cpp +++ b/daemon/src/devices/huamidevice.cpp @@ -1,6 +1,7 @@ #include "huamidevice.h" #include "bipfirmwareinfo.h" #include "updatefirmwareoperation.h" +#include "amazfishconfig.h" #include @@ -305,6 +306,9 @@ void HuamiDevice::applyDeviceSetting(Settings s) case SETTING_DISCONNECT_NOTIFICATION: mi->setDisconnectNotification(); break; + case SETTING_DEVICE_REALTIME_HRM_MEASUREMENT: + hrm->enableRealtimeHRMeasurement(AmazfishConfig::instance()->deviceRealtimeHRMMeasurement()); + break; } } diff --git a/daemon/src/devices/pinetimejfdevice.cpp b/daemon/src/devices/pinetimejfdevice.cpp index b88a938a..4d6cd72e 100644 --- a/daemon/src/devices/pinetimejfdevice.cpp +++ b/daemon/src/devices/pinetimejfdevice.cpp @@ -216,6 +216,8 @@ void PinetimeJFDevice::initialise() HRMService *hrm = qobject_cast(service(HRMService::UUID_SERVICE_HRM)); if (hrm) { + hrm->enableRealtimeHRMeasurement(AmazfishConfig::instance()->deviceRealtimeHRMMeasurement()); + connect(hrm, &HRMService::informationChanged, this, &AbstractDevice::informationChanged, Qt::UniqueConnection); connect(hrm, &HRMService::informationChanged, &realtimeActivitySample, &RealtimeActivitySample::slot_informationChanged, Qt::UniqueConnection); } @@ -506,10 +508,24 @@ void PinetimeJFDevice::sendWeather(CurrentWeather *weather) } } +void PinetimeJFDevice::applyDeviceSetting(Settings s) +{ + + HRMService *hrm = qobject_cast(service(HRMService::UUID_SERVICE_HRM)); + switch(s) { + case SETTING_DEVICE_REALTIME_HRM_MEASUREMENT: + if (hrm) { + hrm->enableRealtimeHRMeasurement(AmazfishConfig::instance()->deviceRealtimeHRMMeasurement()); + } + break; + } + +} + void PinetimeJFDevice::immediateAlert(int level) { ImmediateAlertService *ias = qobject_cast(service(ImmediateAlertService::UUID_SERVICE_IMMEDIATE_ALERT)); if (ias) { ias->sendAlert((ImmediateAlertService::Levels)level); } -} \ No newline at end of file +} diff --git a/daemon/src/devices/pinetimejfdevice.h b/daemon/src/devices/pinetimejfdevice.h index 69ee0438..4e523817 100644 --- a/daemon/src/devices/pinetimejfdevice.h +++ b/daemon/src/devices/pinetimejfdevice.h @@ -36,6 +36,7 @@ class PinetimeJFDevice : public AbstractDevice //Weather void sendWeather(CurrentWeather *weather) override; + virtual void applyDeviceSetting(Settings s); virtual void immediateAlert(int level) override; protected: diff --git a/daemon/src/services/hrmservice.cpp b/daemon/src/services/hrmservice.cpp index e5a883a3..c36ff7d3 100644 --- a/daemon/src/services/hrmservice.cpp +++ b/daemon/src/services/hrmservice.cpp @@ -19,7 +19,6 @@ void HRMService::characteristicChanged(const QString &characteristic, const QByt qDebug() << Q_FUNC_INFO << "Changed:" << characteristic << value; if (characteristic == UUID_CHARACTERISTIC_HRM_MEASUREMENT) { - qDebug() << "..got HR measurement"; if (value.length() == 2 && value[0] == 0) { m_heartRate = (value[1] & 0xff); emit informationChanged(AbstractDevice::INFO_HEARTRATE, QString::number(m_heartRate)); diff --git a/daemon/src/services/infinitimemotionservice.cpp b/daemon/src/services/infinitimemotionservice.cpp index be2baca4..51326be8 100644 --- a/daemon/src/services/infinitimemotionservice.cpp +++ b/daemon/src/services/infinitimemotionservice.cpp @@ -33,7 +33,6 @@ void InfiniTimeMotionService::characteristicChanged(const QString &characteristi qDebug() << Q_FUNC_INFO << characteristic << value.toHex(); if (characteristic == UUID_CHARACTERISTIC_MOTION_STEPS) { - qDebug() << "...Got realtime steps:" << value.length(); if (value.length() == 4) { m_steps = TypeConversion::toUint32(value[0], value[1], value[2], value[3]); emit informationChanged(AbstractDevice::INFO_STEPS, QString::number(m_steps)); diff --git a/lib/src/amazfish.h b/lib/src/amazfish.h index 0ac2154c..73cd8b28 100644 --- a/lib/src/amazfish.h +++ b/lib/src/amazfish.h @@ -73,7 +73,8 @@ class Amazfish : public QObject { SETTING_DEVICE_DATE, SETTING_DEVICE_TIME, SETTING_DEVICE_UNIT, - SETTING_DISCONNECT_NOTIFICATION + SETTING_DISCONNECT_NOTIFICATION, + SETTING_DEVICE_REALTIME_HRM_MEASUREMENT }; Q_ENUM(Settings) diff --git a/lib/src/amazfishconfig.h b/lib/src/amazfishconfig.h index 6e60d170..93f17fa0 100644 --- a/lib/src/amazfishconfig.h +++ b/lib/src/amazfishconfig.h @@ -139,6 +139,7 @@ class AmazfishConfig : public QObject INT_OPTION(QStringLiteral("app/refreshweather"), appRefreshWeather, setAppRefreshWeather, 80) INT_OPTION(QStringLiteral("app/refreshcalendar"), appRefreshCalendar, setAppRefreshCalendar, 60) + BOOL_OPTION(QStringLiteral("device/realtimehrmmeasurement"), deviceRealtimeHRMMeasurement, setdeviceRealtimeHRMMeasurement, false) BOOL_OPTION(QStringLiteral("device/disconnectnotification"), deviceDisconnectNotification, setDeviceDisconnectNotification, false) BOOL_OPTION(QStringLiteral("device/displayweathershortcut"), deviceDisplayWeatherShortcut, setDeviceDisplayWeatherShortcut, true) BOOL_OPTION(QStringLiteral("device/displayalipayshortcut"), deviceDisplayAliPayShortcut, setDeviceDisplayAliPayShortcut, true) diff --git a/ui/qml/pages/Settings-device.qml b/ui/qml/pages/Settings-device.qml index 5cb26d2b..f9b84d73 100644 --- a/ui/qml/pages/Settings-device.qml +++ b/ui/qml/pages/Settings-device.qml @@ -90,6 +90,15 @@ PagePL { } } + TextSwitchPL { + id: chkRealtimeHRMMeasuerement + width: parent.width + text: qsTr("Realtime HRM measurement") + Component.onCompleted: { + chkRealtimeHRMMeasuerement.checked = AmazfishConfig.deviceRealtimeHRMMeasurement + } + } + ButtonPL { anchors.horizontalCenter: parent.horizontalCenter text: qsTr("Huami Display Items") @@ -121,6 +130,7 @@ PagePL { DaemonInterfaceInstance.applyDeviceSetting(Amazfish.SETTING_DEVICE_TIME); DaemonInterfaceInstance.applyDeviceSetting(Amazfish.SETTING_DEVICE_UNIT); DaemonInterfaceInstance.applyDeviceSetting(Amazfish.SETTING_DISCONNECT_NOTIFICATION); + DaemonInterfaceInstance.applyDeviceSetting(Amazfish.SETTING_DEVICE_REALTIME_HRM_MEASUREMENT); app.pages.pop(); } } @@ -132,6 +142,8 @@ PagePL { AmazfishConfig.deviceTimeFormat = cboTimeFormat.currentIndex; AmazfishConfig.deviceDistanceUnit = cboDistanceUnit.currentIndex; AmazfishConfig.deviceDisconnectNotification = chkDisconnectNotification.checked; + AmazfishConfig.deviceRealtimeHRMMeasurement = chkRealtimeHRMMeasuerement.checked; + tmrSetDelay.start(); } }