这是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