Move LCD string output code to ao_lcd_font.c
authorKeith Packard <keithp@keithp.com>
Fri, 23 Mar 2012 03:02:30 +0000 (20:02 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 29 Mar 2012 04:37:03 +0000 (21:37 -0700)
It's all very specific to the 14-segment display, so
stick it there.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/stm-demo/ao_demo.c
src/stm/ao_arch.h
src/stm/ao_lcd_font.c
src/stm/ao_lcd_stm.c

index 24566f9b65412c2031b39a80338e432b36c4dc5d..a672964b885bca831e6f16a86fd5054984fc60ca 100644 (file)
@@ -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();
index 96cbfe8515f5eeea009d09540672ff093894b17d..61e62f5dc703b3bcec1877c31b188ccf9adef475 100644 (file)
@@ -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_ */
index f6074587e55e785a042ca55e89fa24b6a5a4e257..2bd787ed6e0637d4dcaaa45cc29dc3b407f3172b 100644 (file)
@@ -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 <string>\0Write <string> to LCD" },
+       { 0, NULL }
+};
+
+void
+ao_lcd_font_init(void)
+{
+       ao_cmd_register(ao_lcd_font_cmds);
+}
+       
index 2d2fa9b3833177c51dd576d1fc45198edd643e3b..f68cf165fc076a8528ae23654d401584b0c952b4 100644 (file)
@@ -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 <com> <seg> <value>\0Set LCD segment" },
        { ao_lcd_stm_clear,     "C\0Clear LCD" },
-       { ao_lcd_stm_text,      "t <string>\0Write <string> to LCD" },
        { 0, NULL },
 };