Wim Huiskamp
/
mbed_PT6964
Test program for Princeton PT6964 LED controller library.
See here for more information.
main.cpp@0:58787244fcec, 2015-11-21 (annotated)
- Committer:
- wim
- Date:
- Sat Nov 21 16:43:26 2015 +0000
- Revision:
- 0:58787244fcec
- Child:
- 2:c6897ab055a2
First version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 0:58787244fcec | 1 | /* mbed PT6964 Test program, for PT6964 LED controller |
wim | 0:58787244fcec | 2 | * Copyright (c) 2015, v01: WH, Initial version |
wim | 0:58787244fcec | 3 | * |
wim | 0:58787244fcec | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
wim | 0:58787244fcec | 5 | * of this software and associated documentation files (the "Software"), to deal |
wim | 0:58787244fcec | 6 | * in the Software without restriction, including without limitation the rights |
wim | 0:58787244fcec | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
wim | 0:58787244fcec | 8 | * copies of the Software, and to permit persons to whom the Software is |
wim | 0:58787244fcec | 9 | * furnished to do so, subject to the following conditions: |
wim | 0:58787244fcec | 10 | * |
wim | 0:58787244fcec | 11 | * The above copyright notice and this permission notice shall be included in |
wim | 0:58787244fcec | 12 | * all copies or substantial portions of the Software. |
wim | 0:58787244fcec | 13 | * |
wim | 0:58787244fcec | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
wim | 0:58787244fcec | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
wim | 0:58787244fcec | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
wim | 0:58787244fcec | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
wim | 0:58787244fcec | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
wim | 0:58787244fcec | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
wim | 0:58787244fcec | 20 | * THE SOFTWARE. |
wim | 0:58787244fcec | 21 | */ |
wim | 0:58787244fcec | 22 | #include "mbed.h" |
wim | 0:58787244fcec | 23 | #include "PT6964.h" |
wim | 0:58787244fcec | 24 | |
wim | 0:58787244fcec | 25 | Serial pc(USBTX, USBRX); |
wim | 0:58787244fcec | 26 | DigitalOut myled(LED1); |
wim | 0:58787244fcec | 27 | |
wim | 0:58787244fcec | 28 | #if(1) |
wim | 0:58787244fcec | 29 | //High level Control PT9664 for DVD538 |
wim | 0:58787244fcec | 30 | |
wim | 0:58787244fcec | 31 | PT6964_DVD538A::DisplayData_t all_str = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F}; |
wim | 0:58787244fcec | 32 | |
wim | 0:58787244fcec | 33 | // KeyData_t size is 5 bytes |
wim | 0:58787244fcec | 34 | PT6964_DVD538A::KeyData_t keydata; |
wim | 0:58787244fcec | 35 | |
wim | 0:58787244fcec | 36 | // PT6964 declaration, Default setting 7 Grids @ 10 Segments |
wim | 0:58787244fcec | 37 | PT6964_DVD538A PT6964_dvd538a(p5,p6,p7, p8); |
wim | 0:58787244fcec | 38 | |
wim | 0:58787244fcec | 39 | int main() { |
wim | 0:58787244fcec | 40 | |
wim | 0:58787244fcec | 41 | pc.printf("Hello World\r\n"); // |
wim | 0:58787244fcec | 42 | |
wim | 0:58787244fcec | 43 | PT6964_dvd538a.cls(); |
wim | 0:58787244fcec | 44 | PT6964_dvd538a.writeData(all_str); |
wim | 0:58787244fcec | 45 | wait(4); |
wim | 0:58787244fcec | 46 | PT6964_dvd538a.setBrightness(PT6964_BRT3); |
wim | 0:58787244fcec | 47 | wait(1); |
wim | 0:58787244fcec | 48 | PT6964_dvd538a.setBrightness(PT6964_BRT0); |
wim | 0:58787244fcec | 49 | wait(1); |
wim | 0:58787244fcec | 50 | PT6964_dvd538a.setBrightness(PT6964_BRT3); |
wim | 0:58787244fcec | 51 | |
wim | 0:58787244fcec | 52 | while (1) { |
wim | 0:58787244fcec | 53 | |
wim | 0:58787244fcec | 54 | // Check and read keydata |
wim | 0:58787244fcec | 55 | if (PT6964_dvd538a.getKeys(&keydata)) { |
wim | 0:58787244fcec | 56 | pc.printf("Keydata 0..4 = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2], keydata[3], keydata[4]); |
wim | 0:58787244fcec | 57 | |
wim | 0:58787244fcec | 58 | if (keydata[0] == 0x01) { //sw1 L/R |
wim | 0:58787244fcec | 59 | // PT6964_dvd538a.cls(); |
wim | 0:58787244fcec | 60 | PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_LD1); |
wim | 0:58787244fcec | 61 | PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_LD2); |
wim | 0:58787244fcec | 62 | PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_CD); |
wim | 0:58787244fcec | 63 | PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_DVD); |
wim | 0:58787244fcec | 64 | PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_PSE); |
wim | 0:58787244fcec | 65 | PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_PLY); |
wim | 0:58787244fcec | 66 | PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_COL); |
wim | 0:58787244fcec | 67 | PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_MP4); |
wim | 0:58787244fcec | 68 | PT6964_dvd538a.setIcon(PT6964_DVD538A::Grid1_MP3); |
wim | 0:58787244fcec | 69 | |
wim | 0:58787244fcec | 70 | } |
wim | 0:58787244fcec | 71 | |
wim | 0:58787244fcec | 72 | if (keydata[0] == 0x02) { //sw2 Stop |
wim | 0:58787244fcec | 73 | PT6964_dvd538a.cls(); |
wim | 0:58787244fcec | 74 | |
wim | 0:58787244fcec | 75 | } |
wim | 0:58787244fcec | 76 | |
wim | 0:58787244fcec | 77 | if (keydata[0] == 0x08) { //sw4 Play |
wim | 0:58787244fcec | 78 | PT6964_dvd538a.cls(); |
wim | 0:58787244fcec | 79 | // for (int i=0; i<16; i++) { |
wim | 0:58787244fcec | 80 | for (int i=0x00; i<=0xFF; i++) { |
wim | 0:58787244fcec | 81 | PT6964_dvd538a.locate(0); |
wim | 0:58787244fcec | 82 | PT6964_dvd538a.printf("%04x", i); |
wim | 0:58787244fcec | 83 | // PT6964_dvd538a.printf("%04X", i); |
wim | 0:58787244fcec | 84 | wait(0.2); |
wim | 0:58787244fcec | 85 | } |
wim | 0:58787244fcec | 86 | } |
wim | 0:58787244fcec | 87 | |
wim | 0:58787244fcec | 88 | if (keydata[0] == 0x10) { //sw3 Open |
wim | 0:58787244fcec | 89 | // PT6964_dvd538a.cls(); |
wim | 0:58787244fcec | 90 | PT6964_dvd538a.clrIcon(PT6964_DVD538A::Grid1_LD1); |
wim | 0:58787244fcec | 91 | PT6964_dvd538a.clrIcon(PT6964_DVD538A::Grid1_MP3); |
wim | 0:58787244fcec | 92 | } |
wim | 0:58787244fcec | 93 | |
wim | 0:58787244fcec | 94 | } //if |
wim | 0:58787244fcec | 95 | |
wim | 0:58787244fcec | 96 | myled = !myled; |
wim | 0:58787244fcec | 97 | wait(0.3); |
wim | 0:58787244fcec | 98 | } //while |
wim | 0:58787244fcec | 99 | } |
wim | 0:58787244fcec | 100 | |
wim | 0:58787244fcec | 101 | |
wim | 0:58787244fcec | 102 | #else |
wim | 0:58787244fcec | 103 | //Direct control of PT9664 for DVD538 |
wim | 0:58787244fcec | 104 | |
wim | 0:58787244fcec | 105 | // DisplayData_t size is 8 bytes (4 digits @ 13 segments) OR 10 bytes (5 digits @ 12 segments) OR |
wim | 0:58787244fcec | 106 | // 12 bytes (6 digits @ 11 segments) OR 14 bytes (7 digits @ 10 segments) |
wim | 0:58787244fcec | 107 | PT6964::DisplayData_t mbed_str = {0xDA,0x00, 0x7C,0x00, 0x3C,0x01, 0xF6,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:58787244fcec | 108 | PT6964::DisplayData_t all_str = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F}; |
wim | 0:58787244fcec | 109 | PT6964::DisplayData_t bye_str = {0x7C,0x00, 0xEC,0x00, 0x3C,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:58787244fcec | 110 | PT6964::DisplayData_t hello_str = {0xDC,0x00, 0x3C,0x01, 0x38,0x00, 0x38,0x00, 0xF8,0x01, 0x00,0x00, 0x00,0x00}; |
wim | 0:58787244fcec | 111 | PT6964::DisplayData_t tst_str; |
wim | 0:58787244fcec | 112 | #if(0) |
wim | 0:58787244fcec | 113 | PT6964::DisplayData_t hello1_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0xF8,0x03, 0x00,0x00, 0x00,0x00}; |
wim | 0:58787244fcec | 114 | PT6964::DisplayData_t hello2_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0xF8,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:58787244fcec | 115 | PT6964::DisplayData_t hello3_str = {0x00,0x00, 0x00,0x00, 0xF8,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:58787244fcec | 116 | PT6964::DisplayData_t hello4_str = {0x00,0x00, 0xF8,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:58787244fcec | 117 | #endif |
wim | 0:58787244fcec | 118 | PT6964::DisplayData_t hello1_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x30,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:58787244fcec | 119 | PT6964::DisplayData_t hello2_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0xE8,0x02, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:58787244fcec | 120 | PT6964::DisplayData_t hello3_str = {0x00,0x00, 0x00,0x00, 0x78,0x02, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:58787244fcec | 121 | PT6964::DisplayData_t hello4_str = {0x00,0x00, 0x30,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:58787244fcec | 122 | |
wim | 0:58787244fcec | 123 | |
wim | 0:58787244fcec | 124 | // KeyData_t size is 5 bytes |
wim | 0:58787244fcec | 125 | PT6964::KeyData_t keydata; |
wim | 0:58787244fcec | 126 | |
wim | 0:58787244fcec | 127 | // PT6964 declaration, Default setting 7 Grids @ 10 Segments |
wim | 0:58787244fcec | 128 | PT6964 PT6964(p5,p6,p7, p8); |
wim | 0:58787244fcec | 129 | |
wim | 0:58787244fcec | 130 | int main() { |
wim | 0:58787244fcec | 131 | |
wim | 0:58787244fcec | 132 | pc.printf("Hello World\r\n"); // |
wim | 0:58787244fcec | 133 | |
wim | 0:58787244fcec | 134 | PT6964.cls(); |
wim | 0:58787244fcec | 135 | PT6964.writeData(all_str); |
wim | 0:58787244fcec | 136 | wait(4); |
wim | 0:58787244fcec | 137 | PT6964.setBrightness(PT6964_BRT3); |
wim | 0:58787244fcec | 138 | PT6964.writeData(mbed_str); |
wim | 0:58787244fcec | 139 | wait(1); |
wim | 0:58787244fcec | 140 | PT6964.setBrightness(PT6964_BRT0); |
wim | 0:58787244fcec | 141 | wait(1); |
wim | 0:58787244fcec | 142 | PT6964.setBrightness(PT6964_BRT3); |
wim | 0:58787244fcec | 143 | |
wim | 0:58787244fcec | 144 | while (1) { |
wim | 0:58787244fcec | 145 | |
wim | 0:58787244fcec | 146 | // Check and read keydata |
wim | 0:58787244fcec | 147 | if (PT6964.getKeys(&keydata)) { |
wim | 0:58787244fcec | 148 | pc.printf("Keydata 0..4 = 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2], keydata[3], keydata[4]); |
wim | 0:58787244fcec | 149 | |
wim | 0:58787244fcec | 150 | if (keydata[0] == 0x01) { //sw1 L/R |
wim | 0:58787244fcec | 151 | PT6964.cls(); |
wim | 0:58787244fcec | 152 | PT6964.writeData(hello1_str); |
wim | 0:58787244fcec | 153 | |
wim | 0:58787244fcec | 154 | #if(0) |
wim | 0:58787244fcec | 155 | for (int idx=0; idx < PT6964_DISPLAY_MEM;idx++){ |
wim | 0:58787244fcec | 156 | tst_str[idx]=0x00; |
wim | 0:58787244fcec | 157 | } |
wim | 0:58787244fcec | 158 | // tst_str[0]=0x01; //LD2 |
wim | 0:58787244fcec | 159 | // tst_str[0]=0x10; //DVD |
wim | 0:58787244fcec | 160 | // tst_str[1]=0x01; // MP4 |
wim | 0:58787244fcec | 161 | // tst_str[2]=0x08; // D4 |
wim | 0:58787244fcec | 162 | tst_str[2]=0x80; // E4 |
wim | 0:58787244fcec | 163 | PT6964.writeData(tst_str); |
wim | 0:58787244fcec | 164 | #endif |
wim | 0:58787244fcec | 165 | } |
wim | 0:58787244fcec | 166 | |
wim | 0:58787244fcec | 167 | if (keydata[0] == 0x02) { //sw2 Stop |
wim | 0:58787244fcec | 168 | PT6964.cls(); |
wim | 0:58787244fcec | 169 | PT6964.writeData(hello2_str); |
wim | 0:58787244fcec | 170 | |
wim | 0:58787244fcec | 171 | #if(0) |
wim | 0:58787244fcec | 172 | for (int idx=0; idx < PT6964_DISPLAY_MEM;idx++){ |
wim | 0:58787244fcec | 173 | tst_str[idx]=0x00; |
wim | 0:58787244fcec | 174 | } |
wim | 0:58787244fcec | 175 | // tst_str[0]=0x02; //LD1 |
wim | 0:58787244fcec | 176 | // tst_str[0]=0x20; // pause |
wim | 0:58787244fcec | 177 | // tst_str[1]=0x02; // MP3 |
wim | 0:58787244fcec | 178 | // tst_str[2]=0x10; // C4 |
wim | 0:58787244fcec | 179 | tst_str[3]=0x01; // F4 |
wim | 0:58787244fcec | 180 | PT6964.writeData(tst_str); |
wim | 0:58787244fcec | 181 | #endif |
wim | 0:58787244fcec | 182 | } |
wim | 0:58787244fcec | 183 | |
wim | 0:58787244fcec | 184 | if (keydata[0] == 0x08) { //sw4 Play |
wim | 0:58787244fcec | 185 | PT6964.cls(); |
wim | 0:58787244fcec | 186 | PT6964.writeData(hello3_str); |
wim | 0:58787244fcec | 187 | |
wim | 0:58787244fcec | 188 | #if(0) |
wim | 0:58787244fcec | 189 | for (int idx=0; idx < PT6964_DISPLAY_MEM;idx++){ |
wim | 0:58787244fcec | 190 | tst_str[idx]=0x00; |
wim | 0:58787244fcec | 191 | } |
wim | 0:58787244fcec | 192 | // tst_str[0]=0x04; // nc |
wim | 0:58787244fcec | 193 | // tst_str[0]=0x40; // Play arrow |
wim | 0:58787244fcec | 194 | // tst_str[2]=0x01; // nc |
wim | 0:58787244fcec | 195 | // tst_str[2]=0x20; // B4 |
wim | 0:58787244fcec | 196 | tst_str[3]=0x02; // G4 |
wim | 0:58787244fcec | 197 | PT6964.writeData(tst_str); |
wim | 0:58787244fcec | 198 | #endif |
wim | 0:58787244fcec | 199 | |
wim | 0:58787244fcec | 200 | } |
wim | 0:58787244fcec | 201 | |
wim | 0:58787244fcec | 202 | if (keydata[0] == 0x10) { //sw3 Open |
wim | 0:58787244fcec | 203 | PT6964.cls(); |
wim | 0:58787244fcec | 204 | PT6964.writeData(hello4_str); |
wim | 0:58787244fcec | 205 | |
wim | 0:58787244fcec | 206 | #if(0) |
wim | 0:58787244fcec | 207 | for (int idx=0; idx < PT6964_DISPLAY_MEM;idx++){ |
wim | 0:58787244fcec | 208 | tst_str[idx]=0x00; |
wim | 0:58787244fcec | 209 | } |
wim | 0:58787244fcec | 210 | // tst_str[0]=0x08; //CD |
wim | 0:58787244fcec | 211 | // tst_str[0]=0x80; // colon |
wim | 0:58787244fcec | 212 | // tst_str[2]=0x02; // nc |
wim | 0:58787244fcec | 213 | // tst_str[2]=0x40; // A4 |
wim | 0:58787244fcec | 214 | tst_str[3]=0x04; // nc |
wim | 0:58787244fcec | 215 | PT6964.writeData(tst_str); |
wim | 0:58787244fcec | 216 | #endif |
wim | 0:58787244fcec | 217 | } |
wim | 0:58787244fcec | 218 | |
wim | 0:58787244fcec | 219 | } //if |
wim | 0:58787244fcec | 220 | |
wim | 0:58787244fcec | 221 | myled = !myled; |
wim | 0:58787244fcec | 222 | wait(0.3); |
wim | 0:58787244fcec | 223 | } //while |
wim | 0:58787244fcec | 224 | } |
wim | 0:58787244fcec | 225 | #endif |