Library for Sure Electronics HT1632 based LED matrix displays. Supports multiple displays connected together.
Dependents: HT1632MsgScroller SMS_LEDMatrixPrinter
HT1632_LedMatrix.h
- Committer:
- SomeRandomBloke
- Date:
- 2012-11-20
- Revision:
- 6:80f554fd77a0
- Parent:
- 5:33b2bfce06b7
- Child:
- 9:8a3c981babd9
File content as of revision 6:80f554fd77a0:
/** Library for Holtek HT1632 LED driver chip, * As implemented on the Sure Electronics DE-DP10X display board * 8 x 32 dot matrix LED module.) * * Original code by: * Nov, 2008 by Bill Westfield ("WestfW") * Copyrighted and distributed under the terms of the Berkely license * (copy freely, but include this notice of original author.) * * Adapted for 8x32 display by FlorinC. * * Arduino Library Created and updated by Andrew Lindsay October/November 2009 * * Ported to Mbed platform by Andrew Lindsay, November 2012 * * @author Andrew Lindsay * * @section LICENSE * * Copyright (c) 2012 Andrew Lindsay (andrew [at] thiseldo [dot] co [dot] uk) * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * @section DESCRIPTION * Definitions for Holtek HT1632 LED driver * */ #ifndef _HT1632_LEDMATRIX_H #define _HT1632_LEDMATRIX_H // To include the graphic functions use the following. Comment out to exclude them #define USE_GRAPHIC #include <inttypes.h> /* * commands written to the chip consist of a 3 bit "ID", followed by * either 9 bits of "Command code" or 7 bits of address + 4 bits of data. */ #define HT1632_ID_CMD 4 /* ID = 100 - Commands */ #define HT1632_ID_RD 6 /* ID = 110 - Read RAM */ #define HT1632_ID_WR 5 /* ID = 101 - Write RAM */ #define HT1632_CMD_SYSDIS 0x00 /* CMD= 0000-0000-x Turn off oscil */ #define HT1632_CMD_SYSON 0x01 /* CMD= 0000-0001-x Enable system oscil */ #define HT1632_CMD_LEDOFF 0x02 /* CMD= 0000-0010-x LED duty cycle gen off */ #define HT1632_CMD_LEDON 0x03 /* CMD= 0000-0011-x LEDs ON */ #define HT1632_CMD_BLOFF 0x08 /* CMD= 0000-1000-x Blink ON */ #define HT1632_CMD_BLON 0x09 /* CMD= 0000-1001-x Blink Off */ #define HT1632_CMD_SLVMD 0x10 /* CMD= 0001-00xx-x Slave Mode */ #define HT1632_CMD_MSTMD 0x14 /* CMD= 0001-01xx-x Master Mode */ #define HT1632_CMD_RCCLK 0x18 /* CMD= 0001-10xx-x Use on-chip clock */ #define HT1632_CMD_EXTCLK 0x1C /* CMD= 0001-11xx-x Use external clock */ #define HT1632_CMD_COMS00 0x20 /* CMD= 0010-ABxx-x commons options */ #define HT1632_CMD_COMS01 0x24 /* CMD= 0010-ABxx-x commons options */ #define HT1632_CMD_COMS10 0x28 /* CMD= 0010-ABxx-x commons options */ #define HT1632_CMD_COMS11 0x2C /* CMD= 0010-ABxx-x commons options */ #define HT1632_CMD_PWM 0xA0 /* CMD= 101x-PPPP-x PWM duty cycle */ #define PIXEL_OFF 0 #define PIXEL_ON 1 /** class HT1632_LedMatrix */ class HT1632_LedMatrix //: public Print { private: /** Select a specific display * * @param chip number */ void chipselect( uint8_t ); void chipfree( uint8_t ); void writebits( uint8_t, uint8_t ); void writedatabits( uint8_t, uint8_t ); void sendcmd( uint8_t, uint8_t ); void senddata( uint8_t, uint8_t, uint8_t ); void sendcol( uint8_t, uint8_t, uint8_t ); public: /** Default Constructor */ HT1632_LedMatrix( ); // Init/Clear/position functions void init( uint8_t, uint8_t ); void displayOff( void ) ; void displayOn( void ) ; void clear(void); void setBrightness( unsigned char ); uint8_t putChar( int, int, char ); void write( uint8_t ); void putString( int, int, char* ); void plot( int, int, char ); void gotoXY(int , int); void getXY(int* , int*); void getXYMax(int*, int*); void shiftCursorX(int ); void setCustomChar( int, unsigned char[]); void setCustomChar( int, unsigned char[], uint8_t ); void scrollLeft(uint8_t, uint8_t); void putShadowRam(); void putShadowRam(uint8_t); // Graphic functions #ifdef USE_GRAPHIC void drawLine(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char c); void drawRectangle(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char c); void drawFilledRectangle(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char c); void drawCircle(unsigned char xc, unsigned char yc, unsigned char r, unsigned char c); #endif }; #endif //_HT1632_LEDMATRIX_H