From 94664bafad83dc22d78f66ce7535b331bdc97042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Sun, 24 Jan 2016 21:54:42 +0100 Subject: [PATCH] precalculate all spi data --- lib/vfd.c | 124 ++++++++++++++++-------------------------------------- lib/vfd.h | 4 -- main.c | 19 +++++---- 3 files changed, 47 insertions(+), 100 deletions(-) diff --git a/lib/vfd.c b/lib/vfd.c index 8a7a8ec..32d73ab 100644 --- a/lib/vfd.c +++ b/lib/vfd.c @@ -305,12 +305,9 @@ static const uint8_t pict5x7[][5] = { /* the 32 bits values to be shifted out to the VFD driver * split into 16 bit for SPI transfer */ -static uint32_t vfd_data[VFD_DRIVERS] = {0}; -static uint16_t vfd_spi[VFD_DRIVERS*2] = {0}; -static volatile uint8_t vfd_spi_i = 0; - -char vfd_digits[VFD_DIGITS] = {0}; -char vfd_matrixs[VFD_MATRIX] = {0}; +static uint16_t vfd_spi[VFD_DIGITS+VFD_MATRIX][VFD_DRIVERS*2] = {0}; +static volatile uint8_t vfd_spi_i = 0; // which driver data is being transmitted +static volatile uint8_t vfd_mux = 0; // which part to output /* set digit to ASCII character * use the MSB of to enable the dot */ @@ -319,11 +316,8 @@ void vfd_digit(uint8_t nb, char c) if (!(nb>16; + } } /* set dot matrix to ASCII character @@ -361,10 +361,7 @@ void vfd_matrix(uint8_t nb, char c) return; } - // clear data - for (uint8_t i=0; i>16; - } - vfd_spi_i = 0; - - // enable SPI (the tx empty interrupt will trigger) - spi_enable(VFD_SPI); -} - -/* transmit every digit and matrix */ -void vfd_transmit(void) -{ - for (uint8_t i=0; i>16; } } @@ -439,14 +401,10 @@ void vfd_transmit(void) * the data has to be transmitted separately */ void vfd_clear(void) { - for (uint8_t i=0; i to ASCII character * non ASCII characters are used for pictures */ void vfd_matrix(uint8_t nb, char c); -/* shift out the VFD data */ -void vfd_shift(void); /* clear VFD display * the data has to be transmitted separately */ void vfd_clear(void); @@ -40,8 +38,6 @@ void vfd_clear(void); * the data has to be transmitted separately */ void vfd_test(void); /* transmit every digit and matrix */ -void vfd_transmit(void); -/* switch VFD display on */ void vfd_on(void); /* switch VFD display off */ void vfd_off(void); diff --git a/main.c b/main.c index 329522b..2e6972b 100644 --- a/main.c +++ b/main.c @@ -82,23 +82,20 @@ int main(void) vfd_on(); // switch on VFD + vfd_refresh_on(); vfd_test(); - vfd_shift(); for (uint32_t i = 0; i < 0x800000; i++) { __asm__("nop"); } vfd_clear(); - vfd_shift(); - vfd_digit(0,'0'); - vfd_shift(); - + bool vfd_flag = false; bool refresh = true; for (uint8_t i=0; i