1
0
Fork 0
forked from len0rd/rockbox

Plugin rework 5: (all) Now using the default event handler, standard placement is in switch() default case. (splitedit,star,vu_meter) Compile-time keyboard configuration, for Ondio adaption. (splitedit) Timing kludge for MMC. (star) Completed USB support.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5321 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2004-10-22 00:22:07 +00:00
parent 3a931c113f
commit 2afdf95401
7 changed files with 285 additions and 106 deletions

View file

@ -31,7 +31,10 @@ snake2.c
snow.c snow.c
sokoban.c sokoban.c
solitaire.c solitaire.c
splitedit.c
star.c
video.c video.c
vu_meter.c
#ifdef HAVE_RTC /* Recorder models only */ #ifdef HAVE_RTC /* Recorder models only */
calendar.c calendar.c
@ -40,9 +43,6 @@ clock.c
#if CONFIG_KEYPAD != ONDIO_PAD #if CONFIG_KEYPAD != ONDIO_PAD
/* gradually bring in the ones not working yet */ /* gradually bring in the ones not working yet */
splitedit.c
star.c
vu_meter.c
wormlet.c wormlet.c
#endif /* #if CONFIG_KEYPAD != ONDIO_PAD */ #endif /* #if CONFIG_KEYPAD != ONDIO_PAD */
#endif /*#ifdef HAVE_LCD_BITMAP */ #endif /*#ifdef HAVE_LCD_BITMAP */

View file

@ -381,8 +381,10 @@ static int euro_menu(void)
/* Call when the program end */ /* Call when the program end */
static void euro_exit(void) static void euro_exit(void *parameter)
{ {
(void)parameter;
//Restore the old pattern (i don't find another way to do this. An idea?) //Restore the old pattern (i don't find another way to do this. An idea?)
rb->lcd_unlock_pattern(heuro); rb->lcd_unlock_pattern(heuro);
rb->lcd_unlock_pattern(hhome); rb->lcd_unlock_pattern(hhome);
@ -397,6 +399,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{ {
bool end, pos; bool end, pos;
long long e,h,old_e,old_h; long long e,h,old_e,old_h;
int button;
/* this macro should be called as the first thing you do in the plugin. /* this macro should be called as the first thing you do in the plugin.
it test that the api version and model the plugin was compiled for it test that the api version and model the plugin was compiled for
@ -439,7 +442,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
/*Main loop*/ /*Main loop*/
while(end!=true) while(end!=true)
{ {
switch (rb->button_get(true)) button = rb->button_get(true);
switch (button)
{ {
case BUTTON_MENU|BUTTON_REL: case BUTTON_MENU|BUTTON_REL:
switch (euro_menu()) switch (euro_menu())
@ -586,10 +590,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
} }
break; break;
case SYS_USB_CONNECTED: default:
rb->usb_screen(); if (rb->default_event_handler_ex(button, euro_exit, NULL)
euro_exit(); == SYS_USB_CONNECTED)
return PLUGIN_USB_CONNECTED; return PLUGIN_USB_CONNECTED;
break;
} }
/*Display*/ /*Display*/
if (!pos) /*Euro>home*/ if (!pos) /*Euro>home*/
@ -598,7 +603,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
e=mydiv(h,currency[country]); e=mydiv(h,currency[country]);
display(e,h,pos); display(e,h,pos);
} }
euro_exit(); euro_exit(NULL);
return PLUGIN_OK; return PLUGIN_OK;
} }

View file

