espruino-adafruit-led-backpack
This is an driver that closely mirrors the Adafruit's LED Backpack Library.
This package currently works with Adafruit 8x8 Single Color LED Backpacks.
- 0.8" (872, 871, 870 )
- 1.2" (1049, 1052, 1051, 1050, 1614, 1632, 1857, 1854, 1855, 1856)
This library was tested on on the Small 1.2" 8x8 Ultra Bright Square White LED Matrix + Backpack, PRODUCT ID: 1857.
This doesn't work with the 7-Segment backpacks or 8x16 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 = require("espruino-adafruit-led-backpack").Matrix8x8;
var matrix = new Matrix8x8({scl:B6, sda:B7, address:0x70, brightness: 0});
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
];
function delay(time) {
var i = 0;
while(i < time * 10) { i++; }
}
function testDisplay() {
matrix.clear();
matrix.drawBitmap(smileBmp);
matrix.writeDisplay();
delay(500);
matrix.clear();
matrix.drawBitmap(neutralBmp);
matrix.writeDisplay();
delay(500);
matrix.clear();
matrix.drawBitmap(frownBmp);
matrix.writeDisplay();
delay(500);
matrix.clear();
matrix.drawPixel(0, 0);
matrix.writeDisplay();
delay(500);
matrix.clear();
matrix.drawLine(0,0, 7,7);
matrix.writeDisplay();
delay(500);
matrix.clear();
matrix.drawRect(0,0, 8,8);
matrix.writeDisplay();
delay(500);
matrix.clear();
matrix.drawRect(0,0, 8,8);
matrix.fillRect(2,2, 4,4);
matrix.writeDisplay();
delay(500);
}
testDisplay();
Here's a gif of the above code in action:
![](https://github.com/chalkers/espruino-adafruit-led-backpack/raw/HEAD/8x8.gif)
Todos - A.K.A. Please Help