moved busy_spinner to lcdutils.c for use by comms.c

test for ABORT long in record menu
This commit is contained in:
sweetlilmre
2014-08-11 19:13:05 +02:00
parent 1d8a2694ef
commit cddd8b4e6b
6 changed files with 39 additions and 20 deletions
+10 -2
View File
@@ -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;
}
+5 -3
View File
@@ -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;
+10 -1
View File
@@ -1,6 +1,7 @@
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <util/delay.h>
#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;
+2 -1
View File
@@ -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);
+7
View File
@@ -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;
+5 -13
View File
@@ -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();
}