Not powering up digits

This commit is contained in:
Neale Pickett 2014-01-11 21:02:24 -07:00
parent 4667e6dbfb
commit b95c4aa485
4 changed files with 29 additions and 11 deletions

View File

@ -12,7 +12,6 @@ LDFLAGS += -mmcu=$(MCU)
AVDFLAGS += -p $(MCU)
AVDFLAGS += -c usbtiny
CLOCK_HZ = 1600000
FUSES += -U lfuse:w:0x7f:m
FUSES += -U hfuse:w:0xdd:m
FUSES += -U efuse:w:0xff:m
@ -28,7 +27,8 @@ fuses:
avrdude $(AVDFLAGS) $(FUSES)
main: main.o avr.o
avr.o: CFLAGS += -DCLOCK_HZ=$(CLOCK_HZ)
avr.o: avr.c config.h
$(PROG).hex: $(PROG)
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@

1
avr.c
View File

@ -3,6 +3,7 @@
#include <avr/io.h>
#include <avr/interrupt.h>
#include "avr.h"
#include "config.h"
/* Clock must be a multiple of 2MHz or there will be clock drift */
#define TICKS_PER_SECOND (CLOCK_HZ / 64)

10
config.h Normal file
View File

@ -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
View File

@ -6,6 +6,7 @@
#include <util/delay.h>
#include "avr.h"
#include "config.h"
// Number of shift registers in your scoreboard
// 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[] = {
// 0 1 2 3 4 5 6 7 8 9
0x7b, 0x60, 0x37, 0x76, 0x6c, 0x5e, 0x5f, 0x70, 0x7f, 0x7e
};
const uint8_t setup_digits[] = {
// [ = ]
0x1b, 0x12, 0x72
};
// keyed by state
const uint8_t indicator[] = {
// '' J L T -
0x00, 0x63, 0x0b, 0x0f, 0x04
};
void
latch()
{
@ -170,7 +179,7 @@ draw()
#endif
// Score A
write_num(score_b, 2);
write_num(score_b, SCORE_DIGITS);
// Jam clock, least significant half
write_num(jclk % 100, 2);
@ -191,17 +200,15 @@ draw()
}
// 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
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
latch();
pulse();