Commit aea4f76f authored by David Griffith's avatar David Griffith

Move around process_longpress() and getkey() to fit in same ifdef.

parent 77ba77a0
......@@ -734,68 +734,6 @@ void process_key(uint8_t key, bool pause)
} /* void process_key(uint8_t key) */
#ifdef KEYS_13
/*
* void process_longpress(uint8_t key)
*
* 13-key version
*
* A long press will do either of two things. A long press on the 2600
* key will toggle the bluebox between normal and memory playback modes.
* A long press on any other key while in normal mode will save the last
* EEPROM_CHUNK_SIZE - 1 keystrokes to EEPROM (first byte is for mode).
* The only long press while in memory playback mode that is honored is
* 2600, which will toggle the bluebox back to normal mode.
*
*/
void process_longpress(uint8_t key)
{
bool just_flipped = FALSE;
bool just_wrote = FALSE;
longpress_counter = LONGPRESS_TIME;
longpress_on = TRUE;
while (key == getkey() && key != KEY_NOTHING) {
if (longpress_flag) {
/* Long press on 2600 toggles playback mode. */
if (key == KEY_SEIZE) {
/* Clear buffer when toggling playback. */
rbuf_init(&rbuf);
just_flipped = TRUE;
if (playback_mode == FALSE) {
playback_mode = TRUE;
play(75, 1300, 1300);
play(75, 1700, 1700);
} else {
playback_mode = FALSE;
play(75, 1700, 1700);
play(75, 1300, 1300);
}
} else { /* Store the buffer in EEPROM, */
/* but don't store when in playback mode. */
if (!playback_mode) {
eeprom_store(key);
just_wrote = TRUE;
}
}
}
}
longpress_on = FALSE;
/* If a long press was not detected, */
/* store the key in the circular buffer.*/
if (!playback_mode && !just_flipped && !just_wrote)
rbuf_insert(&rbuf, key);
just_flipped = FALSE;
just_wrote = FALSE;
return;
}
#else /* We're using a 16-key keypad */
#error 16-keys not yet implemented
#endif
#ifdef KEYS_13
/*
* uint8_t getkey(void)
......@@ -865,6 +803,64 @@ uint8_t getkey(void)
}
return 0;
} /* uint8_t getkey() */
/*
* void process_longpress(uint8_t key)
*
* 13-key version
*
* A long press will do either of two things. A long press on the 2600
* key will toggle the bluebox between normal and memory playback modes.
* A long press on any other key while in normal mode will save the last
* EEPROM_CHUNK_SIZE - 1 keystrokes to EEPROM (first byte is for mode).
* The only long press while in memory playback mode that is honored is
* 2600, which will toggle the bluebox back to normal mode.
*
*/
void process_longpress(uint8_t key)
{
bool just_flipped = FALSE;
bool just_wrote = FALSE;
longpress_counter = LONGPRESS_TIME;
longpress_on = TRUE;
while (key == getkey() && key != KEY_NOTHING) {
if (longpress_flag) {
/* Long press on 2600 toggles playback mode. */
if (key == KEY_SEIZE) {
/* Clear buffer when toggling playback. */
rbuf_init(&rbuf);
just_flipped = TRUE;
if (playback_mode == FALSE) {
playback_mode = TRUE;
play(75, 1300, 1300);
play(75, 1700, 1700);
} else {
playback_mode = FALSE;
play(75, 1700, 1700);
play(75, 1300, 1300);
}
} else { /* Store the buffer in EEPROM, */
/* but don't store when in playback mode. */
if (!playback_mode) {
eeprom_store(key);
just_wrote = TRUE;
}
}
}
}
longpress_on = FALSE;
/* If a long press was not detected, */
/* store the key in the circular buffer.*/
if (!playback_mode && !just_flipped && !just_wrote)
rbuf_insert(&rbuf, key);
just_flipped = FALSE;
just_wrote = FALSE;
return;
}
#else /* We're using a 16-key keypad */
#error 16-keys not yet implemented
#endif
......
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