Not powering up digits
This commit is contained in:
parent
4667e6dbfb
commit
b95c4aa485
4
Makefile
4
Makefile
|
@ -12,7 +12,6 @@ LDFLAGS += -mmcu=$(MCU)
|
||||||
AVDFLAGS += -p $(MCU)
|
AVDFLAGS += -p $(MCU)
|
||||||
AVDFLAGS += -c usbtiny
|
AVDFLAGS += -c usbtiny
|
||||||
|
|
||||||
CLOCK_HZ = 1600000
|
|
||||||
FUSES += -U lfuse:w:0x7f:m
|
FUSES += -U lfuse:w:0x7f:m
|
||||||
FUSES += -U hfuse:w:0xdd:m
|
FUSES += -U hfuse:w:0xdd:m
|
||||||
FUSES += -U efuse:w:0xff:m
|
FUSES += -U efuse:w:0xff:m
|
||||||
|
@ -28,7 +27,8 @@ fuses:
|
||||||
avrdude $(AVDFLAGS) $(FUSES)
|
avrdude $(AVDFLAGS) $(FUSES)
|
||||||
|
|
||||||
main: main.o avr.o
|
main: main.o avr.o
|
||||||
avr.o: CFLAGS += -DCLOCK_HZ=$(CLOCK_HZ)
|
|
||||||
|
avr.o: avr.c config.h
|
||||||
|
|
||||||
$(PROG).hex: $(PROG)
|
$(PROG).hex: $(PROG)
|
||||||
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@
|
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@
|
||||||
|
|
1
avr.c
1
avr.c
|
@ -3,6 +3,7 @@
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include "avr.h"
|
#include "avr.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
/* Clock must be a multiple of 2MHz or there will be clock drift */
|
/* Clock must be a multiple of 2MHz or there will be clock drift */
|
||||||
#define TICKS_PER_SECOND (CLOCK_HZ / 64)
|
#define TICKS_PER_SECOND (CLOCK_HZ / 64)
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef __CONFIG_H__
|
||||||
|
#define __CONFIG_H__
|
||||||
|
|
||||||
|
#define CLOCK_HZ 2000000
|
||||||
|
|
||||||
|
#define SCORE_DIGITS 2
|
||||||
|
#define JAM_INDICATOR 1
|
||||||
|
#define JAM_DIGITS 3
|
||||||
|
|
||||||
|
#endif
|
25
main.c
25
main.c
|
@ -6,6 +6,7 @@
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
|
|
||||||
#include "avr.h"
|
#include "avr.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
// Number of shift registers in your scoreboard
|
// Number of shift registers in your scoreboard
|
||||||
// If you want scores to go over 199, you need 8
|
// If you want scores to go over 199, you need 8
|
||||||
|
@ -64,13 +65,21 @@ const uint8_t test_pattern[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t seven_segment_digits[] = {
|
const uint8_t seven_segment_digits[] = {
|
||||||
|
// 0 1 2 3 4 5 6 7 8 9
|
||||||
0x7b, 0x60, 0x37, 0x76, 0x6c, 0x5e, 0x5f, 0x70, 0x7f, 0x7e
|
0x7b, 0x60, 0x37, 0x76, 0x6c, 0x5e, 0x5f, 0x70, 0x7f, 0x7e
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t setup_digits[] = {
|
const uint8_t setup_digits[] = {
|
||||||
|
// [ = ]
|
||||||
0x1b, 0x12, 0x72
|
0x1b, 0x12, 0x72
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// keyed by state
|
||||||
|
const uint8_t indicator[] = {
|
||||||
|
// '' J L T -
|
||||||
|
0x00, 0x63, 0x0b, 0x0f, 0x04
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
latch()
|
latch()
|
||||||
{
|
{
|
||||||
|
@ -170,7 +179,7 @@ draw()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Score A
|
// Score A
|
||||||
write_num(score_b, 2);
|
write_num(score_b, SCORE_DIGITS);
|
||||||
|
|
||||||
// Jam clock, least significant half
|
// Jam clock, least significant half
|
||||||
write_num(jclk % 100, 2);
|
write_num(jclk % 100, 2);
|
||||||
|
@ -191,17 +200,15 @@ draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Jam clock, most significant half
|
// Jam clock, most significant half
|
||||||
write_num(jclk / 100, 2);
|
write_num(jclk / 100, JAM_DIGITS - 2);
|
||||||
|
|
||||||
|
#if JAM_INDICATOR
|
||||||
|
write(indicator[state]);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Score A
|
// Score A
|
||||||
write_num(score_a, 2);
|
write_num(score_a, SCORE_DIGITS);
|
||||||
|
|
||||||
if (false) {
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < 12; i += 1) {
|
|
||||||
write_num(jiffies / 10, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Tell chips to start displaying new values
|
// Tell chips to start displaying new values
|
||||||
latch();
|
latch();
|
||||||
pulse();
|
pulse();
|
||||||
|
|
Loading…
Reference in New Issue