Wim Huiskamp
/
mbed_PT6315
PT6315 VFD driver test program. Supports DVDR3510.
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 /* mbed PT6315 Test program, for Princeton PT6315 VFD controller 00002 * Copyright (c) 2016, v01: WH, Initial version, DVDR3510 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 * THE SOFTWARE. 00021 */ 00022 #include "mbed.h" 00023 #include "PT6315.h" 00024 00025 // Select one of the testboards for Princeton PT6315 VFD controller 00026 00027 #if (DVDR3510_TEST == 1) 00028 // DVDR3510 PT6315 Test 00029 #include "mbed.h" 00030 #include "PT6315.h" 00031 #include "Font_16Seg.h" 00032 00033 Serial pc(USBTX, USBRX); 00034 DigitalOut myled(LED1); 00035 00036 // DisplayData_t size is 12 bytes (4 grids @ max 24 segments) ... 36 bytes (12 grids @ max 16 segments) 00037 // DisplayData_t size for DVDR3510 is 33 bytes (11 Grids @ 17 Segments) 00038 PT6315::DisplayData_t all_str = {0xFF,0xFF,0x01, 0xFF,0xFF,0x01, 0xFF,0xFF,0x01, 0xFF,0xFF,0x01, \ 00039 0xFF,0xFF,0x01, 0xFF,0xFF,0x01, 0xFF,0xFF,0x01, 0xFF,0xFF,0x01, \ 00040 0xFF,0xFF,0x01, 0xFF,0xFF,0x01, 0xFF,0xFF,0x01}; 00041 00042 PT6315::DisplayData_t cls_str = {0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ 00043 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ 00044 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00}; 00045 00046 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, \ 00047 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ 00048 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00}; 00049 00050 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), \ 00051 LO(C16_O),MD(C16_O),HI(C16_O), 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ 00052 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00}; 00053 00054 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), \ 00055 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ 00056 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00}; 00057 00058 // KeyData_t size is 3 bytes 00059 PT6315::KeyData_t keydata; 00060 00061 //PT6315_DVDR3510 declaration, Setting 12 Grids @ 16 Segments 00062 PT6315_DVDR3510 DVDR3510(p5,p6,p7, p8); 00063 00064 char cmd, bits; 00065 int main() { 00066 00067 pc.printf("Hello World\r\n"); // 00068 00069 DVDR3510.cls(); 00070 DVDR3510.writeData(all_str); 00071 wait(4); 00072 DVDR3510.setBrightness(PT6315_BRT3); 00073 wait(1); 00074 DVDR3510.setBrightness(PT6315_BRT0); 00075 wait(1); 00076 DVDR3510.setBrightness(PT6315_BRT7); 00077 00078 while (1) { 00079 00080 // Check and read keydata 00081 if (DVDR3510.getKeys(&keydata)) { 00082 pc.printf("Keydata 0..3 = 0x%02x 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2], keydata[3]); 00083 00084 if (keydata[1] == 0x20) { //dub 00085 DVDR3510.cls(); 00086 DVDR3510.writeData(all_str); 00087 } 00088 00089 if (keydata[2] == 0x01) { //up 00090 DVDR3510.cls(); 00091 DVDR3510.writeData(cls_str); 00092 #if(1) 00093 //test to show all segs 00094 pc.printf("Show all segs\r\n"); 00095 wait(1); 00096 DVDR3510.cls(); 00097 00098 for (int i=0; i<PT6315_DISPLAY_MEM; i++) { 00099 for (int bit=0; bit<8; bit++) { 00100 DVDR3510.cls(); 00101 00102 bits = 0x01 << bit; 00103 DVDR3510.writeData(i, bits); 00104 00105 pc.printf("Idx = %d, Bits = 0x%02x\r\n", i, bits); 00106 // wait(0.5); 00107 cmd = pc.getc(); // wait for key 00108 } 00109 } 00110 pc.printf("Show all segs done\r\n"); 00111 #endif 00112 } 00113 00114 00115 if (keydata[1] == 0x10) { //down 00116 00117 #if(0) 00118 //test to show all digits (base is 10) 00119 pc.printf("Show all digits\r\n"); 00120 wait(1); 00121 DVDR3510.cls(); 00122 00123 int val = 1; 00124 for (int i=0; i<DVDR3510_NR_DIGITS; i++) { 00125 00126 for (int cnt=0; cnt<10; cnt++) { 00127 DVDR3510.locate(0); 00128 DVDR3510.printf("%08d", (val * cnt)); 00129 00130 // wait(0.5); 00131 cmd = pc.getc(); // wait for key 00132 } 00133 val = val * 10; 00134 } 00135 pc.printf("Show all digits done\r\n"); 00136 #endif 00137 00138 #if(1) 00139 //test to show all digits (base is 0x10) 00140 pc.printf("Show all digits\r\n"); 00141 wait(1); 00142 00143 DVDR3510.cls(); 00144 DVDR3510.printf("%d", 0); 00145 cmd = pc.getc(); // wait for key 00146 00147 DVDR3510.cls(); 00148 DVDR3510.printf("%3.4f", 12.3456); 00149 cmd = pc.getc(); // wait for key 00150 00151 DVDR3510.cls(); 00152 DVDR3510.printf("%d", 123456); 00153 cmd = pc.getc(); // wait for key 00154 00155 DVDR3510.cls(); 00156 DVDR3510.printf("%08x", 0x0123ABCD); //Note this value needs 64bits 00157 cmd = pc.getc(); // wait for key 00158 00159 int val = 1; 00160 for (int i=0; i<DVDR3510_NR_DIGITS; i++) { 00161 00162 for (int cnt=0; cnt<0x10; cnt++) { 00163 DVDR3510.locate(0); 00164 DVDR3510.printf("%08x", (val * cnt)); 00165 // wait(0.5); 00166 cmd = pc.getc(); // wait for key 00167 } 00168 val = val * 0x10; 00169 } 00170 pc.printf("Show all digits done\r\n"); 00171 #endif 00172 00173 } 00174 00175 if (keydata[1] == 0x04) { //vcr/dvd 00176 00177 #if(1) 00178 //test to show all alpha chars 00179 pc.printf("Show all alpha chars\r\n"); 00180 wait(1); 00181 DVDR3510.cls(); 00182 00183 for (int i=0; i<26; i++) { 00184 DVDR3510.printf("%c", char(i + 'A')); 00185 // DVDR3510.printf("%c", char(i + 'a')); 00186 wait(0.25); 00187 } 00188 pc.printf("Show all alpha chars done\r\n"); 00189 #endif 00190 00191 #if(0) 00192 //test to show all chars 00193 pc.printf("Show all chars\r\n"); 00194 wait(1); 00195 DVDR3510.cls(); 00196 00197 for (int i=FONT_16S_START; i<FONT_16S_END; i++) { 00198 DVDR3510.printf("%c", char(i)); 00199 // wait(0.25); 00200 cmd = pc.getc(); // wait for key 00201 } 00202 pc.printf("Show all chars done\r\n"); 00203 #endif 00204 } 00205 00206 if (keydata[3] == 0x08) { //eject 00207 #if(1) 00208 //wheel 00209 for(int cnt=0;cnt<10;cnt++) { 00210 for(int idx=0;idx<8;idx++) { 00211 DVDR3510.setUDC(0, WHEEL_ANI[idx]); 00212 DVDR3510.locate(0); 00213 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); 00214 00215 wait(0.1); 00216 } 00217 } 00218 #endif 00219 } 00220 00221 if (keydata[3] == 0x20) { //open/close 00222 DVDR3510.cls(); 00223 // 01234567 00224 DVDR3510.printf("Hi mbed"); 00225 } 00226 00227 00228 if (keydata[2] == 0x20) { //rec 00229 00230 #if(1) 00231 //test to show all icons 00232 pc.printf("Show all icons\r\n"); 00233 wait(1); 00234 DVDR3510.cls(true); // Also clear all Icons 00235 wait(1); 00236 00237 float delay=0.1; 00238 DVDR3510.setIcon(PT6315_DVDR3510::RCV); wait(delay); 00239 DVDR3510.setIcon(PT6315_DVDR3510::TV); wait(delay); 00240 DVDR3510.setIcon(PT6315_DVDR3510::DRT); wait(delay); 00241 DVDR3510.setIcon(PT6315_DVDR3510::TMR); wait(delay); 00242 DVDR3510.setIcon(PT6315_DVDR3510::COL4); wait(delay); 00243 DVDR3510.setIcon(PT6315_DVDR3510::PRS); wait(delay); 00244 DVDR3510.setIcon(PT6315_DVDR3510::COL6); wait(delay); 00245 DVDR3510.setIcon(PT6315_DVDR3510::DP6); wait(delay); 00246 DVDR3510.setIcon(PT6315_DVDR3510::SAT); wait(delay); 00247 wait(delay); 00248 DVDR3510.clrIcon(PT6315_DVDR3510::RCV); wait(delay); 00249 DVDR3510.clrIcon(PT6315_DVDR3510::TV); wait(delay); 00250 DVDR3510.clrIcon(PT6315_DVDR3510::DRT); wait(delay); 00251 DVDR3510.clrIcon(PT6315_DVDR3510::TMR); wait(delay); 00252 DVDR3510.clrIcon(PT6315_DVDR3510::COL4); wait(delay); 00253 DVDR3510.clrIcon(PT6315_DVDR3510::PRS); wait(delay); 00254 DVDR3510.clrIcon(PT6315_DVDR3510::COL6); wait(delay); 00255 DVDR3510.clrIcon(PT6315_DVDR3510::DP6); wait(delay); 00256 DVDR3510.clrIcon(PT6315_DVDR3510::SAT); wait(delay); 00257 wait(1); 00258 DVDR3510.cls(); // clear all, preserve Icons 00259 pc.printf("Show all icons done\r\n"); 00260 #endif 00261 } 00262 00263 if (keydata[2] == 0x08) { //prev 00264 //write LEDs off 00265 DVDR3510.setLED(0x07); 00266 } 00267 00268 if (keydata[2] == 0x80) { //next 00269 //write LEDs on 00270 DVDR3510.setLED(0x00); 00271 } 00272 00273 if (keydata[3] == 0x02) { //stop 00274 } 00275 00276 if (keydata[3] == 0x80) { //play 00277 } 00278 00279 } //if Key 00280 00281 00282 00283 myled = !myled; 00284 wait(0.3); 00285 } //while 00286 } 00287 #endif 00288 00289 00290 #if(PT6315_TEST == 1) 00291 // Direct PT6315 Test 00292 #include "mbed.h" 00293 #include "PT6315.h" 00294 00295 Serial pc(USBTX, USBRX); 00296 DigitalOut myled(LED1); 00297 00298 // DisplayData_t size is 24 bytes (8 digits @ max 20 segments) ... 48 bytes (16 digits @ max 12 segments) 00299 // DisplayData_t size default is 48 bytes (16 Grids @ 12 Segments) 00300 PT6315::DisplayData_t all_str = {0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, \ 00301 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, \ 00302 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, \ 00303 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00, 0xFF,0x0F,0x00}; 00304 00305 PT6315::DisplayData_t cls_str = {0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ 00306 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, \ 00307 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00}; 00308 00309 // KeyData_t size is 6 bytes 00310 PT6315::KeyData_t keydata; 00311 00312 // Switchdata is 1 byte 00313 char switchdata; 00314 00315 PT6315 PT6315(p5,p6,p7, p8); 00316 //PT6315 PT6315(p5,p6,p7, p8, PT6315::Grid16_Seg12); 00317 00318 char cmd, bits; 00319 int main() { 00320 00321 pc.printf("Hello World\r\n"); // 00322 00323 PT6315.cls(); 00324 PT6315.writeData(all_str); 00325 wait(4); 00326 PT6315.setBrightness(PT6315_BRT3); 00327 wait(1); 00328 PT6315.setBrightness(PT6315_BRT0); 00329 wait(1); 00330 PT6315.setBrightness(PT6315_BRT7); 00331 00332 while (1) { 00333 00334 // Check and read keydata 00335 if (PT6315.getKeys(&keydata)) { 00336 pc.printf("Keydata 0..3 = 0x%02x 0x%02x 0x%02x 0x%02x\r\n", keydata[0], keydata[1], keydata[2], keydata[3]); 00337 00338 if (keydata[0] == 0x01) { //play 00339 PT6315.cls(); 00340 PT6315.writeData(all_str); 00341 } 00342 00343 if (keydata[0] == 0x02) { //stop 00344 PT6315.cls(); 00345 PT6315.writeData(cls_str); 00346 } 00347 00348 if (keydata[0] == 0x04) { //open/close 00349 PT6315.cls(); 00350 PT6315.writeData(all_str); 00351 00352 #if(1) 00353 //test to show all segs 00354 pc.printf("Show all segs\r\n"); 00355 wait(1); 00356 PT6315.cls(); 00357 00358 for (int i=0; i<PT6315_DISPLAY_MEM; i++) { 00359 for (int bit=0; bit<8; bit++) { 00360 PT6315.cls(); 00361 00362 bits = 0x01 << bit; 00363 PT6315.writeData(i, bits); 00364 00365 pc.printf("Idx = %d, Bits = 0x%02x\r\n", i, bits); 00366 // wait(0.5); 00367 cmd = pc.getc(); // wait for key 00368 } 00369 } 00370 pc.printf("Show all segs done\r\n"); 00371 #endif 00372 00373 } 00374 00375 } //if Key 00376 00377 myled = !myled; 00378 wait(0.3); 00379 } //while 00380 } 00381 #endif
Generated on Thu Jul 14 2022 21:30:35 by 1.7.2