display typed text

This commit is contained in:
King Kévin 2016-01-25 10:29:32 +01:00
parent f65a53f606
commit a7e4d8f4ea
1 changed files with 18 additions and 13 deletions

31
main.c
View File

@ -85,26 +85,31 @@ int main(void)
} }
vfd_clear(); // clear all data vfd_clear(); // clear all data
bool vfd_flag = false; uint8_t vfd_place = 0; // the place on which the next character will be displayed on the VFD
for (uint8_t i=0; i<VFD_DIGITS; i++) { bool vfd_flag = false; // do something with the VFD
vfd_digit(i,'0'+i); char c = 0; // the character to display
}
for (uint8_t i=0; i<VFD_MATRIX; i++) {
vfd_matrix(i,'A'+i);
}
while (true) { while (true) {
while (usart_received) { // echo every received character while (usart_received) { // echo every received character
printf("%c",usart_getchar()); // transmit receive character c = usart_getchar();
vfd_flag = true; vfd_flag = true; // display character
} }
while (cdcacm_received) { // echo every received character while (cdcacm_received) { // echo every received character
printf("%c",cdcacm_getchar()); // transmit receive character c = cdcacm_getchar();
vfd_flag = true; vfd_flag = true; // display character
} }
while (vfd_flag) { while (vfd_flag) {
vfd_flag = false; vfd_flag = false;
gpio_toggle(LED_PORT, LED_PIN); // toggle LED printf("%c", c); // transmit receive character
} gpio_toggle(LED_PORT, LED_PIN); // toggle LED to show activity
if (c=='\r' || c=='\n') { // on newline
vfd_clear(); // clear display
vfd_place = 0; // restart from beginning
} else {
vfd_digit(vfd_place,c); // display character on digit
vfd_matrix(vfd_place,c); // display character on matrix
vfd_place++; // go to next place
}
}
__WFI(); // go to sleep __WFI(); // go to sleep
} }