combine on/off with refresh

This commit is contained in:
King Kévin 2016-01-25 00:46:09 +01:00
parent 78e2f7bb1c
commit f5f4fa55eb
3 changed files with 10 additions and 42 deletions

View File

@ -399,8 +399,7 @@ void vfd_matrix(uint8_t nb, char c)
} }
} }
/* clear VFD display /* clear VFD display */
* the data has to be transmitted separately */
void vfd_clear(void) void vfd_clear(void)
{ {
for (uint8_t i=0; i<LENGTH(driver_data); i++) { 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) /* test VFD display (light up all anodes) */
* the data has to be transmitted separately */
void vfd_test(void) void vfd_test(void)
{ {
for (uint8_t i=0; i<LENGTH(driver_data); i++) { for (uint8_t i=0; i<LENGTH(driver_data); i++) {
@ -425,23 +423,13 @@ void vfd_test(void)
void vfd_on(void) void vfd_on(void)
{ {
gpio_clear(VFD_PORT, VFD_STR); // enable HV output 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 */ /* switch VFD display off */
void vfd_off(void) void vfd_off(void)
{ {
gpio_set(VFD_PORT, VFD_STR); // disable HV output 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 timer_disable_counter(VFD_TIMER); // stop timer to periodically output that to the parts
} }

View File

@ -21,29 +21,19 @@
#define VFD_DIGITS 10 #define VFD_DIGITS 10
#define VFD_MATRIX 12 #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> /* set digit <nb> to ASCII character <c>
* use the MSB of <c> to enable the dot */ * use the MSB of <c> to enable the dot */
void vfd_digit(uint8_t nb, char c); void vfd_digit(uint8_t nb, char c);
/* set dot matrix <nb> to ASCII character <c> /* set dot matrix <nb> to ASCII character <c>
* non ASCII characters are used for pictures */ * non ASCII characters are used for pictures */
void vfd_matrix(uint8_t nb, char c); void vfd_matrix(uint8_t nb, char c);
/* clear VFD display /* clear VFD display */
* the data has to be transmitted separately */
void vfd_clear(void); void vfd_clear(void);
/* test VFD display (light up all anodes) /* test VFD display (light up all anodes) */
* the data has to be transmitted separately */
void vfd_test(void); void vfd_test(void);
/* transmit every digit and matrix */ /* transmit every digit and matrix */
void vfd_on(void); void vfd_on(void);
/* switch VFD display off */ /* switch VFD display off */
void vfd_off(void); 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 */ /* setup VFD */
void vfd_setup(void); void vfd_setup(void);

20
main.c
View File

@ -79,19 +79,17 @@ int main(void)
vfd_on(); // switch on VFD vfd_on(); // switch on VFD
vfd_refresh_on(); vfd_test(); // show all anodes
vfd_test(); for (uint32_t i = 0; i < 0x800000; i++) { // show for a bit of time
for (uint32_t i = 0; i < 0x800000; i++) {
__asm__("nop"); __asm__("nop");
} }
vfd_clear(); vfd_clear(); // clear all data
bool vfd_flag = false; bool vfd_flag = false;
bool refresh = true; for (uint8_t i=0; i<VFD_DIGITS; i++) {
for (uint8_t i=0; i<LENGTH(vfd_digits); i++) {
vfd_digit(i,'0'+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); vfd_matrix(i,'A'+i);
} }
while (true) { while (true) {
@ -106,14 +104,6 @@ int main(void)
while (vfd_flag) { while (vfd_flag) {
vfd_flag = false; vfd_flag = false;
gpio_toggle(LED_PORT, LED_PIN); // toggle LED 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 __WFI(); // go to sleep
} }