From: Keith Packard Date: Fri, 23 Mar 2012 03:02:30 +0000 (-0700) Subject: Move LCD string output code to ao_lcd_font.c X-Git-Tag: 1.0.9.4~16 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=d236a5c7cd6e9b1d7192e801d63b4bd348cc2f12 Move LCD string output code to ao_lcd_font.c It's all very specific to the 14-segment display, so stick it there. Signed-off-by: Keith Packard --- diff --git a/src/stm-demo/ao_demo.c b/src/stm-demo/ao_demo.c index 24566f9b..a672964b 100644 --- a/src/stm-demo/ao_demo.c +++ b/src/stm-demo/ao_demo.c @@ -49,6 +49,7 @@ main(void) ao_cmd_init(); // ao_led_init(LEDS_AVAILABLE); ao_lcd_stm_init(); + ao_lcd_font_init(); // ao_add_task(&demo_task, ao_demo, "demo"); ao_start_scheduler(); diff --git a/src/stm/ao_arch.h b/src/stm/ao_arch.h index 96cbfe85..61e62f5d 100644 --- a/src/stm/ao_arch.h +++ b/src/stm/ao_arch.h @@ -157,6 +157,8 @@ struct ao_adc { void ao_lcd_stm_init(void); +void ao_lcd_font_init(void); + void ao_lcd_font_string(char *s); #endif /* _AO_ARCH_H_ */ diff --git a/src/stm/ao_lcd_font.c b/src/stm/ao_lcd_font.c index f6074587..2bd787ed 100644 --- a/src/stm/ao_lcd_font.c +++ b/src/stm/ao_lcd_font.c @@ -99,3 +99,30 @@ ao_lcd_font_string(char *s) { while (pos < 6) ao_lcd_font_char(pos++, ' ', 0); } + +static void +ao_lcd_font_text(void) +{ + char string[20]; + uint8_t c = 0; + ao_cmd_white(); + while (ao_cmd_lex_c != '\n' && c < sizeof (string) - 1) { + string[c++] = ao_cmd_lex_c; + ao_cmd_lex(); + } + string[c++] = '\0'; + ao_lcd_font_string(string); + stm_lcd.sr = (1 << STM_LCD_SR_UDR); +} + +const struct ao_cmds ao_lcd_font_cmds[] = { + { ao_lcd_font_text, "t \0Write to LCD" }, + { 0, NULL } +}; + +void +ao_lcd_font_init(void) +{ + ao_cmd_register(ao_lcd_font_cmds); +} + diff --git a/src/stm/ao_lcd_stm.c b/src/stm/ao_lcd_stm.c index 2d2fa9b3..f68cf165 100644 --- a/src/stm/ao_lcd_stm.c +++ b/src/stm/ao_lcd_stm.c @@ -268,25 +268,10 @@ ao_lcd_stm_clear(void) stm_lcd.sr = (1 << STM_LCD_SR_UDR); } -static void -ao_lcd_stm_text(void) -{ - char string[7]; - uint8_t c = 0; - ao_cmd_white(); - while (ao_cmd_lex_c != '\n' && c < sizeof (string)) { - string[c++] = ao_cmd_lex_c; - ao_cmd_lex(); - } - string[c++] = '\0'; - ao_lcd_font_string(string); - stm_lcd.sr = (1 << STM_LCD_SR_UDR); -} const struct ao_cmds ao_lcd_stm_cmds[] = { { ao_lcd_stm_seg_set, "s \0Set LCD segment" }, { ao_lcd_stm_clear, "C\0Clear LCD" }, - { ao_lcd_stm_text, "t \0Write to LCD" }, { 0, NULL }, };