Up/Dn modifies period clock during timeout

This commit is contained in:
Neale Pickett 2013-07-02 22:31:54 -06:00
parent 7c5fd66f92
commit ce4dd819b9
1 changed files with 17 additions and 7 deletions

24
main.c
View File

@ -115,6 +115,7 @@ draw()
write_num(score_b, 2); write_num(score_b, 2);
write_num(score_a, 2);
if (state == SETUP) { if (state == SETUP) {
write(setup_digits[2]); write(setup_digits[2]);
@ -127,9 +128,6 @@ draw()
write_num(clk, 4); write_num(clk, 4);
} }
write_num(score_a, 2);
if ((state == TIMEOUT) && (jam_clock % 8 == 0)) { if ((state == TIMEOUT) && (jam_clock % 8 == 0)) {
// Blank it out // Blank it out
for (clk = 0; clk < 4; clk += 1) { for (clk = 0; clk < 4; clk += 1) {
@ -176,11 +174,15 @@ void
update_controller() update_controller()
{ {
static uint8_t last_val = 0; static uint8_t last_val = 0;
static uint8_t last_change = 0;
uint8_t cur; uint8_t cur;
uint8_t pressed; uint8_t pressed;
int inc = 1; int inc = 1;
cur = nesprobe(); cur = nesprobe();
if (last_val != cur) {
last_change = jiffies;
}
pressed = (last_val ^ cur) & cur; pressed = (last_val ^ cur) & cur;
last_val = cur; last_val = cur;
@ -199,10 +201,18 @@ update_controller()
jam_clock = 1; jam_clock = 1;
} }
if (cur & BTN_SELECT) { if ((state == TIMEOUT) || (state == SETUP)) {
inc = -1; uint8_t v = pressed;
// XXX: if in timeout, select digit to adjust if (jiffies - last_change > 10) {
v = cur;
}
if (v & BTN_UP) {
period_clock -= 10;
}
if (v & BTN_DOWN) {
period_clock += 10;
}
} }
if (pressed & BTN_LEFT) { if (pressed & BTN_LEFT) {
@ -226,7 +236,7 @@ setup()
{ {
int i; int i;
// TLC5941 datasheet says you have to do this before DC initialization. // TLC594 datasheet says you have to do this before DC initialization.
// In practice it doesn't seem to matter, but what the hey. // In practice it doesn't seem to matter, but what the hey.
draw(); draw();