@ -64,8 +64,10 @@ static void display_first_line(int g)
} }
/*Call when the program exit*/ /*Call when the program exit*/
static void jackpot_exit(void) static void jackpot_exit(void *parameter)
{ {
(void)parameter;
/* Restore the old pattern (i don't find another way to do this. Any /* Restore the old pattern (i don't find another way to do this. Any
idea?) */ idea?) */
rb->lcd_unlock_pattern(h1); rb->lcd_unlock_pattern(h1);
@ -154,10 +156,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
} }
break; break;
case SYS_USB_CONNECTED: default:
rb->usb_screen(); if (rb->default_event_handler_ex(button, jackpot_exit,
jackpot_exit(); NULL) == SYS_USB_CONNECTED)
return PLUGIN_USB_CONNECTED; return PLUGIN_USB_CONNECTED;
break;
} }
} }
@ -270,7 +273,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
} }
/* This is the end */ /* This is the end */
jackpot_exit(); jackpot_exit(NULL);
/* Bye */ /* Bye */
return PLUGIN_OK; return PLUGIN_OK;
} }

View file

@ -118,8 +118,10 @@ static void display_first_line(int x)
} }
/* Call when the program end */ /* Call when the program end */
static void nim_exit(void) static void nim_exit(void *parameter)
{ {
(void)parameter;
/*Restore the old pattern*/ /*Restore the old pattern*/
rb->lcd_unlock_pattern(h1); rb->lcd_unlock_pattern(h1);
rb->lcd_unlock_pattern(h2); rb->lcd_unlock_pattern(h2);
@ -194,7 +196,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{ {
case BUTTON_STOP|BUTTON_REL: case BUTTON_STOP|BUTTON_REL:
go = true; go = true;
nim_exit(); nim_exit(NULL);
return PLUGIN_OK; return PLUGIN_OK;
break; break;
@ -214,10 +216,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
y++; y++;
break; break;
case SYS_USB_CONNECTED: default:
rb->usb_screen(); if (rb->default_event_handler_ex(button, nim_exit,
nim_exit(); NULL) == SYS_USB_CONNECTED)
return PLUGIN_USB_CONNECTED; return PLUGIN_USB_CONNECTED;
break;
} }
display_first_line(x); display_first_line(x);
rb->snprintf(str,sizeof(str),"[%d..%d]?=%d",min,v,y); rb->snprintf(str,sizeof(str),"[%d..%d]?=%d",min,v,y);
@ -289,7 +292,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
min=1; min=1;
} }
} }
nim_exit(); nim_exit(NULL);
return PLUGIN_OK; return PLUGIN_OK;
} }
#endif #endif

View file

