From e5d8d8770adb04c4ef039e02767d5824c1c470d2 Mon Sep 17 00:00:00 2001 From: pierre Date: Sun, 22 Dec 2024 23:37:43 +0100 Subject: [PATCH] upload pixl.js source --- pixl.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 pixl.js diff --git a/pixl.js b/pixl.js new file mode 100644 index 0000000..a6562dd --- /dev/null +++ b/pixl.js @@ -0,0 +1,35 @@ +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(); \ No newline at end of file