From ea02c1f4c1e534e3df35b563eef4f8ee3b256253 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Tue, 26 Apr 2022 16:35:00 +0200 Subject: clang format indent switch case + serial demo app --- robot/main.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'robot') diff --git a/robot/main.c b/robot/main.c index dfc8d68..21d0e5c 100644 --- a/robot/main.c +++ b/robot/main.c @@ -1,19 +1,33 @@ #include +#include int main() { - print("Hello!"); - play("L16 ceg>c"); + play("L50 c>c"); + serial_set_baud_rate(9600); - while (1) { - red_led(0); - green_led(1); - - delay_ms(100); + char *buf = malloc(20); + unsigned int counter = 0; - red_led(1); - green_led(0); + while (1) { + serial_receive_blocking(buf, 1, 65e3); - delay_ms(100); + switch (buf[0]) { + case 0x7f: { + counter--; + lcd_goto_xy(counter, 0); + print(" "); + lcd_goto_xy(counter, 0); + break; + } + default: { + print(&buf[0]); + counter++; + if (counter > 20) { + counter = 0; + lcd_goto_xy(0, 0); + } + } + } } return 0; -- cgit v1.2.3