-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
91 lines (69 loc) · 2.6 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
NanoPlay OS
Copyright (C) Subnodal Technologies. All Rights Reserved.
https://nanoplay.subnodal.com
Licenced by the Subnodal Open-Source Licence, which can be found at LICENCE.md.
*/
var uiHomeScreen = require("home").HomeScreen;
var rootScreenIsOpen = false;
exports.rootScreenLoop = null;
exports.openRootScreenAllowed = true;
function _(text) {
return require("l10n").translate(text);
}
function startRootScreen() {
if (!rootScreenIsOpen && exports.openRootScreenAllowed) {
Bluetooth.setConsole(true);
rootScreenIsOpen = true;
let homeScreen = new uiHomeScreen([
{
text: _("clock"),
icon: require("images").clockIcon,
module: "clock",
action: function() {
let screenClass = require("clock").ClockScreen;
homeScreen.open(new screenClass());
}
},
{
text: _("settings"),
icon: require("images").settingsIcon,
module: "settings",
action: function() {
require("settings").load(homeScreen);
}
}
]);
homeScreen.items = homeScreen.items.concat(require("appload").getHomeScreenIcons(homeScreen));
require("ui").buttons.tl.statusBuffer = [];
require("ui").buttons.tr.statusBuffer = [];
require("ui").buttons.bl.statusBuffer = [];
require("ui").buttons.br.statusBuffer = [];
LED.write(require("config").properties.backlight);
Pixl.setLCDPower(true);
exports.rootScreenLoop = require("ui").openRootScreen(homeScreen, function() {
rootScreenIsOpen = false;
require("display").clear();
require("display").render();
LED.write(0);
Pixl.setLCDPower(false);
});
}
}
exports.start = function() {
LED.write(0);
Pixl.setLCDPower(false);
setTime(Date.parse("2021-01-01T00:00:00") / 1000);
NRF.setAdvertising({}, {name: "NanoPlay " + NRF.getAddress().substring(12).replace(":", "")});
NRF.nfcURL("https://subnodal.com/np");
require("display").clear();
require("display").render();
setWatch(startRootScreen, BTN1, {repeat: true, edge: "falling"});
setWatch(startRootScreen, BTN2, {repeat: true, edge: "falling"});
setWatch(startRootScreen, BTN4, {repeat: true, edge: "falling"});
setWatch(startRootScreen, BTN3, {repeat: true, edge: "falling"});
startRootScreen();
};
exports.preventOpening = function() {
exports.openRootScreenAllowed = false;
};