Wim Huiskamp
/
mbed_PT6961
Test program for Princeton PT6961 LED controller library.
See here for more information.
main.cpp@4:bedc75e6561a, 2016-01-07 (annotated)
- Committer:
- wim
- Date:
- Thu Jan 07 20:57:24 2016 +0000
- Revision:
- 4:bedc75e6561a
- Parent:
- 2:3bc72b8f5481
Added support for HR734 and V56S display print, Added Stream support for decimal and hex digits.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 0:c77f1ad8d993 | 1 | /* mbed PT6961 Test program, for Princeton PT6961 LED controller |
wim | 4:bedc75e6561a | 2 | * Copyright (c) 2015, v01: WH, Initial version PT6961 (HR734) |
wim | 4:bedc75e6561a | 3 | * 2016, v02: WH, Added V56S, Added Stream support |
wim | 4:bedc75e6561a | 4 | |
wim | 0:c77f1ad8d993 | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
wim | 0:c77f1ad8d993 | 6 | * of this software and associated documentation files (the "Software"), to deal |
wim | 0:c77f1ad8d993 | 7 | * in the Software without restriction, including without limitation the rights |
wim | 0:c77f1ad8d993 | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
wim | 0:c77f1ad8d993 | 9 | * copies of the Software, and to permit persons to whom the Software is |
wim | 0:c77f1ad8d993 | 10 | * furnished to do so, subject to the following conditions: |
wim | 0:c77f1ad8d993 | 11 | * |
wim | 0:c77f1ad8d993 | 12 | * The above copyright notice and this permission notice shall be included in |
wim | 0:c77f1ad8d993 | 13 | * all copies or substantial portions of the Software. |
wim | 0:c77f1ad8d993 | 14 | * |
wim | 0:c77f1ad8d993 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
wim | 0:c77f1ad8d993 | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
wim | 0:c77f1ad8d993 | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
wim | 0:c77f1ad8d993 | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
wim | 0:c77f1ad8d993 | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
wim | 0:c77f1ad8d993 | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
wim | 0:c77f1ad8d993 | 21 | * THE SOFTWARE. |
wim | 0:c77f1ad8d993 | 22 | */ |
wim | 0:c77f1ad8d993 | 23 | #include "mbed.h" |
wim | 0:c77f1ad8d993 | 24 | #include "PT6961.h" |
wim | 0:c77f1ad8d993 | 25 | |
wim | 0:c77f1ad8d993 | 26 | Serial pc(USBTX, USBRX); |
wim | 0:c77f1ad8d993 | 27 | DigitalOut myled(LED1); |
wim | 0:c77f1ad8d993 | 28 | |
wim | 4:bedc75e6561a | 29 | #if(HR734_TEST == 1) |
wim | 4:bedc75e6561a | 30 | //Test on HR734 display |
wim | 4:bedc75e6561a | 31 | |
wim | 4:bedc75e6561a | 32 | #include "Font_7Seg.h" |
wim | 4:bedc75e6561a | 33 | |
wim | 4:bedc75e6561a | 34 | // DisplayData_t size is 14 bytes (7 grids @ 11 segments) |
wim | 4:bedc75e6561a | 35 | PT6961::DisplayData_t mbed_str = {0xDA,0x00, 0x7C,0x00, 0x3C,0x01, 0xF6,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 4:bedc75e6561a | 36 | PT6961::DisplayData_t all_str = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F}; |
wim | 4:bedc75e6561a | 37 | PT6961::DisplayData_t hello_str = {LO(C7_H),HI(C7_H), LO(C7_E),HI(C7_E), LO(C7_L),HI(C7_L), LO(C7_L),HI(C7_L), LO(C7_O),HI(C7_O), 0x00,0x00, 0x00,0x00}; |
wim | 4:bedc75e6561a | 38 | PT6961::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 | 4:bedc75e6561a | 39 | //PT6961::DisplayData_t tst_str; |
wim | 4:bedc75e6561a | 40 | |
wim | 4:bedc75e6561a | 41 | // KeyData_t size is 5 bytes |
wim | 4:bedc75e6561a | 42 | PT6961::KeyData_t keydata; |
wim | 4:bedc75e6561a | 43 | |
wim | 4:bedc75e6561a | 44 | // PT6191_HR734 declaration, Setting 7 Grids @ 11 Segments |
wim | 4:bedc75e6561a | 45 | PT6961_HR734 pt6961_hr734(p5,p6,p7, p8); |
wim | 4:bedc75e6561a | 46 | |
wim | 4:bedc75e6561a | 47 | char cmd, bits; |
wim | 4:bedc75e6561a | 48 | int main() { |
wim | 4:bedc75e6561a | 49 | |
wim | 4:bedc75e6561a | 50 | pc.printf("Hello World\r\n"); // |
wim | 4:bedc75e6561a | 51 | |
wim | 4:bedc75e6561a | 52 | pt6961_hr734.cls(); |
wim | 4:bedc75e6561a | 53 | pt6961_hr734.writeData(all_str); |
wim | 4:bedc75e6561a | 54 | wait(4); |
wim | 4:bedc75e6561a | 55 | pt6961_hr734.setBrightness(PT6961_BRT3); |
wim | 4:bedc75e6561a | 56 | pt6961_hr734.writeData(mbed_str); |
wim | 4:bedc75e6561a | 57 | wait(1); |
wim | 4:bedc75e6561a | 58 | pt6961_hr734.setBrightness(PT6961_BRT0); |
wim | 4:bedc75e6561a | 59 | wait(1); |
wim | 4:bedc75e6561a | 60 | pt6961_hr734.setBrightness(PT6961_BRT3); |
wim | 4:bedc75e6561a | 61 | |
wim | 4:bedc75e6561a | 62 | while (1) { |
wim | 4:bedc75e6561a | 63 | |
wim | 4:bedc75e6561a | 64 | // Check and read keydata |
wim | 4:bedc75e6561a | 65 | if (pt6961_hr734.getKeys(&keydata)) { |
wim | 4:bedc75e6561a | 66 | 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 | 4:bedc75e6561a | 67 | |
wim | 4:bedc75e6561a | 68 | if (keydata[0] == 0x10) { //sw2 FF |
wim | 4:bedc75e6561a | 69 | pt6961_hr734.cls(); |
wim | 4:bedc75e6561a | 70 | pt6961_hr734.writeData(all_str); |
wim | 4:bedc75e6561a | 71 | } |
wim | 4:bedc75e6561a | 72 | |
wim | 4:bedc75e6561a | 73 | if (keydata[0] == 0x02) { //sw8 Play |
wim | 4:bedc75e6561a | 74 | pt6961_hr734.cls(); |
wim | 4:bedc75e6561a | 75 | pt6961_hr734.writeData(hello_str); |
wim | 4:bedc75e6561a | 76 | // pt6961_hr734.printf("Hello"); |
wim | 4:bedc75e6561a | 77 | } |
wim | 4:bedc75e6561a | 78 | |
wim | 4:bedc75e6561a | 79 | if (keydata[0] == 0x20) { //sw6 Stop |
wim | 4:bedc75e6561a | 80 | pt6961_hr734.cls(); |
wim | 4:bedc75e6561a | 81 | pt6961_hr734.writeData(mbed_str); |
wim | 4:bedc75e6561a | 82 | } |
wim | 4:bedc75e6561a | 83 | |
wim | 4:bedc75e6561a | 84 | if (keydata[1] == 0x02) { //sw4 Rew |
wim | 4:bedc75e6561a | 85 | pt6961_hr734.cls(); |
wim | 4:bedc75e6561a | 86 | pt6961_hr734.writeData(bye_str); |
wim | 4:bedc75e6561a | 87 | // pt6961_hr734.printf("Bye"); |
wim | 4:bedc75e6561a | 88 | } |
wim | 4:bedc75e6561a | 89 | |
wim | 4:bedc75e6561a | 90 | if (keydata[0] == 0x04) { //sw11 Rec |
wim | 4:bedc75e6561a | 91 | #if(1) |
wim | 4:bedc75e6561a | 92 | //test to show all segs |
wim | 4:bedc75e6561a | 93 | pc.printf("Show all segs\r\n"); |
wim | 4:bedc75e6561a | 94 | wait(1); |
wim | 4:bedc75e6561a | 95 | pt6961_hr734.cls(); |
wim | 4:bedc75e6561a | 96 | |
wim | 4:bedc75e6561a | 97 | for (int i=0; i<PT6961_DISPLAY_MEM; i++) { |
wim | 4:bedc75e6561a | 98 | for (int bit=0; bit<8; bit++) { |
wim | 4:bedc75e6561a | 99 | pt6961_hr734.cls(); |
wim | 4:bedc75e6561a | 100 | |
wim | 4:bedc75e6561a | 101 | bits = 0x01 << bit; |
wim | 4:bedc75e6561a | 102 | pt6961_hr734.writeData(i, bits); |
wim | 4:bedc75e6561a | 103 | |
wim | 4:bedc75e6561a | 104 | pc.printf("Idx = %d, Bits = 0x%02x\r\n", i, bits); |
wim | 4:bedc75e6561a | 105 | // wait(0.5); |
wim | 4:bedc75e6561a | 106 | cmd = pc.getc(); // wait for key |
wim | 4:bedc75e6561a | 107 | } |
wim | 4:bedc75e6561a | 108 | } |
wim | 4:bedc75e6561a | 109 | pc.printf("Show all segs done\r\n"); |
wim | 4:bedc75e6561a | 110 | #endif |
wim | 4:bedc75e6561a | 111 | } |
wim | 4:bedc75e6561a | 112 | |
wim | 4:bedc75e6561a | 113 | if (keydata[0] == 0x08) { //sw10 Ch- |
wim | 4:bedc75e6561a | 114 | #if(1) |
wim | 4:bedc75e6561a | 115 | //test to show all digits (base is 0x10) |
wim | 4:bedc75e6561a | 116 | pc.printf("Show all hex digits\r\n"); |
wim | 4:bedc75e6561a | 117 | wait(1); |
wim | 4:bedc75e6561a | 118 | pt6961_hr734.cls(); |
wim | 4:bedc75e6561a | 119 | |
wim | 4:bedc75e6561a | 120 | pt6961_hr734.printf("%05x", 0x012AB); |
wim | 4:bedc75e6561a | 121 | cmd = pc.getc(); // wait for key |
wim | 4:bedc75e6561a | 122 | |
wim | 4:bedc75e6561a | 123 | int val = 1; |
wim | 4:bedc75e6561a | 124 | for (int i=0; i<HR734_NR_DIGITS; i++) { |
wim | 4:bedc75e6561a | 125 | |
wim | 4:bedc75e6561a | 126 | for (int cnt=0; cnt<0x10; cnt++) { |
wim | 4:bedc75e6561a | 127 | pt6961_hr734.locate(0); |
wim | 4:bedc75e6561a | 128 | pt6961_hr734.printf("%05x", (val * cnt)); |
wim | 4:bedc75e6561a | 129 | |
wim | 4:bedc75e6561a | 130 | // wait(0.5); |
wim | 4:bedc75e6561a | 131 | cmd = pc.getc(); // wait for key |
wim | 4:bedc75e6561a | 132 | } |
wim | 4:bedc75e6561a | 133 | val = val * 0x10; |
wim | 4:bedc75e6561a | 134 | } |
wim | 4:bedc75e6561a | 135 | pc.printf("\r\nShow all hex digits done\r\n"); |
wim | 4:bedc75e6561a | 136 | #endif |
wim | 4:bedc75e6561a | 137 | } |
wim | 4:bedc75e6561a | 138 | |
wim | 4:bedc75e6561a | 139 | if (keydata[1] == 0x01) { //sw9 Ch+ |
wim | 4:bedc75e6561a | 140 | float delay = 0.2; |
wim | 4:bedc75e6561a | 141 | |
wim | 4:bedc75e6561a | 142 | pt6961_hr734.cls(); |
wim | 4:bedc75e6561a | 143 | pt6961_hr734.setIcon(PT6961_HR734::RA); wait(delay); |
wim | 4:bedc75e6561a | 144 | pt6961_hr734.setIcon(PT6961_HR734::M); wait(delay); |
wim | 4:bedc75e6561a | 145 | pt6961_hr734.setIcon(PT6961_HR734::ARW); wait(delay); |
wim | 4:bedc75e6561a | 146 | pt6961_hr734.setIcon(PT6961_HR734::HDDDVD_HD); wait(delay); |
wim | 4:bedc75e6561a | 147 | pt6961_hr734.setIcon(PT6961_HR734::HDDDVD_D); wait(delay); |
wim | 4:bedc75e6561a | 148 | pt6961_hr734.setIcon(PT6961_HR734::HDDDVD_VD); wait(delay); |
wim | 4:bedc75e6561a | 149 | pt6961_hr734.setIcon(PT6961_HR734::DP2); wait(delay); |
wim | 4:bedc75e6561a | 150 | pt6961_hr734.setIcon(PT6961_HR734::DP1); wait(delay); |
wim | 4:bedc75e6561a | 151 | pt6961_hr734.setIcon(PT6961_HR734::R); wait(delay); |
wim | 4:bedc75e6561a | 152 | pt6961_hr734.setIcon(PT6961_HR734::W); wait(delay); |
wim | 4:bedc75e6561a | 153 | pt6961_hr734.setIcon(PT6961_HR734::SO); wait(delay); |
wim | 4:bedc75e6561a | 154 | pt6961_hr734.setIcon(PT6961_HR734::P); wait(delay); |
wim | 4:bedc75e6561a | 155 | pt6961_hr734.setIcon(PT6961_HR734::CLK); wait(delay); |
wim | 4:bedc75e6561a | 156 | pt6961_hr734.setIcon(PT6961_HR734::BRK); wait(delay); |
wim | 4:bedc75e6561a | 157 | pt6961_hr734.setIcon(PT6961_HR734::DP4); wait(delay); |
wim | 4:bedc75e6561a | 158 | pt6961_hr734.setIcon(PT6961_HR734::DP3); wait(delay); |
wim | 4:bedc75e6561a | 159 | wait(delay); |
wim | 4:bedc75e6561a | 160 | pt6961_hr734.clrIcon(PT6961_HR734::RA); wait(delay); |
wim | 4:bedc75e6561a | 161 | pt6961_hr734.clrIcon(PT6961_HR734::M); wait(delay); |
wim | 4:bedc75e6561a | 162 | pt6961_hr734.clrIcon(PT6961_HR734::ARW); wait(delay); |
wim | 4:bedc75e6561a | 163 | pt6961_hr734.clrIcon(PT6961_HR734::HDDDVD_HD); wait(delay); |
wim | 4:bedc75e6561a | 164 | pt6961_hr734.clrIcon(PT6961_HR734::HDDDVD_D); wait(delay); |
wim | 4:bedc75e6561a | 165 | pt6961_hr734.clrIcon(PT6961_HR734::HDDDVD_VD); wait(delay); |
wim | 4:bedc75e6561a | 166 | pt6961_hr734.clrIcon(PT6961_HR734::DP2); wait(delay); |
wim | 4:bedc75e6561a | 167 | pt6961_hr734.clrIcon(PT6961_HR734::DP1); wait(delay); |
wim | 4:bedc75e6561a | 168 | pt6961_hr734.clrIcon(PT6961_HR734::R); wait(delay); |
wim | 4:bedc75e6561a | 169 | pt6961_hr734.clrIcon(PT6961_HR734::W); wait(delay); |
wim | 4:bedc75e6561a | 170 | pt6961_hr734.clrIcon(PT6961_HR734::SO); wait(delay); |
wim | 4:bedc75e6561a | 171 | pt6961_hr734.clrIcon(PT6961_HR734::P); wait(delay); |
wim | 4:bedc75e6561a | 172 | pt6961_hr734.clrIcon(PT6961_HR734::CLK); wait(delay); |
wim | 4:bedc75e6561a | 173 | pt6961_hr734.clrIcon(PT6961_HR734::BRK); wait(delay); |
wim | 4:bedc75e6561a | 174 | pt6961_hr734.clrIcon(PT6961_HR734::DP4); wait(delay); |
wim | 4:bedc75e6561a | 175 | pt6961_hr734.clrIcon(PT6961_HR734::DP3); wait(delay); |
wim | 4:bedc75e6561a | 176 | } |
wim | 4:bedc75e6561a | 177 | |
wim | 4:bedc75e6561a | 178 | if (keydata[0] == 0x01) { //sw7 |
wim | 4:bedc75e6561a | 179 | pt6961_hr734.cls(); |
wim | 4:bedc75e6561a | 180 | |
wim | 4:bedc75e6561a | 181 | } |
wim | 4:bedc75e6561a | 182 | |
wim | 4:bedc75e6561a | 183 | if (keydata[1] == 0x04) { //sw12 HDD |
wim | 4:bedc75e6561a | 184 | pt6961_hr734.cls(); |
wim | 4:bedc75e6561a | 185 | pt6961_hr734.printf("%5d", -1234); |
wim | 4:bedc75e6561a | 186 | } |
wim | 4:bedc75e6561a | 187 | |
wim | 4:bedc75e6561a | 188 | if (keydata[1] == 0x10) { //sw13 DVD |
wim | 4:bedc75e6561a | 189 | pt6961_hr734.cls(); |
wim | 4:bedc75e6561a | 190 | pt6961_hr734.printf("%05d", 1234); |
wim | 4:bedc75e6561a | 191 | } |
wim | 4:bedc75e6561a | 192 | |
wim | 4:bedc75e6561a | 193 | |
wim | 4:bedc75e6561a | 194 | } //if |
wim | 4:bedc75e6561a | 195 | |
wim | 4:bedc75e6561a | 196 | myled = !myled; |
wim | 4:bedc75e6561a | 197 | wait(0.3); |
wim | 4:bedc75e6561a | 198 | } //while |
wim | 4:bedc75e6561a | 199 | } |
wim | 4:bedc75e6561a | 200 | #endif |
wim | 4:bedc75e6561a | 201 | |
wim | 4:bedc75e6561a | 202 | |
wim | 4:bedc75e6561a | 203 | #if(V56S_TEST == 1) |
wim | 4:bedc75e6561a | 204 | //Test on V56S display |
wim | 4:bedc75e6561a | 205 | |
wim | 4:bedc75e6561a | 206 | #include "Font_7Seg.h" |
wim | 4:bedc75e6561a | 207 | |
wim | 4:bedc75e6561a | 208 | // DisplayData_t size is 14 bytes (7 grids @ 11 segments) |
wim | 4:bedc75e6561a | 209 | PT6961::DisplayData_t mbed_str = {0xDA,0x00, 0x7C,0x00, 0x3C,0x01, 0xF6,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 4:bedc75e6561a | 210 | PT6961::DisplayData_t all_str = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F}; |
wim | 4:bedc75e6561a | 211 | PT6961::DisplayData_t hello_str = {LO(C7_H),HI(C7_H), LO(C7_E),HI(C7_E), LO(C7_L),HI(C7_L), LO(C7_L),HI(C7_L), LO(C7_O),HI(C7_O), 0x00,0x00, 0x00,0x00}; |
wim | 4:bedc75e6561a | 212 | PT6961::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 | 4:bedc75e6561a | 213 | //PT6961::DisplayData_t tst_str; |
wim | 4:bedc75e6561a | 214 | |
wim | 4:bedc75e6561a | 215 | // KeyData_t size is 5 bytes |
wim | 4:bedc75e6561a | 216 | PT6961::KeyData_t keydata; |
wim | 4:bedc75e6561a | 217 | |
wim | 4:bedc75e6561a | 218 | // PT6191_V56S declaration, Setting 7 Grids @ 11 Segments |
wim | 4:bedc75e6561a | 219 | PT6961_V56S pt6961_v56s(p5,p6,p7, p8); |
wim | 4:bedc75e6561a | 220 | |
wim | 4:bedc75e6561a | 221 | char cmd, bits; |
wim | 4:bedc75e6561a | 222 | int main() { |
wim | 4:bedc75e6561a | 223 | |
wim | 4:bedc75e6561a | 224 | pc.printf("Hello World\r\n"); // |
wim | 4:bedc75e6561a | 225 | |
wim | 4:bedc75e6561a | 226 | pt6961_v56s.cls(); |
wim | 4:bedc75e6561a | 227 | pt6961_v56s.writeData(all_str); |
wim | 4:bedc75e6561a | 228 | wait(4); |
wim | 4:bedc75e6561a | 229 | pt6961_v56s.setBrightness(PT6961_BRT3); |
wim | 4:bedc75e6561a | 230 | pt6961_v56s.writeData(hello_str); |
wim | 4:bedc75e6561a | 231 | wait(1); |
wim | 4:bedc75e6561a | 232 | pt6961_v56s.setBrightness(PT6961_BRT0); |
wim | 4:bedc75e6561a | 233 | wait(1); |
wim | 4:bedc75e6561a | 234 | pt6961_v56s.setBrightness(PT6961_BRT3); |
wim | 4:bedc75e6561a | 235 | |
wim | 4:bedc75e6561a | 236 | while (1) { |
wim | 4:bedc75e6561a | 237 | |
wim | 4:bedc75e6561a | 238 | // Check and read keydata |
wim | 4:bedc75e6561a | 239 | if (pt6961_v56s.getKeys(&keydata)) { |
wim | 4:bedc75e6561a | 240 | 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 | 4:bedc75e6561a | 241 | |
wim | 4:bedc75e6561a | 242 | if (keydata[0] == 0x01) { //sw5 |
wim | 4:bedc75e6561a | 243 | pt6961_v56s.cls(); |
wim | 4:bedc75e6561a | 244 | pt6961_v56s.writeData(all_str); |
wim | 4:bedc75e6561a | 245 | } |
wim | 4:bedc75e6561a | 246 | |
wim | 4:bedc75e6561a | 247 | if (keydata[0] == 0x02) { //sw1 |
wim | 4:bedc75e6561a | 248 | pt6961_v56s.cls(); |
wim | 4:bedc75e6561a | 249 | pt6961_v56s.writeData(hello_str); |
wim | 4:bedc75e6561a | 250 | // pt6961_v56s.printf("Hello"); |
wim | 4:bedc75e6561a | 251 | // pt6961_v56s.writeData(mbed_str); |
wim | 4:bedc75e6561a | 252 | // pt6961_v56s.writeData(bye_str); |
wim | 4:bedc75e6561a | 253 | } |
wim | 4:bedc75e6561a | 254 | |
wim | 4:bedc75e6561a | 255 | if (keydata[0] == 0x08) { //sw6 |
wim | 4:bedc75e6561a | 256 | #if(1) |
wim | 4:bedc75e6561a | 257 | //test to show all segs |
wim | 4:bedc75e6561a | 258 | pc.printf("Show all segs\r\n"); |
wim | 4:bedc75e6561a | 259 | wait(1); |
wim | 4:bedc75e6561a | 260 | pt6961_v56s.cls(); |
wim | 4:bedc75e6561a | 261 | |
wim | 4:bedc75e6561a | 262 | for (int i=0; i<PT6961_DISPLAY_MEM; i++) { |
wim | 4:bedc75e6561a | 263 | for (int bit=0; bit<8; bit++) { |
wim | 4:bedc75e6561a | 264 | pt6961_v56s.cls(); |
wim | 4:bedc75e6561a | 265 | |
wim | 4:bedc75e6561a | 266 | bits = 0x01 << bit; |
wim | 4:bedc75e6561a | 267 | pt6961_v56s.writeData(i, bits); |
wim | 4:bedc75e6561a | 268 | |
wim | 4:bedc75e6561a | 269 | pc.printf("Idx = %d, Bits = 0x%02x\r\n", i, bits); |
wim | 4:bedc75e6561a | 270 | // wait(0.5); |
wim | 4:bedc75e6561a | 271 | cmd = pc.getc(); // wait for key |
wim | 4:bedc75e6561a | 272 | } |
wim | 4:bedc75e6561a | 273 | } |
wim | 4:bedc75e6561a | 274 | pc.printf("Show all segs done\r\n"); |
wim | 4:bedc75e6561a | 275 | #endif |
wim | 4:bedc75e6561a | 276 | } |
wim | 4:bedc75e6561a | 277 | |
wim | 4:bedc75e6561a | 278 | if (keydata[0] == 0x10) { //sw2 |
wim | 4:bedc75e6561a | 279 | #if(1) |
wim | 4:bedc75e6561a | 280 | //test to show all digits (base is 0x10) |
wim | 4:bedc75e6561a | 281 | pc.printf("Show all hex digits\r\n"); |
wim | 4:bedc75e6561a | 282 | wait(1); |
wim | 4:bedc75e6561a | 283 | pt6961_v56s.cls(); |
wim | 4:bedc75e6561a | 284 | |
wim | 4:bedc75e6561a | 285 | pt6961_v56s.printf("%05x", 0x012AB); |
wim | 4:bedc75e6561a | 286 | cmd = pc.getc(); // wait for key |
wim | 4:bedc75e6561a | 287 | |
wim | 4:bedc75e6561a | 288 | int val = 1; |
wim | 4:bedc75e6561a | 289 | for (int i=0; i<V56S_NR_DIGITS; i++) { |
wim | 4:bedc75e6561a | 290 | |
wim | 4:bedc75e6561a | 291 | for (int cnt=0; cnt<0x10; cnt++) { |
wim | 4:bedc75e6561a | 292 | pt6961_v56s.locate(0); |
wim | 4:bedc75e6561a | 293 | pt6961_v56s.printf("%05x", (val * cnt)); |
wim | 4:bedc75e6561a | 294 | |
wim | 4:bedc75e6561a | 295 | // wait(0.5); |
wim | 4:bedc75e6561a | 296 | cmd = pc.getc(); // wait for key |
wim | 4:bedc75e6561a | 297 | } |
wim | 4:bedc75e6561a | 298 | val = val * 0x10; |
wim | 4:bedc75e6561a | 299 | } |
wim | 4:bedc75e6561a | 300 | pc.printf("\r\nShow all hex digits done\r\n"); |
wim | 4:bedc75e6561a | 301 | #endif |
wim | 4:bedc75e6561a | 302 | } |
wim | 4:bedc75e6561a | 303 | |
wim | 4:bedc75e6561a | 304 | if (keydata[1] == 0x02) { //sw3 |
wim | 4:bedc75e6561a | 305 | float delay = 0.2; |
wim | 4:bedc75e6561a | 306 | |
wim | 4:bedc75e6561a | 307 | pt6961_v56s.cls(); |
wim | 4:bedc75e6561a | 308 | pt6961_v56s.setIcon(PT6961_V56S::RED); wait(delay); |
wim | 4:bedc75e6561a | 309 | pt6961_v56s.setIcon(PT6961_V56S::GRN); wait(delay); |
wim | 4:bedc75e6561a | 310 | pt6961_v56s.setIcon(PT6961_V56S::YEL); wait(delay); |
wim | 4:bedc75e6561a | 311 | pt6961_v56s.setIcon(PT6961_V56S::DVD); wait(delay); |
wim | 4:bedc75e6561a | 312 | pt6961_v56s.setIcon(PT6961_V56S::COL1); wait(delay); |
wim | 4:bedc75e6561a | 313 | pt6961_v56s.setIcon(PT6961_V56S::DP3); wait(delay); |
wim | 4:bedc75e6561a | 314 | pt6961_v56s.setIcon(PT6961_V56S::PSE); wait(delay); |
wim | 4:bedc75e6561a | 315 | pt6961_v56s.setIcon(PT6961_V56S::MP3); wait(delay); |
wim | 4:bedc75e6561a | 316 | pt6961_v56s.setIcon(PT6961_V56S::PLY); wait(delay); |
wim | 4:bedc75e6561a | 317 | pt6961_v56s.setIcon(PT6961_V56S::CD); wait(delay); |
wim | 4:bedc75e6561a | 318 | pt6961_v56s.setIcon(PT6961_V56S::COL3); wait(delay); |
wim | 4:bedc75e6561a | 319 | pt6961_v56s.setIcon(PT6961_V56S::ARW); wait(delay); |
wim | 4:bedc75e6561a | 320 | pt6961_v56s.setIcon(PT6961_V56S::ANT); wait(delay); |
wim | 4:bedc75e6561a | 321 | pt6961_v56s.setIcon(PT6961_V56S::DTS); wait(delay); |
wim | 4:bedc75e6561a | 322 | pt6961_v56s.setIcon(PT6961_V56S::MHZ); wait(delay); |
wim | 4:bedc75e6561a | 323 | pt6961_v56s.setIcon(PT6961_V56S::DDD); wait(delay); |
wim | 4:bedc75e6561a | 324 | pt6961_v56s.setIcon(PT6961_V56S::KHZ); wait(delay); |
wim | 4:bedc75e6561a | 325 | pt6961_v56s.setIcon(PT6961_V56S::RDS); wait(delay); |
wim | 4:bedc75e6561a | 326 | wait(delay); |
wim | 4:bedc75e6561a | 327 | pt6961_v56s.clrIcon(PT6961_V56S::RED); wait(delay); |
wim | 4:bedc75e6561a | 328 | pt6961_v56s.clrIcon(PT6961_V56S::GRN); wait(delay); |
wim | 4:bedc75e6561a | 329 | pt6961_v56s.clrIcon(PT6961_V56S::YEL); wait(delay); |
wim | 4:bedc75e6561a | 330 | pt6961_v56s.clrIcon(PT6961_V56S::DVD); wait(delay); |
wim | 4:bedc75e6561a | 331 | pt6961_v56s.clrIcon(PT6961_V56S::COL1); wait(delay); |
wim | 4:bedc75e6561a | 332 | pt6961_v56s.clrIcon(PT6961_V56S::DP3); wait(delay); |
wim | 4:bedc75e6561a | 333 | pt6961_v56s.clrIcon(PT6961_V56S::PSE); wait(delay); |
wim | 4:bedc75e6561a | 334 | pt6961_v56s.clrIcon(PT6961_V56S::MP3); wait(delay); |
wim | 4:bedc75e6561a | 335 | pt6961_v56s.clrIcon(PT6961_V56S::PLY); wait(delay); |
wim | 4:bedc75e6561a | 336 | pt6961_v56s.clrIcon(PT6961_V56S::CD); wait(delay); |
wim | 4:bedc75e6561a | 337 | pt6961_v56s.clrIcon(PT6961_V56S::COL3); wait(delay); |
wim | 4:bedc75e6561a | 338 | pt6961_v56s.clrIcon(PT6961_V56S::ARW); wait(delay); |
wim | 4:bedc75e6561a | 339 | pt6961_v56s.clrIcon(PT6961_V56S::ANT); wait(delay); |
wim | 4:bedc75e6561a | 340 | pt6961_v56s.clrIcon(PT6961_V56S::DTS); wait(delay); |
wim | 4:bedc75e6561a | 341 | pt6961_v56s.clrIcon(PT6961_V56S::MHZ); wait(delay); |
wim | 4:bedc75e6561a | 342 | pt6961_v56s.clrIcon(PT6961_V56S::DDD); wait(delay); |
wim | 4:bedc75e6561a | 343 | pt6961_v56s.clrIcon(PT6961_V56S::KHZ); wait(delay); |
wim | 4:bedc75e6561a | 344 | pt6961_v56s.clrIcon(PT6961_V56S::RDS); wait(delay); |
wim | 4:bedc75e6561a | 345 | } |
wim | 4:bedc75e6561a | 346 | |
wim | 4:bedc75e6561a | 347 | if (keydata[1] == 0x10) { //sw4 - not mounted |
wim | 4:bedc75e6561a | 348 | pt6961_v56s.cls(); |
wim | 4:bedc75e6561a | 349 | pt6961_v56s.printf("%5d", -1234); |
wim | 4:bedc75e6561a | 350 | // pt6961_v56s.printf("%05d", 1234); |
wim | 4:bedc75e6561a | 351 | } |
wim | 4:bedc75e6561a | 352 | |
wim | 4:bedc75e6561a | 353 | } //if |
wim | 4:bedc75e6561a | 354 | |
wim | 4:bedc75e6561a | 355 | myled = !myled; |
wim | 4:bedc75e6561a | 356 | wait(0.3); |
wim | 4:bedc75e6561a | 357 | } //while |
wim | 4:bedc75e6561a | 358 | } |
wim | 4:bedc75e6561a | 359 | #endif |
wim | 4:bedc75e6561a | 360 | |
wim | 4:bedc75e6561a | 361 | |
wim | 4:bedc75e6561a | 362 | #if(PT6961_TEST == 1) |
wim | 4:bedc75e6561a | 363 | //Raw test on HR734 display |
wim | 4:bedc75e6561a | 364 | |
wim | 4:bedc75e6561a | 365 | #include "Font_7Seg.h" |
wim | 4:bedc75e6561a | 366 | |
wim | 2:3bc72b8f5481 | 367 | // DisplayData_t size is 12 bytes (6 digits @ 12 segments) OR 14 bytes (7 digits @ 11 segments) |
wim | 0:c77f1ad8d993 | 368 | PT6961::DisplayData_t mbed_str = {0xDA,0x00, 0x7C,0x00, 0x3C,0x01, 0xF6,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:c77f1ad8d993 | 369 | PT6961::DisplayData_t all_str = {0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F, 0xFF,0x0F}; |
wim | 0:c77f1ad8d993 | 370 | PT6961::DisplayData_t bye_str = {0x7C,0x00, 0xEC,0x00, 0x3C,0x01, 0x00,0x00, 0x00,0x00, 0x00,0x00, 0x00,0x00}; |
wim | 0:c77f1ad8d993 | 371 | PT6961::DisplayData_t hello_str = {0xDC,0x00, 0x3C,0x01, 0x38,0x00, 0x38,0x00, 0xF8,0x01, 0x00,0x00, 0x00,0x00}; |
wim | 2:3bc72b8f5481 | 372 | PT6961::DisplayData_t tst_str; |
wim | 0:c77f1ad8d993 | 373 | |
wim | 0:c77f1ad8d993 | 374 | // KeyData_t size is 5 bytes |
wim | 0:c77f1ad8d993 | 375 | PT6961::KeyData_t keydata; |
wim | 0:c77f1ad8d993 | 376 | |
wim | 2:3bc72b8f5481 | 377 | // PT6191 declaration, Default setting 7 Digits @ 11 Segments |
wim | 0:c77f1ad8d993 | 378 | PT6961 pt6961(p5,p6,p7, p8); |
wim | 0:c77f1ad8d993 | 379 | |
wim | 0:c77f1ad8d993 | 380 | int main() { |
wim | 0:c77f1ad8d993 | 381 | |
wim | 0:c77f1ad8d993 | 382 | pc.printf("Hello World\r\n"); // |
wim | 0:c77f1ad8d993 | 383 | |
wim | 0:c77f1ad8d993 | 384 | pt6961.cls(); |
wim | 0:c77f1ad8d993 | 385 | pt6961.writeData(all_str); |
wim | 0:c77f1ad8d993 | 386 | wait(4); |
wim | 0:c77f1ad8d993 | 387 | pt6961.setBrightness(PT6961_BRT3); |
wim | 0:c77f1ad8d993 | 388 | pt6961.writeData(mbed_str); |
wim | 0:c77f1ad8d993 | 389 | wait(1); |
wim | 0:c77f1ad8d993 | 390 | pt6961.setBrightness(PT6961_BRT0); |
wim | 0:c77f1ad8d993 | 391 | wait(1); |
wim | 0:c77f1ad8d993 | 392 | pt6961.setBrightness(PT6961_BRT3); |
wim | 0:c77f1ad8d993 | 393 | |
wim | 0:c77f1ad8d993 | 394 | while (1) { |
wim | 0:c77f1ad8d993 | 395 | |
wim | 0:c77f1ad8d993 | 396 | // Check and read keydata |
wim | 2:3bc72b8f5481 | 397 | if (pt6961.getKeys(&keydata)) { |
wim | 0:c77f1ad8d993 | 398 | 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:c77f1ad8d993 | 399 | |
wim | 0:c77f1ad8d993 | 400 | if (keydata[0] == 0x10) { //sw2 |
wim | 0:c77f1ad8d993 | 401 | pt6961.cls(); |
wim | 0:c77f1ad8d993 | 402 | pt6961.writeData(all_str); |
wim | 0:c77f1ad8d993 | 403 | } |
wim | 0:c77f1ad8d993 | 404 | |
wim | 0:c77f1ad8d993 | 405 | if (keydata[0] == 0x02) { //sw8 |
wim | 0:c77f1ad8d993 | 406 | pt6961.cls(); |
wim | 0:c77f1ad8d993 | 407 | pt6961.writeData(hello_str); |
wim | 0:c77f1ad8d993 | 408 | } |
wim | 0:c77f1ad8d993 | 409 | |
wim | 0:c77f1ad8d993 | 410 | if (keydata[0] == 0x20) { //sw6 |
wim | 0:c77f1ad8d993 | 411 | pt6961.cls(); |
wim | 0:c77f1ad8d993 | 412 | pt6961.writeData(mbed_str); |
wim | 0:c77f1ad8d993 | 413 | } |
wim | 0:c77f1ad8d993 | 414 | |
wim | 0:c77f1ad8d993 | 415 | if (keydata[1] == 0x02) { //sw4 |
wim | 0:c77f1ad8d993 | 416 | pt6961.cls(); |
wim | 0:c77f1ad8d993 | 417 | pt6961.writeData(bye_str); |
wim | 0:c77f1ad8d993 | 418 | } |
wim | 2:3bc72b8f5481 | 419 | |
wim | 2:3bc72b8f5481 | 420 | if (keydata[0] == 0x04) { //sw11 |
wim | 2:3bc72b8f5481 | 421 | pt6961.cls(); |
wim | 2:3bc72b8f5481 | 422 | |
wim | 2:3bc72b8f5481 | 423 | for (int idx=0; idx < PT6961_DISPLAY_MEM;idx++){ |
wim | 2:3bc72b8f5481 | 424 | tst_str[idx]=0x00; |
wim | 2:3bc72b8f5481 | 425 | } |
wim | 2:3bc72b8f5481 | 426 | tst_str[0]=0x01; //RA |
wim | 2:3bc72b8f5481 | 427 | tst_str[2]=0x01; //M |
wim | 2:3bc72b8f5481 | 428 | pt6961.writeData(tst_str); |
wim | 2:3bc72b8f5481 | 429 | } |
wim | 2:3bc72b8f5481 | 430 | |
wim | 2:3bc72b8f5481 | 431 | if (keydata[0] == 0x08) { //sw10 |
wim | 2:3bc72b8f5481 | 432 | pt6961.cls(); |
wim | 2:3bc72b8f5481 | 433 | |
wim | 2:3bc72b8f5481 | 434 | for (int idx=0; idx < PT6961_DISPLAY_MEM;idx++){ |
wim | 2:3bc72b8f5481 | 435 | tst_str[idx]=0x00; |
wim | 2:3bc72b8f5481 | 436 | } |
wim | 2:3bc72b8f5481 | 437 | tst_str[6]=0x01; //HD |
wim | 2:3bc72b8f5481 | 438 | tst_str[8]=0x01; //D |
wim | 2:3bc72b8f5481 | 439 | pt6961.writeData(tst_str); |
wim | 2:3bc72b8f5481 | 440 | } |
wim | 2:3bc72b8f5481 | 441 | |
wim | 2:3bc72b8f5481 | 442 | if (keydata[1] == 0x01) { //sw9 |
wim | 2:3bc72b8f5481 | 443 | pt6961.cls(); |
wim | 2:3bc72b8f5481 | 444 | |
wim | 2:3bc72b8f5481 | 445 | for (int idx=0; idx < PT6961_DISPLAY_MEM;idx++){ |
wim | 2:3bc72b8f5481 | 446 | tst_str[idx]=0x00; |
wim | 2:3bc72b8f5481 | 447 | } |
wim | 2:3bc72b8f5481 | 448 | tst_str[8]=0x01; //D |
wim | 2:3bc72b8f5481 | 449 | tst_str[10]=0x01; //VD |
wim | 2:3bc72b8f5481 | 450 | pt6961.writeData(tst_str); |
wim | 2:3bc72b8f5481 | 451 | } |
wim | 2:3bc72b8f5481 | 452 | |
wim | 2:3bc72b8f5481 | 453 | if (keydata[0] == 0x01) { //sw7 |
wim | 2:3bc72b8f5481 | 454 | pt6961.cls(); |
wim | 2:3bc72b8f5481 | 455 | |
wim | 2:3bc72b8f5481 | 456 | for (int idx=0; idx < PT6961_DISPLAY_MEM;idx++){ |
wim | 2:3bc72b8f5481 | 457 | tst_str[idx]=0x00; |
wim | 2:3bc72b8f5481 | 458 | } |
wim | 2:3bc72b8f5481 | 459 | tst_str[12]=0x20; //clock |
wim | 2:3bc72b8f5481 | 460 | pt6961.writeData(tst_str); |
wim | 2:3bc72b8f5481 | 461 | } |
wim | 0:c77f1ad8d993 | 462 | |
wim | 0:c77f1ad8d993 | 463 | } //if |
wim | 0:c77f1ad8d993 | 464 | |
wim | 0:c77f1ad8d993 | 465 | myled = !myled; |
wim | 0:c77f1ad8d993 | 466 | wait(0.3); |
wim | 0:c77f1ad8d993 | 467 | } //while |
wim | 0:c77f1ad8d993 | 468 | } |
wim | 4:bedc75e6561a | 469 | #endif |
wim | 4:bedc75e6561a | 470 | |
wim | 4:bedc75e6561a | 471 |