Wim Huiskamp
/
mbed_CU209SCPB_T20
Test program for Noritake Itron VFD Module (1 Line, 20 Chars), Serial interface
More info is here.
main.cpp@0:35e8b8e8446a, 2017-12-10 (annotated)
- Committer:
- wim
- Date:
- Sun Dec 10 17:04:13 2017 +0000
- Revision:
- 0:35e8b8e8446a
Test program for Noritake Itron CU209SCPB VFD module
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 0:35e8b8e8446a | 1 | /* mbed CU209SCPB Test program for Noritake Itron CU209SCPB VFD module |
wim | 0:35e8b8e8446a | 2 | * |
wim | 0:35e8b8e8446a | 3 | * Copyright (c) 2017, v01: WH, Initial version |
wim | 0:35e8b8e8446a | 4 | * |
wim | 0:35e8b8e8446a | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
wim | 0:35e8b8e8446a | 6 | * of this software and associated documentation files (the "Software"), to deal |
wim | 0:35e8b8e8446a | 7 | * in the Software without restriction, including without limitation the rights |
wim | 0:35e8b8e8446a | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
wim | 0:35e8b8e8446a | 9 | * copies of the Software, and to permit persons to whom the Software is |
wim | 0:35e8b8e8446a | 10 | * furnished to do so, subject to the following conditions: |
wim | 0:35e8b8e8446a | 11 | * |
wim | 0:35e8b8e8446a | 12 | * The above copyright notice and this permission notice shall be included in |
wim | 0:35e8b8e8446a | 13 | * all copies or substantial portions of the Software. |
wim | 0:35e8b8e8446a | 14 | * |
wim | 0:35e8b8e8446a | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
wim | 0:35e8b8e8446a | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
wim | 0:35e8b8e8446a | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
wim | 0:35e8b8e8446a | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
wim | 0:35e8b8e8446a | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
wim | 0:35e8b8e8446a | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
wim | 0:35e8b8e8446a | 21 | * THE SOFTWARE. |
wim | 0:35e8b8e8446a | 22 | */ |
wim | 0:35e8b8e8446a | 23 | #include "mbed.h" |
wim | 0:35e8b8e8446a | 24 | #include "CU209SCPB.h" |
wim | 0:35e8b8e8446a | 25 | |
wim | 0:35e8b8e8446a | 26 | DigitalOut myled(LED1); |
wim | 0:35e8b8e8446a | 27 | Serial pc(USBTX, USBRX); |
wim | 0:35e8b8e8446a | 28 | |
wim | 0:35e8b8e8446a | 29 | CU209SCPB CU209SCPB(p9); |
wim | 0:35e8b8e8446a | 30 | //CU209SCPB CU209SCPB(p13); |
wim | 0:35e8b8e8446a | 31 | |
wim | 0:35e8b8e8446a | 32 | void show_menu() { |
wim | 0:35e8b8e8446a | 33 | // pc.printf("0: Exit\n\r"); |
wim | 0:35e8b8e8446a | 34 | pc.printf("1: All\n\r"); |
wim | 0:35e8b8e8446a | 35 | pc.printf("2: Show UDC chars\n\r"); |
wim | 0:35e8b8e8446a | 36 | pc.printf("3: Show all chars\n\r"); |
wim | 0:35e8b8e8446a | 37 | pc.printf("4: Show all digits\n\r"); |
wim | 0:35e8b8e8446a | 38 | pc.printf("6: Counter\n\r"); |
wim | 0:35e8b8e8446a | 39 | pc.printf("7: Floats\n\r"); |
wim | 0:35e8b8e8446a | 40 | pc.printf("8: Kitt\n\r"); |
wim | 0:35e8b8e8446a | 41 | pc.printf("9: Cls\n\r"); |
wim | 0:35e8b8e8446a | 42 | pc.printf("A/B: Cursor On/Off\n\r"); |
wim | 0:35e8b8e8446a | 43 | pc.printf("C: Bye\n\r"); |
wim | 0:35e8b8e8446a | 44 | } |
wim | 0:35e8b8e8446a | 45 | |
wim | 0:35e8b8e8446a | 46 | |
wim | 0:35e8b8e8446a | 47 | int main() { |
wim | 0:35e8b8e8446a | 48 | pc.printf("Hello World: CU209SCPB test\n\r"); |
wim | 0:35e8b8e8446a | 49 | |
wim | 0:35e8b8e8446a | 50 | CU209SCPB.locate(0); |
wim | 0:35e8b8e8446a | 51 | CU209SCPB.printf("Hello mbed"); |
wim | 0:35e8b8e8446a | 52 | |
wim | 0:35e8b8e8446a | 53 | CU209SCPB.setBrightness(CU209SCPB_BRT_3); |
wim | 0:35e8b8e8446a | 54 | wait(1); |
wim | 0:35e8b8e8446a | 55 | CU209SCPB.setBrightness(CU209SCPB_BRT_0); |
wim | 0:35e8b8e8446a | 56 | wait(1); |
wim | 0:35e8b8e8446a | 57 | CU209SCPB.setBrightness(CU209SCPB_BRT_DEF); |
wim | 0:35e8b8e8446a | 58 | wait(1); |
wim | 0:35e8b8e8446a | 59 | |
wim | 0:35e8b8e8446a | 60 | char cmd, cmd2 = '0'; |
wim | 0:35e8b8e8446a | 61 | while (1) { |
wim | 0:35e8b8e8446a | 62 | |
wim | 0:35e8b8e8446a | 63 | show_menu(); |
wim | 0:35e8b8e8446a | 64 | cmd2 = pc.getc(); |
wim | 0:35e8b8e8446a | 65 | |
wim | 0:35e8b8e8446a | 66 | switch (cmd2) { |
wim | 0:35e8b8e8446a | 67 | case '1' : { |
wim | 0:35e8b8e8446a | 68 | pc.printf("all\r\n"); |
wim | 0:35e8b8e8446a | 69 | CU209SCPB.cls(); |
wim | 0:35e8b8e8446a | 70 | CU209SCPB.printf("Hello mbed"); |
wim | 0:35e8b8e8446a | 71 | break; |
wim | 0:35e8b8e8446a | 72 | } |
wim | 0:35e8b8e8446a | 73 | |
wim | 0:35e8b8e8446a | 74 | |
wim | 0:35e8b8e8446a | 75 | case '2' : { |
wim | 0:35e8b8e8446a | 76 | pc.printf("UDC\r\n"); |
wim | 0:35e8b8e8446a | 77 | CU209SCPB.cls(); |
wim | 0:35e8b8e8446a | 78 | |
wim | 0:35e8b8e8446a | 79 | // Store UDC_idx=0, 1 |
wim | 0:35e8b8e8446a | 80 | CU209SCPB.setUDC(0, (char *) udc_LAR); // Left Arrow |
wim | 0:35e8b8e8446a | 81 | CU209SCPB.setUDC(1, (char *) udc_RAR); // Right Arrow |
wim | 0:35e8b8e8446a | 82 | |
wim | 0:35e8b8e8446a | 83 | // Show UDC_idx=0, 1 |
wim | 0:35e8b8e8446a | 84 | CU209SCPB.locate(0); |
wim | 0:35e8b8e8446a | 85 | CU209SCPB.putc((char) 0); |
wim | 0:35e8b8e8446a | 86 | CU209SCPB.putc((char) 1); |
wim | 0:35e8b8e8446a | 87 | |
wim | 0:35e8b8e8446a | 88 | break; |
wim | 0:35e8b8e8446a | 89 | } |
wim | 0:35e8b8e8446a | 90 | |
wim | 0:35e8b8e8446a | 91 | case '3' : { |
wim | 0:35e8b8e8446a | 92 | #if(1) |
wim | 0:35e8b8e8446a | 93 | //test to show all chars |
wim | 0:35e8b8e8446a | 94 | pc.printf("Show all alpha chars\r\n"); |
wim | 0:35e8b8e8446a | 95 | wait(1); |
wim | 0:35e8b8e8446a | 96 | CU209SCPB.cls(); |
wim | 0:35e8b8e8446a | 97 | |
wim | 0:35e8b8e8446a | 98 | for (int i=0; i<26; i++) { |
wim | 0:35e8b8e8446a | 99 | CU209SCPB.printf("%c", char(i + 'A')); |
wim | 0:35e8b8e8446a | 100 | CU209SCPB.printf("%c", char(i + 'a')); |
wim | 0:35e8b8e8446a | 101 | wait(0.25); |
wim | 0:35e8b8e8446a | 102 | } |
wim | 0:35e8b8e8446a | 103 | pc.printf("Show all alpha chars done\r\n"); |
wim | 0:35e8b8e8446a | 104 | #endif |
wim | 0:35e8b8e8446a | 105 | break; |
wim | 0:35e8b8e8446a | 106 | } |
wim | 0:35e8b8e8446a | 107 | |
wim | 0:35e8b8e8446a | 108 | case '4': { |
wim | 0:35e8b8e8446a | 109 | #if(0) |
wim | 0:35e8b8e8446a | 110 | //test to show all digits (base is 10) |
wim | 0:35e8b8e8446a | 111 | pc.printf("Show all digits\r\n"); |
wim | 0:35e8b8e8446a | 112 | wait(1); |
wim | 0:35e8b8e8446a | 113 | CU209SCPB.cls(); |
wim | 0:35e8b8e8446a | 114 | |
wim | 0:35e8b8e8446a | 115 | for (int i=0; i<CU209SCPB_NR_COLS; i++) { |
wim | 0:35e8b8e8446a | 116 | |
wim | 0:35e8b8e8446a | 117 | for (int cnt=0; cnt<10; cnt++) { |
wim | 0:35e8b8e8446a | 118 | CU209SCPB.locate(i); |
wim | 0:35e8b8e8446a | 119 | CU209SCPB.printf("%0d", cnt); |
wim | 0:35e8b8e8446a | 120 | |
wim | 0:35e8b8e8446a | 121 | // wait(0.5); |
wim | 0:35e8b8e8446a | 122 | cmd = pc.getc(); // wait for key |
wim | 0:35e8b8e8446a | 123 | } |
wim | 0:35e8b8e8446a | 124 | } |
wim | 0:35e8b8e8446a | 125 | pc.printf("\r\nShow all digits done\r\n"); |
wim | 0:35e8b8e8446a | 126 | #endif |
wim | 0:35e8b8e8446a | 127 | |
wim | 0:35e8b8e8446a | 128 | #if(1) |
wim | 0:35e8b8e8446a | 129 | //test to show all digits (base is 0x10) |
wim | 0:35e8b8e8446a | 130 | pc.printf("Show all hex digits\r\n"); |
wim | 0:35e8b8e8446a | 131 | wait(1); |
wim | 0:35e8b8e8446a | 132 | CU209SCPB.cls(); |
wim | 0:35e8b8e8446a | 133 | |
wim | 0:35e8b8e8446a | 134 | CU209SCPB.printf("%010X", 0x0123ABCDEF); |
wim | 0:35e8b8e8446a | 135 | cmd = pc.getc(); // wait for key |
wim | 0:35e8b8e8446a | 136 | CU209SCPB.locate(0); |
wim | 0:35e8b8e8446a | 137 | CU209SCPB.printf("%020X", 0x0); |
wim | 0:35e8b8e8446a | 138 | |
wim | 0:35e8b8e8446a | 139 | for (int i=0; i<CU209SCPB_NR_COLS; i++) { |
wim | 0:35e8b8e8446a | 140 | // for (int i=0; i<1; i++) { |
wim | 0:35e8b8e8446a | 141 | |
wim | 0:35e8b8e8446a | 142 | for (int cnt=0; cnt<0x10; cnt++) { |
wim | 0:35e8b8e8446a | 143 | CU209SCPB.locate(i); |
wim | 0:35e8b8e8446a | 144 | CU209SCPB.printf("%0X", cnt); |
wim | 0:35e8b8e8446a | 145 | // pc.printf("%0X", cnt); |
wim | 0:35e8b8e8446a | 146 | // wait(0.5); |
wim | 0:35e8b8e8446a | 147 | cmd = pc.getc(); // wait for key |
wim | 0:35e8b8e8446a | 148 | } |
wim | 0:35e8b8e8446a | 149 | } |
wim | 0:35e8b8e8446a | 150 | pc.printf("\r\nShow all hex digits done\r\n"); |
wim | 0:35e8b8e8446a | 151 | #endif |
wim | 0:35e8b8e8446a | 152 | break; |
wim | 0:35e8b8e8446a | 153 | } |
wim | 0:35e8b8e8446a | 154 | |
wim | 0:35e8b8e8446a | 155 | case '5': { |
wim | 0:35e8b8e8446a | 156 | break; |
wim | 0:35e8b8e8446a | 157 | } |
wim | 0:35e8b8e8446a | 158 | |
wim | 0:35e8b8e8446a | 159 | case '6': { |
wim | 0:35e8b8e8446a | 160 | pc.printf("Show counter\r\n"); |
wim | 0:35e8b8e8446a | 161 | CU209SCPB.cls(); // clear all, preserve Icons |
wim | 0:35e8b8e8446a | 162 | |
wim | 0:35e8b8e8446a | 163 | #if(1) |
wim | 0:35e8b8e8446a | 164 | CU209SCPB.locate(0); |
wim | 0:35e8b8e8446a | 165 | CU209SCPB.printf("Cnt="); |
wim | 0:35e8b8e8446a | 166 | for (int cnt=0; cnt<=0xFF; cnt++) { |
wim | 0:35e8b8e8446a | 167 | CU209SCPB.locate(8); |
wim | 0:35e8b8e8446a | 168 | CU209SCPB.printf("%02X", cnt); |
wim | 0:35e8b8e8446a | 169 | wait(0.2); |
wim | 0:35e8b8e8446a | 170 | } |
wim | 0:35e8b8e8446a | 171 | #endif |
wim | 0:35e8b8e8446a | 172 | break; |
wim | 0:35e8b8e8446a | 173 | } |
wim | 0:35e8b8e8446a | 174 | |
wim | 0:35e8b8e8446a | 175 | case '7': { |
wim | 0:35e8b8e8446a | 176 | pc.printf("Show floats\r\n"); |
wim | 0:35e8b8e8446a | 177 | |
wim | 0:35e8b8e8446a | 178 | CU209SCPB.cls(); // clear all, preserve Icons |
wim | 0:35e8b8e8446a | 179 | CU209SCPB.printf("%1.7f", -0.1234567); // test decimal point display |
wim | 0:35e8b8e8446a | 180 | wait(0.5); |
wim | 0:35e8b8e8446a | 181 | CU209SCPB.cls(); // clear all, preserve Icons |
wim | 0:35e8b8e8446a | 182 | CU209SCPB.printf("%3.6f", 123.456789); // test decimal point display |
wim | 0:35e8b8e8446a | 183 | break; |
wim | 0:35e8b8e8446a | 184 | } |
wim | 0:35e8b8e8446a | 185 | |
wim | 0:35e8b8e8446a | 186 | case '8': { |
wim | 0:35e8b8e8446a | 187 | |
wim | 0:35e8b8e8446a | 188 | #if(1) |
wim | 0:35e8b8e8446a | 189 | //test to show KITT |
wim | 0:35e8b8e8446a | 190 | pc.printf("Show KITT scanner\r\n"); |
wim | 0:35e8b8e8446a | 191 | |
wim | 0:35e8b8e8446a | 192 | // 0123456789 |
wim | 0:35e8b8e8446a | 193 | const char KITT[][11] = {{"8 "}, |
wim | 0:35e8b8e8446a | 194 | {"38 "}, |
wim | 0:35e8b8e8446a | 195 | {" 38 "}, |
wim | 0:35e8b8e8446a | 196 | {" 38 "}, |
wim | 0:35e8b8e8446a | 197 | {" 38 "}, |
wim | 0:35e8b8e8446a | 198 | {" 38 "}, |
wim | 0:35e8b8e8446a | 199 | {" 38 "}, |
wim | 0:35e8b8e8446a | 200 | {" 38 "}, |
wim | 0:35e8b8e8446a | 201 | {" 38 "}, |
wim | 0:35e8b8e8446a | 202 | {" 38"}, |
wim | 0:35e8b8e8446a | 203 | {" 3"}, |
wim | 0:35e8b8e8446a | 204 | {" "}, |
wim | 0:35e8b8e8446a | 205 | {" 8"}, |
wim | 0:35e8b8e8446a | 206 | {" 8E"}, |
wim | 0:35e8b8e8446a | 207 | {" 8E "}, |
wim | 0:35e8b8e8446a | 208 | {" 8E "}, |
wim | 0:35e8b8e8446a | 209 | {" 8E "}, |
wim | 0:35e8b8e8446a | 210 | {" 8E "}, |
wim | 0:35e8b8e8446a | 211 | {" 8E "}, |
wim | 0:35e8b8e8446a | 212 | {" 8E "}, |
wim | 0:35e8b8e8446a | 213 | {" 8E "}, |
wim | 0:35e8b8e8446a | 214 | {"8E "}, |
wim | 0:35e8b8e8446a | 215 | {"E "}, |
wim | 0:35e8b8e8446a | 216 | {" "} |
wim | 0:35e8b8e8446a | 217 | }; |
wim | 0:35e8b8e8446a | 218 | |
wim | 0:35e8b8e8446a | 219 | CU209SCPB.cls(); // clear all, preserve Icons |
wim | 0:35e8b8e8446a | 220 | |
wim | 0:35e8b8e8446a | 221 | while (!pc.readable()) { // wait for key |
wim | 0:35e8b8e8446a | 222 | for (int i=0; i < (sizeof(KITT) / 11) ; i++) { |
wim | 0:35e8b8e8446a | 223 | CU209SCPB.locate(0); |
wim | 0:35e8b8e8446a | 224 | CU209SCPB.printf("%s", KITT[i]); |
wim | 0:35e8b8e8446a | 225 | wait(0.1); |
wim | 0:35e8b8e8446a | 226 | } |
wim | 0:35e8b8e8446a | 227 | } |
wim | 0:35e8b8e8446a | 228 | cmd = pc.getc(); // read key |
wim | 0:35e8b8e8446a | 229 | pc.printf("Show KITT done\r\n"); |
wim | 0:35e8b8e8446a | 230 | #endif |
wim | 0:35e8b8e8446a | 231 | break; |
wim | 0:35e8b8e8446a | 232 | } |
wim | 0:35e8b8e8446a | 233 | |
wim | 0:35e8b8e8446a | 234 | case '9': { |
wim | 0:35e8b8e8446a | 235 | CU209SCPB.cls(); // clear all |
wim | 0:35e8b8e8446a | 236 | break; |
wim | 0:35e8b8e8446a | 237 | } |
wim | 0:35e8b8e8446a | 238 | |
wim | 0:35e8b8e8446a | 239 | case 'A': { |
wim | 0:35e8b8e8446a | 240 | pc.printf("Cursor On\r\n"); |
wim | 0:35e8b8e8446a | 241 | CU209SCPB.setCursor(true); |
wim | 0:35e8b8e8446a | 242 | break; |
wim | 0:35e8b8e8446a | 243 | } |
wim | 0:35e8b8e8446a | 244 | |
wim | 0:35e8b8e8446a | 245 | case 'B': { |
wim | 0:35e8b8e8446a | 246 | pc.printf("Cursor Off\r\n"); |
wim | 0:35e8b8e8446a | 247 | CU209SCPB.setCursor(false); |
wim | 0:35e8b8e8446a | 248 | break; |
wim | 0:35e8b8e8446a | 249 | } |
wim | 0:35e8b8e8446a | 250 | |
wim | 0:35e8b8e8446a | 251 | case 'C': { |
wim | 0:35e8b8e8446a | 252 | CU209SCPB.cls(); // clear all |
wim | 0:35e8b8e8446a | 253 | CU209SCPB.printf("Bye"); |
wim | 0:35e8b8e8446a | 254 | |
wim | 0:35e8b8e8446a | 255 | break; |
wim | 0:35e8b8e8446a | 256 | } |
wim | 0:35e8b8e8446a | 257 | |
wim | 0:35e8b8e8446a | 258 | default : { |
wim | 0:35e8b8e8446a | 259 | break; |
wim | 0:35e8b8e8446a | 260 | } |
wim | 0:35e8b8e8446a | 261 | |
wim | 0:35e8b8e8446a | 262 | } //switch cmd |
wim | 0:35e8b8e8446a | 263 | |
wim | 0:35e8b8e8446a | 264 | myled = !myled; |
wim | 0:35e8b8e8446a | 265 | wait(0.3); |
wim | 0:35e8b8e8446a | 266 | } |
wim | 0:35e8b8e8446a | 267 | } |
wim | 0:35e8b8e8446a | 268 |