Example code for the PT6312 VFD driver. Also supports the PT6312 in ASCII mode as used in the Philips DVP630 DVD player.
main.cpp@5:d1242b251ca4, 2016-01-20 (annotated)
- Committer:
- wim
- Date:
- Wed Jan 20 18:51:05 2016 +0000
- Revision:
- 5:d1242b251ca4
- Parent:
- 4:ee70d1077e54
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:1d4ba8a2baa0 | 1 | /* mbed PT6312 Test program, for Princeton PT6312 VFD controller |
wim | 0:1d4ba8a2baa0 | 2 | * Copyright (c) 2015, v01: WH, Initial version |
wim | 4:ee70d1077e54 | 3 | * 2015, v02: WH, Test DVD462 and C2233 |
wim | 0:1d4ba8a2baa0 | 4 | * |
wim | 0:1d4ba8a2baa0 | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
wim | 0:1d4ba8a2baa0 | 6 | * of this software and associated documentation files (the "Software"), to deal |
wim | 0:1d4ba8a2baa0 | 7 | * in the Software without restriction, including without limitation the rights |
wim | 0:1d4ba8a2baa0 | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
wim | 0:1d4ba8a2baa0 | 9 | * copies of the Software, and to permit persons to whom the Software is |
wim | 0:1d4ba8a2baa0 | 10 | * furnished to do so, subject to the following conditions: |
wim | 0:1d4ba8a2baa0 | 11 | * |
wim | 0:1d4ba8a2baa0 | 12 | * The above copyright notice and this permission notice shall be included in |
wim | 0:1d4ba8a2baa0 | 13 | * all copies or substantial portions of the Software. |
wim | 0:1d4ba8a2baa0 | 14 | * |
wim | 0:1d4ba8a2baa0 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
wim | 0:1d4ba8a2baa0 | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
wim | 0:1d4ba8a2baa0 | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
wim | 0:1d4ba8a2baa0 | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
wim | 0:1d4ba8a2baa0 | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
wim | 0:1d4ba8a2baa0 | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
wim | 0:1d4ba8a2baa0 | 21 | * THE SOFTWARE. |
wim | 0:1d4ba8a2baa0 | 22 | */ |
wim | 0:1d4ba8a2baa0 | 23 | #include "mbed.h" |
wim | 0:1d4ba8a2baa0 | 24 | #include "PT6312.h" |
wim | 0:1d4ba8a2baa0 | 25 | |
wim | 4:ee70d1077e54 | 26 | |
wim | 4:ee70d1077e54 | 27 | #if (DVP630_TEST == 1) |
wim | 4:ee70d1077e54 | 28 | // Philips DVP630 Display Test |
wim | 4:ee70d1077e54 | 29 | |
wim | 0:1d4ba8a2baa0 | 30 | Serial pc(USBTX, USBRX); |
wim | 0:1d4ba8a2baa0 | 31 | DigitalOut myled(LED1); |
wim | 0:1d4ba8a2baa0 | 32 | |
wim | 0:1d4ba8a2baa0 | 33 | // KeyData_t size is 3 bytes |
wim | 0:1d4ba8a2baa0 | 34 | PT6312::KeyData_t keydata; |
wim | 0:1d4ba8a2baa0 | 35 | |
wim | 0:1d4ba8a2baa0 | 36 | // Switchdata is 1 byte |
wim | 0:1d4ba8a2baa0 | 37 | char switchdata; |
wim | 0:1d4ba8a2baa0 | 38 | |
wim | 4:ee70d1077e54 | 39 | // PT6312_DVP630 declaration. Setting 7 Grids @ 15 Segments) |
wim | 1:0484256914b0 | 40 | PT6312_DVP630 DVP630(p5,p6,p7, p8); |
wim | 0:1d4ba8a2baa0 | 41 | |
wim | 0:1d4ba8a2baa0 | 42 | int main() { |
wim | 0:1d4ba8a2baa0 | 43 | |
wim | 0:1d4ba8a2baa0 | 44 | pc.printf("Hello World\r\n"); // |
wim | 0:1d4ba8a2baa0 | 45 | |
wim | 1:0484256914b0 | 46 | DVP630.cls(); |
wim | 2:0dd4c697fc31 | 47 | // DVP630.putc('A'); |
wim | 2:0dd4c697fc31 | 48 | // wait(1); |
wim | 2:0dd4c697fc31 | 49 | |
wim | 2:0dd4c697fc31 | 50 | DVP630.setUDC(0, UDC_SANDHR); //Set UDC |
wim | 2:0dd4c697fc31 | 51 | DVP630.putc((char) 0); |
wim | 2:0dd4c697fc31 | 52 | wait(1); |
wim | 2:0dd4c697fc31 | 53 | |
wim | 2:0dd4c697fc31 | 54 | DVP630.setBrightness(PT6312_BRT7); |
wim | 1:0484256914b0 | 55 | wait(1); |
wim | 2:0dd4c697fc31 | 56 | |
wim | 2:0dd4c697fc31 | 57 | //wheel |
wim | 2:0dd4c697fc31 | 58 | for(int cnt=0;cnt<10;cnt++) { |
wim | 2:0dd4c697fc31 | 59 | for(int idx=0;idx<8;idx++) { |
wim | 2:0dd4c697fc31 | 60 | DVP630.setUDC(0, WHEEL_ANI[idx]); |
wim | 2:0dd4c697fc31 | 61 | DVP630.locate(0); |
wim | 2:0dd4c697fc31 | 62 | DVP630.printf("%c%c%c%c%c%c%c",(char)0,(char)0,(char)0,(char)0,(char)0,(char)0,(char)0); |
wim | 2:0dd4c697fc31 | 63 | |
wim | 2:0dd4c697fc31 | 64 | wait(0.1); |
wim | 2:0dd4c697fc31 | 65 | } |
wim | 2:0dd4c697fc31 | 66 | } |
wim | 2:0dd4c697fc31 | 67 | |
wim | 2:0dd4c697fc31 | 68 | |
wim | 0:1d4ba8a2baa0 | 69 | //test to show all chars |
wim | 0:1d4ba8a2baa0 | 70 | wait(1); |
wim | 1:0484256914b0 | 71 | DVP630.cls(); |
wim | 0:1d4ba8a2baa0 | 72 | |
wim | 1:0484256914b0 | 73 | for (int i=0x20; i<0x80; i++) { |
wim | 2:0dd4c697fc31 | 74 | // DVP630.cls(); |
wim | 2:0dd4c697fc31 | 75 | DVP630.locate(0); |
wim | 2:0dd4c697fc31 | 76 | DVP630.printf("0x%2X=%c ", i, (char) i); |
wim | 2:0dd4c697fc31 | 77 | wait(0.2); |
wim | 2:0dd4c697fc31 | 78 | // pc.getc(); |
wim | 0:1d4ba8a2baa0 | 79 | } |
wim | 1:0484256914b0 | 80 | |
wim | 1:0484256914b0 | 81 | while (1) { |
wim | 1:0484256914b0 | 82 | |
wim | 1:0484256914b0 | 83 | // Check and read keydata |
wim | 1:0484256914b0 | 84 | if (DVP630.getKeys(&keydata)) { |
wim | 1:0484256914b0 | 85 | pc.printf("Keydata 0..2 = 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2]); |
wim | 1:0484256914b0 | 86 | |
wim | 1:0484256914b0 | 87 | if (keydata[0] == 0x01) { //play |
wim | 1:0484256914b0 | 88 | DVP630.cls(); |
wim | 1:0484256914b0 | 89 | DVP630.printf("AAAAAAA"); |
wim | 4:ee70d1077e54 | 90 | DVP630.setIcon(PT6312_DVP630::COL3); |
wim | 4:ee70d1077e54 | 91 | DVP630.setIcon(PT6312_DVP630::COL5); |
wim | 1:0484256914b0 | 92 | } |
wim | 1:0484256914b0 | 93 | |
wim | 1:0484256914b0 | 94 | if (keydata[0] == 0x02) { //stop |
wim | 1:0484256914b0 | 95 | DVP630.cls(); |
wim | 1:0484256914b0 | 96 | DVP630.printf("HELLO "); |
wim | 4:ee70d1077e54 | 97 | DVP630.clrIcon(PT6312_DVP630::COL3); |
wim | 4:ee70d1077e54 | 98 | DVP630.clrIcon(PT6312_DVP630::COL5); |
wim | 1:0484256914b0 | 99 | } |
wim | 1:0484256914b0 | 100 | |
wim | 1:0484256914b0 | 101 | if (keydata[0] == 0x04) { //open/close |
wim | 1:0484256914b0 | 102 | DVP630.cls(); |
wim | 1:0484256914b0 | 103 | DVP630.printf("MBED "); |
wim | 1:0484256914b0 | 104 | } |
wim | 1:0484256914b0 | 105 | |
wim | 1:0484256914b0 | 106 | } //if Key |
wim | 1:0484256914b0 | 107 | |
wim | 1:0484256914b0 | 108 | |
wim | 1:0484256914b0 | 109 | // Check and read switch data |
wim | 1:0484256914b0 | 110 | switchdata = DVP630.getSwitches(); |
wim | 1:0484256914b0 | 111 | |
wim | 1:0484256914b0 | 112 | if (switchdata != 0) { |
wim | 1:0484256914b0 | 113 | pc.printf("Switchdata = 0x%02x\r\n", switchdata); |
wim | 1:0484256914b0 | 114 | |
wim | 1:0484256914b0 | 115 | if (switchdata == PT6312_SW1) { //S1 |
wim | 1:0484256914b0 | 116 | DVP630.cls(); |
wim | 1:0484256914b0 | 117 | DVP630.printf(" HELLO "); |
wim | 1:0484256914b0 | 118 | } |
wim | 1:0484256914b0 | 119 | |
wim | 1:0484256914b0 | 120 | if (switchdata == PT6312_SW2) { //S2 |
wim | 1:0484256914b0 | 121 | DVP630.cls(); |
wim | 1:0484256914b0 | 122 | DVP630.printf("BYE "); |
wim | 1:0484256914b0 | 123 | } |
wim | 1:0484256914b0 | 124 | |
wim | 1:0484256914b0 | 125 | if (switchdata == PT6312_SW3) { //S3 |
wim | 1:0484256914b0 | 126 | DVP630.cls(); |
wim | 1:0484256914b0 | 127 | DVP630.printf("HI MBED"); |
wim | 1:0484256914b0 | 128 | } |
wim | 1:0484256914b0 | 129 | |
wim | 1:0484256914b0 | 130 | DVP630.setLED(switchdata); //write LEDs in same pattern |
wim | 1:0484256914b0 | 131 | } //if Switch |
wim | 1:0484256914b0 | 132 | |
wim | 1:0484256914b0 | 133 | myled = !myled; |
wim | 1:0484256914b0 | 134 | wait(0.3); |
wim | 1:0484256914b0 | 135 | } //while |
wim | 0:1d4ba8a2baa0 | 136 | |
wim | 0:1d4ba8a2baa0 | 137 | } |
wim | 4:ee70d1077e54 | 138 | #endif |
wim | 4:ee70d1077e54 | 139 | |
wim | 4:ee70d1077e54 | 140 | |
wim | 4:ee70d1077e54 | 141 | #if (DVD462_TEST == 1) |
wim | 4:ee70d1077e54 | 142 | // DVD462 PT6312 Test |
wim | 0:1d4ba8a2baa0 | 143 | #include "mbed.h" |
wim | 0:1d4ba8a2baa0 | 144 | #include "PT6312.h" |
wim | 4:ee70d1077e54 | 145 | #include "Font_7Seg.h" |
wim | 0:1d4ba8a2baa0 | 146 | |
wim | 0:1d4ba8a2baa0 | 147 | Serial pc(USBTX, USBRX); |
wim | 0:1d4ba8a2baa0 | 148 | DigitalOut myled(LED1); |
wim | 0:1d4ba8a2baa0 | 149 | |
wim | 4:ee70d1077e54 | 150 | // DisplayData_t size is 8 bytes (4 digits @ max 16 segments) ... 22 bytes (11 digits @ max 11 segments) |
wim | 4:ee70d1077e54 | 151 | // DisplayData_t size default is 22 bytes (11 digits @ max 11 segments) |
wim | 4:ee70d1077e54 | 152 | PT6312::DisplayData_t all_str = {0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF}; |
wim | 4:ee70d1077e54 | 153 | PT6312::DisplayData_t bye_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, LO(C7_E),HI(C7_E), LO(C7_Y),HI(C7_Y), LO(C7_B),HI(C7_B)}; |
wim | 4:ee70d1077e54 | 154 | PT6312::DisplayData_t hello_str = {0x00,0x00, 0x00,0x00, LO(C7_O),HI(C7_O), LO(C7_L),HI(C7_L), LO(C7_L),HI(C7_L), LO(C7_E),HI(C7_E), LO(C7_H), HI(C7_H)}; |
wim | 4:ee70d1077e54 | 155 | PT6312::DisplayData_t mbed_str = {LO(C7_D), HI(C7_D), LO(C7_E), HI(C7_E), LO(C7_B), HI(C7_B), LO(C7_M), HI(C7_M)}; |
wim | 0:1d4ba8a2baa0 | 156 | |
wim | 0:1d4ba8a2baa0 | 157 | // KeyData_t size is 3 bytes |
wim | 0:1d4ba8a2baa0 | 158 | PT6312::KeyData_t keydata; |
wim | 0:1d4ba8a2baa0 | 159 | |
wim | 0:1d4ba8a2baa0 | 160 | // Switchdata is 1 byte |
wim | 0:1d4ba8a2baa0 | 161 | char switchdata; |
wim | 0:1d4ba8a2baa0 | 162 | |
wim | 4:ee70d1077e54 | 163 | //PT6312_DVD462 declaration, Setting 6 Grids @ 16 Segments |
wim | 4:ee70d1077e54 | 164 | PT6312_DVD462 DVD462(p5,p6,p7, p8); |
wim | 4:ee70d1077e54 | 165 | |
wim | 4:ee70d1077e54 | 166 | char cmd, bits; |
wim | 4:ee70d1077e54 | 167 | int main() { |
wim | 4:ee70d1077e54 | 168 | |
wim | 4:ee70d1077e54 | 169 | pc.printf("Hello World\r\n"); // |
wim | 4:ee70d1077e54 | 170 | |
wim | 4:ee70d1077e54 | 171 | DVD462.cls(); |
wim | 4:ee70d1077e54 | 172 | DVD462.writeData(all_str); |
wim | 4:ee70d1077e54 | 173 | wait(4); |
wim | 4:ee70d1077e54 | 174 | DVD462.setBrightness(PT6312_BRT3); |
wim | 4:ee70d1077e54 | 175 | wait(1); |
wim | 4:ee70d1077e54 | 176 | DVD462.setBrightness(PT6312_BRT0); |
wim | 4:ee70d1077e54 | 177 | wait(1); |
wim | 4:ee70d1077e54 | 178 | DVD462.setBrightness(PT6312_BRT7); |
wim | 4:ee70d1077e54 | 179 | |
wim | 4:ee70d1077e54 | 180 | while (1) { |
wim | 4:ee70d1077e54 | 181 | |
wim | 4:ee70d1077e54 | 182 | // Check and read keydata |
wim | 4:ee70d1077e54 | 183 | if (DVD462.getKeys(&keydata)) { |
wim | 4:ee70d1077e54 | 184 | pc.printf("Keydata 0..2 = 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2]); |
wim | 4:ee70d1077e54 | 185 | |
wim | 4:ee70d1077e54 | 186 | if (keydata[0] == 0x01) { //play |
wim | 4:ee70d1077e54 | 187 | DVD462.cls(); |
wim | 4:ee70d1077e54 | 188 | DVD462.writeData(all_str); |
wim | 4:ee70d1077e54 | 189 | } |
wim | 4:ee70d1077e54 | 190 | |
wim | 4:ee70d1077e54 | 191 | if (keydata[0] == 0x02) { //pause |
wim | 4:ee70d1077e54 | 192 | DVD462.cls(); |
wim | 4:ee70d1077e54 | 193 | // DVD462.writeData(hello_str); |
wim | 4:ee70d1077e54 | 194 | #if(1) |
wim | 4:ee70d1077e54 | 195 | //test to show all segs |
wim | 4:ee70d1077e54 | 196 | pc.printf("Show all segs\r\n"); |
wim | 4:ee70d1077e54 | 197 | wait(1); |
wim | 4:ee70d1077e54 | 198 | DVD462.cls(); |
wim | 4:ee70d1077e54 | 199 | |
wim | 4:ee70d1077e54 | 200 | for (int i=0; i<PT6312_DISPLAY_MEM; i++) { |
wim | 4:ee70d1077e54 | 201 | for (int bit=0; bit<8; bit++) { |
wim | 4:ee70d1077e54 | 202 | DVD462.cls(); |
wim | 4:ee70d1077e54 | 203 | |
wim | 4:ee70d1077e54 | 204 | bits = 0x01 << bit; |
wim | 4:ee70d1077e54 | 205 | DVD462.writeData(i, bits); |
wim | 4:ee70d1077e54 | 206 | |
wim | 4:ee70d1077e54 | 207 | pc.printf("Idx = %d, Bits = 0x%02x\r\n", i, bits); |
wim | 4:ee70d1077e54 | 208 | // wait(0.5); |
wim | 4:ee70d1077e54 | 209 | cmd = pc.getc(); // wait for key |
wim | 4:ee70d1077e54 | 210 | } |
wim | 4:ee70d1077e54 | 211 | } |
wim | 4:ee70d1077e54 | 212 | pc.printf("Show all segs done\r\n"); |
wim | 4:ee70d1077e54 | 213 | #endif |
wim | 4:ee70d1077e54 | 214 | |
wim | 4:ee70d1077e54 | 215 | } |
wim | 4:ee70d1077e54 | 216 | |
wim | 4:ee70d1077e54 | 217 | |
wim | 4:ee70d1077e54 | 218 | if (keydata[0] == 0x04) { //stop |
wim | 4:ee70d1077e54 | 219 | // DVD462.cls(); |
wim | 4:ee70d1077e54 | 220 | // DVD462.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 221 | |
wim | 4:ee70d1077e54 | 222 | #if(0) |
wim | 4:ee70d1077e54 | 223 | //test to show all chars |
wim | 4:ee70d1077e54 | 224 | pc.printf("Show all chars\r\n"); |
wim | 4:ee70d1077e54 | 225 | wait(1); |
wim | 4:ee70d1077e54 | 226 | DVD462.cls(); |
wim | 4:ee70d1077e54 | 227 | |
wim | 4:ee70d1077e54 | 228 | for (int i=0; i<26; i++) { |
wim | 4:ee70d1077e54 | 229 | DVD462.writeData(0, FONT_16S[i][0]); |
wim | 4:ee70d1077e54 | 230 | DVD462.writeData(1, FONT_16S[i][1]); |
wim | 4:ee70d1077e54 | 231 | wait(1); |
wim | 4:ee70d1077e54 | 232 | } |
wim | 4:ee70d1077e54 | 233 | pc.printf("Show all chars done\r\n"); |
wim | 4:ee70d1077e54 | 234 | #endif |
wim | 4:ee70d1077e54 | 235 | |
wim | 4:ee70d1077e54 | 236 | |
wim | 4:ee70d1077e54 | 237 | #if(0) |
wim | 4:ee70d1077e54 | 238 | //test to show all digits (base is 10) |
wim | 4:ee70d1077e54 | 239 | pc.printf("Show all digits\r\n"); |
wim | 4:ee70d1077e54 | 240 | wait(1); |
wim | 4:ee70d1077e54 | 241 | DVD462.cls(); |
wim | 4:ee70d1077e54 | 242 | |
wim | 4:ee70d1077e54 | 243 | int val = 1; |
wim | 4:ee70d1077e54 | 244 | for (int i=0; i<DVD462_NR_DIGITS; i++) { |
wim | 4:ee70d1077e54 | 245 | |
wim | 4:ee70d1077e54 | 246 | for (int cnt=0; cnt<10; cnt++) { |
wim | 4:ee70d1077e54 | 247 | DVD462.locate(0); |
wim | 4:ee70d1077e54 | 248 | DVD462.printf("%07d", (val * cnt)); |
wim | 4:ee70d1077e54 | 249 | |
wim | 4:ee70d1077e54 | 250 | // wait(0.5); |
wim | 4:ee70d1077e54 | 251 | cmd = pc.getc(); // wait for key |
wim | 4:ee70d1077e54 | 252 | } |
wim | 4:ee70d1077e54 | 253 | val = val * 10; |
wim | 4:ee70d1077e54 | 254 | } |
wim | 4:ee70d1077e54 | 255 | pc.printf("Show all digits done\r\n"); |
wim | 4:ee70d1077e54 | 256 | #endif |
wim | 4:ee70d1077e54 | 257 | |
wim | 4:ee70d1077e54 | 258 | #if(1) |
wim | 4:ee70d1077e54 | 259 | //test to show all digits (base is 0x10) |
wim | 4:ee70d1077e54 | 260 | pc.printf("Show all digits\r\n"); |
wim | 4:ee70d1077e54 | 261 | wait(1); |
wim | 4:ee70d1077e54 | 262 | DVD462.cls(); |
wim | 4:ee70d1077e54 | 263 | |
wim | 4:ee70d1077e54 | 264 | DVD462.printf("%07x", 0x012ABCD); |
wim | 4:ee70d1077e54 | 265 | cmd = pc.getc(); // wait for key |
wim | 4:ee70d1077e54 | 266 | |
wim | 4:ee70d1077e54 | 267 | int val = 1; |
wim | 4:ee70d1077e54 | 268 | for (int i=0; i<DVD462_NR_DIGITS; i++) { |
wim | 4:ee70d1077e54 | 269 | |
wim | 4:ee70d1077e54 | 270 | for (int cnt=0; cnt<0x10; cnt++) { |
wim | 4:ee70d1077e54 | 271 | DVD462.locate(0); |
wim | 4:ee70d1077e54 | 272 | DVD462.printf("%07x", (val * cnt)); |
wim | 4:ee70d1077e54 | 273 | |
wim | 4:ee70d1077e54 | 274 | // wait(0.5); |
wim | 4:ee70d1077e54 | 275 | cmd = pc.getc(); // wait for key |
wim | 4:ee70d1077e54 | 276 | } |
wim | 4:ee70d1077e54 | 277 | val = val * 0x10; |
wim | 4:ee70d1077e54 | 278 | } |
wim | 4:ee70d1077e54 | 279 | pc.printf("Show all digits done\r\n"); |
wim | 4:ee70d1077e54 | 280 | #endif |
wim | 4:ee70d1077e54 | 281 | |
wim | 4:ee70d1077e54 | 282 | } |
wim | 4:ee70d1077e54 | 283 | |
wim | 4:ee70d1077e54 | 284 | if (keydata[0] == 0x10) { //open/close |
wim | 4:ee70d1077e54 | 285 | // DVD462.cls(); |
wim | 4:ee70d1077e54 | 286 | // DVD462.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 287 | #if(1) |
wim | 4:ee70d1077e54 | 288 | //test to show all icons |
wim | 4:ee70d1077e54 | 289 | pc.printf("Show all icons\r\n"); |
wim | 4:ee70d1077e54 | 290 | wait(1); |
wim | 4:ee70d1077e54 | 291 | DVD462.cls(true); // Also clear all Icons |
wim | 4:ee70d1077e54 | 292 | wait(1); |
wim | 4:ee70d1077e54 | 293 | |
wim | 4:ee70d1077e54 | 294 | DVD462.setIcon(PT6312_DVD462::MP3); |
wim | 4:ee70d1077e54 | 295 | DVD462.setIcon(PT6312_DVD462::CD); |
wim | 4:ee70d1077e54 | 296 | DVD462.setIcon(PT6312_DVD462::V); |
wim | 4:ee70d1077e54 | 297 | DVD462.setIcon(PT6312_DVD462::S); |
wim | 4:ee70d1077e54 | 298 | DVD462.setIcon(PT6312_DVD462::DVD); |
wim | 4:ee70d1077e54 | 299 | |
wim | 4:ee70d1077e54 | 300 | DVD462.setIcon(PT6312_DVD462::DDD); |
wim | 4:ee70d1077e54 | 301 | DVD462.setIcon(PT6312_DVD462::DTS); |
wim | 4:ee70d1077e54 | 302 | |
wim | 4:ee70d1077e54 | 303 | DVD462.setIcon(PT6312_DVD462::COL5); |
wim | 4:ee70d1077e54 | 304 | DVD462.setIcon(PT6312_DVD462::COL3); |
wim | 4:ee70d1077e54 | 305 | |
wim | 4:ee70d1077e54 | 306 | DVD462.setIcon(PT6312_DVD462::ARW); |
wim | 4:ee70d1077e54 | 307 | DVD462.setIcon(PT6312_DVD462::ALL); |
wim | 4:ee70d1077e54 | 308 | DVD462.setIcon(PT6312_DVD462::PSE); |
wim | 4:ee70d1077e54 | 309 | DVD462.setIcon(PT6312_DVD462::PLY); |
wim | 4:ee70d1077e54 | 310 | DVD462.setIcon(PT6312_DVD462::PBC); |
wim | 4:ee70d1077e54 | 311 | |
wim | 4:ee70d1077e54 | 312 | DVD462.setIcon(PT6312_DVD462::P1); |
wim | 4:ee70d1077e54 | 313 | DVD462.setIcon(PT6312_DVD462::P2); |
wim | 4:ee70d1077e54 | 314 | DVD462.setIcon(PT6312_DVD462::P3); |
wim | 4:ee70d1077e54 | 315 | DVD462.setIcon(PT6312_DVD462::P4); |
wim | 4:ee70d1077e54 | 316 | DVD462.setIcon(PT6312_DVD462::P5); |
wim | 4:ee70d1077e54 | 317 | DVD462.setIcon(PT6312_DVD462::P6); |
wim | 4:ee70d1077e54 | 318 | DVD462.setIcon(PT6312_DVD462::P7); |
wim | 4:ee70d1077e54 | 319 | DVD462.setIcon(PT6312_DVD462::P8); |
wim | 4:ee70d1077e54 | 320 | DVD462.setIcon(PT6312_DVD462::P9); |
wim | 4:ee70d1077e54 | 321 | DVD462.setIcon(PT6312_DVD462::P10); |
wim | 4:ee70d1077e54 | 322 | DVD462.setIcon(PT6312_DVD462::P11); |
wim | 4:ee70d1077e54 | 323 | DVD462.setIcon(PT6312_DVD462::P12); |
wim | 4:ee70d1077e54 | 324 | DVD462.setIcon(PT6312_DVD462::P13); |
wim | 4:ee70d1077e54 | 325 | |
wim | 4:ee70d1077e54 | 326 | wait(1); |
wim | 4:ee70d1077e54 | 327 | DVD462.cls(); // clear all, preserve Icons |
wim | 4:ee70d1077e54 | 328 | pc.printf("Show all icons done\r\n"); |
wim | 4:ee70d1077e54 | 329 | #endif |
wim | 4:ee70d1077e54 | 330 | } |
wim | 4:ee70d1077e54 | 331 | |
wim | 4:ee70d1077e54 | 332 | if (keydata[0] == 0x20) { //fr |
wim | 4:ee70d1077e54 | 333 | // DVD462.cls(); |
wim | 4:ee70d1077e54 | 334 | // DVD462.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 335 | |
wim | 4:ee70d1077e54 | 336 | //write LEDs off |
wim | 4:ee70d1077e54 | 337 | DVD462.setLED(0x01); |
wim | 4:ee70d1077e54 | 338 | } |
wim | 4:ee70d1077e54 | 339 | |
wim | 4:ee70d1077e54 | 340 | if (keydata[0] == 0x40) { //ff |
wim | 4:ee70d1077e54 | 341 | // DVD462.cls(); |
wim | 4:ee70d1077e54 | 342 | // DVD462.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 343 | |
wim | 4:ee70d1077e54 | 344 | //write LEDs on |
wim | 4:ee70d1077e54 | 345 | DVD462.setLED(0x00); |
wim | 4:ee70d1077e54 | 346 | |
wim | 4:ee70d1077e54 | 347 | } |
wim | 4:ee70d1077e54 | 348 | |
wim | 4:ee70d1077e54 | 349 | if (keydata[0] == 0x80) { //pwr |
wim | 4:ee70d1077e54 | 350 | DVD462.cls(true); |
wim | 4:ee70d1077e54 | 351 | // DVD462.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 352 | // DVD462.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 353 | |
wim | 4:ee70d1077e54 | 354 | float delay=0.1; |
wim | 4:ee70d1077e54 | 355 | // Piechart Icons on |
wim | 4:ee70d1077e54 | 356 | DVD462.setIcon(PT6312_DVD462::P13); wait(delay); |
wim | 4:ee70d1077e54 | 357 | DVD462.setIcon(PT6312_DVD462::P12); wait(delay); |
wim | 4:ee70d1077e54 | 358 | DVD462.setIcon(PT6312_DVD462::P11); wait(delay); |
wim | 4:ee70d1077e54 | 359 | DVD462.setIcon(PT6312_DVD462::P10); wait(delay); |
wim | 4:ee70d1077e54 | 360 | DVD462.setIcon(PT6312_DVD462::P9); wait(delay); |
wim | 4:ee70d1077e54 | 361 | DVD462.setIcon(PT6312_DVD462::P8); wait(delay); |
wim | 4:ee70d1077e54 | 362 | DVD462.setIcon(PT6312_DVD462::P7); wait(delay); |
wim | 4:ee70d1077e54 | 363 | DVD462.setIcon(PT6312_DVD462::P6); wait(delay); |
wim | 4:ee70d1077e54 | 364 | DVD462.setIcon(PT6312_DVD462::P5); wait(delay); |
wim | 4:ee70d1077e54 | 365 | DVD462.setIcon(PT6312_DVD462::P4); wait(delay); |
wim | 4:ee70d1077e54 | 366 | DVD462.setIcon(PT6312_DVD462::P3); wait(delay); |
wim | 4:ee70d1077e54 | 367 | DVD462.setIcon(PT6312_DVD462::P2); wait(delay); |
wim | 4:ee70d1077e54 | 368 | DVD462.setIcon(PT6312_DVD462::P1); wait(delay); |
wim | 4:ee70d1077e54 | 369 | |
wim | 4:ee70d1077e54 | 370 | wait(delay); |
wim | 4:ee70d1077e54 | 371 | |
wim | 4:ee70d1077e54 | 372 | // Piechart Icons off |
wim | 4:ee70d1077e54 | 373 | DVD462.clrIcon(PT6312_DVD462::P13); wait(delay); |
wim | 4:ee70d1077e54 | 374 | DVD462.clrIcon(PT6312_DVD462::P12); wait(delay); |
wim | 4:ee70d1077e54 | 375 | DVD462.clrIcon(PT6312_DVD462::P11); wait(delay); |
wim | 4:ee70d1077e54 | 376 | DVD462.clrIcon(PT6312_DVD462::P10); wait(delay); |
wim | 4:ee70d1077e54 | 377 | DVD462.clrIcon(PT6312_DVD462::P9); wait(delay); |
wim | 4:ee70d1077e54 | 378 | DVD462.clrIcon(PT6312_DVD462::P8); wait(delay); |
wim | 4:ee70d1077e54 | 379 | DVD462.clrIcon(PT6312_DVD462::P7); wait(delay); |
wim | 4:ee70d1077e54 | 380 | DVD462.clrIcon(PT6312_DVD462::P6); wait(delay); |
wim | 4:ee70d1077e54 | 381 | DVD462.clrIcon(PT6312_DVD462::P5); wait(delay); |
wim | 4:ee70d1077e54 | 382 | DVD462.clrIcon(PT6312_DVD462::P4); wait(delay); |
wim | 4:ee70d1077e54 | 383 | DVD462.clrIcon(PT6312_DVD462::P3); wait(delay); |
wim | 4:ee70d1077e54 | 384 | DVD462.clrIcon(PT6312_DVD462::P2); wait(delay); |
wim | 4:ee70d1077e54 | 385 | DVD462.clrIcon(PT6312_DVD462::P1); wait(delay); |
wim | 4:ee70d1077e54 | 386 | } |
wim | 4:ee70d1077e54 | 387 | |
wim | 4:ee70d1077e54 | 388 | } //if Key |
wim | 4:ee70d1077e54 | 389 | |
wim | 4:ee70d1077e54 | 390 | |
wim | 4:ee70d1077e54 | 391 | // Check and read switch data |
wim | 4:ee70d1077e54 | 392 | switchdata = DVD462.getSwitches(); |
wim | 4:ee70d1077e54 | 393 | |
wim | 4:ee70d1077e54 | 394 | if (switchdata != 0) { |
wim | 4:ee70d1077e54 | 395 | pc.printf("Switchdata = 0x%02x\r\n", switchdata); |
wim | 4:ee70d1077e54 | 396 | |
wim | 4:ee70d1077e54 | 397 | if (switchdata == PT6312_SW1) { //S1 |
wim | 4:ee70d1077e54 | 398 | DVD462.cls(); |
wim | 4:ee70d1077e54 | 399 | DVD462.writeData(hello_str); |
wim | 4:ee70d1077e54 | 400 | } |
wim | 4:ee70d1077e54 | 401 | |
wim | 4:ee70d1077e54 | 402 | if (switchdata == PT6312_SW2) { //S2 |
wim | 4:ee70d1077e54 | 403 | DVD462.cls(); |
wim | 4:ee70d1077e54 | 404 | DVD462.writeData(bye_str); |
wim | 4:ee70d1077e54 | 405 | } |
wim | 4:ee70d1077e54 | 406 | |
wim | 4:ee70d1077e54 | 407 | if (switchdata == PT6312_SW3) { //S3 |
wim | 4:ee70d1077e54 | 408 | DVD462.cls(); |
wim | 4:ee70d1077e54 | 409 | DVD462.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 410 | } |
wim | 4:ee70d1077e54 | 411 | |
wim | 4:ee70d1077e54 | 412 | DVD462.setLED(switchdata); //write LEDs in same pattern |
wim | 4:ee70d1077e54 | 413 | } //if Switch |
wim | 4:ee70d1077e54 | 414 | |
wim | 4:ee70d1077e54 | 415 | |
wim | 4:ee70d1077e54 | 416 | myled = !myled; |
wim | 4:ee70d1077e54 | 417 | wait(0.3); |
wim | 4:ee70d1077e54 | 418 | } //while |
wim | 4:ee70d1077e54 | 419 | } |
wim | 4:ee70d1077e54 | 420 | #endif |
wim | 4:ee70d1077e54 | 421 | |
wim | 4:ee70d1077e54 | 422 | |
wim | 4:ee70d1077e54 | 423 | #if (C2233_TEST == 1) |
wim | 4:ee70d1077e54 | 424 | // C2233 PT6312 Test |
wim | 4:ee70d1077e54 | 425 | #include "mbed.h" |
wim | 4:ee70d1077e54 | 426 | #include "PT6312.h" |
wim | 4:ee70d1077e54 | 427 | #include "Font_7Seg.h" |
wim | 4:ee70d1077e54 | 428 | |
wim | 4:ee70d1077e54 | 429 | Serial pc(USBTX, USBRX); |
wim | 4:ee70d1077e54 | 430 | DigitalOut myled(LED1); |
wim | 4:ee70d1077e54 | 431 | |
wim | 4:ee70d1077e54 | 432 | // DisplayData_t size is 8 bytes (4 digits @ max 16 segments) ... 22 bytes (11 digits @ max 11 segments) |
wim | 4:ee70d1077e54 | 433 | // DisplayData_t size default is 22 bytes (11 digits @ max 11 segments) |
wim | 4:ee70d1077e54 | 434 | PT6312::DisplayData_t all_str = {0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF, 0xFF,0xFF}; |
wim | 4:ee70d1077e54 | 435 | //PT6312::DisplayData_t bye_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, LO(C7_E),HI(C7_E), LO(C7_Y),HI(C7_Y), LO(C7_B),HI(C7_B)}; |
wim | 4:ee70d1077e54 | 436 | PT6312::DisplayData_t hello_str = {0x00,0x00, (C7_O | ((C7_L & 0x01) << 7)),(C7_L >> 1), C7_L,C7_E, C7_H,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 4:ee70d1077e54 | 437 | //PT6312::DisplayData_t mbed_str = {LO(C7_D), HI(C7_D), LO(C7_E), HI(C7_E), LO(C7_B), HI(C7_B), LO(C7_M), HI(C7_M)}; |
wim | 4:ee70d1077e54 | 438 | |
wim | 4:ee70d1077e54 | 439 | // KeyData_t size is 3 bytes |
wim | 4:ee70d1077e54 | 440 | PT6312::KeyData_t keydata; |
wim | 4:ee70d1077e54 | 441 | |
wim | 4:ee70d1077e54 | 442 | // Switchdata is 1 byte |
wim | 4:ee70d1077e54 | 443 | char switchdata; |
wim | 4:ee70d1077e54 | 444 | |
wim | 4:ee70d1077e54 | 445 | //PT6312_C2233 declaration, Setting 6 Grids @ 16 Segments |
wim | 4:ee70d1077e54 | 446 | PT6312_C2233 C2233(p5,p6,p7, p8); |
wim | 4:ee70d1077e54 | 447 | |
wim | 4:ee70d1077e54 | 448 | char cmd, bits; |
wim | 4:ee70d1077e54 | 449 | int main() { |
wim | 4:ee70d1077e54 | 450 | |
wim | 4:ee70d1077e54 | 451 | pc.printf("Hello World\r\n"); // |
wim | 4:ee70d1077e54 | 452 | |
wim | 4:ee70d1077e54 | 453 | C2233.cls(); |
wim | 4:ee70d1077e54 | 454 | C2233.writeData(all_str); |
wim | 4:ee70d1077e54 | 455 | wait(4); |
wim | 4:ee70d1077e54 | 456 | C2233.setBrightness(PT6312_BRT3); |
wim | 4:ee70d1077e54 | 457 | wait(1); |
wim | 4:ee70d1077e54 | 458 | C2233.setBrightness(PT6312_BRT0); |
wim | 4:ee70d1077e54 | 459 | wait(1); |
wim | 4:ee70d1077e54 | 460 | C2233.setBrightness(PT6312_BRT7); |
wim | 4:ee70d1077e54 | 461 | |
wim | 4:ee70d1077e54 | 462 | wait(1); |
wim | 4:ee70d1077e54 | 463 | C2233.cls(true); |
wim | 4:ee70d1077e54 | 464 | C2233.writeData(hello_str); |
wim | 4:ee70d1077e54 | 465 | |
wim | 4:ee70d1077e54 | 466 | while (1) { |
wim | 4:ee70d1077e54 | 467 | |
wim | 4:ee70d1077e54 | 468 | // Check and read keydata |
wim | 4:ee70d1077e54 | 469 | if (C2233.getKeys(&keydata)) { |
wim | 4:ee70d1077e54 | 470 | pc.printf("Keydata 0..2 = 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2]); |
wim | 4:ee70d1077e54 | 471 | |
wim | 4:ee70d1077e54 | 472 | if (keydata[0] == 0x01) { //sw4 |
wim | 4:ee70d1077e54 | 473 | C2233.cls(); |
wim | 4:ee70d1077e54 | 474 | C2233.writeData(all_str); |
wim | 4:ee70d1077e54 | 475 | } |
wim | 4:ee70d1077e54 | 476 | |
wim | 4:ee70d1077e54 | 477 | if (keydata[0] == 0x02) { //sw7 |
wim | 4:ee70d1077e54 | 478 | C2233.cls(); |
wim | 4:ee70d1077e54 | 479 | // C2233.writeData(hello_str); |
wim | 4:ee70d1077e54 | 480 | #if(1) |
wim | 4:ee70d1077e54 | 481 | //test to show all segs |
wim | 4:ee70d1077e54 | 482 | pc.printf("Show all segs\r\n"); |
wim | 4:ee70d1077e54 | 483 | wait(1); |
wim | 4:ee70d1077e54 | 484 | C2233.cls(); |
wim | 4:ee70d1077e54 | 485 | |
wim | 4:ee70d1077e54 | 486 | for (int i=0; i<PT6312_DISPLAY_MEM; i++) { |
wim | 4:ee70d1077e54 | 487 | for (int bit=0; bit<8; bit++) { |
wim | 4:ee70d1077e54 | 488 | C2233.cls(); |
wim | 4:ee70d1077e54 | 489 | |
wim | 4:ee70d1077e54 | 490 | bits = 0x01 << bit; |
wim | 4:ee70d1077e54 | 491 | C2233.writeData(i, bits); |
wim | 4:ee70d1077e54 | 492 | |
wim | 4:ee70d1077e54 | 493 | pc.printf("Idx = %d, Bits = 0x%02x\r\n", i, bits); |
wim | 4:ee70d1077e54 | 494 | // wait(0.5); |
wim | 4:ee70d1077e54 | 495 | cmd = pc.getc(); // wait for key |
wim | 4:ee70d1077e54 | 496 | } |
wim | 4:ee70d1077e54 | 497 | } |
wim | 4:ee70d1077e54 | 498 | pc.printf("Show all segs done\r\n"); |
wim | 4:ee70d1077e54 | 499 | #endif |
wim | 4:ee70d1077e54 | 500 | |
wim | 4:ee70d1077e54 | 501 | } |
wim | 4:ee70d1077e54 | 502 | |
wim | 4:ee70d1077e54 | 503 | |
wim | 4:ee70d1077e54 | 504 | if (keydata[0] == 0x04) { //sw3 |
wim | 4:ee70d1077e54 | 505 | // C2233.cls(); |
wim | 4:ee70d1077e54 | 506 | // C2233.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 507 | |
wim | 4:ee70d1077e54 | 508 | #if(0) |
wim | 4:ee70d1077e54 | 509 | //test to show all chars |
wim | 4:ee70d1077e54 | 510 | pc.printf("Show all chars\r\n"); |
wim | 4:ee70d1077e54 | 511 | wait(1); |
wim | 4:ee70d1077e54 | 512 | C2233.cls(); |
wim | 4:ee70d1077e54 | 513 | |
wim | 4:ee70d1077e54 | 514 | for (int i=0; i<26; i++) { |
wim | 4:ee70d1077e54 | 515 | C2233.writeData(0, FONT_16S[i][0]); |
wim | 4:ee70d1077e54 | 516 | C2233.writeData(1, FONT_16S[i][1]); |
wim | 4:ee70d1077e54 | 517 | wait(1); |
wim | 4:ee70d1077e54 | 518 | } |
wim | 4:ee70d1077e54 | 519 | pc.printf("Show all chars done\r\n"); |
wim | 4:ee70d1077e54 | 520 | #endif |
wim | 4:ee70d1077e54 | 521 | |
wim | 4:ee70d1077e54 | 522 | |
wim | 4:ee70d1077e54 | 523 | #if(0) |
wim | 4:ee70d1077e54 | 524 | //test to show all digits (base is 10) |
wim | 4:ee70d1077e54 | 525 | pc.printf("Show all digits\r\n"); |
wim | 4:ee70d1077e54 | 526 | wait(1); |
wim | 4:ee70d1077e54 | 527 | C2233.cls(); |
wim | 4:ee70d1077e54 | 528 | |
wim | 4:ee70d1077e54 | 529 | int val = 1; |
wim | 4:ee70d1077e54 | 530 | for (int i=0; i<C2233_NR_DIGITS; i++) { |
wim | 4:ee70d1077e54 | 531 | |
wim | 4:ee70d1077e54 | 532 | for (int cnt=0; cnt<10; cnt++) { |
wim | 4:ee70d1077e54 | 533 | C2233.locate(0); |
wim | 4:ee70d1077e54 | 534 | C2233.printf("%07d", (val * cnt)); |
wim | 4:ee70d1077e54 | 535 | |
wim | 4:ee70d1077e54 | 536 | // wait(0.5); |
wim | 4:ee70d1077e54 | 537 | cmd = pc.getc(); // wait for key |
wim | 4:ee70d1077e54 | 538 | } |
wim | 4:ee70d1077e54 | 539 | val = val * 10; |
wim | 4:ee70d1077e54 | 540 | } |
wim | 4:ee70d1077e54 | 541 | pc.printf("Show all digits done\r\n"); |
wim | 4:ee70d1077e54 | 542 | #endif |
wim | 4:ee70d1077e54 | 543 | |
wim | 4:ee70d1077e54 | 544 | #if(1) |
wim | 4:ee70d1077e54 | 545 | //test to show all digits (base is 0x10) |
wim | 4:ee70d1077e54 | 546 | pc.printf("Show all digits\r\n"); |
wim | 4:ee70d1077e54 | 547 | wait(1); |
wim | 4:ee70d1077e54 | 548 | C2233.cls(); |
wim | 4:ee70d1077e54 | 549 | |
wim | 4:ee70d1077e54 | 550 | C2233.printf("%07x", 0x012ABCD); |
wim | 4:ee70d1077e54 | 551 | cmd = pc.getc(); // wait for key |
wim | 4:ee70d1077e54 | 552 | |
wim | 4:ee70d1077e54 | 553 | int val = 1; |
wim | 4:ee70d1077e54 | 554 | for (int i=0; i<C2233_NR_DIGITS; i++) { |
wim | 4:ee70d1077e54 | 555 | |
wim | 4:ee70d1077e54 | 556 | for (int cnt=0; cnt<0x10; cnt++) { |
wim | 4:ee70d1077e54 | 557 | C2233.locate(0); |
wim | 4:ee70d1077e54 | 558 | C2233.printf("%07x", (val * cnt)); |
wim | 4:ee70d1077e54 | 559 | |
wim | 4:ee70d1077e54 | 560 | // wait(0.5); |
wim | 4:ee70d1077e54 | 561 | cmd = pc.getc(); // wait for key |
wim | 4:ee70d1077e54 | 562 | } |
wim | 4:ee70d1077e54 | 563 | val = val * 0x10; |
wim | 4:ee70d1077e54 | 564 | } |
wim | 4:ee70d1077e54 | 565 | pc.printf("Show all digits done\r\n"); |
wim | 4:ee70d1077e54 | 566 | #endif |
wim | 4:ee70d1077e54 | 567 | |
wim | 4:ee70d1077e54 | 568 | } |
wim | 4:ee70d1077e54 | 569 | |
wim | 4:ee70d1077e54 | 570 | if (keydata[0] == 0x10) { //sw5 |
wim | 4:ee70d1077e54 | 571 | // C2233.cls(); |
wim | 4:ee70d1077e54 | 572 | // C2233.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 573 | #if(1) |
wim | 4:ee70d1077e54 | 574 | //test to show all icons |
wim | 4:ee70d1077e54 | 575 | pc.printf("Show all icons\r\n"); |
wim | 4:ee70d1077e54 | 576 | wait(1); |
wim | 4:ee70d1077e54 | 577 | C2233.cls(true); // Also clear all Icons |
wim | 4:ee70d1077e54 | 578 | wait(1); |
wim | 4:ee70d1077e54 | 579 | |
wim | 4:ee70d1077e54 | 580 | C2233.setIcon(PT6312_C2233::MP3); |
wim | 4:ee70d1077e54 | 581 | C2233.setIcon(PT6312_C2233::PBC); |
wim | 4:ee70d1077e54 | 582 | |
wim | 4:ee70d1077e54 | 583 | C2233.setIcon(PT6312_C2233::COL5); |
wim | 4:ee70d1077e54 | 584 | C2233.setIcon(PT6312_C2233::CAM); |
wim | 4:ee70d1077e54 | 585 | |
wim | 4:ee70d1077e54 | 586 | C2233.setIcon(PT6312_C2233::COL3); |
wim | 4:ee70d1077e54 | 587 | C2233.setIcon(PT6312_C2233::DDD); |
wim | 4:ee70d1077e54 | 588 | |
wim | 4:ee70d1077e54 | 589 | C2233.setIcon(PT6312_C2233::ARW); |
wim | 4:ee70d1077e54 | 590 | C2233.setIcon(PT6312_C2233::ALL); |
wim | 4:ee70d1077e54 | 591 | C2233.setIcon(PT6312_C2233::PSE); |
wim | 4:ee70d1077e54 | 592 | C2233.setIcon(PT6312_C2233::PLY); |
wim | 4:ee70d1077e54 | 593 | C2233.setIcon(PT6312_C2233::CD); |
wim | 4:ee70d1077e54 | 594 | C2233.setIcon(PT6312_C2233::V); |
wim | 4:ee70d1077e54 | 595 | C2233.setIcon(PT6312_C2233::S); |
wim | 4:ee70d1077e54 | 596 | C2233.setIcon(PT6312_C2233::DTS); |
wim | 4:ee70d1077e54 | 597 | |
wim | 4:ee70d1077e54 | 598 | C2233.setIcon(PT6312_C2233::P1); |
wim | 4:ee70d1077e54 | 599 | C2233.setIcon(PT6312_C2233::P2); |
wim | 4:ee70d1077e54 | 600 | C2233.setIcon(PT6312_C2233::P3); |
wim | 4:ee70d1077e54 | 601 | C2233.setIcon(PT6312_C2233::P4); |
wim | 4:ee70d1077e54 | 602 | C2233.setIcon(PT6312_C2233::P5); |
wim | 4:ee70d1077e54 | 603 | C2233.setIcon(PT6312_C2233::P6); |
wim | 4:ee70d1077e54 | 604 | C2233.setIcon(PT6312_C2233::P7); |
wim | 4:ee70d1077e54 | 605 | C2233.setIcon(PT6312_C2233::P8); |
wim | 4:ee70d1077e54 | 606 | C2233.setIcon(PT6312_C2233::P9); |
wim | 4:ee70d1077e54 | 607 | C2233.setIcon(PT6312_C2233::P10); |
wim | 4:ee70d1077e54 | 608 | C2233.setIcon(PT6312_C2233::P11); |
wim | 4:ee70d1077e54 | 609 | C2233.setIcon(PT6312_C2233::P12); |
wim | 4:ee70d1077e54 | 610 | C2233.setIcon(PT6312_C2233::P13); |
wim | 4:ee70d1077e54 | 611 | C2233.setIcon(PT6312_C2233::DVD); |
wim | 4:ee70d1077e54 | 612 | |
wim | 4:ee70d1077e54 | 613 | wait(1); |
wim | 4:ee70d1077e54 | 614 | C2233.cls(); // clear all, preserve Icons |
wim | 4:ee70d1077e54 | 615 | pc.printf("Show all icons done\r\n"); |
wim | 4:ee70d1077e54 | 616 | #endif |
wim | 4:ee70d1077e54 | 617 | } |
wim | 4:ee70d1077e54 | 618 | |
wim | 4:ee70d1077e54 | 619 | if (keydata[0] == 0x20) { //sw6 |
wim | 4:ee70d1077e54 | 620 | // C2233.cls(); |
wim | 4:ee70d1077e54 | 621 | // C2233.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 622 | |
wim | 4:ee70d1077e54 | 623 | //write LEDs off |
wim | 4:ee70d1077e54 | 624 | C2233.setLED(0x01); |
wim | 4:ee70d1077e54 | 625 | } |
wim | 4:ee70d1077e54 | 626 | |
wim | 4:ee70d1077e54 | 627 | if (keydata[0] == 0x40) { //sw2 |
wim | 4:ee70d1077e54 | 628 | // C2233.cls(); |
wim | 4:ee70d1077e54 | 629 | // C2233.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 630 | |
wim | 4:ee70d1077e54 | 631 | //write LEDs on |
wim | 4:ee70d1077e54 | 632 | C2233.setLED(0x00); |
wim | 4:ee70d1077e54 | 633 | |
wim | 4:ee70d1077e54 | 634 | } |
wim | 4:ee70d1077e54 | 635 | |
wim | 4:ee70d1077e54 | 636 | if (keydata[0] == 0x80) { //sw1 |
wim | 4:ee70d1077e54 | 637 | C2233.cls(true); |
wim | 4:ee70d1077e54 | 638 | // C2233.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 639 | // C2233.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 640 | |
wim | 4:ee70d1077e54 | 641 | float delay=0.1; |
wim | 4:ee70d1077e54 | 642 | // Piechart Icons on |
wim | 4:ee70d1077e54 | 643 | C2233.setIcon(PT6312_C2233::P13); wait(delay); |
wim | 4:ee70d1077e54 | 644 | C2233.setIcon(PT6312_C2233::P12); wait(delay); |
wim | 4:ee70d1077e54 | 645 | C2233.setIcon(PT6312_C2233::P11); wait(delay); |
wim | 4:ee70d1077e54 | 646 | C2233.setIcon(PT6312_C2233::P10); wait(delay); |
wim | 4:ee70d1077e54 | 647 | C2233.setIcon(PT6312_C2233::P9); wait(delay); |
wim | 4:ee70d1077e54 | 648 | C2233.setIcon(PT6312_C2233::P8); wait(delay); |
wim | 4:ee70d1077e54 | 649 | C2233.setIcon(PT6312_C2233::P7); wait(delay); |
wim | 4:ee70d1077e54 | 650 | C2233.setIcon(PT6312_C2233::P6); wait(delay); |
wim | 4:ee70d1077e54 | 651 | C2233.setIcon(PT6312_C2233::P5); wait(delay); |
wim | 4:ee70d1077e54 | 652 | C2233.setIcon(PT6312_C2233::P4); wait(delay); |
wim | 4:ee70d1077e54 | 653 | C2233.setIcon(PT6312_C2233::P3); wait(delay); |
wim | 4:ee70d1077e54 | 654 | C2233.setIcon(PT6312_C2233::P2); wait(delay); |
wim | 4:ee70d1077e54 | 655 | C2233.setIcon(PT6312_C2233::P1); wait(delay); |
wim | 4:ee70d1077e54 | 656 | |
wim | 4:ee70d1077e54 | 657 | wait(delay); |
wim | 4:ee70d1077e54 | 658 | |
wim | 4:ee70d1077e54 | 659 | // Piechart Icons off |
wim | 4:ee70d1077e54 | 660 | C2233.clrIcon(PT6312_C2233::P13); wait(delay); |
wim | 4:ee70d1077e54 | 661 | C2233.clrIcon(PT6312_C2233::P12); wait(delay); |
wim | 4:ee70d1077e54 | 662 | C2233.clrIcon(PT6312_C2233::P11); wait(delay); |
wim | 4:ee70d1077e54 | 663 | C2233.clrIcon(PT6312_C2233::P10); wait(delay); |
wim | 4:ee70d1077e54 | 664 | C2233.clrIcon(PT6312_C2233::P9); wait(delay); |
wim | 4:ee70d1077e54 | 665 | C2233.clrIcon(PT6312_C2233::P8); wait(delay); |
wim | 4:ee70d1077e54 | 666 | C2233.clrIcon(PT6312_C2233::P7); wait(delay); |
wim | 4:ee70d1077e54 | 667 | C2233.clrIcon(PT6312_C2233::P6); wait(delay); |
wim | 4:ee70d1077e54 | 668 | C2233.clrIcon(PT6312_C2233::P5); wait(delay); |
wim | 4:ee70d1077e54 | 669 | C2233.clrIcon(PT6312_C2233::P4); wait(delay); |
wim | 4:ee70d1077e54 | 670 | C2233.clrIcon(PT6312_C2233::P3); wait(delay); |
wim | 4:ee70d1077e54 | 671 | C2233.clrIcon(PT6312_C2233::P2); wait(delay); |
wim | 4:ee70d1077e54 | 672 | C2233.clrIcon(PT6312_C2233::P1); wait(delay); |
wim | 4:ee70d1077e54 | 673 | } |
wim | 4:ee70d1077e54 | 674 | |
wim | 4:ee70d1077e54 | 675 | } //if Key |
wim | 4:ee70d1077e54 | 676 | |
wim | 4:ee70d1077e54 | 677 | |
wim | 4:ee70d1077e54 | 678 | // Check and read switch data (not available on C2233) |
wim | 4:ee70d1077e54 | 679 | switchdata = C2233.getSwitches(); |
wim | 4:ee70d1077e54 | 680 | |
wim | 4:ee70d1077e54 | 681 | if (switchdata != 0) { |
wim | 4:ee70d1077e54 | 682 | pc.printf("Switchdata = 0x%02x\r\n", switchdata); |
wim | 4:ee70d1077e54 | 683 | |
wim | 4:ee70d1077e54 | 684 | if (switchdata == PT6312_SW1) { //S1 |
wim | 4:ee70d1077e54 | 685 | C2233.cls(); |
wim | 4:ee70d1077e54 | 686 | C2233.writeData(hello_str); |
wim | 4:ee70d1077e54 | 687 | } |
wim | 4:ee70d1077e54 | 688 | |
wim | 4:ee70d1077e54 | 689 | if (switchdata == PT6312_SW2) { //S2 |
wim | 4:ee70d1077e54 | 690 | C2233.cls(); |
wim | 4:ee70d1077e54 | 691 | // C2233.writeData(bye_str); |
wim | 4:ee70d1077e54 | 692 | } |
wim | 4:ee70d1077e54 | 693 | |
wim | 4:ee70d1077e54 | 694 | if (switchdata == PT6312_SW3) { //S3 |
wim | 4:ee70d1077e54 | 695 | C2233.cls(); |
wim | 4:ee70d1077e54 | 696 | // C2233.writeData(mbed_str); |
wim | 4:ee70d1077e54 | 697 | } |
wim | 4:ee70d1077e54 | 698 | |
wim | 4:ee70d1077e54 | 699 | C2233.setLED(switchdata); //write LEDs in same pattern (not available on C2233) |
wim | 4:ee70d1077e54 | 700 | } //if Switch |
wim | 4:ee70d1077e54 | 701 | |
wim | 4:ee70d1077e54 | 702 | |
wim | 4:ee70d1077e54 | 703 | myled = !myled; |
wim | 4:ee70d1077e54 | 704 | wait(0.3); |
wim | 4:ee70d1077e54 | 705 | } //while |
wim | 4:ee70d1077e54 | 706 | } |
wim | 4:ee70d1077e54 | 707 | #endif |
wim | 4:ee70d1077e54 | 708 | |
wim | 4:ee70d1077e54 | 709 | |
wim | 4:ee70d1077e54 | 710 | |
wim | 4:ee70d1077e54 | 711 | #if(PT6312_TEST == 1) |
wim | 4:ee70d1077e54 | 712 | // Direct PT6312 Test |
wim | 4:ee70d1077e54 | 713 | #include "mbed.h" |
wim | 4:ee70d1077e54 | 714 | #include "PT6312.h" |
wim | 4:ee70d1077e54 | 715 | |
wim | 4:ee70d1077e54 | 716 | Serial pc(USBTX, USBRX); |
wim | 4:ee70d1077e54 | 717 | DigitalOut myled(LED1); |
wim | 4:ee70d1077e54 | 718 | |
wim | 4:ee70d1077e54 | 719 | // DisplayData_t size is 8 bytes (4 digits @ max 16 segments) ... 22 bytes (11 digits @ max 11 segments) |
wim | 4:ee70d1077e54 | 720 | // DisplayData_t size default is 14 bytes (7 Grids @ 15 Segments) |
wim | 4:ee70d1077e54 | 721 | PT6312::DisplayData_t all_str = {0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F, 0xFF,0x7F}; |
wim | 4:ee70d1077e54 | 722 | PT6312::DisplayData_t cls_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 4:ee70d1077e54 | 723 | |
wim | 4:ee70d1077e54 | 724 | // KeyData_t size is 3 bytes |
wim | 4:ee70d1077e54 | 725 | PT6312::KeyData_t keydata; |
wim | 4:ee70d1077e54 | 726 | |
wim | 4:ee70d1077e54 | 727 | // Switchdata is 1 byte |
wim | 4:ee70d1077e54 | 728 | char switchdata; |
wim | 4:ee70d1077e54 | 729 | |
wim | 0:1d4ba8a2baa0 | 730 | PT6312 PT6312(p5,p6,p7, p8); |
wim | 4:ee70d1077e54 | 731 | //PT6312 PT6312(p5,p6,p7, p8, PT6312::Grid4_Seg16); |
wim | 0:1d4ba8a2baa0 | 732 | |
wim | 4:ee70d1077e54 | 733 | char cmd, bits; |
wim | 0:1d4ba8a2baa0 | 734 | int main() { |
wim | 0:1d4ba8a2baa0 | 735 | |
wim | 0:1d4ba8a2baa0 | 736 | pc.printf("Hello World\r\n"); // |
wim | 0:1d4ba8a2baa0 | 737 | |
wim | 0:1d4ba8a2baa0 | 738 | PT6312.cls(); |
wim | 0:1d4ba8a2baa0 | 739 | PT6312.writeData(all_str); |
wim | 0:1d4ba8a2baa0 | 740 | wait(4); |
wim | 0:1d4ba8a2baa0 | 741 | PT6312.setBrightness(PT6312_BRT3); |
wim | 0:1d4ba8a2baa0 | 742 | wait(1); |
wim | 0:1d4ba8a2baa0 | 743 | PT6312.setBrightness(PT6312_BRT0); |
wim | 0:1d4ba8a2baa0 | 744 | wait(1); |
wim | 0:1d4ba8a2baa0 | 745 | PT6312.setBrightness(PT6312_BRT7); |
wim | 0:1d4ba8a2baa0 | 746 | |
wim | 0:1d4ba8a2baa0 | 747 | while (1) { |
wim | 0:1d4ba8a2baa0 | 748 | |
wim | 0:1d4ba8a2baa0 | 749 | // Check and read keydata |
wim | 0:1d4ba8a2baa0 | 750 | if (PT6312.getKeys(&keydata)) { |
wim | 0:1d4ba8a2baa0 | 751 | pc.printf("Keydata 0..2 = 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2]); |
wim | 0:1d4ba8a2baa0 | 752 | |
wim | 0:1d4ba8a2baa0 | 753 | if (keydata[0] == 0x01) { //play |
wim | 0:1d4ba8a2baa0 | 754 | PT6312.cls(); |
wim | 0:1d4ba8a2baa0 | 755 | PT6312.writeData(all_str); |
wim | 0:1d4ba8a2baa0 | 756 | } |
wim | 0:1d4ba8a2baa0 | 757 | |
wim | 0:1d4ba8a2baa0 | 758 | if (keydata[0] == 0x02) { //stop |
wim | 0:1d4ba8a2baa0 | 759 | PT6312.cls(); |
wim | 4:ee70d1077e54 | 760 | PT6312.writeData(cls_str); |
wim | 0:1d4ba8a2baa0 | 761 | } |
wim | 0:1d4ba8a2baa0 | 762 | |
wim | 0:1d4ba8a2baa0 | 763 | if (keydata[0] == 0x04) { //open/close |
wim | 0:1d4ba8a2baa0 | 764 | PT6312.cls(); |
wim | 4:ee70d1077e54 | 765 | PT6312.writeData(all_str); |
wim | 0:1d4ba8a2baa0 | 766 | |
wim | 4:ee70d1077e54 | 767 | #if(1) |
wim | 4:ee70d1077e54 | 768 | //test to show all segs |
wim | 4:ee70d1077e54 | 769 | pc.printf("Show all segs\r\n"); |
wim | 0:1d4ba8a2baa0 | 770 | wait(1); |
wim | 0:1d4ba8a2baa0 | 771 | PT6312.cls(); |
wim | 0:1d4ba8a2baa0 | 772 | |
wim | 4:ee70d1077e54 | 773 | for (int i=0; i<PT6312_DISPLAY_MEM; i++) { |
wim | 4:ee70d1077e54 | 774 | for (int bit=0; bit<8; bit++) { |
wim | 4:ee70d1077e54 | 775 | PT6312.cls(); |
wim | 4:ee70d1077e54 | 776 | |
wim | 4:ee70d1077e54 | 777 | bits = 0x01 << bit; |
wim | 4:ee70d1077e54 | 778 | PT6312.writeData(i, bits); |
wim | 4:ee70d1077e54 | 779 | |
wim | 4:ee70d1077e54 | 780 | pc.printf("Idx = %d, Bits = 0x%02x\r\n", i, bits); |
wim | 4:ee70d1077e54 | 781 | // wait(0.5); |
wim | 4:ee70d1077e54 | 782 | cmd = pc.getc(); // wait for key |
wim | 4:ee70d1077e54 | 783 | } |
wim | 0:1d4ba8a2baa0 | 784 | } |
wim | 4:ee70d1077e54 | 785 | pc.printf("Show all segs done\r\n"); |
wim | 4:ee70d1077e54 | 786 | #endif |
wim | 4:ee70d1077e54 | 787 | |
wim | 0:1d4ba8a2baa0 | 788 | } |
wim | 0:1d4ba8a2baa0 | 789 | |
wim | 0:1d4ba8a2baa0 | 790 | } //if Key |
wim | 0:1d4ba8a2baa0 | 791 | |
wim | 0:1d4ba8a2baa0 | 792 | |
wim | 0:1d4ba8a2baa0 | 793 | // Check and read switch data |
wim | 0:1d4ba8a2baa0 | 794 | switchdata = PT6312.getSwitches(); |
wim | 0:1d4ba8a2baa0 | 795 | |
wim | 0:1d4ba8a2baa0 | 796 | if (switchdata != 0) { |
wim | 0:1d4ba8a2baa0 | 797 | pc.printf("Switchdata = 0x%02x\r\n", switchdata); |
wim | 0:1d4ba8a2baa0 | 798 | |
wim | 0:1d4ba8a2baa0 | 799 | if (switchdata == PT6312_SW1) { //S1 |
wim | 0:1d4ba8a2baa0 | 800 | PT6312.cls(); |
wim | 4:ee70d1077e54 | 801 | PT6312.writeData(all_str); |
wim | 0:1d4ba8a2baa0 | 802 | } |
wim | 0:1d4ba8a2baa0 | 803 | |
wim | 0:1d4ba8a2baa0 | 804 | if (switchdata == PT6312_SW2) { //S2 |
wim | 0:1d4ba8a2baa0 | 805 | PT6312.cls(); |
wim | 4:ee70d1077e54 | 806 | PT6312.writeData(cls_str); |
wim | 0:1d4ba8a2baa0 | 807 | } |
wim | 0:1d4ba8a2baa0 | 808 | |
wim | 0:1d4ba8a2baa0 | 809 | if (switchdata == PT6312_SW3) { //S3 |
wim | 0:1d4ba8a2baa0 | 810 | PT6312.cls(); |
wim | 4:ee70d1077e54 | 811 | PT6312.writeData(all_str); |
wim | 0:1d4ba8a2baa0 | 812 | } |
wim | 0:1d4ba8a2baa0 | 813 | |
wim | 0:1d4ba8a2baa0 | 814 | PT6312.setLED(switchdata); //write LEDs in same pattern |
wim | 0:1d4ba8a2baa0 | 815 | } //if Switch |
wim | 0:1d4ba8a2baa0 | 816 | |
wim | 0:1d4ba8a2baa0 | 817 | |
wim | 0:1d4ba8a2baa0 | 818 | myled = !myled; |
wim | 0:1d4ba8a2baa0 | 819 | wait(0.3); |
wim | 0:1d4ba8a2baa0 | 820 | } //while |
wim | 0:1d4ba8a2baa0 | 821 | } |
wim | 4:ee70d1077e54 | 822 | #endif |