@ -22,6 +22,29 @@
#ifndef SIMULATOR #ifndef SIMULATOR
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define SPLITEDIT_QUIT BUTTON_OFF
#define SPLITEDIT_PLAY BUTTON_PLAY
#define SPLITEDIT_SAVE BUTTON_F1
#define SPLITEDIT_LOOP_MODE BUTTON_F2
#define SPLITEDIT_SCALE BUTTON_F3
#define SPLITEDIT_SPEED50 (BUTTON_ON | BUTTON_LEFT)
#define SPLITEDIT_SPEED100 (BUTTON_ON | BUTTON_PLAY)
#define SPLITEDIT_SPEED150 (BUTTON_ON | BUTTON_RIGHT)
#define SPLITEDIT_MENU_RUN BUTTON_PLAY
#elif CONFIG_KEYPAD == ONDIO_PAD
#define SPLITEDIT_QUIT BUTTON_OFF
#define SPLITEDIT_PLAY_PRE BUTTON_MENU
#define SPLITEDIT_PLAY (BUTTON_MENU | BUTTON_REL)
#define SPLITEDIT_SAVE (BUTTON_MENU | BUTTON_LEFT)
#define SPLITEDIT_LOOP_MODE (BUTTON_MENU | BUTTON_UP)
#define SPLITEDIT_SCALE (BUTTON_MENU | BUTTON_RIGHT)
#define SPLITEDIT_MENU_RUN BUTTON_RIGHT
#endif
#define BMPHEIGHT 7 #define BMPHEIGHT 7
#define BMPWIDTH 13 #define BMPWIDTH 13
unsigned char LOOP_BMP[][13] = unsigned char LOOP_BMP[][13] =
@ -499,7 +522,7 @@ static void generateFileName(char* file_name, int part_no)
} }
else else
{ {
rb->splash(0, true, "name to long"); rb->splash(0, true, "name too long");
rb->button_get(true); rb->button_get(true);
rb->button_get(true); rb->button_get(true);
@ -765,7 +788,7 @@ static void save_editor(struct mp3entry *mp3, int splittime)
choice = (choice + 1) % SE_COUNT; choice = (choice + 1) % SE_COUNT;
break; break;
case BUTTON_PLAY: case SPLITEDIT_MENU_RUN:
switch (choice) switch (choice)
{ {
int saved; int saved;
@ -806,9 +829,17 @@ static void save_editor(struct mp3entry *mp3, int splittime)
} }
break; break;
case BUTTON_OFF: case SPLITEDIT_QUIT:
exit_request = true; exit_request = true;
break; break;
default:
if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
{
splitedit_exit_code = PLUGIN_USB_CONNECTED;
exit_request = true;
}
break;
} }
} }
} }
@ -821,6 +852,7 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
unsigned int range) unsigned int range)
{ {
int button = BUTTON_NONE; int button = BUTTON_NONE;
int lastbutton = BUTTON_NONE;
struct mp3entry *mp3 = mp3_to_split; struct mp3entry *mp3 = mp3_to_split;
unsigned int last_elapsed = 0; unsigned int last_elapsed = 0;
int lastx = OSCI_X + (OSCI_WIDTH / 2); int lastx = OSCI_X + (OSCI_WIDTH / 2);
@ -943,12 +975,24 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
case LOOP_MODE_TO: case LOOP_MODE_TO:
rb->mpeg_pause(); rb->mpeg_pause();
rb->mpeg_ff_rewind(range_start); rb->mpeg_ff_rewind(range_start);
#ifdef HAVE_MMC
/* MMC is slow - wait some time to allow track reload to finish */
rb->sleep(HZ/20);
if (mp3->elapsed > play_end) /* reload in progress */
rb->splash(10*HZ, true, "Wait - reloading");
#endif
rb->mpeg_resume(); rb->mpeg_resume();
break; break;
case LOOP_MODE_FROM: case LOOP_MODE_FROM:
rb->mpeg_pause(); rb->mpeg_pause();
rb->mpeg_ff_rewind(xpos_to_time(split_x)); rb->mpeg_ff_rewind(xpos_to_time(split_x));
#ifdef HAVE_MMC
/* MMC is slow - wait some time to allow track reload to finish */
rb->sleep(HZ/20);
if (mp3->elapsed > play_end) /* reload in progress */
rb->splash(10*HZ, true, "Wait - reloading");
#endif
rb->mpeg_resume(); rb->mpeg_resume();
break; break;
@ -964,7 +1008,6 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
rb->lcd_update(); rb->lcd_update();
break; break;
} }
} }
} }
@ -977,17 +1020,11 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
/* key_scheme_execute(button, &scheme); */ /* key_scheme_execute(button, &scheme); */
switch (button) switch (button)
{ {
case SYS_USB_CONNECTED: case SPLITEDIT_PLAY:
rb->usb_screen(); #ifdef SPLITEDIT_PLAY_PRE
splitedit_exit_code = PLUGIN_USB_CONNECTED; if (lastbutton != SPLITEDIT_PLAY_PRE)
exit_request = true; break;
break; #endif
case BUTTON_OFF:
exit_request = true;
break;
case BUTTON_PLAY:
rb->mpeg_pause(); rb->mpeg_pause();
rb->mpeg_ff_rewind(xpos_to_time(split_x)); rb->mpeg_ff_rewind(xpos_to_time(split_x));
rb->mpeg_resume(); rb->mpeg_resume();
@ -1004,20 +1041,22 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
break; break;
#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
case BUTTON_ON | BUTTON_RIGHT: #if defined(SPLITEDIT_SPEED150) && defined(SPLITEDIT_SPEED100) && defined(SPLITEDIT_SPEED50)
case SPLITEDIT_SPEED150:
rb->mpeg_set_pitch(1500); rb->mpeg_set_pitch(1500);
splitedit_invalidate_osci(); splitedit_invalidate_osci();
break; break;
case BUTTON_ON | BUTTON_PLAY: case SPLITEDIT_SPEED100:
rb->mpeg_set_pitch(1000); rb->mpeg_set_pitch(1000);
splitedit_invalidate_osci(); splitedit_invalidate_osci();
break; break;
case BUTTON_ON | BUTTON_LEFT: case SPLITEDIT_SPEED50:
rb->mpeg_set_pitch(500); rb->mpeg_set_pitch(500);
splitedit_invalidate_osci(); splitedit_invalidate_osci();
break; break;
#endif
#endif #endif
case BUTTON_LEFT: case BUTTON_LEFT:
@ -1046,7 +1085,7 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
} }
break; break;
case BUTTON_F1 | BUTTON_REL: case SPLITEDIT_SAVE:
save_editor(mp3, xpos_to_time(split_x)); save_editor(mp3, xpos_to_time(split_x));
rb->lcd_clear_display(); rb->lcd_clear_display();
update_osci(); update_osci();
@ -1054,19 +1093,34 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split,
update_icons(); update_icons();
break; break;
case BUTTON_F2: case SPLITEDIT_LOOP_MODE:
splitedit_set_loop_mode(splitedit_get_loop_mode() + 1); splitedit_set_loop_mode(splitedit_get_loop_mode() + 1);
update_icons(); update_icons();
break; break;
case BUTTON_F3: case SPLITEDIT_SCALE:
#if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F) #if (CONFIG_HWCODEC == MAS3587F) || (CONFIG_HWCODEC == MAS3539F)
rb->peak_meter_set_use_dbfs(rb->peak_meter_get_use_dbfs() +1); rb->peak_meter_set_use_dbfs(rb->peak_meter_get_use_dbfs() +1);
#endif #endif
splitedit_invalidate_osci(); splitedit_invalidate_osci();
update_icons(); update_icons();
break; break;
case SPLITEDIT_QUIT:
exit_request = true;
break;
default:
if (rb->default_event_handler(button) == SYS_USB_CONNECTED)
{
splitedit_exit_code = PLUGIN_USB_CONNECTED;
exit_request = true;
}
break;
} }
if (button != BUTTON_NONE)
lastbutton = button;
if (validation_start == ~(unsigned int)0) if (validation_start == ~(unsigned int)0)
{ {

View file

@ -59,6 +59,32 @@
#define STAR_CONTROL_BALL 0 #define STAR_CONTROL_BALL 0
#define STAR_CONTROL_BLOCK 1 #define STAR_CONTROL_BLOCK 1
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define STAR_QUIT BUTTON_OFF
#define STAR_TOGGLE_CONTROL BUTTON_ON
#define STAR_TOGGLE_CONTROL2 BUTTON_PLAY
#define STAR_LEVEL_UP BUTTON_F3
#define STAR_LEVEL_DOWN BUTTON_F1
#define STAR_LEVEL_REPEAT BUTTON_F2
#define STAR_MENU_RUN BUTTON_PLAY
#define STAR_MENU_RUN2 BUTTON_RIGHT
#define STAR_MENU_RUN3 BUTTON_ON
#elif CONFIG_KEYPAD == ONDIO_PAD
#define STAR_QUIT BUTTON_OFF
#define STAR_TOGGLE_CONTROL_PRE BUTTON_MENU
#define STAR_TOGGLE_CONTROL (BUTTON_MENU | BUTTON_REL)
#define STAR_LEVEL_UP (BUTTON_MENU | BUTTON_RIGHT)
#define STAR_LEVEL_DOWN (BUTTON_MENU | BUTTON_LEFT)
#define STAR_LEVEL_REPEAT (BUTTON_MENU | BUTTON_UP)
#define STAR_MENU_RUN BUTTON_RIGHT
#endif
/* function returns because of USB? */
static bool usb_detected = false;
/* position of the ball */ /* position of the ball */
static int ball_x, ball_y; static int ball_x, ball_y;
@ -328,6 +354,7 @@ static void star_display_text(char *str, bool waitkey)
int i; int i;
char line[255]; char line[255];
int key; int key;
bool go_on;
rb->lcd_clear_display(); rb->lcd_clear_display();
@ -384,10 +411,26 @@ static void star_display_text(char *str, bool waitkey)
{ {
current_line = 0; current_line = 0;
rb->lcd_update(); rb->lcd_update();
if (waitkey) go_on = false;
while ((key = rb->button_get(true)) != BUTTON_PLAY while (waitkey && !go_on)
&& key != BUTTON_ON {
&& key != BUTTON_DOWN); key = rb->button_get(true);
switch (key)
{
case STAR_MENU_RUN:
case BUTTON_DOWN:
go_on = true;
break;
default:
if (rb->default_event_handler(key) == SYS_USB_CONNECTED)
{
usb_detected = true;
go_on = true;
break;
}
}
}
rb->lcd_clear_display(); rb->lcd_clear_display();
} }
} while (*ptr_char != '\0'); } while (*ptr_char != '\0');
@ -518,6 +561,8 @@ static int star_run_game(void)
int move_x = 0; int move_x = 0;
int move_y = 0; int move_y = 0;
int i; int i;
int key;
int lastkey = BUTTON_NONE;
int label_offset_y; int label_offset_y;
@ -531,58 +576,75 @@ static int star_run_game(void)
move_x = 0; move_x = 0;
move_y = 0; move_y = 0;
switch (rb->button_get(true)) while ((move_x == 0) && (move_y == 0))
{ {
case BUTTON_OFF: key = rb->button_get(true);
return PLUGIN_OK; switch (key)
{
case STAR_QUIT:
return 0;
case BUTTON_LEFT: case BUTTON_LEFT:
move_x = -1; move_x = -1;
break; break;
case BUTTON_RIGHT: case BUTTON_RIGHT:
move_x = 1; move_x = 1;
break; break;
case BUTTON_UP: case BUTTON_UP:
move_y = -1; move_y = -1;
break; break;
case BUTTON_DOWN: case BUTTON_DOWN:
move_y = 1; move_y = 1;
break; break;
case BUTTON_F1: case STAR_LEVEL_DOWN:
if (current_level > 0) if (current_level > 0)
{ {
current_level--; current_level--;
star_load_level(current_level);
}
break;
case STAR_LEVEL_REPEAT:
star_load_level(current_level); star_load_level(current_level);
} break;
continue;
case BUTTON_F2: case STAR_LEVEL_UP:
star_load_level(current_level); if (current_level < STAR_LEVEL_COUNT - 1)
continue; {
current_level++;
star_load_level(current_level);
}
break;
case BUTTON_F3: case STAR_TOGGLE_CONTROL:
if (current_level < STAR_LEVEL_COUNT - 1) #ifdef STAR_TOGGLE_CONTROL_PRE
{ if (lastkey != STAR_TOGGLE_CONTROL_PRE)
current_level++; break;
star_load_level(current_level); #endif
} #ifdef STAR_TOGGLE_CONTROL2
continue; case STAR_TOGGLE_CONTROL2:
#endif
if (control == STAR_CONTROL_BALL)
control = STAR_CONTROL_BLOCK;
else
control = STAR_CONTROL_BALL;
star_display_board_info();
break;
case BUTTON_PLAY: default:
case BUTTON_ON: if (rb->default_event_handler(key) == SYS_USB_CONNECTED)
if (control == STAR_CONTROL_BALL) {
control = STAR_CONTROL_BLOCK; usb_detected = true;
else return 0;
control = STAR_CONTROL_BALL; }
star_display_board_info(); break;
continue; }
if (key != BUTTON_NONE)
default: lastkey = key;
continue;
} }
if (control == STAR_CONTROL_BALL) if (control == STAR_CONTROL_BALL)
@ -673,6 +735,7 @@ static int star_menu(void)
unsigned char *menu[4] = {"Start", "Information", "Keys", "Exit"}; unsigned char *menu[4] = {"Start", "Information", "Keys", "Exit"};
int menu_count = sizeof(menu) / sizeof(unsigned char *); int menu_count = sizeof(menu) / sizeof(unsigned char *);
int menu_offset_y; int menu_offset_y;
int key;
menu_offset_y = LCD_HEIGHT - char_height * menu_count; menu_offset_y = LCD_HEIGHT - char_height * menu_count;
@ -700,9 +763,10 @@ static int star_menu(void)
rb->sleep(STAR_SLEEP); rb->sleep(STAR_SLEEP);
anim_state++; anim_state++;
switch (rb->button_get(false)) key = rb->button_get(false);
switch (key)
{ {
case BUTTON_OFF: case STAR_QUIT:
return PLUGIN_OK; return PLUGIN_OK;
case BUTTON_UP: case BUTTON_UP:
if (menu_y > 0) if (menu_y > 0)
@ -713,15 +777,18 @@ static int star_menu(void)
move_y = 1; move_y = 1;
break; break;
case BUTTON_ON: case STAR_MENU_RUN:
case BUTTON_PLAY: #ifdef STAR_MENU_RUN3
case BUTTON_RIGHT: case STAR_MENU_RUN2:
case STAR_MENU_RUN3:
#endif
refresh = true; refresh = true;
switch (menu_y) switch (menu_y)
{ {
case 0: case 0:
if (!star_run_game()) if (!star_run_game())
return PLUGIN_OK; return usb_detected ?
PLUGIN_USB_CONNECTED : PLUGIN_OK;
break; break;
case 1: case 1:
star_display_text( star_display_text(
@ -732,24 +799,33 @@ static int star_menu(void)
"take \"o\".", true); "take \"o\".", true);
break; break;
case 2: case 2:
#if CONFIG_KEYPAD == RECORDER_PAD
star_display_text("KEYS\n\n" star_display_text("KEYS\n\n"
"[ON] Toggle Ctl.\n" "[ON] Toggle Ctl.\n"
"[OFF] Exit\n" "[OFF] Exit\n"
"[F1] Prev. level\n" "[F1] Prev. level\n"
"[F2] Reset level\n" "[F2] Reset level\n"
"[F3] Next level", true); "[F3] Next level", true);
#elif CONFIG_KEYPAD == ONDIO_PAD
star_display_text("KEYS\n\n"
"[MENU] Toggle Ctl\n"
"[OFF] Exit\n"
"[M <] Prev. level\n"
"[M ^] Reset level\n"
"[M >] Next level", true);
#endif
break; break;
case 3: case 3:
return PLUGIN_OK; return PLUGIN_OK;
} }
if (usb_detected)
return PLUGIN_USB_CONNECTED;
break; break;
case SYS_USB_CONNECTED:
rb->usb_screen();
return PLUGIN_USB_CONNECTED;
default: default:
continue; if (rb->default_event_handler(key) == SYS_USB_CONNECTED)
return PLUGIN_USB_CONNECTED;
break;
} }
for (i = 0 ; i < char_height ; i++) for (i = 0 ; i < char_height ; i++)

