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

Dependents:   HT1632MsgScroller SMS_LEDMatrixPrinter

Committer:
SomeRandomBloke
Date:
Mon Nov 12 23:13:04 2012 +0000
Revision:
5:33b2bfce06b7
Parent:
4:7513dd37efed
Child:
6:80f554fd77a0
Added displayOn/Off functions

Who changed what in which revision?

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