Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 /* mbed PT6301 Test program, for Princeton PT6301 VFD controller 00002 * The controller is used by Futaba 'Chip In Glass' (CIG) VFD tubes. 00003 * 00004 * Copyright (c) 2021, v01: WH, Initial version 00005 * 00006 * Permission is hereby granted, free of charge, to any person obtaining a copy 00007 * of this software and associated documentation files (the "Software"), to deal 00008 * in the Software without restriction, including without limitation the rights 00009 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00010 * copies of the Software, and to permit persons to whom the Software is 00011 * furnished to do so, subject to the following conditions: 00012 * 00013 * The above copyright notice and this permission notice shall be included in 00014 * all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00019 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00022 * THE SOFTWARE. 00023 */ 00024 #include "mbed.h" 00025 #include "PT6301.h" 00026 00027 // Select one of the testboards for Princeton PT6301 VFD controller 00028 #include "PT6301_Config.h" 00029 00030 00031 #if (SMTG7400_TEST == 1) 00032 00033 DigitalOut myled(LED1); 00034 Serial pc(USBTX, USBRX); 00035 00036 // PT6301_SMTG7400 declaration, Default setting 16 Grids @ 5x7 Segments, with 4 additional Icons and 1 Row 00037 PT6301_SMTG7400 PT6301(p5, p7, p8, p9); // DI, CLK, CS, RST 00038 00039 int main() { 00040 pc.printf("Hello World: PT6301_SMTG7400 test\n\r"); 00041 00042 // PT6301.printf("Hello World"); 00043 PT6301.printf("Hello World %1.2f", 1.23); 00044 PT6301.refresh(); 00045 00046 PT6301.setBrightness(PT6301_BRT_6); 00047 wait(1); 00048 PT6301.setBrightness(PT6301_BRT_DEF); 00049 wait(1); 00050 00051 PT6301.setIcon(SMTG7400_ICON_OFFLINE); 00052 PT6301.setIcon(SMTG7400_ICON_WIFI); 00053 PT6301.setIcon(SMTG7400_ICON_PHONE); 00054 PT6301.setIcon(SMTG7400_ICON_REC); 00055 PT6301.refresh(); 00056 wait(1); 00057 00058 PT6301.cls(); 00059 // PT6301.locate(0, 0); 00060 PT6301.setUDC(0, (char*) udc_LAR); 00061 PT6301.setUDC(1, (char*) udc_RAR); 00062 PT6301.putc(char(0)); 00063 PT6301.putc(char(1)); 00064 PT6301.refresh(); 00065 wait(1); 00066 00067 while(1) { 00068 myled = !myled; 00069 PT6301.clrIcon(SMTG7400_ICON_OFFLINE); 00070 PT6301.refresh(); 00071 wait(1); 00072 00073 myled = !myled; 00074 PT6301.setIcon(SMTG7400_ICON_OFFLINE); 00075 PT6301.refresh(); 00076 wait(1); 00077 } 00078 } 00079 #endif 00080 00081 00082 00083 00084 00085 #if (SMTC7140_TEST == 1) 00086 00087 // PT6301 Test 00088 #include "mbed.h" 00089 #include "PT6301.h" 00090 00091 DigitalOut myled(LED1); 00092 Serial pc(USBTX, USBRX); 00093 00094 // PT6301_SMTC7140 declaration, Default setting 12 Grids @ 5x7 Segments, without additional Icons, 2 Rows. Separate Grid13 for Icons 00095 PT6301_SMTC7140 PT6301(p5, p7, p8, p9); 00096 00097 void show_menu() { 00098 // pc.printf("0: Exit\n\r"); 00099 pc.printf("1: All\n\r"); 00100 pc.printf("2: Show UDC chars\n\r"); 00101 pc.printf("3: Show all chars\n\r"); 00102 pc.printf("4: Show all digits\n\r"); 00103 pc.printf("5: Show all icons\n\r"); 00104 pc.printf("6: Counter\n\r"); 00105 pc.printf("7: Floats\n\r"); 00106 pc.printf("8: Kitt\n\r"); 00107 pc.printf("9: Cls\n\r"); 00108 pc.printf("A: Display All Off / Normal\n\r"); 00109 pc.printf("B: Display All On / Normal\n\r"); 00110 pc.printf("C: Bye\n\r"); 00111 } 00112 00113 00114 int main() { 00115 pc.printf("Hello World: PT6301 SMTC7140 test\n\r"); 00116 00117 PT6301.locate(0, 0); 00118 PT6301.printf("Hello mbed"); 00119 PT6301.refresh(); 00120 wait(1); 00121 00122 PT6301.setBrightness(PT6301_BRT_7); 00123 wait(1); 00124 // PT6301.setBrightness(PT6301_BRT_0); 00125 // wait(1); 00126 PT6301.setBrightness(PT6301_BRT_DEF); 00127 00128 char cmd, cmd2 = '0'; 00129 while (1) { 00130 00131 show_menu(); 00132 cmd2 = pc.getc(); 00133 00134 switch (cmd2) { 00135 case '1' : { 00136 pc.printf("all\r\n"); 00137 PT6301.cls(); 00138 PT6301.printf("Hello mbed"); 00139 PT6301.refresh(); 00140 break; 00141 } 00142 00143 00144 case '2' : { 00145 pc.printf("UDC\r\n"); 00146 PT6301.cls(); 00147 PT6301.refresh(); 00148 00149 // Store UDC_idx=0, reserved for Icons on SMTC7140 00150 00151 // Store UDC_idx=1, 2 00152 PT6301.setUDC(1, (char *) udc_LAR); // Left Arrow 00153 PT6301.setUDC(2, (char *) udc_RAR); // Right Arrow 00154 00155 // Show UDC_idx=1, 2 00156 PT6301.locate(0,0); 00157 PT6301.putc((char) 1); 00158 PT6301.putc((char) 2); 00159 PT6301.refresh(); 00160 pc.printf("\r\nShow all UDC done\r\n"); 00161 break; 00162 } 00163 00164 case '3' : { 00165 #if(1) 00166 //test to show all chars 00167 pc.printf("Show all alpha chars\r\n"); 00168 wait(1); 00169 PT6301.cls(); 00170 00171 for (int i=0; i<26; i++) { 00172 PT6301.printf("%c", char(i + 'A')); 00173 PT6301.printf("%c", char(i + 'a')); 00174 PT6301.refresh(); 00175 wait(0.25); 00176 } 00177 pc.printf("Show all alpha chars done\r\n"); 00178 #endif 00179 break; 00180 } 00181 00182 case '4': { 00183 #if(0) 00184 //test to show all digits (base is 10) 00185 pc.printf("Show all digits\r\n"); 00186 wait(1); 00187 PT6301.cls(); 00188 00189 for (int i=0; i<SMTC7140_NR_COLS; i++) { 00190 00191 for (int cnt=0; cnt<10; cnt++) { 00192 PT6301.locate(0, i); 00193 PT6301.printf("%0d", cnt); 00194 PT6301.refresh(); 00195 00196 // wait(0.5); 00197 cmd = pc.getc(); // wait for key 00198 } 00199 } 00200 pc.printf("\r\nShow all digits done\r\n"); 00201 #endif 00202 00203 #if(1) 00204 //test to show all digits (base is 0x10) 00205 pc.printf("Show all hex digits\r\n"); 00206 wait(1); 00207 PT6301.cls(); 00208 00209 PT6301.printf("%010X", 0x0123ABCDEF); 00210 PT6301.refresh(); 00211 cmd = pc.getc(); // wait for key 00212 PT6301.locate(0,0); 00213 PT6301.printf("%012X", 0x0); 00214 PT6301.refresh(); 00215 00216 for (int i=0; i<SMTC7140_NR_COLS; i++) { 00217 // for (int i=0; i<1; i++) { 00218 00219 for (int cnt=0; cnt<0x10; cnt++) { 00220 PT6301.locate(0, i); 00221 PT6301.printf("%0X", cnt); 00222 PT6301.refresh(); 00223 // pc.printf("%0X", cnt); 00224 // wait(0.5); 00225 cmd = pc.getc(); // wait for key 00226 } 00227 } 00228 pc.printf("\r\nShow all hex digits done\r\n"); 00229 #endif 00230 break; 00231 } 00232 00233 case '5': { 00234 pc.printf("\r\nShow all icon bits\r\n"); 00235 // PT6301.cls(); 00236 // PT6301.refresh(); 00237 00238 // Store UDC_idx=0, reserved for Icons on SMTC7140 00239 // Show UDC_idx=0 on Position (0, 12), ie Grid13 00240 #if(0) 00241 //Test version to check all bits 00242 for (int i=0; i<5; i++) { 00243 char bits = 0x40; 00244 00245 for (int cnt=0; cnt<7; cnt++) { 00246 PT6301.setIconGrid13( (i << 8) | bits); // Test 00247 pc.printf("Showing icon [%d] => bits 0x%0X\r\n", i, bits); 00248 bits = bits >> 1; 00249 cmd = pc.getc(); // wait for key 00250 } 00251 } 00252 pc.printf("\r\nShow all icon bits done\r\n"); 00253 #else 00254 pc.printf("\r\nShow all icon bits\r\n"); 00255 cmd = pc.getc(); // wait for key 00256 PT6301.setIconGrid13(SMTC7140_ICON_DOLBY); 00257 cmd = pc.getc(); // wait for key 00258 PT6301.setIconGrid13(SMTC7140_ICON_PLUS); 00259 cmd = pc.getc(); // wait for key 00260 PT6301.setIconGrid13(SMTC7140_ICON_HD); 00261 cmd = pc.getc(); // wait for key 00262 PT6301.setIconGrid13(SMTC7140_ICON_CLOCK); 00263 cmd = pc.getc(); // wait for key 00264 PT6301.setIconGrid13(SMTC7140_ICON_REC); 00265 cmd = pc.getc(); // wait for key 00266 PT6301.setIconGrid13(SMTC7140_ICON_MAIL); 00267 cmd = pc.getc(); // wait for key 00268 00269 PT6301.clrIconGrid13(SMTC7140_ICON_DOLBY); 00270 cmd = pc.getc(); // wait for key 00271 PT6301.clrIconGrid13(SMTC7140_ICON_PLUS); 00272 cmd = pc.getc(); // wait for key 00273 PT6301.clrIconGrid13(SMTC7140_ICON_HD); 00274 cmd = pc.getc(); // wait for key 00275 PT6301.clrIconGrid13(SMTC7140_ICON_CLOCK); 00276 cmd = pc.getc(); // wait for key 00277 PT6301.clrIconGrid13(SMTC7140_ICON_REC); 00278 cmd = pc.getc(); // wait for key 00279 PT6301.clrIconGrid13(SMTC7140_ICON_MAIL); 00280 cmd = pc.getc(); // wait for key 00281 00282 pc.printf("\r\nShow all icon bits done\r\n"); 00283 #endif 00284 break; 00285 } 00286 00287 case '6': { 00288 pc.printf("Show counter\r\n"); 00289 PT6301.cls(false); // clear all, preserve Icons 00290 00291 #if(1) 00292 PT6301.locate(0, 0); 00293 PT6301.printf("Cnt="); 00294 for (int cnt=0; cnt<=0xFF; cnt++) { 00295 PT6301.locate(0, 8); 00296 PT6301.printf("%02X", cnt); 00297 PT6301.refresh(); 00298 wait(0.2); 00299 } 00300 #endif 00301 break; 00302 } 00303 00304 case '7': { 00305 pc.printf("Show floats\r\n"); 00306 00307 PT6301.cls(false); // clear all, preserve Icons 00308 PT6301.printf("%1.7f", -0.1234567); // test decimal point display 00309 PT6301.refresh(); 00310 wait(0.5); 00311 PT6301.cls(false); // clear all, preserve Icons 00312 PT6301.printf("%3.6f", 123.456789); // test decimal point display 00313 PT6301.refresh(); 00314 break; 00315 } 00316 00317 case '8': { 00318 00319 #if(1) 00320 //test to show KITT 00321 pc.printf("Show KITT scanner\r\n"); 00322 00323 // 0123456789 00324 const char KITT[][11] = {{"8 "}, 00325 {"38 "}, 00326 {" 38 "}, 00327 {" 38 "}, 00328 {" 38 "}, 00329 {" 38 "}, 00330 {" 38 "}, 00331 {" 38 "}, 00332 {" 38 "}, 00333 {" 38"}, 00334 {" 3"}, 00335 {" "}, 00336 {" 8"}, 00337 {" 8E"}, 00338 {" 8E "}, 00339 {" 8E "}, 00340 {" 8E "}, 00341 {" 8E "}, 00342 {" 8E "}, 00343 {" 8E "}, 00344 {" 8E "}, 00345 {"8E "}, 00346 {"E "}, 00347 {" "} 00348 }; 00349 00350 PT6301.cls(false); // clear all, preserve Icons 00351 00352 while (!pc.readable()) { // wait for key 00353 for (int i=0; i < (sizeof(KITT) / 11) ; i++) { 00354 PT6301.locate(0,0); 00355 PT6301.printf("%s", KITT[i]); 00356 PT6301.refresh(); 00357 wait(0.1); 00358 } 00359 } 00360 cmd = pc.getc(); // read key 00361 pc.printf("Show KITT done\r\n"); 00362 #endif 00363 break; 00364 } 00365 00366 case '9': { 00367 PT6301.cls(true); // clear all, including Icons 00368 PT6301.refresh(); 00369 break; 00370 } 00371 00372 case 'A': { 00373 pc.printf("Display All Off / Normal\n\r"); 00374 PT6301.setDisplay(false); 00375 wait(1.0); 00376 PT6301.setDisplay(true); 00377 wait(1.0); 00378 break; 00379 } 00380 00381 case 'B': { 00382 pc.printf("Display All On / Normal\n\r"); 00383 PT6301.setDisplayTest(true); 00384 wait(1.0); 00385 PT6301.setDisplayTest(false); 00386 wait(1.0); 00387 break; 00388 } 00389 00390 case 'C': { 00391 PT6301.cls(false); // clear all, preserve Icons 00392 // PT6301.printf("Bye"); 00393 // "0123456789AB"); 00394 PT6301.printf("Stack...\r\n"); 00395 PT6301.printf(" ..Overflow"); 00396 PT6301.refresh(); 00397 break; 00398 } 00399 00400 default : { 00401 break; 00402 } 00403 00404 } //switch cmd 00405 00406 myled = !myled; 00407 wait(0.3); 00408 } 00409 } 00410 #endif 00411 00412 00413 #if (PT6301_TEST == 1) 00414 00415 // PT6301 Bare Metal Test 00416 #include "mbed.h" 00417 #include "PT6301.h" 00418 00419 DigitalOut myled(LED1); 00420 Serial pc(USBTX, USBRX); 00421 00422 // PT6301 declaration, Default setting 20 Grids @ 5x7 Segments for 2 rows of characters 00423 PT6301 PT6301(p5, p7, p8, p9); // DI, CLK, CS, RST 00424 00425 int main() { 00426 pc.printf("Hello World: PT6301 test\n\r"); 00427 00428 // PT6301.writeData((char)'H', 0, 0); 00429 // PT6301.writeData((char)'e', 0, 1); 00430 // PT6301.writeData((char)'l', 0, 2); 00431 // PT6301.writeData((char)'l', 0, 3); 00432 // PT6301.writeData((char)'o', 0, 4); 00433 PT6301.printf("Hello World"); 00434 PT6301.refresh(); 00435 00436 while(1) { 00437 myled = !myled; 00438 wait(1); 00439 } 00440 } 00441 #endif
Generated on Thu Jul 28 2022 23:25:03 by
1.7.2