35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
|
require("FontTeletext5x9Ascii").add(Graphics);
|
||
|
require("FontHaxorNarrow7x17").add(Graphics);
|
||
|
|
||
|
function scanForDevices() {
|
||
|
NRF.findDevices(function(devs) {
|
||
|
g.clear();
|
||
|
var idx = 0;
|
||
|
devs.forEach(function(dev) {
|
||
|
if ("services" in dev && dev.services.includes("feaa")) {
|
||
|
g.setFont("Teletext5x9Ascii");
|
||
|
g.drawString(`${dev.id.substring(12,14).toUpperCase()}${dev.id.substring(15,17).toUpperCase()}`,2,idx*20+10);
|
||
|
g.setFont("Teletext5x9Ascii");
|
||
|
g.drawString(`FEAA`,2,idx*20+2);
|
||
|
g.setFont("HaxorNarrow7x17");
|
||
|
var arr = dev.serviceData.feaa;
|
||
|
var str = String.fromCharCode(arr[2],arr[3],arr[4],arr[5],arr[6],arr[7],arr[8],arr[9],arr[10],arr[11],arr[12],arr[13],arr[14],arr[15],arr[16],arr[17]);
|
||
|
g.drawString(str,25,idx*20+1);
|
||
|
idx++;
|
||
|
}
|
||
|
});
|
||
|
if (!idx) {
|
||
|
g.clear();
|
||
|
g.flip();
|
||
|
Pixl.setLCDPower(false);
|
||
|
LED1.reset();
|
||
|
} else {
|
||
|
Pixl.setLCDPower(true);
|
||
|
LED1.set();
|
||
|
g.flip();
|
||
|
}
|
||
|
}, 1900); // scan for 1 sec
|
||
|
}
|
||
|
|
||
|
setInterval(scanForDevices, 2000);
|
||
|
scanForDevices();
|