Library for the Princeton PT6312 Vacuum Fluorescent Display (VFD) driver.
This library is documented here.
PT6312.h@3:156c23d9652a, 2015-09-10 (annotated)
- Committer:
- wim
- Date:
- Thu Sep 10 18:40:51 2015 +0000
- Revision:
- 3:156c23d9652a
- Parent:
- 2:f010b7022803
- Child:
- 4:6ecb924fa0b5
First Release
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 | 0:e59142cded2b | 3 | * |
wim | 0:e59142cded2b | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
wim | 0:e59142cded2b | 5 | * of this software and associated documentation files (the "Software"), to deal |
wim | 0:e59142cded2b | 6 | * in the Software without restriction, including without limitation the rights |
wim | 0:e59142cded2b | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
wim | 0:e59142cded2b | 8 | * copies of the Software, and to permit persons to whom the Software is |
wim | 0:e59142cded2b | 9 | * furnished to do so, subject to the following conditions: |
wim | 0:e59142cded2b | 10 | * |
wim | 0:e59142cded2b | 11 | * The above copyright notice and this permission notice shall be included in |
wim | 0:e59142cded2b | 12 | * all copies or substantial portions of the Software. |
wim | 0:e59142cded2b | 13 | * |
wim | 0:e59142cded2b | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
wim | 0:e59142cded2b | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
wim | 0:e59142cded2b | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
wim | 0:e59142cded2b | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
wim | 0:e59142cded2b | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
wim | 0:e59142cded2b | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
wim | 0:e59142cded2b | 20 | * THE SOFTWARE. |
wim | 0:e59142cded2b | 21 | */ |
wim | 0:e59142cded2b | 22 | |
wim | 0:e59142cded2b | 23 | #ifndef PT6312_H |
wim | 0:e59142cded2b | 24 | #define PT6312_H |
wim | 0:e59142cded2b | 25 | |
wim | 3:156c23d9652a | 26 | #include "Font_16Seg.h" |
wim | 3:156c23d9652a | 27 | |
wim | 0:e59142cded2b | 28 | /** An interface for driving Princeton PT6312 VFD controller |
wim | 0:e59142cded2b | 29 | * |
wim | 0:e59142cded2b | 30 | * @code |
wim | 3:156c23d9652a | 31 | * |
wim | 3:156c23d9652a | 32 | * #if(1) |
wim | 3:156c23d9652a | 33 | * // Direct driving of PT6312 Test |
wim | 3:156c23d9652a | 34 | * |
wim | 0:e59142cded2b | 35 | * #include "mbed.h" |
wim | 3:156c23d9652a | 36 | * #include "PT6312.h" |
wim | 0:e59142cded2b | 37 | * |
wim | 0:e59142cded2b | 38 | * DisplayData_t size is 8 bytes (4 digits max 16 segments) ... 22 bytes (11 digits at max 11 segments) |
wim | 0:e59142cded2b | 39 | * DisplayData_t size default is 14 bytes (7 digits max 15 segments) |
wim | 0:e59142cded2b | 40 | * PT6312::DisplayData_t mbed_str = {0xDA,0x00, 0x7C,0x00, 0x3C,0x01, 0xF6,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:e59142cded2b | 41 | * PT6312::DisplayData_t all_str = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F}; |
wim | 0:e59142cded2b | 42 | * |
wim | 0:e59142cded2b | 43 | * // KeyData_t size is 3 bytes |
wim | 0:e59142cded2b | 44 | * PT6312::KeyData_t keydata; |
wim | 0:e59142cded2b | 45 | * |
wim | 0:e59142cded2b | 46 | * // PT6191 declaration, Default setting x Digits, y Segments |
wim | 0:e59142cded2b | 47 | * PT6312 PT6312(p5,p6,p7, p8); |
wim | 0:e59142cded2b | 48 | * |
wim | 0:e59142cded2b | 49 | * int main() { |
wim | 0:e59142cded2b | 50 | * PT6312.cls(); |
wim | 0:e59142cded2b | 51 | * PT6312.writeData(all_str); |
wim | 0:e59142cded2b | 52 | * wait(4); |
wim | 0:e59142cded2b | 53 | * PT6312.writeData(mbed_str); |
wim | 0:e59142cded2b | 54 | * wait(1); |
wim | 0:e59142cded2b | 55 | * PT6312.setBrightness(PT6312_BRT0); |
wim | 0:e59142cded2b | 56 | * wait(1); |
wim | 0:e59142cded2b | 57 | * PT6312.setBrightness(PT6312_BRT3); |
wim | 0:e59142cded2b | 58 | * |
wim | 0:e59142cded2b | 59 | * while (1) { |
wim | 0:e59142cded2b | 60 | * // Check and read keydata |
wim | 1:c5e247159aa6 | 61 | * if (PT6312.getKeys(&keydata)) { |
wim | 0:e59142cded2b | 62 | * pc.printf("Keydata 0..2 = 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2]); |
wim | 0:e59142cded2b | 63 | * |
wim | 0:e59142cded2b | 64 | * if (keydata[0] == 0x10) { //sw2 |
wim | 0:e59142cded2b | 65 | * PT6312.cls(); |
wim | 0:e59142cded2b | 66 | * PT6312.writeData(all_str); |
wim | 0:e59142cded2b | 67 | * } |
wim | 0:e59142cded2b | 68 | * } |
wim | 0:e59142cded2b | 69 | * } |
wim | 0:e59142cded2b | 70 | * } |
wim | 3:156c23d9652a | 71 | * |
wim | 3:156c23d9652a | 72 | * #else |
wim | 3:156c23d9652a | 73 | * |
wim | 3:156c23d9652a | 74 | * //Philips DVP630 Display Test |
wim | 3:156c23d9652a | 75 | * |
wim | 3:156c23d9652a | 76 | * #include "mbed.h" |
wim | 3:156c23d9652a | 77 | * #include "PT6312.h" |
wim | 3:156c23d9652a | 78 | * |
wim | 3:156c23d9652a | 79 | * // KeyData_t size is 3 bytes |
wim | 3:156c23d9652a | 80 | * PT6312::KeyData_t keydata; |
wim | 3:156c23d9652a | 81 | * |
wim | 3:156c23d9652a | 82 | * // PT6312_DVD declaration (7 Digits, 15 Segments) |
wim | 3:156c23d9652a | 83 | * PT6312_DVP630 DVP630(p5,p6,p7, p8); |
wim | 3:156c23d9652a | 84 | * |
wim | 3:156c23d9652a | 85 | * int main() { |
wim | 3:156c23d9652a | 86 | * |
wim | 3:156c23d9652a | 87 | * DVP630.cls(); |
wim | 3:156c23d9652a | 88 | * DVP630.setBrightness(PT6312_BRT7); |
wim | 3:156c23d9652a | 89 | * |
wim | 3:156c23d9652a | 90 | * //test to show all chars |
wim | 3:156c23d9652a | 91 | * |
wim | 3:156c23d9652a | 92 | * for (int i=0x20; i<0x80; i++) { |
wim | 3:156c23d9652a | 93 | * DVP630.cls(); |
wim | 3:156c23d9652a | 94 | * DVP630.printf("0x%2X=%c", i, (char) i); |
wim | 3:156c23d9652a | 95 | * wait(0.2); |
wim | 3:156c23d9652a | 96 | * // pc.getc(); |
wim | 3:156c23d9652a | 97 | * } |
wim | 3:156c23d9652a | 98 | * } |
wim | 3:156c23d9652a | 99 | * |
wim | 3:156c23d9652a | 100 | * #endif |
wim | 3:156c23d9652a | 101 | * |
wim | 0:e59142cded2b | 102 | * @endcode |
wim | 0:e59142cded2b | 103 | */ |
wim | 0:e59142cded2b | 104 | |
wim | 0:e59142cded2b | 105 | //Memory size in bytes for Display and Keymatrix |
wim | 0:e59142cded2b | 106 | #define PT6312_DISPLAY_MEM 22 |
wim | 0:e59142cded2b | 107 | #define PT6312_KEY_MEM 3 |
wim | 0:e59142cded2b | 108 | //Significant bits Keymatrix data |
wim | 0:e59142cded2b | 109 | #define PT6312_KEY_BITS 8 |
wim | 0:e59142cded2b | 110 | |
wim | 0:e59142cded2b | 111 | //Reserved bits for commands |
wim | 0:e59142cded2b | 112 | #define PT6312_CMD_MSK 0xE0 |
wim | 0:e59142cded2b | 113 | |
wim | 0:e59142cded2b | 114 | //Mode setting command |
wim | 0:e59142cded2b | 115 | #define PT6312_MODE_SET_CMD 0x00 |
wim | 0:e59142cded2b | 116 | #define PT6312_DIG4_SEG16 0x00 |
wim | 0:e59142cded2b | 117 | #define PT6312_DIG5_SEG16 0x01 |
wim | 0:e59142cded2b | 118 | #define PT6312_DIG6_SEG16 0x02 |
wim | 0:e59142cded2b | 119 | #define PT6312_DIG7_SEG15 0x03 //default |
wim | 0:e59142cded2b | 120 | #define PT6312_DIG8_SEG14 0x04 |
wim | 0:e59142cded2b | 121 | #define PT6312_DIG9_SEG13 0x05 |
wim | 0:e59142cded2b | 122 | #define PT6312_DIG10_SEG12 0x06 |
wim | 0:e59142cded2b | 123 | #define PT6312_DIG11_SEG11 0x07 |
wim | 0:e59142cded2b | 124 | |
wim | 0:e59142cded2b | 125 | |
wim | 0:e59142cded2b | 126 | //Data setting commands |
wim | 0:e59142cded2b | 127 | #define PT6312_DATA_SET_CMD 0x40 |
wim | 0:e59142cded2b | 128 | #define PT6312_DATA_WR 0x00 |
wim | 0:e59142cded2b | 129 | #define PT6312_LED_WR 0x01 |
wim | 0:e59142cded2b | 130 | #define PT6312_KEY_RD 0x02 |
wim | 0:e59142cded2b | 131 | #define PT6312_SW_RD 0x03 |
wim | 0:e59142cded2b | 132 | #define PT6312_ADDR_INC 0x00 |
wim | 0:e59142cded2b | 133 | #define PT6312_ADDR_FIXED 0x04 |
wim | 0:e59142cded2b | 134 | #define PT6312_MODE_NORM 0x00 |
wim | 0:e59142cded2b | 135 | #define PT6312_MODE_TEST 0x08 |
wim | 0:e59142cded2b | 136 | |
wim | 0:e59142cded2b | 137 | //LED settings data |
wim | 0:e59142cded2b | 138 | #define PT6312_LED_MSK 0x0F |
wim | 0:e59142cded2b | 139 | #define PT6312_LED1 0x01 |
wim | 0:e59142cded2b | 140 | #define PT6312_LED2 0x02 |
wim | 0:e59142cded2b | 141 | #define PT6312_LED3 0x04 |
wim | 0:e59142cded2b | 142 | #define PT6312_LED4 0x08 |
wim | 0:e59142cded2b | 143 | |
wim | 0:e59142cded2b | 144 | //Switch settings data |
wim | 0:e59142cded2b | 145 | #define PT6312_SW_MSK 0x0F |
wim | 0:e59142cded2b | 146 | #define PT6312_SW1 0x01 |
wim | 0:e59142cded2b | 147 | #define PT6312_SW2 0x02 |
wim | 0:e59142cded2b | 148 | #define PT6312_SW3 0x04 |
wim | 0:e59142cded2b | 149 | #define PT6312_SW4 0x08 |
wim | 0:e59142cded2b | 150 | |
wim | 0:e59142cded2b | 151 | //Address setting commands |
wim | 0:e59142cded2b | 152 | #define PT6312_ADDR_SET_CMD 0xC0 |
wim | 0:e59142cded2b | 153 | #define PT6312_ADDR_MSK 0x1F |
wim | 0:e59142cded2b | 154 | |
wim | 0:e59142cded2b | 155 | //Display control commands |
wim | 0:e59142cded2b | 156 | #define PT6312_DSP_CTRL_CMD 0x80 |
wim | 0:e59142cded2b | 157 | #define PT6312_BRT_MSK 0x07 |
wim | 0:e59142cded2b | 158 | #define PT6312_BRT0 0x00 //Pulsewidth 1/16 |
wim | 0:e59142cded2b | 159 | #define PT6312_BRT1 0x01 |
wim | 0:e59142cded2b | 160 | #define PT6312_BRT2 0x02 |
wim | 0:e59142cded2b | 161 | #define PT6312_BRT3 0x03 |
wim | 0:e59142cded2b | 162 | #define PT6312_BRT4 0x04 |
wim | 0:e59142cded2b | 163 | #define PT6312_BRT5 0x05 |
wim | 0:e59142cded2b | 164 | #define PT6312_BRT6 0x06 |
wim | 0:e59142cded2b | 165 | #define PT6312_BRT7 0x07 //Pulsewidth 14/16 |
wim | 0:e59142cded2b | 166 | |
wim | 0:e59142cded2b | 167 | #define PT6312_BRT_DEF PT6312_BRT3 |
wim | 0:e59142cded2b | 168 | |
wim | 0:e59142cded2b | 169 | #define PT6312_DSP_OFF 0x00 |
wim | 0:e59142cded2b | 170 | #define PT6312_DSP_ON 0x08 |
wim | 0:e59142cded2b | 171 | |
wim | 0:e59142cded2b | 172 | |
wim | 0:e59142cded2b | 173 | /** A class for driving Princeton PT6312 VFD controller |
wim | 0:e59142cded2b | 174 | * |
wim | 0:e59142cded2b | 175 | * @brief Supports 4 Digits of 16 Segments upto 11 Digits of 11 Segments. Also supports a scanned keyboard of upto 24 keys, 4 switches and 4 LEDs. |
wim | 0:e59142cded2b | 176 | * SPI bus interface device. |
wim | 0:e59142cded2b | 177 | */ |
wim | 0:e59142cded2b | 178 | class PT6312 { |
wim | 0:e59142cded2b | 179 | public: |
wim | 0:e59142cded2b | 180 | |
wim | 0:e59142cded2b | 181 | /** Enums for display mode */ |
wim | 0:e59142cded2b | 182 | enum Mode { |
wim | 0:e59142cded2b | 183 | Dig4_Seg16 = PT6312_DIG4_SEG16, |
wim | 0:e59142cded2b | 184 | Dig5_Seg16 = PT6312_DIG5_SEG16, |
wim | 0:e59142cded2b | 185 | Dig6_Seg16 = PT6312_DIG6_SEG16, |
wim | 0:e59142cded2b | 186 | Dig7_Seg15 = PT6312_DIG7_SEG15, |
wim | 0:e59142cded2b | 187 | Dig8_Seg14 = PT6312_DIG8_SEG14, |
wim | 0:e59142cded2b | 188 | Dig9_Seg13 = PT6312_DIG9_SEG13, |
wim | 0:e59142cded2b | 189 | Dig10_Seg12 = PT6312_DIG10_SEG12, |
wim | 0:e59142cded2b | 190 | Dig11_Seg11 = PT6312_DIG11_SEG11 |
wim | 0:e59142cded2b | 191 | }; |
wim | 0:e59142cded2b | 192 | |
wim | 0:e59142cded2b | 193 | /** Datatypes for display and keymatrix data */ |
wim | 0:e59142cded2b | 194 | typedef char DisplayData_t[PT6312_DISPLAY_MEM]; |
wim | 0:e59142cded2b | 195 | typedef char KeyData_t[PT6312_KEY_MEM]; |
wim | 0:e59142cded2b | 196 | |
wim | 1:c5e247159aa6 | 197 | /** Constructor for class for driving Princeton PT6312 VFD controller |
wim | 0:e59142cded2b | 198 | * |
wim | 0:e59142cded2b | 199 | * @brief Supports 4 Digits of 16 Segments upto 11 Digits of 11 Segments. Also supports a scanned keyboard of upto 24 keys, 4 switches and 4 LEDs. |
wim | 0:e59142cded2b | 200 | * SPI bus interface device. |
wim | 0:e59142cded2b | 201 | * @param PinName mosi, miso, sclk, cs SPI bus pins |
wim | 0:e59142cded2b | 202 | * @param Mode selects either number of Digits and 12 Segments (default 7 Digits, 15 Segments) |
wim | 0:e59142cded2b | 203 | */ |
wim | 0:e59142cded2b | 204 | PT6312(PinName mosi, PinName miso, PinName sclk, PinName cs, Mode mode=Dig7_Seg15); |
wim | 0:e59142cded2b | 205 | |
wim | 0:e59142cded2b | 206 | /** Clear the screen and locate to 0 |
wim | 0:e59142cded2b | 207 | */ |
wim | 0:e59142cded2b | 208 | void cls(); |
wim | 0:e59142cded2b | 209 | |
wim | 0:e59142cded2b | 210 | /** Write databyte to PT6312 |
wim | 0:e59142cded2b | 211 | * @param int address display memory location to write byte |
wim | 0:e59142cded2b | 212 | * @param char data byte written at given address |
wim | 0:e59142cded2b | 213 | * @return none |
wim | 0:e59142cded2b | 214 | */ |
wim | 0:e59142cded2b | 215 | void writeData(int address, char data); |
wim | 0:e59142cded2b | 216 | |
wim | 0:e59142cded2b | 217 | /** Write Display datablock to PT6312 |
wim | 3:156c23d9652a | 218 | * @param DisplayData_t data Array of PT6312_DISPLAY_MEM (=22) bytes for displaydata (starting at address 0) |
wim | 3:156c23d9652a | 219 | * @param length number bytes to write (valid range 0..PT6312_DISPLAY_MEM (=22), starting at address 0) |
wim | 0:e59142cded2b | 220 | * @return none |
wim | 0:e59142cded2b | 221 | */ |
wim | 2:f010b7022803 | 222 | void writeData(DisplayData_t data, int length = PT6312_DISPLAY_MEM); |
wim | 0:e59142cded2b | 223 | |
wim | 0:e59142cded2b | 224 | |
wim | 0:e59142cded2b | 225 | /** Read keydata block from PT6312 |
wim | 0:e59142cded2b | 226 | * @param *keydata Ptr to Array of PT6312_KEY_MEM (=3) bytes for keydata |
wim | 0:e59142cded2b | 227 | * @return bool keypress True when at least one key was pressed |
wim | 0:e59142cded2b | 228 | * |
wim | 0:e59142cded2b | 229 | * Note: Due to the hardware configuration the PT6312 key matrix scanner will detect multiple keys pressed at same time, |
wim | 0:e59142cded2b | 230 | * but this may result in some spurious keys also being set in keypress data array. |
wim | 0:e59142cded2b | 231 | * 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 | 232 | */ |
wim | 1:c5e247159aa6 | 233 | bool getKeys(KeyData_t *keydata); |
wim | 0:e59142cded2b | 234 | |
wim | 0:e59142cded2b | 235 | |
wim | 0:e59142cded2b | 236 | /** Read switches from PT6312 |
wim | 0:e59142cded2b | 237 | * |
wim | 0:e59142cded2b | 238 | * @param none |
wim | 0:e59142cded2b | 239 | * @return char for switch data (4 least significant bits) |
wim | 0:e59142cded2b | 240 | * |
wim | 0:e59142cded2b | 241 | */ |
wim | 1:c5e247159aa6 | 242 | char getSwitches(); |
wim | 0:e59142cded2b | 243 | |
wim | 0:e59142cded2b | 244 | /** Set LEDs |
wim | 0:e59142cded2b | 245 | * |
wim | 0:e59142cded2b | 246 | * @param char leds (4 least significant bits) |
wim | 0:e59142cded2b | 247 | * @return none |
wim | 0:e59142cded2b | 248 | */ |
wim | 0:e59142cded2b | 249 | void setLED (char leds = 0); |
wim | 0:e59142cded2b | 250 | |
wim | 0:e59142cded2b | 251 | /** Set Brightness |
wim | 0:e59142cded2b | 252 | * |
wim | 0:e59142cded2b | 253 | * @param char brightness (3 significant bits, valid range 0..7 (1/16 .. 14/14 dutycycle) |
wim | 0:e59142cded2b | 254 | * @return none |
wim | 0:e59142cded2b | 255 | */ |
wim | 0:e59142cded2b | 256 | void setBrightness(char brightness = PT6312_BRT_DEF); |
wim | 0:e59142cded2b | 257 | |
wim | 0:e59142cded2b | 258 | /** Set the Display mode On/off |
wim | 0:e59142cded2b | 259 | * |
wim | 0:e59142cded2b | 260 | * @param bool display mode |
wim | 0:e59142cded2b | 261 | */ |
wim | 0:e59142cded2b | 262 | void setDisplay(bool on); |
wim | 0:e59142cded2b | 263 | |
wim | 0:e59142cded2b | 264 | private: |
wim | 0:e59142cded2b | 265 | SPI _spi; |
wim | 0:e59142cded2b | 266 | DigitalOut _cs; |
wim | 0:e59142cded2b | 267 | Mode _mode; |
wim | 0:e59142cded2b | 268 | char _display; |
wim | 0:e59142cded2b | 269 | char _bright; |
wim | 0:e59142cded2b | 270 | |
wim | 0:e59142cded2b | 271 | /** Init the SPI interface and the controller |
wim | 0:e59142cded2b | 272 | * @param none |
wim | 0:e59142cded2b | 273 | * @return none |
wim | 0:e59142cded2b | 274 | */ |
wim | 0:e59142cded2b | 275 | void _init(); |
wim | 0:e59142cded2b | 276 | |
wim | 0:e59142cded2b | 277 | /** Helper to reverse all command or databits. The PT6312 expects LSB first, whereas SPI is MSB first |
wim | 0:e59142cded2b | 278 | * @param char data |
wim | 0:e59142cded2b | 279 | * @return bitreversed data |
wim | 0:e59142cded2b | 280 | */ |
wim | 0:e59142cded2b | 281 | char _flip(char data); |
wim | 0:e59142cded2b | 282 | |
wim | 0:e59142cded2b | 283 | /** Write command and parameter to PT6312 |
wim | 0:e59142cded2b | 284 | * @param int cmd Command byte |
wim | 0:e59142cded2b | 285 | * &Param int data Parameters for command |
wim | 0:e59142cded2b | 286 | * @return none |
wim | 0:e59142cded2b | 287 | */ |
wim | 0:e59142cded2b | 288 | void _writeCmd(int cmd, int data); |
wim | 0:e59142cded2b | 289 | }; |
wim | 0:e59142cded2b | 290 | |
wim | 1:c5e247159aa6 | 291 | |
wim | 3:156c23d9652a | 292 | // Derived class for PT6312 used in Philips DVP630 front display unit |
wim | 3:156c23d9652a | 293 | // |
wim | 1:c5e247159aa6 | 294 | |
wim | 2:f010b7022803 | 295 | #define DVP630_NR_DIGITS 7 |
wim | 3:156c23d9652a | 296 | #define DVP630_NR_UDC 8 |
wim | 2:f010b7022803 | 297 | |
wim | 2:f010b7022803 | 298 | /** Constructor for class for driving Princeton PT6312 VFD controller as used in Philips DVP630 |
wim | 1:c5e247159aa6 | 299 | * |
wim | 3:156c23d9652a | 300 | * @brief Supports 7 Digits of 15 Segments. Also supports a scanned keyboard of 3 keys, 3 switches and 1 LED. |
wim | 3:156c23d9652a | 301 | * |
wim | 1:c5e247159aa6 | 302 | * @param PinName mosi, miso, sclk, cs SPI bus pins |
wim | 1:c5e247159aa6 | 303 | */ |
wim | 2:f010b7022803 | 304 | class PT6312_DVP630 : public PT6312, public Stream { |
wim | 1:c5e247159aa6 | 305 | public: |
wim | 1:c5e247159aa6 | 306 | |
wim | 3:156c23d9652a | 307 | /** Enums for Icons */ |
wim | 3:156c23d9652a | 308 | // Digit encoded in 16 MSBs, Icon pattern encoded in 16 LSBs |
wim | 3:156c23d9652a | 309 | enum Icon { |
wim | 3:156c23d9652a | 310 | Dig2_Col = (2<<16) | S_COL, |
wim | 3:156c23d9652a | 311 | Dig4_Col = (4<<16) | S_COL |
wim | 3:156c23d9652a | 312 | }; |
wim | 3:156c23d9652a | 313 | |
wim | 3:156c23d9652a | 314 | typedef char UDCData_t[DVP630_NR_UDC][2]; |
wim | 3:156c23d9652a | 315 | |
wim | 2:f010b7022803 | 316 | /** Constructor for class for driving Princeton PT6312 VFD controller as used in Philips DVP630 |
wim | 1:c5e247159aa6 | 317 | * |
wim | 1:c5e247159aa6 | 318 | * @brief Supports 7 Digits of 15 Segments. Also supports a scanned keyboard of 3 keys, 3 switches and 1 LED. |
wim | 3:156c23d9652a | 319 | * |
wim | 1:c5e247159aa6 | 320 | * @param PinName mosi, miso, sclk, cs SPI bus pins |
wim | 1:c5e247159aa6 | 321 | */ |
wim | 2:f010b7022803 | 322 | PT6312_DVP630(PinName mosi, PinName miso, PinName sclk, PinName cs); |
wim | 1:c5e247159aa6 | 323 | |
wim | 1:c5e247159aa6 | 324 | #if DOXYGEN_ONLY |
wim | 1:c5e247159aa6 | 325 | /** Write a character to the LCD |
wim | 1:c5e247159aa6 | 326 | * |
wim | 1:c5e247159aa6 | 327 | * @param c The character to write to the display |
wim | 1:c5e247159aa6 | 328 | */ |
wim | 1:c5e247159aa6 | 329 | int putc(int c); |
wim | 1:c5e247159aa6 | 330 | |
wim | 1:c5e247159aa6 | 331 | /** Write a formatted string to the LCD |
wim | 1:c5e247159aa6 | 332 | * |
wim | 1:c5e247159aa6 | 333 | * @param format A printf-style format string, followed by the |
wim | 1:c5e247159aa6 | 334 | * variables to use in formatting the string. |
wim | 1:c5e247159aa6 | 335 | */ |
wim | 1:c5e247159aa6 | 336 | int printf(const char* format, ...); |
wim | 1:c5e247159aa6 | 337 | #endif |
wim | 1:c5e247159aa6 | 338 | |
wim | 1:c5e247159aa6 | 339 | /** Locate cursor to a screen column |
wim | 1:c5e247159aa6 | 340 | * |
wim | 1:c5e247159aa6 | 341 | * @param column The horizontal position from the left, indexed from 0 |
wim | 1:c5e247159aa6 | 342 | */ |
wim | 1:c5e247159aa6 | 343 | void locate(int column); |
wim | 1:c5e247159aa6 | 344 | |
wim | 1:c5e247159aa6 | 345 | /** Clear the screen and locate to 0 |
wim | 1:c5e247159aa6 | 346 | */ |
wim | 1:c5e247159aa6 | 347 | void cls(); |
wim | 1:c5e247159aa6 | 348 | |
wim | 3:156c23d9652a | 349 | /** Set Icon |
wim | 3:156c23d9652a | 350 | * |
wim | 3:156c23d9652a | 351 | * @param Icon icon Enums Icon has Digit position encoded in 16 MSBs, Icon pattern encoded in 16 LSBs |
wim | 3:156c23d9652a | 352 | * @return none |
wim | 3:156c23d9652a | 353 | */ |
wim | 3:156c23d9652a | 354 | void setIcon(Icon icon); |
wim | 3:156c23d9652a | 355 | |
wim | 3:156c23d9652a | 356 | /** Clr Icon |
wim | 3:156c23d9652a | 357 | * |
wim | 3:156c23d9652a | 358 | * @param Icon icon Enums Icon has Digit position encoded in 16 MSBs, Icon pattern encoded in 16 LSBs |
wim | 3:156c23d9652a | 359 | * @return none |
wim | 3:156c23d9652a | 360 | */ |
wim | 3:156c23d9652a | 361 | void clrIcon(Icon icon); |
wim | 3:156c23d9652a | 362 | |
wim | 3:156c23d9652a | 363 | /** Set User Defined Characters (UDC) |
wim | 3:156c23d9652a | 364 | * |
wim | 3:156c23d9652a | 365 | * @param unsigned char udc_idx The Index of the UDC (0..7) |
wim | 3:156c23d9652a | 366 | * @param int udc_data The bitpattern for the UDC (16 bits) |
wim | 3:156c23d9652a | 367 | */ |
wim | 3:156c23d9652a | 368 | void setUDC(unsigned char udc_idx, int udc_data); |
wim | 3:156c23d9652a | 369 | |
wim | 3:156c23d9652a | 370 | |
wim | 1:c5e247159aa6 | 371 | /** Number of screen columns |
wim | 1:c5e247159aa6 | 372 | * |
wim | 1:c5e247159aa6 | 373 | * @param none |
wim | 1:c5e247159aa6 | 374 | * @return columns |
wim | 1:c5e247159aa6 | 375 | */ |
wim | 1:c5e247159aa6 | 376 | int columns(); |
wim | 1:c5e247159aa6 | 377 | |
wim | 3:156c23d9652a | 378 | /** Write Display datablock to PT6312 |
wim | 3:156c23d9652a | 379 | * @param DisplayData_t data Array of PT6312_DISPLAY_MEM (=22) bytes for displaydata (starting at address 0) |
wim | 3:156c23d9652a | 380 | * @param length number bytes to write (valid range 0..(DVP630_NR_DIGITS*2) (=14), starting at address 0) |
wim | 3:156c23d9652a | 381 | * @return none |
wim | 3:156c23d9652a | 382 | */ |
wim | 3:156c23d9652a | 383 | void writeData(DisplayData_t data, int length = (DVP630_NR_DIGITS*2)) { |
wim | 3:156c23d9652a | 384 | PT6312::writeData(data, length); |
wim | 3:156c23d9652a | 385 | } |
wim | 2:f010b7022803 | 386 | |
wim | 1:c5e247159aa6 | 387 | protected: |
wim | 1:c5e247159aa6 | 388 | // Stream implementation functions |
wim | 1:c5e247159aa6 | 389 | virtual int _putc(int value); |
wim | 1:c5e247159aa6 | 390 | virtual int _getc(); |
wim | 1:c5e247159aa6 | 391 | |
wim | 1:c5e247159aa6 | 392 | private: |
wim | 1:c5e247159aa6 | 393 | int _column; |
wim | 2:f010b7022803 | 394 | int _columns; |
wim | 2:f010b7022803 | 395 | |
wim | 2:f010b7022803 | 396 | DisplayData_t _displaybuffer; |
wim | 3:156c23d9652a | 397 | UDCData_t _UDC_16S; |
wim | 1:c5e247159aa6 | 398 | }; |
wim | 1:c5e247159aa6 | 399 | |
wim | 0:e59142cded2b | 400 | #endif |