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
bool vfd_flag = false;
for (uint8_t i=0; i<VFD_DIGITS; i++) {
vfd_digit(i,'0'+i);
}
for (uint8_t i=0; i<VFD_MATRIX; i++) {
vfd_matrix(i,'A'+i);
}
uint8_t vfd_place = 0; // the place on which the next character will be displayed on the VFD
bool vfd_flag = false; // do something with the VFD
char c = 0; // the character to display
while (true) {
while (usart_received) { // echo every received character
printf("%c",usart_getchar()); // transmit receive character
vfd_flag = true;
c = usart_getchar();
vfd_flag = true; // display character
}
while (cdcacm_received) { // echo every received character
printf("%c",cdcacm_getchar()); // transmit receive character
vfd_flag = true;
c = cdcacm_getchar();
vfd_flag = true; // display character
}
while (vfd_flag) {
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
}