diff --git a/lib/vfd.c b/lib/vfd.c index d1816c5..8a7a8ec 100644 --- a/lib/vfd.c +++ b/lib/vfd.c @@ -477,6 +477,18 @@ 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 +} + /* setup VFD */ void vfd_setup(void) { @@ -522,11 +534,9 @@ void vfd_setup(void) timer_reset(VFD_TIMER); // reset timer state timer_set_mode(VFD_TIMER, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP); // set timer mode, use undivided timer clock,edge alignment (simple count), and count up timer_set_prescaler(VFD_TIMER, (SYSTEM_CLOCK_FREQ/(1<<16))-1); // set the prescaler so this 16 bits timer overflows at 1Hz - //timer_set_period(0xffff/(VFD_DIGITS+VFD_MATRIX)/150); // set the refresh frequency - timer_set_period(VFD_TIMER, 0xfffff); + timer_set_period(VFD_TIMER, 0xffff/(VFD_DIGITS+VFD_MATRIX)/150); // set the refresh frequency timer_enable_irq(VFD_TIMER, TIM_DIER_UIE); // enable interrupt for timer nvic_enable_irq(VFD_TIMER_IRQ); // allow interrupt for timer - timer_enable_counter(VFD_TIMER); // enable timer vfd_clear(); // initialize values } @@ -557,9 +567,21 @@ void tim4_isr(void) void tim5_isr(void) #endif { + static uint8_t vfd_mux = 0; // which part to output + if (timer_get_flag(VFD_TIMER, TIM_SR_UIF)) { // overflow even happened timer_clear_flag(VFD_TIMER, TIM_SR_UIF); // clear flag - gpio_toggle(LED_PORT, LED_PIN); // toggle LED + if (vfd_mux