#include <os.h>
#include <nspireio/uart.hpp>
#include <nspireio/console.hpp>
int key_already_pressed = 0;
char oldinput[100] = {0};
char voidlist[100] = {0};
int dispInput = 0;
int main(void)
{
assert_ndless_rev(874);
//clrscr();
nio_console csl;
nio_init(&csl,NIO_MAX_COLS,NIO_MAX_ROWS,0,0,NIO_COLOR_WHITE,NIO_COLOR_BLACK,TRUE);
nio_set_default(&csl);
nio_color(&csl,NIO_COLOR_BLACK,NIO_COLOR_WHITE);
nio_printf("Nspire UART Chat by Samy. Compiled the %s At %s\n",__DATE__,__TIME__);
nio_color(&csl,NIO_COLOR_WHITE,NIO_COLOR_BLACK);
nio_puts("Press any ESC to exit and CTRL to send msg...\n");
while(!isKeyPressed(KEY_NSPIRE_ESC)){
if(isKeyPressed(KEY_NSPIRE_CTRL) && !key_already_pressed){
nio_printf(">");
char input2[100] = {0};
nio_getsn(input2,100);
uart_printf("\r\n");
uart_printf(input2);
key_already_pressed = 1;
}
if(!any_key_pressed())
key_already_pressed = 0;
if(uart_ready()) {
char input[100] = {0};
uart_getsn(input,100);
if(strcmp(oldinput,input) != 0) {
if(input != voidlist) {
nio_puts(input);
strcpy(oldinput,input);
strcpy(input,voidlist);
}
}
}
}
nio_puts("Tests finished.");
nio_free(&csl);
return 0;
}