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

Dependents:   HT1632MsgScroller SMS_LEDMatrixPrinter

Revision:
14:b051965066db
Parent:
13:9a869360d0ae
--- a/HT1632_LedMatrix.h	Mon Apr 08 20:54:20 2013 +0000
+++ b/HT1632_LedMatrix.h	Mon Jul 29 21:10:07 2013 +0000
@@ -45,10 +45,11 @@
 #ifndef _HT1632_LEDMATRIX_H
 #define _HT1632_LEDMATRIX_H
 
-#include <inttypes.h>
+#include "mbed.h"
+#include "inttypes.h"
 
 // To include the graphic functions use the following. Comment out to exclude them 
-#define USE_GRAPHIC
+#undef USE_GRAPHIC
 
 // Defines for display sizes
 #define HT1632_08x32  1 
@@ -85,72 +86,12 @@
 */
 class HT1632_LedMatrix : public Stream
 {
-private:
-    /** Select a specific display, numbers as 0 to 3
-     *
-     * @param chip number
-     */
-    void chipselect( uint8_t );
-    /** Deselect a specific display, numbers as 0 to 3
-     *
-     * @param chip number
-     */
-    void chipfree( uint8_t );
-    
-    /** Write bits to HT1632 on pins HT1632_DATA, HT1632_WRCLK
-     * Chip is assumed to already be chip-selected
-     * Bits are shifted out from MSB to LSB, with the first bit sent
-     * being (bits & firstbit), shifted till firsbit is zero.
-     * @param bits
-     * @param firstbit
-     */ 
-    void writebits( uint8_t, uint8_t );
-    
-    /** Write databits to HT1632 on pins HT1632_DATA, HT1632_WRCLK
-     * Chip is assumed to already be chip-selected
-     * Bits are shifted out from LSB to MSB
-     * @param bits
-     * @param count
-     */
-    void writedatabits( uint8_t, uint8_t );
-    
-    /**  * Send a command to the ht1632 chip.
-     * A command consists of a 3-bit "CMD" ID, an 8bit command, and
-     * one "don't care bit".
-     *   Select 1 0 0 c7 c6 c5 c4 c3 c2 c1 c0 xx Free
-     * @param chipno the number of the chip/display to write command to
-     * @param command to send
-     */
-    void sendcmd( uint8_t, uint8_t );
-    
-    /** Send a nibble (4 bits) of data to a particular memory location of the
-     * ht1632.  The command has 3 bit ID, 7 bits of address, and 4 bits of data.
-     *    Select 1 0 1 A6 A5 A4 A3 A2 A1 A0 D0 D1 D2 D3 Free
-     * Note that the address is sent MSB first, while the data is sent LSB first!
-     * This means that somewhere a bit reversal will have to be done to get
-     * zero-based addressing of words and dots within words.
-     * @param chipno
-     * @param address
-     * @param data
-     */
-    void senddata( uint8_t, uint8_t, uint8_t );
-
-    /** Send a byte of data to a particular memory location of the
-     * ht1632.  The command has 3 bit ID, 7 bits of address, and 8 bits of data.
-     *    Select 1 0 1 A6 A5 A4 A3 A2 A1 A0 D0 D1 D2 D3 D4 D5 D6 D7 D8 Free
-     * Note that the address is sent MSB first, while the data is sent LSB first!
-     * This means that somewhere a bit reversal will have to be done to get
-     * zero-based addressing of words and dots within words.
-     * @param chipno
-     * @param address
-     * @param data
-     */
-    void sendcol( uint8_t, uint8_t, uint8_t );
-
 public:
     /** Default Constructor for the display driver
      */
-    HT1632_LedMatrix( );
+//    HT1632_LedMatrix( );
+    HT1632_LedMatrix( PinName clk, PinName dat, PinName cs1, PinName cs2 , PinName cs3, PinName cs4);
+
 
     /** Initialise the library with the display configuration
      * @param Number of horizontal displays, max 4
@@ -307,7 +248,76 @@
                     unsigned char r, unsigned char c);
 #endif
 
-protected:
+private:
+    /** Select a specific display, numbers as 0 to 3
+     *
+     * @param chip number
+     */
+    void chipselect( uint8_t );
+    /** Deselect a specific display, numbers as 0 to 3
+     *
+     * @param chip number
+     */
+    void chipfree( uint8_t );
+    
+    /** Write bits to HT1632 on pins HT1632_DATA, HT1632_WRCLK
+     * Chip is assumed to already be chip-selected
+     * Bits are shifted out from MSB to LSB, with the first bit sent
+     * being (bits & firstbit), shifted till firsbit is zero.
+     * @param bits
+     * @param firstbit
+     */ 
+    void writebits( uint8_t, uint8_t );
+    
+    /** Write databits to HT1632 on pins HT1632_DATA, HT1632_WRCLK
+     * Chip is assumed to already be chip-selected
+     * Bits are shifted out from LSB to MSB
+     * @param bits
+     * @param count
+     */
+    void writedatabits( uint8_t, uint8_t );
+    
+    /**  * Send a command to the ht1632 chip.
+     * A command consists of a 3-bit "CMD" ID, an 8bit command, and
+     * one "don't care bit".
+     *   Select 1 0 0 c7 c6 c5 c4 c3 c2 c1 c0 xx Free
+     * @param chipno the number of the chip/display to write command to
+     * @param command to send
+     */
+    void sendcmd( uint8_t, uint8_t );
+    
+    /** Send a nibble (4 bits) of data to a particular memory location of the
+     * ht1632.  The command has 3 bit ID, 7 bits of address, and 4 bits of data.
+     *    Select 1 0 1 A6 A5 A4 A3 A2 A1 A0 D0 D1 D2 D3 Free
+     * Note that the address is sent MSB first, while the data is sent LSB first!
+     * This means that somewhere a bit reversal will have to be done to get
+     * zero-based addressing of words and dots within words.
+     * @param chipno
+     * @param address
+     * @param data
+     */
+    void senddata( uint8_t, uint8_t, uint8_t );
+
+    /** Send a byte of data to a particular memory location of the
+     * ht1632.  The command has 3 bit ID, 7 bits of address, and 8 bits of data.
+     *    Select 1 0 1 A6 A5 A4 A3 A2 A1 A0 D0 D1 D2 D3 D4 D5 D6 D7 D8 Free
+     * Note that the address is sent MSB first, while the data is sent LSB first!
+     * This means that somewhere a bit reversal will have to be done to get
+     * zero-based addressing of words and dots within words.
+     * @param chipno
+     * @param address
+     * @param data
+     */
+    void sendcol( uint8_t, uint8_t, uint8_t );
+    
+    DigitalOut _wrclk;
+    DigitalOut _data;
+    DigitalOut _cs1;
+    DigitalOut _cs2;
+    DigitalOut _cs3;
+    DigitalOut _cs4;
+    
+//protected:
     virtual int _putc(int value);
     virtual int _getc();