Wim Huiskamp
/
mbed_PT6315
PT6315 VFD driver test program. Supports DVDR3510.
main.cpp@0:2ab901c7d70e, 2016-01-20 (annotated)
- Committer:
- wim
- Date:
- Wed Jan 20 19:26:26 2016 +0000
- Revision:
- 0:2ab901c7d70e
PT6315 VFD driver library test program. Supports DVDR3510. First release.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 0:2ab901c7d70e | 1 | /* mbed PT6315 Test program, for Princeton PT6315 VFD controller |
wim | 0:2ab901c7d70e | 2 | * Copyright (c) 2016, v01: WH, Initial version, DVDR3510 |
wim | 0:2ab901c7d70e | 3 | * |
wim | 0:2ab901c7d70e | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
wim | 0:2ab901c7d70e | 5 | * of this software and associated documentation files (the "Software"), to deal |
wim | 0:2ab901c7d70e | 6 | * in the Software without restriction, including without limitation the rights |
wim | 0:2ab901c7d70e | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
wim | 0:2ab901c7d70e | 8 | * copies of the Software, and to permit persons to whom the Software is |
wim | 0:2ab901c7d70e | 9 | * furnished to do so, subject to the following conditions: |
wim | 0:2ab901c7d70e | 10 | * |
wim | 0:2ab901c7d70e | 11 | * The above copyright notice and this permission notice shall be included in |
wim | 0:2ab901c7d70e | 12 | * all copies or substantial portions of the Software. |
wim | 0:2ab901c7d70e | 13 | * |
wim | 0:2ab901c7d70e | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
wim | 0:2ab901c7d70e | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
wim | 0:2ab901c7d70e | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
wim | 0:2ab901c7d70e | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
wim | 0:2ab901c7d70e | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
wim | 0:2ab901c7d70e | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
wim | 0:2ab901c7d70e | 20 | * THE SOFTWARE. |
wim | 0:2ab901c7d70e | 21 | */ |
wim | 0:2ab901c7d70e | 22 | #include "mbed.h" |
wim | 0:2ab901c7d70e | 23 | #include "PT6315.h" |
wim | 0:2ab901c7d70e | 24 | |
wim | 0:2ab901c7d70e | 25 | // Select one of the testboards for Princeton PT6315 VFD controller |
wim | 0:2ab901c7d70e | 26 | |
wim | 0:2ab901c7d70e | 27 | #if (DVDR3510_TEST == 1) |
wim | 0:2ab901c7d70e | 28 | // DVDR3510 PT6315 Test |
wim | 0:2ab901c7d70e | 29 | #include "mbed.h" |
wim | 0:2ab901c7d70e | 30 | #include "PT6315.h" |
wim | 0:2ab901c7d70e | 31 | #include "Font_16Seg.h" |
wim | 0:2ab901c7d70e | 32 | |
wim | 0:2ab901c7d70e | 33 | Serial pc(USBTX, USBRX); |
wim | 0:2ab901c7d70e | 34 | DigitalOut myled(LED1); |
wim | 0:2ab901c7d70e | 35 | |
wim | 0:2ab901c7d70e | 36 | // DisplayData_t size is 12 bytes (4 grids @ max 24 segments) ... 36 bytes (12 grids @ max 16 segments) |
wim | 0:2ab901c7d70e | 37 | // DisplayData_t size for DVDR3510 is 33 bytes (11 Grids @ 17 Segments) |
wim | 0:2ab901c7d70e | 38 | PT6315::DisplayData_t all_str = {0xFF,0xFF,0x01, 0xFF,0xFF,0x01, 0xFF,0xFF,0x01, 0xFF,0xFF,0x01, \ |
wim | 0:2ab901c7d70e | 39 | 0xFF,0xFF,0x01, 0xFF,0xFF,0x01, 0xFF,0xFF,0x01, 0xFF,0xFF,0x01, \ |
wim | 0:2ab901c7d70e | 40 | 0xFF,0xFF,0x01, 0xFF,0xFF,0x01, 0xFF,0xFF,0x01}; |
wim | 0:2ab901c7d70e | 41 | |
wim | 0:2ab901c7d70e | 42 | PT6315::DisplayData_t cls_str = {0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ |
wim | 0:2ab901c7d70e | 43 | 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ |
wim | 0:2ab901c7d70e | 44 | 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00}; |
wim | 0:2ab901c7d70e | 45 | |
wim | 0:2ab901c7d70e | 46 | PT6315::DisplayData_t bye_str = {LO(C16_B),MD(C16_B),HI(C16_B), LO(C16_Y),MD(C16_Y),HI(C16_Y), LO(C16_E),MD(C16_E),HI(C16_E), 0x00,0x00,0x00, \ |
wim | 0:2ab901c7d70e | 47 | 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ |
wim | 0:2ab901c7d70e | 48 | 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00}; |
wim | 0:2ab901c7d70e | 49 | |
wim | 0:2ab901c7d70e | 50 | PT6315::DisplayData_t hello_str = {LO(C16_H),MD(C16_H),HI(C16_H), LO(C16_E),MD(C16_E),HI(C16_E), LO(C16_L),MD(C16_L),HI(C16_L), LO(C16_L),MD(C16_L),HI(C16_L), \ |
wim | 0:2ab901c7d70e | 51 | LO(C16_O),MD(C16_O),HI(C16_O), 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ |
wim | 0:2ab901c7d70e | 52 | 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00}; |
wim | 0:2ab901c7d70e | 53 | |
wim | 0:2ab901c7d70e | 54 | PT6315::DisplayData_t mbed_str = {LO(C16_M),MD(C16_M),HI(C16_M), LO(C16_B),MD(C16_B),HI(C16_B), LO(C16_E),MD(C16_E),HI(C16_E), LO(C16_D),MD(C16_D),HI(C16_D), \ |
wim | 0:2ab901c7d70e | 55 | 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ |
wim | 0:2ab901c7d70e | 56 | 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00}; |
wim | 0:2ab901c7d70e | 57 | |
wim | 0:2ab901c7d70e | 58 | // KeyData_t size is 3 bytes |
wim | 0:2ab901c7d70e | 59 | PT6315::KeyData_t keydata; |
wim | 0:2ab901c7d70e | 60 | |
wim | 0:2ab901c7d70e | 61 | //PT6315_DVDR3510 declaration, Setting 12 Grids @ 16 Segments |
wim | 0:2ab901c7d70e | 62 | PT6315_DVDR3510 DVDR3510(p5,p6,p7, p8); |
wim | 0:2ab901c7d70e | 63 | |
wim | 0:2ab901c7d70e | 64 | char cmd, bits; |
wim | 0:2ab901c7d70e | 65 | int main() { |
wim | 0:2ab901c7d70e | 66 | |
wim | 0:2ab901c7d70e | 67 | pc.printf("Hello World\r\n"); // |
wim | 0:2ab901c7d70e | 68 | |
wim | 0:2ab901c7d70e | 69 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 70 | DVDR3510.writeData(all_str); |
wim | 0:2ab901c7d70e | 71 | wait(4); |
wim | 0:2ab901c7d70e | 72 | DVDR3510.setBrightness(PT6315_BRT3); |
wim | 0:2ab901c7d70e | 73 | wait(1); |
wim | 0:2ab901c7d70e | 74 | DVDR3510.setBrightness(PT6315_BRT0); |
wim | 0:2ab901c7d70e | 75 | wait(1); |
wim | 0:2ab901c7d70e | 76 | DVDR3510.setBrightness(PT6315_BRT7); |
wim | 0:2ab901c7d70e | 77 | |
wim | 0:2ab901c7d70e | 78 | while (1) { |
wim | 0:2ab901c7d70e | 79 | |
wim | 0:2ab901c7d70e | 80 | // Check and read keydata |
wim | 0:2ab901c7d70e | 81 | if (DVDR3510.getKeys(&keydata)) { |
wim | 0:2ab901c7d70e | 82 | pc.printf("Keydata 0..3 = 0x%02x 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2], keydata[3]); |
wim | 0:2ab901c7d70e | 83 | |
wim | 0:2ab901c7d70e | 84 | if (keydata[1] == 0x20) { //dub |
wim | 0:2ab901c7d70e | 85 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 86 | DVDR3510.writeData(all_str); |
wim | 0:2ab901c7d70e | 87 | } |
wim | 0:2ab901c7d70e | 88 | |
wim | 0:2ab901c7d70e | 89 | if (keydata[2] == 0x01) { //up |
wim | 0:2ab901c7d70e | 90 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 91 | DVDR3510.writeData(cls_str); |
wim | 0:2ab901c7d70e | 92 | #if(1) |
wim | 0:2ab901c7d70e | 93 | //test to show all segs |
wim | 0:2ab901c7d70e | 94 | pc.printf("Show all segs\r\n"); |
wim | 0:2ab901c7d70e | 95 | wait(1); |
wim | 0:2ab901c7d70e | 96 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 97 | |
wim | 0:2ab901c7d70e | 98 | for (int i=0; i<PT6315_DISPLAY_MEM; i++) { |
wim | 0:2ab901c7d70e | 99 | for (int bit=0; bit<8; bit++) { |
wim | 0:2ab901c7d70e | 100 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 101 | |
wim | 0:2ab901c7d70e | 102 | bits = 0x01 << bit; |
wim | 0:2ab901c7d70e | 103 | DVDR3510.writeData(i, bits); |
wim | 0:2ab901c7d70e | 104 | |
wim | 0:2ab901c7d70e | 105 | pc.printf("Idx = %d, Bits = 0x%02x\r\n", i, bits); |
wim | 0:2ab901c7d70e | 106 | // wait(0.5); |
wim | 0:2ab901c7d70e | 107 | cmd = pc.getc(); // wait for key |
wim | 0:2ab901c7d70e | 108 | } |
wim | 0:2ab901c7d70e | 109 | } |
wim | 0:2ab901c7d70e | 110 | pc.printf("Show all segs done\r\n"); |
wim | 0:2ab901c7d70e | 111 | #endif |
wim | 0:2ab901c7d70e | 112 | } |
wim | 0:2ab901c7d70e | 113 | |
wim | 0:2ab901c7d70e | 114 | |
wim | 0:2ab901c7d70e | 115 | if (keydata[1] == 0x10) { //down |
wim | 0:2ab901c7d70e | 116 | |
wim | 0:2ab901c7d70e | 117 | #if(0) |
wim | 0:2ab901c7d70e | 118 | //test to show all digits (base is 10) |
wim | 0:2ab901c7d70e | 119 | pc.printf("Show all digits\r\n"); |
wim | 0:2ab901c7d70e | 120 | wait(1); |
wim | 0:2ab901c7d70e | 121 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 122 | |
wim | 0:2ab901c7d70e | 123 | int val = 1; |
wim | 0:2ab901c7d70e | 124 | for (int i=0; i<DVDR3510_NR_DIGITS; i++) { |
wim | 0:2ab901c7d70e | 125 | |
wim | 0:2ab901c7d70e | 126 | for (int cnt=0; cnt<10; cnt++) { |
wim | 0:2ab901c7d70e | 127 | DVDR3510.locate(0); |
wim | 0:2ab901c7d70e | 128 | DVDR3510.printf("%08d", (val * cnt)); |
wim | 0:2ab901c7d70e | 129 | |
wim | 0:2ab901c7d70e | 130 | // wait(0.5); |
wim | 0:2ab901c7d70e | 131 | cmd = pc.getc(); // wait for key |
wim | 0:2ab901c7d70e | 132 | } |
wim | 0:2ab901c7d70e | 133 | val = val * 10; |
wim | 0:2ab901c7d70e | 134 | } |
wim | 0:2ab901c7d70e | 135 | pc.printf("Show all digits done\r\n"); |
wim | 0:2ab901c7d70e | 136 | #endif |
wim | 0:2ab901c7d70e | 137 | |
wim | 0:2ab901c7d70e | 138 | #if(1) |
wim | 0:2ab901c7d70e | 139 | //test to show all digits (base is 0x10) |
wim | 0:2ab901c7d70e | 140 | pc.printf("Show all digits\r\n"); |
wim | 0:2ab901c7d70e | 141 | wait(1); |
wim | 0:2ab901c7d70e | 142 | |
wim | 0:2ab901c7d70e | 143 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 144 | DVDR3510.printf("%d", 0); |
wim | 0:2ab901c7d70e | 145 | cmd = pc.getc(); // wait for key |
wim | 0:2ab901c7d70e | 146 | |
wim | 0:2ab901c7d70e | 147 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 148 | DVDR3510.printf("%3.4f", 12.3456); |
wim | 0:2ab901c7d70e | 149 | cmd = pc.getc(); // wait for key |
wim | 0:2ab901c7d70e | 150 | |
wim | 0:2ab901c7d70e | 151 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 152 | DVDR3510.printf("%d", 123456); |
wim | 0:2ab901c7d70e | 153 | cmd = pc.getc(); // wait for key |
wim | 0:2ab901c7d70e | 154 | |
wim | 0:2ab901c7d70e | 155 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 156 | DVDR3510.printf("%08x", 0x0123ABCD); //Note this value needs 64bits |
wim | 0:2ab901c7d70e | 157 | cmd = pc.getc(); // wait for key |
wim | 0:2ab901c7d70e | 158 | |
wim | 0:2ab901c7d70e | 159 | int val = 1; |
wim | 0:2ab901c7d70e | 160 | for (int i=0; i<DVDR3510_NR_DIGITS; i++) { |
wim | 0:2ab901c7d70e | 161 | |
wim | 0:2ab901c7d70e | 162 | for (int cnt=0; cnt<0x10; cnt++) { |
wim | 0:2ab901c7d70e | 163 | DVDR3510.locate(0); |
wim | 0:2ab901c7d70e | 164 | DVDR3510.printf("%08x", (val * cnt)); |
wim | 0:2ab901c7d70e | 165 | // wait(0.5); |
wim | 0:2ab901c7d70e | 166 | cmd = pc.getc(); // wait for key |
wim | 0:2ab901c7d70e | 167 | } |
wim | 0:2ab901c7d70e | 168 | val = val * 0x10; |
wim | 0:2ab901c7d70e | 169 | } |
wim | 0:2ab901c7d70e | 170 | pc.printf("Show all digits done\r\n"); |
wim | 0:2ab901c7d70e | 171 | #endif |
wim | 0:2ab901c7d70e | 172 | |
wim | 0:2ab901c7d70e | 173 | } |
wim | 0:2ab901c7d70e | 174 | |
wim | 0:2ab901c7d70e | 175 | if (keydata[1] == 0x04) { //vcr/dvd |
wim | 0:2ab901c7d70e | 176 | |
wim | 0:2ab901c7d70e | 177 | #if(1) |
wim | 0:2ab901c7d70e | 178 | //test to show all alpha chars |
wim | 0:2ab901c7d70e | 179 | pc.printf("Show all alpha chars\r\n"); |
wim | 0:2ab901c7d70e | 180 | wait(1); |
wim | 0:2ab901c7d70e | 181 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 182 | |
wim | 0:2ab901c7d70e | 183 | for (int i=0; i<26; i++) { |
wim | 0:2ab901c7d70e | 184 | DVDR3510.printf("%c", char(i + 'A')); |
wim | 0:2ab901c7d70e | 185 | // DVDR3510.printf("%c", char(i + 'a')); |
wim | 0:2ab901c7d70e | 186 | wait(0.25); |
wim | 0:2ab901c7d70e | 187 | } |
wim | 0:2ab901c7d70e | 188 | pc.printf("Show all alpha chars done\r\n"); |
wim | 0:2ab901c7d70e | 189 | #endif |
wim | 0:2ab901c7d70e | 190 | |
wim | 0:2ab901c7d70e | 191 | #if(0) |
wim | 0:2ab901c7d70e | 192 | //test to show all chars |
wim | 0:2ab901c7d70e | 193 | pc.printf("Show all chars\r\n"); |
wim | 0:2ab901c7d70e | 194 | wait(1); |
wim | 0:2ab901c7d70e | 195 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 196 | |
wim | 0:2ab901c7d70e | 197 | for (int i=FONT_16S_START; i<FONT_16S_END; i++) { |
wim | 0:2ab901c7d70e | 198 | DVDR3510.printf("%c", char(i)); |
wim | 0:2ab901c7d70e | 199 | // wait(0.25); |
wim | 0:2ab901c7d70e | 200 | cmd = pc.getc(); // wait for key |
wim | 0:2ab901c7d70e | 201 | } |
wim | 0:2ab901c7d70e | 202 | pc.printf("Show all chars done\r\n"); |
wim | 0:2ab901c7d70e | 203 | #endif |
wim | 0:2ab901c7d70e | 204 | } |
wim | 0:2ab901c7d70e | 205 | |
wim | 0:2ab901c7d70e | 206 | if (keydata[3] == 0x08) { //eject |
wim | 0:2ab901c7d70e | 207 | #if(1) |
wim | 0:2ab901c7d70e | 208 | //wheel |
wim | 0:2ab901c7d70e | 209 | for(int cnt=0;cnt<10;cnt++) { |
wim | 0:2ab901c7d70e | 210 | for(int idx=0;idx<8;idx++) { |
wim | 0:2ab901c7d70e | 211 | DVDR3510.setUDC(0, WHEEL_ANI[idx]); |
wim | 0:2ab901c7d70e | 212 | DVDR3510.locate(0); |
wim | 0:2ab901c7d70e | 213 | DVDR3510.printf("%c%c%c%c%c%c%c%c",(char)0,(char)0, (char)0,(char)0, (char)0,(char)0, (char)0,(char)0); |
wim | 0:2ab901c7d70e | 214 | |
wim | 0:2ab901c7d70e | 215 | wait(0.1); |
wim | 0:2ab901c7d70e | 216 | } |
wim | 0:2ab901c7d70e | 217 | } |
wim | 0:2ab901c7d70e | 218 | #endif |
wim | 0:2ab901c7d70e | 219 | } |
wim | 0:2ab901c7d70e | 220 | |
wim | 0:2ab901c7d70e | 221 | if (keydata[3] == 0x20) { //open/close |
wim | 0:2ab901c7d70e | 222 | DVDR3510.cls(); |
wim | 0:2ab901c7d70e | 223 | // 01234567 |
wim | 0:2ab901c7d70e | 224 | DVDR3510.printf("Hi mbed"); |
wim | 0:2ab901c7d70e | 225 | } |
wim | 0:2ab901c7d70e | 226 | |
wim | 0:2ab901c7d70e | 227 | |
wim | 0:2ab901c7d70e | 228 | if (keydata[2] == 0x20) { //rec |
wim | 0:2ab901c7d70e | 229 | |
wim | 0:2ab901c7d70e | 230 | #if(1) |
wim | 0:2ab901c7d70e | 231 | //test to show all icons |
wim | 0:2ab901c7d70e | 232 | pc.printf("Show all icons\r\n"); |
wim | 0:2ab901c7d70e | 233 | wait(1); |
wim | 0:2ab901c7d70e | 234 | DVDR3510.cls(true); // Also clear all Icons |
wim | 0:2ab901c7d70e | 235 | wait(1); |
wim | 0:2ab901c7d70e | 236 | |
wim | 0:2ab901c7d70e | 237 | float delay=0.1; |
wim | 0:2ab901c7d70e | 238 | DVDR3510.setIcon(PT6315_DVDR3510::RCV); wait(delay); |
wim | 0:2ab901c7d70e | 239 | DVDR3510.setIcon(PT6315_DVDR3510::TV); wait(delay); |
wim | 0:2ab901c7d70e | 240 | DVDR3510.setIcon(PT6315_DVDR3510::DRT); wait(delay); |
wim | 0:2ab901c7d70e | 241 | DVDR3510.setIcon(PT6315_DVDR3510::TMR); wait(delay); |
wim | 0:2ab901c7d70e | 242 | DVDR3510.setIcon(PT6315_DVDR3510::COL4); wait(delay); |
wim | 0:2ab901c7d70e | 243 | DVDR3510.setIcon(PT6315_DVDR3510::PRS); wait(delay); |
wim | 0:2ab901c7d70e | 244 | DVDR3510.setIcon(PT6315_DVDR3510::COL6); wait(delay); |
wim | 0:2ab901c7d70e | 245 | DVDR3510.setIcon(PT6315_DVDR3510::DP6); wait(delay); |
wim | 0:2ab901c7d70e | 246 | DVDR3510.setIcon(PT6315_DVDR3510::SAT); wait(delay); |
wim | 0:2ab901c7d70e | 247 | wait(delay); |
wim | 0:2ab901c7d70e | 248 | DVDR3510.clrIcon(PT6315_DVDR3510::RCV); wait(delay); |
wim | 0:2ab901c7d70e | 249 | DVDR3510.clrIcon(PT6315_DVDR3510::TV); wait(delay); |
wim | 0:2ab901c7d70e | 250 | DVDR3510.clrIcon(PT6315_DVDR3510::DRT); wait(delay); |
wim | 0:2ab901c7d70e | 251 | DVDR3510.clrIcon(PT6315_DVDR3510::TMR); wait(delay); |
wim | 0:2ab901c7d70e | 252 | DVDR3510.clrIcon(PT6315_DVDR3510::COL4); wait(delay); |
wim | 0:2ab901c7d70e | 253 | DVDR3510.clrIcon(PT6315_DVDR3510::PRS); wait(delay); |
wim | 0:2ab901c7d70e | 254 | DVDR3510.clrIcon(PT6315_DVDR3510::COL6); wait(delay); |
wim | 0:2ab901c7d70e | 255 | DVDR3510.clrIcon(PT6315_DVDR3510::DP6); wait(delay); |
wim | 0:2ab901c7d70e | 256 | DVDR3510.clrIcon(PT6315_DVDR3510::SAT); wait(delay); |
wim | 0:2ab901c7d70e | 257 | wait(1); |
wim | 0:2ab901c7d70e | 258 | DVDR3510.cls(); // clear all, preserve Icons |
wim | 0:2ab901c7d70e | 259 | pc.printf("Show all icons done\r\n"); |
wim | 0:2ab901c7d70e | 260 | #endif |
wim | 0:2ab901c7d70e | 261 | } |
wim | 0:2ab901c7d70e | 262 | |
wim | 0:2ab901c7d70e | 263 | if (keydata[2] == 0x08) { //prev |
wim | 0:2ab901c7d70e | 264 | //write LEDs off |
wim | 0:2ab901c7d70e | 265 | DVDR3510.setLED(0x07); |
wim | 0:2ab901c7d70e | 266 | } |
wim | 0:2ab901c7d70e | 267 | |
wim | 0:2ab901c7d70e | 268 | if (keydata[2] == 0x80) { //next |
wim | 0:2ab901c7d70e | 269 | //write LEDs on |
wim | 0:2ab901c7d70e | 270 | DVDR3510.setLED(0x00); |
wim | 0:2ab901c7d70e | 271 | } |
wim | 0:2ab901c7d70e | 272 | |
wim | 0:2ab901c7d70e | 273 | if (keydata[3] == 0x02) { //stop |
wim | 0:2ab901c7d70e | 274 | } |
wim | 0:2ab901c7d70e | 275 | |
wim | 0:2ab901c7d70e | 276 | if (keydata[3] == 0x80) { //play |
wim | 0:2ab901c7d70e | 277 | } |
wim | 0:2ab901c7d70e | 278 | |
wim | 0:2ab901c7d70e | 279 | } //if Key |
wim | 0:2ab901c7d70e | 280 | |
wim | 0:2ab901c7d70e | 281 | |
wim | 0:2ab901c7d70e | 282 | |
wim | 0:2ab901c7d70e | 283 | myled = !myled; |
wim | 0:2ab901c7d70e | 284 | wait(0.3); |
wim | 0:2ab901c7d70e | 285 | } //while |
wim | 0:2ab901c7d70e | 286 | } |
wim | 0:2ab901c7d70e | 287 | #endif |
wim | 0:2ab901c7d70e | 288 | |
wim | 0:2ab901c7d70e | 289 | |
wim | 0:2ab901c7d70e | 290 | #if(PT6315_TEST == 1) |
wim | 0:2ab901c7d70e | 291 | // Direct PT6315 Test |
wim | 0:2ab901c7d70e | 292 | #include "mbed.h" |
wim | 0:2ab901c7d70e | 293 | #include "PT6315.h" |
wim | 0:2ab901c7d70e | 294 | |
wim | 0:2ab901c7d70e | 295 | Serial pc(USBTX, USBRX); |
wim | 0:2ab901c7d70e | 296 | DigitalOut myled(LED1); |
wim | 0:2ab901c7d70e | 297 | |
wim | 0:2ab901c7d70e | 298 | // DisplayData_t size is 24 bytes (8 digits @ max 20 segments) ... 48 bytes (16 digits @ max 12 segments) |
wim | 0:2ab901c7d70e | 299 | // DisplayData_t size default is 48 bytes (16 Grids @ 12 Segments) |
wim | 0:2ab901c7d70e | 300 | PT6315::DisplayData_t all_str = {0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, \ |
wim | 0:2ab901c7d70e | 301 | 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, \ |
wim | 0:2ab901c7d70e | 302 | 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, \ |
wim | 0:2ab901c7d70e | 303 | 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00}; |
wim | 0:2ab901c7d70e | 304 | |
wim | 0:2ab901c7d70e | 305 | PT6315::DisplayData_t cls_str = {0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ |
wim | 0:2ab901c7d70e | 306 | 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ |
wim | 0:2ab901c7d70e | 307 | 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00}; |
wim | 0:2ab901c7d70e | 308 | |
wim | 0:2ab901c7d70e | 309 | // KeyData_t size is 6 bytes |
wim | 0:2ab901c7d70e | 310 | PT6315::KeyData_t keydata; |
wim | 0:2ab901c7d70e | 311 | |
wim | 0:2ab901c7d70e | 312 | // Switchdata is 1 byte |
wim | 0:2ab901c7d70e | 313 | char switchdata; |
wim | 0:2ab901c7d70e | 314 | |
wim | 0:2ab901c7d70e | 315 | PT6315 PT6315(p5,p6,p7, p8); |
wim | 0:2ab901c7d70e | 316 | //PT6315 PT6315(p5,p6,p7, p8, PT6315::Grid16_Seg12); |
wim | 0:2ab901c7d70e | 317 | |
wim | 0:2ab901c7d70e | 318 | char cmd, bits; |
wim | 0:2ab901c7d70e | 319 | int main() { |
wim | 0:2ab901c7d70e | 320 | |
wim | 0:2ab901c7d70e | 321 | pc.printf("Hello World\r\n"); // |
wim | 0:2ab901c7d70e | 322 | |
wim | 0:2ab901c7d70e | 323 | PT6315.cls(); |
wim | 0:2ab901c7d70e | 324 | PT6315.writeData(all_str); |
wim | 0:2ab901c7d70e | 325 | wait(4); |
wim | 0:2ab901c7d70e | 326 | PT6315.setBrightness(PT6315_BRT3); |
wim | 0:2ab901c7d70e | 327 | wait(1); |
wim | 0:2ab901c7d70e | 328 | PT6315.setBrightness(PT6315_BRT0); |
wim | 0:2ab901c7d70e | 329 | wait(1); |
wim | 0:2ab901c7d70e | 330 | PT6315.setBrightness(PT6315_BRT7); |
wim | 0:2ab901c7d70e | 331 | |
wim | 0:2ab901c7d70e | 332 | while (1) { |
wim | 0:2ab901c7d70e | 333 | |
wim | 0:2ab901c7d70e | 334 | // Check and read keydata |
wim | 0:2ab901c7d70e | 335 | if (PT6315.getKeys(&keydata)) { |
wim | 0:2ab901c7d70e | 336 | pc.printf("Keydata 0..3 = 0x%02x 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2], keydata[3]); |
wim | 0:2ab901c7d70e | 337 | |
wim | 0:2ab901c7d70e | 338 | if (keydata[0] == 0x01) { //play |
wim | 0:2ab901c7d70e | 339 | PT6315.cls(); |
wim | 0:2ab901c7d70e | 340 | PT6315.writeData(all_str); |
wim | 0:2ab901c7d70e | 341 | } |
wim | 0:2ab901c7d70e | 342 | |
wim | 0:2ab901c7d70e | 343 | if (keydata[0] == 0x02) { //stop |
wim | 0:2ab901c7d70e | 344 | PT6315.cls(); |
wim | 0:2ab901c7d70e | 345 | PT6315.writeData(cls_str); |
wim | 0:2ab901c7d70e | 346 | } |
wim | 0:2ab901c7d70e | 347 | |
wim | 0:2ab901c7d70e | 348 | if (keydata[0] == 0x04) { //open/close |
wim | 0:2ab901c7d70e | 349 | PT6315.cls(); |
wim | 0:2ab901c7d70e | 350 | PT6315.writeData(all_str); |
wim | 0:2ab901c7d70e | 351 | |
wim | 0:2ab901c7d70e | 352 | #if(1) |
wim | 0:2ab901c7d70e | 353 | //test to show all segs |
wim | 0:2ab901c7d70e | 354 | pc.printf("Show all segs\r\n"); |
wim | 0:2ab901c7d70e | 355 | wait(1); |
wim | 0:2ab901c7d70e | 356 | PT6315.cls(); |
wim | 0:2ab901c7d70e | 357 | |
wim | 0:2ab901c7d70e | 358 | for (int i=0; i<PT6315_DISPLAY_MEM; i++) { |
wim | 0:2ab901c7d70e | 359 | for (int bit=0; bit<8; bit++) { |
wim | 0:2ab901c7d70e | 360 | PT6315.cls(); |
wim | 0:2ab901c7d70e | 361 | |
wim | 0:2ab901c7d70e | 362 | bits = 0x01 << bit; |
wim | 0:2ab901c7d70e | 363 | PT6315.writeData(i, bits); |
wim | 0:2ab901c7d70e | 364 | |
wim | 0:2ab901c7d70e | 365 | pc.printf("Idx = %d, Bits = 0x%02x\r\n", i, bits); |
wim | 0:2ab901c7d70e | 366 | // wait(0.5); |
wim | 0:2ab901c7d70e | 367 | cmd = pc.getc(); // wait for key |
wim | 0:2ab901c7d70e | 368 | } |
wim | 0:2ab901c7d70e | 369 | } |
wim | 0:2ab901c7d70e | 370 | pc.printf("Show all segs done\r\n"); |
wim | 0:2ab901c7d70e | 371 | #endif |
wim | 0:2ab901c7d70e | 372 | |
wim | 0:2ab901c7d70e | 373 | } |
wim | 0:2ab901c7d70e | 374 | |
wim | 0:2ab901c7d70e | 375 | } //if Key |
wim | 0:2ab901c7d70e | 376 | |
wim | 0:2ab901c7d70e | 377 | myled = !myled; |
wim | 0:2ab901c7d70e | 378 | wait(0.3); |
wim | 0:2ab901c7d70e | 379 | } //while |
wim | 0:2ab901c7d70e | 380 | } |
wim | 0:2ab901c7d70e | 381 | #endif |