build(release): v1.0 of VHS Watchface
This commit is contained in:
31
watchface/modules/battery.js
Normal file
31
watchface/modules/battery.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import * as hmSensor from '@zos/sensor'
|
||||
import * as hmUI from '@zos/ui'
|
||||
import fontArray from '../fontData/secondaryFont'
|
||||
|
||||
let batteryWg;
|
||||
|
||||
export default function(){
|
||||
console.log("[modules]: battery module init")
|
||||
let battery = new hmSensor.Battery()
|
||||
updateBatteryWidget(battery.getCurrent())
|
||||
battery.onChange(() => updateBatteryWidget(battery.getCurrent()))
|
||||
hmUI.createWidget(hmUI.widget.IMG, {
|
||||
x: 355,
|
||||
y: 10,
|
||||
src: 'date/perc.PNG'
|
||||
})
|
||||
}
|
||||
function updateBatteryWidget(batteryPercentage){
|
||||
if(batteryWg){
|
||||
hmUI.deleteWidget(batteryWg)
|
||||
}
|
||||
batteryWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
|
||||
x: 270,
|
||||
y: 10,
|
||||
type: hmUI.data_type.BATTERY,
|
||||
font_array: fontArray,
|
||||
h_space: 1,
|
||||
align_h: hmUI.align.RIGHT,
|
||||
text: batteryPercentage
|
||||
})
|
||||
}
|
||||
29
watchface/modules/clock.js
Normal file
29
watchface/modules/clock.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import * as hmUI from '@zos/ui'
|
||||
import timeArray from '../fontData/primaryFont'
|
||||
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
|
||||
})
|
||||
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
|
||||
})
|
||||
}
|
||||
26
watchface/modules/date.js
Normal file
26
watchface/modules/date.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import * as hmUI from '@zos/ui'
|
||||
import fontArray from '../fontData/secondaryFont'
|
||||
export default function () {
|
||||
console.log("[modules]: date module init")
|
||||
hmUI.createWidget(hmUI.widget.IMG_DATE, {
|
||||
day_startX: 10,
|
||||
day_startY: 10,
|
||||
day_align: hmUI.align.LEFT,
|
||||
day_space: 0,
|
||||
day_zero: 1,
|
||||
day_en_array: fontArray
|
||||
})
|
||||
hmUI.createWidget(hmUI.widget.IMG, {
|
||||
x: 54,
|
||||
y: 14,
|
||||
src: 'date/point.PNG'
|
||||
})
|
||||
hmUI.createWidget(hmUI.widget.IMG_DATE, {
|
||||
month_startX: 70,
|
||||
month_startY: 10,
|
||||
month_align: hmUI.align.LEFT,
|
||||
month_space: 0,
|
||||
month_zero: 1,
|
||||
month_en_array: fontArray
|
||||
})
|
||||
}
|
||||
35
watchface/modules/distance.js
Normal file
35
watchface/modules/distance.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import * as hmSensor from '@zos/sensor'
|
||||
import * as hmUI from '@zos/ui';
|
||||
import secondaryFont from '../fontData/secondaryFont';
|
||||
|
||||
let distWg;
|
||||
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: 10,
|
||||
y: 405,
|
||||
src: 'misc/dist.PNG'
|
||||
})
|
||||
}
|
||||
|
||||
function updateDistance(dist){
|
||||
if(!dist){
|
||||
dist = 0
|
||||
}
|
||||
if(distWg){
|
||||
hmUI.deleteWidget(distWg)
|
||||
}
|
||||
dist = (dist * 1000).toFixed(0)
|
||||
distWg = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
|
||||
x: 160,
|
||||
y: 405,
|
||||
type: hmUI.data_type.DISTANCE,
|
||||
font_array: secondaryFont,
|
||||
h_space: 1,
|
||||
align_h: hmUI.align.LEFT,
|
||||
text: dist
|
||||
})
|
||||
}
|
||||
34
watchface/modules/heartRate.js
Normal file
34
watchface/modules/heartRate.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import * as hmSensor from '@zos/sensor'
|
||||
import * as hmUI from '@zos/ui';
|
||||
import secondaryFont from '../fontData/secondaryFont';
|
||||
|
||||
let heartRateWg;
|
||||
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'
|
||||
})
|
||||
}
|
||||
|
||||
function updateHeartWidget(hbpm){
|
||||
if(!hbpm){
|
||||
hbpm = 0
|
||||
}
|
||||
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
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user