fix: cleanup, AOD fixes
This commit is contained in:
@@ -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
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user