View file

@ -19,6 +19,25 @@
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
/* variable button definitions */
#if CONFIG_KEYPAD == RECORDER_PAD
#define VUMETER_QUIT BUTTON_OFF
#define VUMETER_HELP BUTTON_ON
#define VUMETER_MENU BUTTON_F1
#define VUMETER_MENU_EXIT BUTTON_F1
#define VUMETER_MENU_EXIT2 BUTTON_OFF
#elif CONFIG_KEYPAD == ONDIO_PAD
#define VUMETER_QUIT BUTTON_OFF
#define VUMETER_HELP_PRE BUTTON_MENU
#define VUMETER_HELP (BUTTON_MENU | BUTTON_REL)
#define VUMETER_MENU_PRE BUTTON_MENU
#define VUMETER_MENU (BUTTON_MENU | BUTTON_REPEAT)
#define VUMETER_MENU_EXIT BUTTON_MENU
#define VUMETER_MENU_EXIT2 BUTTON_OFF
#endif
const struct plugin_api* rb; const struct plugin_api* rb;
#ifdef SIMULATOR #ifdef SIMULATOR
@ -97,7 +116,11 @@ void load_settings(void) {
} }
else { else {
reset_settings(); reset_settings();
#if CONFIG_KEYPAD == RECORDER_PAD
rb->splash(HZ, true, "Press ON for help"); rb->splash(HZ, true, "Press ON for help");
#elif CONFIG_KEYPAD == ONDIO_PAD
rb->splash(HZ, true, "Press MENU for help");
#endif
} }
} }
@ -195,8 +218,8 @@ void change_settings(void)
switch(rb->button_get_w_tmo(1)) switch(rb->button_get_w_tmo(1))
{ {
case BUTTON_F1: case VUMETER_MENU_EXIT:
case BUTTON_OFF: case VUMETER_MENU_EXIT2:
quit = true; quit = true;
break; break;
@ -385,6 +408,7 @@ void digital_meter(void) {
enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
int button; int button;
int lastbutton = BUTTON_NONE;
TEST_PLUGIN_API(api); TEST_PLUGIN_API(api);
(void) parameter; (void) parameter;
@ -409,21 +433,33 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
button = rb->button_get_w_tmo(1); button = rb->button_get_w_tmo(1);
switch (button) switch (button)
{ {
case BUTTON_OFF: case VUMETER_QUIT:
save_settings(); save_settings();
return PLUGIN_OK; return PLUGIN_OK;
break; break;
case BUTTON_ON: case VUMETER_HELP:
#ifdef VUMETER_HELP_PRE
if (lastbutton != VUMETER_HELP_PRE)
break;
#endif
rb->lcd_clear_display(); rb->lcd_clear_display();
rb->lcd_puts(0, 0, "OFF: Exit"); rb->lcd_puts(0, 0, "OFF: Exit");
#if CONFIG_KEYPAD == RECORDER_PAD
rb->lcd_puts(0, 1, "F1: Settings"); rb->lcd_puts(0, 1, "F1: Settings");
#elif CONFIG_KEYPAD == ONDIO_PAD
rb->lcd_puts(0, 1, "MENU..: Settings");
#endif
rb->lcd_puts(0, 2, "UP/DOWN: Volume"); rb->lcd_puts(0, 2, "UP/DOWN: Volume");
rb->lcd_update(); rb->lcd_update();
rb->sleep(HZ*3); rb->sleep(HZ*3);
break; break;
case BUTTON_F1: case VUMETER_MENU:
#ifdef VUMETER_MENU_PRE
if (lastbutton != VUMETER_MENU_PRE)
break;
#endif
change_settings(); change_settings();
break; break;
@ -442,6 +478,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) {
return PLUGIN_USB_CONNECTED; return PLUGIN_USB_CONNECTED;
break; break;
} }
if (button != BUTTON_NONE)
lastbutton = button;
} }
} }
#endif /* #ifdef HAVE_LCD_BITMAP */ #endif /* #ifdef HAVE_LCD_BITMAP */