espruino-adafruit-led-backpack
This is a driver that closely mirrors the Adafruit's LED Backpack Library.
This package currently works with Adafruit 8x8 and 16x8 Single Color LED Backpacks.
- 8x8 0.8" (872, 871, 870)
- 8x8 1.2" (1049, 1052, 1051, 1050, 1614, 1632, 1857, 1854, 1855, 1856)
- 16x8 1.2" (2044, 2038, 2037, 2040, 2041, 2039, 2043, 2042, 2035, 2036, 2052, 2054)
- 16x8 LED Matrix Driver Backpack (1427)
This library was tested on on the Small 1.2" 8x8 Ultra Bright Square White LED Matrix + Backpack, PRODUCT ID: 1857 and on the 16x8 1.2" Ultra Bright Square Green LED Matrix + Backpack.
This doesn't work with the 7-Segment backpacks.
Example Code for 8 x 8 Matrix
To use this library in the Espruino Web IDE you need to go to Settings > Communications > Check 'Load modules from NPM (BETA)'
.
Here's some example code that mirrors the Adafruit's example code for the 8x8 Matrix example code for Arduino.
var Matrix8x8 = Matrix8x8; //Clock: B6 Data: B7 Device Address: 0x70, Brightness: 0-15var matrix = scl:B6 sda:B7 address:0x70 brightness: 0; //Squint a little and you can see the faces! // :)var smileBmp = 0b00111100 0b01000010 0b10100101 0b10000001 0b10100101 0b10011001 0b01000010 0b00111100//:| neutralBmp = 0b00111100 0b01000010 0b10100101 0b10000001 0b10111101 0b10000001 0b01000010 0b00111100//:( frownBmp = 0b00111100 0b01000010 0b10100101 0b10000001 0b10011001 0b10100101 0b01000010 0b00111100; //Hacky scynchronous timeout :) { var i = 0; whilei < time * 10 i++; } //Run Example Code { //Draws Smiley Face matrixclear; matrix; matrix; ; //Draws Neutral Face matrixclear; matrix; matrix; ; //Draws Frowny Face matrixclear; matrix; matrix; ; //Draws a pixel at the top left x = 0, y = 0 matrixclear; matrix; matrix; ; //Draws a diagonal line between x1 = 0, y1 = 0 and x2 = 7, y2 = 7 matrixclear; matrix; matrix; ; //Draws a rectangle at x = 0, y = 0 and a witdth = 8 and height = 8 matrixclear; matrix; matrix; ; //Draws the same rectangle as abover with a filled in rectangle 4 by 4 starting at x = 2, y = 2 matrixclear; matrix; matrix; matrix; ;} ;
Here's a gif of the above code in action:
Example Code for 16x8 Matrix
var Matrix16x8 = Matrix16x8; var matrix = scl:B6 sda:B7 address:0x70 brightness: 0; // draw smile and frown side by sidevar smileFrownBmp = 0b00111100 0b00111100 0b01000010 0b01000010 0b10100101 0b10100101 0b10000001 0b10000001 0b10100101 0b10011001 0b10011001 0b10100101 0b01000010 0b01000010 0b00111100 0b00111100; matrixclear;matrix;matrix;
The functions drawLine
, drawPixel
, drawRect
and fillRect
work the same as for the 8x8 Matrix except you can address up to 16 pixels on the x axis:
// Draws a diagonal line between x1 = 3, y1 = 3 and x2 = 15, y2 = 7matrix;
Todos - A.K.A. Please Help
- Finish Parity for 8 x 8 Display
-
drawCircle()
-
setTextWrap()
-
setTextColor()
-
setCursor()
-
print()
-
setRotation()
-
- Implement 7 Segment Display