Most recent activity
-
-
-
- 8 comments
- 153 views
-
OK sorry @Robin, I see what you mean't with the
interval
I had set that to false initially, this was something I needed previously, but isn't required now.So thanks to you two, i've been able to debug this, and it turned out to be a problem with L46.
That test there sometimes didn't reset
i = 8
so the text was getting updated fine, but was so far scrolled away I could never see it.Thanks a lot.
-
Hey guys,
Thank you so much for taking the time to have a look at my code:
Good tips for debugging. I'll add an
on handler
.L24
.bind(this)
, I add these to every nested function to maintain function scope to avoid things like var temp = this etc.I've read about places to put the WiFi creds and yes I'll do that when i'm happy its working well.
If it's bad data or an out of range error, wouldn't that crash the whole thing? I mentioned that the Espruino is still calling the Pi4 every 3 seconds even after display stops, so surely there's no error here? Or could it be repeatedly throwing an error but still making calls?
Yes
setInterval
does return an integer, but JS will coerce this to false if 0 and true if its any value greater than 0, so I believe this is correct.Good tip about the
process.memory()
call and the try catch.Really appreciate the advice, will see what I can find out and report back.
-
Hey guys,
I have an Espruino WiFi (love this thing) with an 8x8 matrix led display as recommended here. I have node-red running on my Raspberry PI 4. My Espruino makes calls every 3 seconds to my PI to get the current time and displays it scrolling across the matrix.
The problem is it just stops after about 10 minutes, I checked the Rasperry Pi and it is still being called by the Espruino every 3 seconds in the log. So the reason it's not displaying could be in this script somewhere, just not sure how to even debug it...
var WIFI_NAME = "BTHub-XXX"; var WIFI_OPTIONS = { password : "XxXxX" }; var http = require("http"); var output = 'default text'; var interval = false; const ANODES = [B6,A7,A6,B9,A4,B8,B4,B3]; const CATHODES = [B0,B5,A0,B7,B10,A1,B1,A5]; var g = Graphics.createArrayBuffer(8,8,1); var wifi = require("Wifi"); function onInit() { wifi.connect(WIFI_NAME, WIFI_OPTIONS, function(err) { if (err) { console.log("Connection error: "+err); return; } console.log("Connected!"); getData(); start(); scroll(); }.bind(this)); } // Start scanning out the LED display function start() { console.log('start'); var b = new Uint8Array(g.buffer); // Pre-bind digitalWrites to make things faster var a = digitalWrite.bind(undefined,ANODES); var c = digitalWrite.bind(undefined,CATHODES.concat(ANODES)); return setInterval(function() { b.map((d,i)=>{c(65280^(256<<i));a(d);});c(65280); },10); // 100 Hz } function scroll() { var i = 8; if (interval) clearInterval(interval); interval = setInterval(function(){ if(i == -(output.length * 4)) i = 8; g.clear(); g.drawString(output, i, 2); i--; }, 100); } function getData() { setInterval(function(){ http.get("http://192.168.1.146:1880/hello-data", function(res) { res.on('data', function(data) { output = data; console.log(output); }.bind(this)); }); }.bind(this), 3000); }
Hi guys,
Just playing around with my original Esp. and with only one line of code from the official LEDs example on the site, oddly I'm getting:
Has something changed with how modules are required?