Android Things Port of the Arduino LedControl library for the MAX7219 LED matrix module
Java
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
assets Update schematic Jul 4, 2017
driver-max72xx Update version to 0.0.3 May 10, 2018
gradle/wrapper
sample Update to Android Things 1.0 May 10, 2018
.android-things-driver.json
.gitignore Initial commit Mar 25, 2017
CHANGELOG.md Update version to 0.0.3 May 10, 2018
LICENSE Prepare for 0.0.1 release Jul 3, 2017
README.md Update version to 0.0.3 May 10, 2018
build.gradle Update to Android Things 1.0 May 10, 2018
gradlew Update dependencies Jun 18, 2017
gradlew.bat
settings.gradle Prepare for 0.0.1 release Jul 3, 2017

README.md

MAX7219 / MAX7221 driver for Android Things

A port of the LedControl Arduino library for Android Things.

photo

Download

dependencies {
    compile 'com.nilhcem.androidthings:driver-max72xx:0.0.3'
}

Usage

Setup

try {
    ledControl = new LedControl("SPI0.0", 1); // second parameter is the number of chained matrices. Here, we only use 1 LED matrix module (8x8).
    for (int i = 0; i < ledControl.getDeviceCount(); i++) {
        ledControl.setIntensity(i, 3);
        ledControl.shutdown(i, false);
        ledControl.clearDisplay(i);
    }
} catch (IOException e) {
    Log.e(TAG, "Error initializing LED matrix", e);
}
// Don't forget to call ledControl.close() when you are done.

Turn on one pixel on matrix #0 at {row:2, col:3}

ledControl.setLed(0, 2, 3, true);

Show a bitmap on matrix #0

Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.smiley);
ledControl.draw(0, bmp);

Draw a single bitmap on multiple devices

// Here, we're drawing a [width=32, height=8] bitmap on a "4 in 1" display module
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.hearts32x8);
ledControl.draw(bmp);

Show "42.ABCDEF" on a MAX7219 8-digit module

ledControl.setDigit(0, 7, (byte) 0x04, false);
ledControl.setDigit(0, 6, (byte) 0x02, true);
ledControl.setDigit(0, 5, (byte) 0x0A, false);
ledControl.setDigit(0, 4, (byte) 0x0B, false);
ledControl.setDigit(0, 3, (byte) 0x0C, false);
ledControl.setDigit(0, 2, (byte) 0x0D, false);
ledControl.setDigit(0, 1, (byte) 0x0E, false);
ledControl.setDigit(0, 0, (byte) 0x0F, false);

Show "123456" on a MAX7219 8-digit module

int curValue = 123456;
for (int i = 0; i < 8; i++) {
    byte value = (byte) ((i != 0 && curValue == 0) ? 16 : (curValue % 10));
    ledControl.setDigit(0, i, value, false);
    curValue /= 10;
}

Schematic

schematic

Credits to https://learn.adafruit.com/trinket-slash-gemma-space-invader-pendant/animation for the Space invaders animation, http://wdi.supelec.fr/boulanger/MicroPython/ for the fritzing part.