Commit bcf6418e authored by David Griffith's avatar David Griffith

Replace several instances of bare numbers with defines.

parent 4123ef44
......@@ -170,9 +170,6 @@ do { \
} while (0)
#define TIMER0_OFF() TCCR0A &= ~((1<<CS02)|(1<<CS01)|(1<<CS00))
#define TONE_LENGTH_FAST 75
#define TONE_LENGTH_SLOW 120
#if defined(KEYPAD_13) || defined(KEYPAD_13_REV)
#define KEYS_13
#endif
......@@ -286,9 +283,30 @@ do { \
#define SEIZE 2600 * MULT2
/* Number of milliseconds to make for a long press. */
#define LONGPRESS_TIME 2000
#define TONE_LENGTH_FAST 75
#define TONE_LENGTH_SLOW 120
#define PULSE_DURATION 66
#define PULSE_INTERVAL 34
#define ERROR_LOW_TONE 880
#define ERROR_HIGH_TONE 1760
#define STARTUP_TONE 440 /* nothing held on startup */
#define DEFAULT_WAIT_TONE 1700 /* waiting for new default mode */
#define MODE_SELECT_TONE 1400 /* setting a mode to be forgotten */
#define EEPROM_STORE_START 1700
#define EEPROM_STORE_DONE 1500
#define PLAYBACK_FLIP_LOW_TONE 1300
#define PLAYBACK_FLIP_HIGH_TONE 1700
/* Two bytes, then 12 chunks of 42 (0x2A) bytes each. */
#define EEPROM_CHUNK_SIZE 0x2A
#define EEPROM_STARTUP_TONE_MODE 0x01
......@@ -394,7 +412,7 @@ int main(void)
if (tone_mode < MODE_MIN || tone_mode > MODE_MAX) {
tone_mode = MODE_MIN;
for (key = 0; key < 4; key++) {
play(75,880,880);
play(TONE_LENGTH_FAST, ERROR_LOW_TONE, 0);
sleep_ms(66);
}
}
......@@ -402,7 +420,7 @@ int main(void)
if ((tone_length != TONE_LENGTH_SLOW) && (tone_length != TONE_LENGTH_FAST)) {
tone_length = TONE_LENGTH_FAST;
for (key = 0; key < 4; key++) {
play(75,1760,1760);
play(TONE_LENGTH_FAST, ERROR_HIGH_TONE, 0);
sleep_ms(66);
}
}
......@@ -413,7 +431,7 @@ int main(void)
if (key == KEY_SEIZE) { /* We're setting a default mode. */
startup_set = TRUE;
play(1000, 1700, 1700);
play(1000, DEFAULT_WAIT_TONE, 0);
while (key == getkey()); /* Wait for release. */
do { /* Get the next keystroke. */
key = getkey();
......@@ -432,7 +450,7 @@ int main(void)
else
tone_length = TONE_LENGTH_FAST;
break;
default: play(1000, 440, 440); /* Normal startup tone. */
default: play(1000, STARTUP_TONE, 0);
break;
}
......@@ -442,13 +460,13 @@ int main(void)
* not saving, so then just chirp high.
*/
if (startup_set) {
play(75, 1700, 1700);
play(75, EEPROM_STORE_START, 0);
eeprom_update_byte((uint8_t *)EEPROM_STARTUP_TONE_MODE, tone_mode);
eeprom_update_byte((uint8_t *)EEPROM_STARTUP_TONE_LENGTH, tone_length);
eeprom_busy_wait();
play(1000, 1500, 1500);
play(1000, EEPROM_STORE_DONE, 0);
} else {
if (key > KEY_NOTHING) play(1000, 1700, 1700);
if (key > KEY_NOTHING) play(1000, MODE_SELECT_TONE, 0);
}
while (key == getkey()); /* Wait for release. */
......@@ -493,7 +511,7 @@ void eeprom_store(uint8_t key)
uint8_t ee_buffer[EEPROM_CHUNK_SIZE];
uint16_t i;
play(75, 1700, 1700);
play(75, EEPROM_STORE_START, 0);
ee_buffer[0] = tone_mode;
for (i = 1; i < EEPROM_CHUNK_SIZE; i++) {
......@@ -508,7 +526,7 @@ void eeprom_store(uint8_t key)
eeprom_update_block((uint8_t *)ee_buffer, (void *)i, EEPROM_CHUNK_SIZE);
eeprom_busy_wait();
play(1000, 1500, 1500);
play(1000, EEPROM_STORE_DONE, 0);
} /* void eeprom_store(uint8_t key) */
......@@ -874,12 +892,12 @@ void process_longpress(uint8_t key)
just_flipped = TRUE;
if (playback_mode == FALSE) {
playback_mode = TRUE;
play(75, 1300, 1300);
play(75, 1700, 1700);
play(75, PLAYBACK_FLIP_LOW_TONE, 0);
play(75, PLAYBACK_FLIP_HIGH_TONE, 0);
} else {
playback_mode = FALSE;
play(75, 1700, 1700);
play(75, 1300, 1300);
play(75, PLAYBACK_FLIP_HIGH_TONE, 0);
play(75, PLAYBACK_FLIP_LOW_TONE, 0);
}
} else { /* Store the buffer in EEPROM, */
/* but don't store when in playback mode. */
......@@ -1019,8 +1037,8 @@ void pulse(uint8_t count)
uint8_t i;
for (i = 0; i < count; i++) {
play(66, SEIZE, SEIZE);
sleep_ms(34);
play(PULSE_DURATION, SEIZE, 0);
sleep_ms(PULSE_INTERVAL);
}
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment