Avatar for Coder2012

Coder2012

Member since Jan 2015 • Last active Dec 2019
  • 8 conversations
  • 27 comments

Most recent activity

  • in Pico / Wifi / Original Espruino
    Avatar for Coder2012

    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:

    1v86 Copyright 2016 G.Williams
    >ERROR: Could not open file : NO_PATH
    WARNING: Module "neopixel" not found
    Uncaught Error: Field or method "write" does not already exist, and can't create it on undefined
     at line 1 col 20
    require("neopixel").write(B15, [255,0,0]);
    

    Has something changed with how modules are required?

  • in Pico / Wifi / Original Espruino
    Avatar for Coder2012

    Hi guys,

    I just dug out my original Espruino, and I'd like to see what code is already on the device before I write over it. How can I do this?

  • in Pico / Wifi / Original Espruino
    Avatar for Coder2012

    Hello again,

    Yes exactly <= fixed it.

  • in Pico / Wifi / Original Espruino
    Avatar for Coder2012

    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.

  • in Pico / Wifi / Original Espruino
    Avatar for Coder2012

    Hey guys,

    Thank you so much for taking the time to have a look at my code:

    @allObjects

    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.

    @Robin

    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.

  • in Pico / Wifi / Original Espruino
    Avatar for Coder2012

    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.con­cat(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/hell­o-data", function(res) {
          res.on('data', function(data) {
            output = data;
            console.log(output);
          }.bind(this));
        });
      }.bind(this), 3000);
    }
    
Actions