add VFD set and test capabilities
This commit is contained in:
parent
ab273fc545
commit
515b52ec7b
30
lib/vfd.c
30
lib/vfd.c
|
@ -347,7 +347,6 @@ void vfd_shift(void)
|
||||||
gpio_clear(VFD_PORT, VFD_NLE); // do not latch data
|
gpio_clear(VFD_PORT, VFD_NLE); // do not latch data
|
||||||
gpio_set(VFD_PORT, VFD_CLK); // clock is idle high
|
gpio_set(VFD_PORT, VFD_CLK); // clock is idle high
|
||||||
for (uint8_t i=0; i<sizeof(vfd_data)/sizeof(vfd_data[0]); i++) {
|
for (uint8_t i=0; i<sizeof(vfd_data)/sizeof(vfd_data[0]); i++) {
|
||||||
//printf("%08lx ",vfd_data[i]);
|
|
||||||
for (uint8_t b=0; b<32; b++) {
|
for (uint8_t b=0; b<32; b++) {
|
||||||
gpio_clear(VFD_PORT, VFD_CLK); // change data on low
|
gpio_clear(VFD_PORT, VFD_CLK); // change data on low
|
||||||
if (vfd_data[i]&(1<<b)) { // shift the value
|
if (vfd_data[i]&(1<<b)) { // shift the value
|
||||||
|
@ -358,11 +357,16 @@ void vfd_shift(void)
|
||||||
gpio_set(VFD_PORT, VFD_CLK); // signal need to be valid on high edge
|
gpio_set(VFD_PORT, VFD_CLK); // signal need to be valid on high edge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//printf("\n");
|
|
||||||
gpio_set(VFD_PORT, VFD_STR); // disable HV output
|
gpio_set(VFD_PORT, VFD_STR); // disable HV output
|
||||||
gpio_set(VFD_PORT, VFD_NLE); // latch data
|
gpio_set(VFD_PORT, VFD_NLE); // latch data
|
||||||
gpio_clear(VFD_PORT, VFD_STR); // enable HV output
|
gpio_clear(VFD_PORT, VFD_STR); // enable HV output
|
||||||
gpio_clear(VFD_PORT, VFD_NLE); // stop latching data
|
gpio_clear(VFD_PORT, VFD_NLE); // stop latching data
|
||||||
|
|
||||||
|
// let the fluorescence glow up a bit
|
||||||
|
for (uint32_t i = 0; i < 0x2000; i++) {
|
||||||
|
__asm__("nop");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* transmit each digit and dot */
|
/* transmit each digit and dot */
|
||||||
|
@ -374,6 +378,24 @@ static void vfd_transmit(void)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* clear VFD display
|
||||||
|
* the data has to be transmitted separately */
|
||||||
|
void vfd_clear(void)
|
||||||
|
{
|
||||||
|
for (uint8_t i=0; i<LENGTH(vfd_data); i++) {
|
||||||
|
vfd_data[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* test VFD display (light up all anodes)
|
||||||
|
* the data has to be transmitted separately */
|
||||||
|
void vfd_test(void)
|
||||||
|
{
|
||||||
|
for (uint8_t i=0; i<LENGTH(vfd_data); i++) {
|
||||||
|
vfd_data[i] = ~0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* setup VFD */
|
/* setup VFD */
|
||||||
void vfd_setup(void)
|
void vfd_setup(void)
|
||||||
{
|
{
|
||||||
|
@ -382,4 +404,8 @@ void vfd_setup(void)
|
||||||
gpio_set_mode(VFD_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, VFD_NLE); // set VFD pin to 'output push-pull'
|
gpio_set_mode(VFD_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, VFD_NLE); // set VFD pin to 'output push-pull'
|
||||||
gpio_set_mode(VFD_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, VFD_CLK); // set VFD pin to 'output push-pull'
|
gpio_set_mode(VFD_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, VFD_CLK); // set VFD pin to 'output push-pull'
|
||||||
gpio_set_mode(VFD_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, VFD_DIN); // set VFD pin to 'output push-pull'
|
gpio_set_mode(VFD_PORT, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, VFD_DIN); // set VFD pin to 'output push-pull'
|
||||||
|
|
||||||
|
gpio_set(VFD_PORT, VFD_STR); // disable HV output
|
||||||
|
gpio_clear(VFD_PORT, VFD_NLE); // do not latch data
|
||||||
|
gpio_set(VFD_PORT, VFD_CLK); // clock is idle high
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,5 +32,11 @@ void vfd_digit(uint8_t nb, char c);
|
||||||
void vfd_matrix(uint8_t nb, char c);
|
void vfd_matrix(uint8_t nb, char c);
|
||||||
/* shift out the VFD data */
|
/* shift out the VFD data */
|
||||||
void vfd_shift(void);
|
void vfd_shift(void);
|
||||||
|
/* clear VFD display
|
||||||
|
* the data has to be transmitted separately */
|
||||||
|
void vfd_clear(void);
|
||||||
|
/* test VFD display (light up all anodes)
|
||||||
|
* the data has to be transmitted separately */
|
||||||
|
void vfd_test(void);
|
||||||
/* setup VFD */
|
/* setup VFD */
|
||||||
void vfd_setup(void);
|
void vfd_setup(void);
|
||||||
|
|
26
main.c
26
main.c
|
@ -73,22 +73,24 @@ int main(void)
|
||||||
setbuf(stderr, NULL); // set standard error 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 display driver\n");
|
||||||
|
|
||||||
gpio_set(VFD_PORT, VFD_STR); // disable HV output
|
|
||||||
gpio_clear(VFD_PORT, VFD_NLE); // do not latch data
|
|
||||||
gpio_set(VFD_PORT, VFD_CLK); // clock is idle high
|
|
||||||
|
|
||||||
bool vfd_transmit = false;
|
bool vfd_transmit = false;
|
||||||
uint8_t digit = 0;
|
uint8_t digit = 0;
|
||||||
uint8_t matrix = 0;
|
uint8_t matrix = 0;
|
||||||
char c = 0x80;
|
char c = 0x80;
|
||||||
|
|
||||||
vfd_digit(digit,'0');
|
vfd_clear();
|
||||||
vfd_shift();
|
vfd_shift();
|
||||||
// let the fluorescence glow up a bit
|
for (uint32_t i = 0; i < 0x800000; i++) {
|
||||||
for (uint32_t i = 0; i < 0x2000; i++) {
|
|
||||||
__asm__("nop");
|
__asm__("nop");
|
||||||
}
|
}
|
||||||
|
vfd_test();
|
||||||
|
vfd_shift();
|
||||||
|
for (uint32_t i = 0; i < 0x800000; i++) {
|
||||||
|
__asm__("nop");
|
||||||
|
}
|
||||||
|
vfd_digit(digit,'0');
|
||||||
|
vfd_shift();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
while (usart_received) { // echo every received character
|
while (usart_received) { // echo every received character
|
||||||
|
@ -107,12 +109,8 @@ int main(void)
|
||||||
|
|
||||||
vfd_matrix(matrix,c);
|
vfd_matrix(matrix,c);
|
||||||
vfd_shift();
|
vfd_shift();
|
||||||
// let the fluorescence glow up a bit
|
|
||||||
for (uint32_t i = 0; i < 0x2000; i++) {
|
matrix = (matrix+1)%12;
|
||||||
__asm__("nop");
|
|
||||||
}
|
|
||||||
matrix = (matrix+1)%12;
|
|
||||||
|
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
__WFI(); // go to sleep
|
__WFI(); // go to sleep
|
||||||
|
|
Loading…
Reference in New Issue