Skip to content

Commit

Permalink
moved busy_spinner to lcdutils.c for use by comms.c
Browse files Browse the repository at this point in the history
test for ABORT long in record menu
  • Loading branch information
sweetlilmre committed Aug 11, 2014
1 parent 1d8a269 commit cddd8b4
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 20 deletions.
12 changes: 10 additions & 2 deletions comms.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 5 additions & 3 deletions comms.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 10 additions & 1 deletion lcdutils.c
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion lcdutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 5 additions & 13 deletions tapuino.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -300,7 +292,7 @@ int play_file(FILINFO* pfile_info)
}

// end of load UI indicator
busy_spinner();
lcd_busy_spinner();

return 1;
}
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -436,7 +428,7 @@ void record_file(char* pfile_name) {
}

// end of load UI indicator
busy_spinner();
lcd_busy_spinner();
}


Expand Down

0 comments on commit cddd8b4

Please sign in to comment.