npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

espruino-adafruit-led-backpack

v1.1.0

Published

Espruino Driver for Adafruit's LED Matrix + Backpack

Downloads

12

Readme

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.

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 = require("espruino-adafruit-led-backpack").Matrix8x8;

//Clock: B6 Data: B7 Device Address: 0x70, Brightness: 0-15
var matrix = new Matrix8x8({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 :)
function delay(time) {
  var i = 0;
  while(i < time * 10) {  i++; }
}

//Run Example Code
function testDisplay() {
  //Draws Smiley Face
  matrix.clear();
  matrix.drawBitmap(smileBmp);
  matrix.writeDisplay();
  delay(500);

  //Draws Neutral Face
  matrix.clear();
  matrix.drawBitmap(neutralBmp);
  matrix.writeDisplay();
  delay(500);

  //Draws Frowny Face
  matrix.clear();
  matrix.drawBitmap(frownBmp);
  matrix.writeDisplay();
  delay(500);

  //Draws a pixel at the top left x = 0, y = 0
  matrix.clear();
  matrix.drawPixel(0, 0);
  matrix.writeDisplay();
  delay(500);

  //Draws a diagonal line between x1 = 0, y1 = 0 and x2 = 7, y2 = 7
  matrix.clear();
  matrix.drawLine(0,0, 7,7);
  matrix.writeDisplay();
  delay(500);

  //Draws a rectangle at x = 0, y = 0 and a witdth = 8 and height = 8
  matrix.clear();
  matrix.drawRect(0,0, 8,8);
  matrix.writeDisplay();
  delay(500);

  //Draws the same rectangle as abover with a filled in rectangle 4 by 4 starting at x = 2, y = 2
  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:

Example Code for 16x8 Matrix

var Matrix16x8 = require("espruino-adafruit-led-backpack").Matrix16x8;

var matrix = new Matrix16x8({scl:B6, sda:B7, address:0x70, brightness: 0});

// draw smile and frown side by side
var smileFrownBmp = [
    0b00111100, 0b00111100,
    0b01000010, 0b01000010,
    0b10100101, 0b10100101,
    0b10000001, 0b10000001,
    0b10100101, 0b10011001,
    0b10011001, 0b10100101,
    0b01000010, 0b01000010,
    0b00111100, 0b00111100
];

matrix.clear();
matrix.drawBitmap(smileFrownBmp);
matrix.writeDisplay();

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 = 7
matrix.drawLine(3, 3, 15, 7);

Todos - A.K.A. Please Help

  • [ ] Finish Parity for 8 x 8 Display
    • [ ] drawCircle()
    • [ ] setTextWrap()
    • [ ] setTextColor()
    • [ ] setCursor()
    • [ ] print()
    • [ ] setRotation()
  • [ ] Implement 7 Segment Display