fix: cleanup, AOD fixes
This commit is contained in:
parent
dd8aa149af
commit
0c961f777a
2
app.json
2
app.json
@ -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",
|
||||||
|
@ -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": {
|
||||||
|
@ -6,15 +6,14 @@ import heartRateModule from "./modules/heartRate"
|
|||||||
|
|
||||||
WatchFace({
|
WatchFace({
|
||||||
onInit() {
|
onInit() {
|
||||||
|
clockModule()
|
||||||
|
dateModule()
|
||||||
|
batteryModule()
|
||||||
|
heartRateModule()
|
||||||
|
distanceModule()
|
||||||
},
|
},
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
clockModule()
|
|
||||||
dateModule()
|
|
||||||
batteryModule()
|
|
||||||
heartRateModule()
|
|
||||||
distanceModule()
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onDestroy() {
|
onDestroy() {
|
||||||
|
@ -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,28 +6,31 @@ 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)
|
||||||
}
|
|
||||||
batteryWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
|
if (getScene() != SCENE_AOD) {
|
||||||
x: moduleX - 85,
|
batteryWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
|
||||||
y: moduleY,
|
x: moduleX - 85,
|
||||||
type: hmUI.data_type.BATTERY,
|
y: moduleY,
|
||||||
font_array: fontArray,
|
type: hmUI.data_type.BATTERY,
|
||||||
h_space: 1,
|
font_array: fontArray,
|
||||||
align_h: hmUI.align.RIGHT,
|
h_space: 1,
|
||||||
text: batteryPercentage
|
align_h: hmUI.align.RIGHT,
|
||||||
})
|
text: batteryPercentage
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,29 +1,33 @@
|
|||||||
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(){
|
|
||||||
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, {
|
hmUI.createWidget(hmUI.widget.IMG_TIME, {
|
||||||
hour_zero: 1, // Whether to make up zero.
|
second_startX: 220,
|
||||||
hour_startX: 10,
|
second_startY: 290,
|
||||||
hour_startY: 50,
|
second_array: timeArray,
|
||||||
hour_array: timeArray,
|
second_space: 1,
|
||||||
hour_space: 1,
|
second_align: hmUI.align.CENTER_H | hmUI.align.CENTER_V
|
||||||
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
|
|
||||||
})
|
|
||||||
}
|
}
|
@ -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,32 +6,36 @@ 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()))
|
||||||
hmUI.createWidget(hmUI.widget.IMG, {
|
if (getScene() != SCENE_AOD) {
|
||||||
x: moduleX,
|
hmUI.createWidget(hmUI.widget.IMG, {
|
||||||
y: moduleY,
|
x: moduleX,
|
||||||
src: 'misc/dist.PNG'
|
y: moduleY,
|
||||||
})
|
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, {
|
||||||
|
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
|
|
||||||
})
|
|
||||||
}
|
}
|
@ -1,34 +1,38 @@
|
|||||||
|
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()))
|
||||||
hmUI.createWidget(hmUI.widget.IMG, {
|
if (!getScene() != SCENE_AOD)
|
||||||
x: 10,
|
hmUI.createWidget(hmUI.widget.IMG, {
|
||||||
y: 365,
|
x: 10,
|
||||||
src: 'misc/hb.PNG'
|
y: 365,
|
||||||
})
|
src: 'misc/hb.PNG'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateHeartWidget(hbpm){
|
function updateHeartWidget(hbpm) {
|
||||||
if(!hbpm){
|
if (!hbpm) {
|
||||||
hbpm = 0
|
hbpm = 0
|
||||||
}
|
}
|
||||||
if(heartRateWg){
|
if (heartRateWg) {
|
||||||
hmUI.deleteWidget(heartRateWg)
|
hmUI.deleteWidget(heartRateWg)
|
||||||
}
|
}
|
||||||
heartRateWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
|
if (!getScene() != SCENE_AOD) {
|
||||||
x: 100,
|
heartRateWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
|
||||||
y: 365,
|
x: 100,
|
||||||
type: hmUI.data_type.BATTERY,
|
y: 365,
|
||||||
font_array: secondaryFont,
|
type: hmUI.data_type.BATTERY,
|
||||||
h_space: 1,
|
font_array: secondaryFont,
|
||||||
align_h: hmUI.align.LEFT,
|
h_space: 1,
|
||||||
text: hbpm
|
align_h: hmUI.align.LEFT,
|
||||||
})
|
text: hbpm
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user