From 79bb1a9932af7bfcdab67e2a1da9d9edcba87f71 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 22 Aug 2016 22:28:32 +0200 Subject: old wip --- firmware/src/app.c | 83 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 56 insertions(+), 27 deletions(-) (limited to 'firmware/src/app.c') diff --git a/firmware/src/app.c b/firmware/src/app.c index 635c46f..05b9551 100644 --- a/firmware/src/app.c +++ b/firmware/src/app.c @@ -19,13 +19,18 @@ *******************************************************************************/ #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_keyboardHandler(USB_HID_KEYBOARD_KEYPAD); +void APP_keyboardHandler(USB_HID_KEYBOARD_KEYPAD keyCode) { + if (term != NULL) { + terminal.append(term, (char*) keyboard_keyValue[keyCode]); + terminal.append(term, " - "); + } +} + void APP_Initialize (void) { t6963c_init(); t6963c_clear(); @@ -33,38 +38,62 @@ void APP_Initialize (void) { term = terminal.construct(t6963c_rows * t6963c_columns); term->update = t6963c_update_terminal; + keyboard_setKeyHandler(APP_keyboardHandler); + terminal.append(term, "Initialising... "); + if (!keyboard_init()) { + terminal.append(term, "failure.\n"); + } else { + terminal.append(term, "success.\n"); + } + appData.state = APP_STATE_MAIN; } +bool seen = false; + 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); - } +// 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); +// } +// } + + keyboard_handleKeys(); + + if (!seen && USB_HOST_BusIsEnabled(0)) { + terminal.append(term, "ON\n"); + char s[5]; + itoa(s, USB_HOST_Status(sysObj.usbHostObject0), 10); + terminal.append(term, s); + terminal.append(term, "\n"); + itoa(s, U1CON, 10); + terminal.append(term, s); + terminal.append(term, "\n"); + seen = true; } break; -- cgit v1.2.3