static void reactToUART(void) { if (RxBuf_NofElements() != 0) { SendString((unsigned char*) "uart: ", &deviceData); while (RxBuf_NofElements() != 0) { unsigned char ch; (void) RxBuf_Get(&ch); SendChar(ch, &deviceData); switchLEDs(ch); } SendString((unsigned char*) "\r\n", &deviceData); } }
void APP_Run(void) { Init(); SendString((unsigned char*)"Hello World\r\n", &deviceData); for(;;) { if (RxBuf_NofElements()!=0) { SendString((unsigned char*)"echo: ", &deviceData); while (RxBuf_NofElements()!=0) { unsigned char ch; (void)RxBuf_Get(&ch); SendChar(ch, &deviceData); } SendString((unsigned char*)"\r\n", &deviceData); } } }
//control LED using inputs from virtual serial port //use 'a' and 'd' to cycle through different colors //use 'w' and 's' to increase or decrease brightness void control_LED() { for(;;) { if (RxBuf_NofElements()!=0) { while (RxBuf_NofElements()!=0) { uint8_t ch; (void)RxBuf_Get(&ch); LOG_0("echo: ", 6); LOG_0(&ch, 1); LOG_0("\r\n", 2); if (ch=='w' && dc_code<=90) { dc_code+=10; //increase brightness LOG_0("Increase brightness\r\n", 21); } else if (ch=='s' && dc_code>=10) { dc_code-=10; //decrease brightness LOG_0("Decrease brightness\r\n", 21); } else if (ch=='d' && color_code<7) { color_code++; LOG_0("Change color\r\n", 14); }else if (ch=='a' && color_code>0) { color_code--; LOG_0("Change color\r\n", 14); } switch (color_code) { case 0: PWM_R(dc_code); break; case 1: PWM_G(dc_code); break; case 2: PWM_B(dc_code); break; case 3: PWM_Y(dc_code); break; case 4: PWM_C(dc_code); break; case 5: PWM_M(dc_code); break; case 6: PWM_W(dc_code); break; case 7: LED_clear(); break; default: break; } } } } }