Index: apps/onplay.c =================================================================== --- apps/onplay.c (Revision 18291) +++ apps/onplay.c (Arbeitskopie) @@ -64,6 +64,7 @@ #endif #include "cuesheet.h" #include "backdrop.h" +#include "pitchscreen.h" static int context; static char* selected_file = NULL; @@ -1000,8 +1001,8 @@ MENUITEM_FUNCTION(browse_id3_item, 0, ID2P(LANG_MENU_SHOW_ID3_INFO), browse_id3, NULL, NULL, Icon_NOICON); #ifdef HAVE_PITCHSCREEN -MENUITEM_FUNCTION(pitch_screen_item, 0, ID2P(LANG_PITCH), - pitch_screen, NULL, NULL, Icon_Audio); +MENUITEM_FUNCTION(pitch_screen_item, MENU_FUNC_USEPARAM, ID2P(LANG_PITCH), + gui_syncpitchscreen_run, NULL, NULL, Icon_Audio); #endif /* CONTEXT_[TREE|ID3DB] items */ Index: apps/gui/pitchscreen.c =================================================================== --- apps/gui/pitchscreen.c (Revision 18291) +++ apps/gui/pitchscreen.c (Arbeitskopie) @@ -7,6 +7,7 @@ * \/ \/ \/ \/ \/ * $Id$ * + * Copyright (C) 2008 Thomas Martitz * Copyright (C) 2002 Björn Stenberg * * This program is free software; you can redistribute it and/or @@ -36,89 +37,144 @@ #include "icons.h" #include "screen_access.h" #include "screens.h" +#include "statusbar.h" +#include "viewport.h" +#include "pitchscreen.h" -#define PITCH_MAX 2000 -#define PITCH_MIN 500 -#define PITCH_SMALL_DELTA 1 -#define PITCH_BIG_DELTA 10 -#define PITCH_NUDGE_DELTA 20 - #define PITCH_MODE_ABSOLUTE 1 #define PITCH_MODE_SEMITONE -PITCH_MODE_ABSOLUTE -static int pitch_mode = PITCH_MODE_ABSOLUTE; /* 1 - absolute, -1 - semitone */ - /* returns: 0 if no key was pressed 1 if USB was connected */ -static void pitch_screen_draw(struct screen *display, int pitch, int pitch_mode) +static int pitch_mode = PITCH_MODE_ABSOLUTE; /* 1 - absolute, -1 - semitone */ + +static void pitchscreen_fix_viewports(struct screen *display, + struct viewport *parent, + struct viewport pitch_viewports[NB_SCREENS][PITCH_ITEM_COUNT]) { + int n, width, height; + display->getstringsize("+2%",&width,&height); +#ifdef HAVE_REMOTE_LCD + short screen = display->screen_type; +#else + const short screen = 0; + (void)display; +#endif + short icon_border = 12; + for (n = 0; n < PITCH_ITEM_COUNT; n++) + { + pitch_viewports[screen][n] = *parent; + pitch_viewports[screen][n].height = height; + } + pitch_viewports[screen][PITCH_TOP].y += icon_border; + + pitch_viewports[screen][PITCH_MID].x += icon_border; + pitch_viewports[screen][PITCH_MID].width = parent->width - icon_border*2; + pitch_viewports[screen][PITCH_MID].height = height * 2; + pitch_viewports[screen][PITCH_MID].y += parent->height / 2 - + pitch_viewports[screen][PITCH_MID].height / 2; + pitch_viewports[screen][PITCH_BOTTOM].y += parent->height - height - + icon_border; +} + +static void pitchscreen_draw_icons (struct screen *display, + struct viewport *parent) +{ + display->set_viewport(parent); + display->mono_bitmap(bitmap_icons_7x8[Icon_UpArrow], + parent->width/2 - 3, + 2, 7, 8); + display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], + parent->width /2 - 3, + parent->height - 10, 7, 8); + display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], + parent->width - 10, + parent->height /2 - 4, 7, 8); + display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], + 2, + parent->height /2 - 4, 7, 8); +} + +static void pitchscreen_draw ( + struct screen *display, + struct viewport *parent, + struct viewport pitch_viewports[NB_SCREENS][PITCH_ITEM_COUNT], + int pitch, + int pitch_mode ) +{ unsigned char* ptr; unsigned char buf[32]; - int w, h; + int w, h, lines; +#ifdef HAVE_REMOTE_LCD + short screen = display->screen_type; +#else + const short screen = 0; +#endif + lines = viewport_get_nb_lines(parent); + /* hide icons for tiny screens */ + if (parent->width >=50) + pitchscreen_draw_icons(display, parent); - display->clear_display(); - - if (display->nb_lines < 4) /* very small screen, just show the pitch value */ + /* Hide "Pitch up/Pitch down" for a small screen */ + if (lines >= 6) { - w = snprintf((char *)buf, sizeof(buf), "%s: %d.%d%%",str(LANG_PITCH), - pitch / 10, pitch % 10 ); - display->putsxy((display->lcdwidth-(w*display->char_width))/2, - display->nb_lines/2,buf); - } - else /* bigger screen, show everything... */ - { - /* UP: Pitch Up */ + display->set_viewport(&pitch_viewports[screen][PITCH_TOP]); if (pitch_mode == PITCH_MODE_ABSOLUTE) { ptr = str(LANG_PITCH_UP); + /* only clear vp when changed from semitone to absolute + * the other way isn't needed */ + display->clear_viewport(); } else { ptr = str(LANG_PITCH_UP_SEMITONE); } display->getstringsize(ptr,&w,&h); - display->putsxy((display->lcdwidth-w)/2, 0, ptr); - display->mono_bitmap(bitmap_icons_7x8[Icon_UpArrow], - display->lcdwidth/2 - 3, h, 7, 8); + display->putsxy((pitch_viewports[screen][PITCH_TOP].width / 2) - + (w / 2), 0, ptr); /* DOWN: Pitch Down */ + display->set_viewport(&pitch_viewports[screen][PITCH_BOTTOM]); if (pitch_mode == PITCH_MODE_ABSOLUTE) { ptr = str(LANG_PITCH_DOWN); + display->clear_viewport(); } else { ptr = str(LANG_PITCH_DOWN_SEMITONE); } display->getstringsize(ptr,&w,&h); - display->putsxy((display->lcdwidth-w)/2, display->lcdheight - h, ptr); - display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], - display->lcdwidth/2 - 3, - display->lcdheight - h*2, 7, 8); - + display->putsxy((pitch_viewports[screen][PITCH_BOTTOM].width / 2) - + (w / 2), 0, ptr); + } + /* And hide +2%/-2% for a very small screen */ + if (parent->width >= 65) + { /* RIGHT: +2% */ + display->set_viewport(&pitch_viewports[screen][PITCH_MID]); ptr = "+2%"; display->getstringsize(ptr,&w,&h); - display->putsxy(display->lcdwidth-w, (display->lcdheight-h)/2, ptr); - display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], - display->lcdwidth-w-8, - (display->lcdheight-h)/2, 7, 8); + display->putsxy(pitch_viewports[screen][PITCH_MID].width - w, h /2, ptr); /* LEFT: -2% */ ptr = "-2%"; - display->getstringsize(ptr,&w,&h); - display->putsxy(0, (display->lcdheight-h)/2, ptr); - display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], - w+1, (display->lcdheight-h)/2, 7, 8); - - /* "Pitch" */ - snprintf((char *)buf, sizeof(buf), "%s", str(LANG_PITCH)); - display->getstringsize(buf,&w,&h); - display->putsxy((display->lcdwidth-w)/2, (display->lcdheight/2)-h, buf); - /* "XX.X%" */ - snprintf((char *)buf, sizeof(buf), "%d.%d%%", - pitch / 10, pitch % 10 ); - display->getstringsize(buf,&w,&h); - display->putsxy((display->lcdwidth-w)/2, display->lcdheight/2, buf); + display->putsxy(0, h / 2, ptr); } + else + display->set_viewport(&pitch_viewports[screen][PITCH_MID]); + snprintf((char *)buf, sizeof(buf), "%s", str(LANG_PITCH)); + display->getstringsize(buf,&w,&h); + display->putsxy((pitch_viewports[screen][PITCH_MID].width / 2) - (w / 2), + 0, buf); + /* "XX.X%" */ + /* put spaces around the string, so that it won't show the parts of the old + * value when changing from 100.0% to 99.9%, that saves a clear_viewport() */ + snprintf((char *)buf, sizeof(buf), " %d.%d%% ", + pitch / 10, pitch % 10 ); + display->getstringsize(buf,&w,&h); + display->putsxy((pitch_viewports[screen][PITCH_MID].width / 2) - (w / 2), + h, buf); + display->set_viewport(NULL); display->update(); } @@ -188,7 +244,7 @@ return pitch_increase(pitch, tmp - pitch, false); } -bool pitch_screen(void) +bool gui_syncpitchscreen_run(struct viewport *parent) { int button; int pitch = sound_get_pitch(); @@ -196,16 +252,28 @@ bool nudged = false; bool exit = false; int i; - + struct viewport parent2[NB_SCREENS]; + struct viewport pitch_viewports[NB_SCREENS][PITCH_ITEM_COUNT]; + /* initialize pitchscreen vps */ + FOR_NB_SCREENS(i) + { + screens[i].clear_display(); + if (!(parent)) /* parent could be NULL */ + viewport_set_defaults(&parent2[i], i); + else + parent2[i] = parent[i]; + pitchscreen_fix_viewports(&screens[i], &parent2[i], pitch_viewports); + } #if CONFIG_CODEC == SWCODEC pcmbuf_set_low_latency(true); #endif - + i = 0; while (!exit) { FOR_NB_SCREENS(i) - pitch_screen_draw(&screens[i], pitch, pitch_mode); - + pitchscreen_draw(&screens[i], &parent2[i], pitch_viewports, pitch, + pitch_mode); + gui_syncstatusbar_draw(&statusbars, true); button = get_action(CONTEXT_PITCHSCREEN,TIMEOUT_BLOCK); switch (button) { case ACTION_PS_INC_SMALL: Index: apps/gui/pitchscreen.h =================================================================== --- apps/gui/pitchscreen.h (Revision 0) +++ apps/gui/pitchscreen.h (Revision 0) @@ -0,0 +1,46 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Thomas Martitz + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifdef HAVE_PITCHSCREEN + +#ifndef _PITCHSCREEN_H_ +#define _PITCHSCREEN_H_ + +enum PITCHSCREEN_VALUES +{ + PITCH_SMALL_DELTA = 1, + PITCH_BIG_DELTA = 10, + PITCH_NUDGE_DELTA = 20, + PITCH_MIN = 500, + PITCH_MAX = 2000, +}; + +enum PITCHSCREEN_ITEMS +{ + PITCH_TOP = 0, + PITCH_MID, + PITCH_BOTTOM, + PITCH_ITEM_COUNT, +}; + +bool gui_syncpitchscreen_run(struct viewport parent[NB_SCREENS]); +#endif /* _PITCHSCREEN_H_ */ +#endif /* HAVE_PITCHSCREEN */ Index: apps/gui/gwps.c =================================================================== --- apps/gui/gwps.c (Revision 18291) +++ apps/gui/gwps.c (Arbeitskopie) @@ -60,6 +60,7 @@ #include "root_menu.h" #include "backdrop.h" #include "quickscreen.h" +#include "pitchscreen.h" /* currently only on wps_state is needed */ struct wps_state wps_state; @@ -567,7 +568,7 @@ #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 show_remote_main_backdrop(); #endif - if (1 == pitch_screen()) + if (gui_syncpitchscreen_run(NULL)) return SYS_USB_CONNECTED; #if LCD_DEPTH > 1 show_wps_backdrop();