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",
"version": {
"code": 1,
"name": "1.0.2"
"name": "1.0.3"
},
"icon": "icon.png",
"vender": "zepp",

View File

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

View File

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

View File

@ -1,3 +1,4 @@
import { getScene, SCENE_AOD } from '@zos/app'
import * as hmSensor from '@zos/sensor'
import * as hmUI from '@zos/ui'
import fontArray from '../fontData/secondaryFont'
@ -5,28 +6,31 @@ 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()))
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'
})
x: moduleX,
y: moduleY,
src: 'date/perc.PNG'
})
}
function updateBatteryWidget(batteryPercentage){
if(batteryWg){
hmUI.deleteWidget(batteryWg)
}
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
})
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
})
}
}

View File

@ -1,29 +1,33 @@
import * as hmUI from '@zos/ui'
import { getScene, SCENE_AOD } from '@zos/app'
import timeArray from '../fontData/primaryFont'
export default function(){
console.log("[modules]: clock module init")
export default function () {
console.log("[modules]: clock module init")
hmUI.createWidget(hmUI.widget.IMG_TIME, {
hour_zero: 1, // Whether to make up zero.
hour_startX: 10,
hour_startY: 50,
hour_array: timeArray,
hour_space: 1,
hour_align: hmUI.align.CENTER_H | hmUI.align.CENTER_V, //Я хз работает ли это
show_level: hmUI.show_level.ONLY_NORMAL | hmUI.show_level.ONAL_AOD
})
hmUI.createWidget(hmUI.widget.IMG_TIME, {
minute_startX: 118, //120 - space on center(2)
minute_startY: 170,
minute_array: timeArray,
minute_space: 1,
minute_align: hmUI.align.CENTER_H | hmUI.align.CENTER_V,
show_level: hmUI.show_level.ONLY_NORMAL | hmUI.show_level.ONAL_AOD
})
if (getScene() != SCENE_AOD) {
hmUI.createWidget(hmUI.widget.IMG_TIME, {
hour_zero: 1, // Whether to make up zero.
hour_startX: 10,
hour_startY: 50,
hour_array: timeArray,
hour_space: 1,
hour_align: hmUI.align.CENTER_H | hmUI.align.CENTER_V, //Я хз работает ли это
show_level: hmUI.show_level.ONLY_NORMAL | hmUI.show_level.ONAL_AOD
})
hmUI.createWidget(hmUI.widget.IMG_TIME, {
minute_startX: 118, //120 - space on center(2)
minute_startY: 170,
minute_array: timeArray,
minute_space: 1,
minute_align: hmUI.align.CENTER_H | hmUI.align.CENTER_V,
show_level: hmUI.show_level.ONLY_NORMAL | hmUI.show_level.ONAL_AOD
})
hmUI.createWidget(hmUI.widget.IMG_TIME, {
second_startX: 220,
second_startY: 290,
second_array: timeArray,
second_space: 1,
second_align: hmUI.align.CENTER_H | hmUI.align.CENTER_V
})
second_startX: 220,
second_startY: 290,
second_array: timeArray,
second_space: 1,
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 hmUI from '@zos/ui';
import secondaryFont from '../fontData/secondaryFont';
@ -5,32 +6,36 @@ import secondaryFont from '../fontData/secondaryFont';
let distWg;
const moduleX = 50
const moduleY = 405
export default function(){
export default function () {
console.log("[modules]: distance module init")
let distance = new hmSensor.Distance();
updateDistance(distance.getCurrent())
distance.onChange(() => updateDistance(distance.getCurrent()))
hmUI.createWidget(hmUI.widget.IMG, {
x: moduleX,
y: moduleY,
src: 'misc/dist.PNG'
})
if (getScene() != SCENE_AOD) {
hmUI.createWidget(hmUI.widget.IMG, {
x: moduleX,
y: moduleY,
src: 'misc/dist.PNG'
})
}
}
function updateDistance(dist){
if(!dist){
function updateDistance(dist) {
if (!dist)
dist = 0
}
if(distWg){
if (distWg)
hmUI.deleteWidget(distWg)
if (getScene() != SCENE_AOD) {
distWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
x: moduleX + 150,
y: moduleY,
type: hmUI.data_type.DISTANCE,
font_array: secondaryFont,
h_space: 1,
align_h: hmUI.align.LEFT,
text: dist
})
}
distWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
x: moduleX + 150,
y: moduleY,
type: hmUI.data_type.DISTANCE,
font_array: secondaryFont,
h_space: 1,
align_h: hmUI.align.LEFT,
text: dist
})
}

View File

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