-
Notifications
You must be signed in to change notification settings - Fork 1
/
io.c
66 lines (53 loc) · 789 Bytes
/
io.c
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "io.h"
/*
* Methods, which are only working
* with an ANSI-compatible terminal
*/
#ifdef TERMINAL_TYPE_ANSI
void ansi_setcolor(char* color)
{
#ifdef USE_COLORS
prints(color);
#endif
}
void ansi_gotoxy(uint8_t x, uint8_t y)
{
prints(ANSI_ESC "[");
char s[5];
int2str(y, s);
prints(s);
printc(';');
int2str(x, s);
prints(s);
printc('H');
}
#endif // TERMINAL_TYPE_ANSI
#ifdef EMBEDDED
/*
* use UART console on microcontroller
*/
void printc(char c)
{
uart_send_char(c);
}
void prints(char* s)
{
uint8_t p = 0;
while (s[p] != 0 && p < 255)
{
printc(s[p++]);
}
}
#else
/*
* use standard out on PC
*/
void printc(char c)
{
printf("%c", c);
}
void prints(char* s)
{
printf(s);
}
#endif