這是Compilation error due to table in C++C++ UART Infite循環與TI-Nspire
延續所以這是我的計劃:
#include <os.h>
#include <nspireio/uart.hpp>
#include <nspireio/console.hpp>
int key_already_pressed = 0;
char oldinput[100] = {0};
char voidlist[100] = {0};
/*
void messagel(void) {
if(messagemode){
if(isKeyPressed(KEY_NSPIRE_A) && !key_already_pressed) {
nio_printf("A");
uart_printf("A");
//strcat(message,"A");
key_already_pressed = 1;
}
if(isKeyPressed(KEY_NSPIRE_B) && !key_already_pressed) {
nio_printf("B");
uart_printf("B");
//strcat(message,"B");
key_already_pressed = 1;
}
if(isKeyPressed(KEY_NSPIRE_ENTER) && messagemode && !key_already_pressed) {
messagemode = 0;
key_already_pressed = 1;
}
if(!any_key_pressed())
key_already_pressed = 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 input[100] = {0};
nio_getsn(input,100);
uart_printf(input);
key_already_pressed = 1;
}
if(!any_key_pressed())
key_already_pressed = 0;
if(uart_ready()) {
char input[100] = {0};
getline(input,100);
if(oldinput != input) {
if(input != voidlist) {
nio_puts(input);
strcpy(oldinput,input);
strcpy(input,voidlist);
}
}
}
}
nio_puts("Closing the programm.");
nio_free(&csl);
return 0;
}
的PROGRAME不停地發送一個字母continualy TI的屏幕上和串行輸出。例如,如果我在串口監視器上寫入lol,它將發送l,如果我發送一個新字符串,字母不會改變。
我真的希望這個程序在週末結束時全面工作,所以告訴我我做錯了什麼?
PS:我是法國人
你可能還沒有完全理解弦背後的概念在C/C++中可能會有所幫助瞭解更多關於它們的信息,如果你編寫的程序如此接近實際的硬件,只是說;) – ExOfDe
我沒有選擇它是唯一的方法來與calc進行通信 – TurtleForGaming
不要擔心,但對於這種情況下,它可以幫助你,我給了我的答案ght幫助你進一步。 – ExOfDe