diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-04-26 16:35:00 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-04-26 16:35:00 +0200 |
commit | ea02c1f4c1e534e3df35b563eef4f8ee3b256253 (patch) | |
tree | 94ed5be7bdfc95e29d479cd63b5c459f60f64a27 | |
parent | 5d3e4fdf6d7879cc0017e05af476b62e67ce76b3 (diff) |
clang format indent switch case + serial demo app
-rw-r--r-- | .clang-format | 2 | ||||
-rw-r--r-- | readme.md | 1 | ||||
-rw-r--r-- | robot/main.c | 34 |
3 files changed, 26 insertions, 11 deletions
diff --git a/.clang-format b/.clang-format index 03e38c9..c7d6b0a 100644 --- a/.clang-format +++ b/.clang-format @@ -8,7 +8,7 @@ Language: Cpp Standard: Cpp11 TabWidth: '4' UseTab: Always - +IndentCaseLabels: true ... # vim: ft=yaml @@ -106,3 +106,4 @@ gewoon aan mij (loek) vragen. nu ben je klaar om aan het project te werken! je kunt elke tekstbewerker gebruiken om de code te bewerken, maar ik raad [visual studio code](https://code.visualstudio.com) aan als je geen voorkeur hebt. + 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 <pololu/orangutan.h> +#include <stdlib.h> 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; |