aboutsummaryrefslogtreecommitdiff
path: root/robot/main.c
blob: 21d0e5c1db9091805acd5dc773b910dbe48c1d1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <pololu/orangutan.h>
#include <stdlib.h>

int main() {
	play("L50 c>c");
	serial_set_baud_rate(9600);

	char *buf = malloc(20);
	unsigned int counter = 0;

	while (1) {
		serial_receive_blocking(buf, 1, 65e3);

		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;
}