Library for the Princeton PT6312 Vacuum Fluorescent Display (VFD) driver.
This library is documented here.
PT6312.cpp@1:c5e247159aa6, 2015-08-25 (annotated)
- Committer:
- wim
- Date:
- Tue Aug 25 20:38:30 2015 +0000
- Revision:
- 1:c5e247159aa6
- Parent:
- 0:e59142cded2b
- Child:
- 2:f010b7022803
First lib version
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 | #include "mbed.h" |
wim | 0:e59142cded2b | 23 | #include "PT6312.h" |
wim | 1:c5e247159aa6 | 24 | #include "Font_16Seg.h" |
wim | 0:e59142cded2b | 25 | |
wim | 0:e59142cded2b | 26 | /** Constructor for class for driving Princeton PT6312 VFD controller |
wim | 0:e59142cded2b | 27 | * |
wim | 0:e59142cded2b | 28 | * @brief Supports 4 Digits of 16 Segments upto 10 Digits of 12 Segments. Also supports a scanned keyboard of upto 24 keys, 4 switches and 4 LEDs. |
wim | 0:e59142cded2b | 29 | * SPI bus interface device. |
wim | 0:e59142cded2b | 30 | * |
wim | 0:e59142cded2b | 31 | * @param PinName mosi, miso, sclk, cs SPI bus pins |
wim | 0:e59142cded2b | 32 | * @param Mode selects either number of Digits and Segments |
wim | 0:e59142cded2b | 33 | */ |
wim | 0:e59142cded2b | 34 | PT6312::PT6312(PinName mosi, PinName miso, PinName sclk, PinName cs, Mode mode) : _spi(mosi,miso,sclk), _cs(cs), _mode(mode) { |
wim | 0:e59142cded2b | 35 | |
wim | 0:e59142cded2b | 36 | _init(); |
wim | 0:e59142cded2b | 37 | } |
wim | 0:e59142cded2b | 38 | |
wim | 0:e59142cded2b | 39 | /** Init the SPI interface and the controller |
wim | 0:e59142cded2b | 40 | * @param none |
wim | 0:e59142cded2b | 41 | * @return none |
wim | 0:e59142cded2b | 42 | */ |
wim | 0:e59142cded2b | 43 | void PT6312::_init(){ |
wim | 0:e59142cded2b | 44 | |
wim | 0:e59142cded2b | 45 | //init SPI |
wim | 0:e59142cded2b | 46 | _cs=1; |
wim | 0:e59142cded2b | 47 | _spi.format(8,3); //PT6312 uses mode 3 (Clock High on Idle, Data latched on second (=rising) edge) |
wim | 1:c5e247159aa6 | 48 | // _spi.frequency(100000); |
wim | 1:c5e247159aa6 | 49 | _spi.frequency(500000); |
wim | 0:e59142cded2b | 50 | |
wim | 0:e59142cded2b | 51 | //init controller |
wim | 0:e59142cded2b | 52 | _writeCmd(PT6312_MODE_SET_CMD, _mode); // Mode set command |
wim | 0:e59142cded2b | 53 | |
wim | 0:e59142cded2b | 54 | _display = PT6312_DSP_ON; |
wim | 0:e59142cded2b | 55 | _bright = PT6312_BRT_DEF; |
wim | 0:e59142cded2b | 56 | _writeCmd(PT6312_DSP_CTRL_CMD, _display | _bright ); // Display control cmd, display on/off, brightness |
wim | 0:e59142cded2b | 57 | |
wim | 0:e59142cded2b | 58 | _writeCmd(PT6312_DATA_SET_CMD, PT6312_DATA_WR | PT6312_ADDR_INC | PT6312_MODE_NORM); // Data set cmd, normal mode, auto incr, write data |
wim | 0:e59142cded2b | 59 | } |
wim | 0:e59142cded2b | 60 | |
wim | 0:e59142cded2b | 61 | |
wim | 0:e59142cded2b | 62 | /** Clear the screen and locate to 0 |
wim | 0:e59142cded2b | 63 | */ |
wim | 0:e59142cded2b | 64 | void PT6312::cls() { |
wim | 0:e59142cded2b | 65 | |
wim | 0:e59142cded2b | 66 | _cs=0; |
wim | 0:e59142cded2b | 67 | wait_us(1); |
wim | 0:e59142cded2b | 68 | _spi.write(_flip(PT6312_ADDR_SET_CMD | 0x00)); // Address set cmd, 0 |
wim | 0:e59142cded2b | 69 | |
wim | 0:e59142cded2b | 70 | for (int cnt=0; cnt<PT6312_DISPLAY_MEM; cnt++) { |
wim | 0:e59142cded2b | 71 | _spi.write(0x00); // data |
wim | 0:e59142cded2b | 72 | } |
wim | 0:e59142cded2b | 73 | |
wim | 0:e59142cded2b | 74 | wait_us(1); |
wim | 0:e59142cded2b | 75 | _cs=1; |
wim | 0:e59142cded2b | 76 | |
wim | 0:e59142cded2b | 77 | } |
wim | 0:e59142cded2b | 78 | |
wim | 0:e59142cded2b | 79 | /** Set Brightness |
wim | 0:e59142cded2b | 80 | * |
wim | 0:e59142cded2b | 81 | * @param char brightness (3 significant bits, valid range 0..7 (1/16 .. 14/14 dutycycle) |
wim | 0:e59142cded2b | 82 | * @return none |
wim | 0:e59142cded2b | 83 | */ |
wim | 0:e59142cded2b | 84 | void PT6312::setBrightness(char brightness){ |
wim | 0:e59142cded2b | 85 | |
wim | 0:e59142cded2b | 86 | _bright = brightness & PT6312_BRT_MSK; // mask invalid bits |
wim | 0:e59142cded2b | 87 | |
wim | 0:e59142cded2b | 88 | _writeCmd(PT6312_DSP_CTRL_CMD, _display | _bright ); // Display control cmd, display on/off, brightness |
wim | 0:e59142cded2b | 89 | |
wim | 0:e59142cded2b | 90 | } |
wim | 0:e59142cded2b | 91 | |
wim | 0:e59142cded2b | 92 | /** Set the Display mode On/off |
wim | 0:e59142cded2b | 93 | * |
wim | 0:e59142cded2b | 94 | * @param bool display mode |
wim | 0:e59142cded2b | 95 | */ |
wim | 0:e59142cded2b | 96 | void PT6312::setDisplay(bool on) { |
wim | 0:e59142cded2b | 97 | |
wim | 0:e59142cded2b | 98 | if (on) { |
wim | 0:e59142cded2b | 99 | _display = PT6312_DSP_ON; |
wim | 0:e59142cded2b | 100 | } |
wim | 0:e59142cded2b | 101 | else { |
wim | 0:e59142cded2b | 102 | _display = PT6312_DSP_OFF; |
wim | 0:e59142cded2b | 103 | } |
wim | 0:e59142cded2b | 104 | |
wim | 0:e59142cded2b | 105 | _writeCmd(PT6312_DSP_CTRL_CMD, _display | _bright ); // Display control cmd, display on/off, brightness |
wim | 0:e59142cded2b | 106 | } |
wim | 0:e59142cded2b | 107 | |
wim | 0:e59142cded2b | 108 | /** Write databyte to PT6312 |
wim | 0:e59142cded2b | 109 | * @param int address display memory location to write byte |
wim | 0:e59142cded2b | 110 | * @param char data byte written at given address |
wim | 0:e59142cded2b | 111 | * @return none |
wim | 0:e59142cded2b | 112 | */ |
wim | 0:e59142cded2b | 113 | void PT6312::writeData(int address, char data) { |
wim | 0:e59142cded2b | 114 | _cs=0; |
wim | 0:e59142cded2b | 115 | wait_us(1); |
wim | 0:e59142cded2b | 116 | _spi.write(_flip(PT6312_ADDR_SET_CMD | (address & PT6312_ADDR_MSK))); // Set Address cmd |
wim | 0:e59142cded2b | 117 | |
wim | 0:e59142cded2b | 118 | _spi.write(_flip(data)); // data |
wim | 0:e59142cded2b | 119 | |
wim | 0:e59142cded2b | 120 | wait_us(1); |
wim | 0:e59142cded2b | 121 | _cs=1; |
wim | 0:e59142cded2b | 122 | |
wim | 0:e59142cded2b | 123 | } |
wim | 0:e59142cded2b | 124 | |
wim | 0:e59142cded2b | 125 | /** Write Display datablock to PT6312 |
wim | 0:e59142cded2b | 126 | * @param DisplayData_t data Array of PT6312_DISPLAY_MEM (=16) bytes for displaydata (starting at address 0) |
wim | 0:e59142cded2b | 127 | * @return none |
wim | 0:e59142cded2b | 128 | */ |
wim | 0:e59142cded2b | 129 | void PT6312::writeData(DisplayData_t data) { |
wim | 0:e59142cded2b | 130 | _cs=0; |
wim | 0:e59142cded2b | 131 | wait_us(1); |
wim | 0:e59142cded2b | 132 | _spi.write(_flip(PT6312_ADDR_SET_CMD | 0x00)); // Set Address at 0 |
wim | 0:e59142cded2b | 133 | |
wim | 0:e59142cded2b | 134 | for (int idx=0; idx<PT6312_DISPLAY_MEM; idx++) { |
wim | 0:e59142cded2b | 135 | _spi.write(_flip(data[idx])); // data |
wim | 0:e59142cded2b | 136 | } |
wim | 0:e59142cded2b | 137 | |
wim | 0:e59142cded2b | 138 | wait_us(1); |
wim | 0:e59142cded2b | 139 | _cs=1; |
wim | 0:e59142cded2b | 140 | |
wim | 0:e59142cded2b | 141 | } |
wim | 0:e59142cded2b | 142 | |
wim | 0:e59142cded2b | 143 | /** Read keydata block from PT6312 |
wim | 0:e59142cded2b | 144 | * @param *keydata Ptr to Array of PT6312_KEY_MEM (=3) bytes for keydata |
wim | 0:e59142cded2b | 145 | * @return bool keypress True when at least one key was pressed |
wim | 0:e59142cded2b | 146 | * |
wim | 0:e59142cded2b | 147 | * Note: Due to the hardware configuration the PT6312 key matrix scanner will detect multiple keys pressed at same time, |
wim | 0:e59142cded2b | 148 | * but this may also result in some spurious keys being set in keypress data array. |
wim | 0:e59142cded2b | 149 | * 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 | 150 | */ |
wim | 1:c5e247159aa6 | 151 | bool PT6312::getKeys(KeyData_t *keydata) { |
wim | 0:e59142cded2b | 152 | int keypress = 0; |
wim | 0:e59142cded2b | 153 | char data; |
wim | 0:e59142cded2b | 154 | |
wim | 0:e59142cded2b | 155 | // Read keys |
wim | 0:e59142cded2b | 156 | _cs=0; |
wim | 0:e59142cded2b | 157 | wait_us(1); |
wim | 0:e59142cded2b | 158 | |
wim | 0:e59142cded2b | 159 | // Enable Key Read mode |
wim | 0:e59142cded2b | 160 | _spi.write(_flip(PT6312_DATA_SET_CMD | PT6312_KEY_RD | PT6312_ADDR_INC | PT6312_MODE_NORM)); // Data set cmd, normal mode, auto incr, read data |
wim | 0:e59142cded2b | 161 | |
wim | 0:e59142cded2b | 162 | for (int idx=0; idx < PT6312_KEY_MEM; idx++) { |
wim | 0:e59142cded2b | 163 | data = _flip(_spi.write(0xFF)); // read keys and correct bitorder |
wim | 0:e59142cded2b | 164 | |
wim | 0:e59142cded2b | 165 | if (data != 0) { // Check for any pressed key |
wim | 0:e59142cded2b | 166 | for (int bit=0; bit < PT6312_KEY_BITS; bit++) { |
wim | 0:e59142cded2b | 167 | if (data & (1 << bit)) {keypress++;} // Test all significant bits |
wim | 0:e59142cded2b | 168 | } |
wim | 0:e59142cded2b | 169 | } |
wim | 0:e59142cded2b | 170 | |
wim | 0:e59142cded2b | 171 | (*keydata)[idx] = data; // Store keydata after correcting bitorder |
wim | 0:e59142cded2b | 172 | } |
wim | 0:e59142cded2b | 173 | |
wim | 0:e59142cded2b | 174 | wait_us(1); |
wim | 0:e59142cded2b | 175 | _cs=1; |
wim | 0:e59142cded2b | 176 | |
wim | 0:e59142cded2b | 177 | // Restore Data Write mode |
wim | 0:e59142cded2b | 178 | _writeCmd(PT6312_DATA_SET_CMD, PT6312_DATA_WR | PT6312_ADDR_INC | PT6312_MODE_NORM); // Data set cmd, normal mode, auto incr, write data |
wim | 0:e59142cded2b | 179 | |
wim | 0:e59142cded2b | 180 | #if(1) |
wim | 0:e59142cded2b | 181 | // Dismiss multiple keypresses at same time |
wim | 0:e59142cded2b | 182 | return (keypress == 1); |
wim | 0:e59142cded2b | 183 | #else |
wim | 0:e59142cded2b | 184 | // Allow multiple keypress and accept possible spurious keys |
wim | 0:e59142cded2b | 185 | return (keypress > 0); |
wim | 0:e59142cded2b | 186 | #endif |
wim | 0:e59142cded2b | 187 | } |
wim | 0:e59142cded2b | 188 | |
wim | 0:e59142cded2b | 189 | |
wim | 0:e59142cded2b | 190 | /** Read switches from PT6312 |
wim | 0:e59142cded2b | 191 | * |
wim | 0:e59142cded2b | 192 | * @param none |
wim | 0:e59142cded2b | 193 | * @return char for switch data (4 least significant bits) |
wim | 0:e59142cded2b | 194 | * |
wim | 0:e59142cded2b | 195 | */ |
wim | 1:c5e247159aa6 | 196 | char PT6312::getSwitches() { |
wim | 0:e59142cded2b | 197 | char data; |
wim | 0:e59142cded2b | 198 | |
wim | 0:e59142cded2b | 199 | // Read switches |
wim | 0:e59142cded2b | 200 | _cs=0; |
wim | 0:e59142cded2b | 201 | wait_us(1); |
wim | 0:e59142cded2b | 202 | |
wim | 0:e59142cded2b | 203 | // Enable Switch Read mode |
wim | 0:e59142cded2b | 204 | _spi.write(_flip(PT6312_DATA_SET_CMD | PT6312_SW_RD | PT6312_ADDR_INC | PT6312_MODE_NORM)); // Data set cmd, normal mode, auto incr, read data |
wim | 0:e59142cded2b | 205 | |
wim | 0:e59142cded2b | 206 | data = _flip(_spi.write(0xFF)) & PT6312_SW_MSK; // read switches and correct bitorder |
wim | 0:e59142cded2b | 207 | |
wim | 0:e59142cded2b | 208 | wait_us(1); |
wim | 0:e59142cded2b | 209 | _cs=1; |
wim | 0:e59142cded2b | 210 | |
wim | 0:e59142cded2b | 211 | // Restore Data Write mode |
wim | 0:e59142cded2b | 212 | _writeCmd(PT6312_DATA_SET_CMD, PT6312_DATA_WR | PT6312_ADDR_INC | PT6312_MODE_NORM); // Data set cmd, normal mode, auto incr, write data |
wim | 0:e59142cded2b | 213 | |
wim | 0:e59142cded2b | 214 | return data; |
wim | 0:e59142cded2b | 215 | } |
wim | 0:e59142cded2b | 216 | |
wim | 0:e59142cded2b | 217 | |
wim | 0:e59142cded2b | 218 | /** Set LEDs |
wim | 0:e59142cded2b | 219 | * |
wim | 0:e59142cded2b | 220 | * @param char leds (4 least significant bits) |
wim | 0:e59142cded2b | 221 | * @return none |
wim | 0:e59142cded2b | 222 | */ |
wim | 0:e59142cded2b | 223 | void PT6312::setLED (char leds) { |
wim | 0:e59142cded2b | 224 | |
wim | 0:e59142cded2b | 225 | // Set LEDs |
wim | 0:e59142cded2b | 226 | _cs=0; |
wim | 0:e59142cded2b | 227 | wait_us(1); |
wim | 0:e59142cded2b | 228 | |
wim | 0:e59142cded2b | 229 | // Enable LED Write mode |
wim | 0:e59142cded2b | 230 | _spi.write(_flip(PT6312_DATA_SET_CMD | PT6312_LED_WR | PT6312_ADDR_INC | PT6312_MODE_NORM)); // Data set cmd, normal mode, auto incr, write data |
wim | 0:e59142cded2b | 231 | |
wim | 0:e59142cded2b | 232 | _spi.write(_flip(leds & PT6312_LED_MSK)); // write LEDs in correct bitorder |
wim | 0:e59142cded2b | 233 | |
wim | 0:e59142cded2b | 234 | wait_us(1); |
wim | 0:e59142cded2b | 235 | _cs=1; |
wim | 0:e59142cded2b | 236 | |
wim | 0:e59142cded2b | 237 | // Restore Data Write mode |
wim | 0:e59142cded2b | 238 | _writeCmd(PT6312_DATA_SET_CMD, PT6312_DATA_WR | PT6312_ADDR_INC | PT6312_MODE_NORM); // Data set cmd, normal mode, auto incr, write data |
wim | 0:e59142cded2b | 239 | } |
wim | 0:e59142cded2b | 240 | |
wim | 0:e59142cded2b | 241 | |
wim | 0:e59142cded2b | 242 | |
wim | 0:e59142cded2b | 243 | /** Helper to reverse all command or databits. The PT6312 expects LSB first, whereas SPI is MSB first |
wim | 0:e59142cded2b | 244 | * @param char data |
wim | 0:e59142cded2b | 245 | * @return bitreversed data |
wim | 0:e59142cded2b | 246 | */ |
wim | 0:e59142cded2b | 247 | char PT6312::_flip(char data) { |
wim | 0:e59142cded2b | 248 | char value=0; |
wim | 0:e59142cded2b | 249 | |
wim | 0:e59142cded2b | 250 | if (data & 0x01) {value |= 0x80;} ; |
wim | 0:e59142cded2b | 251 | if (data & 0x02) {value |= 0x40;} ; |
wim | 0:e59142cded2b | 252 | if (data & 0x04) {value |= 0x20;} ; |
wim | 0:e59142cded2b | 253 | if (data & 0x08) {value |= 0x10;} ; |
wim | 0:e59142cded2b | 254 | if (data & 0x10) {value |= 0x08;} ; |
wim | 0:e59142cded2b | 255 | if (data & 0x20) {value |= 0x04;} ; |
wim | 0:e59142cded2b | 256 | if (data & 0x40) {value |= 0x02;} ; |
wim | 0:e59142cded2b | 257 | if (data & 0x80) {value |= 0x01;} ; |
wim | 0:e59142cded2b | 258 | return value; |
wim | 0:e59142cded2b | 259 | } |
wim | 0:e59142cded2b | 260 | |
wim | 0:e59142cded2b | 261 | |
wim | 0:e59142cded2b | 262 | /** Write command and parameter to PT6312 |
wim | 0:e59142cded2b | 263 | * @param int cmd Command byte |
wim | 0:e59142cded2b | 264 | * &Param int data Parameters for command |
wim | 0:e59142cded2b | 265 | * @return none |
wim | 0:e59142cded2b | 266 | */ |
wim | 0:e59142cded2b | 267 | void PT6312::_writeCmd(int cmd, int data){ |
wim | 0:e59142cded2b | 268 | |
wim | 0:e59142cded2b | 269 | _cs=0; |
wim | 0:e59142cded2b | 270 | wait_us(1); |
wim | 0:e59142cded2b | 271 | // _spi.write(_flip( (cmd & 0xF0) | (data & 0x0F))); |
wim | 0:e59142cded2b | 272 | _spi.write(_flip( (cmd & PT6312_CMD_MSK) | (data & ~PT6312_CMD_MSK))); |
wim | 0:e59142cded2b | 273 | |
wim | 0:e59142cded2b | 274 | wait_us(1); |
wim | 0:e59142cded2b | 275 | _cs=1; |
wim | 0:e59142cded2b | 276 | |
wim | 0:e59142cded2b | 277 | }; |
wim | 0:e59142cded2b | 278 | |
wim | 0:e59142cded2b | 279 | |
wim | 1:c5e247159aa6 | 280 | |
wim | 1:c5e247159aa6 | 281 | /** Constructor for class for driving Princeton PT6312 VFD controller as used in Philips DVD625 |
wim | 1:c5e247159aa6 | 282 | * |
wim | 1:c5e247159aa6 | 283 | * @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 | 1:c5e247159aa6 | 284 | * SPI bus interface device. |
wim | 1:c5e247159aa6 | 285 | * @param PinName mosi, miso, sclk, cs SPI bus pins |
wim | 1:c5e247159aa6 | 286 | */ |
wim | 1:c5e247159aa6 | 287 | PT6312_DVD625::PT6312_DVD625(PinName mosi, PinName miso, PinName sclk, PinName cs) : PT6312(mosi, miso, sclk, cs, Dig7_Seg15) { |
wim | 1:c5e247159aa6 | 288 | _column = 0; |
wim | 1:c5e247159aa6 | 289 | _columns = 7; |
wim | 1:c5e247159aa6 | 290 | } |
wim | 1:c5e247159aa6 | 291 | |
wim | 1:c5e247159aa6 | 292 | #if(0) |
wim | 1:c5e247159aa6 | 293 | #if DOXYGEN_ONLY |
wim | 1:c5e247159aa6 | 294 | /** Write a character to the LCD |
wim | 1:c5e247159aa6 | 295 | * |
wim | 1:c5e247159aa6 | 296 | * @param c The character to write to the display |
wim | 1:c5e247159aa6 | 297 | */ |
wim | 1:c5e247159aa6 | 298 | int putc(int c); |
wim | 1:c5e247159aa6 | 299 | |
wim | 1:c5e247159aa6 | 300 | /** Write a formatted string to the LCD |
wim | 1:c5e247159aa6 | 301 | * |
wim | 1:c5e247159aa6 | 302 | * @param format A printf-style format string, followed by the |
wim | 1:c5e247159aa6 | 303 | * variables to use in formatting the string. |
wim | 1:c5e247159aa6 | 304 | */ |
wim | 1:c5e247159aa6 | 305 | int printf(const char* format, ...); |
wim | 1:c5e247159aa6 | 306 | #endif |
wim | 1:c5e247159aa6 | 307 | #endif |
wim | 1:c5e247159aa6 | 308 | |
wim | 1:c5e247159aa6 | 309 | /** Locate cursor to a screen column |
wim | 1:c5e247159aa6 | 310 | * |
wim | 1:c5e247159aa6 | 311 | * @param column The horizontal position from the left, indexed from 0 |
wim | 1:c5e247159aa6 | 312 | */ |
wim | 1:c5e247159aa6 | 313 | void PT6312_DVD625::locate(int column) { |
wim | 1:c5e247159aa6 | 314 | } |
wim | 1:c5e247159aa6 | 315 | |
wim | 1:c5e247159aa6 | 316 | |
wim | 1:c5e247159aa6 | 317 | /** Number of screen columns |
wim | 1:c5e247159aa6 | 318 | * |
wim | 1:c5e247159aa6 | 319 | * @param none |
wim | 1:c5e247159aa6 | 320 | * @return columns |
wim | 1:c5e247159aa6 | 321 | */ |
wim | 1:c5e247159aa6 | 322 | int PT6312_DVD625::columns() { |
wim | 1:c5e247159aa6 | 323 | return _columns; |
wim | 1:c5e247159aa6 | 324 | } |
wim | 1:c5e247159aa6 | 325 | |
wim | 1:c5e247159aa6 | 326 | |
wim | 1:c5e247159aa6 | 327 | /** Clear the screen and locate to 0 |
wim | 1:c5e247159aa6 | 328 | */ |
wim | 1:c5e247159aa6 | 329 | void PT6312_DVD625::cls() { |
wim | 1:c5e247159aa6 | 330 | PT6312::cls(); |
wim | 1:c5e247159aa6 | 331 | } |
wim | 1:c5e247159aa6 | 332 | |
wim | 1:c5e247159aa6 | 333 | |
wim | 1:c5e247159aa6 | 334 | /** Write a single character (Stream implementation) |
wim | 1:c5e247159aa6 | 335 | */ |
wim | 1:c5e247159aa6 | 336 | int PT6312_DVD625::_putc(int value) { |
wim | 1:c5e247159aa6 | 337 | int addr; |
wim | 1:c5e247159aa6 | 338 | |
wim | 1:c5e247159aa6 | 339 | if (value == '\n') { |
wim | 1:c5e247159aa6 | 340 | //No character to write |
wim | 1:c5e247159aa6 | 341 | |
wim | 1:c5e247159aa6 | 342 | //Update Cursor |
wim | 1:c5e247159aa6 | 343 | _column = 0; |
wim | 1:c5e247159aa6 | 344 | } |
wim | 1:c5e247159aa6 | 345 | else { |
wim | 1:c5e247159aa6 | 346 | //Character to write |
wim | 1:c5e247159aa6 | 347 | value = value - 'A'; |
wim | 1:c5e247159aa6 | 348 | addr = ((_columns - 1) - _column) * 2; |
wim | 1:c5e247159aa6 | 349 | PT6312::writeData(addr, font_16A[value][0]); |
wim | 1:c5e247159aa6 | 350 | PT6312::writeData(addr + 1, font_16A[value][1]); |
wim | 1:c5e247159aa6 | 351 | |
wim | 1:c5e247159aa6 | 352 | //Update Cursor |
wim | 1:c5e247159aa6 | 353 | _column++; |
wim | 1:c5e247159aa6 | 354 | if (_column >= columns()) { |
wim | 1:c5e247159aa6 | 355 | _column = 0; |
wim | 1:c5e247159aa6 | 356 | } |
wim | 1:c5e247159aa6 | 357 | } //else |
wim | 1:c5e247159aa6 | 358 | |
wim | 1:c5e247159aa6 | 359 | // //Set next memoryaddress, make sure cursor blinks at next location |
wim | 1:c5e247159aa6 | 360 | // addr = getAddress(_column, _row); |
wim | 1:c5e247159aa6 | 361 | // _writeCommand(0x80 | addr); |
wim | 1:c5e247159aa6 | 362 | |
wim | 1:c5e247159aa6 | 363 | return value; |
wim | 1:c5e247159aa6 | 364 | } |
wim | 1:c5e247159aa6 | 365 | |
wim | 1:c5e247159aa6 | 366 | |
wim | 1:c5e247159aa6 | 367 | // get a single character (Stream implementation) |
wim | 1:c5e247159aa6 | 368 | int PT6312_DVD625::_getc() { |
wim | 1:c5e247159aa6 | 369 | return -1; |
wim | 1:c5e247159aa6 | 370 | } |