Avatar for chalkers

chalkers

Member since Apr 2015 • Last active Jun 2016
  • 1 conversations
  • 13 comments

Most recent activity

    • 20 comments
    • 7,299 views
  • in Interfacing
    Avatar for chalkers

    The module uses a similar API to what the arduino library had for the backpack. It uses the graphics API in the module :)

  • in Interfacing
    Avatar for chalkers

    Hey Kylir

    I created an NPM module...you can check it out here:
    https://www.npmjs.com/package/espruino-a­dafruit-led-backpack

    Feel free to contribute additional functionality via GitHub :)

    But I have the basics of drawing implemented :)

    Regards
    Andrew

  • in Interfacing
    Avatar for chalkers

    @Gordon How do I go about contributing modules to the Espruino project?

  • in Interfacing
    Avatar for chalkers

    I created a git repo with tests and this is the function we got to get it working:

    module.exports = function rotate(value) {
        var rotated = value >> 1;
        // Check to see if the first bit was set...
        if (1 & value) {
        	//...flip the furthest bit on.
        	rotated += (1 << 7);
        }
        return rotated;
    };
    
  • in Interfacing
    Avatar for chalkers

    Thanks for getting me this far!

    return (a>>1)||(a<<7); 
    

    This rotated the pixels correctly except for one last issue...

    I can draw a line, I can set a pixel anywhere in the grid.

    If the left most x is on 0 and it doesn't share the row with another pixel it will show up. If it does share with another pixel, it switches off.

    g.clear();
    //face top
    g.setPixel(2,0);
    g.setPixel(3,0);
    g.setPixel(4,0);
    g.setPixel(5,0);
    g.setPixel(1,1);
    g.setPixel(6,1);
    
    //face left
    g.setPixel(0,2);
    g.setPixel(0,3); // Won't show because of eyes on 2 and 5.
    g.setPixel(0,4);
    g.setPixel(0,5);
    
    //eyes
    g.setPixel(2,3);
    g.setPixel(5,3);
    
    //face right
    //g.setPixel(7,2);
    //g.setPixel(7,3);
    //g.setPixel(7,4);
    //g.setPixel(7,5);
    
    //face bottom
    g.setPixel(2,7);
    g.setPixel(3,7);
    g.setPixel(4,7);
    g.setPixel(5,7);
    g.setPixel(1,6);
    g.setPixel(6,6);
    
    g.flip();
    

    If I comment out the eyes the left most pixel will show:

    
    g.clear();
    //face top
    g.setPixel(2,0);
    g.setPixel(3,0);
    g.setPixel(4,0);
    g.setPixel(5,0);
    g.setPixel(1,1);
    g.setPixel(6,1);
    
    //face left
    g.setPixel(0,2);
    g.setPixel(0,3); // Won't show because of eyes on 2 and 5.
    g.setPixel(0,4);
    g.setPixel(0,5);
    
    
    //eyes
    //g.setPixel(2,3);
    //g.setPixel(5,3);
    
    //face right
    //g.setPixel(7,2);
    //g.setPixel(7,3);
    //g.setPixel(7,4);
    //g.setPixel(7,5);
    
    //face bottom
    g.setPixel(2,7);
    g.setPixel(3,7);
    g.setPixel(4,7);
    g.setPixel(5,7);
    g.setPixel(1,6);
    g.setPixel(6,6);
    
    g.flip();
    

  • in Interfacing
    Avatar for chalkers

    So do I have to do a bit wise operation on the buffer?

  • in Interfacing
    Avatar for chalkers

    PaintYourDragon from adafruit said this on Twitter:

    It's wired that way for routing reasons; need to ROL or ROR (forget
    which).

    https://twitter.com/paintyourdragon/stat­us/663086330834907136

    I don't understand what that means :)

  • in Interfacing
    Avatar for chalkers

    It seems 0,0 starts at 0,1 or 1,0.

  • in Interfacing
    Avatar for chalkers

    The horse shoe looking one was I2C1.writeTo(0x70, 0, g.buffer);

    I2C1.writeTo(0x70, 1, g.buffer); and I2C1.writeTo(0x70, 7, g.buffer); were off.

    I2C1.writeTo(0x70, 2, g.buffer); and I2C1.writeTo(0x70, 14, g.buffer); created the L shape.

Actions