Library for Sure Electronics HT1632 based LED matrix displays. Supports multiple displays connected together.

Dependents:   HT1632MsgScroller SMS_LEDMatrixPrinter

Files at this revision

API Documentation at this revision

Comitter:
SomeRandomBloke
Date:
Fri Nov 09 08:54:37 2012 +0000
Parent:
1:96695118ee13
Child:
3:48f430fe186e
Commit message:
Clean up parts of library, remove AVR definitions

Changed in this revision

HT1632_LedMatrix.cpp Show annotated file Show diff for this revision Revisions of this file
font_5x7_p.h Show annotated file Show diff for this revision Revisions of this file
--- a/HT1632_LedMatrix.cpp	Fri Nov 09 08:48:49 2012 +0000
+++ b/HT1632_LedMatrix.cpp	Fri Nov 09 08:54:37 2012 +0000
@@ -1,5 +1,5 @@
 /***********************************************************************
- * HT1632_LedMatrix.cpp - Arduino library for Holtek HT1632 LED driver chip,
+ * HT1632_LedMatrix.cpp - Library for Holtek HT1632 LED driver chip,
  *     As implemented on the Sure Electronics DE-DP10X display board
  *       (8 x 32 dot matrix LED module.)
  *
@@ -10,16 +10,15 @@
  *
  * Adapted for 8x32 display by FlorinC.
  *
- * Library Created and updated by Andrew Lindsay October/November 2009
+ * Arduino Library Created and updated by Andrew Lindsay October/November 2009
+ *
+ * Ported to Mbed platform by Andrew Lindsay, November 2012
  ***********************************************************************/
 
 #include "mbed.h"
 #include "HT1632_LedMatrix.h"
 #include "font_5x7_p.h"
 
-// Use this define to select Direct port writes for speed or regular arduino digitalWrite functions
-#undef DIRECTIO
-
 #define HIGH 1
 #define LOW 0
 /*
@@ -33,11 +32,6 @@
 
 // For mbed, use WR=p7, DATA=p5, cs1=p17, cs2=p18, cs3=p19, cs4=p20
 
-//#define LOWPINS
-//#define LOWPINS1
-//#define HIGHPINS
-
-//#ifdef LOWPINS
 DigitalOut ht1632_wrclk(p7); // For Test : Led1 is Clock
 DigitalOut ht1632_data(p5); //            Led2 is Data ....
 DigitalOut ht1632_cs1(p17);
@@ -45,30 +39,15 @@
 DigitalOut ht1632_cs3(p19);
 DigitalOut ht1632_cs4(p20);
 
-// Port D defines for 2-7
-// If using Nuelectronics ethernet shield, need to cut unused interrupt track to PD2
-//uint8_t ht1632_cs[4] = {ht1632_cs1, ht1632_cs2, ht1632_cs3, ht1632_cs4};    // Chip Select (1, 2, 3, or 4)
+// CS pins 17, 18, 19, 20 used.
 DigitalOut  ht1632_cs[4] = {p17, p18, p19, p20};    // Chip Select (1, 2, 3, or 4)
-//volatile uint8_t* ht1632_cs_Port[4] = {&PORTD, &PORTD, &PORTD, &PORTD};    // Chip Select (1, 2, 3, or 4)
-//volatile uint8_t* ht1632_cs_DDR[4] = {&DDRD, &DDRD, &DDRD, &DDRD};    // Chip Select (1, 2, 3, or 4)
-//#define HT1632_DATA       6      // Data pin
-//#define HT1632_DATA_PORT  PORTD  // Data port
-//#define HT1632_DATA_DDR   DDRD   // Data port
-//#define HT1632_WRCLK      7      // Write clock pin
-//#define HT1632_WRCLK_PORT PORTD  // Write clock port
-//#define HT1632_WRCLK_DDR  DDRD   // Write clock port
-//#endif
-
 
 // helper macros
-//#define output_low(port,pin) port &= ~(1<<pin)
-//#define output_high(port,pin) port |= (1<<pin)
 #define chip_number(x,y) (x >> 5) + (y >> 3)*numYDevices
 #define chip_nibble_address(x,y) ((x%32)<<1) + ((y%8)>>2);  
 #define chip_byte_address(x,y) ((x%32)<<1);
 #define max(a, b)  (((a) > (b)) ? (a) : (b))
 
-
 // Display size and configuration, defaul is for a single 8x32 display
 uint8_t numDevices = 1;    // Total number of devices
 uint8_t numXDevices = 1;   // Number of horizontal devices
@@ -88,7 +67,6 @@
 uint8_t shadowram[129];  // our copy of the display's RAM
 
 
-
 // Custom character buffers - 8 characters available
 // 6 cols * 8 rows - first byte of each char is the number of columns used
 // Bits are aranged in columns with LSB at top
@@ -114,17 +92,13 @@
   xMax = 32 * numXDevices-1;
   numYDevices = yDevices;
   yMax = 8 * numYDevices-1;
+  numDevices = numXDevices * numYDevices;
 
-  numDevices = numXDevices * numYDevices;
   // Disable all display CS lines by taking high
   for( uint8_t i = 0; i < 4; i++ )
     ht1632_cs[i] = HIGH;
 
-//  HT1632_WRCLK_DDR |= _BV( HT1632_WRCLK );      // set pins to output
-//  HT1632_DATA_DDR |= _BV( HT1632_DATA );
-
   for (uint8_t chipno=0; chipno<numDevices; chipno++){
- //     *ht1632_cs_DDR[chipno] |= _BV( ht1632_cs[chipno] );   // output pin
       chipfree(chipno);     // unselect it 
       sendcmd(chipno, HT1632_CMD_SYSDIS);  // Disable system
       sendcmd(chipno, HT1632_CMD_COMS10);  // 08*32, PMOS drivers
--- a/font_5x7_p.h	Fri Nov 09 08:48:49 2012 +0000
+++ b/font_5x7_p.h	Fri Nov 09 08:54:37 2012 +0000
@@ -2,7 +2,6 @@
 // 5 x 7 font
 // 1 pixel space at left and bottom
 // index = ASCII - 32
-//#include <avr/pgmspace.h>
 
 //***** Small fonts (5x7) **********