blob: d03b3e292dcd70a01752cd5ea1c8e650f625d31f (
plain) (
blame)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#include <xc.h>
#include "init.h"
#include "t6963c/t6963c.h"
#include "t6963c/terminal.h"
static Terminal* term;
//unsigned char* string = "me@pic:~$ ls
//me@pic:~$ mkdir docs
//me@pic:~$ cd docs/
//me@pic:~/docs$ ls
//me@pic:~/docs$ touch doc.txt
//me@pic:~/docs$ ls
//doc.txt
//me@pic:~/docs$ cat doc.txt
//me@pic:~/docs$ echo hello > doc.txt
//me@pic:~/docs$ cat doc.txt
//hello
//me@pic:~/docs$ cd ..
//me@pic:~$ tree -fFi
//.
//./docs/
//./docs/doc.txt
//
//1 directory, 1 file
//me@pic:~$ rm -r docs/
//";
const static char* string =
"[me@pic ~] ls\n"
"[me@pic ~] mkdir docs\n"
"[me@pic ~] cd docs/\n"
"[me@pic docs] ls\n"
"[me@pic docs] touch doc.txt\n"
"[me@pic docs] ls\n"
"doc.txt\n"
"[me@pic docs] cat doc.txt\n"
"[me@pic docs] echo hello > doc.txt\n"
"[me@pic docs] cat doc.txt\n"
"hello\n"
"[me@pic docs] cd ..\n"
"[me@pic ~] tree -fFi\n"
".\n"
"./docs/\n"
"./docs/doc.txt\n"
"\n"
"1 directory, 1 file\n"
"[me@pic ~] rm -r docs/\n";
void init_terminal(void) {
term = terminal.construct(t6963c_rows * t6963c_columns);
term->update = t6963c_update_terminal;
}
void loop_string(void) {
unsigned short i, j;
unsigned char state = 0; // 0 = quick, 1 = slow
for (i = 0; string[i]; i++) {
if (!terminal.appendChar(term, string[i])) {
terminal.free(term);
t6963c_clear();
t6963c_set_address(5,5);
t6963c_writeString("ERROR");
while (1);
}
if (string[i] == ']') {
state = 1;
terminal.appendChar(term, string[++i]);
__delay_ms(800);
} else if (string[i] == '\n') {
state = 0;
}
if (state) {
__delay_ms(80);
}
}
}
int main(void) {
init();
init_terminal();
while (1) {
loop_string();
}
return 0;
}
|