Fix stupid displaytest bug
This commit is contained in:
parent
99c45c5650
commit
b17bc8bbc9
4 changed files with 19 additions and 9 deletions
|
@ -11,6 +11,7 @@
|
|||
[env:ATmega1284P]
|
||||
platform = atmelavr
|
||||
board = ATmega1284P
|
||||
debug_tool = simavr
|
||||
framework = arduino
|
||||
upload_protocol = custom
|
||||
upload_port = /dev/ttyACM0
|
||||
|
|
|
@ -22,8 +22,11 @@ void Display::write(uint8_t digit)
|
|||
{
|
||||
uint8_t pattern = _digitToPattern(digit);
|
||||
|
||||
// Write the pattern to PORTD
|
||||
PORTD = (PORTD & ~0x7F) | (pattern & 0x7F); // Mask out the lower 7 bits and set the correct pattern
|
||||
// Shift the pattern to align with PD3–PD6
|
||||
pattern <<= 3;
|
||||
|
||||
// Write the pattern to PORTD, preserving unrelated bits
|
||||
PORTD = (PORTD & 0x87) | (pattern & 0x78); // Preserve bits 7, 2–0; update bits 6–3
|
||||
}
|
||||
|
||||
// Convert the digit (0-9) to the 4-bit pattern for the CD4511
|
||||
|
|
|
@ -20,12 +20,16 @@ int main(void)
|
|||
DDRB |= (1 << PB0) <-- as output
|
||||
*************************************************/
|
||||
|
||||
// "Attempt" LEDs.
|
||||
// Configured as output.
|
||||
DDRA |= (1 << LED_T1);
|
||||
DDRA |= (1 << LED_T2);
|
||||
DDRA |= (1 << LED_T3);
|
||||
DDRA |= (1 << LED_T4);
|
||||
DDRA |= (1 << LED_T5);
|
||||
|
||||
// "Status" LEDs.
|
||||
// Configured as output.
|
||||
DDRC |= (1 << LED_LATE);
|
||||
DDRC |= (1 << LED_EARLY);
|
||||
DDRC |= (1 << LED_COIN);
|
||||
|
|
|
@ -42,13 +42,15 @@ void systest(void)
|
|||
|
||||
_delay_ms(1000);
|
||||
// Create an instance of the CD4511 class
|
||||
Display display(true); // Set inverse to false (or true if you need inverted logic)
|
||||
display.update(1, 0);
|
||||
Display display(false); // Set inverse to false (or true if you need inverted logic)
|
||||
//display.update(1, 2);
|
||||
|
||||
// Display digits 0 to 9 in sequence
|
||||
//for (uint8_t i = 0; i < 10; ++i) {
|
||||
// display.update(1, i); // Write the current digit to the CD4511
|
||||
// _delay_ms(500); // Wait for 1 second before changing the digit
|
||||
//}
|
||||
//Display digits 0 to 9 in sequence
|
||||
for (uint8_t x = 0; x < 5; ++x) {
|
||||
for (uint8_t i = 0; i < 10; ++i) {
|
||||
display.update(x, i); // Write the current digit to the CD4511
|
||||
_delay_ms(500); // Wait for 1 second before changing the digit
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue