Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into placeholderEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlich committed Nov 15, 2024
2 parents 6bd6e89 + fa87b40 commit f102e8e
Show file tree
Hide file tree
Showing 27 changed files with 1,781 additions and 228 deletions.
18 changes: 18 additions & 0 deletions daemon/src/devices/banglejsdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,24 @@ void BangleJSDevice::initialise()
}

setConnectionState("authenticated");

setTime();
}

void BangleJSDevice::setTime() {
UARTService *uart = qobject_cast<UARTService*>(service(UARTService::UUID_SERVICE_UART));
if (!uart){
return;
}

qint64 ts;

#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
ts = QDateTime::currentSecsSinceEpoch();
#else
ts = QDateTime::currentDateTime().toTime_t();
#endif
uart->tx(QByteArray(1, 0x10) + QString("setTime(" + QString::number(ts) + ");\n").toUtf8());
}

void BangleJSDevice::onPropertiesChanged(QString interface, QVariantMap map, QStringList list)
Expand Down
2 changes: 2 additions & 0 deletions daemon/src/devices/banglejsdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class BangleJSDevice : public AbstractDevice
//Weather
void sendWeather(CurrentWeather *weather) override;

void setTime();

protected:
virtual void onPropertiesChanged(QString interface, QVariantMap map, QStringList list);

Expand Down
18 changes: 9 additions & 9 deletions daemon/translations/harbour-amazfishd-cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<context>
<name>AsteroidOSDevice</name>
<message>
<location filename="../src/devices/asteroidosdevice.cpp" line="313"/>
<location filename="../src/devices/asteroidosdevice.cpp" line="324"/>
<source>Stored %1...</source>
<translation>Uloženo %1 ...</translation>
</message>
Expand Down Expand Up @@ -61,27 +61,27 @@
<translation>Zařízení není platné, nemusí být podporované</translation>
</message>
<message>
<location filename="../src/deviceinterface.cpp" line="446"/>
<location filename="../src/deviceinterface.cpp" line="444"/>
<source>Amazfish</source>
<translation>Amazfish</translation>
</message>
<message>
<location filename="../src/deviceinterface.cpp" line="446"/>
<location filename="../src/deviceinterface.cpp" line="444"/>
<source>Connected</source>
<translation>Připojeno</translation>
</message>
<message>
<location filename="../src/deviceinterface.cpp" line="446"/>
<location filename="../src/deviceinterface.cpp" line="444"/>
<source>Phone and watch are connected</source>
<translation>Telefon a hodinky jsou propojeny</translation>
</message>
<message>
<location filename="../src/deviceinterface.cpp" line="511"/>
<location filename="../src/deviceinterface.cpp" line="504"/>
<source>Low Battery</source>
<translation>Slabá baterie</translation>
</message>
<message>
<location filename="../src/deviceinterface.cpp" line="511"/>
<location filename="../src/deviceinterface.cpp" line="504"/>
<source>Battery level now </source>
<translation>Stupeň nabití </translation>
</message>
Expand All @@ -102,17 +102,17 @@
<context>
<name>HuamiDevice</name>
<message>
<location filename="../src/devices/huamidevice.cpp" line="172"/>
<location filename="../src/devices/huamidevice.cpp" line="183"/>
<source>Navigation Started</source>
<translation>Navigace spuštěna</translation>
</message>
<message>
<location filename="../src/devices/huamidevice.cpp" line="174"/>
<location filename="../src/devices/huamidevice.cpp" line="185"/>
<source>Navigation Stopped</source>
<translation>Navigace zastavena</translation>
</message>
<message>
<location filename="../src/devices/huamidevice.cpp" line="181"/>
<location filename="../src/devices/huamidevice.cpp" line="192"/>
<source>Progress</source>
<translation>Průbeh</translation>
</message>
Expand Down
10 changes: 5 additions & 5 deletions documentation/build-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ sudo apt install -y qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libkdb3-de
```

Two dependencies can be found on git repos
https://git.sailfishos.org/mer-core/nemo-qml-plugin-dbus
https://github.com/sailfishos/nemo-qml-plugin-dbus
and
https://git.sailfishos.org/mer-core/qtmpris
https://github.com/sailfishos/qtmpris.git/

```
git clone https://git.sailfishos.org/mer-core/qtmpris.git
git clone https://github.com/sailfishos/qtmpris.git/
cd qtmpris
qmake
make
Expand All @@ -59,7 +59,7 @@ cd ..
```

```
git clone https://git.sailfishos.org/mer-core/nemo-qml-plugin-dbus.git
git clone https://github.com/sailfishos/nemo-qml-plugin-dbus
cd nemo-qml-plugin-dbus
qmake
make
Expand Down Expand Up @@ -143,7 +143,7 @@ clickable build --libs
clickable desktop
```

To build the application for ARM architecture and install it on your device, follow these steps:
To build the libraries and the application for the architecture of the connected device and install the app on your device, follow these steps:

```
clickable build --libs --app --arch detect --skip-review
Expand Down
2 changes: 1 addition & 1 deletion lib/src/amazfishconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class AmazfishConfig : public QObject
ENUM_OPTION(QStringLiteral("profile/gender"), profileGender, setProfileGender, ProfileGender, ProfileGenderMale)
ENUM_OPTION(QStringLiteral("profile/wearlocation"), profileWearLocation, setProfileWearLocation, WearLocation, WearLocationLeftWrist)

