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 LC75711 Test program, for Sanyo LC75711 VFD controller 00002 * Copyright (c) 2017, v01: WH, Initial version 00003 * 2017, v02: WH, Modified setBlink 00004 * 00005 * Permission is hereby granted, free of charge, to any person obtaining a copy 00006 * of this software and associated documentation files (the "Software"), to deal 00007 * in the Software without restriction, including without limitation the rights 00008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 * copies of the Software, and to permit persons to whom the Software is 00010 * furnished to do so, subject to the following conditions: 00011 * 00012 * The above copyright notice and this permission notice shall be included in 00013 * all copies or substantial portions of the Software. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00021 * THE SOFTWARE. 00022 */ 00023 #include "mbed.h" 00024 #include "LC75711.h" 00025 00026 // Select one of the testboards for Sanyo LC75711 VFD controller 00027 #include "LC75711_Config.h" 00028 00029 #if (ASTON_TEST == 1) 00030 00031 // LC75711 Test 00032 #include "mbed.h" 00033 #include "LC75711.h" 00034 00035 DigitalOut myled(LED1); 00036 Serial pc(USBTX, USBRX); 00037 00038 LC75711_ASTON LC75711(p5, p7, p8); 00039 00040 void show_menu() { 00041 // pc.printf("0: Exit\n\r"); 00042 pc.printf("1: All\n\r"); 00043 pc.printf("2: Show UDC chars\n\r"); 00044 pc.printf("3: Show all chars\n\r"); 00045 pc.printf("4: Show all digits\n\r"); 00046 pc.printf("5: Show all icons\n\r"); 00047 pc.printf("6: Counter\n\r"); 00048 pc.printf("7: Floats\n\r"); 00049 pc.printf("8: Kitt\n\r"); 00050 pc.printf("9: Cls\n\r"); 00051 pc.printf("A/B: Blink On/Off\n\r"); 00052 pc.printf("C/D: Display On/Off\n\r"); 00053 pc.printf("X: Bye\n\r"); 00054 } 00055 00056 00057 int main() { 00058 pc.printf("Hello World: LC75711 test\n\r"); 00059 00060 LC75711.locate(0); 00061 LC75711.printf("Hello mbed"); 00062 00063 LC75711.setBrightness(LC75711_BRT_4); 00064 wait(1); 00065 LC75711.setBrightness(LC75711_BRT_1); 00066 wait(1); 00067 LC75711.setBrightness(LC75711_BRT_4); 00068 wait(1); 00069 00070 char cmd, cmd2 = '0'; 00071 while (1) { 00072 00073 show_menu(); 00074 cmd2 = pc.getc(); 00075 00076 switch (cmd2) { 00077 case '1' : { 00078 pc.printf("all\r\n"); 00079 LC75711.cls(); 00080 LC75711.printf("Hello mbed"); 00081 break; 00082 } 00083 00084 00085 case '2' : { 00086 pc.printf("UDC\r\n"); 00087 LC75711.cls(); 00088 00089 // Note that UDC_idx=0 is reserved for Grid11 to display Icons 00090 LC75711.setUDC(1, (char *) udc_checker); 00091 LC75711.setUDC(2, (char *) udc_Bat_Hi); 00092 LC75711.setUDC(3, (char *) udc_Bat_Ha); 00093 LC75711.setUDC(4, (char *) udc_Bat_Lo); 00094 LC75711.locate(0); 00095 LC75711.putc((char) 1); 00096 LC75711.putc((char) 2); 00097 LC75711.putc((char) 3); 00098 LC75711.putc((char) 4); 00099 00100 break; 00101 } 00102 00103 case '3' : { 00104 #if(1) 00105 //test to show all chars 00106 pc.printf("Show all alpha chars\r\n"); 00107 wait(1); 00108 LC75711.cls(); 00109 00110 for (int i=0; i<26; i++) { 00111 LC75711.printf("%c", char(i + 'A')); 00112 // LC75711.printf("%c", char(i + 'a')); 00113 wait(0.25); 00114 } 00115 pc.printf("Show all alpha chars done\r\n"); 00116 #endif 00117 break; 00118 } 00119 00120 case '4': { 00121 #if(0) 00122 //test to show all digits (base is 10) 00123 pc.printf("Show all digits\r\n"); 00124 wait(1); 00125 LC75711.cls(); 00126 00127 for (int i=0; i<LC75711_NR_DIGITS; i++) { 00128 00129 for (int cnt=0; cnt<10; cnt++) { 00130 LC75711.locate(i); 00131 LC75711.printf("%0d", cnt); 00132 00133 // wait(0.5); 00134 cmd = pc.getc(); // wait for key 00135 } 00136 } 00137 pc.printf("\r\nShow all digits done\r\n"); 00138 #endif 00139 00140 #if(1) 00141 //test to show all digits (base is 0x10) 00142 pc.printf("Show all hex digits\r\n"); 00143 wait(1); 00144 LC75711.cls(); 00145 00146 LC75711.printf("%010X", 0x0123ABCDEF); 00147 cmd = pc.getc(); // wait for key 00148 LC75711.printf("%010X", 0x0); 00149 00150 for (int i=0; i<ASTON_NR_DIGITS; i++) { 00151 00152 for (int cnt=0; cnt<0x10; cnt++) { 00153 LC75711.locate(i); 00154 LC75711.printf("%0X", cnt); 00155 00156 // wait(0.5); 00157 cmd = pc.getc(); // wait for key 00158 } 00159 } 00160 pc.printf("\r\nShow all hex digits done\r\n"); 00161 #endif 00162 break; 00163 } 00164 00165 case '5': { 00166 #if(1) 00167 //test to show all icons 00168 pc.printf("Show all icons\r\n"); 00169 LC75711.cls(true); // Also clear all Icons 00170 00171 #if(0) 00172 // activate each icon sequentially to find mapping 00173 char udc[7] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00}; 00174 for (int row=0; row<7; row++) { 00175 for (int bit=0; bit<5; bit++) { 00176 udc[row] = (1 << bit); 00177 LC75711.setUDC(0, (char *) udc); 00178 pc.printf("Icon row= %d, bit= %d\r\n", row, bit); 00179 cmd = pc.getc(); // wait for key 00180 } 00181 udc[row] = 0x00; 00182 } 00183 #endif 00184 00185 float delay=0.1; 00186 00187 // Icons on 00188 LC75711.setIcon(LC75711_ASTON::R0); wait(delay); 00189 LC75711.setIcon(LC75711_ASTON::R1); wait(delay); 00190 LC75711.setIcon(LC75711_ASTON::R2); wait(delay); 00191 LC75711.setIcon(LC75711_ASTON::R3); wait(delay); 00192 LC75711.setIcon(LC75711_ASTON::CRD1); wait(delay); 00193 LC75711.setIcon(LC75711_ASTON::CRD2); wait(delay); 00194 LC75711.setIcon(LC75711_ASTON::CARD); wait(delay); 00195 LC75711.setIcon(LC75711_ASTON::KEY); wait(delay); 00196 LC75711.setIcon(LC75711_ASTON::VDCRP); wait(delay); 00197 LC75711.setIcon(LC75711_ASTON::D); wait(delay); 00198 LC75711.setIcon(LC75711_ASTON::D2); wait(delay); 00199 LC75711.setIcon(LC75711_ASTON::MAC); wait(delay); 00200 LC75711.setIcon(LC75711_ASTON::R16_9); wait(delay); 00201 LC75711.setIcon(LC75711_ASTON::DISH); wait(delay); 00202 LC75711.setIcon(LC75711_ASTON::DSH1); wait(delay); 00203 LC75711.setIcon(LC75711_ASTON::DSH2); wait(delay); 00204 LC75711.setIcon(LC75711_ASTON::TMR); wait(delay); 00205 LC75711.setIcon(LC75711_ASTON::CBND); wait(delay); 00206 LC75711.setIcon(LC75711_ASTON::KBND); wait(delay); 00207 LC75711.setIcon(LC75711_ASTON::AFC); wait(delay); 00208 00209 wait(delay); 00210 00211 // Icons off 00212 LC75711.clrIcon(LC75711_ASTON::AFC); wait(delay); 00213 LC75711.clrIcon(LC75711_ASTON::KBND); wait(delay); 00214 LC75711.clrIcon(LC75711_ASTON::CBND); wait(delay); 00215 LC75711.clrIcon(LC75711_ASTON::TMR); wait(delay); 00216 LC75711.clrIcon(LC75711_ASTON::DSH2); wait(delay); 00217 LC75711.clrIcon(LC75711_ASTON::DSH1); wait(delay); 00218 LC75711.clrIcon(LC75711_ASTON::DISH); wait(delay); 00219 LC75711.clrIcon(LC75711_ASTON::R16_9); wait(delay); 00220 LC75711.clrIcon(LC75711_ASTON::MAC); wait(delay); 00221 LC75711.clrIcon(LC75711_ASTON::D2); wait(delay); 00222 LC75711.clrIcon(LC75711_ASTON::D); wait(delay); 00223 LC75711.clrIcon(LC75711_ASTON::VDCRP); wait(delay); 00224 LC75711.clrIcon(LC75711_ASTON::KEY); wait(delay); 00225 LC75711.clrIcon(LC75711_ASTON::CRD2); wait(delay); 00226 LC75711.clrIcon(LC75711_ASTON::CRD1); wait(delay); 00227 LC75711.clrIcon(LC75711_ASTON::CARD); wait(delay); 00228 LC75711.clrIcon(LC75711_ASTON::R3); wait(delay); 00229 LC75711.clrIcon(LC75711_ASTON::R2); wait(delay); 00230 LC75711.clrIcon(LC75711_ASTON::R1); wait(delay); 00231 LC75711.clrIcon(LC75711_ASTON::R0); wait(delay); 00232 00233 pc.printf("Show all icons done\r\n"); 00234 #endif 00235 break; 00236 } 00237 00238 case '6': { 00239 pc.printf("Show counter\r\n"); 00240 LC75711.cls(); // clear all, preserve Icons 00241 00242 #if(1) 00243 LC75711.locate(0); 00244 LC75711.printf("Cnt="); 00245 for (int cnt=0; cnt<=0xFF; cnt++) { 00246 LC75711.locate(8); 00247 LC75711.printf("%02X", cnt); 00248 wait(0.2); 00249 } 00250 #endif 00251 break; 00252 } 00253 00254 case '7': { 00255 pc.printf("Show floats\r\n"); 00256 00257 LC75711.cls(); // clear all, preserve Icons 00258 LC75711.printf("%1.7f", -0.1234567); // test decimal point display 00259 wait(0.5); 00260 LC75711.cls(); // clear all, preserve Icons 00261 LC75711.printf("%3.6f", 123.456789); // test decimal point display 00262 break; 00263 } 00264 00265 case '8': { 00266 00267 #if(1) 00268 //test to show KITT 00269 pc.printf("Show KITT scanner\r\n"); 00270 00271 // 0123456789 00272 const char KITT[][11] = {{"8 "}, 00273 {"38 "}, 00274 {" 38 "}, 00275 {" 38 "}, 00276 {" 38 "}, 00277 {" 38 "}, 00278 {" 38 "}, 00279 {" 38 "}, 00280 {" 38 "}, 00281 {" 38"}, 00282 {" 3"}, 00283 {" "}, 00284 {" 8"}, 00285 {" 8E"}, 00286 {" 8E "}, 00287 {" 8E "}, 00288 {" 8E "}, 00289 {" 8E "}, 00290 {" 8E "}, 00291 {" 8E "}, 00292 {" 8E "}, 00293 {"8E "}, 00294 {"E "}, 00295 {" "} 00296 }; 00297 00298 LC75711.cls(); // clear all, preserve Icons 00299 00300 while (!pc.readable()) { // wait for key 00301 for (int i=0; i < (sizeof(KITT) / 11) ; i++) { 00302 LC75711.locate(0); 00303 LC75711.printf("%s", KITT[i]); 00304 wait(0.1); 00305 } 00306 } 00307 cmd = pc.getc(); // read key 00308 pc.printf("Show KITT done\r\n"); 00309 #endif 00310 break; 00311 } 00312 00313 00314 case '9': { 00315 LC75711.cls(true); // clear all, including Icons 00316 break; 00317 } 00318 00319 case 'A': { 00320 //Blink some grids 00321 LC75711.setBlink( (LC75711_GR1 | LC75711_GR2 | LC75711_GR3 | LC75711_GR4) ); 00322 break; 00323 } 00324 00325 case 'B': { 00326 //Disable Blinking grids 00327 LC75711.clrBlink(LC75711_GR3); // Clear GR3 Blink 00328 wait(2); 00329 LC75711.clrBlink(); //Clear All 00330 00331 break; 00332 } 00333 00334 case 'C': { 00335 //Display On 00336 LC75711.setDisplay(true); 00337 break; 00338 } 00339 00340 case 'D': { 00341 //Display Off 00342 LC75711.setDisplay(false); 00343 00344 break; 00345 } 00346 00347 case 'X': { 00348 LC75711.cls(); // clear all, preserve Icons 00349 LC75711.printf("Bye"); 00350 00351 break; 00352 } 00353 00354 default : { 00355 break; 00356 } 00357 00358 } //switch cmd 00359 00360 myled = !myled; 00361 wait(0.3); 00362 } 00363 } 00364 #endif 00365 00366 00367 #if (LC75711_TEST == 1) 00368 00369 // LC75711 Bare Metal Test 00370 #include "mbed.h" 00371 #include "LC75711.h" 00372 00373 DigitalOut myled(LED1); 00374 Serial pc(USBTX, USBRX); 00375 00376 // LC75711 declaration, Default setting 16 Grids @ 35 Segments 00377 LC75711 LC75711(p5, p7, p8); // DI, CLK, CS 00378 00379 int main() { 00380 pc.printf("Hello World: LC75711 test\n\r"); 00381 00382 LC75711.writeData((char)'H', 9); 00383 LC75711.writeData((char)'e', 8); 00384 LC75711.writeData((char)'l', 7); 00385 LC75711.writeData((char)'l', 6); 00386 LC75711.writeData((char)'o', 5); 00387 00388 LC75711.setBlink(true, (LC75711_GR10 | LC75711_GR9 | LC75711_GR8 | LC75711_GR7 | LC75711_GR6) ); 00389 00390 while(1) { 00391 myled = !myled; 00392 wait(1); 00393 } 00394 } 00395 #endif
Generated on Sun Jul 17 2022 04:47:20 by
1.7.2
LC75711 VFD Driver for upto 16 Dot Matrix Characters,