done

Dependents:   AwesomeAlarm_BLE

Committer:
wim
Date:
Sat Jan 30 20:35:25 2016 +0000
Revision:
0:dc8789a6e21f
Child:
1:f63d87466f55
TM1637 Library, for TM1637 LEDcontroller

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wim 0:dc8789a6e21f 1 /* mbed TM1637 Library, for TM1637 LED controller
wim 0:dc8789a6e21f 2 * Copyright (c) 2016, v01: WH, Initial version
wim 0:dc8789a6e21f 3 *
wim 0:dc8789a6e21f 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
wim 0:dc8789a6e21f 5 * of this software and associated documentation files (the "Software"), to deal
wim 0:dc8789a6e21f 6 * in the Software without restriction, inclumosig without limitation the rights
wim 0:dc8789a6e21f 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
wim 0:dc8789a6e21f 8 * copies of the Software, and to permit persons to whom the Software is
wim 0:dc8789a6e21f 9 * furnished to do so, subject to the following conditions:
wim 0:dc8789a6e21f 10 *
wim 0:dc8789a6e21f 11 * The above copyright notice and this permission notice shall be included in
wim 0:dc8789a6e21f 12 * all copies or substantial portions of the Software.
wim 0:dc8789a6e21f 13 *
wim 0:dc8789a6e21f 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
wim 0:dc8789a6e21f 15 * IMPLIED, INCLUmosiG BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
wim 0:dc8789a6e21f 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
wim 0:dc8789a6e21f 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
wim 0:dc8789a6e21f 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
wim 0:dc8789a6e21f 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
wim 0:dc8789a6e21f 20 * THE SOFTWARE.
wim 0:dc8789a6e21f 21 */
wim 0:dc8789a6e21f 22
wim 0:dc8789a6e21f 23 #ifndef TM1637_H
wim 0:dc8789a6e21f 24 #define TM1637_H
wim 0:dc8789a6e21f 25
wim 0:dc8789a6e21f 26 // Select one of the testboards for TM1637 LED controller
wim 0:dc8789a6e21f 27 #include "TM1637_Config.h"
wim 0:dc8789a6e21f 28
wim 0:dc8789a6e21f 29 /** An interface for driving TM1637 LED controller
wim 0:dc8789a6e21f 30 *
wim 0:dc8789a6e21f 31 * @code
wim 0:dc8789a6e21f 32 * #include "mbed.h"
wim 0:dc8789a6e21f 33 * #include "TM1637.h"
wim 0:dc8789a6e21f 34 *
wim 0:dc8789a6e21f 35 * //DisplayData_t size is 6 bytes (6 grids @ 8 segments)
wim 0:dc8789a6e21f 36 * TM1637::DisplayData_t all_str = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
wim 0:dc8789a6e21f 37 *
wim 0:dc8789a6e21f 38 * // KeyData_t size is 1 bytes
wim 0:dc8789a6e21f 39 * TM1637::KeyData_t keydata;
wim 0:dc8789a6e21f 40 *
wim 0:dc8789a6e21f 41 * // TM1637 declaration
wim 0:dc8789a6e21f 42 * TM1637 TM1637(p5,p6,p7);
wim 0:dc8789a6e21f 43 *
wim 0:dc8789a6e21f 44 * int main() {
wim 0:dc8789a6e21f 45 * TM1637.cls();
wim 0:dc8789a6e21f 46 * TM1637.writeData(all_str);
wim 0:dc8789a6e21f 47 * wait(1);
wim 0:dc8789a6e21f 48 * TM1637.setBrightness(TM1637_BRT0);
wim 0:dc8789a6e21f 49 * wait(1);
wim 0:dc8789a6e21f 50 * TM1637.setBrightness(TM1637_BRT3);
wim 0:dc8789a6e21f 51 *
wim 0:dc8789a6e21f 52 * while (1) {
wim 0:dc8789a6e21f 53 * TM1637.cls();
wim 0:dc8789a6e21f 54 * wait(0.5);
wim 0:dc8789a6e21f 55 * TM1637.writeData(all_str);
wim 0:dc8789a6e21f 56 * wait(0.5);
wim 0:dc8789a6e21f 57 *
wim 0:dc8789a6e21f 58 * // Check and read keydata
wim 0:dc8789a6e21f 59 * if (TM1637.getKeys(&keydata)) {
wim 0:dc8789a6e21f 60 * pc.printf("Keydata = 0x%02x\r\n", keydata);
wim 0:dc8789a6e21f 61 *
wim 0:dc8789a6e21f 62 * if (keydata == TM1637_SW9_BIT) { //sw9
wim 0:dc8789a6e21f 63 * TM1637.cls();
wim 0:dc8789a6e21f 64 * TM1637.writeData(0xFF, 1);
wim 0:dc8789a6e21f 65 * TM1637.writeData(0xFF, 2);
wim 0:dc8789a6e21f 66 * }
wim 0:dc8789a6e21f 67 * } // Check keydata
wim 0:dc8789a6e21f 68 * } // while
wim 0:dc8789a6e21f 69 * }
wim 0:dc8789a6e21f 70 * @endcode
wim 0:dc8789a6e21f 71 */
wim 0:dc8789a6e21f 72
wim 0:dc8789a6e21f 73
wim 0:dc8789a6e21f 74 //TM1637 Display data
wim 0:dc8789a6e21f 75 #define TM1637_MAX_NR_GRIDS 6
wim 0:dc8789a6e21f 76 #define TM1637_BYTES_PER_GRID 1
wim 0:dc8789a6e21f 77
wim 0:dc8789a6e21f 78 //Significant bits Keymatrix data
wim 0:dc8789a6e21f 79 //#define TM1638_KEY_MSK 0xFF
wim 0:dc8789a6e21f 80
wim 0:dc8789a6e21f 81 //Memory size in bytes for Display and Keymatrix
wim 0:dc8789a6e21f 82 #define TM1637_DISPLAY_MEM (TM1637_MAX_NR_GRIDS * TM1637_BYTES_PER_GRID)
wim 0:dc8789a6e21f 83 #define TM1637_KEY_MEM 2
wim 0:dc8789a6e21f 84
wim 0:dc8789a6e21f 85 //Reserved bits for commands
wim 0:dc8789a6e21f 86 #define TM1637_CMD_MSK 0xC0
wim 0:dc8789a6e21f 87
wim 0:dc8789a6e21f 88 //Data setting commands
wim 0:dc8789a6e21f 89 #define TM1637_DATA_SET_CMD 0x40
wim 0:dc8789a6e21f 90 #define TM1637_DATA_WR 0x00
wim 0:dc8789a6e21f 91 #define TM1637_KEY_RD 0x02
wim 0:dc8789a6e21f 92 #define TM1637_ADDR_INC 0x00
wim 0:dc8789a6e21f 93 #define TM1637_ADDR_FIXED 0x04
wim 0:dc8789a6e21f 94 #define TM1637_MODE_NORM 0x00
wim 0:dc8789a6e21f 95 #define TM1637_MODE_TEST 0x08
wim 0:dc8789a6e21f 96
wim 0:dc8789a6e21f 97 //Address setting commands
wim 0:dc8789a6e21f 98 #define TM1637_ADDR_SET_CMD 0xC0
wim 0:dc8789a6e21f 99 #define TM1637_ADDR_MSK 0x07 //0..5
wim 0:dc8789a6e21f 100
wim 0:dc8789a6e21f 101 //Display control commands
wim 0:dc8789a6e21f 102 #define TM1637_DSP_CTRL_CMD 0x80
wim 0:dc8789a6e21f 103 #define TM1637_BRT_MSK 0x07
wim 0:dc8789a6e21f 104 #define TM1637_BRT0 0x00 //Pulsewidth 1/16
wim 0:dc8789a6e21f 105 #define TM1637_BRT1 0x01
wim 0:dc8789a6e21f 106 #define TM1637_BRT2 0x02
wim 0:dc8789a6e21f 107 #define TM1637_BRT3 0x03
wim 0:dc8789a6e21f 108 #define TM1637_BRT4 0x04
wim 0:dc8789a6e21f 109 #define TM1637_BRT5 0x05
wim 0:dc8789a6e21f 110 #define TM1637_BRT6 0x06
wim 0:dc8789a6e21f 111 #define TM1637_BRT7 0x07 //Pulsewidth 14/16
wim 0:dc8789a6e21f 112
wim 0:dc8789a6e21f 113 #define TM1637_BRT_DEF TM1637_BRT3
wim 0:dc8789a6e21f 114
wim 0:dc8789a6e21f 115 #define TM1637_DSP_OFF 0x00
wim 0:dc8789a6e21f 116 #define TM1637_DSP_ON 0x08
wim 0:dc8789a6e21f 117
wim 0:dc8789a6e21f 118
wim 0:dc8789a6e21f 119 //Access to 16 Switches
wim 0:dc8789a6e21f 120 #define TM1637_SW1_BIT 0xEF
wim 0:dc8789a6e21f 121 #define TM1637_SW2_BIT 0x6F
wim 0:dc8789a6e21f 122 #define TM1637_SW3_BIT 0xAF
wim 0:dc8789a6e21f 123 #define TM1637_SW4_BIT 0x2F
wim 0:dc8789a6e21f 124 #define TM1637_SW5_BIT 0xCF
wim 0:dc8789a6e21f 125 #define TM1637_SW6_BIT 0x4F
wim 0:dc8789a6e21f 126 #define TM1637_SW7_BIT 0x8F
wim 0:dc8789a6e21f 127 #define TM1637_SW8_BIT 0x0F
wim 0:dc8789a6e21f 128
wim 0:dc8789a6e21f 129 #define TM1637_SW9_BIT 0xF7
wim 0:dc8789a6e21f 130 #define TM1637_SW10_BIT 0x77
wim 0:dc8789a6e21f 131 #define TM1637_SW11_BIT 0xB7
wim 0:dc8789a6e21f 132 #define TM1637_SW12_BIT 0x37
wim 0:dc8789a6e21f 133 #define TM1637_SW13_BIT 0xD7
wim 0:dc8789a6e21f 134 #define TM1637_SW14_BIT 0x57
wim 0:dc8789a6e21f 135 #define TM1637_SW15_BIT 0x97
wim 0:dc8789a6e21f 136 #define TM1637_SW16_BIT 0x17
wim 0:dc8789a6e21f 137
wim 0:dc8789a6e21f 138 #define TM1637_SW_NONE 0xFF
wim 0:dc8789a6e21f 139
wim 0:dc8789a6e21f 140 /** A class for driving TM1637 LED controller
wim 0:dc8789a6e21f 141 *
wim 0:dc8789a6e21f 142 * @brief Supports 6 Grids @ 8 Segments.
wim 0:dc8789a6e21f 143 * Serial bus interface device.
wim 0:dc8789a6e21f 144 */
wim 0:dc8789a6e21f 145 class TM1637 {
wim 0:dc8789a6e21f 146 public:
wim 0:dc8789a6e21f 147
wim 0:dc8789a6e21f 148 /** Datatype for displaydata */
wim 0:dc8789a6e21f 149 typedef char DisplayData_t[TM1637_DISPLAY_MEM];
wim 0:dc8789a6e21f 150
wim 0:dc8789a6e21f 151 /** Datatypes for keymatrix data */
wim 0:dc8789a6e21f 152 typedef char KeyData_t;
wim 0:dc8789a6e21f 153
wim 0:dc8789a6e21f 154 /** Constructor for class for driving TM1637 LED controller
wim 0:dc8789a6e21f 155 *
wim 0:dc8789a6e21f 156 * @brief Supports 6 Grids @ 8 segments.
wim 0:dc8789a6e21f 157 * Serial bus interface device.
wim 0:dc8789a6e21f 158 *
wim 0:dc8789a6e21f 159 * @param PinName mosi Serial bus MOSI pin
wim 0:dc8789a6e21f 160 * @param PinName miso Serial bus MISO pin
wim 0:dc8789a6e21f 161 * @param PinName sclk Serial bus SCLK pin
wim 0:dc8789a6e21f 162 */
wim 0:dc8789a6e21f 163 TM1637(PinName mosi, PinName miso, PinName sclk);
wim 0:dc8789a6e21f 164
wim 0:dc8789a6e21f 165 /** Clear the screen and locate to 0
wim 0:dc8789a6e21f 166 */
wim 0:dc8789a6e21f 167 void cls();
wim 0:dc8789a6e21f 168
wim 0:dc8789a6e21f 169 /** Write databyte to TM1637
wim 0:dc8789a6e21f 170 * @param char data byte written at given address
wim 0:dc8789a6e21f 171 * @param int address display memory location to write byte
wim 0:dc8789a6e21f 172 * @return none
wim 0:dc8789a6e21f 173 */
wim 0:dc8789a6e21f 174 void writeData(char data, int address);
wim 0:dc8789a6e21f 175
wim 0:dc8789a6e21f 176 /** Write Display datablock to TM1637
wim 0:dc8789a6e21f 177 * @param DisplayData_t data Array of TM1637_DISPLAY_MEM (=6) bytes for displaydata
wim 0:dc8789a6e21f 178 * @param length number bytes to write (valid range 0..(TM1637_MAX_NR_GRIDS * TM1637_BYTES_PER_GRID) (=6), when starting at address 0)
wim 0:dc8789a6e21f 179 * @param int address display memory location to write bytes (default = 0)
wim 0:dc8789a6e21f 180 * @return none
wim 0:dc8789a6e21f 181 */
wim 0:dc8789a6e21f 182 void writeData(DisplayData_t data, int length = (TM1637_MAX_NR_GRIDS * TM1637_BYTES_PER_GRID), int address = 0);
wim 0:dc8789a6e21f 183
wim 0:dc8789a6e21f 184 /** Read keydata block from TM1637
wim 0:dc8789a6e21f 185 * @param *keydata Ptr to bytes for keydata
wim 0:dc8789a6e21f 186 * @return bool keypress True when at least one key was pressed
wim 0:dc8789a6e21f 187 *
wim 0:dc8789a6e21f 188 */
wim 0:dc8789a6e21f 189 bool getKeys(KeyData_t *keydata);
wim 0:dc8789a6e21f 190
wim 0:dc8789a6e21f 191 /** Set Brightness
wim 0:dc8789a6e21f 192 *
wim 0:dc8789a6e21f 193 * @param char brightness (3 significant bits, valid range 0..7 (1/16 .. 14/16 dutycycle)
wim 0:dc8789a6e21f 194 * @return none
wim 0:dc8789a6e21f 195 */
wim 0:dc8789a6e21f 196 void setBrightness(char brightness = TM1637_BRT_DEF);
wim 0:dc8789a6e21f 197
wim 0:dc8789a6e21f 198 /** Set the Display mode On/off
wim 0:dc8789a6e21f 199 *
wim 0:dc8789a6e21f 200 * @param bool display mode
wim 0:dc8789a6e21f 201 */
wim 0:dc8789a6e21f 202 void setDisplay(bool on);
wim 0:dc8789a6e21f 203
wim 0:dc8789a6e21f 204 private:
wim 0:dc8789a6e21f 205 DigitalOut _mosi;
wim 0:dc8789a6e21f 206 DigitalIn _miso;
wim 0:dc8789a6e21f 207 DigitalOut _sclk;
wim 0:dc8789a6e21f 208 char _display;
wim 0:dc8789a6e21f 209 char _bright;
wim 0:dc8789a6e21f 210
wim 0:dc8789a6e21f 211 /** Init the Serial interface and the controller
wim 0:dc8789a6e21f 212 * @param none
wim 0:dc8789a6e21f 213 * @return none
wim 0:dc8789a6e21f 214 */
wim 0:dc8789a6e21f 215 void _init();
wim 0:dc8789a6e21f 216
wim 0:dc8789a6e21f 217
wim 0:dc8789a6e21f 218 /** Generate Start condition for TM1637
wim 0:dc8789a6e21f 219 * @param none
wim 0:dc8789a6e21f 220 * @return none
wim 0:dc8789a6e21f 221 */
wim 0:dc8789a6e21f 222 void _start();
wim 0:dc8789a6e21f 223
wim 0:dc8789a6e21f 224 /** Generate Stop condition for TM1637
wim 0:dc8789a6e21f 225 * @param none
wim 0:dc8789a6e21f 226 * @return none
wim 0:dc8789a6e21f 227 */
wim 0:dc8789a6e21f 228 void _stop();
wim 0:dc8789a6e21f 229
wim 0:dc8789a6e21f 230 /** Send byte to TM1637
wim 0:dc8789a6e21f 231 * @param int data
wim 0:dc8789a6e21f 232 * @return none
wim 0:dc8789a6e21f 233 */
wim 0:dc8789a6e21f 234 void _write(int data);
wim 0:dc8789a6e21f 235
wim 0:dc8789a6e21f 236 /** Read byte from TM1637
wim 0:dc8789a6e21f 237 * @param int senddata
wim 0:dc8789a6e21f 238 * @return read byte
wim 0:dc8789a6e21f 239 */
wim 0:dc8789a6e21f 240 char _read(int data);
wim 0:dc8789a6e21f 241
wim 0:dc8789a6e21f 242 /** Write command and parameter to TM1637
wim 0:dc8789a6e21f 243 * @param int cmd Command byte
wim 0:dc8789a6e21f 244 * &Param int data Parameters for command
wim 0:dc8789a6e21f 245 * @return none
wim 0:dc8789a6e21f 246 */
wim 0:dc8789a6e21f 247 void _writeCmd(int cmd, int data);
wim 0:dc8789a6e21f 248 };
wim 0:dc8789a6e21f 249
wim 0:dc8789a6e21f 250
wim 0:dc8789a6e21f 251 #if (CATALEX_TEST == 1)
wim 0:dc8789a6e21f 252 // Derived class for TM1637 used in CATALEX display unit
wim 0:dc8789a6e21f 253 //
wim 0:dc8789a6e21f 254
wim 0:dc8789a6e21f 255 #include "Font_7Seg.h"
wim 0:dc8789a6e21f 256
wim 0:dc8789a6e21f 257 #define CATALEX_NR_GRIDS 4
wim 0:dc8789a6e21f 258 #define CATALEX_NR_DIGITS 4
wim 0:dc8789a6e21f 259 #define CATALEX_NR_UDC 8
wim 0:dc8789a6e21f 260
wim 0:dc8789a6e21f 261
wim 0:dc8789a6e21f 262 /** Constructor for class for driving TM1637 controller as used in CATALEX
wim 0:dc8789a6e21f 263 *
wim 0:dc8789a6e21f 264 * @brief Supports 4 Digits of 7 Segments + DP.
wim 0:dc8789a6e21f 265 *
wim 0:dc8789a6e21f 266 * @param PinName mosi Serial bus MOSI pin
wim 0:dc8789a6e21f 267 * @param PinName miso Serial bus MISO pin
wim 0:dc8789a6e21f 268 * @param PinName sclk Serial bus SCLK pin
wim 0:dc8789a6e21f 269 */
wim 0:dc8789a6e21f 270 class TM1637_CATALEX : public TM1637, public Stream {
wim 0:dc8789a6e21f 271 public:
wim 0:dc8789a6e21f 272
wim 0:dc8789a6e21f 273 /** Enums for Icons */
wim 0:dc8789a6e21f 274 // Grid encoded in 8 MSBs, Icon pattern encoded in 16 LSBs
wim 0:dc8789a6e21f 275 enum Icon {
wim 0:dc8789a6e21f 276 COL2 = ( 2<<24) | S7_DP2, /**< Column 2 */
wim 0:dc8789a6e21f 277 };
wim 0:dc8789a6e21f 278
wim 0:dc8789a6e21f 279 typedef char UDCData_t[CATALEX_NR_UDC];
wim 0:dc8789a6e21f 280
wim 0:dc8789a6e21f 281 /** Constructor for class for driving TM1637 LED controller as used in CATALEX
wim 0:dc8789a6e21f 282 *
wim 0:dc8789a6e21f 283 * @brief Supports 4 Digits of 7 Segments + DP.
wim 0:dc8789a6e21f 284 *
wim 0:dc8789a6e21f 285 * @param PinName mosi Serial bus MOSI pin
wim 0:dc8789a6e21f 286 * @param PinName mis0 Serial bus MISO pin
wim 0:dc8789a6e21f 287 * @param PinName sclk Serial bus SCLK pin
wim 0:dc8789a6e21f 288 */
wim 0:dc8789a6e21f 289 TM1637_CATALEX(PinName mosi, PinName miso, PinName sclk);
wim 0:dc8789a6e21f 290
wim 0:dc8789a6e21f 291 #if DOXYGEN_ONLY
wim 0:dc8789a6e21f 292 /** Write a character to the Display
wim 0:dc8789a6e21f 293 *
wim 0:dc8789a6e21f 294 * @param c The character to write to the display
wim 0:dc8789a6e21f 295 */
wim 0:dc8789a6e21f 296 int putc(int c);
wim 0:dc8789a6e21f 297
wim 0:dc8789a6e21f 298 /** Write a formatted string to the Display
wim 0:dc8789a6e21f 299 *
wim 0:dc8789a6e21f 300 * @param format A printf-style format string, followed by the
wim 0:dc8789a6e21f 301 * variables to use in formatting the string.
wim 0:dc8789a6e21f 302 */
wim 0:dc8789a6e21f 303 int printf(const char* format, ...);
wim 0:dc8789a6e21f 304 #endif
wim 0:dc8789a6e21f 305
wim 0:dc8789a6e21f 306 /** Locate cursor to a screen column
wim 0:dc8789a6e21f 307 *
wim 0:dc8789a6e21f 308 * @param column The horizontal position from the left, indexed from 0
wim 0:dc8789a6e21f 309 */
wim 0:dc8789a6e21f 310 void locate(int column);
wim 0:dc8789a6e21f 311
wim 0:dc8789a6e21f 312 /** Clear the screen and locate to 0
wim 0:dc8789a6e21f 313 * @param bool clrAll Clear Icons also (default = false)
wim 0:dc8789a6e21f 314 */
wim 0:dc8789a6e21f 315 void cls(bool clrAll = false);
wim 0:dc8789a6e21f 316
wim 0:dc8789a6e21f 317 /** Set Icon
wim 0:dc8789a6e21f 318 *
wim 0:dc8789a6e21f 319 * @param Icon icon Enums Icon has Grid position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs
wim 0:dc8789a6e21f 320 * @return none
wim 0:dc8789a6e21f 321 */
wim 0:dc8789a6e21f 322 void setIcon(Icon icon);
wim 0:dc8789a6e21f 323
wim 0:dc8789a6e21f 324 /** Clr Icon
wim 0:dc8789a6e21f 325 *
wim 0:dc8789a6e21f 326 * @param Icon icon Enums Icon has Grid position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs
wim 0:dc8789a6e21f 327 * @return none
wim 0:dc8789a6e21f 328 */
wim 0:dc8789a6e21f 329 void clrIcon(Icon icon);
wim 0:dc8789a6e21f 330
wim 0:dc8789a6e21f 331 /** Set User Defined Characters (UDC)
wim 0:dc8789a6e21f 332 *
wim 0:dc8789a6e21f 333 * @param unsigned char udc_idx The Index of the UDC (0..7)
wim 0:dc8789a6e21f 334 * @param int udc_data The bitpattern for the UDC (16 bits)
wim 0:dc8789a6e21f 335 */
wim 0:dc8789a6e21f 336 void setUDC(unsigned char udc_idx, int udc_data);
wim 0:dc8789a6e21f 337
wim 0:dc8789a6e21f 338
wim 0:dc8789a6e21f 339 /** Number of screen columns
wim 0:dc8789a6e21f 340 *
wim 0:dc8789a6e21f 341 * @param none
wim 0:dc8789a6e21f 342 * @return columns
wim 0:dc8789a6e21f 343 */
wim 0:dc8789a6e21f 344 int columns();
wim 0:dc8789a6e21f 345
wim 0:dc8789a6e21f 346 /** Write databyte to TM1637
wim 0:dc8789a6e21f 347 * @param char data byte written at given address
wim 0:dc8789a6e21f 348 * @param int address display memory location to write byte
wim 0:dc8789a6e21f 349 * @return none
wim 0:dc8789a6e21f 350 */
wim 0:dc8789a6e21f 351 void writeData(char data, int address){
wim 0:dc8789a6e21f 352 TM1637::writeData(data, address);
wim 0:dc8789a6e21f 353 }
wim 0:dc8789a6e21f 354
wim 0:dc8789a6e21f 355 /** Write Display datablock to TM1637
wim 0:dc8789a6e21f 356 * @param DisplayData_t data Array of TM1637_DISPLAY_MEM (=4) bytes for displaydata
wim 0:dc8789a6e21f 357 * @param length number bytes to write (valid range 0..(CATALEX_NR_GRIDS * TM1637_BYTES_PER_GRID) (=4), when starting at address 0)
wim 0:dc8789a6e21f 358 * @param int address display memory location to write bytes (default = 0)
wim 0:dc8789a6e21f 359 * @return none
wim 0:dc8789a6e21f 360 */
wim 0:dc8789a6e21f 361 void writeData(DisplayData_t data, int length = (CATALEX_NR_GRIDS * TM1637_BYTES_PER_GRID), int address = 0) {
wim 0:dc8789a6e21f 362 TM1637::writeData(data, length, address);
wim 0:dc8789a6e21f 363 }
wim 0:dc8789a6e21f 364
wim 0:dc8789a6e21f 365 protected:
wim 0:dc8789a6e21f 366 // Stream implementation functions
wim 0:dc8789a6e21f 367 virtual int _putc(int value);
wim 0:dc8789a6e21f 368 virtual int _getc();
wim 0:dc8789a6e21f 369
wim 0:dc8789a6e21f 370 private:
wim 0:dc8789a6e21f 371 int _column;
wim 0:dc8789a6e21f 372 int _columns;
wim 0:dc8789a6e21f 373
wim 0:dc8789a6e21f 374 DisplayData_t _displaybuffer;
wim 0:dc8789a6e21f 375 UDCData_t _UDC_7S;
wim 0:dc8789a6e21f 376 };
wim 0:dc8789a6e21f 377 #endif
wim 0:dc8789a6e21f 378
wim 0:dc8789a6e21f 379 #endif