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

Dependents:   HT1632MsgScroller SMS_LEDMatrixPrinter

Committer:
SomeRandomBloke
Date:
Fri Nov 09 16:33:53 2012 +0000
Revision:
3:48f430fe186e
Parent:
0:b3e0f5bb3b87
Child:
4:7513dd37efed
minor updates and re-format

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SomeRandomBloke 0:b3e0f5bb3b87 1 /*
SomeRandomBloke 0:b3e0f5bb3b87 2 * HT1632_LedMatrix.h
SomeRandomBloke 0:b3e0f5bb3b87 3 * defintions for Holtek ht1632 LED driver
SomeRandomBloke 0:b3e0f5bb3b87 4 */
SomeRandomBloke 0:b3e0f5bb3b87 5
SomeRandomBloke 0:b3e0f5bb3b87 6 #ifndef _HT1632_LEDMATRIX_H
SomeRandomBloke 0:b3e0f5bb3b87 7 #define _HT1632_LEDMATRIX_H
SomeRandomBloke 0:b3e0f5bb3b87 8
SomeRandomBloke 0:b3e0f5bb3b87 9 #define USE_GRAPHIC
SomeRandomBloke 0:b3e0f5bb3b87 10
SomeRandomBloke 0:b3e0f5bb3b87 11
SomeRandomBloke 0:b3e0f5bb3b87 12 #include <inttypes.h>
SomeRandomBloke 0:b3e0f5bb3b87 13
SomeRandomBloke 0:b3e0f5bb3b87 14 /*
SomeRandomBloke 0:b3e0f5bb3b87 15 * commands written to the chip consist of a 3 bit "ID", followed by
SomeRandomBloke 0:b3e0f5bb3b87 16 * either 9 bits of "Command code" or 7 bits of address + 4 bits of data.
SomeRandomBloke 0:b3e0f5bb3b87 17 */
SomeRandomBloke 0:b3e0f5bb3b87 18 #define HT1632_ID_CMD 4 /* ID = 100 - Commands */
SomeRandomBloke 0:b3e0f5bb3b87 19 #define HT1632_ID_RD 6 /* ID = 110 - Read RAM */
SomeRandomBloke 0:b3e0f5bb3b87 20 #define HT1632_ID_WR 5 /* ID = 101 - Write RAM */
SomeRandomBloke 0:b3e0f5bb3b87 21
SomeRandomBloke 0:b3e0f5bb3b87 22 #define HT1632_CMD_SYSDIS 0x00 /* CMD= 0000-0000-x Turn off oscil */
SomeRandomBloke 0:b3e0f5bb3b87 23 #define HT1632_CMD_SYSON 0x01 /* CMD= 0000-0001-x Enable system oscil */
SomeRandomBloke 0:b3e0f5bb3b87 24 #define HT1632_CMD_LEDOFF 0x02 /* CMD= 0000-0010-x LED duty cycle gen off */
SomeRandomBloke 0:b3e0f5bb3b87 25 #define HT1632_CMD_LEDON 0x03 /* CMD= 0000-0011-x LEDs ON */
SomeRandomBloke 0:b3e0f5bb3b87 26 #define HT1632_CMD_BLOFF 0x08 /* CMD= 0000-1000-x Blink ON */
SomeRandomBloke 0:b3e0f5bb3b87 27 #define HT1632_CMD_BLON 0x09 /* CMD= 0000-1001-x Blink Off */
SomeRandomBloke 0:b3e0f5bb3b87 28 #define HT1632_CMD_SLVMD 0x10 /* CMD= 0001-00xx-x Slave Mode */
SomeRandomBloke 0:b3e0f5bb3b87 29 #define HT1632_CMD_MSTMD 0x14 /* CMD= 0001-01xx-x Master Mode */
SomeRandomBloke 0:b3e0f5bb3b87 30 #define HT1632_CMD_RCCLK 0x18 /* CMD= 0001-10xx-x Use on-chip clock */
SomeRandomBloke 0:b3e0f5bb3b87 31 #define HT1632_CMD_EXTCLK 0x1C /* CMD= 0001-11xx-x Use external clock */
SomeRandomBloke 0:b3e0f5bb3b87 32 #define HT1632_CMD_COMS00 0x20 /* CMD= 0010-ABxx-x commons options */
SomeRandomBloke 0:b3e0f5bb3b87 33 #define HT1632_CMD_COMS01 0x24 /* CMD= 0010-ABxx-x commons options */
SomeRandomBloke 0:b3e0f5bb3b87 34 #define HT1632_CMD_COMS10 0x28 /* CMD= 0010-ABxx-x commons options */
SomeRandomBloke 0:b3e0f5bb3b87 35 #define HT1632_CMD_COMS11 0x2C /* CMD= 0010-ABxx-x commons options */
SomeRandomBloke 0:b3e0f5bb3b87 36 #define HT1632_CMD_PWM 0xA0 /* CMD= 101x-PPPP-x PWM duty cycle */
SomeRandomBloke 0:b3e0f5bb3b87 37
SomeRandomBloke 0:b3e0f5bb3b87 38 #define PIXEL_OFF 0
SomeRandomBloke 0:b3e0f5bb3b87 39 #define PIXEL_ON 1
SomeRandomBloke 0:b3e0f5bb3b87 40
SomeRandomBloke 3:48f430fe186e 41 //class HT1632_LedMatrix
SomeRandomBloke 3:48f430fe186e 42 class HT1632_LedMatrix //: public Print
SomeRandomBloke 0:b3e0f5bb3b87 43 {
SomeRandomBloke 3:48f430fe186e 44 private:
SomeRandomBloke 0:b3e0f5bb3b87 45 void chipselect( uint8_t );
SomeRandomBloke 0:b3e0f5bb3b87 46 void chipfree( uint8_t );
SomeRandomBloke 0:b3e0f5bb3b87 47 void writebits( uint8_t, uint8_t );
SomeRandomBloke 0:b3e0f5bb3b87 48 void writedatabits( uint8_t, uint8_t );
SomeRandomBloke 0:b3e0f5bb3b87 49 void sendcmd( uint8_t, uint8_t );
SomeRandomBloke 0:b3e0f5bb3b87 50 void senddata( uint8_t, uint8_t, uint8_t );
SomeRandomBloke 0:b3e0f5bb3b87 51 void sendcol( uint8_t, uint8_t, uint8_t );
SomeRandomBloke 0:b3e0f5bb3b87 52
SomeRandomBloke 3:48f430fe186e 53 public:
SomeRandomBloke 0:b3e0f5bb3b87 54 HT1632_LedMatrix( );
SomeRandomBloke 3:48f430fe186e 55
SomeRandomBloke 0:b3e0f5bb3b87 56 // Init/Clear/position functions
SomeRandomBloke 0:b3e0f5bb3b87 57 void init( uint8_t, uint8_t );
SomeRandomBloke 0:b3e0f5bb3b87 58 void clear(void);
SomeRandomBloke 0:b3e0f5bb3b87 59 void setBrightness( unsigned char );
SomeRandomBloke 0:b3e0f5bb3b87 60 uint8_t putChar( int, int, char );
SomeRandomBloke 0:b3e0f5bb3b87 61 void write( uint8_t );
SomeRandomBloke 0:b3e0f5bb3b87 62 void putString( int, int, char* );
SomeRandomBloke 0:b3e0f5bb3b87 63 void plot( int, int, char );
SomeRandomBloke 0:b3e0f5bb3b87 64 void gotoXY(int , int);
SomeRandomBloke 0:b3e0f5bb3b87 65 void getXY(int* , int*);
SomeRandomBloke 0:b3e0f5bb3b87 66 void getXYMax(int*, int*);
SomeRandomBloke 0:b3e0f5bb3b87 67 void shiftCursorX(int );
SomeRandomBloke 0:b3e0f5bb3b87 68 void setCustomChar( int, unsigned char[]);
SomeRandomBloke 0:b3e0f5bb3b87 69 void setCustomChar( int, unsigned char[], uint8_t );
SomeRandomBloke 0:b3e0f5bb3b87 70 void scrollLeft(uint8_t);
SomeRandomBloke 0:b3e0f5bb3b87 71 void putShadowRam();
SomeRandomBloke 0:b3e0f5bb3b87 72 void putShadowRam(uint8_t);
SomeRandomBloke 0:b3e0f5bb3b87 73 // Graphic functions
SomeRandomBloke 0:b3e0f5bb3b87 74 #ifdef USE_GRAPHIC
SomeRandomBloke 0:b3e0f5bb3b87 75 void drawLine(unsigned char x1, unsigned char y1,
SomeRandomBloke 3:48f430fe186e 76 unsigned char x2, unsigned char y2, unsigned char c);
SomeRandomBloke 0:b3e0f5bb3b87 77 void drawRectangle(unsigned char x1, unsigned char y1,
SomeRandomBloke 3:48f430fe186e 78 unsigned char x2, unsigned char y2, unsigned char c);
SomeRandomBloke 0:b3e0f5bb3b87 79 void drawFilledRectangle(unsigned char x1, unsigned char y1,
SomeRandomBloke 3:48f430fe186e 80 unsigned char x2, unsigned char y2, unsigned char c);
SomeRandomBloke 0:b3e0f5bb3b87 81 void drawCircle(unsigned char xc, unsigned char yc,
SomeRandomBloke 3:48f430fe186e 82 unsigned char r, unsigned char c);
SomeRandomBloke 0:b3e0f5bb3b87 83 #endif
SomeRandomBloke 0:b3e0f5bb3b87 84
SomeRandomBloke 0:b3e0f5bb3b87 85 };
SomeRandomBloke 0:b3e0f5bb3b87 86
SomeRandomBloke 0:b3e0f5bb3b87 87 #endif //_HT1632_LEDMATRIX_H