Commit 8f54dd4f13ce2a2d71bb820c0adcfc1db36d6671

Authored by Ilya Yanok
Committed by Wolfgang Denk
1 parent 7ae549926a

a4m072: change 'display' command implementation

This patch changes implementation of 'display' command for a4m072
that uses 7-segment LED display as customer requested:

a) The "display" command shall _not_ turn on the decimal point.

b) Exception: "display ." shall turn on (only) the decimal point.

c) Hex digits (0-9, A-F, a-f) shall be displayed as usual.

d) Letters U, P, Y, L, S, T, H shall be displayed as usual (lower
   case letters identical to upper case letters)

e) 'I' (and 'i') shall be displayed like '1'

f) 'O' (and 'o') shall be displayed like '0'

g) all other Characters shall be displayed like ' ' (all segments off).

Signed-off-by: Ilya Yanok <yanok@emcraft.com>

Showing 1 changed file with 23 additions and 39 deletions Side-by-side Diff

board/a4m072/a4m072.c
... ... @@ -270,8 +270,6 @@
270 270 static u8 display_putc_pos;
271 271 static u8 display_out_pos;
272 272  
273   -static u8 display_dot_enable;
274   -
275 273 void display_set(int cmd) {
276 274  
277 275 if (cmd & DISPLAY_CLEAR) {
... ... @@ -281,12 +279,6 @@
281 279 if (cmd & DISPLAY_HOME) {
282 280 display_putc_pos = 0;
283 281 }
284   -
285   - if (cmd & DISPLAY_MARK) {
286   - display_dot_enable = 1;
287   - } else {
288   - display_dot_enable = 0;
289   - }
290 282 }
291 283  
292 284 #define SEG_A (1<<0)
293 285  
... ... @@ -314,10 +306,12 @@
314 306 * A..Z index 10..35
315 307 * - index 36
316 308 * _ index 37
  309 + * . index 38
317 310 */
318 311  
319 312 #define SYMBOL_DASH (36)
320 313 #define SYMBOL_UNDERLINE (37)
  314 +#define SYMBOL_DOT (38)
321 315  
322 316 static u8 display_char2seg7_tbl[]=
323 317 {
324 318  
325 319  
326 320  
327 321  
328 322  
329 323  
... ... @@ -337,28 +331,29 @@
337 331 SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, /* d */
338 332 SEG_A | SEG_D | SEG_E | SEG_F | SEG_G, /* E */
339 333 SEG_A | SEG_E | SEG_F | SEG_G, /* F */
340   - SEG_A | SEG_B | SEG_C | SEG_D | SEG_F | SEG_G, /* g */
  334 + 0, /* g - not displayed */
341 335 SEG_B | SEG_C | SEG_E | SEG_F | SEG_G, /* H */
342   - SEG_E | SEG_F, /* I */
343   - SEG_B | SEG_C | SEG_D | SEG_E, /* J */
344   - SEG_A, /* K - special 1 */
  336 + SEG_B | SEG_C, /* I */
  337 + 0, /* J - not displayed */
  338 + 0, /* K - not displayed */
345 339 SEG_D | SEG_E | SEG_F, /* L */
346   - SEG_B, /* m - special 2 */
347   - SEG_C | SEG_E | SEG_G, /* n */
348   - SEG_C | SEG_D | SEG_E | SEG_G, /* o */
  340 + 0, /* m - not displayed */
  341 + 0, /* n - not displayed */
  342 + SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F, /* O */
349 343 SEG_A | SEG_B | SEG_E | SEG_F | SEG_G, /* P */
350   - SEG_A | SEG_B | SEG_C | SEG_F | SEG_G, /* q */
351   - SEG_E | SEG_G, /* r */
  344 + 0, /* q - not displayed */
  345 + 0, /* r - not displayed */
352 346 SEG_A | SEG_C | SEG_D | SEG_F | SEG_G, /* S */
353 347 SEG_D | SEG_E | SEG_F | SEG_G, /* t */
354 348 SEG_B | SEG_C | SEG_D | SEG_E | SEG_F, /* U */
355   - SEG_C | SEG_D | SEG_E | SEG_F, /* V */
356   - SEG_C, /* w - special 3 */
357   - SEG_B | SEG_C | SEG_E | SEG_F | SEG_G, /* X */
  349 + 0, /* V - not displayed */
  350 + 0, /* w - not displayed */
  351 + 0, /* X - not displayed */
358 352 SEG_B | SEG_C | SEG_D | SEG_F | SEG_G, /* Y */
359   - SEG_A | SEG_B | SEG_D | SEG_E | SEG_G, /* Z */
  353 + 0, /* Z - not displayed */
360 354 SEG_G, /* - */
361   - SEG_D /* _ */
  355 + SEG_D, /* _ */
  356 + SEG_P /* . */
362 357 };
363 358  
364 359 /* Convert char to the LED segments representation */
365 360  
366 361  
367 362  
... ... @@ -374,23 +369,20 @@
374 369 c -= 'A' - 10;
375 370 else if (c == '-')
376 371 c = SYMBOL_DASH;
377   - else if ((c == '_') || (c == '.'))
  372 + else if (c == '_')
378 373 c = SYMBOL_UNDERLINE;
  374 + else if (c == '.')
  375 + c = SYMBOL_DOT;
379 376 else
380 377 c = ' '; /* display unsupported symbols as space */
381 378  
382 379 if (c != ' ')
383 380 val = display_char2seg7_tbl[(int)c];
384 381  
385   - /* Handle DP LED here */
386   - if (display_dot_enable) {
387   - val |= SEG_P;
388   - }
389   -
390 382 return val;
391 383 }
392 384  
393   -static inline int display_putc_nomark(char c)
  385 +int display_putc(char c)
394 386 {
395 387 if (display_putc_pos >= DISPLAY_BUF_SIZE)
396 388 return -1;
... ... @@ -403,13 +395,6 @@
403 395 return c;
404 396 }
405 397  
406   -int display_putc(char c)
407   -{
408   - /* Mark the codes from the "display" command with the DP LED */
409   - display_set(DISPLAY_MARK);
410   - return display_putc_nomark(c);
411   -}
412   -
413 398 /*
414 399 * Flush current symbol to the LED display hardware
415 400 */
... ... @@ -493,9 +478,8 @@
493 478 if (a4m072_status2code(status, buf) < 0)
494 479 return;
495 480  
496   - display_set(0); /* Clear DP Led */
497   - display_putc_nomark(buf[0]);
498   - display_putc_nomark(buf[1]);
  481 + display_putc(buf[0]);
  482 + display_putc(buf[1]);
499 483 display_set(DISPLAY_HOME);
500 484 display_out_pos = 0; /* reset output position */
501 485