aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKing Kévin <kingkevin@cuvoodoo.info>2016-01-26 09:46:36 +0100
committerKing Kévin <kingkevin@cuvoodoo.info>2016-01-26 09:46:36 +0100
commitc1efb819a53831bf4c51a0fe1d508edc497b9816 (patch)
tree7fa72ca271d821d61e51ad923e573f2a5127c876
parenta7e4d8f4ea7afe49b8e80c3b57f036c2a30ab196 (diff)
add animation
-rw-r--r--main.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/main.c b/main.c
index b3752d9..06e0e42 100644
--- a/main.c
+++ b/main.c
@@ -20,6 +20,7 @@
#include <stdlib.h> // standard utilities
#include <unistd.h> // standard streams
#include <errno.h> // error number utilities
+#include <string.h> // stting utilities
/* STM32 (including CM3) libraries */
#include <libopencm3/stm32/rcc.h> // real-time control clock library
@@ -75,9 +76,9 @@ int main(void)
setbuf(stdout, NULL); // set standard out buffer to NULL to immediately print
setbuf(stderr, NULL); // set standard error buffer to NULL to immediately print
- printf("welcome to the STM32F1 CuVoodoo display driver\n");
-
+ printf("welcome to the STM32F1 CuVoodoo vacuum fluorescent display driver\n");
+ printf("testing VFD\n");
vfd_on(); // switch on VFD
vfd_test(); // show all anodes
for (uint32_t i = 0; i < 0x800000; i++) { // show for a bit of time
@@ -85,6 +86,40 @@ int main(void)
}
vfd_clear(); // clear all data
+ printf("scrolling message\n");
+ const char* message = " follow the white rabbit "; // message to display (shifted by left-padded by VFD_MATRIX (12), right padded by VFD_MATRIX-VFD_DIGITS (2))
+ for (uint8_t i=0; i<strlen(message); i++) { // scroll through message (from right to left)
+ vfd_clear(); // clear display
+ for (uint8_t j=i; j<strlen(message); j++) { // display message
+ if (j+2<(uint8_t)strlen(message)) { // align VFD_MATRIX (12) to VFD_DIGITS (10)
+ vfd_digit(j-i,message[j+2]); // shift the matrix display
+ }
+ vfd_matrix(j-i,message[j]); // show digit
+ }
+ for (uint32_t j = 0; j < 0x200000; j++) { // show for a bit of time
+ __asm__("nop");
+ }
+ }
+ vfd_clear(); // clear all data
+
+ printf("showing animation\n");
+ // show rabbit + number animation
+ const uint8_t animation[] = {2,3,2,3,2,3,7,6,7,6,7,6}; // rabbit animation (using pict5x7)
+ for (uint8_t i=0; i<sizeof(animation) && i<VFD_MATRIX; i++) {
+ vfd_clear(); // clear display
+ vfd_matrix(i,0x80+animation[i]); // show rabbit
+ for (uint8_t j=0; j<50; j++) {
+ for (uint8_t k=0; k<VFD_DIGITS; k++) {
+ vfd_digit(k,'0'+(rand()%10)); // show (not very) random number
+ for (uint32_t l = 0; l<0x4000; l++) { // show for a bit of time
+ __asm__("nop");
+ }
+ }
+ }
+ }
+ vfd_clear(); // clear all data
+
+ printf("type to display\n");
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
@@ -99,7 +134,7 @@ int main(void)
}
while (vfd_flag) {
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
if (c=='\r' || c=='\n') { // on newline
vfd_clear(); // clear display