blob: 635c46fd1cf59a5dd2740b65b52b9260e9a7cd3f (
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
|
/*******************************************************************************
MPLAB Harmony Application Source File
File Name:
app.c
Summary:
This file contains the source code for the MPLAB Harmony application.
Description:
This file contains the source code for the MPLAB Harmony application. It
implements the logic of the application's state machine and it may call
API routines of other MPLAB Harmony modules in the system, such as drivers,
system services, and middleware. However, it does not call any of the
system interfaces (such as the "Initialize" and "Tasks" functions) of any of
the modules in the system or make any assumptions about when those functions
are called. That is the responsibility of the configuration-specific system
files.
*******************************************************************************/
#include "app.h"
#include "T6963C_PIC/t6963c.h"
#include "t6963c_specific.h"
#include "T6963C_PIC/terminal.h"
APP_DATA appData;
static Terminal* term;
void APP_Initialize (void) {
t6963c_init();
t6963c_clear();
term = terminal.construct(t6963c_rows * t6963c_columns);
term->update = t6963c_update_terminal;
appData.state = APP_STATE_MAIN;
}
void APP_Tasks (void) {
/* Check the application's current state. */
switch (appData.state) {
/* Application's main state. */
case APP_STATE_MAIN: {
if (term != NULL) {
unsigned char* string = "me@pic:~$ ls\nme@pic:~$ mkdir docs\nme@pic:~$ cd docs/\nme@pic:~/docs$ ls\nme@pic:~/docs$ touch doc.txt\nme@pic:~/docs$ ls\ndoc.txt\nme@pic:~/docs$ cat doc.txt\nme@pic:~/docs$ echo hello > doc.txt\nme@pic:~/docs$ cat doc.txt\nhello\nme@pic:~/docs$ cd ..\nme@pic:~$ tree -fFi\n.\n./docs/\n./docs/doc.txt\n\n1 directory, 1 file\nme@pic:~$ rm -r docs/\n";
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]);
for (j = 0; j < 10000; j++)
delay_ns(60000);
} else if (string[i] == '\n') {
state = 0;
}
if (state)
for (j = 0; j < 800; j++)
delay_ns(60000);
}
}
break;
}
default: {
/* TODO: Handle error in application's state machine. */
break;
}
}
}
|