Please note that User Registration has been temporarily disabled due to a recent increase in automated registrations. If anyone needs an account, please request one here: RequestAccount. Thanks for your patience!--Wmat (talk)
Please email User:Wmat if you experience any issues with the Request Account form.

Adafruit: 16x24 Red LED Matrix Panel

From eLinux.org
Revision as of 23:25, 8 November 2012 by Larmorgs (Talk | contribs)

Jump to: navigation, search


Overview: 2
Wiring:   2
Code:     2
git/Compiles with make: 2
Demo:     2
Total:    10
Comments: Looks good.  
Have you been able to look into other ways besides bit banging to drive the display?

16x24 LED Matrix Display

Overview

Adafruit's 16x24 Red LED Matrix Panel uses the HT1632C LED driver. The driver has the ability to dim and flash and they can be chained together to produce large displays. The code developed for this Mini Project is based on Adafruit's original HT1632 github repository originally written for Arduino. It also uses a modified version of BoneHeader.h to support C++ originally from Andrew Miller's github repository.

16x24 LED Matrix Display Side Connector
Back connector on the 16x24 LED Matrix Display courtesy of adafruit

Inputs and Outputs

A single matrix panel can be powered directly off of the BeagleBone's 3.3V supply (running only on USB power). The interface is a bit-banged serial interface requiring 3 pins: chip select (active low), write clock (rising edge trigger), and data. The HT1632C also has a read pin, but it is not populated or used in the example code developed for this Mini Project.

Bone Usage

P9 Connector Pinout
Pinout for the P9 header on the BeagleBone
16x24 LED Matrix Board Side Connector
Board side connector with wires attached courtesy of ladyada

The pin mappings

P9 pin # (BeagleBone pin) -> Panel pin (wire color)

1 (GND) -> GND (black)

3 (VDD_3V3EXP) -> VCC (red)

15 (R13/GPIO1_16) -> CS0 (white)

23 (V14/GPIO1_17) -> DATA (orange)

12 (A14/GPIO1_28) -> WR (yellow)


Sample C++ Code

The code shown below is sample code to demonstrate the 16x24 Red LED Matrix Panel.

#include "../Resources/adafruit/HT1632/HT1632.h"
#include <stdio.h>
#include <unistd.h>
#include "icons.c"

/* 
This is a basic demo program showing how to write to a HT1632
These can be used for up to 16x24 LED matrix grids, with internal memory
and using only 3 pins - data, write and select.
Multiple HT1632's can share data and write pins, but need unique CS pins.
*/

#define BANK 1
#define DATA 28 //1_28
#define WR 17 //1_17
#define CS 16 //1_16

void testMatrix2(HT1632LEDMatrix *matrix) {
  //Display "A+"
  matrix->setTextSize(2);
  matrix->setTextColor(1);
  matrix->write('A');
  matrix->write('+');
  matrix->writeScreen();
  usleep(2000000);

  // Blink!
  matrix->blink(true);
  usleep(2000000);
  matrix->blink(false);

  // Dim down and then up
  for (int8_t i = 15; i >= 0; i--) {
    matrix->setBrightness(i);
    usleep(100000);
  }
  for (int8_t i = 0; i < 16; i++) {
    matrix->setBrightness(i);
    usleep(100000);
  }

  // Blink again!
  matrix->blink(true);
  usleep(2000000);
  matrix->blink(false);
}

void testMatrix1(HT1632LEDMatrix *matrix) {
  //Display icon
  matrix->drawBitmap(0, 0, icon, matrix->width(), matrix->height(), 1);  
  matrix->writeScreen();
  usleep(2000000);

  // Blink!
  matrix->blink(true);
  usleep(2000000);
  matrix->blink(false);

  // Dim down and then up
  for (int8_t i = 15; i >= 0; i--) {
    matrix->setBrightness(i);
    usleep(100000);
  }
  for (int8_t i = 0; i < 16; i++) {
    matrix->setBrightness(i);
    usleep(100000);
  }

  // Blink again!
  matrix->blink(true);
  usleep(2000000);
  matrix->blink(false);
}

int main(void) {
  printf("Starting...\n");
  HT1632LEDMatrix matrix = HT1632LEDMatrix(BANK, DATA, WR, CS);
  matrix.begin(HT1632_COMMON_16NMOS);
  
  printf("Clear\n");
  matrix.clearScreen();
  
  printf("Test #1\n");
  testMatrix1(&matrix);

  printf("Clear\n");
  matrix.clearScreen();
  
  printf("Test2\n");
  testMatrix2(&matrix);
  
  printf("Done!\n");
  return 0;
}

This code example and the required resources can be found in Greg Larmore's github repository

Updates

A node.js implementation has been added that sends hard coded pictures to the bone. Also the driver has been switched over to use mmap for gpio writes to speed it up. Ideally the writes should occur at 500kHz now.

Future Work

The node.js implementation should be modified to take in a .gif file. Or scrolling text could be implemented.