UINT_OPTION(QStringLiteral("profile/height"), profileHeight, setProfileHeight, 200)
UINT_OPTION(QStringLiteral("profile/height"), profileHeight, setProfileHeight, 170)
UINT_OPTION(QStringLiteral("profile/weight"), profileWeight, setProfileWeight, 70)
UINT_OPTION(QStringLiteral("profile/alldayhrm"), profileAllDayHRM, setProfileAllDayHRM, 0)
UINT_OPTION(QStringLiteral("profile/fitnessgoal"), profileFitnessGoal, setProfileFitnessGoal, 10000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Kirigami.ApplicationWindow {
pageStack.globalToolBar.showNavigationButtons: pages && pages.currentIndex > 0 ?
Kirigami.ApplicationHeaderStyle.ShowBackButton :
Kirigami.ApplicationHeaderStyle.NoNavigationButtons

property var cover
property real compassOrientationOffset: 0
property bool isConvergent: true
property var initialPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ApplicationWindow {
height: 480
visible: true

property var cover
property real compassOrientationOffset: 0
property alias initialPage: pageStack.initialItem
property string menuPageUrl
Expand Down
1 change: 1 addition & 0 deletions ui/qml/components/platform.uuitk/ApplicationWindowPL.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ApplicationWindow {
height: 480
visible: true

property var cover
property real compassOrientationOffset: 0
property alias initialPage: pageStack.initialItem
property string menuPageUrl
Expand Down
4 changes: 2 additions & 2 deletions ui/qml/cover/CoverPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ CoverBackground {

Image {
id: imgSteps
source: "../pics/icon-m-steps.png"
source: "../pics/custom-icons/icon-m-steps.png"
height: Theme.iconSizeMedium
width: height
}
Expand All @@ -94,7 +94,7 @@ CoverBackground {

Image {
id: imgHeartrate
source: "../pics/icon-m-heartrate.png"
source: "../pics/custom-icons/icon-m-heartrate.png"
height: Theme.iconSizeMedium
width: height
}
Expand Down
2 changes: 1 addition & 1 deletion ui/qml/harbour-amazfish.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ApplicationWindowPL
id: app
initialPage: Component { FirstPage { } }
property var rootPage: null
//cover: Qt.resolvedUrl("cover/CoverPage.qml")
cover: Qt.resolvedUrl("cover/CoverPage.qml")
//allowedOrientations: defaultAllowedOrientations

property int _lastNotificationId: 0
Expand Down
4 changes: 2 additions & 2 deletions ui/qml/pages/AnalysisPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ PagePL {
graphTitle: qsTr("Heartrate")
graphHeight: 300

axisY.units: "BPM"
axisY.units: qsTr("BPM")
type: DataSource.Heartrate

minY: 0
Expand All @@ -57,7 +57,7 @@ PagePL {
graphTitle: qsTr("Steps")
graphHeight: 300

axisY.units: "Steps"
axisY.units: qsTr("Steps")
type: DataSource.Steps

minY: 0
Expand Down
4 changes: 2 additions & 2 deletions ui/qml/pages/BipFirmwarePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "../components/platform"

PagePL {
id: page
title: qsTr("Download File")
title: qsTr("Install File")

property string selectedFile: qsTr("None")
property string fileVersion
Expand All @@ -19,7 +19,7 @@ PagePL {

LabelPL {
width: parent.width
text: qsTr("Select a file to download.");
text: qsTr("Select a file to install.");
}

ValueButtonPL {
Expand Down
7 changes: 6 additions & 1 deletion ui/qml/pages/FirstPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ PagePL {
}
}
PageMenuItemPL {
text: qsTr("Download File")
text: qsTr("Install File")
onClicked: app.pages.push(Qt.resolvedUrl("BipFirmwarePage.qml"))
}
PageMenuItemPL {
Expand Down Expand Up @@ -199,6 +199,11 @@ PagePL {
text: AmazfishConfig.profileFitnessGoal.toLocaleString()
}
}
Component.onCompleted: {
if (_connected) {
_InfoSteps = parseInt(DaemonInterfaceInstance.information(Amazfish.INFO_STEPS), 10) || 0;
}
}
}

SectionHeaderPL {
Expand Down
100 changes: 55 additions & 45 deletions ui/qml/pages/HeartratePage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ PagePL {
graphTitle: qsTr("BPM")
graphHeight: 300

axisY.units: "BPM"
axisY.units: qsTr("BPM")
type: DataSource.Heartrate
graphType: 2

Expand All @@ -85,45 +85,65 @@ PagePL {

//Type summary
Grid {
columns: 2
columns: 3
spacing: styler.themePaddingMedium
width: parent.width
LabelPL { text: qsTr("Relaxed") }
Item { width: parent.width * 0.5; height: 50
width: parent.width - (styler.themePaddingMedium * 2)
LabelPL {text: qsTr("Relaxed")}
Item {
width: parent.width * 0.5
height: 50
Rectangle { color: "grey"; width: parent.width * (relaxed / total) ; height: parent.height }
LabelPL { text: Math.floor((relaxed / total) * 100) + "%"; anchors.centerIn: parent}
LabelPL { text: Math.round((relaxed / total) * 100) + "%"; anchors.centerIn: parent}
}
LabelPL { text: qsTr("Light") }
Item { width: parent.width * 0.5; height: 50
LabelPL {text: qsTr("≤ %1 BPM".arg(Math.round(maxHR()*0.5)))}

LabelPL {text: qsTr("Light")}
Item {
width: parent.width * 0.5
height: 50
Rectangle { color: "lightblue"; width: parent.width * (light / total) ; height: parent.height }
LabelPL { text: Math.floor((light / total) * 100) + "%"; anchors.centerIn: parent}
LabelPL { text: Math.round((light / total) * 100) + "%"; anchors.centerIn: parent}
}
LabelPL { text: qsTr("Intensive")}
Item { width: parent.width * 0.5; height: 50
LabelPL {text: qsTr("≤ %1 BPM".arg(Math.round(maxHR()*0.6)))}

LabelPL {text: qsTr("Intensive")}
Item {
width: parent.width * 0.5
height: 50
Rectangle { color: "green"; width: parent.width * (intensive / total) ; height: parent.height }
LabelPL { text: Math.floor((intensive / total) * 100) + "%"; anchors.centerIn: parent}
LabelPL { text: Math.round((intensive / total) * 100) + "%"; anchors.centerIn: parent}
}
LabelPL { text: qsTr("Aerobic")}
Item { width: parent.width * 0.5; height: 50
LabelPL {text: qsTr("≤ %1 BPM".arg(Math.round(maxHR()*0.7)))}

LabelPL {text: qsTr("Aerobic")}
Item {
width: parent.width * 0.5
height: 50
Rectangle { color: "yellow"; width: parent.width * (aerobic / total) ; height: parent.height }
LabelPL { text: Math.floor((aerobic / total) * 100) + "%"; anchors.centerIn: parent}
LabelPL { text: Math.round((aerobic / total) * 100) + "%"; anchors.centerIn: parent}
}
LabelPL {text: qsTr("≤ %1 BPM".arg(Math.round(maxHR()*0.8)))}

LabelPL { text: qsTr("Anerobic")}
Item { width: parent.width * 0.5; height: 50
LabelPL {text: qsTr("Anerobic")}
Item {
width: parent.width * 0.5
height: 50
Rectangle { color: "orange"; width: parent.width * (anerobic / total) ; height: parent.height }
LabelPL { text: Math.floor((anerobic / total) * 100) + "%"; anchors.centerIn: parent}
LabelPL { text: Math.round((anerobic / total) * 100) + "%"; anchors.centerIn: parent}
}
LabelPL {text: qsTr("≤ %1 BPM".arg(Math.round(maxHR()*0.9)))}

LabelPL { text: qsTr("VO2 Max") }
Item { width: parent.width * 0.5; height: 50
LabelPL {text: qsTr("VO2 Max")}
Item {
width: parent.width * 0.5
height: 50
Rectangle { color: "red"; width: parent.width * (vo2max / total) ; height: parent.height }
LabelPL { text: Math.floor((vo2max / total) * 100) + "%"; anchors.centerIn: parent}
LabelPL { text: Math.round((vo2max / total) * 100) + "%"; anchors.centerIn: parent}
}
LabelPL {text: qsTr("≤ %1 BPM".arg(Math.round(maxHR())))}
}
}


function updateGraphs() {
graphHR.updateGraph(day);
calculateZones();
Expand Down Expand Up @@ -179,33 +199,23 @@ PagePL {

function maxHR() {
var dob = AmazfishConfig.profileDOB;
var gender = AmazfishConfig.profileGender;
var diff_ms = Date.now() - dob.getTime();
var age_dt = new Date(diff_ms);
var age = Math.abs(age_dt.getUTCFullYear() - 1970);
var max_hr = 200;

if (age >= 70) {
max_hr = 150;
} else if (age >= 65) {
max_hr = 155;
} else if (age >= 60) {
max_hr = 160;
} else if (age >= 55) {
max_hr = 165;
} else if (age >= 50) {
max_hr = 170;
} else if (age >= 45) {
max_hr = 175;
} else if (age >= 40) {
max_hr = 180;
} else if (age >= 35) {
max_hr = 185;
} else if (age >= 30) {
max_hr = 190;
} else if (age >= 25) {
max_hr = 195;
var max_hr;

// if no age is provided, use an average age
// this is to avoid providing too height values which may be a health risk
if (!age) {
age = 50
}
// max HR calculated with Wingate formula as the most recent evaluation with a large test group
// for details see https://en.wikipedia.org/wiki/Heart_rate#Maximum_heart_rate
if (gender = 1) { // 1=male
max_hr = 208.609-(0.716*age)
} else {
max_hr = 200;
max_hr = 209.273-(0.804*age)
}

console.log("Age is", age, "max hr is", max_hr);
Expand Down
Loading

0 comments on commit f102e8e

Please sign in to comment.