aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKing Kévin <kingkevin@cuvoodoo.info>2016-01-25 00:46:09 +0100
committerKing Kévin <kingkevin@cuvoodoo.info>2016-01-25 00:46:09 +0100
commitf5f4fa55ebf45a1addb0b15121ef9dd4244ad851 (patch)
treee52529e049221cbab0e944988e6991f0ec84ec8c
parent78e2f7bb1cbc48d9fcfb340a3cd9641ac6020760 (diff)
combine on/off with refresh
-rw-r--r--lib/vfd.c18
-rw-r--r--lib/vfd.h14
-rw-r--r--main.c20
3 files changed, 10 insertions, 42 deletions
diff --git a/lib/vfd.c b/lib/vfd.c
index d44275d..e6ddf95 100644
--- a/lib/vfd.c
+++ b/lib/vfd.c
@@ -399,8 +399,7 @@ void vfd_matrix(uint8_t nb, char c)
}
}
-/* clear VFD display
- * the data has to be transmitted separately */
+/* clear VFD display */
void vfd_clear(void)
{
for (uint8_t i=0; i<LENGTH(driver_data); i++) {
@@ -410,8 +409,7 @@ void vfd_clear(void)
}
}
-/* test VFD display (light up all anodes)
- * the data has to be transmitted separately */
+/* test VFD display (light up all anodes) */
void vfd_test(void)
{
for (uint8_t i=0; i<LENGTH(driver_data); i++) {
@@ -425,23 +423,13 @@ void vfd_test(void)
void vfd_on(void)
{
gpio_clear(VFD_PORT, VFD_STR); // enable HV output
+ timer_enable_counter(VFD_TIMER); // start timer to periodically output that to the parts
}
/* switch VFD display off */
void vfd_off(void)
{
gpio_set(VFD_PORT, VFD_STR); // disable HV output
-}
-
-/* output data on the parts */
-void vfd_refresh_on(void)
-{
- timer_enable_counter(VFD_TIMER); // start timer to periodically output that to the parts
-}
-
-/* stop outputting data on the parts*/
-void vfd_refresh_off(void)
-{
timer_disable_counter(VFD_TIMER); // stop timer to periodically output that to the parts
}
diff --git a/lib/vfd.h b/lib/vfd.h
index 3036e64..a52a79e 100644
--- a/lib/vfd.h
+++ b/lib/vfd.h
@@ -21,29 +21,19 @@
#define VFD_DIGITS 10
#define VFD_MATRIX 12
-/* all digits and matrix values */
-extern char vfd_digits[VFD_DIGITS];
-extern char vfd_matrixs[VFD_MATRIX];
-
/* set digit <nb> to ASCII character <c>
* use the MSB of <c> to enable the dot */
void vfd_digit(uint8_t nb, char c);
/* set dot matrix <nb> to ASCII character <c>
* non ASCII characters are used for pictures */
void vfd_matrix(uint8_t nb, char c);
-/* clear VFD display
- * the data has to be transmitted separately */
+/* clear VFD display */
void vfd_clear(void);
-/* test VFD display (light up all anodes)
- * the data has to be transmitted separately */
+/* test VFD display (light up all anodes) */
void vfd_test(void);
/* transmit every digit and matrix */
void vfd_on(void);
/* switch VFD display off */
void vfd_off(void);
-/* output data on the parts */
-void vfd_refresh_on(void);
-/* stop outputing data on the parts*/
-void vfd_refresh_off(void);
/* setup VFD */
void vfd_setup(void);
diff --git a/main.c b/main.c
index 7f6c791..c944810 100644
--- a/main.c
+++ b/main.c
@@ -79,19 +79,17 @@ int main(void)
vfd_on(); // switch on VFD
- vfd_refresh_on();
- vfd_test();
- for (uint32_t i = 0; i < 0x800000; i++) {
+ vfd_test(); // show all anodes
+ for (uint32_t i = 0; i < 0x800000; i++) { // show for a bit of time
__asm__("nop");
}
- vfd_clear();
+ vfd_clear(); // clear all data
bool vfd_flag = false;
- bool refresh = true;
- for (uint8_t i=0; i<LENGTH(vfd_digits); i++) {
+ for (uint8_t i=0; i<VFD_DIGITS; i++) {
vfd_digit(i,'0'+i);
}
- for (uint8_t i=0; i<LENGTH(vfd_matrixs); i++) {
+ for (uint8_t i=0; i<VFD_MATRIX; i++) {
vfd_matrix(i,'A'+i);
}
while (true) {
@@ -106,14 +104,6 @@ int main(void)
while (vfd_flag) {
vfd_flag = false;
gpio_toggle(LED_PORT, LED_PIN); // toggle LED
- if (refresh) {
- printf("on\n");
- vfd_refresh_on();
- } else {
- printf("off\n");
- vfd_refresh_off();
- }
- refresh = !refresh;
}
__WFI(); // go to sleep
}