diff --git a/comms.c b/comms.c index 56a37a7..16cc96b 100644 --- a/comms.c +++ b/comms.c @@ -5,8 +5,8 @@ volatile uint8_t g_cur_command = COMMAND_IDLE; -//Debounce -#define REPEAT_MASK (_BV(KEY_PREV_PIN) | _BV(KEY_NEXT_PIN)) // repeat: key1, key2 + // repeat needed on all keys for short/long on select/abort and repeat on prev/next +#define REPEAT_MASK (_BV(KEY_SELECT_PIN) | _BV(KEY_ABORT_PIN) | _BV(KEY_PREV_PIN) | _BV(KEY_NEXT_PIN)) volatile unsigned char key_press = 0; volatile unsigned char key_state = 0; volatile unsigned char key_rpt = 0; @@ -69,6 +69,14 @@ void player_handleInputKeys() { g_cur_command = COMMAND_ABORT; } + if (get_key_long(_BV(KEY_SELECT_PIN))) { + g_cur_command = COMMAND_SELECT_LONG; + } + + if (get_key_long(_BV(KEY_ABORT_PIN))) { + g_cur_command = COMMAND_ABORT_LONG; + } + if (get_key_press(_BV(KEY_PREV_PIN)) || get_key_rpt(_BV(KEY_PREV_PIN))) { g_cur_command = COMMAND_PREVIOUS; } diff --git a/comms.h b/comms.h index 76be6fb..eabbdf7 100644 --- a/comms.h +++ b/comms.h @@ -4,9 +4,11 @@ #define COMMAND_IDLE 0 #define COMMAND_SELECT 1 -#define COMMAND_NEXT 2 -#define COMMAND_PREVIOUS 3 -#define COMMAND_ABORT 4 +#define COMMAND_SELECT_LONG 2 +#define COMMAND_ABORT 3 +#define COMMAND_ABORT_LONG 4 +#define COMMAND_NEXT 5 +#define COMMAND_PREVIOUS 6 void input_callback(); extern volatile uint8_t g_cur_command; diff --git a/lcdutils.c b/lcdutils.c index 9290342..ef0afd2 100644 --- a/lcdutils.c +++ b/lcdutils.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "ff.h" #include "config.h" #include "lcd.h" @@ -76,7 +77,15 @@ void display_filename(FILINFO* pfile_info) { g_ticker_enabled = strlen(ticker_string) > (MAX_LCD_LINE_LEN - 1); } -inline void lcd_spinner(int32_t cur_tick, int perc) { +void lcd_busy_spinner() { + int i; + for (i = 0; i < 100; i++) { + lcd_spinner(0, 100); + _delay_ms(20); + } +} + +void lcd_spinner(int32_t cur_tick, int perc) { static uint8_t indicators[] = {'|', '/', '-', 1}; static uint8_t pos = 0; static int32_t last_tick = 0; diff --git a/lcdutils.h b/lcdutils.h index 460816e..4bae47d 100644 --- a/lcdutils.h +++ b/lcdutils.h @@ -5,7 +5,8 @@ void lcd_setup(); void filename_ticker(uint32_t cur_tick); void display_filename(FILINFO* pfile_info); -inline void lcd_spinner(int32_t wait, int perc); +void lcd_busy_spinner(); +void lcd_spinner(int32_t wait, int perc); void lcd_show_dir(); void lcd_title(char* msg); void lcd_title_P(const char* msg); diff --git a/menu.c b/menu.c index cecb38c..6a0e292 100644 --- a/menu.c +++ b/menu.c @@ -170,6 +170,13 @@ void handle_manual_filename(FILINFO* pfile_info) { g_cur_command = COMMAND_IDLE; break; } + case COMMAND_ABORT_LONG: + { + lcd_title_P(S_OPERATION_ABORTED); + lcd_busy_spinner(); + // exit to previous menu + return; + } case COMMAND_NEXT: { cur_char_pos = (cur_char_pos + 1) % max_chars; diff --git a/tapuino.c b/tapuino.c index 0249e53..f15e13d 100644 --- a/tapuino.c +++ b/tapuino.c @@ -199,14 +199,6 @@ void signal_timer_stop() { TIMSK1 = 0; } -void busy_spinner() { - int i; - for (i = 0; i < 100; i++) { - lcd_spinner(0, 100); - _delay_ms(20); - } -} - int play_file(FILINFO* pfile_info) { FRESULT res; @@ -300,7 +292,7 @@ int play_file(FILINFO* pfile_info) } // end of load UI indicator - busy_spinner(); + lcd_busy_spinner(); return 1; } @@ -321,14 +313,14 @@ void record_file(char* pfile_name) { res = f_mkdir((char*)g_fat_buffer); if (res != FR_OK || f_opendir(&g_dir, (char*)g_fat_buffer) != FR_OK) { lcd_status_P(S_MKDIR_FAILED); - busy_spinner(); + lcd_busy_spinner(); return; } } // change to the recording dir if (f_chdir((char*)g_fat_buffer) != FR_OK) { lcd_status_P(S_CHDIR_FAILED); - busy_spinner(); + lcd_busy_spinner(); return; } @@ -351,7 +343,7 @@ void record_file(char* pfile_name) { if (res != FR_OK) { lcd_status_P(S_OPEN_FAILED); - busy_spinner(); + lcd_busy_spinner(); return; } @@ -436,7 +428,7 @@ void record_file(char* pfile_name) { } // end of load UI indicator - busy_spinner(); + lcd_busy_spinner(); }