Library for Sure Electronics HT1632 based LED matrix displays. Supports multiple displays connected together.
Dependents: HT1632MsgScroller SMS_LEDMatrixPrinter
Revision 6:80f554fd77a0, committed 2012-11-20
- Comitter:
- SomeRandomBloke
- Date:
- Tue Nov 20 13:08:43 2012 +0000
- Parent:
- 5:33b2bfce06b7
- Child:
- 8:61130f9b5b79
- Commit message:
- tweeks
Changed in this revision
HT1632_LedMatrix.cpp | Show annotated file Show diff for this revision Revisions of this file |
HT1632_LedMatrix.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/HT1632_LedMatrix.cpp Mon Nov 12 23:13:04 2012 +0000 +++ b/HT1632_LedMatrix.cpp Tue Nov 20 13:08:43 2012 +0000 @@ -1,7 +1,6 @@ -/*********************************************************************** - * 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.) +/** 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") @@ -13,7 +12,35 @@ * 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 + * Functions to drive displays + * + */ #include "mbed.h" #include "HT1632_LedMatrix.h" @@ -23,24 +50,18 @@ #define LOW 0 /* * Set these constants to the values of the pins connected to the SureElectronics Module - * NOTE - these are different from the original demo code by westfw - * - * Use Pin Mappings 8-11 for CS1 to 4, 12 for Data and 13 for Clock - * Use mixture of #define and variables. - * Pin numbers are for setup and port identifiers are for direct port writes. + * For mbed, use WR=p7, DATA=p5, cs1=p17, cs2=p18, cs3=p19, cs4=p20 */ -// For mbed, use WR=p7, DATA=p5, cs1=p17, cs2=p18, cs3=p19, cs4=p20 - -DigitalOut ht1632_wrclk(p7); // For Test : Led1 is Clock -DigitalOut ht1632_data(p5); // Led2 is Data .... +DigitalOut ht1632_wrclk(p7); +DigitalOut ht1632_data(p5); DigitalOut ht1632_cs1(p17); DigitalOut ht1632_cs2(p18); DigitalOut ht1632_cs3(p19); DigitalOut ht1632_cs4(p20); // CS pins 17, 18, 19, 20 used. -DigitalOut ht1632_cs[4] = {p17, p18, p19, p20}; // Chip Select (1, 2, 3, or 4) +DigitalOut ht1632_cs[4] = {p17, p18, p19, p20}; // Chip Select (1, 2, 3, 4) // helper macros #define chip_number(x,y) (x >> 5) + (y >> 3)*numYDevices @@ -117,14 +138,16 @@ cursorY = 0; } -void HT1632_LedMatrix::displayOff( void ) { +void HT1632_LedMatrix::displayOff( void ) +{ for (uint8_t chipno=0; chipno<4; chipno++) { chipfree(chipno); // unselect it sendcmd(chipno, HT1632_CMD_LEDOFF); // LEDs on } } -void HT1632_LedMatrix::displayOn( void ) { +void HT1632_LedMatrix::displayOn( void ) +{ for (uint8_t chipno=0; chipno<4; chipno++) { chipfree(chipno); // unselect it sendcmd(chipno, HT1632_CMD_LEDON); // LEDs on @@ -180,11 +203,6 @@ while (count) { ht1632_wrclk = LOW; ht1632_data = bits & 1; -// if (bits & 1) { -// ht1632_data = HIGH; -// } else { -// ht1632_data = LOW; -// } ht1632_wrclk = HIGH; count--; bits >>= 1; @@ -449,14 +467,14 @@ for (int i=xMax-numberCols; i<xMax; i++) { shadowram[i]=0; } -/* - for (int i=0; i<128-numberCols-1; i++) { - shadowram[i]=shadowram[i+numberCols]; - } - for (int i=128-numberCols; i<128; i++) { - shadowram[i]=0; - } -*/ + /* + for (int i=0; i<128-numberCols-1; i++) { + shadowram[i]=shadowram[i+numberCols]; + } + for (int i=128-numberCols; i<128; i++) { + shadowram[i]=0; + } + */ cursorX -= numberCols; if (cursorX < 0 ) cursorX = 0; }
--- a/HT1632_LedMatrix.h Mon Nov 12 23:13:04 2012 +0000 +++ b/HT1632_LedMatrix.h Tue Nov 20 13:08:43 2012 +0000 @@ -1,14 +1,53 @@ -/* -* HT1632_LedMatrix.h -* defintions for Holtek ht1632 LED driver -*/ +/** 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> /* @@ -38,10 +77,15 @@ #define PIXEL_OFF 0 #define PIXEL_ON 1 -//class HT1632_LedMatrix +/** 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 ); @@ -51,6 +95,8 @@ void sendcol( uint8_t, uint8_t, uint8_t ); public: + /** Default Constructor + */ HT1632_LedMatrix( ); // Init/Clear/position functions