Library for the Princeton PT6312 Vacuum Fluorescent Display (VFD) driver.
This library is documented here.
PT6312.h@6:d3dc313a6840, 2016-01-20 (annotated)
- Committer:
- wim
- Date:
- Wed Jan 20 18:50:50 2016 +0000
- Revision:
- 6:d3dc313a6840
- Parent:
- 5:be9ec73af639
Rename Digit/Grid, added DVD462 code, added C2233 code, added fonts.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 0:e59142cded2b | 1 | /* mbed PT6312 Library, for Princeton PT6312 VFD controller |
wim | 0:e59142cded2b | 2 | * Copyright (c) 2015, v01: WH, Initial version |
wim | 5:be9ec73af639 | 3 | * 2015, v02: WH, rename Digit/Grid, added DVD462 code, added C2233 code |
wim | 6:d3dc313a6840 | 4 | * 2016, v03: WH, refactored display and keyboard defines |
wim | 0:e59142cded2b | 5 | * |
wim | 0:e59142cded2b | 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
wim | 0:e59142cded2b | 7 | * of this software and associated documentation files (the "Software"), to deal |
wim | 0:e59142cded2b | 8 | * in the Software without restriction, including without limitation the rights |
wim | 0:e59142cded2b | 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
wim | 0:e59142cded2b | 10 | * copies of the Software, and to permit persons to whom the Software is |
wim | 0:e59142cded2b | 11 | * furnished to do so, subject to the following conditions: |
wim | 0:e59142cded2b | 12 | * |
wim | 0:e59142cded2b | 13 | * The above copyright notice and this permission notice shall be included in |
wim | 0:e59142cded2b | 14 | * all copies or substantial portions of the Software. |
wim | 0:e59142cded2b | 15 | * |
wim | 0:e59142cded2b | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
wim | 0:e59142cded2b | 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
wim | 0:e59142cded2b | 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
wim | 0:e59142cded2b | 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
wim | 0:e59142cded2b | 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
wim | 0:e59142cded2b | 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
wim | 0:e59142cded2b | 22 | * THE SOFTWARE. |
wim | 0:e59142cded2b | 23 | */ |
wim | 0:e59142cded2b | 24 | |
wim | 0:e59142cded2b | 25 | #ifndef PT6312_H |
wim | 0:e59142cded2b | 26 | #define PT6312_H |
wim | 0:e59142cded2b | 27 | |
wim | 5:be9ec73af639 | 28 | // Select one of the testboards for Princeton PT6312 VFD controller |
wim | 5:be9ec73af639 | 29 | #include "PT6312_Config.h" |
wim | 3:156c23d9652a | 30 | |
wim | 0:e59142cded2b | 31 | /** An interface for driving Princeton PT6312 VFD controller |
wim | 0:e59142cded2b | 32 | * |
wim | 0:e59142cded2b | 33 | * @code |
wim | 3:156c23d9652a | 34 | * |
wim | 5:be9ec73af639 | 35 | * #if (PT6312_TEST == 1) |
wim | 3:156c23d9652a | 36 | * // Direct driving of PT6312 Test |
wim | 3:156c23d9652a | 37 | * |
wim | 0:e59142cded2b | 38 | * #include "mbed.h" |
wim | 3:156c23d9652a | 39 | * #include "PT6312.h" |
wim | 0:e59142cded2b | 40 | * |
wim | 5:be9ec73af639 | 41 | * DisplayData_t size is 8 bytes (4 Grids @ 16 Segments) ... 22 bytes (11 Grids @ 11 Segments) |
wim | 5:be9ec73af639 | 42 | * DisplayData_t size default is 14 bytes (7 Grids @ 15 Segments) |
wim | 0:e59142cded2b | 43 | * PT6312::DisplayData_t mbed_str = {0xDA,0x00, 0x7C,0x00, 0x3C,0x01, 0xF6,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:e59142cded2b | 44 | * PT6312::DisplayData_t all_str = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F}; |
wim | 0:e59142cded2b | 45 | * |
wim | 0:e59142cded2b | 46 | * // KeyData_t size is 3 bytes |
wim | 0:e59142cded2b | 47 | * PT6312::KeyData_t keydata; |
wim | 0:e59142cded2b | 48 | * |
wim | 5:be9ec73af639 | 49 | * // PT6191 declaration, Default setting 7 Grids @ 15 Segments |
wim | 0:e59142cded2b | 50 | * PT6312 PT6312(p5,p6,p7, p8); |
wim | 0:e59142cded2b | 51 | * |
wim | 0:e59142cded2b | 52 | * int main() { |
wim | 0:e59142cded2b | 53 | * PT6312.cls(); |
wim | 0:e59142cded2b | 54 | * PT6312.writeData(all_str); |
wim | 0:e59142cded2b | 55 | * wait(4); |
wim | 0:e59142cded2b | 56 | * PT6312.writeData(mbed_str); |
wim | 0:e59142cded2b | 57 | * wait(1); |
wim | 0:e59142cded2b | 58 | * PT6312.setBrightness(PT6312_BRT0); |
wim | 0:e59142cded2b | 59 | * wait(1); |
wim | 0:e59142cded2b | 60 | * PT6312.setBrightness(PT6312_BRT3); |
wim | 0:e59142cded2b | 61 | * |
wim | 0:e59142cded2b | 62 | * while (1) { |
wim | 0:e59142cded2b | 63 | * // Check and read keydata |
wim | 1:c5e247159aa6 | 64 | * if (PT6312.getKeys(&keydata)) { |
wim | 0:e59142cded2b | 65 | * pc.printf("Keydata 0..2 = 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2]); |
wim | 0:e59142cded2b | 66 | * |
wim | 0:e59142cded2b | 67 | * if (keydata[0] == 0x10) { //sw2 |
wim | 0:e59142cded2b | 68 | * PT6312.cls(); |
wim | 0:e59142cded2b | 69 | * PT6312.writeData(all_str); |
wim | 0:e59142cded2b | 70 | * } |
wim | 0:e59142cded2b | 71 | * } |
wim | 0:e59142cded2b | 72 | * } |
wim | 0:e59142cded2b | 73 | * } |
wim | 5:be9ec73af639 | 74 | * #endif |
wim | 3:156c23d9652a | 75 | * |
wim | 5:be9ec73af639 | 76 | * #if (DVP630_TEST == 1) |
wim | 3:156c23d9652a | 77 | * //Philips DVP630 Display Test |
wim | 3:156c23d9652a | 78 | * |
wim | 3:156c23d9652a | 79 | * #include "mbed.h" |
wim | 3:156c23d9652a | 80 | * #include "PT6312.h" |
wim | 3:156c23d9652a | 81 | * |
wim | 3:156c23d9652a | 82 | * // KeyData_t size is 3 bytes |
wim | 3:156c23d9652a | 83 | * PT6312::KeyData_t keydata; |
wim | 3:156c23d9652a | 84 | * |
wim | 5:be9ec73af639 | 85 | * // PT6312_DVD declaration (7 Grids @ 15 Segments) |
wim | 3:156c23d9652a | 86 | * PT6312_DVP630 DVP630(p5,p6,p7, p8); |
wim | 3:156c23d9652a | 87 | * |
wim | 3:156c23d9652a | 88 | * int main() { |
wim | 3:156c23d9652a | 89 | * |
wim | 3:156c23d9652a | 90 | * DVP630.cls(); |
wim | 3:156c23d9652a | 91 | * DVP630.setBrightness(PT6312_BRT7); |
wim | 3:156c23d9652a | 92 | * |
wim | 3:156c23d9652a | 93 | * //test to show all chars |
wim | 3:156c23d9652a | 94 | * |
wim | 3:156c23d9652a | 95 | * for (int i=0x20; i<0x80; i++) { |
wim | 3:156c23d9652a | 96 | * DVP630.cls(); |
wim | 3:156c23d9652a | 97 | * DVP630.printf("0x%2X=%c", i, (char) i); |
wim | 3:156c23d9652a | 98 | * wait(0.2); |
wim | 3:156c23d9652a | 99 | * // pc.getc(); |
wim | 3:156c23d9652a | 100 | * } |
wim | 3:156c23d9652a | 101 | * } |
wim | 3:156c23d9652a | 102 | * |
wim | 3:156c23d9652a | 103 | * #endif |
wim | 3:156c23d9652a | 104 | * |
wim | 0:e59142cded2b | 105 | * @endcode |
wim | 0:e59142cded2b | 106 | */ |
wim | 0:e59142cded2b | 107 | |
wim | 6:d3dc313a6840 | 108 | //PT6312 Display and Keymatrix data |
wim | 6:d3dc313a6840 | 109 | #define PT6312_MAX_NR_GRIDS 11 |
wim | 6:d3dc313a6840 | 110 | #define PT6312_BYTES_PER_GRID 2 |
wim | 6:d3dc313a6840 | 111 | //Significant bits Keymatrix data |
wim | 6:d3dc313a6840 | 112 | #define PT6312_KEY_MSK 0xFF |
wim | 6:d3dc313a6840 | 113 | |
wim | 0:e59142cded2b | 114 | //Memory size in bytes for Display and Keymatrix |
wim | 6:d3dc313a6840 | 115 | #define PT6312_DISPLAY_MEM (PT6312_MAX_NR_GRIDS * PT6312_BYTES_PER_GRID) |
wim | 0:e59142cded2b | 116 | #define PT6312_KEY_MEM 3 |
wim | 6:d3dc313a6840 | 117 | |
wim | 0:e59142cded2b | 118 | |
wim | 0:e59142cded2b | 119 | //Reserved bits for commands |
wim | 0:e59142cded2b | 120 | #define PT6312_CMD_MSK 0xE0 |
wim | 0:e59142cded2b | 121 | |
wim | 0:e59142cded2b | 122 | //Mode setting command |
wim | 0:e59142cded2b | 123 | #define PT6312_MODE_SET_CMD 0x00 |
wim | 5:be9ec73af639 | 124 | #define PT6312_GR4_SEG16 0x00 |
wim | 5:be9ec73af639 | 125 | #define PT6312_GR5_SEG16 0x01 |
wim | 5:be9ec73af639 | 126 | #define PT6312_GR6_SEG16 0x02 |
wim | 5:be9ec73af639 | 127 | #define PT6312_GR7_SEG15 0x03 //default |
wim | 5:be9ec73af639 | 128 | #define PT6312_GR8_SEG14 0x04 |
wim | 5:be9ec73af639 | 129 | #define PT6312_GR9_SEG13 0x05 |
wim | 5:be9ec73af639 | 130 | #define PT6312_GR10_SEG12 0x06 |
wim | 5:be9ec73af639 | 131 | #define PT6312_GR11_SEG11 0x07 |
wim | 0:e59142cded2b | 132 | |
wim | 0:e59142cded2b | 133 | |
wim | 0:e59142cded2b | 134 | //Data setting commands |
wim | 0:e59142cded2b | 135 | #define PT6312_DATA_SET_CMD 0x40 |
wim | 0:e59142cded2b | 136 | #define PT6312_DATA_WR 0x00 |
wim | 0:e59142cded2b | 137 | #define PT6312_LED_WR 0x01 |
wim | 0:e59142cded2b | 138 | #define PT6312_KEY_RD 0x02 |
wim | 0:e59142cded2b | 139 | #define PT6312_SW_RD 0x03 |
wim | 0:e59142cded2b | 140 | #define PT6312_ADDR_INC 0x00 |
wim | 0:e59142cded2b | 141 | #define PT6312_ADDR_FIXED 0x04 |
wim | 0:e59142cded2b | 142 | #define PT6312_MODE_NORM 0x00 |
wim | 0:e59142cded2b | 143 | #define PT6312_MODE_TEST 0x08 |
wim | 0:e59142cded2b | 144 | |
wim | 0:e59142cded2b | 145 | //LED settings data |
wim | 0:e59142cded2b | 146 | #define PT6312_LED_MSK 0x0F |
wim | 0:e59142cded2b | 147 | #define PT6312_LED1 0x01 |
wim | 0:e59142cded2b | 148 | #define PT6312_LED2 0x02 |
wim | 0:e59142cded2b | 149 | #define PT6312_LED3 0x04 |
wim | 0:e59142cded2b | 150 | #define PT6312_LED4 0x08 |
wim | 0:e59142cded2b | 151 | |
wim | 0:e59142cded2b | 152 | //Switch settings data |
wim | 0:e59142cded2b | 153 | #define PT6312_SW_MSK 0x0F |
wim | 0:e59142cded2b | 154 | #define PT6312_SW1 0x01 |
wim | 0:e59142cded2b | 155 | #define PT6312_SW2 0x02 |
wim | 0:e59142cded2b | 156 | #define PT6312_SW3 0x04 |
wim | 0:e59142cded2b | 157 | #define PT6312_SW4 0x08 |
wim | 0:e59142cded2b | 158 | |
wim | 0:e59142cded2b | 159 | //Address setting commands |
wim | 0:e59142cded2b | 160 | #define PT6312_ADDR_SET_CMD 0xC0 |
wim | 0:e59142cded2b | 161 | #define PT6312_ADDR_MSK 0x1F |
wim | 0:e59142cded2b | 162 | |
wim | 0:e59142cded2b | 163 | //Display control commands |
wim | 0:e59142cded2b | 164 | #define PT6312_DSP_CTRL_CMD 0x80 |
wim | 0:e59142cded2b | 165 | #define PT6312_BRT_MSK 0x07 |
wim | 0:e59142cded2b | 166 | #define PT6312_BRT0 0x00 //Pulsewidth 1/16 |
wim | 0:e59142cded2b | 167 | #define PT6312_BRT1 0x01 |
wim | 0:e59142cded2b | 168 | #define PT6312_BRT2 0x02 |
wim | 0:e59142cded2b | 169 | #define PT6312_BRT3 0x03 |
wim | 0:e59142cded2b | 170 | #define PT6312_BRT4 0x04 |
wim | 0:e59142cded2b | 171 | #define PT6312_BRT5 0x05 |
wim | 0:e59142cded2b | 172 | #define PT6312_BRT6 0x06 |
wim | 0:e59142cded2b | 173 | #define PT6312_BRT7 0x07 //Pulsewidth 14/16 |
wim | 0:e59142cded2b | 174 | |
wim | 0:e59142cded2b | 175 | #define PT6312_BRT_DEF PT6312_BRT3 |
wim | 0:e59142cded2b | 176 | |
wim | 0:e59142cded2b | 177 | #define PT6312_DSP_OFF 0x00 |
wim | 0:e59142cded2b | 178 | #define PT6312_DSP_ON 0x08 |
wim | 0:e59142cded2b | 179 | |
wim | 0:e59142cded2b | 180 | |
wim | 0:e59142cded2b | 181 | /** A class for driving Princeton PT6312 VFD controller |
wim | 0:e59142cded2b | 182 | * |
wim | 5:be9ec73af639 | 183 | * @brief Supports 4 Grids of 16 Segments upto 11 Grids of 11 Segments. Also supports a scanned keyboard of upto 24 keys, 4 switches and 4 LEDs. |
wim | 0:e59142cded2b | 184 | * SPI bus interface device. |
wim | 0:e59142cded2b | 185 | */ |
wim | 0:e59142cded2b | 186 | class PT6312 { |
wim | 0:e59142cded2b | 187 | public: |
wim | 0:e59142cded2b | 188 | |
wim | 0:e59142cded2b | 189 | /** Enums for display mode */ |
wim | 0:e59142cded2b | 190 | enum Mode { |
wim | 5:be9ec73af639 | 191 | Grid4_Seg16 = PT6312_GR4_SEG16, |
wim | 5:be9ec73af639 | 192 | Grid5_Seg16 = PT6312_GR5_SEG16, |
wim | 5:be9ec73af639 | 193 | Grid6_Seg16 = PT6312_GR6_SEG16, |
wim | 5:be9ec73af639 | 194 | Grid7_Seg15 = PT6312_GR7_SEG15, |
wim | 5:be9ec73af639 | 195 | Grid8_Seg14 = PT6312_GR8_SEG14, |
wim | 5:be9ec73af639 | 196 | Grid9_Seg13 = PT6312_GR9_SEG13, |
wim | 5:be9ec73af639 | 197 | Grid10_Seg12 = PT6312_GR10_SEG12, |
wim | 5:be9ec73af639 | 198 | Grid11_Seg11 = PT6312_GR11_SEG11 |
wim | 0:e59142cded2b | 199 | }; |
wim | 0:e59142cded2b | 200 | |
wim | 0:e59142cded2b | 201 | /** Datatypes for display and keymatrix data */ |
wim | 0:e59142cded2b | 202 | typedef char DisplayData_t[PT6312_DISPLAY_MEM]; |
wim | 0:e59142cded2b | 203 | typedef char KeyData_t[PT6312_KEY_MEM]; |
wim | 0:e59142cded2b | 204 | |
wim | 1:c5e247159aa6 | 205 | /** Constructor for class for driving Princeton PT6312 VFD controller |
wim | 0:e59142cded2b | 206 | * |
wim | 5:be9ec73af639 | 207 | * @brief Supports 4 Grids of 16 Segments upto 11 Grids of 11 Segments. Also supports a scanned keyboard of upto 24 keys, 4 switches and 4 LEDs. |
wim | 0:e59142cded2b | 208 | * SPI bus interface device. |
wim | 0:e59142cded2b | 209 | * @param PinName mosi, miso, sclk, cs SPI bus pins |
wim | 5:be9ec73af639 | 210 | * @param Mode selects either number of Grids and Segments (default 7 Grids, 15 Segments) |
wim | 0:e59142cded2b | 211 | */ |
wim | 5:be9ec73af639 | 212 | PT6312(PinName mosi, PinName miso, PinName sclk, PinName cs, Mode mode=Grid7_Seg15); |
wim | 0:e59142cded2b | 213 | |
wim | 0:e59142cded2b | 214 | /** Clear the screen and locate to 0 |
wim | 0:e59142cded2b | 215 | */ |
wim | 0:e59142cded2b | 216 | void cls(); |
wim | 0:e59142cded2b | 217 | |
wim | 0:e59142cded2b | 218 | /** Write databyte to PT6312 |
wim | 0:e59142cded2b | 219 | * @param int address display memory location to write byte |
wim | 0:e59142cded2b | 220 | * @param char data byte written at given address |
wim | 0:e59142cded2b | 221 | * @return none |
wim | 0:e59142cded2b | 222 | */ |
wim | 0:e59142cded2b | 223 | void writeData(int address, char data); |
wim | 0:e59142cded2b | 224 | |
wim | 0:e59142cded2b | 225 | /** Write Display datablock to PT6312 |
wim | 3:156c23d9652a | 226 | * @param DisplayData_t data Array of PT6312_DISPLAY_MEM (=22) bytes for displaydata (starting at address 0) |
wim | 3:156c23d9652a | 227 | * @param length number bytes to write (valid range 0..PT6312_DISPLAY_MEM (=22), starting at address 0) |
wim | 0:e59142cded2b | 228 | * @return none |
wim | 0:e59142cded2b | 229 | */ |
wim | 2:f010b7022803 | 230 | void writeData(DisplayData_t data, int length = PT6312_DISPLAY_MEM); |
wim | 0:e59142cded2b | 231 | |
wim | 0:e59142cded2b | 232 | |
wim | 0:e59142cded2b | 233 | /** Read keydata block from PT6312 |
wim | 0:e59142cded2b | 234 | * @param *keydata Ptr to Array of PT6312_KEY_MEM (=3) bytes for keydata |
wim | 0:e59142cded2b | 235 | * @return bool keypress True when at least one key was pressed |
wim | 0:e59142cded2b | 236 | * |
wim | 0:e59142cded2b | 237 | * Note: Due to the hardware configuration the PT6312 key matrix scanner will detect multiple keys pressed at same time, |
wim | 0:e59142cded2b | 238 | * but this may result in some spurious keys also being set in keypress data array. |
wim | 0:e59142cded2b | 239 | * It may be best to ignore all keys in those situations. That option is implemented in this method depending on #define setting. |
wim | 0:e59142cded2b | 240 | */ |
wim | 1:c5e247159aa6 | 241 | bool getKeys(KeyData_t *keydata); |
wim | 0:e59142cded2b | 242 | |
wim | 0:e59142cded2b | 243 | |
wim | 0:e59142cded2b | 244 | /** Read switches from PT6312 |
wim | 0:e59142cded2b | 245 | * |
wim | 0:e59142cded2b | 246 | * @param none |
wim | 0:e59142cded2b | 247 | * @return char for switch data (4 least significant bits) |
wim | 0:e59142cded2b | 248 | * |
wim | 0:e59142cded2b | 249 | */ |
wim | 1:c5e247159aa6 | 250 | char getSwitches(); |
wim | 0:e59142cded2b | 251 | |
wim | 0:e59142cded2b | 252 | /** Set LEDs |
wim | 0:e59142cded2b | 253 | * |
wim | 0:e59142cded2b | 254 | * @param char leds (4 least significant bits) |
wim | 0:e59142cded2b | 255 | * @return none |
wim | 0:e59142cded2b | 256 | */ |
wim | 0:e59142cded2b | 257 | void setLED (char leds = 0); |
wim | 0:e59142cded2b | 258 | |
wim | 0:e59142cded2b | 259 | /** Set Brightness |
wim | 0:e59142cded2b | 260 | * |
wim | 0:e59142cded2b | 261 | * @param char brightness (3 significant bits, valid range 0..7 (1/16 .. 14/14 dutycycle) |
wim | 0:e59142cded2b | 262 | * @return none |
wim | 0:e59142cded2b | 263 | */ |
wim | 0:e59142cded2b | 264 | void setBrightness(char brightness = PT6312_BRT_DEF); |
wim | 0:e59142cded2b | 265 | |
wim | 0:e59142cded2b | 266 | /** Set the Display mode On/off |
wim | 0:e59142cded2b | 267 | * |
wim | 0:e59142cded2b | 268 | * @param bool display mode |
wim | 0:e59142cded2b | 269 | */ |
wim | 0:e59142cded2b | 270 | void setDisplay(bool on); |
wim | 0:e59142cded2b | 271 | |
wim | 0:e59142cded2b | 272 | private: |
wim | 0:e59142cded2b | 273 | SPI _spi; |
wim | 0:e59142cded2b | 274 | DigitalOut _cs; |
wim | 0:e59142cded2b | 275 | Mode _mode; |
wim | 0:e59142cded2b | 276 | char _display; |
wim | 0:e59142cded2b | 277 | char _bright; |
wim | 0:e59142cded2b | 278 | |
wim | 0:e59142cded2b | 279 | /** Init the SPI interface and the controller |
wim | 0:e59142cded2b | 280 | * @param none |
wim | 0:e59142cded2b | 281 | * @return none |
wim | 0:e59142cded2b | 282 | */ |
wim | 0:e59142cded2b | 283 | void _init(); |
wim | 0:e59142cded2b | 284 | |
wim | 0:e59142cded2b | 285 | /** Helper to reverse all command or databits. The PT6312 expects LSB first, whereas SPI is MSB first |
wim | 0:e59142cded2b | 286 | * @param char data |
wim | 0:e59142cded2b | 287 | * @return bitreversed data |
wim | 0:e59142cded2b | 288 | */ |
wim | 0:e59142cded2b | 289 | char _flip(char data); |
wim | 0:e59142cded2b | 290 | |
wim | 0:e59142cded2b | 291 | /** Write command and parameter to PT6312 |
wim | 0:e59142cded2b | 292 | * @param int cmd Command byte |
wim | 0:e59142cded2b | 293 | * &Param int data Parameters for command |
wim | 0:e59142cded2b | 294 | * @return none |
wim | 0:e59142cded2b | 295 | */ |
wim | 0:e59142cded2b | 296 | void _writeCmd(int cmd, int data); |
wim | 0:e59142cded2b | 297 | }; |
wim | 0:e59142cded2b | 298 | |
wim | 1:c5e247159aa6 | 299 | |
wim | 5:be9ec73af639 | 300 | |
wim | 5:be9ec73af639 | 301 | #if (DVP630_TEST == 1) |
wim | 3:156c23d9652a | 302 | // Derived class for PT6312 used in Philips DVP630 front display unit |
wim | 3:156c23d9652a | 303 | // |
wim | 5:be9ec73af639 | 304 | #include "Font_16Seg.h" |
wim | 1:c5e247159aa6 | 305 | |
wim | 5:be9ec73af639 | 306 | #define DVP630_NR_GRIDS 7 |
wim | 2:f010b7022803 | 307 | #define DVP630_NR_DIGITS 7 |
wim | 5:be9ec73af639 | 308 | #define DVP630_DIG1_IDX 1 |
wim | 3:156c23d9652a | 309 | #define DVP630_NR_UDC 8 |
wim | 2:f010b7022803 | 310 | |
wim | 2:f010b7022803 | 311 | /** Constructor for class for driving Princeton PT6312 VFD controller as used in Philips DVP630 |
wim | 1:c5e247159aa6 | 312 | * |
wim | 3:156c23d9652a | 313 | * @brief Supports 7 Digits of 15 Segments. Also supports a scanned keyboard of 3 keys, 3 switches and 1 LED. |
wim | 3:156c23d9652a | 314 | * |
wim | 1:c5e247159aa6 | 315 | * @param PinName mosi, miso, sclk, cs SPI bus pins |
wim | 1:c5e247159aa6 | 316 | */ |
wim | 2:f010b7022803 | 317 | class PT6312_DVP630 : public PT6312, public Stream { |
wim | 1:c5e247159aa6 | 318 | public: |
wim | 1:c5e247159aa6 | 319 | |
wim | 3:156c23d9652a | 320 | /** Enums for Icons */ |
wim | 5:be9ec73af639 | 321 | // Grid encoded in 8 MSBs, Icon pattern encoded in 24 LSBs |
wim | 3:156c23d9652a | 322 | enum Icon { |
wim | 5:be9ec73af639 | 323 | COL3 = (5<<24) | S_COL3, |
wim | 5:be9ec73af639 | 324 | COL5 = (3<<24) | S_COL5 |
wim | 3:156c23d9652a | 325 | }; |
wim | 3:156c23d9652a | 326 | |
wim | 3:156c23d9652a | 327 | typedef char UDCData_t[DVP630_NR_UDC][2]; |
wim | 3:156c23d9652a | 328 | |
wim | 2:f010b7022803 | 329 | /** Constructor for class for driving Princeton PT6312 VFD controller as used in Philips DVP630 |
wim | 1:c5e247159aa6 | 330 | * |
wim | 1:c5e247159aa6 | 331 | * @brief Supports 7 Digits of 15 Segments. Also supports a scanned keyboard of 3 keys, 3 switches and 1 LED. |
wim | 3:156c23d9652a | 332 | * |
wim | 1:c5e247159aa6 | 333 | * @param PinName mosi, miso, sclk, cs SPI bus pins |
wim | 1:c5e247159aa6 | 334 | */ |
wim | 2:f010b7022803 | 335 | PT6312_DVP630(PinName mosi, PinName miso, PinName sclk, PinName cs); |
wim | 1:c5e247159aa6 | 336 | |
wim | 1:c5e247159aa6 | 337 | #if DOXYGEN_ONLY |
wim | 5:be9ec73af639 | 338 | /** Write a character to the Display |
wim | 1:c5e247159aa6 | 339 | * |
wim | 1:c5e247159aa6 | 340 | * @param c The character to write to the display |
wim | 1:c5e247159aa6 | 341 | */ |
wim | 1:c5e247159aa6 | 342 | int putc(int c); |
wim | 1:c5e247159aa6 | 343 | |
wim | 5:be9ec73af639 | 344 | /** Write a formatted string to the Display |
wim | 1:c5e247159aa6 | 345 | * |
wim | 1:c5e247159aa6 | 346 | * @param format A printf-style format string, followed by the |
wim | 1:c5e247159aa6 | 347 | * variables to use in formatting the string. |
wim | 1:c5e247159aa6 | 348 | */ |
wim | 1:c5e247159aa6 | 349 | int printf(const char* format, ...); |
wim | 1:c5e247159aa6 | 350 | #endif |
wim | 1:c5e247159aa6 | 351 | |
wim | 1:c5e247159aa6 | 352 | /** Locate cursor to a screen column |
wim | 1:c5e247159aa6 | 353 | * |
wim | 1:c5e247159aa6 | 354 | * @param column The horizontal position from the left, indexed from 0 |
wim | 1:c5e247159aa6 | 355 | */ |
wim | 1:c5e247159aa6 | 356 | void locate(int column); |
wim | 1:c5e247159aa6 | 357 | |
wim | 1:c5e247159aa6 | 358 | /** Clear the screen and locate to 0 |
wim | 5:be9ec73af639 | 359 | * @param bool clrAll Clear Icons also (default = false) |
wim | 1:c5e247159aa6 | 360 | */ |
wim | 5:be9ec73af639 | 361 | void cls(bool clrAll = false); |
wim | 1:c5e247159aa6 | 362 | |
wim | 3:156c23d9652a | 363 | /** Set Icon |
wim | 3:156c23d9652a | 364 | * |
wim | 5:be9ec73af639 | 365 | * @param Icon icon Enums Icon has Digit position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs |
wim | 3:156c23d9652a | 366 | * @return none |
wim | 3:156c23d9652a | 367 | */ |
wim | 3:156c23d9652a | 368 | void setIcon(Icon icon); |
wim | 3:156c23d9652a | 369 | |
wim | 3:156c23d9652a | 370 | /** Clr Icon |
wim | 3:156c23d9652a | 371 | * |
wim | 5:be9ec73af639 | 372 | * @param Icon icon Enums Icon has Digit position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs |
wim | 5:be9ec73af639 | 373 | * @return none |
wim | 5:be9ec73af639 | 374 | */ |
wim | 5:be9ec73af639 | 375 | void clrIcon(Icon icon); |
wim | 5:be9ec73af639 | 376 | |
wim | 5:be9ec73af639 | 377 | /** Set User Defined Characters (UDC) |
wim | 5:be9ec73af639 | 378 | * |
wim | 5:be9ec73af639 | 379 | * @param unsigned char udc_idx The Index of the UDC (0..7) |
wim | 5:be9ec73af639 | 380 | * @param int udc_data The bitpattern for the UDC (16 bits) |
wim | 5:be9ec73af639 | 381 | */ |
wim | 5:be9ec73af639 | 382 | void setUDC(unsigned char udc_idx, int udc_data); |
wim | 5:be9ec73af639 | 383 | |
wim | 5:be9ec73af639 | 384 | |
wim | 5:be9ec73af639 | 385 | /** Number of screen columns |
wim | 5:be9ec73af639 | 386 | * |
wim | 5:be9ec73af639 | 387 | * @param none |
wim | 5:be9ec73af639 | 388 | * @return columns |
wim | 5:be9ec73af639 | 389 | */ |
wim | 5:be9ec73af639 | 390 | int columns(); |
wim | 5:be9ec73af639 | 391 | |
wim | 5:be9ec73af639 | 392 | /** Write databyte to PT6312 |
wim | 5:be9ec73af639 | 393 | * @param int address display memory location to write byte |
wim | 5:be9ec73af639 | 394 | * @param char data byte written at given address |
wim | 5:be9ec73af639 | 395 | * @return none |
wim | 5:be9ec73af639 | 396 | */ |
wim | 5:be9ec73af639 | 397 | void writeData(int address, char data){ |
wim | 5:be9ec73af639 | 398 | PT6312::writeData(address, data); |
wim | 5:be9ec73af639 | 399 | } |
wim | 5:be9ec73af639 | 400 | |
wim | 5:be9ec73af639 | 401 | /** Write Display datablock to PT6312 |
wim | 5:be9ec73af639 | 402 | * @param DisplayData_t data Array of PT6312_DISPLAY_MEM (=22) bytes for displaydata (starting at address 0) |
wim | 5:be9ec73af639 | 403 | * @param length number bytes to write (valid range 0..(DVP630_NR_GRIDS*2) (=14), starting at address 0) |
wim | 5:be9ec73af639 | 404 | * @return none |
wim | 5:be9ec73af639 | 405 | */ |
wim | 5:be9ec73af639 | 406 | void writeData(DisplayData_t data, int length = (DVP630_NR_GRIDS*2)) { |
wim | 5:be9ec73af639 | 407 | PT6312::writeData(data, length); |
wim | 5:be9ec73af639 | 408 | } |
wim | 5:be9ec73af639 | 409 | |
wim | 5:be9ec73af639 | 410 | protected: |
wim | 5:be9ec73af639 | 411 | // Stream implementation functions |
wim | 5:be9ec73af639 | 412 | virtual int _putc(int value); |
wim | 5:be9ec73af639 | 413 | virtual int _getc(); |
wim | 5:be9ec73af639 | 414 | |
wim | 5:be9ec73af639 | 415 | private: |
wim | 5:be9ec73af639 | 416 | int _column; // Current cursor location |
wim | 5:be9ec73af639 | 417 | int _columns; // Max number of columns |
wim | 5:be9ec73af639 | 418 | |
wim | 5:be9ec73af639 | 419 | DisplayData_t _displaybuffer; // Local mirror for all chars and icons |
wim | 5:be9ec73af639 | 420 | UDCData_t _UDC_16S; // User Defined Character pattterns (UDC) |
wim | 5:be9ec73af639 | 421 | }; |
wim | 5:be9ec73af639 | 422 | #endif |
wim | 5:be9ec73af639 | 423 | |
wim | 5:be9ec73af639 | 424 | #if (DVD462_TEST == 1) |
wim | 5:be9ec73af639 | 425 | // Derived class for DVD462 in Cyberhome DVD462 front display unit |
wim | 5:be9ec73af639 | 426 | // Grids 2-4 each display two 7-Segment digits, Grid 5 displays one 7-Segment digit. |
wim | 5:be9ec73af639 | 427 | // Several Icons are also available. |
wim | 5:be9ec73af639 | 428 | // |
wim | 5:be9ec73af639 | 429 | #include "Font_7Seg.h" |
wim | 5:be9ec73af639 | 430 | |
wim | 5:be9ec73af639 | 431 | #define DVD462_NR_GRIDS 6 |
wim | 5:be9ec73af639 | 432 | #define DVD462_NR_DIGITS 7 |
wim | 5:be9ec73af639 | 433 | //#define DVD462_DIG1_IDX 1 |
wim | 5:be9ec73af639 | 434 | #define DVD462_NR_UDC 8 |
wim | 5:be9ec73af639 | 435 | |
wim | 5:be9ec73af639 | 436 | /** Constructor for class for driving Princeton PT6312 VFD controller as used in DVD462 |
wim | 5:be9ec73af639 | 437 | * |
wim | 5:be9ec73af639 | 438 | * @brief Supports 7 Digits of 7 Segments and icons. Also supports a scanned keyboard of 7 keys and 1 LED. |
wim | 5:be9ec73af639 | 439 | * |
wim | 5:be9ec73af639 | 440 | * @param PinName mosi, miso, sclk, cs SPI bus pins |
wim | 5:be9ec73af639 | 441 | */ |
wim | 5:be9ec73af639 | 442 | class PT6312_DVD462 : public PT6312, public Stream { |
wim | 5:be9ec73af639 | 443 | public: |
wim | 5:be9ec73af639 | 444 | |
wim | 5:be9ec73af639 | 445 | /** Enums for Icons */ |
wim | 5:be9ec73af639 | 446 | // Grid encoded in 8 MSBs, Icon pattern encoded in 24 LSBs |
wim | 5:be9ec73af639 | 447 | enum Icon { |
wim | 5:be9ec73af639 | 448 | MP3 = (1<<24) | S7_MP3, |
wim | 5:be9ec73af639 | 449 | CD = (1<<24) | S7_CD, |
wim | 5:be9ec73af639 | 450 | V = (1<<24) | S7_V, |
wim | 5:be9ec73af639 | 451 | S = (1<<24) | S7_S, |
wim | 5:be9ec73af639 | 452 | DVD = (1<<24) | S7_DVD, |
wim | 5:be9ec73af639 | 453 | |
wim | 5:be9ec73af639 | 454 | DDD = (2<<24) | S7_DDD, |
wim | 5:be9ec73af639 | 455 | DTS = (2<<24) | S7_DTS, |
wim | 5:be9ec73af639 | 456 | |
wim | 5:be9ec73af639 | 457 | COL5 = (3<<24) | S7_COL5, |
wim | 5:be9ec73af639 | 458 | |
wim | 5:be9ec73af639 | 459 | COL3 = (4<<24) | S7_COL3, |
wim | 5:be9ec73af639 | 460 | |
wim | 5:be9ec73af639 | 461 | ARW = (5<<24) | S7_ARW, |
wim | 5:be9ec73af639 | 462 | ALL = (5<<24) | S7_ALL, |
wim | 5:be9ec73af639 | 463 | PSE = (5<<24) | S7_PSE, |
wim | 5:be9ec73af639 | 464 | PLY = (5<<24) | S7_PLY, |
wim | 5:be9ec73af639 | 465 | PBC = (5<<24) | S7_PBC, |
wim | 5:be9ec73af639 | 466 | |
wim | 5:be9ec73af639 | 467 | P1 = (6<<24) | S7_P1, |
wim | 5:be9ec73af639 | 468 | P2 = (6<<24) | S7_P2, |
wim | 5:be9ec73af639 | 469 | P3 = (6<<24) | S7_P3, |
wim | 5:be9ec73af639 | 470 | P4 = (6<<24) | S7_P4, |
wim | 5:be9ec73af639 | 471 | P5 = (6<<24) | S7_P5, |
wim | 5:be9ec73af639 | 472 | P6 = (6<<24) | S7_P6, |
wim | 5:be9ec73af639 | 473 | P7 = (6<<24) | S7_P7, |
wim | 5:be9ec73af639 | 474 | P8 = (6<<24) | S7_P8, |
wim | 5:be9ec73af639 | 475 | P9 = (6<<24) | S7_P9, |
wim | 5:be9ec73af639 | 476 | P10 = (6<<24) | S7_P10, |
wim | 5:be9ec73af639 | 477 | P11 = (6<<24) | S7_P11, |
wim | 5:be9ec73af639 | 478 | P12 = (6<<24) | S7_P12, |
wim | 5:be9ec73af639 | 479 | P13 = (6<<24) | S7_P13 |
wim | 5:be9ec73af639 | 480 | |
wim | 5:be9ec73af639 | 481 | }; |
wim | 5:be9ec73af639 | 482 | |
wim | 5:be9ec73af639 | 483 | typedef char UDCData_t[DVD462_NR_UDC]; |
wim | 5:be9ec73af639 | 484 | |
wim | 5:be9ec73af639 | 485 | /** Constructor for class for driving Princeton PT6312 VFD controller as used in DVD462 |
wim | 5:be9ec73af639 | 486 | * |
wim | 5:be9ec73af639 | 487 | * @brief Supports 7 Digits of 7 Segments and Icons. Also supports a scanned keyboard of 7 keys and 1 LED. |
wim | 5:be9ec73af639 | 488 | * |
wim | 5:be9ec73af639 | 489 | * @param PinName mosi, miso, sclk, cs SPI bus pins |
wim | 5:be9ec73af639 | 490 | */ |
wim | 5:be9ec73af639 | 491 | PT6312_DVD462(PinName mosi, PinName miso, PinName sclk, PinName cs); |
wim | 5:be9ec73af639 | 492 | |
wim | 5:be9ec73af639 | 493 | #if DOXYGEN_ONLY |
wim | 5:be9ec73af639 | 494 | /** Write a character to the Display |
wim | 5:be9ec73af639 | 495 | * |
wim | 5:be9ec73af639 | 496 | * @param c The character to write to the display |
wim | 5:be9ec73af639 | 497 | */ |
wim | 5:be9ec73af639 | 498 | int putc(int c); |
wim | 5:be9ec73af639 | 499 | |
wim | 5:be9ec73af639 | 500 | /** Write a formatted string to the Display |
wim | 5:be9ec73af639 | 501 | * |
wim | 5:be9ec73af639 | 502 | * @param format A printf-style format string, followed by the |
wim | 5:be9ec73af639 | 503 | * variables to use in formatting the string. |
wim | 5:be9ec73af639 | 504 | */ |
wim | 5:be9ec73af639 | 505 | int printf(const char* format, ...); |
wim | 5:be9ec73af639 | 506 | #endif |
wim | 5:be9ec73af639 | 507 | |
wim | 5:be9ec73af639 | 508 | /** Locate cursor to a screen column |
wim | 5:be9ec73af639 | 509 | * |
wim | 5:be9ec73af639 | 510 | * @param column The horizontal position from the left, indexed from 0 |
wim | 5:be9ec73af639 | 511 | */ |
wim | 5:be9ec73af639 | 512 | void locate(int column); |
wim | 5:be9ec73af639 | 513 | |
wim | 5:be9ec73af639 | 514 | /** Clear the screen and locate to 0 |
wim | 5:be9ec73af639 | 515 | * @param bool clrAll Clear Icons also (default = false) |
wim | 5:be9ec73af639 | 516 | */ |
wim | 5:be9ec73af639 | 517 | void cls(bool clrAll = false); |
wim | 5:be9ec73af639 | 518 | |
wim | 5:be9ec73af639 | 519 | /** Set Icon |
wim | 5:be9ec73af639 | 520 | * |
wim | 5:be9ec73af639 | 521 | * @param Icon icon Enums Icon has Grid position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs |
wim | 5:be9ec73af639 | 522 | * @return none |
wim | 5:be9ec73af639 | 523 | */ |
wim | 5:be9ec73af639 | 524 | void setIcon(Icon icon); |
wim | 5:be9ec73af639 | 525 | |
wim | 5:be9ec73af639 | 526 | /** Clr Icon |
wim | 5:be9ec73af639 | 527 | * |
wim | 5:be9ec73af639 | 528 | * @param Icon icon Enums Icon has Grid position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs |
wim | 3:156c23d9652a | 529 | * @return none |
wim | 3:156c23d9652a | 530 | */ |
wim | 3:156c23d9652a | 531 | void clrIcon(Icon icon); |
wim | 3:156c23d9652a | 532 | |
wim | 3:156c23d9652a | 533 | /** Set User Defined Characters (UDC) |
wim | 3:156c23d9652a | 534 | * |
wim | 3:156c23d9652a | 535 | * @param unsigned char udc_idx The Index of the UDC (0..7) |
wim | 3:156c23d9652a | 536 | * @param int udc_data The bitpattern for the UDC (16 bits) |
wim | 3:156c23d9652a | 537 | */ |
wim | 3:156c23d9652a | 538 | void setUDC(unsigned char udc_idx, int udc_data); |
wim | 3:156c23d9652a | 539 | |
wim | 3:156c23d9652a | 540 | |
wim | 1:c5e247159aa6 | 541 | /** Number of screen columns |
wim | 1:c5e247159aa6 | 542 | * |
wim | 1:c5e247159aa6 | 543 | * @param none |
wim | 1:c5e247159aa6 | 544 | * @return columns |
wim | 1:c5e247159aa6 | 545 | */ |
wim | 1:c5e247159aa6 | 546 | int columns(); |
wim | 1:c5e247159aa6 | 547 | |
wim | 5:be9ec73af639 | 548 | /** Write databyte to PT6312 |
wim | 5:be9ec73af639 | 549 | * @param int address display memory location to write byte |
wim | 5:be9ec73af639 | 550 | * @param char data byte written at given address |
wim | 5:be9ec73af639 | 551 | * @return none |
wim | 5:be9ec73af639 | 552 | */ |
wim | 5:be9ec73af639 | 553 | void writeData(int address, char data){ |
wim | 5:be9ec73af639 | 554 | PT6312::writeData(address, data); |
wim | 5:be9ec73af639 | 555 | } |
wim | 5:be9ec73af639 | 556 | |
wim | 3:156c23d9652a | 557 | /** Write Display datablock to PT6312 |
wim | 3:156c23d9652a | 558 | * @param DisplayData_t data Array of PT6312_DISPLAY_MEM (=22) bytes for displaydata (starting at address 0) |
wim | 5:be9ec73af639 | 559 | * @param length number bytes to write (valid range 0..(DVD462_NR_GRIDS*2) (=14), starting at address 0) |
wim | 3:156c23d9652a | 560 | * @return none |
wim | 3:156c23d9652a | 561 | */ |
wim | 5:be9ec73af639 | 562 | void writeData(DisplayData_t data, int length = (DVD462_NR_GRIDS*2)) { |
wim | 3:156c23d9652a | 563 | PT6312::writeData(data, length); |
wim | 3:156c23d9652a | 564 | } |
wim | 2:f010b7022803 | 565 | |
wim | 1:c5e247159aa6 | 566 | protected: |
wim | 1:c5e247159aa6 | 567 | // Stream implementation functions |
wim | 1:c5e247159aa6 | 568 | virtual int _putc(int value); |
wim | 1:c5e247159aa6 | 569 | virtual int _getc(); |
wim | 1:c5e247159aa6 | 570 | |
wim | 1:c5e247159aa6 | 571 | private: |
wim | 5:be9ec73af639 | 572 | int _column; // Current cursor location |
wim | 5:be9ec73af639 | 573 | int _columns; // Max number of columns |
wim | 5:be9ec73af639 | 574 | |
wim | 5:be9ec73af639 | 575 | DisplayData_t _displaybuffer; // Local mirror for all chars and icons |
wim | 5:be9ec73af639 | 576 | UDCData_t _UDC_7S; // User Defined Character pattterns (UDC) |
wim | 5:be9ec73af639 | 577 | }; |
wim | 5:be9ec73af639 | 578 | #endif |
wim | 5:be9ec73af639 | 579 | |
wim | 5:be9ec73af639 | 580 | #if (C2233_TEST == 1) |
wim | 5:be9ec73af639 | 581 | // Derived class for C2233 front display unit |
wim | 5:be9ec73af639 | 582 | // Grids 2-4 each display two 7-Segment digits, Grid 5 displays one 7-Segment digit. |
wim | 5:be9ec73af639 | 583 | // Several Icons are also available. |
wim | 5:be9ec73af639 | 584 | // |
wim | 5:be9ec73af639 | 585 | #include "Font_7Seg.h" |
wim | 5:be9ec73af639 | 586 | |
wim | 5:be9ec73af639 | 587 | #define C2233_NR_GRIDS 6 |
wim | 5:be9ec73af639 | 588 | #define C2233_NR_DIGITS 7 |
wim | 5:be9ec73af639 | 589 | //#define C2233_DIG1_IDX 1 |
wim | 5:be9ec73af639 | 590 | #define C2233_NR_UDC 8 |
wim | 5:be9ec73af639 | 591 | |
wim | 5:be9ec73af639 | 592 | /** Constructor for class for driving Princeton PT6312 VFD controller as used in C2233 |
wim | 5:be9ec73af639 | 593 | * |
wim | 5:be9ec73af639 | 594 | * @brief Supports 7 Digits of 7 Segments and icons. Also supports a scanned keyboard of 7 keys. |
wim | 5:be9ec73af639 | 595 | * |
wim | 5:be9ec73af639 | 596 | * @param PinName mosi, miso, sclk, cs SPI bus pins |
wim | 5:be9ec73af639 | 597 | */ |
wim | 5:be9ec73af639 | 598 | class PT6312_C2233 : public PT6312, public Stream { |
wim | 5:be9ec73af639 | 599 | public: |
wim | 5:be9ec73af639 | 600 | |
wim | 5:be9ec73af639 | 601 | /** Enums for Icons */ |
wim | 5:be9ec73af639 | 602 | // Grid encoded in 8 MSBs, Icon pattern encoded in 24 LSBs |
wim | 5:be9ec73af639 | 603 | enum Icon { |
wim | 5:be9ec73af639 | 604 | MP3 = (2<<24) | S7_MP3, |
wim | 5:be9ec73af639 | 605 | PBC = (2<<24) | S7_PBC, |
wim | 5:be9ec73af639 | 606 | |
wim | 5:be9ec73af639 | 607 | COL5 = (3<<24) | S7_COL5, |
wim | 5:be9ec73af639 | 608 | CAM = (3<<24) | S7_CAM, |
wim | 5:be9ec73af639 | 609 | |
wim | 5:be9ec73af639 | 610 | COL3 = (4<<24) | S7_COL3, |
wim | 5:be9ec73af639 | 611 | DDD = (4<<24) | S7_DDD, |
wim | 2:f010b7022803 | 612 | |
wim | 5:be9ec73af639 | 613 | ARW = (5<<24) | S7_ARW, |
wim | 5:be9ec73af639 | 614 | ALL = (5<<24) | S7_ALL, |
wim | 5:be9ec73af639 | 615 | PSE = (5<<24) | S7_PSE, |
wim | 5:be9ec73af639 | 616 | PLY = (5<<24) | S7_PLY, |
wim | 5:be9ec73af639 | 617 | CD = (5<<24) | S7_CD, |
wim | 5:be9ec73af639 | 618 | V = (5<<24) | S7_V, |
wim | 5:be9ec73af639 | 619 | S = (5<<24) | S7_S, |
wim | 5:be9ec73af639 | 620 | DTS = (5<<24) | S7_DTS, |
wim | 5:be9ec73af639 | 621 | |
wim | 5:be9ec73af639 | 622 | P1 = (6<<24) | S7_P1, |
wim | 5:be9ec73af639 | 623 | P2 = (6<<24) | S7_P2, |
wim | 5:be9ec73af639 | 624 | P3 = (6<<24) | S7_P3, |
wim | 5:be9ec73af639 | 625 | P4 = (6<<24) | S7_P4, |
wim | 5:be9ec73af639 | 626 | P5 = (6<<24) | S7_P5, |
wim | 5:be9ec73af639 | 627 | P6 = (6<<24) | S7_P6, |
wim | 5:be9ec73af639 | 628 | P7 = (6<<24) | S7_P7, |
wim | 5:be9ec73af639 | 629 | P8 = (6<<24) | S7_P8, |
wim | 5:be9ec73af639 | 630 | P9 = (6<<24) | S7_P9, |
wim | 5:be9ec73af639 | 631 | P10 = (6<<24) | S7_P10, |
wim | 5:be9ec73af639 | 632 | P11 = (6<<24) | S7_P11, |
wim | 5:be9ec73af639 | 633 | P12 = (6<<24) | S7_P12, |
wim | 5:be9ec73af639 | 634 | P13 = (6<<24) | S7_P13, |
wim | 5:be9ec73af639 | 635 | |
wim | 5:be9ec73af639 | 636 | DVD = (6<<24) | S7_DVD |
wim | 5:be9ec73af639 | 637 | }; |
wim | 5:be9ec73af639 | 638 | |
wim | 5:be9ec73af639 | 639 | typedef char UDCData_t[C2233_NR_UDC]; |
wim | 5:be9ec73af639 | 640 | |
wim | 5:be9ec73af639 | 641 | /** Constructor for class for driving Princeton PT6312 VFD controller as used in C2233 |
wim | 5:be9ec73af639 | 642 | * |
wim | 5:be9ec73af639 | 643 | * @brief Supports 7 Digits of 7 Segments and Icons. Also supports a scanned keyboard of 7 keys. |
wim | 5:be9ec73af639 | 644 | * |
wim | 5:be9ec73af639 | 645 | * @param PinName mosi, miso, sclk, cs SPI bus pins |
wim | 5:be9ec73af639 | 646 | */ |
wim | 5:be9ec73af639 | 647 | PT6312_C2233(PinName mosi, PinName miso, PinName sclk, PinName cs); |
wim | 5:be9ec73af639 | 648 | |
wim | 5:be9ec73af639 | 649 | #if DOXYGEN_ONLY |
wim | 5:be9ec73af639 | 650 | /** Write a character to the Display |
wim | 5:be9ec73af639 | 651 | * |
wim | 5:be9ec73af639 | 652 | * @param c The character to write to the display |
wim | 5:be9ec73af639 | 653 | */ |
wim | 5:be9ec73af639 | 654 | int putc(int c); |
wim | 5:be9ec73af639 | 655 | |
wim | 5:be9ec73af639 | 656 | /** Write a formatted string to the Display |
wim | 5:be9ec73af639 | 657 | * |
wim | 5:be9ec73af639 | 658 | * @param format A printf-style format string, followed by the |
wim | 5:be9ec73af639 | 659 | * variables to use in formatting the string. |
wim | 5:be9ec73af639 | 660 | */ |
wim | 5:be9ec73af639 | 661 | int printf(const char* format, ...); |
wim | 5:be9ec73af639 | 662 | #endif |
wim | 5:be9ec73af639 | 663 | |
wim | 5:be9ec73af639 | 664 | /** Locate cursor to a screen column |
wim | 5:be9ec73af639 | 665 | * |
wim | 5:be9ec73af639 | 666 | * @param column The horizontal position from the left, indexed from 0 |
wim | 5:be9ec73af639 | 667 | */ |
wim | 5:be9ec73af639 | 668 | void locate(int column); |
wim | 5:be9ec73af639 | 669 | |
wim | 5:be9ec73af639 | 670 | /** Clear the screen and locate to 0 |
wim | 5:be9ec73af639 | 671 | * @param bool clrAll Clear Icons also (default = false) |
wim | 5:be9ec73af639 | 672 | */ |
wim | 5:be9ec73af639 | 673 | void cls(bool clrAll = false); |
wim | 5:be9ec73af639 | 674 | |
wim | 5:be9ec73af639 | 675 | /** Set Icon |
wim | 5:be9ec73af639 | 676 | * |
wim | 5:be9ec73af639 | 677 | * @param Icon icon Enums Icon has Grid position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs |
wim | 5:be9ec73af639 | 678 | * @return none |
wim | 5:be9ec73af639 | 679 | */ |
wim | 5:be9ec73af639 | 680 | void setIcon(Icon icon); |
wim | 5:be9ec73af639 | 681 | |
wim | 5:be9ec73af639 | 682 | /** Clr Icon |
wim | 5:be9ec73af639 | 683 | * |
wim | 5:be9ec73af639 | 684 | * @param Icon icon Enums Icon has Grid position encoded in 8 MSBs, Icon pattern encoded in 16 LSBs |
wim | 5:be9ec73af639 | 685 | * @return none |
wim | 5:be9ec73af639 | 686 | */ |
wim | 5:be9ec73af639 | 687 | void clrIcon(Icon icon); |
wim | 5:be9ec73af639 | 688 | |
wim | 5:be9ec73af639 | 689 | /** Set User Defined Characters (UDC) |
wim | 5:be9ec73af639 | 690 | * |
wim | 5:be9ec73af639 | 691 | * @param unsigned char udc_idx The Index of the UDC (0..7) |
wim | 5:be9ec73af639 | 692 | * @param int udc_data The bitpattern for the UDC (16 bits) |
wim | 5:be9ec73af639 | 693 | */ |
wim | 5:be9ec73af639 | 694 | void setUDC(unsigned char udc_idx, int udc_data); |
wim | 5:be9ec73af639 | 695 | |
wim | 5:be9ec73af639 | 696 | |
wim | 5:be9ec73af639 | 697 | /** Number of screen columns |
wim | 5:be9ec73af639 | 698 | * |
wim | 5:be9ec73af639 | 699 | * @param none |
wim | 5:be9ec73af639 | 700 | * @return columns |
wim | 5:be9ec73af639 | 701 | */ |
wim | 5:be9ec73af639 | 702 | int columns(); |
wim | 5:be9ec73af639 | 703 | |
wim | 5:be9ec73af639 | 704 | /** Write databyte to PT6312 |
wim | 5:be9ec73af639 | 705 | * @param int address display memory location to write byte |
wim | 5:be9ec73af639 | 706 | * @param char data byte written at given address |
wim | 5:be9ec73af639 | 707 | * @return none |
wim | 5:be9ec73af639 | 708 | */ |
wim | 5:be9ec73af639 | 709 | void writeData(int address, char data){ |
wim | 5:be9ec73af639 | 710 | PT6312::writeData(address, data); |
wim | 5:be9ec73af639 | 711 | } |
wim | 5:be9ec73af639 | 712 | |
wim | 5:be9ec73af639 | 713 | /** Write Display datablock to PT6312 |
wim | 5:be9ec73af639 | 714 | * @param DisplayData_t data Array of PT6312_DISPLAY_MEM (=22) bytes for displaydata (starting at address 0) |
wim | 5:be9ec73af639 | 715 | * @param length number bytes to write (valid range 0..(DVD462_NR_GRIDS*2) (=14), starting at address 0) |
wim | 5:be9ec73af639 | 716 | * @return none |
wim | 5:be9ec73af639 | 717 | */ |
wim | 5:be9ec73af639 | 718 | void writeData(DisplayData_t data, int length = (C2233_NR_GRIDS*2)) { |
wim | 5:be9ec73af639 | 719 | PT6312::writeData(data, length); |
wim | 5:be9ec73af639 | 720 | } |
wim | 5:be9ec73af639 | 721 | |
wim | 5:be9ec73af639 | 722 | protected: |
wim | 5:be9ec73af639 | 723 | // Stream implementation functions |
wim | 5:be9ec73af639 | 724 | virtual int _putc(int value); |
wim | 5:be9ec73af639 | 725 | virtual int _getc(); |
wim | 5:be9ec73af639 | 726 | |
wim | 5:be9ec73af639 | 727 | private: |
wim | 5:be9ec73af639 | 728 | int _column; // Current cursor location |
wim | 5:be9ec73af639 | 729 | int _columns; // Max number of columns |
wim | 5:be9ec73af639 | 730 | |
wim | 5:be9ec73af639 | 731 | DisplayData_t _displaybuffer; // Local mirror for all chars and icons |
wim | 5:be9ec73af639 | 732 | UDCData_t _UDC_7S; // User Defined Character pattterns (UDC) |
wim | 1:c5e247159aa6 | 733 | }; |
wim | 5:be9ec73af639 | 734 | #endif |
wim | 1:c5e247159aa6 | 735 | |
wim | 5:be9ec73af639 | 736 | #endif |