From 87afd0b0507a59e0731a79662ab820f89bf5b585 Mon Sep 17 00:00:00 2001 From: Zakk Roberts Date: Tue, 21 Mar 2006 07:59:23 +0000 Subject: Reworked pitch screen for easier adjustment and better looks. Added some button definitions for iPods - coming soon to a Sound Settings menu near you... git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9146 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/gwps.c | 54 ++++++++-------- apps/lang/english.lang | 5 ++ apps/screens.c | 169 +++++++++++++++++++++---------------------------- apps/screens.h | 32 ++++++++-- 4 files changed, 128 insertions(+), 132 deletions(-) diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 2ec1c4dcc7..5ffdf4e33f 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c @@ -134,7 +134,7 @@ long gui_wps_show(void) while ( 1 ) { bool audio_paused = (audio_status() & AUDIO_STATUS_PAUSE)?true:false; - + /* did someone else (i.e power thread) change audio pause mode? */ if (wps_state.paused != audio_paused) { wps_state.paused = audio_paused; @@ -160,7 +160,7 @@ long gui_wps_show(void) if(gui_wps[i].data->peak_meter_enabled) pm = true; } - + if (pm) { long next_refresh = current_tick; long next_big_refresh = current_tick + HZ / 5; @@ -171,7 +171,7 @@ long gui_wps_show(void) break; } peak_meter_peek(); - sleep(0); /* Sleep until end of current tick. */ + sleep(0); /* Sleep until end of current tick. */ if (TIME_AFTER(current_tick, next_refresh)) { FOR_NB_SCREENS(i) @@ -185,7 +185,7 @@ long gui_wps_show(void) } } - + /* The peak meter is disabled -> no additional screen updates needed */ else { @@ -408,7 +408,7 @@ long gui_wps_show(void) if ((button == WPS_RC_PREV) && (lastbutton != WPS_RC_PREV_PRE)) break; #endif -#endif +#endif left_lastclick = current_tick; update_track = true; @@ -487,7 +487,7 @@ long gui_wps_show(void) case WPS_NEXT: #ifdef WPS_NEXT_PRE if (lastbutton != WPS_NEXT_PRE) - break; + break; #endif #ifdef WPS_RC_NEXT case WPS_RC_NEXT: @@ -607,15 +607,11 @@ long gui_wps_show(void) /* pitch screen */ #if CONFIG_KEYPAD == RECORDER_PAD || CONFIG_KEYPAD == IRIVER_H100_PAD \ || CONFIG_KEYPAD == IRIVER_H300_PAD - case BUTTON_ON | BUTTON_UP: - case BUTTON_ON | BUTTON_DOWN: -#if CONFIG_KEYPAD == IRIVER_H100_PAD || CONFIG_KEYPAD == IRIVER_H300_PAD - case BUTTON_ON | BUTTON_OFF: -#endif + case BUTTON_ON | BUTTON_REPEAT: #ifdef HAVE_LCD_COLOR lcd_set_backdrop(gui_wps[SCREEN_MAIN].data->old_backdrop); #endif - if (2 == pitch_screen()) + if (1 == pitch_screen()) return SYS_USB_CONNECTED; #ifdef HAVE_LCD_COLOR if (gui_wps[SCREEN_MAIN].data->has_backdrop) @@ -653,8 +649,8 @@ long gui_wps_show(void) ab_set_A_marker(wps_state.id3->elapsed); break; #endif - - + + #ifdef WPS_AB_SET_A_MARKER /* set A marker for A-B repeat */ case WPS_AB_SET_A_MARKER: @@ -717,7 +713,7 @@ long gui_wps_show(void) restore = true; break; #endif - + case BUTTON_NONE: /* Timeout */ update_track = true; break; @@ -726,7 +722,7 @@ long gui_wps_show(void) bookmark_autobookmark(); default_event_handler(SYS_POWEROFF); break; - + default: if(default_event_handler(button) == SYS_USB_CONNECTED) return SYS_USB_CONNECTED; @@ -748,7 +744,7 @@ long gui_wps_show(void) if (global_settings.browse_current && wps_state.current_track_path[0] != '\0') set_current_file(wps_state.current_track_path); - + return 0; } update_track = false; @@ -761,7 +757,7 @@ long gui_wps_show(void) #endif if (global_settings.fade_on_stop) fade(0); - + FOR_NB_SCREENS(i) gui_wps[i].display->stop_scroll(); bookmark_autobookmark(); @@ -778,10 +774,10 @@ long gui_wps_show(void) if (global_settings.browse_current && wps_state.current_track_path[0] != '\0') set_current_file(wps_state.current_track_path); - + return 0; } - + if ( button ) ata_spin(); @@ -883,8 +879,8 @@ bool wps_data_load(struct wps_data *wps_data, } else { - /* - * Hardcode loading WPS_DEFAULTCFG to cause a reset ideally this + /* + * Hardcode loading WPS_DEFAULTCFG to cause a reset ideally this * wants to be a virtual file. Feel free to modify dirbrowse() * if you're feeling brave. */ @@ -893,7 +889,7 @@ bool wps_data_load(struct wps_data *wps_data, wps_reset(wps_data); global_settings.wps_file[0] = 0; return false; - } + } #ifdef HAVE_REMOTE_LCD if (! strcmp(buf, RWPS_DEFAULTCFG) ) @@ -907,13 +903,13 @@ bool wps_data_load(struct wps_data *wps_data, size_t bmpdirlen; char *bmpdir = strrchr(buf, '.'); bmpdirlen = bmpdir - buf; - + fd = open(buf, O_RDONLY); if (fd >= 0) { unsigned int start = 0; - + wps_reset(wps_data); #ifdef HAVE_LCD_BITMAP wps_data->img_buf_ptr = wps_data->img_buf; /* where in image buffer */ @@ -928,7 +924,7 @@ bool wps_data_load(struct wps_data *wps_data, buf, bmpdirlen)) { start += strlen(&wps_data->format_buffer[start]); - + if (start < sizeof(wps_data->format_buffer) - 1) { wps_data->format_buffer[start++] = '\n'; @@ -941,11 +937,11 @@ bool wps_data_load(struct wps_data *wps_data, { gui_wps_format(wps_data); } - + close(fd); - + wps_data->wps_loaded = true; - + return start > 0; } } diff --git a/apps/lang/english.lang b/apps/lang/english.lang index f2f12b51f7..b6113b6771 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -3827,3 +3827,8 @@ eng: "File/directory exists. Overwrite?" voice: "File or directory exists. Overwrite?" new: +id: LANG_PITCH +desc: "pitch" in the pitch screen +eng: "Pitch" +voice: "Pitch" +new: diff --git a/apps/screens.c b/apps/screens.c index f9867a2526..4c71667a91 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -345,147 +345,120 @@ int charging_screen(void) } #endif /* HAVE_CHARGING && !HAVE_POWEROFF_WHILE_CHARGING */ - -#if CONFIG_KEYPAD == RECORDER_PAD || CONFIG_KEYPAD == IRIVER_H100_PAD \ - || CONFIG_KEYPAD == IRIVER_H300_PAD +#if (CONFIG_KEYPAD != IAUDIO_X5_PAD) && (CONFIG_KEYPAD != PLAYER_PAD) /* returns: 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 */ -#if CONFIG_KEYPAD == RECORDER_PAD -#define PITCH_PAUSE BUTTON_PLAY -#elif CONFIG_KEYPAD == IRIVER_H100_PAD || CONFIG_KEYPAD == IRIVER_H300_PAD -#define PITCH_PAUSE BUTTON_SELECT -#endif -int pitch_screen(void) + 1 if USB was connected */ +bool pitch_screen(void) { int button; int pitch = sound_get_pitch(); bool exit = false; - bool used = false; while (!exit) { + unsigned char* ptr; + unsigned char buf[32]; + int w, h; - if ( used ) { - unsigned char* ptr; - unsigned char buf[32]; - int w, h; - - lcd_clear_display(); - lcd_setfont(FONT_SYSFIXED); - - ptr = str(LANG_PITCH_UP); - lcd_getstringsize(ptr,&w,&h); - lcd_putsxy((LCD_WIDTH-w)/2, 0, ptr); - lcd_mono_bitmap(bitmap_icons_7x8[Icon_UpArrow], - LCD_WIDTH/2 - 3, h*2, 7, 8); - - snprintf((char *)buf, sizeof buf, "%d.%d%%", - pitch / 10, pitch % 10 ); - lcd_getstringsize(buf,&w,&h); - lcd_putsxy((LCD_WIDTH-w)/2, h, buf); - - ptr = str(LANG_PITCH_DOWN); - lcd_getstringsize(ptr,&w,&h); - lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr); - lcd_mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], - LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8); - - ptr = str(LANG_PAUSE); - lcd_getstringsize(ptr,&w,&h); - lcd_putsxy((LCD_WIDTH-(w/2))/2, LCD_HEIGHT/2 - h/2, ptr); - lcd_mono_bitmap(bitmap_icons_7x8[Icon_Pause], - (LCD_WIDTH-(w/2))/2-10, LCD_HEIGHT/2 - h/2, 7, 8); + lcd_clear_display(); + lcd_setfont(FONT_SYSFIXED); + + /* UP: +0.1% */ + ptr = "+0.1%"; + lcd_getstringsize(ptr,&w,&h); + lcd_putsxy((LCD_WIDTH-w)/2, 0, ptr); + lcd_mono_bitmap(bitmap_icons_7x8[Icon_UpArrow], + LCD_WIDTH/2 - 3, h, 7, 8); + + /* DOWN: -0.1% */ + ptr = "-0.1%"; + lcd_getstringsize(ptr,&w,&h); + lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr); + lcd_mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], + LCD_WIDTH/2 - 3, LCD_HEIGHT - h*2, 7, 8); + + /* RIGHT: +2% */ + ptr = "+2%"; + lcd_getstringsize(ptr,&w,&h); + lcd_putsxy(LCD_WIDTH-w, (LCD_HEIGHT-h)/2, ptr); + lcd_mono_bitmap(bitmap_icons_7x8[Icon_FastForward], + LCD_WIDTH-w-8, (LCD_HEIGHT-h)/2, 7, 8); + + /* LEFT: -2% */ + ptr = "-2%"; + lcd_getstringsize(ptr,&w,&h); + lcd_putsxy(0, (LCD_HEIGHT-h)/2, ptr); + lcd_mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], + w+1, (LCD_HEIGHT-h)/2, 7, 8); + + /* "Pitch" */ + snprintf((char *)buf, sizeof(buf), str(LANG_PITCH)); + lcd_getstringsize(buf,&w,&h); + lcd_putsxy((LCD_WIDTH-w)/2, (LCD_HEIGHT/2)-h, buf); + /* "XX.X%" */ + snprintf((char *)buf, sizeof(buf), "%d.%d%%", + pitch / 10, pitch % 10 ); + lcd_getstringsize(buf,&w,&h); + lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT/2, buf); - lcd_update(); - } + lcd_update(); /* use lastbutton, so the main loop can decide whether to exit to browser or not */ button = button_get(true); switch (button) { - case BUTTON_UP: - case BUTTON_ON | BUTTON_UP: - case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT: - used = true; + case PITCH_UP: + case PITCH_UP | BUTTON_REPEAT: if ( pitch < 2000 ) pitch++; sound_set_pitch(pitch); break; - case BUTTON_DOWN: - case BUTTON_ON | BUTTON_DOWN: - case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT: - used = true; + case PITCH_DOWN: + case PITCH_DOWN | BUTTON_REPEAT: if ( pitch > 500 ) pitch--; sound_set_pitch(pitch); break; - case BUTTON_ON | PITCH_PAUSE: - audio_pause(); - used = true; - break; - - case PITCH_PAUSE | BUTTON_REL: - audio_resume(); - used = true; - break; - - case BUTTON_ON | PITCH_PAUSE | BUTTON_REL: - audio_resume(); - exit = true; - break; - - case BUTTON_ON | BUTTON_RIGHT: - case BUTTON_LEFT | BUTTON_REL: - if ( pitch < 2000 ) { + case PITCH_RIGHT: + case PITCH_RIGHT | BUTTON_REPEAT: + if ( pitch < 1980 ) pitch += 20; - sound_set_pitch(pitch); - } + else + pitch = 2000; + sound_set_pitch(pitch); break; - case BUTTON_ON | BUTTON_LEFT: - case BUTTON_RIGHT | BUTTON_REL: - if ( pitch > 500 ) { + case PITCH_LEFT: + case PITCH_LEFT | BUTTON_REPEAT: + if ( pitch > 520 ) pitch -= 20; - sound_set_pitch(pitch); - } - break; - -#ifdef SIMULATOR - case BUTTON_ON: -#else - case BUTTON_ON | BUTTON_REL: - case BUTTON_ON | BUTTON_UP | BUTTON_REL: - case BUTTON_ON | BUTTON_DOWN | BUTTON_REL: -#endif - exit = true; - break; - - case BUTTON_ON | BUTTON_REPEAT: - used = true; + else + pitch = 500; + sound_set_pitch(pitch); break; - case BUTTON_ON | BUTTON_OFF: + case PITCH_RESET: pitch = 1000; sound_set_pitch( pitch ); break; + case PITCH_EXIT: + exit = true; + break; + default: if(default_event_handler(button) == SYS_USB_CONNECTED) - return 2; + return 1; break; } } lcd_setfont(FONT_UI); - - if ( used ) - return 1; - else - return 0; + return 0; } + #endif #if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IRIVER_H100_PAD) ||\ diff --git a/apps/screens.h b/apps/screens.h index d9b6ba47be..c6c3e06dc6 100644 --- a/apps/screens.h +++ b/apps/screens.h @@ -22,6 +22,30 @@ #include "config.h" #include "timefuncs.h" +#if (CONFIG_KEYPAD == RECORDER_PAD) || (CONFIG_KEYPAD == IRIVER_H100_PAD) ||\ + (CONFIG_KEYPAD == IRIVER_H300_PAD) || (CONFIG_KEYPAD == ONDIO_PAD) +#define PITCH_UP BUTTON_UP +#define PITCH_DOWN BUTTON_DOWN +#define PITCH_RIGHT BUTTON_RIGHT +#define PITCH_LEFT BUTTON_LEFT +#define PITCH_EXIT BUTTON_OFF +#define PITCH_RESET BUTTON_ON +#elif (CONFIG_KEYPAD == ONDIO_PAD) +#define PITCH_UP BUTTON_UP +#define PITCH_DOWN BUTTON_DOWN +#define PITCH_RIGHT BUTTON_RIGHT +#define PITCH_LEFT BUTTON_LEFT +#define PITCH_EXIT BUTTON_OFF +#define PITCH_RESET BUTTON_MENU +#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) +#define PITCH_UP BUTTON_SCROLL_FWD +#define PITCH_DOWN BUTTON_SCROLL_BACK +#define PITCH_RIGHT BUTTON_RIGHT +#define PITCH_LEFT BUTTON_LEFT +#define PITCH_EXIT BUTTON_SELECT +#define PITCH_RESET BUTTON_MENU +#endif + struct screen; void usb_display_info(struct screen * display); @@ -33,11 +57,9 @@ void charging_splash(void); int mmc_remove_request(void); #endif -#if CONFIG_KEYPAD == RECORDER_PAD || CONFIG_KEYPAD == IRIVER_H100_PAD \ - || CONFIG_KEYPAD == IRIVER_H300_PAD -int pitch_screen(void); -#endif -#if CONFIG_KEYPAD == RECORDER_PAD +bool pitch_screen(void); + +#if CONFIG_KEYPAD == RECORDER_PAD extern bool quick_screen_f3(int button_enter); #endif extern bool quick_screen_quick(int button_enter); -- cgit v1.2.3