From: Keith Packard Date: Fri, 23 Mar 2012 07:04:47 +0000 (-0700) Subject: Make stm-demo display a scrolling message X-Git-Tag: 1.0.9.4~11 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=41a3fded116a3101789df44647d0eb06be07a25b Make stm-demo display a scrolling message Instead of trying to frob the LEDs, which are now owned by the serial port. Signed-off-by: Keith Packard --- diff --git a/src/stm-demo/ao_demo.c b/src/stm-demo/ao_demo.c index a672964b..544f261f 100644 --- a/src/stm-demo/ao_demo.c +++ b/src/stm-demo/ao_demo.c @@ -19,16 +19,27 @@ struct ao_task demo_task; +static inline int min(int a, int b) { return a < b ? a : b; } + void ao_demo(void) { + char message[] = "Hello, Mike & Bdale --- "; + char part[7]; + int i = 0; + int len = sizeof(message) - 1; + int first, second; + + part[6] = '\0'; for (;;) { - ao_led_on(AO_LED_BLUE); - ao_delay(AO_MS_TO_TICKS(500)); - ao_led_off(AO_LED_BLUE); - ao_led_on(AO_LED_GREEN); - ao_delay(AO_MS_TO_TICKS(500)); - ao_led_off(AO_LED_GREEN); + ao_delay(AO_MS_TO_TICKS(150)); + first = min(6, len - i); + second = 6 - first; + memcpy(part, message + i, first); + memcpy(part + first, message, second); + ao_lcd_font_string(part); + if (++i >= len) + i = 0; } } @@ -47,10 +58,9 @@ main(void) ao_serial_init(); ao_timer_init(); 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_add_task(&demo_task, ao_demo, "demo"); ao_start_scheduler(); return 0; diff --git a/src/stm-demo/ao_pins.h b/src/stm-demo/ao_pins.h index 8d7ed76b..798a292e 100644 --- a/src/stm-demo/ao_pins.h +++ b/src/stm-demo/ao_pins.h @@ -19,9 +19,21 @@ #define _AO_PINS_H_ #define HAS_SERIAL_1 1 +#define USE_SERIAL_1_STDIN 1 +#define SERIAL_1_PB6_PB7 1 +#define SERIAL_1_PA9_PA10 0 + #define HAS_SERIAL_2 0 +#define USE_SERIAL_2_STDIN 1 +#define SERIAL_2_PA2_PA3 0 +#define SERIAL_2_PD5_PD6 1 + #define HAS_SERIAL_3 0 -#define USE_SERIAL_STDIN 1 +#define USE_SERIAL_3_STDIN 1 +#define SERIAL_3_PB10_PB11 0 +#define SERIAL_3_PC10_PC11 0 +#define SERIAL_3_PD8_PD9 1 + #define HAS_USB 0 #define HAS_BEEP 0 #define PACKET_HAS_SLAVE 0