41 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2024-10-20 03:27:14 +03:00
import { getScene, SCENE_AOD } from '@zos/app'
2024-10-20 02:54:13 +03:00
import * as hmSensor from '@zos/sensor'
import * as hmUI from '@zos/ui';
import secondaryFont from '../fontData/secondaryFont';
let distWg;
const moduleX = 50
const moduleY = 405
2024-10-20 03:27:14 +03:00
export default function () {
2024-10-20 02:54:13 +03:00
console.log("[modules]: distance module init")
let distance = new hmSensor.Distance();
updateDistance(distance.getCurrent())
distance.onChange(() => updateDistance(distance.getCurrent()))
2024-10-20 03:27:14 +03:00
if (getScene() != SCENE_AOD) {
hmUI.createWidget(hmUI.widget.IMG, {
x: moduleX,
y: moduleY,
src: 'misc/dist.PNG'
})
}
2024-10-20 02:54:13 +03:00
}
2024-10-20 03:27:14 +03:00
function updateDistance(dist) {
if (!dist)
2024-10-20 02:54:13 +03:00
dist = 0
2024-10-20 03:27:14 +03:00
if (distWg)
2024-10-20 02:54:13 +03:00
hmUI.deleteWidget(distWg)
2024-10-20 03:27:14 +03:00
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
})
2024-10-20 02:54:13 +03:00
}
}