-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestoverlay.js
More file actions
68 lines (61 loc) · 2.05 KB
/
Copy pathtestoverlay.js
File metadata and controls
68 lines (61 loc) · 2.05 KB
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
"use strict";
const fpplib = require("./lib/fpp.js");
const infoboard = new fpplib.FPPApi("192.168.1.158");
//const infoboard = new fpplib.FPPApi("192.168.1.148");
function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
async function test() {
let today = 1242;
let season = 10123;
let popular = "White";
let full_message = "Today, there have been " + today + " buttons pressed. " + popular + " has been the most popular today. ";
full_message += "This season, a total of " + season + " buttons have been pressed!";
let fontsize = 48;
let sleep_dur = full_message.length * 200 + 1000;
await infoboard.overlaySetState(1);
await infoboard.overlaySetText(full_message, fontsize, "R2L");
console.log("Sleeping: ", sleep_dur)
await sleep(sleep_dur);
await infoboard.overlayClearMessage();
await infoboard.overlaySetState(0);
console.log("Done");
}
async function testold() {
let today = 1242;
let season = 10123;
let popular = "White";
let fontsize = 48;
const max_length = 15;
const sleep_dur = 2000;
let full_message = "There have been " + today + " buttons pressed today. " + popular + " has been the most popular today. ";
full_message += "This season a total of " + season + " buttons have been pressed!";
let parts = full_message.split(" ");
let msg = "";
await infoboard.overlaySetState(1);
for (const p of parts) {
if (msg.length + p.length < max_length) {
msg += " ";
msg += p;
} else {
msg = msg.trim();
console.log(msg);
await infoboard.overlaySetText(msg, fontsize);
await sleep(sleep_dur);
msg = p;
}
}
if (msg.length > 0) {
msg = msg.trim();
console.log(msg);
await infoboard.overlaySetText(msg, fontsize);
await sleep(sleep_dur);
msg = "";
}
await infoboard.overlayClearMessage();
await infoboard.overlaySetState(0);
}
test();
setInterval(test, 45000);