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