fix(release): fixed info update on battery, heartrate and distance widget

This commit is contained in:
Савелий Савенок
2024-10-27 19:08:24 +03:00
parent 8dccc528ba
commit 8c3305685f
5 changed files with 22 additions and 67 deletions

View File

@@ -1,36 +1,24 @@
import { getScene, SCENE_AOD } from '@zos/app'
import * as hmSensor from '@zos/sensor'
import * as hmUI from '@zos/ui'
import fontArray from '../fontData/secondaryFont'
let batteryWg;
const moduleX = 310
const moduleY = 10
export default function () {
console.log("[modules]: battery module init")
let battery = new hmSensor.Battery()
updateBatteryWidget(battery.getCurrent())
battery.onChange(() => updateBatteryWidget(battery.getCurrent()))
if (getScene() != SCENE_AOD)
hmUI.createWidget(hmUI.widget.IMG, {
x: moduleX,
y: moduleY,
src: 'date/perc.PNG'
})
}
function updateBatteryWidget(batteryPercentage) {
if (batteryWg)
hmUI.deleteWidget(batteryWg)
if (getScene() != SCENE_AOD) {
batteryWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
x: moduleX - 85,
y: moduleY,
type: hmUI.data_type.BATTERY,
font_array: fontArray,
h_space: 1,
align_h: hmUI.align.RIGHT,
text: batteryPercentage
})
}
console.log("[modules]: battery module init")
if (getScene() != SCENE_AOD) {
hmUI.createWidget(hmUI.widget.IMG, {
x: moduleX,
y: moduleY,
src: 'date/perc.PNG'
})
hmUI.createWidget(hmUI.widget.TEXT_IMG, {
x: moduleX - 85,
y: moduleY,
font_array: fontArray,
h_space: 1,
align_h: hmUI.align.RIGHT,
type: hmUI.data_type.BATTERY
})
}
}