summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/bookmark.c69
-rw-r--r--apps/credits.c2
-rw-r--r--apps/debug_menu.c460
-rw-r--r--apps/main.c2
-rw-r--r--apps/main_menu.c15
-rw-r--r--apps/menu.c77
-rw-r--r--apps/menu.h26
-rw-r--r--apps/misc.c5
-rw-r--r--apps/onplay.c71
-rw-r--r--apps/player/keyboard.c17
-rw-r--r--apps/playlist.c18
-rw-r--r--apps/playlist_viewer.c67
-rw-r--r--apps/plugins/calendar.c2
-rw-r--r--apps/recorder/keyboard.c13
-rw-r--r--apps/recorder/radio.c13
-rw-r--r--apps/recorder/recording.c10
-rw-r--r--apps/screens.c157
-rw-r--r--apps/screens.h3
-rw-r--r--apps/settings.c69
-rw-r--r--apps/settings.h25
-rw-r--r--apps/settings_menu.c38
-rw-r--r--apps/sleeptimer.c96
-rw-r--r--apps/sound_menu.c31
-rw-r--r--apps/tree.c115
-rw-r--r--apps/tree.h42
-rw-r--r--apps/wps.c653
-rw-r--r--apps/wps.h1
27 files changed, 967 insertions, 1130 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c
index ed85ff6222..9488e52d3d 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -256,33 +256,25 @@ bool bookmark_autobookmark(void)
{
/* Wait for a key to be pushed */
key = button_get(true);
- switch (key)
+ if (key & BUTTON_REL)
{
- case BUTTON_DOWN | BUTTON_REL:
- case BUTTON_ON | BUTTON_REL:
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_OFF | BUTTON_REL:
- case BUTTON_RIGHT | BUTTON_REL:
- case BUTTON_UP | BUTTON_REL:
+#ifdef BUTTON_PLAY
+ if (key & BUTTON_PLAY)
+#else
+ if (key & BUTTON_RIGHT)
#endif
- case BUTTON_LEFT | BUTTON_REL:
- done = true;
- break;
-
- case BUTTON_PLAY | BUTTON_REL:
+ {
if (global_settings.autocreatebookmark ==
BOOKMARK_RECENT_ONLY_ASK)
write_bookmark(false);
else
write_bookmark(true);
- done = true;
- break;
-
- default:
- if(default_event_handler(key) == SYS_USB_CONNECTED)
- return false;
- break;
+ }
+ done = true;
}
+
+ if (default_event_handler(key) == SYS_USB_CONNECTED)
+ return false;
}
return true;
}
@@ -520,7 +512,11 @@ bool bookmark_autoload(const char* file)
case BUTTON_DOWN:
return bookmark_load(global_bookmark_file_name, false);
#endif
+#ifdef BUTTON_PLAY
case BUTTON_PLAY:
+#else
+ case BUTTON_RIGHT:
+#endif
return bookmark_load(global_bookmark_file_name, true);
default:
@@ -668,7 +664,10 @@ static char* select_bookmark(const char* bookmark_file_name)
key = button_get(true);
switch(key)
{
- case BUTTON_PLAY:
+ case SETTINGS_OK:
+#ifdef SETTINGS_OK2
+ case SETTINGS_OK2:
+#endif
/* User wants to use this bookmark */
#ifdef HAVE_LCD_BITMAP
if (global_settings.statusbar)
@@ -678,7 +677,11 @@ static char* select_bookmark(const char* bookmark_file_name)
#endif
return bookmark;
+#if defined(BUTTON_ON) && defined(BUTTON_PLAY)
case BUTTON_ON | BUTTON_PLAY:
+#elif defined(BUTTON_MENU) && defined(BUTTON_RIGHT)
+ case BUTTON_MENU | BUTTON_RIGHT:
+#endif
/* User wants to delete this bookmark */
delete_bookmark(bookmark_file_name, bookmark_id);
bookmark_id_prev=-1;
@@ -687,36 +690,20 @@ static char* select_bookmark(const char* bookmark_file_name)
while (button_get(false)); /* clear button queue */
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_UP:
+ case SETTINGS_DEC:
bookmark_id--;
break;
- case BUTTON_DOWN:
+ case SETTINGS_INC:
bookmark_id++;
break;
- case BUTTON_LEFT:
- case BUTTON_OFF:
-#ifdef HAVE_LCD_BITMAP
- if (global_settings.statusbar)
- lcd_setmargins(0, STATUSBAR_HEIGHT);
- else
- lcd_setmargins(0, 0);
+ case SETTINGS_CANCEL:
+#ifdef SETTINGS_CANCEL2
+ case SETTINGS_CANCEL2:
#endif
return NULL;
-#else
- case BUTTON_LEFT:
- bookmark_id--;
- break;
- case BUTTON_RIGHT:
- bookmark_id++;
- break;
-
- case BUTTON_STOP:
- return NULL;
-#endif
default:
if(default_event_handler(key) == SYS_USB_CONNECTED)
return NULL;
diff --git a/apps/credits.c b/apps/credits.c
index d8cda66677..492426ef8d 100644
--- a/apps/credits.c
+++ b/apps/credits.c
@@ -54,7 +54,7 @@ void roll_credits(void)
}
/* abort on keypress */
- if (button_get_w_tmo(DISPLAY_TIME))
+ if (button_get_w_tmo(DISPLAY_TIME) & BUTTON_REL)
return;
}
return;
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 12ba0c5fbe..7ef531f4df 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -93,10 +93,7 @@ bool dbg_os(void)
switch(button)
{
-#ifdef BUTTON_OFF
- case BUTTON_OFF:
-#endif
- case BUTTON_LEFT:
+ case SETTINGS_CANCEL:
return false;
}
}
@@ -127,16 +124,16 @@ bool dbg_os(void)
switch(button)
{
- case BUTTON_STOP:
+ case SETTINGS_CANCEL:
return false;
- case BUTTON_LEFT:
+ case SETTINGS_DEC:
currval--;
if(currval < 0)
currval = num_threads-1;
break;
- case BUTTON_RIGHT:
+ case SETTINGS_INC:
currval++;
if(currval > num_threads-1)
currval = 0;
@@ -161,7 +158,7 @@ bool dbg_mpeg_thread(void)
button = button_get_w_tmo(HZ/5);
switch(button)
{
- case BUTTON_OFF | BUTTON_REL:
+ case SETTINGS_CANCEL:
return false;
}
@@ -375,7 +372,7 @@ bool dbg_hw_info(void)
while(1)
{
button = button_get(true);
- if(button == (BUTTON_OFF | BUTTON_REL))
+ if(button == SETTINGS_CANCEL)
return false;
}
@@ -460,16 +457,16 @@ bool dbg_hw_info(void)
switch(button)
{
- case BUTTON_STOP:
+ case SETTINGS_CANCEL:
return false;
- case BUTTON_LEFT:
+ case SETTINGS_DEC:
currval--;
if(currval < 0)
currval = 5;
break;
- case BUTTON_RIGHT:
+ case SETTINGS_INC:
currval++;
if(currval > 5)
currval = 0;
@@ -507,26 +504,17 @@ bool dbg_partitions(void)
switch(button)
{
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_OFF:
-#else
- case BUTTON_STOP:
-#endif
+ case SETTINGS_OK:
+ case SETTINGS_CANCEL:
return false;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_UP:
-#endif
- case BUTTON_LEFT:
+ case SETTINGS_DEC:
partition--;
if (partition < 0)
partition = 3;
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_DOWN:
-#endif
- case BUTTON_RIGHT:
+ case SETTINGS_INC:
partition++;
if (partition > 3)
partition = 0;
@@ -595,7 +583,7 @@ bool dbg_ports(void)
switch(button)
{
- case BUTTON_OFF | BUTTON_REL:
+ case SETTINGS_CANCEL:
return false;
}
}
@@ -675,16 +663,16 @@ bool dbg_ports(void)
switch(button)
{
- case BUTTON_STOP | BUTTON_REL:
+ case SETTINGS_CANCEL:
return false;
- case BUTTON_LEFT:
+ case SETTINGS_DEC:
currval--;
if(currval < 0)
currval = 10;
break;
- case BUTTON_RIGHT:
+ case SETTINGS_INC:
currval++;
if(currval > 10)
currval = 0;
@@ -727,20 +715,25 @@ bool dbg_rtc(void)
switch(button)
{
- case BUTTON_DOWN:
- if (addr < 63-16) { addr += 16; }
- break;
- case BUTTON_UP:
- if (addr) { addr -= 16; }
- break;
- case BUTTON_F2:
- /* clear the user RAM space */
- for (c = 0; c <= 43; c++)
- rtc_write(0x14 + c, 0);
- break;
- case BUTTON_OFF | BUTTON_REL:
- case BUTTON_LEFT | BUTTON_REL:
- return false;
+ case SETTINGS_INC:
+ if (addr < 63-16) { addr += 16; }
+ break;
+
+ case SETTINGS_DEC:
+ if (addr) { addr -= 16; }
+ break;
+
+#ifdef BUTTON_F2
+ case BUTTON_F2:
+ /* clear the user RAM space */
+ for (c = 0; c <= 43; c++)
+ rtc_write(0x14 + c, 0);
+ break;
+#endif
+
+ case SETTINGS_OK:
+ case SETTINGS_CANCEL:
+ return false;
}
}
return false;
@@ -781,26 +774,17 @@ bool dbg_mas(void)
switch(button_get_w_tmo(HZ/16))
{
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_DOWN:
-#else
- case BUTTON_RIGHT:
-#endif
- addr = (addr + NUMROWS) & 0xFF; /* register addrs are 8 bit */
- break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_UP:
-#else
- case BUTTON_LEFT:
-#endif
- addr = (addr - NUMROWS) & 0xFF; /* register addrs are 8 bit */
- break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_LEFT:
-#else
- case BUTTON_DOWN:
-#endif
- return false;
+ case SETTINGS_INC:
+ addr = (addr + NUMROWS) & 0xFF; /* register addrs are 8 bit */
+ break;
+
+ case SETTINGS_DEC:
+ addr = (addr - NUMROWS) & 0xFF; /* register addrs are 8 bit */
+ break;
+
+ case SETTINGS_OK:
+ case SETTINGS_CANCEL:
+ return false;
}
}
return false;
@@ -830,15 +814,16 @@ bool dbg_mas_codec(void)
switch(button_get_w_tmo(HZ/16))
{
- case BUTTON_DOWN:
- addr += 4;
- break;
- case BUTTON_UP:
- if (addr) { addr -= 4; }
- break;
- case BUTTON_LEFT | BUTTON_REL:
- case BUTTON_OFF | BUTTON_REL:
- return false;
+ case SETTINGS_INC:
+ addr += 4;
+ break;
+ case SETTINGS_DEC:
+ if (addr) { addr -= 4; }
+ break;
+
+ case SETTINGS_OK:
+ case SETTINGS_CANCEL:
+ return false;
}
}
return false;
@@ -994,18 +979,18 @@ bool view_battery(void)
switch(button_get_w_tmo(HZ/2))
{
- case BUTTON_UP:
+ case SETTINGS_DEC:
if (view)
view--;
break;
- case BUTTON_DOWN:
+ case SETTINGS_INC:
if (view < 3)
view++;
break;
- case BUTTON_LEFT | BUTTON_REL:
- case BUTTON_OFF | BUTTON_REL:
+ case SETTINGS_OK:
+ case SETTINGS_CANCEL:
return false;
}
}
@@ -1031,158 +1016,159 @@ bool dbg_mas_info(void)
{
switch(currval)
{
- case 0:
- mas_readmem(MAS_BANK_D1, 0xff7, &val, 1);
- lcd_puts(0, 0, "Design Code");
- snprintf(buf, 32, "%05x ", val);
- break;
- case 1:
- lcd_puts(0, 0, "DC/DC mode ");
- snprintf(buf, 32, "8e: %05x ", mas_readreg(0x8e) & 0xfffff);
- break;
- case 2:
- lcd_puts(0, 0, "Mute/Bypass");
- snprintf(buf, 32, "aa: %05x ", mas_readreg(0xaa) & 0xfffff);
- break;
- case 3:
- lcd_puts(0, 0, "PIOData ");
- snprintf(buf, 32, "ed: %05x ", mas_readreg(0xed) & 0xfffff);
- break;
- case 4:
- lcd_puts(0, 0, "Startup Cfg");
- snprintf(buf, 32, "e6: %05x ", mas_readreg(0xe6) & 0xfffff);
- break;
- case 5:
- lcd_puts(0, 0, "KPrescale ");
- snprintf(buf, 32, "e7: %05x ", mas_readreg(0xe7) & 0xfffff);
- break;
- case 6:
- lcd_puts(0, 0, "KBass ");
- snprintf(buf, 32, "6b: %05x ", mas_readreg(0x6b) & 0xfffff);
- break;
- case 7:
- lcd_puts(0, 0, "KTreble ");
- snprintf(buf, 32, "6f: %05x ", mas_readreg(0x6f) & 0xfffff);
- break;
- case 8:
- mas_readmem(MAS_BANK_D0, 0x300, &val, 1);
- lcd_puts(0, 0, "Frame Count");
- snprintf(buf, 32, "0/300: %04x", val & 0xffff);
- break;
- case 9:
- mas_readmem(MAS_BANK_D0, 0x301, &val, 1);
- lcd_puts(0, 0, "Status1 ");
- snprintf(buf, 32, "0/301: %04x", val & 0xffff);
- break;
- case 10:
- mas_readmem(MAS_BANK_D0, 0x302, &val, 1);
- lcd_puts(0, 0, "Status2 ");
- snprintf(buf, 32, "0/302: %04x", val & 0xffff);
- break;
- case 11:
- mas_readmem(MAS_BANK_D0, 0x303, &val, 1);
- lcd_puts(0, 0, "CRC Count ");
- snprintf(buf, 32, "0/303: %04x", val & 0xffff);
- break;
- case 12:
- mas_readmem(MAS_BANK_D0, 0x36d, &val, 1);
- lcd_puts(0, 0, "PLLOffset48");
- snprintf(buf, 32, "0/36d %05x", val & 0xfffff);
- break;
- case 13:
- mas_readmem(MAS_BANK_D0, 0x32d, &val, 1);
- lcd_puts(0, 0, "PLLOffset48");
- snprintf(buf, 32, "0/32d %05x", val & 0xfffff);
- break;
- case 14:
- mas_readmem(MAS_BANK_D0, 0x36e, &val, 1);
- lcd_puts(0, 0, "PLLOffset44");
- snprintf(buf, 32, "0/36e %05x", val & 0xfffff);
- break;
- case 15:
- mas_readmem(MAS_BANK_D0, 0x32e, &val, 1);
- lcd_puts(0, 0, "PLLOffset44");
- snprintf(buf, 32, "0/32e %05x", val & 0xfffff);
- break;
- case 16:
- mas_readmem(MAS_BANK_D0, 0x36f, &val, 1);
- lcd_puts(0, 0, "OutputConf ");
- snprintf(buf, 32, "0/36f %05x", val & 0xfffff);
- break;
- case 17:
- mas_readmem(MAS_BANK_D0, 0x32f, &val, 1);
- lcd_puts(0, 0, "OutputConf ");
- snprintf(buf, 32, "0/32f %05x", val & 0xfffff);
- break;
- case 18:
- mas_readmem(MAS_BANK_D1, 0x7f8, &val, 1);
- lcd_puts(0, 0, "LL Gain ");
- snprintf(buf, 32, "1/7f8 %05x", val & 0xfffff);
- break;
- case 19:
- mas_readmem(MAS_BANK_D1, 0x7f9, &val, 1);
- lcd_puts(0, 0, "LR Gain ");
- snprintf(buf, 32, "1/7f9 %05x", val & 0xfffff);
- break;
- case 20:
- mas_readmem(MAS_BANK_D1, 0x7fa, &val, 1);
- lcd_puts(0, 0, "RL Gain ");
- snprintf(buf, 32, "1/7fa %05x", val & 0xfffff);
- break;
- case 21:
- mas_readmem(MAS_BANK_D1, 0x7fb, &val, 1);
- lcd_puts(0, 0, "RR Gain ");
- snprintf(buf, 32, "1/7fb %05x", val & 0xfffff);
- break;
- case 22:
- lcd_puts(0, 0, "L Trailbits");
- snprintf(buf, 32, "c5: %05x ", mas_readreg(0xc5) & 0xfffff);
- break;
- case 23:
- lcd_puts(0, 0, "R Trailbits");
- snprintf(buf, 32, "c6: %05x ", mas_readreg(0xc6) & 0xfffff);
- break;
+ case 0:
+ mas_readmem(MAS_BANK_D1, 0xff7, &val, 1);
+ lcd_puts(0, 0, "Design Code");
+ snprintf(buf, 32, "%05x ", val);
+ break;
+ case 1:
+ lcd_puts(0, 0, "DC/DC mode ");
+ snprintf(buf, 32, "8e: %05x ", mas_readreg(0x8e) & 0xfffff);
+ break;
+ case 2:
+ lcd_puts(0, 0, "Mute/Bypass");
+ snprintf(buf, 32, "aa: %05x ", mas_readreg(0xaa) & 0xfffff);
+ break;
+ case 3:
+ lcd_puts(0, 0, "PIOData ");
+ snprintf(buf, 32, "ed: %05x ", mas_readreg(0xed) & 0xfffff);
+ break;
+ case 4:
+ lcd_puts(0, 0, "Startup Cfg");
+ snprintf(buf, 32, "e6: %05x ", mas_readreg(0xe6) & 0xfffff);
+ break;
+ case 5:
+ lcd_puts(0, 0, "KPrescale ");
+ snprintf(buf, 32, "e7: %05x ", mas_readreg(0xe7) & 0xfffff);
+ break;
+ case 6:
+ lcd_puts(0, 0, "KBass ");
+ snprintf(buf, 32, "6b: %05x ", mas_readreg(0x6b) & 0xfffff);
+ break;
+ case 7:
+ lcd_puts(0, 0, "KTreble ");
+ snprintf(buf, 32, "6f: %05x ", mas_readreg(0x6f) & 0xfffff);
+ break;
+ case 8:
+ mas_readmem(MAS_BANK_D0, 0x300, &val, 1);
+ lcd_puts(0, 0, "Frame Count");
+ snprintf(buf, 32, "0/300: %04x", val & 0xffff);
+ break;
+ case 9:
+ mas_readmem(MAS_BANK_D0, 0x301, &val, 1);
+ lcd_puts(0, 0, "Status1 ");
+ snprintf(buf, 32, "0/301: %04x", val & 0xffff);
+ break;
+ case 10:
+ mas_readmem(MAS_BANK_D0, 0x302, &val, 1);
+ lcd_puts(0, 0, "Status2 ");
+ snprintf(buf, 32, "0/302: %04x", val & 0xffff);
+ break;
+ case 11:
+ mas_readmem(MAS_BANK_D0, 0x303, &val, 1);
+ lcd_puts(0, 0, "CRC Count ");
+ snprintf(buf, 32, "0/303: %04x", val & 0xffff);
+ break;
+ case 12:
+ mas_readmem(MAS_BANK_D0, 0x36d, &val, 1);
+ lcd_puts(0, 0, "PLLOffset48");
+ snprintf(buf, 32, "0/36d %05x", val & 0xfffff);
+ break;
+ case 13:
+ mas_readmem(MAS_BANK_D0, 0x32d, &val, 1);
+ lcd_puts(0, 0, "PLLOffset48");
+ snprintf(buf, 32, "0/32d %05x", val & 0xfffff);
+ break;
+ case 14:
+ mas_readmem(MAS_BANK_D0, 0x36e, &val, 1);
+ lcd_puts(0, 0, "PLLOffset44");
+ snprintf(buf, 32, "0/36e %05x", val & 0xfffff);
+ break;
+ case 15:
+ mas_readmem(MAS_BANK_D0, 0x32e, &val, 1);
+ lcd_puts(0, 0, "PLLOffset44");
+ snprintf(buf, 32, "0/32e %05x", val & 0xfffff);
+ break;
+ case 16:
+ mas_readmem(MAS_BANK_D0, 0x36f, &val, 1);
+ lcd_puts(0, 0, "OutputConf ");
+ snprintf(buf, 32, "0/36f %05x", val & 0xfffff);
+ break;
+ case 17:
+ mas_readmem(MAS_BANK_D0, 0x32f, &val, 1);
+ lcd_puts(0, 0, "OutputConf ");
+ snprintf(buf, 32, "0/32f %05x", val & 0xfffff);
+ break;
+ case 18:
+ mas_readmem(MAS_BANK_D1, 0x7f8, &val, 1);
+ lcd_puts(0, 0, "LL Gain ");
+ snprintf(buf, 32, "1/7f8 %05x", val & 0xfffff);
+ break;
+ case 19:
+ mas_readmem(MAS_BANK_D1, 0x7f9, &val, 1);
+ lcd_puts(0, 0, "LR Gain ");
+ snprintf(buf, 32, "1/7f9 %05x", val & 0xfffff);
+ break;
+ case 20:
+ mas_readmem(MAS_BANK_D1, 0x7fa, &val, 1);
+ lcd_puts(0, 0, "RL Gain ");
+ snprintf(buf, 32, "1/7fa %05x", val & 0xfffff);
+ break;
+ case 21:
+ mas_readmem(MAS_BANK_D1, 0x7fb, &val, 1);
+ lcd_puts(0, 0, "RR Gain ");
+ snprintf(buf, 32, "1/7fb %05x", val & 0xfffff);
+ break;
+ case 22:
+ lcd_puts(0, 0, "L Trailbits");
+ snprintf(buf, 32, "c5: %05x ", mas_readreg(0xc5) & 0xfffff);
+ break;
+ case 23:
+ lcd_puts(0, 0, "R Trailbits");
+ snprintf(buf, 32, "c6: %05x ", mas_readreg(0xc6) & 0xfffff);
+ break;
}
lcd_puts(0, 1, buf);
button = button_get_w_tmo(HZ/5);
switch(button)
{
- case BUTTON_STOP:
- return false;
+ case SETTINGS_CANCEL:
+ return false;
- case BUTTON_LEFT:
- currval--;
- if(currval < 0)
- currval = 23;
- break;
+ case SETTINGS_DEC:
+ currval--;
+ if(currval < 0)
+ currval = 23;
+ break;
- case BUTTON_RIGHT:
- currval++;
- if(currval > 23)
- currval = 0;
- break;
- case BUTTON_PLAY:
- pll_toggle = !pll_toggle;
- if(pll_toggle)
- {
- /* 14.31818 MHz crystal */
- pll48 = 0x5d9d0;
- pll44 = 0xfffceceb;
- config = 0;
- }
- else
- {
- /* 14.725 MHz crystal */
- pll48 = 0x2d0de;
- pll44 = 0xfffa2319;
- config = 0;
- }
- mas_writemem(MAS_BANK_D0, 0x32d, &pll48, 1);
- mas_writemem(MAS_BANK_D0, 0x32e, &pll44, 1);
- mas_writemem(MAS_BANK_D0, 0x32f, &config, 1);
- mas_run(0x475);
- break;
+ case SETTINGS_INC:
+ currval++;
+ if(currval > 23)
+ currval = 0;
+ break;
+
+ case SETTINGS_OK:
+ pll_toggle = !pll_toggle;
+ if(pll_toggle)
+ {
+ /* 14.31818 MHz crystal */
+ pll48 = 0x5d9d0;
+ pll44 = 0xfffceceb;
+ config = 0;
+ }
+ else
+ {
+ /* 14.725 MHz crystal */
+ pll48 = 0x2d0de;
+ pll44 = 0xfffa2319;
+ config = 0;
+ }
+ mas_writemem(MAS_BANK_D0, 0x32d, &pll48, 1);
+ mas_writemem(MAS_BANK_D0, 0x32e, &pll44, 1);
+ mas_writemem(MAS_BANK_D0, 0x32f, &config, 1);
+ mas_run(0x475);
+ break;
}
}
return false;
@@ -1233,23 +1219,19 @@ static bool view_runtime(void)
/* Wait for a key to be pushed */
key = button_get_w_tmo(HZ);
switch(key) {
-#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
- case BUTTON_STOP | BUTTON_REL:
-#elif HAVE_RECORDER_KEYPAD
- case BUTTON_OFF | BUTTON_REL:
-#endif
+ case SETTINGS_CANCEL:
done = true;
break;
- case BUTTON_LEFT:
- case BUTTON_RIGHT:
+ case SETTINGS_INC:
+ case SETTINGS_DEC:
if (state == 1)
state = 2;
else
state = 1;
break;
-
- case BUTTON_PLAY:
+
+ case SETTINGS_OK:
lcd_clear_display();
lcd_puts(0,0,"Clear time?");
lcd_puts(0,1,"PLAY = Yes");
@@ -1258,7 +1240,7 @@ static bool view_runtime(void)
key = button_get_w_tmo(HZ*10);
if ( key & BUTTON_REL )
continue;
- if ( key == BUTTON_PLAY ) {
+ if ( key == SETTINGS_OK ) {
if ( state == 1 )
global_settings.runtime = 0;
else
@@ -1412,25 +1394,21 @@ static bool dbg_disk_info(void)
/* Wait for a key to be pushed */
key = button_get_w_tmo(HZ*5);
switch(key) {
-#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
- case BUTTON_STOP | BUTTON_REL:
-#else
- case BUTTON_OFF | BUTTON_REL:
-#endif
+ case SETTINGS_CANCEL:
done = true;
break;
- case BUTTON_LEFT:
+ case SETTINGS_DEC:
if (--page < 0)
page = max_page;
break;
- case BUTTON_RIGHT:
+ case SETTINGS_INC:
if (++page > max_page)
page = 0;
break;
- case BUTTON_PLAY:
+ case SETTINGS_OK:
if (page == 3) {
mpeg_stop(); /* stop playback, to avoid disk access */
lcd_clear_display();
@@ -1498,11 +1476,7 @@ bool dbg_fm_radio(void)
switch(button)
{
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_OFF:
-#else
- case BUTTON_STOP:
-#endif
+ case SETTINGS_CANCEL:
return false;
}
}
diff --git a/apps/main.c b/apps/main.c
index 54d3955f4d..70dc9e2fed 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -169,7 +169,7 @@ void init(void)
lcd_puts(0, 1, str);
lcd_puts(0, 3, "Press ON to debug");
lcd_update();
- while(button_get(true) != BUTTON_ON);
+ while(!(button_get(true) & BUTTON_REL));
dbg_ports();
#endif
panicf("ata: %d", rc);
diff --git a/apps/main_menu.c b/apps/main_menu.c
index 1d2978e65e..da3d8ad5c1 100644
--- a/apps/main_menu.c
+++ b/apps/main_menu.c
@@ -231,24 +231,19 @@ bool show_info(void)
/* Wait for a key to be pushed */
key = button_get_w_tmo(HZ*5);
switch(key) {
-#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
- case BUTTON_STOP | BUTTON_REL:
-#else
- case BUTTON_LEFT | BUTTON_REL:
- case BUTTON_OFF | BUTTON_REL:
-#endif
+ case SETTINGS_OK:
+ case SETTINGS_CANCEL:
done = true;
break;
-#if defined(HAVE_RECORDER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
- case BUTTON_LEFT:
- case BUTTON_RIGHT:
+ case SETTINGS_INC:
+ case SETTINGS_DEC:
if (state == 1)
state = 2;
else
state = 1;
break;
-#endif
+
default:
if(default_event_handler(key) == SYS_USB_CONNECTED)
return true;
diff --git a/apps/menu.c b/apps/menu.c
index fccc88479b..e999c5f774 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -288,11 +288,17 @@ int menu_show(int m)
}
menu_lines = height / fh;
+#else
+ int menu_lines = MENU_LINES;
#endif
/* Put the cursor on the first line and draw the menu */
put_cursor(m, menus[m].cursor);
+ /* wait until all keys are released */
+ while (button_get(false) != BUTTON_NONE)
+ yield();
+
while (!exit) {
key = button_get_w_tmo(HZ/2);
@@ -308,25 +314,15 @@ int menu_show(int m)
key = menus[m].callback(key, m);
switch( key ) {
-
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_UP:
- case BUTTON_UP | BUTTON_REPEAT:
-#else
- case BUTTON_LEFT:
- case BUTTON_LEFT | BUTTON_REPEAT:
-#endif
+ case MENU_PREV:
+ case MENU_PREV | BUTTON_REPEAT:
if (menus[m].cursor) {
/* move up */
put_cursor(m, menus[m].cursor-1);
}
else {
/* move to bottom */
-#ifdef HAVE_RECORDER_KEYPAD
menus[m].top = menus[m].itemcount-(menu_lines+1);
-#else
- menus[m].top = menus[m].itemcount-3;
-#endif
if (menus[m].top < 0)
menus[m].top = 0;
menus[m].cursor = menus[m].itemcount-1;
@@ -334,13 +330,8 @@ int menu_show(int m)
}
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_DOWN:
- case BUTTON_DOWN | BUTTON_REPEAT:
-#else
- case BUTTON_RIGHT:
- case BUTTON_RIGHT | BUTTON_REPEAT:
-#endif
+ case MENU_NEXT:
+ case MENU_NEXT | BUTTON_REPEAT:
if (menus[m].cursor < menus[m].itemcount-1) {
/* move down */
put_cursor(m, menus[m].cursor+1);
@@ -353,22 +344,23 @@ int menu_show(int m)
}
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_RIGHT:
+ case MENU_ENTER:
+#ifdef MENU_ENTER2
+ case MENU_ENTER2:
#endif
- case BUTTON_PLAY:
/* Erase current display state */
lcd_clear_display();
return menus[m].cursor;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_LEFT:
- case BUTTON_F1:
- case BUTTON_OFF | BUTTON_REPEAT:
-#else
- case BUTTON_STOP:
- case BUTTON_MENU:
- case BUTTON_STOP | BUTTON_REPEAT:
+ case MENU_EXIT:
+ case MENU_EXIT | BUTTON_REPEAT:
+#ifdef MENU_EXIT2
+ case MENU_EXIT2:
+ case MENU_EXIT2 | BUTTON_REPEAT:
+#endif
+#ifdef MENU_EXIT3
+ case MENU_EXIT3:
+ case MENU_EXIT3 | BUTTON_REPEAT:
#endif
lcd_stop_scroll();
exit = true;
@@ -388,18 +380,21 @@ int menu_show(int m)
bool menu_run(int m)
{
- bool stop=false;
- while (!stop) {
- int result=menu_show(m);
- if (result == MENU_SELECTED_EXIT)
- return false;
- else if (result == MENU_ATTACHED_USB)
- return true;
- if (menus[m].items[menus[m].cursor].function()) {
- return true;
+ while (1) {
+ switch (menu_show(m))
+ {
+ case MENU_SELECTED_EXIT:
+ return false;
+
+ case MENU_ATTACHED_USB:
+ return true;
+
+ default:
+ if (menus[m].items[menus[m].cursor].function())
+ return true;
+ }
}
- }
- return false;
+ return false;
}
/*
diff --git a/apps/menu.h b/apps/menu.h
index 12d934fc18..99ef3443ba 100644
--- a/apps/menu.h
+++ b/apps/menu.h
@@ -22,6 +22,32 @@
#include <stdbool.h>
+/* button definitions */
+#ifdef HAVE_RECORDER_KEYPAD
+#define MENU_NEXT BUTTON_DOWN
+#define MENU_PREV BUTTON_UP
+#define MENU_EXIT (BUTTON_LEFT | BUTTON_REL)
+#define MENU_EXIT2 (BUTTON_OFF | BUTTON_REL)
+#define MENU_EXIT3 (BUTTON_F1 | BUTTON_REL)
+#define MENU_ENTER (BUTTON_RIGHT | BUTTON_REL)
+#define MENU_ENTER2 (BUTTON_PLAY | BUTTON_REL)
+
+#elif defined HAVE_PLAYER_KEYPAD
+#define MENU_NEXT BUTTON_RIGHT
+#define MENU_PREV BUTTON_LEFT
+#define MENU_EXIT (BUTTON_STOP | BUTTON_REL)
+#define MENU_EXIT2 (BUTTON_MENU | BUTTON_REL)
+#define MENU_ENTER (BUTTON_PLAY | BUTTON_REL)
+
+#elif defined HAVE_ONDIO_KEYPAD
+#define MENU_NEXT BUTTON_DOWN
+#define MENU_PREV BUTTON_UP
+#define MENU_EXIT (BUTTON_LEFT | BUTTON_REL)
+#define MENU_EXIT2 (BUTTON_MENU | BUTTON_REL)
+#define MENU_ENTER (BUTTON_RIGHT | BUTTON_REL)
+
+#endif
+
struct menu_item {
unsigned char *desc; /* string or ID */
bool (*function) (void); /* return true if USB was connected */
diff --git a/apps/misc.c b/apps/misc.c
index fc84386d56..ced0668ae6 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -16,6 +16,7 @@
* KIND, either express or implied.
*
****************************************************************************/
+#include <stdlib.h>
#include <ctype.h>
#include "lang.h"
#include "string.h"
@@ -206,7 +207,9 @@ bool settings_parseline(char* line, char** name, char** value)
bool clean_shutdown(void)
{
-#ifndef SIMULATOR
+#ifdef SIMULATOR
+ exit(0);
+#else
if(!charger_inserted())
{
lcd_clear_display();
diff --git a/apps/onplay.c b/apps/onplay.c
index 5ef595a774..41e8d2d192 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -116,21 +116,22 @@ static bool add_to_playlist(int position, bool queue)
while (!exit) {
int btn = button_get(true);
switch (btn) {
- case BUTTON_PLAY:
- recurse = true;
- exit = true;
- break;
- default:
- /* ignore button releases */
- if (!(btn & BUTTON_REL))
+ case SETTINGS_OK:
+ recurse = true;
exit = true;
- break;
+ break;
+
+ default:
+ /* ignore button releases */
+ if (!(btn & BUTTON_REL))
+ exit = true;
+ break;
}
}
}
playlist_insert_directory(NULL, selected_file, position, queue,
- recurse);
+ recurse);
}
else if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)
playlist_insert_playlist(NULL, selected_file, position, queue);
@@ -303,34 +304,34 @@ static bool delete_handler(bool is_dir)
while (!exit) {
int btn = button_get(true);
switch (btn) {
- case BUTTON_PLAY:
- if (is_dir)
- {
- char pathname[MAX_PATH]; /* space to go deep */
- strncpy(pathname, selected_file, sizeof pathname);
- res = remove_dir(pathname, sizeof(pathname));
- }
- else
- {
- res = remove(selected_file);
- }
+ case SETTINGS_OK:
+ if (is_dir)
+ {
+ char pathname[MAX_PATH]; /* space to go deep */
+ strncpy(pathname, selected_file, sizeof pathname);
+ res = remove_dir(pathname, sizeof(pathname));
+ }
+ else
+ {
+ res = remove(selected_file);
+ }
- if (!res) {
- onplay_result = ONPLAY_RELOAD_DIR;
- lcd_clear_display();
- lcd_puts(0,0,str(LANG_DELETED));
- lcd_puts_scroll(0,1,selected_file);
- lcd_update();
- sleep(HZ);
- exit = true;
- }
- break;
+ if (!res) {
+ onplay_result = ONPLAY_RELOAD_DIR;
+ lcd_clear_display();
+ lcd_puts(0,0,str(LANG_DELETED));
+ lcd_puts_scroll(0,1,selected_file);
+ lcd_update();
+ sleep(HZ);
+ exit = true;
+ }
+ break;
- default:
- /* ignore button releases */
- if (!(btn & BUTTON_REL))
- exit = true;
- break;
+ default:
+ /* ignore button releases */
+ if (!(btn & BUTTON_REL))
+ exit = true;
+ break;
}
}
return false;
diff --git a/apps/player/keyboard.c b/apps/player/keyboard.c
index 495102b29a..7752ce3ff7 100644
--- a/apps/player/keyboard.c
+++ b/apps/player/keyboard.c
@@ -181,14 +181,15 @@ int kbd_input(char* text, int buflen)
case MENU_LINE_INPUT:
switch (button_pressed)
{
- case BUTTON_UP:
- case BUTTON_UP | BUTTON_REPEAT:
+ case BUTTON_PLAY:
+ case BUTTON_PLAY | BUTTON_REPEAT:
if (cursor_pos<len)
cursor_pos++;
button_pressed=BUTTON_NONE;
break;
- case BUTTON_DOWN:
- case BUTTON_DOWN | BUTTON_REPEAT:
+
+ case BUTTON_STOP:
+ case BUTTON_STOP | BUTTON_REPEAT:
if (cursor_pos>0)
cursor_pos--;
button_pressed=BUTTON_NONE;
@@ -199,13 +200,13 @@ int kbd_input(char* text, int buflen)
case MENU_LINE_NEWCHARS:
switch (button_pressed)
{
- case BUTTON_UP:
- case BUTTON_UP | BUTTON_REPEAT:
+ case BUTTON_PLAY:
+ case BUTTON_PLAY | BUTTON_REPEAT:
x=(x+1+linelen)%linelen;
button_pressed=BUTTON_NONE;
break;
- case BUTTON_DOWN:
- case BUTTON_DOWN | BUTTON_REPEAT:
+ case BUTTON_STOP:
+ case BUTTON_STOP | BUTTON_REPEAT:
x=(x-1+linelen)%linelen;
button_pressed=BUTTON_NONE;
break;
diff --git a/apps/playlist.c b/apps/playlist.c
index 5725c4be85..ecdb45c104 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -564,11 +564,7 @@ static int add_directory_to_playlist(struct playlist_info* playlist,
for (i=0; i<num_files; i++)
{
/* user abort */
-#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
- if (button_get(false) == BUTTON_STOP)
-#else
- if (button_get(false) == BUTTON_OFF)
-#endif
+ if (button_get(false) == SETTINGS_CANCEL)
{
result = -1;
break;
@@ -2016,11 +2012,7 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
while ((max = read_line(fd, temp_buf, sizeof(temp_buf))) > 0)
{
/* user abort */
-#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
- if (button_get(false) == BUTTON_STOP)
-#else
- if (button_get(false) == BUTTON_OFF)
-#endif
+ if (button_get(false) == SETTINGS_CANCEL)
break;
if (temp_buf[0] != '#' && temp_buf[0] != '\0')
@@ -2384,11 +2376,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
int seek;
/* user abort */
-#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
- if (button_get(false) == BUTTON_STOP)
-#else
- if (button_get(false) == BUTTON_OFF)
-#endif
+ if (button_get(false) == SETTINGS_CANCEL)
break;
control_file = playlist->indices[index] & PLAYLIST_INSERT_TYPE_MASK;
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index f093efd172..4268a28c86 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -130,7 +130,7 @@ static void update_display_line(int line, bool scroll);
static void scroll_display(int lines);
static void update_first_index(void);
static bool update_playlist(bool force);
-#ifdef BUTTON_ON
+#ifdef TREE_SHIFT
static int onplay_menu(int index);
#endif
static bool viewer_menu(void);
@@ -672,7 +672,7 @@ static bool update_playlist(bool force)
return true;
}
-#ifdef BUTTON_ON
+#ifdef TREE_SHIFT
/* Menu of playlist commands. Invoked via ON+PLAY on main viewer screen.
Returns -1 if USB attached, 0 if no playlist change, and 1 if playlist
changed. */
@@ -902,67 +902,37 @@ bool playlist_viewer_ex(char* filename)
switch (button)
{
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_OFF:
- case BUTTON_LEFT:
-#else
- case BUTTON_STOP:
-#endif
+ case TREE_EXIT:
exit = true;
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_UP:
- case BUTTON_UP | BUTTON_REPEAT:
-#else
- case BUTTON_LEFT:
- case BUTTON_LEFT | BUTTON_REPEAT:
-#endif
+ case TREE_PREV:
+ case TREE_PREV | BUTTON_REPEAT:
scroll_display(-1);
update = true;
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_DOWN:
- case BUTTON_DOWN | BUTTON_REPEAT:
-#else
- case BUTTON_RIGHT:
- case BUTTON_RIGHT | BUTTON_REPEAT:
-#endif
+ case TREE_NEXT:
+ case TREE_NEXT | BUTTON_REPEAT:
scroll_display(1);
update = true;
break;
-#ifdef BUTTON_ON
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_ON | BUTTON_UP:
- case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT:
-#else
- case BUTTON_ON | BUTTON_LEFT:
- case BUTTON_ON | BUTTON_LEFT | BUTTON_REPEAT:
-#endif
+ case TREE_SHIFT | TREE_PREV:
+ case TREE_SHIFT | TREE_PREV | BUTTON_REPEAT:
/* Pageup */
scroll_display(-viewer.num_display_lines);
update = true;
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_ON | BUTTON_DOWN:
- case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT:
-#else
- case BUTTON_ON | BUTTON_RIGHT:
- case BUTTON_ON | BUTTON_RIGHT | BUTTON_REPEAT:
-#endif
+ case TREE_SHIFT | TREE_NEXT:
+ case TREE_SHIFT | TREE_NEXT | BUTTON_REPEAT:
/* Pagedown */
scroll_display(viewer.num_display_lines);
update = true;
break;
-#endif /* BUTTON_ON */
-
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_RIGHT:
-#endif
- case BUTTON_PLAY:
+
+ case TREE_RUN:
if (viewer.move_track >= 0)
{
/* Move track */
@@ -1003,8 +973,7 @@ bool playlist_viewer_ex(char* filename)
update = true;
break;
-#ifdef BUTTON_ON
- case BUTTON_ON | BUTTON_PLAY:
+ case TREE_SHIFT | TREE_RUN:
{
/* ON+PLAY menu */
int ret;
@@ -1030,12 +999,8 @@ bool playlist_viewer_ex(char* filename)
update = true;
break;
}
-#endif /* BUTTON_ON */
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_F1:
-#else
- case BUTTON_MENU:
-#endif
+
+ case TREE_MENU:
if (viewer_menu())
{
ret = true;
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index f3ee8d82db..b501115618 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -71,6 +71,8 @@ static void calendar_init(struct today *today, struct shown *shown)
int w,h;
#ifdef HAVE_RTC
struct tm *tm;
+#else
+ (void)today;
#endif
rb->lcd_getstringsize("A",&w,&h);
if ( ((w * 14) > LCD_WIDTH) || ((h * 7) > LCD_HEIGHT) )
diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c
index 1c9ba7bed4..c1bd25e0aa 100644
--- a/apps/recorder/keyboard.c
+++ b/apps/recorder/keyboard.c
@@ -33,6 +33,7 @@
#define KEYBOARD_LINES 4
#define KEYBOARD_PAGES 3
+#ifdef HAVE_RECORDER_KEYPAD
static void kbd_setupkeys(const char* line[KEYBOARD_LINES], int page)
{
switch (page) {
@@ -58,6 +59,7 @@ static void kbd_setupkeys(const char* line[KEYBOARD_LINES], int page)
break;
}
}
+#endif
/* helper function to spell a char if voice UI is enabled */
void kbd_spellchar(char c)
@@ -75,6 +77,12 @@ void kbd_spellchar(char c)
int kbd_input(char* text, int buflen)
{
+#ifndef HAVE_RECORDER_KEYPAD
+ (void)text;
+ (void)buflen;
+ splash(HZ*2, true, "Keyboard not implemented yet");
+ return 0;
+#else
bool done = false;
int page = 0;
@@ -240,7 +248,6 @@ int kbd_input(char* text, int buflen)
kbd_spellchar(line[y][x]);
break;
-#if (BUTTON_UP != BUTTON_PLAY) /* FixMe, this is just to make the Ondio compile */
case BUTTON_UP:
case BUTTON_UP | BUTTON_REPEAT:
if (y)
@@ -249,7 +256,7 @@ int kbd_input(char* text, int buflen)
y = KEYBOARD_LINES - 1;
kbd_spellchar(line[y][x]);
break;
-#endif
+
case BUTTON_F3:
case BUTTON_F3 | BUTTON_REPEAT:
/* backspace */
@@ -326,5 +333,7 @@ int kbd_input(char* text, int buflen)
}
}
lcd_setfont(FONT_UI);
+
return 0;
+#endif /* ONDIO */
}
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 6b056dfe31..c163cc4552 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -167,6 +167,10 @@ static void remember_frequency(void)
bool radio_screen(void)
{
+#ifndef HAVE_RECORDER_KEYPAD
+ splash(HZ*2, true, "Radio not supported yet");
+ return false;
+#else
char buf[MAX_PATH];
bool done = false;
int button;
@@ -554,6 +558,7 @@ bool radio_screen(void)
}
#endif
return have_recorded;
+#endif /* ONDIO */
}
void radio_save_presets(void)
@@ -663,12 +668,14 @@ static bool radio_add_preset(void)
static int handle_radio_presets_menu_cb(int key, int m)
{
(void)m;
+#ifdef HAVE_RECORDER_KEYPAD
switch(key)
{
case BUTTON_F3:
key = BUTTON_LEFT; /* Fake an exit */
break;
}
+#endif
return key;
}
@@ -725,6 +732,11 @@ bool handle_radio_presets_menu(void)
int handle_radio_presets_cb(int key, int m)
{
+#ifdef HAVE_ONDIO_KEYPAD
+ (void)key;
+ (void)m;
+ return BUTTON_NONE;
+#else
bool ret;
switch(key)
@@ -750,6 +762,7 @@ int handle_radio_presets_cb(int key, int m)
break;
}
return key;
+#endif
}
bool handle_radio_presets(void)
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 392f20d9ed..2c39c367b8 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -166,6 +166,10 @@ int rec_create_directory(void)
bool recording_screen(void)
{
+#ifndef HAVE_RECORDING_KEYPAD
+ splash(HZ*2, true, "Recording not supported yet");
+ return false;
+#else
int button;
bool done = false;
char buf[32];
@@ -280,13 +284,12 @@ bool recording_screen(void)
}
break;
-#if (BUTTON_UP != BUTTON_PLAY) /* FixMe, this is just to make the Ondio compile */
case BUTTON_UP:
cursor--;
adjust_cursor();
update_countdown = 1; /* Update immediately */
break;
-#endif
+
case BUTTON_DOWN:
cursor++;
adjust_cursor();
@@ -619,8 +622,10 @@ bool recording_screen(void)
reload_directory();
return been_in_usb_mode;
+#endif
}
+#ifdef HAVE_RECORDER_KEYPAD
bool f2_rec_screen(void)
{
bool exit = false;
@@ -813,3 +818,4 @@ bool f3_rec_screen(void)
return false;
}
+#endif
diff --git a/apps/screens.c b/apps/screens.c
index ebb7981bd1..b0d95e0a7a 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -40,6 +40,7 @@
#include "action.h"
#include "talk.h"
#include "misc.h"
+#include "id3.h"
#ifdef HAVE_LCD_BITMAP
#define BMPHEIGHT_usb_logo 32
@@ -240,7 +241,7 @@ int charging_screen(void)
{
int button;
int rc = 0;
-#ifdef HAVE_RECORDER_KEYPAD
+#ifdef BUTTON_OFF
const int offbutton = BUTTON_OFF;
#else
const int offbutton = BUTTON_STOP;
@@ -263,7 +264,11 @@ int charging_screen(void)
status_draw(false);
charging_display_info(true);
button = button_get_w_tmo(HZ/3);
+#ifdef BUTTON_ON
if (button == (BUTTON_ON | BUTTON_REL))
+#else
+ if (button == (BUTTON_RIGHT | BUTTON_REL))
+#endif
rc = 3;
else if (button == offbutton)
rc = 2;
@@ -286,7 +291,7 @@ int charging_screen(void)
0 if no key was pressed
1 if a key was pressed (or if ON was held down long enough to repeat)
2 if USB was connected */
-int on_screen(void)
+int pitch_screen(void)
{
int button;
static int pitch = 1000;
@@ -1082,15 +1087,19 @@ bool set_time_screen(const char* string, struct tm *tm)
*valptr = min;
say_time(cursorpos, tm);
break;
+
+#ifdef BUTTON_ON
case BUTTON_ON:
+#elif defined BUTTON_MENU
+ case BUTTON_MENU:
+#endif
done = true;
break;
-#if (BUTTON_ON != BUTTON_OFF) /* FixMe, this is just to make the Ondio compile */
+
case BUTTON_OFF:
done = true;
tm->tm_year = -1;
break;
-#endif
default:
if (default_event_handler(button) == SYS_USB_CONNECTED)
@@ -1140,3 +1149,143 @@ bool shutdown_screen(void)
return false;
}
#endif
+
+bool browse_id3(void)
+{
+ struct mp3entry* id3 = mpeg_current_track();
+ int button;
+ int menu_pos = 0;
+ int menu_max = 8;
+ bool exit = false;
+ char scroll_text[MAX_PATH];
+
+ if (!(mpeg_status() & MPEG_STATUS_PLAY))
+ return false;
+
+ while (!exit)
+ {
+ lcd_clear_display();
+
+ switch (menu_pos)
+ {
+ case 0:
+ lcd_puts(0, 0, str(LANG_ID3_TITLE));
+ lcd_puts_scroll(0, 1, id3->title ? id3->title :
+ (char*)str(LANG_ID3_NO_TITLE));
+ break;
+
+ case 1:
+ lcd_puts(0, 0, str(LANG_ID3_ARTIST));
+ lcd_puts_scroll(0, 1,
+ id3->artist ? id3->artist :
+ (char*)str(LANG_ID3_NO_ARTIST));
+ break;
+
+ case 2:
+ lcd_puts(0, 0, str(LANG_ID3_ALBUM));
+ lcd_puts_scroll(0, 1, id3->album ? id3->album :
+ (char*)str(LANG_ID3_NO_ALBUM));
+ break;
+
+ case 3:
+ lcd_puts(0, 0, str(LANG_ID3_TRACKNUM));
+
+ if (id3->tracknum) {
+ snprintf(scroll_text,sizeof(scroll_text), "%d",
+ id3->tracknum);
+ lcd_puts_scroll(0, 1, scroll_text);
+ }
+ else
+ lcd_puts_scroll(0, 1, str(LANG_ID3_NO_TRACKNUM));
+ break;
+
+ case 4:
+ lcd_puts(0, 0, str(LANG_ID3_GENRE));
+ lcd_puts_scroll(0, 1,
+ id3_get_genre(id3) ?
+ id3_get_genre(id3) :
+ (char*)str(LANG_ID3_NO_INFO));
+ break;
+
+ case 5:
+ lcd_puts(0, 0, str(LANG_ID3_YEAR));
+ if (id3->year) {
+ snprintf(scroll_text,sizeof(scroll_text), "%d",
+ id3->year);
+ lcd_puts_scroll(0, 1, scroll_text);
+ }
+ else
+ lcd_puts_scroll(0, 1, str(LANG_ID3_NO_INFO));
+ break;
+
+ case 6:
+ lcd_puts(0, 0, str(LANG_ID3_LENGHT));
+ snprintf(scroll_text,sizeof(scroll_text), "%d:%02d",
+ id3->length / 60000,
+ id3->length % 60000 / 1000 );
+ lcd_puts(0, 1, scroll_text);
+ break;
+
+ case 7:
+ lcd_puts(0, 0, str(LANG_ID3_PLAYLIST));
+ snprintf(scroll_text,sizeof(scroll_text), "%d/%d",
+ playlist_get_display_index(), playlist_amount());
+ lcd_puts_scroll(0, 1, scroll_text);
+ break;
+
+
+ case 8:
+ lcd_puts(0, 0, str(LANG_ID3_BITRATE));
+ snprintf(scroll_text,sizeof(scroll_text), "%d kbps",
+ id3->bitrate);
+ lcd_puts(0, 1, scroll_text);
+ break;
+
+ case 9:
+ lcd_puts(0, 0, str(LANG_ID3_FRECUENCY));
+ snprintf(scroll_text,sizeof(scroll_text), "%d Hz",
+ id3->frequency);
+ lcd_puts(0, 1, scroll_text);
+ break;
+
+ case 10:
+ lcd_puts(0, 0, str(LANG_ID3_PATH));
+ lcd_puts_scroll(0, 1, id3->path);
+ break;
+ }
+ lcd_update();
+
+ button = button_get(true);
+
+ switch(button)
+ {
+ case SETTINGS_DEC:
+ if (menu_pos > 0)
+ menu_pos--;
+ else
+ menu_pos = menu_max;
+ break;
+
+ case SETTINGS_INC:
+ if (menu_pos < menu_max)
+ menu_pos++;
+ else
+ menu_pos = 0;
+ break;
+
+ case SETTINGS_CANCEL:
+ lcd_stop_scroll();
+ /* eat release event */
+ button_get(true);
+ exit = true;
+ break;
+
+ default:
+ if(default_event_handler(button) == SYS_USB_CONNECTED)
+ return true;
+ break;
+ }
+ }
+ return false;
+}
+
diff --git a/apps/screens.h b/apps/screens.h
index a119a9b853..9f15ff3228 100644
--- a/apps/screens.h
+++ b/apps/screens.h
@@ -27,7 +27,7 @@ int charging_screen(void);
void charging_splash(void);
#ifdef HAVE_RECORDER_KEYPAD
-int on_screen(void);
+int pitch_screen(void);
bool quick_screen(const int, const int);
#endif
@@ -42,6 +42,7 @@ bool set_time_screen(const char* string, struct tm *tm);
#endif
bool shutdown_screen(void);
+bool browse_id3(void);
#endif
diff --git a/apps/settings.c b/apps/settings.c
index ccb7703ab2..708a38b678 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -70,6 +70,7 @@ struct user_settings global_settings;
const char rec_base_directory[] = REC_BASE_DIR;
+
#define CONFIG_BLOCK_VERSION 16
#define CONFIG_BLOCK_SIZE 512
#define RTC_BLOCK_SIZE 44
@@ -1319,40 +1320,26 @@ bool set_int(const char* string,
button = button_get_w_tmo(HZ/2);
switch(button) {
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_UP:
- case BUTTON_UP | BUTTON_REPEAT:
-#else
- case BUTTON_RIGHT:
- case BUTTON_RIGHT | BUTTON_REPEAT:
-#endif
+ case SETTINGS_INC:
+ case SETTINGS_INC | BUTTON_REPEAT:
*variable += step;
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_DOWN:
- case BUTTON_DOWN | BUTTON_REPEAT:
-#else
- case BUTTON_LEFT:
- case BUTTON_LEFT | BUTTON_REPEAT:
-#endif
+ case SETTINGS_DEC:
+ case SETTINGS_DEC | BUTTON_REPEAT:
*variable -= step;
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_LEFT:
- case BUTTON_PLAY:
-#else
- case BUTTON_PLAY:
+ case SETTINGS_OK:
+#ifdef SETTINGS_OK2
+ case SETTINGS_OK2:
#endif
done = true;
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_OFF:
-#else
- case BUTTON_STOP:
- case BUTTON_MENU:
+ case SETTINGS_CANCEL:
+#ifdef SETTINGS_CANCEL2
+ case SETTINGS_CANCEL2:
#endif
if (*variable != org_value) {
*variable=org_value;
@@ -1431,13 +1418,8 @@ bool set_option(const char* string, void* variable, enum optiontype type,
button = button_get_w_tmo(HZ/2);
switch (button) {
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_UP:
- case BUTTON_UP | BUTTON_REPEAT:
-#else
- case BUTTON_RIGHT:
- case BUTTON_RIGHT | BUTTON_REPEAT:
-#endif
+ case SETTINGS_INC:
+ case SETTINGS_INC | BUTTON_REPEAT:
if (type == INT) {
if ( *intvar < (numoptions-1) )
(*intvar)++;
@@ -1448,13 +1430,8 @@ bool set_option(const char* string, void* variable, enum optiontype type,
*boolvar = !*boolvar;
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_DOWN:
- case BUTTON_DOWN | BUTTON_REPEAT:
-#else
- case BUTTON_LEFT:
- case BUTTON_LEFT | BUTTON_REPEAT:
-#endif
+ case SETTINGS_DEC:
+ case SETTINGS_DEC | BUTTON_REPEAT:
if (type == INT) {
if ( *intvar > 0 )
(*intvar)--;
@@ -1465,20 +1442,16 @@ bool set_option(const char* string, void* variable, enum optiontype type,
*boolvar = !*boolvar;
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_LEFT:
- case BUTTON_PLAY:
-#else
- case BUTTON_PLAY:
+ case SETTINGS_OK:
+#ifdef SETTINGS_OK2
+ case SETTINGS_OK2:
#endif
done = true;
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_OFF:
-#else
- case BUTTON_STOP:
- case BUTTON_MENU:
+ case SETTINGS_CANCEL:
+#ifdef SETTINGS_CANCEL2
+ case SETTINGS_CANCEL2:
#endif
if (((type==INT) && (*intvar != oldval)) ||
((type==BOOL) && (*boolvar != (bool)oldval))) {
diff --git a/apps/settings.h b/apps/settings.h
index 331e8dc904..0af466c5f7 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -33,6 +33,31 @@
#define MAX_FILENAME 20
+/* button definitions */
+#ifdef HAVE_RECORDER_KEYPAD
+#define SETTINGS_INC BUTTON_UP
+#define SETTINGS_DEC BUTTON_DOWN
+#define SETTINGS_OK (BUTTON_PLAY|BUTTON_REL)
+#define SETTINGS_OK2 (BUTTON_LEFT|BUTTON_REL)
+#define SETTINGS_CANCEL (BUTTON_OFF|BUTTON_REL)
+#define SETTINGS_CANCEL2 (BUTTON_F1|BUTTON_REL)
+
+#elif defined HAVE_PLAYER_KEYPAD
+#define SETTINGS_INC BUTTON_RIGHT
+#define SETTINGS_DEC BUTTON_LEFT
+#define SETTINGS_OK (BUTTON_PLAY|BUTTON_REL)
+#define SETTINGS_CANCEL (BUTTON_STOP|BUTTON_REL)
+#define SETTINGS_CANCEL2 (BUTTON_MENU|BUTTON_REL)
+
+#elif defined HAVE_ONDIO_KEYPAD
+#define SETTINGS_INC BUTTON_UP
+#define SETTINGS_DEC BUTTON_DOWN
+#define SETTINGS_OK (BUTTON_RIGHT|BUTTON_REL)
+#define SETTINGS_OK2 (BUTTON_LEFT|BUTTON_REL)
+#define SETTINGS_CANCEL (BUTTON_MENU|BUTTON_REL)
+
+#endif
+
/* data structures */
#define RESUME_OFF 0
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 4d2e2f9a44..9e95fe9d9a 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -1066,27 +1066,23 @@ static bool reset_settings(void)
while(!done) {
button = button_get(true);
switch(button) {
- case BUTTON_PLAY:
- settings_reset();
- settings_apply();
- lcd_clear_display();
- lcd_puts(0,1,str(LANG_RESET_DONE_CLEAR));
- done = true;
- break;
-
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_OFF:
-#else
- case BUTTON_STOP:
-#endif
- lcd_clear_display();
- lcd_puts(0,1,str(LANG_RESET_DONE_CANCEL));
- done = true;
- break;
-
- default:
- if(default_event_handler(button) == SYS_USB_CONNECTED)
- return true;
+ case SETTINGS_OK:
+ settings_reset();
+ settings_apply();
+ lcd_clear_display();
+ lcd_puts(0,1,str(LANG_RESET_DONE_CLEAR));
+ done = true;
+ break;
+
+ case SETTINGS_CANCEL:
+ lcd_clear_display();
+ lcd_puts(0,1,str(LANG_RESET_DONE_CANCEL));
+ done = true;
+ break;
+
+ default:
+ if(default_event_handler(button) == SYS_USB_CONNECTED)
+ return true;
}
}
diff --git a/apps/sleeptimer.c b/apps/sleeptimer.c
index 4fc7515ac0..55599bf7b3 100644
--- a/apps/sleeptimer.c
+++ b/apps/sleeptimer.c
@@ -69,68 +69,50 @@ bool sleeptimer_screen(void)
button = button_get_w_tmo(HZ);
switch(button)
{
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_LEFT:
- case BUTTON_PLAY:
-#else
- case BUTTON_PLAY:
-#endif
- done = true;
- break;
-
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_OFF:
-#else
- case BUTTON_STOP:
- case BUTTON_MENU:
-#endif
- if (changed) {
- lcd_stop_scroll();
- lcd_puts(0, 0, str(LANG_MENU_SETTING_CANCEL));
- lcd_update();
- set_sleep_timer(org_timer);
- sleep(HZ/2);
- }
- done = true;
- break;
-
-#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
- case BUTTON_RIGHT:
-#else
- case BUTTON_UP:
-#endif
- oldtime = (get_sleep_timer()+59) / 60;
- if(oldtime < THRESHOLD)
- amount = SMALL_STEP_SIZE;
- else
- amount = LARGE_STEP_SIZE;
+ case SETTINGS_OK:
+ done = true;
+ break;
+
+ case SETTINGS_CANCEL:
+ if (changed) {
+ lcd_stop_scroll();
+ lcd_puts(0, 0, str(LANG_MENU_SETTING_CANCEL));
+ lcd_update();
+ set_sleep_timer(org_timer);
+ sleep(HZ/2);
+ }
+ done = true;
+ break;
+
+ case SETTINGS_INC:
+ oldtime = (get_sleep_timer()+59) / 60;
+ if(oldtime < THRESHOLD)
+ amount = SMALL_STEP_SIZE;
+ else
+ amount = LARGE_STEP_SIZE;
- newtime = oldtime * 60 + amount;
- if(newtime > MAX_TIME)
- newtime = MAX_TIME;
+ newtime = oldtime * 60 + amount;
+ if(newtime > MAX_TIME)
+ newtime = MAX_TIME;
- changed = sayit = true;
- set_sleep_timer(newtime);
- break;
+ changed = sayit = true;
+ set_sleep_timer(newtime);
+ break;
-#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
- case BUTTON_LEFT:
-#else
- case BUTTON_DOWN:
-#endif
- oldtime = (get_sleep_timer()+59) / 60;
- if(oldtime <= THRESHOLD)
- amount = SMALL_STEP_SIZE;
- else
- amount = LARGE_STEP_SIZE;
+ case SETTINGS_DEC:
+ oldtime = (get_sleep_timer()+59) / 60;
+ if(oldtime <= THRESHOLD)
+ amount = SMALL_STEP_SIZE;
+ else
+ amount = LARGE_STEP_SIZE;
- newtime = oldtime*60 - amount;
- if(newtime < 0)
- newtime = 0;
+ newtime = oldtime*60 - amount;
+ if(newtime < 0)
+ newtime = 0;
- changed = sayit = true;
- set_sleep_timer(newtime);
- break;
+ changed = sayit = true;
+ set_sleep_timer(newtime);
+ break;
}
seconds = get_sleep_timer();
diff --git a/apps/sound_menu.c b/apps/sound_menu.c
index a037c94084..fdb2043171 100644
--- a/apps/sound_menu.c
+++ b/apps/sound_menu.c
@@ -103,38 +103,29 @@ bool set_sound(const char* string,
changed = false;
button = button_get_w_tmo(HZ/2);
switch( button ) {
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_UP:
- case BUTTON_UP | BUTTON_REPEAT:
-#else
- case BUTTON_RIGHT:
- case BUTTON_RIGHT | BUTTON_REPEAT:
-#endif
+ case SETTINGS_INC:
+ case SETTINGS_INC | BUTTON_REPEAT:
(*variable)+=steps;
if(*variable > max )
*variable = max;
changed = true;
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_DOWN:
- case BUTTON_DOWN | BUTTON_REPEAT:
-#else
- case BUTTON_LEFT:
- case BUTTON_LEFT | BUTTON_REPEAT:
-#endif
+ case SETTINGS_DEC:
+ case SETTINGS_DEC | BUTTON_REPEAT:
(*variable)-=steps;
if(*variable < min )
*variable = min;
changed = true;
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_LEFT:
-#else
- case BUTTON_STOP:
- case BUTTON_MENU:
- case BUTTON_PLAY:
+ case SETTINGS_OK:
+ case SETTINGS_CANCEL:
+#ifdef SETTINGS_OK2
+ case SETTINGS_OK2:
+#endif
+#ifdef SETTINGS_CANCEL2
+ case SETTINGS_CANCEL2:
#endif
done = true;
break;
diff --git a/apps/tree.c b/apps/tree.c
index 90d7010d03..a83346b8d2 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -194,20 +194,6 @@ void tree_get_filetypes(const struct filetype** types, int* count)
#endif /* HAVE_LCD_BITMAP */
-#ifdef HAVE_RECORDER_KEYPAD
-#define TREE_NEXT BUTTON_DOWN
-#define TREE_PREV BUTTON_UP
-#define TREE_EXIT BUTTON_LEFT
-#define TREE_ENTER BUTTON_RIGHT
-#define TREE_MENU BUTTON_F1
-#else
-#define TREE_NEXT BUTTON_RIGHT
-#define TREE_PREV BUTTON_LEFT
-#define TREE_EXIT BUTTON_STOP
-#define TREE_ENTER BUTTON_PLAY
-#define TREE_MENU BUTTON_MENU
-#endif /* HAVE_RECORDER_KEYPAD */
-
/* talkbox hovering delay, to avoid immediate disk activity */
#define HOVER_DELAY (HZ/2)
@@ -641,9 +627,9 @@ static bool ask_resume(bool ask_once)
while (!stop) {
button = button_get(true);
switch (button) {
- case BUTTON_PLAY:
-#ifdef BUTTON_RC_PLAY
- case BUTTON_RC_PLAY:
+ case TREE_RUN:
+#ifdef TREE_RC_RUN
+ case TREE_RC_RUN:
#endif
return true;
@@ -771,9 +757,10 @@ void set_current_file(char *path)
}
}
-#ifdef BUTTON_ON
-static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
- const int *dirfilter)
+#ifdef TREE_SHIFT
+static bool handle_shift(int *ds, int *dc, int numentries,
+ int tree_max_on_screen,
+ const int *dirfilter)
{
bool exit = false;
bool used = false;
@@ -790,12 +777,12 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
while (!exit) {
switch (button_get(true)) {
case TREE_PREV:
-#ifdef BUTTON_RC_LEFT
- case BUTTON_RC_LEFT:
+#ifdef TREE_RC_PREV
+ case TREE_RC_PREV:
#endif
-#ifdef BUTTON_ON
- case BUTTON_ON | TREE_PREV:
- case BUTTON_ON | TREE_PREV | BUTTON_REPEAT:
+#ifdef TREE_SHIFT
+ case TREE_SHIFT | TREE_PREV:
+ case TREE_SHIFT | TREE_PREV | BUTTON_REPEAT:
#endif
used = true;
if ( dirstart ) {
@@ -808,12 +795,12 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
break;
case TREE_NEXT:
-#ifdef BUTTON_RC_RIGHT
- case BUTTON_RC_RIGHT:
+#ifdef TREE_RC_NEXT
+ case TREE_RC_NEXT:
#endif
-#ifdef BUTTON_ON
- case BUTTON_ON | TREE_NEXT:
- case BUTTON_ON | TREE_NEXT | BUTTON_REPEAT:
+#ifdef TREE_SHIFT
+ case TREE_SHIFT | TREE_NEXT:
+ case TREE_SHIFT | TREE_NEXT | BUTTON_REPEAT:
#endif
used = true;
if ( dirstart < numentries - tree_max_on_screen ) {
@@ -827,12 +814,12 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
break;
- case BUTTON_PLAY:
-#ifdef BUTTON_RC_PLAY
- case BUTTON_RC_PLAY:
+ case TREE_RUN:
+#ifdef TREE_RC_PLAY
+ case TREE_RC_RUN:
#endif
-#ifdef BUTTON_ON
- case BUTTON_ON | BUTTON_PLAY:
+#ifdef TREE_SHIFT
+ case TREE_SHIFT | TREE_RUN:
#endif
{
int onplay_result;
@@ -866,10 +853,10 @@ static bool handle_on(int *ds, int *dc, int numentries, int tree_max_on_screen,
exit = true;
break;
}
-#ifdef BUTTON_ON
- case BUTTON_ON | BUTTON_REL:
- case BUTTON_ON | TREE_PREV | BUTTON_REL:
- case BUTTON_ON | TREE_NEXT | BUTTON_REL:
+#ifdef TREE_SHIFT
+ case TREE_SHIFT | BUTTON_REL:
+ case TREE_SHIFT | TREE_PREV | BUTTON_REL:
+ case TREE_SHIFT | TREE_NEXT | BUTTON_REL:
exit = true;
break;
#endif
@@ -969,7 +956,7 @@ static bool dirbrowse(const char *root, const int *dirfilter)
while (!stop) {
button = button_get(true);
switch (button) {
- case BUTTON_PLAY:
+ case TREE_RUN:
rolo_load("/" BOOTFILE);
stop = true;
break;
@@ -988,11 +975,9 @@ static bool dirbrowse(const char *root, const int *dirfilter)
switch ( button ) {
case TREE_EXIT:
-#ifdef BUTTON_RC_STOP
- case BUTTON_RC_STOP:
-#endif
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_LEFT | BUTTON_REPEAT:
+ case TREE_EXIT | BUTTON_REPEAT:
+#ifdef TREE_RC_EXIT
+ case TREE_RC_EXIT:
#endif
i=strlen(currdir);
if (i>1) {
@@ -1027,8 +1012,8 @@ static bool dirbrowse(const char *root, const int *dirfilter)
}
break;
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_OFF:
+#ifdef TREE_OFF
+ case TREE_OFF:
/* Stop the music if it is playing, else show the shutdown
screen */
if(mpeg_status())
@@ -1042,27 +1027,23 @@ static bool dirbrowse(const char *root, const int *dirfilter)
restore = true;
}
break;
-#endif
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_OFF | BUTTON_REPEAT:
-#else
- case BUTTON_STOP | BUTTON_REPEAT:
-#endif
+ case TREE_OFF | BUTTON_REPEAT:
if (charger_inserted()) {
charging_splash();
restore = true;
}
break;
+#endif
case TREE_ENTER:
case TREE_ENTER | BUTTON_REPEAT:
-#ifdef BUTTON_RC_PLAY
- case BUTTON_RC_PLAY:
+#if defined TREE_RC_ENTER && (TREE_RC_ENTER != TREE_RC_RUN)
+ case TREE_RC_ENTER:
#endif
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_PLAY:
- case BUTTON_PLAY | BUTTON_REPEAT:
+#if defined TREE_RUN && (TREE_RUN != TREE_ENTER)
+ case TREE_RUN:
+ case TREE_RUN | BUTTON_REPEAT:
#endif
if ( !numentries )
break;
@@ -1255,8 +1236,9 @@ static bool dirbrowse(const char *root, const int *dirfilter)
case TREE_PREV:
case TREE_PREV | BUTTON_REPEAT:
-#ifdef BUTTON_RC_LEFT
- case BUTTON_RC_LEFT:
+#ifdef TREE_RC_PREV
+ case TREE_RC_PREV:
+ case TREE_RC_PREV | BUTTON_REPEAT:
#endif
if(filesindir) {
if(dircursor) {
@@ -1295,8 +1277,9 @@ static bool dirbrowse(const char *root, const int *dirfilter)
case TREE_NEXT:
case TREE_NEXT | BUTTON_REPEAT:
-#ifdef BUTTON_RC_RIGHT
- case BUTTON_RC_RIGHT:
+#ifdef TREE_RC_NEXT
+ case TREE_RC_NEXT:
+ case TREE_RC_NEXT | BUTTON_REPEAT:
#endif
if(filesindir)
{
@@ -1340,11 +1323,11 @@ static bool dirbrowse(const char *root, const int *dirfilter)
}
break;
-#ifdef BUTTON_ON /* I bet the folks without ON-button want this to
+#ifdef TREE_SHIFT /* I bet the folks without ON-button want this to
work on a different button */
- case BUTTON_ON:
- if (handle_on(&dirstart, &dircursor, numentries,
- tree_max_on_screen, dirfilter))
+ case TREE_SHIFT:
+ if (handle_shift(&dirstart, &dircursor, numentries,
+ tree_max_on_screen, dirfilter))
{
/* start scroll */
restore = true;
diff --git a/apps/tree.h b/apps/tree.h
index dd08ca9392..eb4f0cd00c 100644
--- a/apps/tree.h
+++ b/apps/tree.h
@@ -21,6 +21,48 @@
#include <stdbool.h>
+#ifdef HAVE_RECORDER_KEYPAD
+#define TREE_NEXT BUTTON_DOWN
+#define TREE_PREV BUTTON_UP
+#define TREE_EXIT BUTTON_LEFT
+#define TREE_ENTER BUTTON_RIGHT
+#define TREE_RUN BUTTON_PLAY
+#define TREE_MENU (BUTTON_F1 | BUTTON_REL)
+#define TREE_SHIFT BUTTON_ON
+#define TREE_OFF BUTTON_OFF
+
+#define TREE_RC_NEXT BUTTON_RC_RIGHT
+#define TREE_RC_REV BUTTON_RC_LEFT
+#define TREE_RC_EXIT BUTTON_RC_STOP
+#define TREE_RC_ENTER BUTTON_RC_PLAY
+#define TREE_RC_RUN BUTTON_RC_PLAY
+
+#elif defined HAVE_PLAYER_KEYPAD
+#define TREE_NEXT BUTTON_RIGHT
+#define TREE_PREV BUTTON_LEFT
+#define TREE_EXIT BUTTON_STOP
+#define TREE_ENTER BUTTON_PLAY
+#define TREE_RUN BUTTON_PLAY
+#define TREE_MENU (BUTTON_MENU | BUTTON_REL)
+#define TREE_SHIFT BUTTON_ON
+
+#define TREE_RC_NEXT BUTTON_RC_RIGHT
+#define TREE_RC_REV BUTTON_RC_LEFT
+#define TREE_RC_EXIT BUTTON_RC_STOP
+#define TREE_RC_ENTER BUTTON_RC_PLAY
+#define TREE_RC_RUN BUTTON_RC_PLAY
+
+#elif defined HAVE_ONDIO_KEYPAD
+#define TREE_NEXT BUTTON_DOWN
+#define TREE_PREV BUTTON_UP
+#define TREE_EXIT BUTTON_LEFT
+#define TREE_ENTER BUTTON_RIGHT
+#define TREE_RUN BUTTON_RIGHT
+#define TREE_MENU (BUTTON_MENU | BUTTON_REPEAT)
+#define TREE_SHIFT BUTTON_MENU
+
+#endif
+
struct entry {
short attr; /* FAT attributes + file type flags */
unsigned long time_write; /* Last write time */
diff --git a/apps/wps.c b/apps/wps.c
index 92b4e008b8..49d7d3db36 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -61,63 +61,86 @@ static struct mp3entry* id3 = NULL;
static struct mp3entry* nid3 = NULL;
static char current_track_path[MAX_PATH+1];
-#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD) || defined(HAVE_ONDIO_KEYPAD)
-void player_change_volume(int button)
+/* button definitions */
+#ifdef HAVE_RECORDER_KEYPAD
+#define WPS_NEXT (BUTTON_RIGHT | BUTTON_REL)
+#define WPS_PREV (BUTTON_LEFT | BUTTON_REL)
+#define WPS_FFWD (BUTTON_RIGHT | BUTTON_REPEAT)
+#define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT)
+#define WPS_INCVOL BUTTON_UP
+#define WPS_DECVOL BUTTON_DOWN
+#define WPS_PAUSE BUTTON_PLAY
+#define WPS_MENU (BUTTON_F1 | BUTTON_REL)
+#define WPS_MENU_PRE BUTTON_F1
+#define WPS_BROWSE (BUTTON_ON | BUTTON_REL)
+#define WPS_EXIT BUTTON_OFF
+#define WPS_KEYLOCK (BUTTON_F1 | BUTTON_DOWN)
+#define WPS_ID3 (BUTTON_F1 | BUTTON_ON)
+
+#define WPS_RC_NEXT BUTTON_RC_RIGHT
+#define WPS_RC_PREV BUTTON_RC_LEFT
+#define WPS_RC_PAUSE BUTTON_RC_PLAY
+#define WPS_RC_INCVOL BUTTON_RC_VOL_UP
+#define WPS_RC_DECVOL BUTTON_RC_VOL_DOWN
+#define WPS_RC_EXIT BUTTON_RC_STOP
+
+#elif defined HAVE_PLAYER_KEYPAD
+#define WPS_NEXT BUTTON_RIGHT
+#define WPS_PREV BUTTON_LEFT
+#define WPS_FFWD (BUTTON_RIGHT | BUTTON_REPEAT)
+#define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT)
+#define WPS_INCVOL (BUTTON_MENU | BUTTON_RIGHT)
+#define WPS_DECVOL (BUTTON_MENU | BUTTON_LEFT)
+#define WPS_PAUSE BUTTON_PLAY
+#define WPS_MENU (BUTTON_MENU | BUTTON_REL)
+#define WPS_MENU_PRE BUTTON_MENU
+#define WPS_BROWSE (BUTTON_ON | BUTTON_REL)
+#define WPS_EXIT BUTTON_STOP
+#define WPS_KEYLOCK (BUTTON_MENU | BUTTON_STOP)
+#define WPS_ID3 (BUTTON_MENU | BUTTON_ON)
+
+#define WPS_RC_NEXT BUTTON_RC_RIGHT
+#define WPS_RC_PREV BUTTON_RC_LEFT
+#define WPS_RC_PAUSE BUTTON_RC_PLAY
+#define WPS_RC_INCVOL BUTTON_RC_VOL_UP
+#define WPS_RC_DECVOL BUTTON_RC_VOL_DOWN
+#define WPS_RC_EXIT BUTTON_RC_STOP
+
+#elif defined HAVE_ONDIO_KEYPAD
+#define WPS_NEXT (BUTTON_RIGHT | BUTTON_REL)
+#define WPS_PREV (BUTTON_LEFT | BUTTON_REL)
+#define WPS_FFWD (BUTTON_RIGHT | BUTTON_REPEAT)
+#define WPS_REW (BUTTON_LEFT | BUTTON_REPEAT)
+#define WPS_INCVOL BUTTON_UP
+#define WPS_DECVOL BUTTON_DOWN
+#define WPS_PAUSE BUTTON_OFF
+#define WPS_MENU (BUTTON_MENU | BUTTON_REPEAT)
+#define WPS_BROWSE (BUTTON_MENU | BUTTON_REL)
+#define WPS_KEYLOCK (BUTTON_MENU | BUTTON_DOWN)
+
+#endif
+
+/* set volume
+ return true if screen restore is needed
+ return false otherwise
+*/
+static bool setvol(void)
{
- bool exit = false;
- char buffer[32];
-
- lcd_stop_scroll();
- while (!exit)
- {
- switch (button)
- {
- case BUTTON_MENU | BUTTON_RIGHT:
- case BUTTON_MENU | BUTTON_RIGHT | BUTTON_REPEAT:
- global_settings.volume++;
- if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME))
- global_settings.volume = mpeg_sound_max(SOUND_VOLUME);
- mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
- wps_refresh(id3, nid3, 0, WPS_REFRESH_NON_STATIC);
- settings_save();
- break;
-
- case BUTTON_MENU | BUTTON_LEFT:
- case BUTTON_MENU | BUTTON_LEFT | BUTTON_REPEAT:
- global_settings.volume--;
- if(global_settings.volume < mpeg_sound_min(SOUND_VOLUME))
- global_settings.volume = mpeg_sound_min(SOUND_VOLUME);
- mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
- wps_refresh(id3, nid3, 0, WPS_REFRESH_NON_STATIC);
- settings_save();
- break;
-
- case BUTTON_MENU | BUTTON_REL:
- case BUTTON_MENU | BUTTON_LEFT | BUTTON_REL:
- case BUTTON_MENU | BUTTON_RIGHT | BUTTON_REL:
- exit = true;
- break;
- }
-
- snprintf(buffer,sizeof(buffer),"Vol: %d %% ",
- mpeg_val2phys(SOUND_VOLUME, global_settings.volume));
-
+ if (global_settings.volume < mpeg_sound_min(SOUND_VOLUME))
+ global_settings.volume = mpeg_sound_min(SOUND_VOLUME);
+ mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
+ status_draw(false);
+ wps_refresh(id3, nid3, 0, WPS_REFRESH_NON_STATIC);
+ settings_save();
#ifdef HAVE_LCD_CHARCELLS
- lcd_puts(0, 0, buffer);
-#else
- lcd_puts(2, 3, buffer);
- lcd_update();
+ splash(0, false, "Vol: %d %% ",
+ mpeg_val2phys(SOUND_VOLUME, global_settings.volume));
+ return true;
#endif
- status_draw(false);
-
- if (!exit)
- button = button_get(true);
- }
- wps_refresh(id3, nid3, 0, WPS_REFRESH_ALL);
+ return false;
}
-#endif
-void display_keylock_text(bool locked)
+static void display_keylock_text(bool locked)
{
char* s;
lcd_stop_scroll();
@@ -135,176 +158,6 @@ void display_keylock_text(bool locked)
splash(HZ, true, s);
}
-void display_mute_text(bool muted)
-{
- char *s;
- lcd_stop_scroll();
-#ifdef HAVE_LCD_CHARCELLS
- if (muted)
- s = str(LANG_MUTE_ON_PLAYER);
- else
- s = str(LANG_MUTE_OFF_PLAYER);
-#else
- if (muted)
- s = str(LANG_MUTE_ON_RECORDER);
- else
- s = str(LANG_MUTE_OFF_RECORDER);
-#endif
- splash(HZ, true, s);
-}
-
-bool browse_id3(void)
-{
- int button;
- int menu_pos = 0;
- int menu_max = 8;
- bool exit = false;
- char scroll_text[MAX_PATH];
-
- if (!(mpeg_status() & MPEG_STATUS_PLAY))
- return false;
-
- while (!exit)
- {
- lcd_clear_display();
-
- switch (menu_pos)
- {
- case 0:
- lcd_puts(0, 0, str(LANG_ID3_TITLE));
- lcd_puts_scroll(0, 1, id3->title ? id3->title :
- (char*)str(LANG_ID3_NO_TITLE));
- break;
-
- case 1:
- lcd_puts(0, 0, str(LANG_ID3_ARTIST));
- lcd_puts_scroll(0, 1,
- id3->artist ? id3->artist :
- (char*)str(LANG_ID3_NO_ARTIST));
- break;
-
- case 2:
- lcd_puts(0, 0, str(LANG_ID3_ALBUM));
- lcd_puts_scroll(0, 1, id3->album ? id3->album :
- (char*)str(LANG_ID3_NO_ALBUM));
- break;
-
- case 3:
- lcd_puts(0, 0, str(LANG_ID3_TRACKNUM));
-
- if (id3->tracknum) {
- snprintf(scroll_text,sizeof(scroll_text), "%d",
- id3->tracknum);
- lcd_puts_scroll(0, 1, scroll_text);
- }
- else
- lcd_puts_scroll(0, 1, str(LANG_ID3_NO_TRACKNUM));
- break;
-
- case 4:
- lcd_puts(0, 0, str(LANG_ID3_GENRE));
- lcd_puts_scroll(0, 1,
- id3_get_genre(id3) ?
- id3_get_genre(id3) :
- (char*)str(LANG_ID3_NO_INFO));
- break;
-
- case 5:
- lcd_puts(0, 0, str(LANG_ID3_YEAR));
- if (id3->year) {
- snprintf(scroll_text,sizeof(scroll_text), "%d",
- id3->year);
- lcd_puts_scroll(0, 1, scroll_text);
- }
- else
- lcd_puts_scroll(0, 1, str(LANG_ID3_NO_INFO));
- break;
-
- case 6:
- lcd_puts(0, 0, str(LANG_ID3_LENGHT));
- snprintf(scroll_text,sizeof(scroll_text), "%d:%02d",
- id3->length / 60000,
- id3->length % 60000 / 1000 );
- lcd_puts(0, 1, scroll_text);
- break;
-
- case 7:
- lcd_puts(0, 0, str(LANG_ID3_PLAYLIST));
- snprintf(scroll_text,sizeof(scroll_text), "%d/%d",
- playlist_get_display_index(), playlist_amount());
- lcd_puts_scroll(0, 1, scroll_text);
- break;
-
-
- case 8:
- lcd_puts(0, 0, str(LANG_ID3_BITRATE));
- snprintf(scroll_text,sizeof(scroll_text), "%d kbps",
- id3->bitrate);
- lcd_puts(0, 1, scroll_text);
- break;
-
- case 9:
- lcd_puts(0, 0, str(LANG_ID3_FRECUENCY));
- snprintf(scroll_text,sizeof(scroll_text), "%d Hz",
- id3->frequency);
- lcd_puts(0, 1, scroll_text);
- break;
-
- case 10:
- lcd_puts(0, 0, str(LANG_ID3_PATH));
- lcd_puts_scroll(0, 1, id3->path);
- break;
- }
- lcd_update();
-
- button = button_get(true);
-
- switch(button)
- {
- case BUTTON_LEFT:
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_UP:
-#endif
- if (menu_pos > 0)
- menu_pos--;
- else
- menu_pos = menu_max;
- break;
-
- case BUTTON_RIGHT:
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_DOWN:
-#endif
- if (menu_pos < menu_max)
- menu_pos++;
- else
- menu_pos = 0;
- break;
-
- case BUTTON_REPEAT:
- break;
-
-#ifdef BUTTON_STOP
- case BUTTON_STOP:
-#else
- case BUTTON_OFF:
-#endif
- case BUTTON_PLAY:
- lcd_stop_scroll();
- /* eat release event */
- button_get(true);
- exit = true;
- break;
-
- default:
- if(default_event_handler(button) == SYS_USB_CONNECTED)
- return true;
- break;
- }
- }
- return false;
-}
-
static bool ffwd_rew(int button)
{
static const int ff_rew_steps[] = {
@@ -324,8 +177,8 @@ static bool ffwd_rew(int button)
while (!exit) {
switch ( button ) {
- case BUTTON_LEFT | BUTTON_REPEAT:
- case BUTTON_RIGHT | BUTTON_REPEAT:
+ case WPS_FFWD:
+ case WPS_REW:
if (ff_rewind)
{
if (direction == 1)
@@ -367,7 +220,7 @@ static bool ffwd_rew(int button)
#ifdef HAVE_PLAYER_KEYPAD
lcd_stop_scroll();
#endif
- direction = (button & BUTTON_RIGHT) ? 1 : -1;
+ direction = (button & WPS_FFWD) ? 1 : -1;
if (direction > 0)
status_set_ffmode(STATUS_FASTFORWARD);
@@ -405,8 +258,8 @@ static bool ffwd_rew(int button)
break;
- case BUTTON_LEFT | BUTTON_REL:
- case BUTTON_RIGHT | BUTTON_REL:
+ case WPS_PREV:
+ case WPS_NEXT:
mpeg_ff_rewind(id3->elapsed+ff_rewind_count);
ff_rewind_count = 0;
ff_rewind = false;
@@ -483,133 +336,6 @@ static bool update(void)
return retcode;
}
-static bool menu(void)
-{
- static bool muted = false;
- bool exit = false;
- int last_button = 0;
-
-#ifdef HAVE_LCD_CHARCELLS
- status_set_param(true);
- status_draw(false);
-#endif
-
- while (!exit) {
- int button = button_get(true);
-
- /* these are never locked */
- switch (button)
- {
- /* key lock */
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_F1 | BUTTON_DOWN:
-#else
- case BUTTON_MENU | BUTTON_STOP:
-#endif
- keys_locked = !keys_locked;
- display_keylock_text(keys_locked);
- exit = true;
- while (button_get(false)); /* clear button queue */
- break;
-
- default:
- if(default_event_handler(button) == SYS_USB_CONNECTED) {
- keys_locked = false;
- return true;
- }
- break;
- }
-
- if (keys_locked) {
- display_keylock_text(true);
- break;
- }
-
- switch ( button ) {
- /* go into menu */
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_F1 | BUTTON_REL:
-#else
- case BUTTON_MENU | BUTTON_REL:
-#endif
- exit = true;
- if ( !last_button && !keys_locked ) {
- lcd_stop_scroll();
-
- if (main_menu())
- return true;
-#ifdef HAVE_LCD_BITMAP
- if(global_settings.statusbar)
- lcd_setmargins(0, STATUSBAR_HEIGHT);
- else
- lcd_setmargins(0, 0);
-#endif
- }
- break;
-
- /* mute */
-#ifdef BUTTON_MENU
- case BUTTON_MENU | BUTTON_PLAY:
-#else
- case BUTTON_F1 | BUTTON_PLAY:
-#endif
- if ( muted )
- mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
- else
- mpeg_sound_set(SOUND_VOLUME, 0);
- muted = !muted;
-#ifdef HAVE_LCD_CHARCELLS
- status_set_param(false);
-#endif
- display_mute_text(muted);
- break;
-
-#ifdef BUTTON_MENU
- /* change volume */
- case BUTTON_MENU | BUTTON_LEFT:
- case BUTTON_MENU | BUTTON_LEFT | BUTTON_REPEAT:
- case BUTTON_MENU | BUTTON_RIGHT:
- case BUTTON_MENU | BUTTON_RIGHT | BUTTON_REPEAT:
- player_change_volume(button);
- exit = true;
- break;
-
- /* show id3 tags */
-#ifdef BUTTON_ON
- case BUTTON_MENU | BUTTON_ON:
-#ifdef HAVE_LCD_CHARCELLS
- status_set_param(true);
- status_set_audio(true);
-#endif
-#endif
-#else
- case BUTTON_F1 | BUTTON_ON:
-#endif
- lcd_clear_display();
- lcd_puts(0, 0, str(LANG_ID3_INFO));
- lcd_puts(0, 1, str(LANG_ID3_SCREEN));
- lcd_update();
- sleep(HZ);
-
- if(browse_id3())
- return true;
-#ifdef HAVE_PLAYER_KEYPAD
- status_set_param(false);
- status_set_audio(true);
-#endif
- exit = true;
- break;
- }
- last_button = button;
- }
-
-#ifdef HAVE_LCD_CHARCELLS
- status_set_param(false);
-#endif
-
- return false;
-}
-
static void fade(bool fade_in)
{
if (fade_in) {
@@ -647,12 +373,20 @@ static void fade(bool fade_in)
}
+static void waitfor_nokey(void)
+{
+ /* wait until all keys are released */
+ while (button_get(false) != BUTTON_NONE)
+ yield();
+}
+
/* demonstrates showing different formats from playtune */
int wps_show(void)
{
int button = 0, lastbutton = 0;
bool ignore_keyup = true;
bool restore = false;
+ long restoretimer = 0; /* timer to delay screen redraw temporarily */
bool exit = false;
bool update_track = false;
@@ -763,26 +497,22 @@ int wps_show(void)
if (button >= 0 && button & BUTTON_REL )
continue;
}
-
+
+#ifdef WPS_KEYLOCK
/* ignore non-remote buttons when keys are locked */
if (keys_locked &&
! ((button < 0) ||
-#ifdef HAVE_RECORDER_KEYPAD
- (button & BUTTON_F1) ||
-#else
- (button & BUTTON_MENU) ||
-#endif
- (button == BUTTON_NONE)
-#ifdef BUTTON_REMOTE
- || (button & BUTTON_REMOTE)
-#endif
- ))
+ (button == BUTTON_NONE) ||
+ ((button & WPS_KEYLOCK) == WPS_KEYLOCK) ||
+ (button & BUTTON_REMOTE)
+ ))
{
- while (button_get(false)); /* clear button queue */
- display_keylock_text(true);
+ if (!(button & BUTTON_REL))
+ display_keylock_text(true);
restore = true;
- continue;
+ button = BUTTON_NONE;
}
+#endif
/* Exit if mpeg has stopped playing. This can happen if using the
sleep timer with the charger plugged or if starting a recording
@@ -792,49 +522,25 @@ int wps_show(void)
switch(button)
{
-#ifdef BUTTON_ON
- case BUTTON_ON:
-#ifdef HAVE_RECORDER_KEYPAD
- switch (on_screen()) {
- case 2:
- /* usb connected? */
- return SYS_USB_CONNECTED;
-
- case 1:
- /* was on_screen used? */
- restore = true;
-
- /* pause may have been turned off by pitch screen */
- if (paused && !(mpeg_status() & MPEG_STATUS_PAUSE)) {
- paused = false;
- }
- break;
-
- case 0:
- /* otherwise, exit to browser */
-#else
+ case WPS_BROWSE:
#ifdef HAVE_LCD_CHARCELLS
- status_set_record(false);
- status_set_audio(false);
-#endif
+ status_set_record(false);
+ status_set_audio(false);
#endif
- lcd_stop_scroll();
+ lcd_stop_scroll();
- /* set dir browser to current playing song */
- if (global_settings.browse_current &&
- current_track_path[0] != '\0')
- set_current_file(current_track_path);
-
- return 0;
-#ifdef HAVE_RECORDER_KEYPAD
- }
+ /* set dir browser to current playing song */
+ if (global_settings.browse_current &&
+ current_track_path[0] != '\0')
+ set_current_file(current_track_path);
+
+ return 0;
break;
-#endif
-#endif /* BUTTON_ON */
+
/* play/pause */
- case BUTTON_PLAY:
-#ifdef BUTTON_RC_PLAY
- case BUTTON_RC_PLAY:
+ case WPS_PAUSE:
+#ifdef WPS_RC_PAUSE
+ case WPS_RC_PAUSE:
#endif
if ( paused )
{
@@ -861,53 +567,50 @@ int wps_show(void)
break;
/* volume up */
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_UP:
- case BUTTON_UP | BUTTON_REPEAT:
-#endif
-#ifdef BUTTON_RC_VOL_UP
- case BUTTON_RC_VOL_UP:
+ case WPS_INCVOL:
+ case WPS_INCVOL | BUTTON_REPEAT:
+#ifdef WPS_RC_INCVOL
+ case WPS_RC_INCVOL:
#endif
global_settings.volume++;
- if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME))
- global_settings.volume = mpeg_sound_max(SOUND_VOLUME);
- mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
- status_draw(false);
- settings_save();
+ if (setvol()) {
+ restore = true;
+ restoretimer = current_tick + HZ;
+ }
break;
/* volume down */
-#ifdef HAVE_RECORDER_KEYPAD
- case BUTTON_DOWN:
- case BUTTON_DOWN | BUTTON_REPEAT:
-#endif
-#ifdef BUTTON_RC_VOL_DOWN
- case BUTTON_RC_VOL_DOWN:
+ case WPS_DECVOL:
+ case WPS_DECVOL | BUTTON_REPEAT:
+#ifdef WPS_RC_DECVOL
+ case WPS_RC_DECVOL:
#endif
global_settings.volume--;
- if(global_settings.volume < mpeg_sound_min(SOUND_VOLUME))
- global_settings.volume = mpeg_sound_min(SOUND_VOLUME);
- mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
- status_draw(false);
- settings_save();
+ if (setvol()) {
+ restore = true;
+ restoretimer = current_tick + HZ;
+ }
break;
/* fast forward / rewind */
- case BUTTON_LEFT | BUTTON_REPEAT:
- case BUTTON_RIGHT | BUTTON_REPEAT:
+ case WPS_FFWD:
+ case WPS_REW:
+#ifdef WPS_RC_FFWD
+ case WPS_RC_FFWD:
+ case WPS_RC_RWD:
+#endif
ffwd_rew(button);
break;
/* prev / restart */
-#ifdef BUTTON_RC_LEFT
- case BUTTON_RC_LEFT:
+#ifdef WPS_RC_PREV
+ case WPS_RC_PREV:
#endif
- case BUTTON_LEFT | BUTTON_REL:
-#ifdef HAVE_RECORDER_KEYPAD
- if ((button == (BUTTON_LEFT | BUTTON_REL)) &&
- (lastbutton != BUTTON_LEFT ))
+ case WPS_PREV:
+ /* ignore release event after rewind */
+ if (lastbutton & BUTTON_REPEAT)
break;
-#endif
+
if (!id3 || (id3->elapsed < 3*1000)) {
mpeg_prev();
}
@@ -923,29 +626,43 @@ int wps_show(void)
break;
/* next */
-#ifdef BUTTON_RC_RIGHT
- case BUTTON_RC_RIGHT:
+#ifdef WPS_RC_NEXT
+ case WPS_RC_NEXT:
#endif
- case BUTTON_RIGHT | BUTTON_REL:
+ case WPS_NEXT:
#ifdef HAVE_RECORDER_KEYPAD
- if ((button == (BUTTON_RIGHT | BUTTON_REL)) &&
- (lastbutton != BUTTON_RIGHT))
- break;
+ if (lastbutton & BUTTON_REPEAT)
+ break;
#endif
mpeg_next();
break;
/* menu key functions */
-#ifdef BUTTON_MENU
- case BUTTON_MENU:
-#else
- case BUTTON_F1:
+ case WPS_MENU:
+#ifdef WPS_MENU_PRE
+ if (lastbutton != WPS_MENU_PRE)
+ break;
#endif
- if (menu())
- return SYS_USB_CONNECTED;
+ lcd_stop_scroll();
- update_track = true;
+ if (main_menu())
+ return true;
+#ifdef HAVE_LCD_BITMAP
+ if (global_settings.statusbar)
+ lcd_setmargins(0, STATUSBAR_HEIGHT);
+ else
+ lcd_setmargins(0, 0);
+#endif
+ restore = true;
+ break;
+
+ /* key lock */
+ case WPS_KEYLOCK:
+ case WPS_KEYLOCK | BUTTON_REPEAT:
+ keys_locked = !keys_locked;
+ display_keylock_text(keys_locked);
restore = true;
+ waitfor_nokey();
break;
#ifdef HAVE_RECORDER_KEYPAD
@@ -962,22 +679,32 @@ int wps_show(void)
return SYS_USB_CONNECTED;
restore = true;
break;
+
+ /* pitch screen */
+ case BUTTON_ON | BUTTON_REPEAT:
+ if (2 == pitch_screen())
+ return SYS_USB_CONNECTED;
+ restore = true;
+ break;
#endif
/* stop and exit wps */
-#ifdef BUTTON_OFF
- case BUTTON_OFF | BUTTON_REL:
-#else
- case BUTTON_STOP | BUTTON_REL:
- if ( lastbutton != BUTTON_STOP )
- break;
-#endif
-#ifdef BUTTON_RC_STOP
- case BUTTON_RC_STOP:
+#ifdef WPS_EXIT
+ case WPS_EXIT:
+#ifdef WPS_RC_EXIT
+ case WPS_RC_EXIT:
#endif
exit = true;
break;
+#endif
+#ifdef WPS_ID3
+ case WPS_ID3:
+ browse_id3();
+ restore = true;
+ break;
+#endif
+
case BUTTON_NONE: /* Timeout */
update_track = true;
break;
@@ -1029,8 +756,12 @@ int wps_show(void)
if ( button )
ata_spin();
- if (restore) {
+ if (restore &&
+ ((restoretimer == 0) ||
+ (restoretimer < current_tick)))
+ {
restore = false;
+ restoretimer = 0;
if (wps_display(id3, nid3))
{
/* set dir browser to current playing song */
@@ -1044,7 +775,7 @@ int wps_show(void)
if (id3)
wps_refresh(id3, nid3, 0, WPS_REFRESH_NON_STATIC);
}
- if(button != BUTTON_NONE)
+ if (button != BUTTON_NONE)
lastbutton = button;
}
return 0; /* unreachable - just to reduce compiler warnings */
diff --git a/apps/wps.h b/apps/wps.h
index 3680515951..c6cec3fdce 100644
--- a/apps/wps.h
+++ b/apps/wps.h
@@ -27,7 +27,6 @@ extern bool wps_time_countup;
int wps_show(void);
bool refresh_wps(bool refresh_scroll);
void handle_usb(void);
-bool browse_id3(void);
#ifdef HAVE_RECORDER_KEYPAD
bool f2_screen(void);