Avatar for Owen

Owen

Member since Feb 2014 • Last active Jun 2018
  • 16 conversations
  • 67 comments

Most recent activity

    • 23 comments
    • 474 views
  • in Electronics
    Avatar for Owen

    Thanks Gordon. I'm not great with hardware coding but LPD6416 looks like a good starting point.

  • in Electronics
    Avatar for Owen

    Has anyone used Espruino with a P3 RGB pixel matrix like this? Where would I begin?
    https://www.aliexpress.com/item/P3-RGB-p­ixel-panel-HD-display-64x32-dot-matrix-p­3-smd-rgb-led-module/32728985432.html

  • in Interfacing
    Avatar for Owen

    Hi,
    I think this is the working code but haven't tested it in a while. Read the comment at the top for the wiring, matrix and Glediator settings.
    Let me know if that works or not. I was using the Pico but it shouldn't matter which espruino you use.

    /**
    Glediator settings
    Driver: Glediator
    COM6
    Baud 1000000
    Colour order: GRB
    Pixel order:  HS_TL
    */
    var fps = 0,
        buf = new Uint8Array(15*15*3),
        bufIdx = 0,
        cmd = "";
    
    function onInit() {
      SPI1.setup({baud:3200000, mosi:A7});
      
      Serial1.setup(115200, {tx:B6,rx:B7});
      Serial1.on('data', function (data) {
        
        buf.set(data, bufIdx);
        bufIdx += data.length;
        
        if (data.indexOf("\1") >= 0) {
          var idx = bufIdx + data.indexOf("\1");
          var line = new Uint8Array(buf.buffer, 0, idx);
          console.log(idx);
          
          SPI1.send4bit(line, 0b0001, 0b0011);
          buf.set(new Uint8Array(buf.buffer, idx, bufIdx-idx), 0);
          bufIdx -= idx;
          fps++;
        }
      });
        
      var fps = setInterval(function() {
        console.log('fps: ' + fps);
        fps = 0;
      }, 1000);
    }
    
    onInit();
    
    • 38 comments
    • 2,268 views
    • 5 comments
    • 705 views
  • in Projects
    Avatar for Owen

    The apple-eating animation is a hollow circle that grows from the point of the apple and fades its colour out on each step.
    I added a helper function to draw the circle that was fast enough not to affect the frame rate. I don't know much C but I can try port it to be used in the Espruino graphic library.

      m.drawCircle = function(posX, posY, radX){
        var radY = 0;
        // Decision criterion divided by 2 evaluated at radX=radX, radY=0 .
        var decisionOver2 = 1 - radX;
      
        while (radX >= radY) {
          m.setPixel(radX + posX,  radY + posY);
          m.setPixel(radY + posX,  radX + posY);
          m.setPixel(-radX + posX,  radY + posY);
          m.setPixel(-radY + posX,  radX + posY);
          m.setPixel(-radX + posX, -radY + posY);
          m.setPixel(-radY + posX, -radX + posY);
          m.setPixel(radX + posX, -radY + posY);
          m.setPixel(radY + posX, -radX + posY);
          radY++;
      
          if (decisionOver2 <= 0) {
            // Change in decision criterion for radY -> radY+1 .
            decisionOver2 += 2 * radY + 1;
          }
          else {
            radX--;
            // Change for radY -> radY+1, radX -> radX-1 .
            decisionOver2 += 2 * (radY - radX) + 1;
          }
        }
      };
    
  • in Projects
    Avatar for Owen

    Hello, I've just finished writing my version on Snake on Espruino to be played on a 15x15 RGB LED martix board (I can do a write up on how I built it if anyone would be interested).
    For the controls I used an analog 2-axis thumb joystick wired onto the Espruino Pico.
    You can find the code on GitHub and use it how ever you wish, I've added lots of comments explaining what's going on and by changing the settings at the beginning you'll easily be able to get it working on any similar devices.
    Code: https://github.com/owenmcateer/espruino-­snake

    Demo video https://www.youtube.com/watch?v=C0IXREfD­MOk

    • 4 comments
    • 731 views
  • in JavaScript
    Avatar for Owen

    That's an interesting idea. I've also been looking at a similar method where you removed any frame based animation and only use time based animation. So instead of for example "5 spaces per frame" you use "150 spaces per second" and the code decided how to move the item each frame output.

    Here is a detailed article on JavaScript game loops and timing: http://www.isaacsukin.com/news/2015/01/d­etailed-explanation-javascript-game-loop­s-and-timing

Actions