Test program for Princeton PT6964 LED controller library.

Dependencies:   PT6964 mbed

See here for more information.

Committer:
wim
Date:
Thu Jan 14 20:10:05 2016 +0000
Revision:
3:d7990de75130
Parent:
2:c6897ab055a2
Refactored display and keyboard defines

Who changed what in which revision?

UserRevisionLine numberNew 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 2:c6897ab055a2 3 * 2016, v03: WH, updated Icon handling, UDCs and _putc()
wim 0:58787244fcec 4 *
wim 0:58787244fcec 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
wim 0:58787244fcec 6 * of this software and associated documentation files (the "Software"), to deal
wim 0:58787244fcec 7 * in the Software without restriction, including without limitation the rights
wim 0:58787244fcec 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
wim 0:58787244fcec 9 * copies of the Software, and to permit persons to whom the Software is
wim 0:58787244fcec 10 * furnished to do so, subject to the following conditions:
wim 0:58787244fcec 11 *
wim 0:58787244fcec 12 * The above copyright notice and this permission notice shall be included in
wim 0:58787244fcec 13 * all copies or substantial portions of the Software.
wim 0:58787244fcec 14 *
wim 0:58787244fcec 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
wim 0:58787244fcec 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
wim 0:58787244fcec 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
wim 0:58787244fcec 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
wim 0:58787244fcec 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
wim 0:58787244fcec 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
wim 0:58787244fcec 21 * THE SOFTWARE.
wim 0:58787244fcec 22 */
wim 0:58787244fcec 23 #include "mbed.h"
wim 0:58787244fcec 24 #include "PT6964.h"
wim 0:58787244fcec 25
wim 0:58787244fcec 26 Serial pc(USBTX, USBRX);
wim 0:58787244fcec 27 DigitalOut myled(LED1);
wim 0:58787244fcec 28
wim 2:c6897ab055a2 29 // Select one of the testboards for Princeton PT6964 LED controller
wim 2:c6897ab055a2 30 #define PT6964_TEST 0
wim 2:c6897ab055a2 31 #define DVD538A_TEST 1
wim 2:c6897ab055a2 32
wim 2:c6897ab055a2 33 #if (DVD538A_TEST == 1)
wim 2:c6897ab055a2 34 //High level Control PT9664 for DVD538A
wim 0:58787244fcec 35
wim 0:58787244fcec 36 PT6964_DVD538A::DisplayData_t all_str = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F};
wim 2:c6897ab055a2 37 PT6964_DVD538A::DisplayData_t bye_str = {LO(C7_B),HI(C7_B), LO(C7_Y),HI(C7_Y), LO(C7_E),HI(C7_E), 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
wim 0:58787244fcec 38
wim 0:58787244fcec 39 // KeyData_t size is 5 bytes
wim 0:58787244fcec 40 PT6964_DVD538A::KeyData_t keydata;
wim 0:58787244fcec 41
wim 0:58787244fcec 42 // PT6964 declaration, Default setting 7 Grids @ 10 Segments
wim 0:58787244fcec 43 PT6964_DVD538A PT6964_dvd538a(p5,p6,p7, p8);
wim 0:58787244fcec 44
wim 2:c6897ab055a2 45 char cmd;
wim 0:58787244fcec 46 int main() {
wim 0:58787244fcec 47
wim 0:58787244fcec 48 pc.printf("Hello World\r\n"); //
wim 0:58787244fcec 49
wim 0:58787244fcec 50 PT6964_dvd538a.cls();
wim 0:58787244fcec 51 PT6964_dvd538a.writeData(all_str);
wim 0:58787244fcec 52 wait(4);
wim 0:58787244fcec 53 PT6964_dvd538a.setBrightness(PT6964_BRT3);
wim 0:58787244fcec 54 wait(1);
wim 0:58787244fcec 55 PT6964_dvd538a.setBrightness(PT6964_BRT0);
wim 0:58787244fcec 56 wait(1);
wim 0:58787244fcec 57 PT6964_dvd538a.setBrightness(PT6964_BRT3);
wim 0:58787244fcec 58
wim 0:58787244fcec 59 while (1) {
wim 0:58787244fcec 60
wim 0:58787244fcec 61 // Check and read keydata
wim 0:58787244fcec 62 if (PT6964_dvd538a.getKeys(&keydata)) {
wim 0:58787244fcec 63 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 64
wim 0:58787244fcec 65 if (keydata[0] == 0x01) { //sw1 L/R
wim 2:c6897ab055a2 66 float delay = 0.2;
wim 2:c6897ab055a2 67
wim 2:c6897ab055a2 68 PT6964_dvd538a.cls();
wim 2:c6897ab055a2 69 PT6964_dvd538a.setIcon(PT6964_DVD538A::LD1); wait(delay);
wim 2:c6897ab055a2 70 PT6964_dvd538a.setIcon(PT6964_DVD538A::LD2); wait(delay);
wim 2:c6897ab055a2 71 PT6964_dvd538a.setIcon(PT6964_DVD538A::CD); wait(delay);
wim 2:c6897ab055a2 72 PT6964_dvd538a.setIcon(PT6964_DVD538A::DVD); wait(delay);
wim 2:c6897ab055a2 73 PT6964_dvd538a.setIcon(PT6964_DVD538A::PSE); wait(delay);
wim 2:c6897ab055a2 74 PT6964_dvd538a.setIcon(PT6964_DVD538A::PLY); wait(delay);
wim 2:c6897ab055a2 75 PT6964_dvd538a.setIcon(PT6964_DVD538A::COL2); wait(delay);
wim 2:c6897ab055a2 76 PT6964_dvd538a.setIcon(PT6964_DVD538A::MP4); wait(delay);
wim 2:c6897ab055a2 77 PT6964_dvd538a.setIcon(PT6964_DVD538A::MP3); wait(delay);
wim 2:c6897ab055a2 78
wim 2:c6897ab055a2 79 PT6964_dvd538a.clrIcon(PT6964_DVD538A::LD1); wait(delay);
wim 2:c6897ab055a2 80 PT6964_dvd538a.clrIcon(PT6964_DVD538A::LD2); wait(delay);
wim 2:c6897ab055a2 81 PT6964_dvd538a.clrIcon(PT6964_DVD538A::CD); wait(delay);
wim 2:c6897ab055a2 82 PT6964_dvd538a.clrIcon(PT6964_DVD538A::DVD); wait(delay);
wim 2:c6897ab055a2 83 PT6964_dvd538a.clrIcon(PT6964_DVD538A::PSE); wait(delay);
wim 2:c6897ab055a2 84 PT6964_dvd538a.clrIcon(PT6964_DVD538A::PLY); wait(delay);
wim 2:c6897ab055a2 85 PT6964_dvd538a.clrIcon(PT6964_DVD538A::COL2); wait(delay);
wim 2:c6897ab055a2 86 PT6964_dvd538a.clrIcon(PT6964_DVD538A::MP4); wait(delay);
wim 2:c6897ab055a2 87 PT6964_dvd538a.clrIcon(PT6964_DVD538A::MP3); wait(delay);
wim 0:58787244fcec 88 }
wim 0:58787244fcec 89
wim 0:58787244fcec 90 if (keydata[0] == 0x02) { //sw2 Stop
wim 0:58787244fcec 91 PT6964_dvd538a.cls();
wim 0:58787244fcec 92 }
wim 0:58787244fcec 93
wim 0:58787244fcec 94 if (keydata[0] == 0x08) { //sw4 Play
wim 0:58787244fcec 95 PT6964_dvd538a.cls();
wim 0:58787244fcec 96 // for (int i=0; i<16; i++) {
wim 0:58787244fcec 97 for (int i=0x00; i<=0xFF; i++) {
wim 0:58787244fcec 98 PT6964_dvd538a.locate(0);
wim 0:58787244fcec 99 PT6964_dvd538a.printf("%04x", i);
wim 0:58787244fcec 100 // PT6964_dvd538a.printf("%04X", i);
wim 0:58787244fcec 101 wait(0.2);
wim 0:58787244fcec 102 }
wim 0:58787244fcec 103 }
wim 0:58787244fcec 104
wim 0:58787244fcec 105 if (keydata[0] == 0x10) { //sw3 Open
wim 2:c6897ab055a2 106 #if(1)
wim 2:c6897ab055a2 107 //test to show all digits (base is 0x10)
wim 2:c6897ab055a2 108 pc.printf("Show all hex digits\r\n");
wim 2:c6897ab055a2 109 wait(1);
wim 2:c6897ab055a2 110 PT6964_dvd538a.cls();
wim 2:c6897ab055a2 111
wim 2:c6897ab055a2 112 PT6964_dvd538a.printf("%04x", 0x01AB);
wim 2:c6897ab055a2 113 cmd = pc.getc(); // wait for key
wim 2:c6897ab055a2 114
wim 2:c6897ab055a2 115 int val = 1;
wim 2:c6897ab055a2 116 for (int i=0; i<DVD538A_NR_DIGITS; i++) {
wim 2:c6897ab055a2 117
wim 2:c6897ab055a2 118 for (int cnt=0; cnt<0x10; cnt++) {
wim 2:c6897ab055a2 119 PT6964_dvd538a.locate(0);
wim 2:c6897ab055a2 120 PT6964_dvd538a.printf("%04x", (val * cnt));
wim 2:c6897ab055a2 121
wim 2:c6897ab055a2 122 // wait(0.5);
wim 2:c6897ab055a2 123 cmd = pc.getc(); // wait for key
wim 2:c6897ab055a2 124 }
wim 2:c6897ab055a2 125 val = val * 0x10;
wim 2:c6897ab055a2 126 }
wim 2:c6897ab055a2 127 pc.printf("\r\nShow all hex digits done\r\n");
wim 2:c6897ab055a2 128 #endif
wim 0:58787244fcec 129 }
wim 0:58787244fcec 130
wim 0:58787244fcec 131 } //if
wim 0:58787244fcec 132
wim 0:58787244fcec 133 myled = !myled;
wim 0:58787244fcec 134 wait(0.3);
wim 0:58787244fcec 135 } //while
wim 0:58787244fcec 136 }
wim 2:c6897ab055a2 137 #endif
wim 0:58787244fcec 138
wim 2:c6897ab055a2 139 #if (PT6964_TEST == 1)
wim 0:58787244fcec 140 //Direct control of PT9664 for DVD538
wim 0:58787244fcec 141
wim 0:58787244fcec 142 // DisplayData_t size is 8 bytes (4 digits @ 13 segments) OR 10 bytes (5 digits @ 12 segments) OR
wim 0:58787244fcec 143 // 12 bytes (6 digits @ 11 segments) OR 14 bytes (7 digits @ 10 segments)
wim 0:58787244fcec 144 PT6964::DisplayData_t mbed_str = {0xDA,0x00, 0x7C,0x00, 0x3C,0x01, 0xF6,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
wim 0:58787244fcec 145 PT6964::DisplayData_t all_str = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F};
wim 0:58787244fcec 146 PT6964::DisplayData_t bye_str = {0x7C,0x00, 0xEC,0x00, 0x3C,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
wim 0:58787244fcec 147 PT6964::DisplayData_t hello_str = {0xDC,0x00, 0x3C,0x01, 0x38,0x00, 0x38,0x00, 0xF8,0x01, 0x00,0x00, 0x00,0x00};
wim 0:58787244fcec 148 PT6964::DisplayData_t tst_str;
wim 0:58787244fcec 149 PT6964::DisplayData_t hello1_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x30,0x00, 0x00,0x00, 0x00,0x00};
wim 0:58787244fcec 150 PT6964::DisplayData_t hello2_str = {0x00,0x00, 0x00,0x00, 0x00,0x00, 0xE8,0x02, 0x00,0x00, 0x00,0x00, 0x00,0x00};
wim 0:58787244fcec 151 PT6964::DisplayData_t hello3_str = {0x00,0x00, 0x00,0x00, 0x78,0x02, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
wim 0:58787244fcec 152 PT6964::DisplayData_t hello4_str = {0x00,0x00, 0x30,0x03, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00};
wim 0:58787244fcec 153
wim 0:58787244fcec 154
wim 0:58787244fcec 155 // KeyData_t size is 5 bytes
wim 0:58787244fcec 156 PT6964::KeyData_t keydata;
wim 0:58787244fcec 157
wim 0:58787244fcec 158 // PT6964 declaration, Default setting 7 Grids @ 10 Segments
wim 0:58787244fcec 159 PT6964 PT6964(p5,p6,p7, p8);
wim 0:58787244fcec 160
wim 0:58787244fcec 161 int main() {
wim 0:58787244fcec 162
wim 0:58787244fcec 163 pc.printf("Hello World\r\n"); //
wim 0:58787244fcec 164
wim 0:58787244fcec 165 PT6964.cls();
wim 0:58787244fcec 166 PT6964.writeData(all_str);
wim 0:58787244fcec 167 wait(4);
wim 0:58787244fcec 168 PT6964.setBrightness(PT6964_BRT3);
wim 0:58787244fcec 169 PT6964.writeData(mbed_str);
wim 0:58787244fcec 170 wait(1);
wim 0:58787244fcec 171 PT6964.setBrightness(PT6964_BRT0);
wim 0:58787244fcec 172 wait(1);
wim 0:58787244fcec 173 PT6964.setBrightness(PT6964_BRT3);
wim 0:58787244fcec 174
wim 0:58787244fcec 175 while (1) {
wim 0:58787244fcec 176
wim 0:58787244fcec 177 // Check and read keydata
wim 0:58787244fcec 178 if (PT6964.getKeys(&keydata)) {
wim 0:58787244fcec 179 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 180
wim 0:58787244fcec 181 if (keydata[0] == 0x01) { //sw1 L/R
wim 0:58787244fcec 182 PT6964.cls();
wim 0:58787244fcec 183 PT6964.writeData(hello1_str);
wim 3:d7990de75130 184
wim 0:58787244fcec 185 }
wim 0:58787244fcec 186
wim 0:58787244fcec 187 if (keydata[0] == 0x02) { //sw2 Stop
wim 0:58787244fcec 188 PT6964.cls();
wim 0:58787244fcec 189 PT6964.writeData(hello2_str);
wim 0:58787244fcec 190
wim 0:58787244fcec 191 }
wim 0:58787244fcec 192
wim 0:58787244fcec 193 if (keydata[0] == 0x08) { //sw4 Play
wim 0:58787244fcec 194 PT6964.cls();
wim 0:58787244fcec 195 PT6964.writeData(hello3_str);
wim 3:d7990de75130 196
wim 0:58787244fcec 197 }
wim 0:58787244fcec 198
wim 0:58787244fcec 199 if (keydata[0] == 0x10) { //sw3 Open
wim 0:58787244fcec 200 PT6964.cls();
wim 0:58787244fcec 201 PT6964.writeData(hello4_str);
wim 0:58787244fcec 202
wim 0:58787244fcec 203 }
wim 0:58787244fcec 204
wim 0:58787244fcec 205 } //if
wim 0:58787244fcec 206
wim 0:58787244fcec 207 myled = !myled;
wim 0:58787244fcec 208 wait(0.3);
wim 0:58787244fcec 209 } //while
wim 0:58787244fcec 210 }
wim 0:58787244fcec 211 #endif