fix: cleanup, AOD fixes

This commit is contained in:
Савелий Савенок 2024-10-20 03:27:14 +03:00
parent dd8aa149af
commit 0c961f777a
7 changed files with 108 additions and 92 deletions

View File

@ -6,7 +6,7 @@
"appType": "watchface", "appType": "watchface",
"version": { "version": {
"code": 1, "code": 1,
"name": "1.0.2" "name": "1.0.3"
}, },
"icon": "icon.png", "icon": "icon.png",
"vender": "zepp", "vender": "zepp",

View File

@ -1,6 +1,6 @@
{ {
"name": "vhs-watch", "name": "vhs-watch",
"version": "1.0.2", "version": "1.0.3",
"description": "vhs watch for Zepp OS 3.0 (GTS 4)", "description": "vhs watch for Zepp OS 3.0 (GTS 4)",
"main": "app.js", "main": "app.js",
"scripts": { "scripts": {

View File

@ -6,10 +6,6 @@ import heartRateModule from "./modules/heartRate"
WatchFace({ WatchFace({
onInit() { onInit() {
},
build() {
clockModule() clockModule()
dateModule() dateModule()
batteryModule() batteryModule()
@ -17,6 +13,9 @@ WatchFace({
distanceModule() distanceModule()
}, },
build() {
},
onDestroy() { onDestroy() {
} }

View File

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

View File

@ -1,6 +1,8 @@
import * as hmUI from '@zos/ui' import * as hmUI from '@zos/ui'
import { getScene, SCENE_AOD } from '@zos/app'
import timeArray from '../fontData/primaryFont' import timeArray from '../fontData/primaryFont'
export default function(){
export default function () {
console.log("[modules]: clock module init") console.log("[modules]: clock module init")
hmUI.createWidget(hmUI.widget.IMG_TIME, { hmUI.createWidget(hmUI.widget.IMG_TIME, {
hour_zero: 1, // Whether to make up zero. hour_zero: 1, // Whether to make up zero.
@ -19,6 +21,7 @@ export default function(){
minute_align: hmUI.align.CENTER_H | hmUI.align.CENTER_V, minute_align: hmUI.align.CENTER_H | hmUI.align.CENTER_V,
show_level: hmUI.show_level.ONLY_NORMAL | hmUI.show_level.ONAL_AOD show_level: hmUI.show_level.ONLY_NORMAL | hmUI.show_level.ONAL_AOD
}) })
if (getScene() != SCENE_AOD) {
hmUI.createWidget(hmUI.widget.IMG_TIME, { hmUI.createWidget(hmUI.widget.IMG_TIME, {
second_startX: 220, second_startX: 220,
second_startY: 290, second_startY: 290,
@ -26,4 +29,5 @@ export default function(){
second_space: 1, second_space: 1,
second_align: hmUI.align.CENTER_H | hmUI.align.CENTER_V second_align: hmUI.align.CENTER_H | hmUI.align.CENTER_V
}) })
}
} }

View File

@ -1,3 +1,4 @@
import { getScene, SCENE_AOD } from '@zos/app'
import * as hmSensor from '@zos/sensor' import * as hmSensor from '@zos/sensor'
import * as hmUI from '@zos/ui'; import * as hmUI from '@zos/ui';
import secondaryFont from '../fontData/secondaryFont'; import secondaryFont from '../fontData/secondaryFont';
@ -5,25 +6,28 @@ import secondaryFont from '../fontData/secondaryFont';
let distWg; let distWg;
const moduleX = 50 const moduleX = 50
const moduleY = 405 const moduleY = 405
export default function(){ export default function () {
console.log("[modules]: distance module init") console.log("[modules]: distance module init")
let distance = new hmSensor.Distance(); let distance = new hmSensor.Distance();
updateDistance(distance.getCurrent()) updateDistance(distance.getCurrent())
distance.onChange(() => updateDistance(distance.getCurrent())) distance.onChange(() => updateDistance(distance.getCurrent()))
if (getScene() != SCENE_AOD) {
hmUI.createWidget(hmUI.widget.IMG, { hmUI.createWidget(hmUI.widget.IMG, {
x: moduleX, x: moduleX,
y: moduleY, y: moduleY,
src: 'misc/dist.PNG' src: 'misc/dist.PNG'
}) })
}
} }
function updateDistance(dist){ function updateDistance(dist) {
if(!dist){ if (!dist)
dist = 0 dist = 0
}
if(distWg){ if (distWg)
hmUI.deleteWidget(distWg) hmUI.deleteWidget(distWg)
}
if (getScene() != SCENE_AOD) {
distWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, { distWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
x: moduleX + 150, x: moduleX + 150,
y: moduleY, y: moduleY,
@ -33,4 +37,5 @@ function updateDistance(dist){
align_h: hmUI.align.LEFT, align_h: hmUI.align.LEFT,
text: dist text: dist
}) })
}
} }

View File

@ -1,13 +1,15 @@
import { getScene, SCENE_AOD } from '@zos/app'
import * as hmSensor from '@zos/sensor' import * as hmSensor from '@zos/sensor'
import * as hmUI from '@zos/ui'; import * as hmUI from '@zos/ui';
import secondaryFont from '../fontData/secondaryFont'; import secondaryFont from '../fontData/secondaryFont';
let heartRateWg; let heartRateWg;
export default function(){ export default function () {
console.log("[modules]: heartrate module init") console.log("[modules]: heartrate module init")
let heart = new hmSensor.HeartRate(); let heart = new hmSensor.HeartRate();
updateHeartWidget(heart.getCurrent()) updateHeartWidget(heart.getCurrent())
heart.onCurrentChange(() => updateHeartWidget(heart.getCurrent())) heart.onCurrentChange(() => updateHeartWidget(heart.getCurrent()))
if (!getScene() != SCENE_AOD)
hmUI.createWidget(hmUI.widget.IMG, { hmUI.createWidget(hmUI.widget.IMG, {
x: 10, x: 10,
y: 365, y: 365,
@ -15,13 +17,14 @@ export default function(){
}) })
} }
function updateHeartWidget(hbpm){ function updateHeartWidget(hbpm) {
if(!hbpm){ if (!hbpm) {
hbpm = 0 hbpm = 0
} }
if(heartRateWg){ if (heartRateWg) {
hmUI.deleteWidget(heartRateWg) hmUI.deleteWidget(heartRateWg)
} }
if (!getScene() != SCENE_AOD) {
heartRateWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, { heartRateWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
x: 100, x: 100,
y: 365, y: 365,
@ -31,4 +34,5 @@ function updateHeartWidget(hbpm){
align_h: hmUI.align.LEFT, align_h: hmUI.align.LEFT,
text: hbpm text: hbpm
}) })
}
} }