From b95c4aa485fc39d0506d427f05b4ad2058f1375f Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Sat, 11 Jan 2014 21:02:24 -0700 Subject: [PATCH] Not powering up digits --- Makefile | 4 ++-- avr.c | 1 + config.h | 10 ++++++++++ main.c | 25 ++++++++++++++++--------- 4 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 config.h diff --git a/Makefile b/Makefile index dc5608a..1b5ce82 100644 --- a/Makefile +++ b/Makefile @@ -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 $< $@ diff --git a/avr.c b/avr.c index 14b1d2c..e9b9155 100644 --- a/avr.c +++ b/avr.c @@ -3,6 +3,7 @@ #include #include #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) diff --git a/config.h b/config.h new file mode 100644 index 0000000..e8a4417 --- /dev/null +++ b/config.h @@ -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 \ No newline at end of file diff --git a/main.c b/main.c index 26bd0e8..dab5f49 100644 --- a/main.c +++ b/main.c @@ -6,6 +6,7 @@ #include #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();