aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKing Kévin <kingkevin@cuvoodoo.info>2016-01-25 10:29:32 +0100
committerKing Kévin <kingkevin@cuvoodoo.info>2016-01-25 10:29:32 +0100
commita7e4d8f4ea7afe49b8e80c3b57f036c2a30ab196 (patch)
tree85a0f0a57e1b8279f67efd1071dd572269984f46
parentf65a53f6062c53d604a4f4171bc13ac24d3e95a3 (diff)
display typed text
-rw-r--r--main.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/main.c b/main.c
index c944810..b3752d9 100644
--- a/main.c
+++ b/main.c
@@ -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
}