diff --git a/main.c b/main.c index 06e0e42..5bbebb2 100644 --- a/main.c +++ b/main.c @@ -123,6 +123,7 @@ int main(void) 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 + char previous_line[VFD_DIGITS] = {0}; while (true) { while (usart_received) { // echo every received character c = usart_getchar(); @@ -136,13 +137,26 @@ int main(void) vfd_flag = false; 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 + if (c=='\r' || c=='\n') { // on (new) newline + if (vfd_place>0) { // only on new newline + vfd_clear(); // clear display + vfd_place = 0; // restart from beginning + // show previous line on digits (and clear it + for (uint8_t i=0; i