vfd has how two lines
This commit is contained in:
parent
91fd87c701
commit
7661170957
26
main.c
26
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
|
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
|
bool vfd_flag = false; // do something with the VFD
|
||||||
char c = 0; // the character to display
|
char c = 0; // the character to display
|
||||||
|
char previous_line[VFD_DIGITS] = {0};
|
||||||
while (true) {
|
while (true) {
|
||||||
while (usart_received) { // echo every received character
|
while (usart_received) { // echo every received character
|
||||||
c = usart_getchar();
|
c = usart_getchar();
|
||||||
|
@ -136,13 +137,26 @@ int main(void)
|
||||||
vfd_flag = false;
|
vfd_flag = false;
|
||||||
printf("%c", c); // transmit receive character
|
printf("%c", c); // transmit receive character
|
||||||
gpio_toggle(LED_PORT, LED_PIN); // toggle LED to show activity
|
gpio_toggle(LED_PORT, LED_PIN); // toggle LED to show activity
|
||||||
if (c=='\r' || c=='\n') { // on newline
|
if (c=='\r' || c=='\n') { // on (new) newline
|
||||||
vfd_clear(); // clear display
|
if (vfd_place>0) { // only on new newline
|
||||||
vfd_place = 0; // restart from beginning
|
vfd_clear(); // clear display
|
||||||
|
vfd_place = 0; // restart from beginning
|
||||||
|
// show previous line on digits (and clear it
|
||||||
|
for (uint8_t i=0; i<LENGTH(previous_line) && i<VFD_DIGITS; i++) {
|
||||||
|
vfd_digit(i,previous_line[i]);
|
||||||
|
previous_line[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
vfd_digit(vfd_place,c); // display character on digit
|
// show typed character for current line on matrix
|
||||||
vfd_matrix(vfd_place,c); // display character on matrix
|
if (vfd_place < VFD_MATRIX) {
|
||||||
vfd_place++; // go to next place
|
vfd_matrix(vfd_place,c); // display character on digit
|
||||||
|
}
|
||||||
|
// save character for the net previous line
|
||||||
|
if (vfd_place < LENGTH(previous_line)) {
|
||||||
|
previous_line[vfd_place] = c;
|
||||||
|
}
|
||||||
|
vfd_place++; // go to next place (you can overflow it and confuse the newline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
__WFI(); // go to sleep
|
__WFI(); // go to sleep
|
||||||
|
|
Loading…
Reference in New Issue