aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKing Kévin <kingkevin@cuvoodoo.info>2016-01-26 10:16:14 +0100
committerKing Kévin <kingkevin@cuvoodoo.info>2016-01-26 10:16:14 +0100
commit7661170957df45c954fbdbc8d24cb9542986cf27 (patch)
tree93c50e4329c2d5b2e4c892ded435e78421fe7dcd
parent91fd87c70145e86076df654691b73f974718ed7f (diff)
vfd has how two lines
-rw-r--r--main.c26
1 files changed, 20 insertions, 6 deletions
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<LENGTH(previous_line) && i<VFD_DIGITS; i++) {
+ vfd_digit(i,previous_line[i]);
+ previous_line[i] = 0;
+ }
+ }
} 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
+ // show typed character for current line on matrix
+ if (vfd_place < VFD_MATRIX) {
+ 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