add matrix selector
This commit is contained in:
parent
7894df3bb3
commit
e9a92f16b2
25
main.c
25
main.c
|
@ -214,7 +214,6 @@ static const uint8_t ascii_7segments[] = {
|
||||||
/* put digit into memory */
|
/* put digit into memory */
|
||||||
static void vfd_digit(uint8_t nb, char c)
|
static void vfd_digit(uint8_t nb, char c)
|
||||||
{
|
{
|
||||||
(void)c;
|
|
||||||
// there are only 10 digits
|
// there are only 10 digits
|
||||||
if (nb>9) {
|
if (nb>9) {
|
||||||
return;
|
return;
|
||||||
|
@ -246,6 +245,24 @@ static void vfd_digit(uint8_t nb, char c)
|
||||||
vfd_data[2] = 0;
|
vfd_data[2] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vfd_matrix(uint8_t nb, char c)
|
||||||
|
{
|
||||||
|
(void)c;
|
||||||
|
// there are only 12 matrix
|
||||||
|
if (nb>11) {
|
||||||
|
return;
|
||||||
|
} else if (nb<4) {
|
||||||
|
vfd_data[0] = 0;
|
||||||
|
vfd_data[1] = 1<<(3-nb); // select digit
|
||||||
|
} else {
|
||||||
|
vfd_data[0] = 1<<(35-nb); // select digit
|
||||||
|
vfd_data[1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
vfd_data[1] |= 0xff000000;
|
||||||
|
vfd_data[2] = 0xffffffff;
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
SCB_VTOR = (uint32_t) 0x08002000; // relocate vector table because of the bootloader
|
SCB_VTOR = (uint32_t) 0x08002000; // relocate vector table because of the bootloader
|
||||||
|
@ -267,6 +284,7 @@ int main(void)
|
||||||
bool vfd_transmit = false;
|
bool vfd_transmit = false;
|
||||||
uint8_t digit = 0;
|
uint8_t digit = 0;
|
||||||
uint8_t c = 0;
|
uint8_t c = 0;
|
||||||
|
vfd_digit(0,0);
|
||||||
/* blink the LED with every transmitted character */
|
/* blink the LED with every transmitted character */
|
||||||
while (1) {
|
while (1) {
|
||||||
while (usart_received) { // echo every received character
|
while (usart_received) { // echo every received character
|
||||||
|
@ -280,10 +298,11 @@ int main(void)
|
||||||
vfd_transmit = true;
|
vfd_transmit = true;
|
||||||
}
|
}
|
||||||
while (vfd_transmit) {
|
while (vfd_transmit) {
|
||||||
|
vfd_transmit = false;
|
||||||
c = digit+'0';
|
c = digit+'0';
|
||||||
vfd_digit(digit,c);
|
vfd_matrix(digit,c);
|
||||||
vfd_shift();
|
vfd_shift();
|
||||||
digit = (digit+1)%10;
|
digit = (digit+1)%12;
|
||||||
// let the fluorescence glow up a bit
|
// let the fluorescence glow up a bit
|
||||||
for (uint32_t i = 0; i < 0x2000; i++) {
|
for (uint32_t i = 0; i < 0x2000; i++) {
|
||||||
__asm__("nop");
|
__asm__("nop");
|
||||||
|
|
Loading…
Reference in New Issue