Library for Sure Electronics HT1632 based LED matrix displays. Supports multiple displays connected together.
Dependents: HT1632MsgScroller SMS_LEDMatrixPrinter
HT1632_LedMatrix.h@14:b051965066db, 2013-07-29 (annotated)
- Committer:
- SomeRandomBloke
- Date:
- Mon Jul 29 21:10:07 2013 +0000
- Revision:
- 14:b051965066db
- Parent:
- 13:9a869360d0ae
Updated library to specify pin names in constructor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SomeRandomBloke | 6:80f554fd77a0 | 1 | /** Library for Holtek HT1632 LED driver chip, |
SomeRandomBloke | 11:0fac71b7ec1d | 2 | * As implemented on the Sure Electronics DE-DP10X or and DE-DP13X1X display board |
SomeRandomBloke | 6:80f554fd77a0 | 3 | * 8 x 32 dot matrix LED module.) |
SomeRandomBloke | 6:80f554fd77a0 | 4 | * |
SomeRandomBloke | 6:80f554fd77a0 | 5 | * Original code by: |
SomeRandomBloke | 6:80f554fd77a0 | 6 | * Nov, 2008 by Bill Westfield ("WestfW") |
SomeRandomBloke | 6:80f554fd77a0 | 7 | * Copyrighted and distributed under the terms of the Berkely license |
SomeRandomBloke | 6:80f554fd77a0 | 8 | * (copy freely, but include this notice of original author.) |
SomeRandomBloke | 6:80f554fd77a0 | 9 | * |
SomeRandomBloke | 6:80f554fd77a0 | 10 | * Adapted for 8x32 display by FlorinC. |
SomeRandomBloke | 6:80f554fd77a0 | 11 | * |
SomeRandomBloke | 6:80f554fd77a0 | 12 | * Arduino Library Created and updated by Andrew Lindsay October/November 2009 |
SomeRandomBloke | 6:80f554fd77a0 | 13 | * |
SomeRandomBloke | 6:80f554fd77a0 | 14 | * Ported to Mbed platform by Andrew Lindsay, November 2012 |
SomeRandomBloke | 6:80f554fd77a0 | 15 | * |
SomeRandomBloke | 6:80f554fd77a0 | 16 | * @author Andrew Lindsay |
SomeRandomBloke | 6:80f554fd77a0 | 17 | * |
SomeRandomBloke | 6:80f554fd77a0 | 18 | * @section LICENSE |
SomeRandomBloke | 6:80f554fd77a0 | 19 | * |
SomeRandomBloke | 6:80f554fd77a0 | 20 | * Copyright (c) 2012 Andrew Lindsay (andrew [at] thiseldo [dot] co [dot] uk) |
SomeRandomBloke | 6:80f554fd77a0 | 21 | * |
SomeRandomBloke | 6:80f554fd77a0 | 22 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
SomeRandomBloke | 6:80f554fd77a0 | 23 | * of this software and associated documentation files (the "Software"), to deal |
SomeRandomBloke | 6:80f554fd77a0 | 24 | * in the Software without restriction, including without limitation the rights |
SomeRandomBloke | 6:80f554fd77a0 | 25 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
SomeRandomBloke | 6:80f554fd77a0 | 26 | * copies of the Software, and to permit persons to whom the Software is |
SomeRandomBloke | 6:80f554fd77a0 | 27 | * furnished to do so, subject to the following conditions: |
SomeRandomBloke | 6:80f554fd77a0 | 28 | |
SomeRandomBloke | 6:80f554fd77a0 | 29 | * The above copyright notice and this permission notice shall be included in |
SomeRandomBloke | 6:80f554fd77a0 | 30 | * all copies or substantial portions of the Software. |
SomeRandomBloke | 6:80f554fd77a0 | 31 | * |
SomeRandomBloke | 6:80f554fd77a0 | 32 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
SomeRandomBloke | 6:80f554fd77a0 | 33 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
SomeRandomBloke | 6:80f554fd77a0 | 34 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
SomeRandomBloke | 6:80f554fd77a0 | 35 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
SomeRandomBloke | 6:80f554fd77a0 | 36 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
SomeRandomBloke | 6:80f554fd77a0 | 37 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
SomeRandomBloke | 6:80f554fd77a0 | 38 | * THE SOFTWARE. |
SomeRandomBloke | 6:80f554fd77a0 | 39 | * |
SomeRandomBloke | 6:80f554fd77a0 | 40 | * @section DESCRIPTION |
SomeRandomBloke | 6:80f554fd77a0 | 41 | * Definitions for Holtek HT1632 LED driver |
SomeRandomBloke | 6:80f554fd77a0 | 42 | * |
SomeRandomBloke | 6:80f554fd77a0 | 43 | */ |
SomeRandomBloke | 4:7513dd37efed | 44 | |
SomeRandomBloke | 4:7513dd37efed | 45 | #ifndef _HT1632_LEDMATRIX_H |
SomeRandomBloke | 4:7513dd37efed | 46 | #define _HT1632_LEDMATRIX_H |
SomeRandomBloke | 4:7513dd37efed | 47 | |
SomeRandomBloke | 14:b051965066db | 48 | #include "mbed.h" |
SomeRandomBloke | 14:b051965066db | 49 | #include "inttypes.h" |
SomeRandomBloke | 9:8a3c981babd9 | 50 | |
SomeRandomBloke | 6:80f554fd77a0 | 51 | // To include the graphic functions use the following. Comment out to exclude them |
SomeRandomBloke | 14:b051965066db | 52 | #undef USE_GRAPHIC |
SomeRandomBloke | 4:7513dd37efed | 53 | |
SomeRandomBloke | 9:8a3c981babd9 | 54 | // Defines for display sizes |
SomeRandomBloke | 10:af973a9c48b2 | 55 | #define HT1632_08x32 1 |
SomeRandomBloke | 10:af973a9c48b2 | 56 | #define HT1632_16x24 2 |
SomeRandomBloke | 4:7513dd37efed | 57 | |
SomeRandomBloke | 4:7513dd37efed | 58 | /* |
SomeRandomBloke | 4:7513dd37efed | 59 | * commands written to the chip consist of a 3 bit "ID", followed by |
SomeRandomBloke | 4:7513dd37efed | 60 | * either 9 bits of "Command code" or 7 bits of address + 4 bits of data. |
SomeRandomBloke | 4:7513dd37efed | 61 | */ |
SomeRandomBloke | 4:7513dd37efed | 62 | #define HT1632_ID_CMD 4 /* ID = 100 - Commands */ |
SomeRandomBloke | 4:7513dd37efed | 63 | #define HT1632_ID_RD 6 /* ID = 110 - Read RAM */ |
SomeRandomBloke | 4:7513dd37efed | 64 | #define HT1632_ID_WR 5 /* ID = 101 - Write RAM */ |
SomeRandomBloke | 4:7513dd37efed | 65 | |
SomeRandomBloke | 4:7513dd37efed | 66 | #define HT1632_CMD_SYSDIS 0x00 /* CMD= 0000-0000-x Turn off oscil */ |
SomeRandomBloke | 4:7513dd37efed | 67 | #define HT1632_CMD_SYSON 0x01 /* CMD= 0000-0001-x Enable system oscil */ |
SomeRandomBloke | 4:7513dd37efed | 68 | #define HT1632_CMD_LEDOFF 0x02 /* CMD= 0000-0010-x LED duty cycle gen off */ |
SomeRandomBloke | 4:7513dd37efed | 69 | #define HT1632_CMD_LEDON 0x03 /* CMD= 0000-0011-x LEDs ON */ |
SomeRandomBloke | 4:7513dd37efed | 70 | #define HT1632_CMD_BLOFF 0x08 /* CMD= 0000-1000-x Blink ON */ |
SomeRandomBloke | 4:7513dd37efed | 71 | #define HT1632_CMD_BLON 0x09 /* CMD= 0000-1001-x Blink Off */ |
SomeRandomBloke | 4:7513dd37efed | 72 | #define HT1632_CMD_SLVMD 0x10 /* CMD= 0001-00xx-x Slave Mode */ |
SomeRandomBloke | 4:7513dd37efed | 73 | #define HT1632_CMD_MSTMD 0x14 /* CMD= 0001-01xx-x Master Mode */ |
SomeRandomBloke | 4:7513dd37efed | 74 | #define HT1632_CMD_RCCLK 0x18 /* CMD= 0001-10xx-x Use on-chip clock */ |
SomeRandomBloke | 4:7513dd37efed | 75 | #define HT1632_CMD_EXTCLK 0x1C /* CMD= 0001-11xx-x Use external clock */ |
SomeRandomBloke | 4:7513dd37efed | 76 | #define HT1632_CMD_COMS00 0x20 /* CMD= 0010-ABxx-x commons options */ |
SomeRandomBloke | 4:7513dd37efed | 77 | #define HT1632_CMD_COMS01 0x24 /* CMD= 0010-ABxx-x commons options */ |
SomeRandomBloke | 4:7513dd37efed | 78 | #define HT1632_CMD_COMS10 0x28 /* CMD= 0010-ABxx-x commons options */ |
SomeRandomBloke | 4:7513dd37efed | 79 | #define HT1632_CMD_COMS11 0x2C /* CMD= 0010-ABxx-x commons options */ |
SomeRandomBloke | 4:7513dd37efed | 80 | #define HT1632_CMD_PWM 0xA0 /* CMD= 101x-PPPP-x PWM duty cycle */ |
SomeRandomBloke | 4:7513dd37efed | 81 | |
SomeRandomBloke | 4:7513dd37efed | 82 | #define PIXEL_OFF 0 |
SomeRandomBloke | 4:7513dd37efed | 83 | #define PIXEL_ON 1 |
SomeRandomBloke | 4:7513dd37efed | 84 | |
SomeRandomBloke | 6:80f554fd77a0 | 85 | /** class HT1632_LedMatrix |
SomeRandomBloke | 6:80f554fd77a0 | 86 | */ |
SomeRandomBloke | 13:9a869360d0ae | 87 | class HT1632_LedMatrix : public Stream |
SomeRandomBloke | 4:7513dd37efed | 88 | { |
SomeRandomBloke | 4:7513dd37efed | 89 | public: |
SomeRandomBloke | 9:8a3c981babd9 | 90 | /** Default Constructor for the display driver |
SomeRandomBloke | 6:80f554fd77a0 | 91 | */ |
SomeRandomBloke | 14:b051965066db | 92 | // HT1632_LedMatrix( ); |
SomeRandomBloke | 14:b051965066db | 93 | HT1632_LedMatrix( PinName clk, PinName dat, PinName cs1, PinName cs2 , PinName cs3, PinName cs4); |
SomeRandomBloke | 14:b051965066db | 94 | |
SomeRandomBloke | 4:7513dd37efed | 95 | |
SomeRandomBloke | 9:8a3c981babd9 | 96 | /** Initialise the library with the display configuration |
SomeRandomBloke | 9:8a3c981babd9 | 97 | * @param Number of horizontal displays, max 4 |
SomeRandomBloke | 9:8a3c981babd9 | 98 | * @param Number of vertical displays, max 4 |
SomeRandomBloke | 9:8a3c981babd9 | 99 | * @param Type of displays being used, either 32x8 or 24x16 |
SomeRandomBloke | 9:8a3c981babd9 | 100 | */ |
SomeRandomBloke | 10:af973a9c48b2 | 101 | void init( uint8_t, uint8_t, uint8_t displayType = HT1632_08x32 ); |
SomeRandomBloke | 9:8a3c981babd9 | 102 | |
SomeRandomBloke | 9:8a3c981babd9 | 103 | /** Turn off the display |
SomeRandomBloke | 9:8a3c981babd9 | 104 | */ |
SomeRandomBloke | 9:8a3c981babd9 | 105 | void displayOff( void ); |
SomeRandomBloke | 9:8a3c981babd9 | 106 | |
SomeRandomBloke | 9:8a3c981babd9 | 107 | /** Turn on the display |
SomeRandomBloke | 9:8a3c981babd9 | 108 | */ |
SomeRandomBloke | 9:8a3c981babd9 | 109 | void displayOn( void ); |
SomeRandomBloke | 9:8a3c981babd9 | 110 | |
SomeRandomBloke | 9:8a3c981babd9 | 111 | /** Clear the display, and the shadow memory, and the snapshot |
SomeRandomBloke | 9:8a3c981babd9 | 112 | * memory. This uses the "write multiple words" capability of |
SomeRandomBloke | 9:8a3c981babd9 | 113 | * the chipset by writing all 96 words of memory without raising |
SomeRandomBloke | 9:8a3c981babd9 | 114 | * the chipselect signal. |
SomeRandomBloke | 9:8a3c981babd9 | 115 | */ |
SomeRandomBloke | 4:7513dd37efed | 116 | void clear(void); |
SomeRandomBloke | 9:8a3c981babd9 | 117 | |
SomeRandomBloke | 9:8a3c981babd9 | 118 | /** Set display brightness. Brighness is from 0 to 15 |
SomeRandomBloke | 9:8a3c981babd9 | 119 | * @param brightness value, range x-y |
SomeRandomBloke | 9:8a3c981babd9 | 120 | */ |
SomeRandomBloke | 4:7513dd37efed | 121 | void setBrightness( unsigned char ); |
SomeRandomBloke | 9:8a3c981babd9 | 122 | |
SomeRandomBloke | 9:8a3c981babd9 | 123 | /** Copy a character glyph from the font data structure to |
SomeRandomBloke | 9:8a3c981babd9 | 124 | * display memory, with its upper left at the given coordinate |
SomeRandomBloke | 9:8a3c981babd9 | 125 | * This is unoptimized and simply uses plot() to draw each dot. |
SomeRandomBloke | 9:8a3c981babd9 | 126 | * returns number of columns that didn't fit |
SomeRandomBloke | 9:8a3c981babd9 | 127 | * @param column |
SomeRandomBloke | 9:8a3c981babd9 | 128 | * @param row |
SomeRandomBloke | 9:8a3c981babd9 | 129 | * @param character to write |
SomeRandomBloke | 9:8a3c981babd9 | 130 | * @returns the number of columns that couldnt be displayed on current matrix |
SomeRandomBloke | 9:8a3c981babd9 | 131 | */ |
SomeRandomBloke | 4:7513dd37efed | 132 | uint8_t putChar( int, int, char ); |
SomeRandomBloke | 9:8a3c981babd9 | 133 | |
SomeRandomBloke | 9:8a3c981babd9 | 134 | /** Copy a character glyph from the font data structure to |
SomeRandomBloke | 9:8a3c981babd9 | 135 | * display memory, with its upper left at the given coordinate |
SomeRandomBloke | 9:8a3c981babd9 | 136 | * This is a wrapper for putChar that uses current cursor position |
SomeRandomBloke | 9:8a3c981babd9 | 137 | */ |
SomeRandomBloke | 4:7513dd37efed | 138 | void write( uint8_t ); |
SomeRandomBloke | 9:8a3c981babd9 | 139 | |
SomeRandomBloke | 9:8a3c981babd9 | 140 | /** Write a string at the position specified |
SomeRandomBloke | 9:8a3c981babd9 | 141 | * x and y start from 0 and count number of pixels, 2nd row on a 2 row display is y=8 |
SomeRandomBloke | 9:8a3c981babd9 | 142 | * @param x position |
SomeRandomBloke | 9:8a3c981babd9 | 143 | * @param y position |
SomeRandomBloke | 9:8a3c981babd9 | 144 | * @param pointer to character data to display |
SomeRandomBloke | 9:8a3c981babd9 | 145 | */ |
SomeRandomBloke | 4:7513dd37efed | 146 | void putString( int, int, char* ); |
SomeRandomBloke | 9:8a3c981babd9 | 147 | |
SomeRandomBloke | 9:8a3c981babd9 | 148 | /** Plot a point on the display, with the upper left hand corner |
SomeRandomBloke | 9:8a3c981babd9 | 149 | * being (0,0), and the lower right hand corner being (xMax-1, yMax-1). |
SomeRandomBloke | 9:8a3c981babd9 | 150 | * Note that Y increases going "downward" in contrast with most |
SomeRandomBloke | 9:8a3c981babd9 | 151 | * mathematical coordiate systems, but in common with many displays |
SomeRandomBloke | 9:8a3c981babd9 | 152 | * basic bounds checking used. |
SomeRandomBloke | 9:8a3c981babd9 | 153 | * @param column |
SomeRandomBloke | 9:8a3c981babd9 | 154 | * @param row |
SomeRandomBloke | 9:8a3c981babd9 | 155 | * @param point on or off |
SomeRandomBloke | 9:8a3c981babd9 | 156 | */ |
SomeRandomBloke | 4:7513dd37efed | 157 | void plot( int, int, char ); |
SomeRandomBloke | 9:8a3c981babd9 | 158 | |
SomeRandomBloke | 9:8a3c981babd9 | 159 | /** Set cursor position |
SomeRandomBloke | 9:8a3c981babd9 | 160 | * @param x or column position, 0 is to left |
SomeRandomBloke | 9:8a3c981babd9 | 161 | * @param y or row position, 0 is at top |
SomeRandomBloke | 9:8a3c981babd9 | 162 | */ |
SomeRandomBloke | 4:7513dd37efed | 163 | void gotoXY(int , int); |
SomeRandomBloke | 9:8a3c981babd9 | 164 | |
SomeRandomBloke | 9:8a3c981babd9 | 165 | /** Return the current cursor position |
SomeRandomBloke | 9:8a3c981babd9 | 166 | * @param column pointer |
SomeRandomBloke | 9:8a3c981babd9 | 167 | * @param row pointer |
SomeRandomBloke | 9:8a3c981babd9 | 168 | */ |
SomeRandomBloke | 4:7513dd37efed | 169 | void getXY(int* , int*); |
SomeRandomBloke | 9:8a3c981babd9 | 170 | |
SomeRandomBloke | 9:8a3c981babd9 | 171 | /** Return the maximum size of the display |
SomeRandomBloke | 9:8a3c981babd9 | 172 | * @param column pointer |
SomeRandomBloke | 9:8a3c981babd9 | 173 | * @param row pointer |
SomeRandomBloke | 9:8a3c981babd9 | 174 | */ |
SomeRandomBloke | 4:7513dd37efed | 175 | void getXYMax(int*, int*); |
SomeRandomBloke | 9:8a3c981babd9 | 176 | |
SomeRandomBloke | 9:8a3c981babd9 | 177 | /** Shift cursor X position a number of positions either left or right. |
SomeRandomBloke | 9:8a3c981babd9 | 178 | * @param increment, -1 for one position left, 1 for right |
SomeRandomBloke | 9:8a3c981babd9 | 179 | */ |
SomeRandomBloke | 4:7513dd37efed | 180 | void shiftCursorX(int ); |
SomeRandomBloke | 9:8a3c981babd9 | 181 | |
SomeRandomBloke | 9:8a3c981babd9 | 182 | /** Create a custom character. 8 character slots are availabe. |
SomeRandomBloke | 9:8a3c981babd9 | 183 | * @param character number, 0 to 7 |
SomeRandomBloke | 9:8a3c981babd9 | 184 | * @param array of character bit maps |
SomeRandomBloke | 9:8a3c981babd9 | 185 | */ |
SomeRandomBloke | 4:7513dd37efed | 186 | void setCustomChar( int, unsigned char[]); |
SomeRandomBloke | 9:8a3c981babd9 | 187 | |
SomeRandomBloke | 9:8a3c981babd9 | 188 | /** Create a custom character. 8 character slots are availabe. |
SomeRandomBloke | 9:8a3c981babd9 | 189 | * @param character number, 0 to 7 |
SomeRandomBloke | 9:8a3c981babd9 | 190 | * @param array of character bit maps |
SomeRandomBloke | 9:8a3c981babd9 | 191 | * @param width of chaaracter in columns |
SomeRandomBloke | 9:8a3c981babd9 | 192 | */ |
SomeRandomBloke | 4:7513dd37efed | 193 | void setCustomChar( int, unsigned char[], uint8_t ); |
SomeRandomBloke | 9:8a3c981babd9 | 194 | |
SomeRandomBloke | 9:8a3c981babd9 | 195 | /** Scroll row to the left |
SomeRandomBloke | 9:8a3c981babd9 | 196 | * @param number fo columns to scroll |
SomeRandomBloke | 9:8a3c981babd9 | 197 | * @param row number to scroll, used when displays are stacked vertically or when more than 8 high displays are used |
SomeRandomBloke | 9:8a3c981babd9 | 198 | */ |
SomeRandomBloke | 4:7513dd37efed | 199 | void scrollLeft(uint8_t, uint8_t); |
SomeRandomBloke | 9:8a3c981babd9 | 200 | |
SomeRandomBloke | 9:8a3c981babd9 | 201 | /** Write shaddow ram to display |
SomeRandomBloke | 9:8a3c981babd9 | 202 | */ |
SomeRandomBloke | 4:7513dd37efed | 203 | void putShadowRam(); |
SomeRandomBloke | 9:8a3c981babd9 | 204 | |
SomeRandomBloke | 9:8a3c981babd9 | 205 | /** Write shadow ram to a specific dasipaly board |
SomeRandomBloke | 9:8a3c981babd9 | 206 | * @param chip or display number |
SomeRandomBloke | 9:8a3c981babd9 | 207 | */ |
SomeRandomBloke | 4:7513dd37efed | 208 | void putShadowRam(uint8_t); |
SomeRandomBloke | 4:7513dd37efed | 209 | // Graphic functions |
SomeRandomBloke | 4:7513dd37efed | 210 | #ifdef USE_GRAPHIC |
SomeRandomBloke | 9:8a3c981babd9 | 211 | |
SomeRandomBloke | 9:8a3c981babd9 | 212 | /** Draws a line between two points on the display |
SomeRandomBloke | 9:8a3c981babd9 | 213 | * @param start column |
SomeRandomBloke | 9:8a3c981babd9 | 214 | * @param start row |
SomeRandomBloke | 9:8a3c981babd9 | 215 | * @param end column |
SomeRandomBloke | 9:8a3c981babd9 | 216 | * @param end row |
SomeRandomBloke | 9:8a3c981babd9 | 217 | * @param point on or off, off to erase, on to draw |
SomeRandomBloke | 9:8a3c981babd9 | 218 | */ |
SomeRandomBloke | 4:7513dd37efed | 219 | void drawLine(unsigned char x1, unsigned char y1, |
SomeRandomBloke | 4:7513dd37efed | 220 | unsigned char x2, unsigned char y2, unsigned char c); |
SomeRandomBloke | 9:8a3c981babd9 | 221 | |
SomeRandomBloke | 9:8a3c981babd9 | 222 | /** Draw a rectangle given to top left and bottom right points |
SomeRandomBloke | 9:8a3c981babd9 | 223 | * @param top left column |
SomeRandomBloke | 9:8a3c981babd9 | 224 | * @param top left row |
SomeRandomBloke | 9:8a3c981babd9 | 225 | * @param bottom right column |
SomeRandomBloke | 9:8a3c981babd9 | 226 | * @param bottom right row |
SomeRandomBloke | 9:8a3c981babd9 | 227 | * @param point on or off, off to erase, on to draw |
SomeRandomBloke | 9:8a3c981babd9 | 228 | */ |
SomeRandomBloke | 4:7513dd37efed | 229 | void drawRectangle(unsigned char x1, unsigned char y1, |
SomeRandomBloke | 4:7513dd37efed | 230 | unsigned char x2, unsigned char y2, unsigned char c); |
SomeRandomBloke | 9:8a3c981babd9 | 231 | /** Draw a filled rectangle given to top left and bottom right points |
SomeRandomBloke | 9:8a3c981babd9 | 232 | * @param top left column |
SomeRandomBloke | 9:8a3c981babd9 | 233 | * @param top left row |
SomeRandomBloke | 9:8a3c981babd9 | 234 | * @param bottom right column |
SomeRandomBloke | 9:8a3c981babd9 | 235 | * @param bottom right row |
SomeRandomBloke | 9:8a3c981babd9 | 236 | * @param point on or off, off to erase, on to draw |
SomeRandomBloke | 9:8a3c981babd9 | 237 | */ |
SomeRandomBloke | 4:7513dd37efed | 238 | void drawFilledRectangle(unsigned char x1, unsigned char y1, |
SomeRandomBloke | 4:7513dd37efed | 239 | unsigned char x2, unsigned char y2, unsigned char c); |
SomeRandomBloke | 9:8a3c981babd9 | 240 | /** Draw a circle using Bresenham's algorithm. |
SomeRandomBloke | 9:8a3c981babd9 | 241 | * Some small circles will look like squares!! |
SomeRandomBloke | 9:8a3c981babd9 | 242 | * @param centre column |
SomeRandomBloke | 9:8a3c981babd9 | 243 | * @param centre row |
SomeRandomBloke | 9:8a3c981babd9 | 244 | * @param radius |
SomeRandomBloke | 9:8a3c981babd9 | 245 | * @param point on or off, off to erase, on to draw |
SomeRandomBloke | 9:8a3c981babd9 | 246 | */ |
SomeRandomBloke | 4:7513dd37efed | 247 | void drawCircle(unsigned char xc, unsigned char yc, |
SomeRandomBloke | 4:7513dd37efed | 248 | unsigned char r, unsigned char c); |
SomeRandomBloke | 4:7513dd37efed | 249 | #endif |
SomeRandomBloke | 4:7513dd37efed | 250 | |
SomeRandomBloke | 14:b051965066db | 251 | private: |
SomeRandomBloke | 14:b051965066db | 252 | /** Select a specific display, numbers as 0 to 3 |
SomeRandomBloke | 14:b051965066db | 253 | * |
SomeRandomBloke | 14:b051965066db | 254 | * @param chip number |
SomeRandomBloke | 14:b051965066db | 255 | */ |
SomeRandomBloke | 14:b051965066db | 256 | void chipselect( uint8_t ); |
SomeRandomBloke | 14:b051965066db | 257 | /** Deselect a specific display, numbers as 0 to 3 |
SomeRandomBloke | 14:b051965066db | 258 | * |
SomeRandomBloke | 14:b051965066db | 259 | * @param chip number |
SomeRandomBloke | 14:b051965066db | 260 | */ |
SomeRandomBloke | 14:b051965066db | 261 | void chipfree( uint8_t ); |
SomeRandomBloke | 14:b051965066db | 262 | |
SomeRandomBloke | 14:b051965066db | 263 | /** Write bits to HT1632 on pins HT1632_DATA, HT1632_WRCLK |
SomeRandomBloke | 14:b051965066db | 264 | * Chip is assumed to already be chip-selected |
SomeRandomBloke | 14:b051965066db | 265 | * Bits are shifted out from MSB to LSB, with the first bit sent |
SomeRandomBloke | 14:b051965066db | 266 | * being (bits & firstbit), shifted till firsbit is zero. |
SomeRandomBloke | 14:b051965066db | 267 | * @param bits |
SomeRandomBloke | 14:b051965066db | 268 | * @param firstbit |
SomeRandomBloke | 14:b051965066db | 269 | */ |
SomeRandomBloke | 14:b051965066db | 270 | void writebits( uint8_t, uint8_t ); |
SomeRandomBloke | 14:b051965066db | 271 | |
SomeRandomBloke | 14:b051965066db | 272 | /** Write databits to HT1632 on pins HT1632_DATA, HT1632_WRCLK |
SomeRandomBloke | 14:b051965066db | 273 | * Chip is assumed to already be chip-selected |
SomeRandomBloke | 14:b051965066db | 274 | * Bits are shifted out from LSB to MSB |
SomeRandomBloke | 14:b051965066db | 275 | * @param bits |
SomeRandomBloke | 14:b051965066db | 276 | * @param count |
SomeRandomBloke | 14:b051965066db | 277 | */ |
SomeRandomBloke | 14:b051965066db | 278 | void writedatabits( uint8_t, uint8_t ); |
SomeRandomBloke | 14:b051965066db | 279 | |
SomeRandomBloke | 14:b051965066db | 280 | /** * Send a command to the ht1632 chip. |
SomeRandomBloke | 14:b051965066db | 281 | * A command consists of a 3-bit "CMD" ID, an 8bit command, and |
SomeRandomBloke | 14:b051965066db | 282 | * one "don't care bit". |
SomeRandomBloke | 14:b051965066db | 283 | * Select 1 0 0 c7 c6 c5 c4 c3 c2 c1 c0 xx Free |
SomeRandomBloke | 14:b051965066db | 284 | * @param chipno the number of the chip/display to write command to |
SomeRandomBloke | 14:b051965066db | 285 | * @param command to send |
SomeRandomBloke | 14:b051965066db | 286 | */ |
SomeRandomBloke | 14:b051965066db | 287 | void sendcmd( uint8_t, uint8_t ); |
SomeRandomBloke | 14:b051965066db | 288 | |
SomeRandomBloke | 14:b051965066db | 289 | /** Send a nibble (4 bits) of data to a particular memory location of the |
SomeRandomBloke | 14:b051965066db | 290 | * ht1632. The command has 3 bit ID, 7 bits of address, and 4 bits of data. |
SomeRandomBloke | 14:b051965066db | 291 | * Select 1 0 1 A6 A5 A4 A3 A2 A1 A0 D0 D1 D2 D3 Free |
SomeRandomBloke | 14:b051965066db | 292 | * Note that the address is sent MSB first, while the data is sent LSB first! |
SomeRandomBloke | 14:b051965066db | 293 | * This means that somewhere a bit reversal will have to be done to get |
SomeRandomBloke | 14:b051965066db | 294 | * zero-based addressing of words and dots within words. |
SomeRandomBloke | 14:b051965066db | 295 | * @param chipno |
SomeRandomBloke | 14:b051965066db | 296 | * @param address |
SomeRandomBloke | 14:b051965066db | 297 | * @param data |
SomeRandomBloke | 14:b051965066db | 298 | */ |
SomeRandomBloke | 14:b051965066db | 299 | void senddata( uint8_t, uint8_t, uint8_t ); |
SomeRandomBloke | 14:b051965066db | 300 | |
SomeRandomBloke | 14:b051965066db | 301 | /** Send a byte of data to a particular memory location of the |
SomeRandomBloke | 14:b051965066db | 302 | * ht1632. The command has 3 bit ID, 7 bits of address, and 8 bits of data. |
SomeRandomBloke | 14:b051965066db | 303 | * Select 1 0 1 A6 A5 A4 A3 A2 A1 A0 D0 D1 D2 D3 D4 D5 D6 D7 D8 Free |
SomeRandomBloke | 14:b051965066db | 304 | * Note that the address is sent MSB first, while the data is sent LSB first! |
SomeRandomBloke | 14:b051965066db | 305 | * This means that somewhere a bit reversal will have to be done to get |
SomeRandomBloke | 14:b051965066db | 306 | * zero-based addressing of words and dots within words. |
SomeRandomBloke | 14:b051965066db | 307 | * @param chipno |
SomeRandomBloke | 14:b051965066db | 308 | * @param address |
SomeRandomBloke | 14:b051965066db | 309 | * @param data |
SomeRandomBloke | 14:b051965066db | 310 | */ |
SomeRandomBloke | 14:b051965066db | 311 | void sendcol( uint8_t, uint8_t, uint8_t ); |
SomeRandomBloke | 14:b051965066db | 312 | |
SomeRandomBloke | 14:b051965066db | 313 | DigitalOut _wrclk; |
SomeRandomBloke | 14:b051965066db | 314 | DigitalOut _data; |
SomeRandomBloke | 14:b051965066db | 315 | DigitalOut _cs1; |
SomeRandomBloke | 14:b051965066db | 316 | DigitalOut _cs2; |
SomeRandomBloke | 14:b051965066db | 317 | DigitalOut _cs3; |
SomeRandomBloke | 14:b051965066db | 318 | DigitalOut _cs4; |
SomeRandomBloke | 14:b051965066db | 319 | |
SomeRandomBloke | 14:b051965066db | 320 | //protected: |
SomeRandomBloke | 13:9a869360d0ae | 321 | virtual int _putc(int value); |
SomeRandomBloke | 13:9a869360d0ae | 322 | virtual int _getc(); |
SomeRandomBloke | 13:9a869360d0ae | 323 | |
SomeRandomBloke | 4:7513dd37efed | 324 | }; |
SomeRandomBloke | 4:7513dd37efed | 325 | |
SomeRandomBloke | 4:7513dd37efed | 326 | #endif //_HT1632_LEDMATRIX_H |