summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2005-11-18 09:03:25 +0000
committerDaniel Stenberg <daniel@haxx.se>2005-11-18 09:03:25 +0000
commit09fce707c117aa4006ca30a5a0bf9eb7a89e2caa (patch)
tree9345d5f6d7d06e122520347a3d9fa3127d3bd4fe /apps
parentfe2c40aedb514126605d5c370ad9792cceadac57 (diff)
Missing file headers put back. Code within 80 cols. Code policed indenting
and style. Simplified struct levels. #if 0'ed unused functions. Made private stuff static. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7954 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/filetree.c4
-rw-r--r--apps/gui/gwps-common.c213
-rw-r--r--apps/gui/gwps-common.h28
-rw-r--r--apps/gui/gwps.c141
-rw-r--r--apps/gui/gwps.h27
-rw-r--r--apps/settings.c12
-rw-r--r--apps/tree.c3
7 files changed, 255 insertions, 173 deletions
diff --git a/apps/filetree.c b/apps/filetree.c
index 6855d3ec5d..236ee487d7 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -384,7 +384,7 @@ int ft_enter(struct tree_context* c)
/* wps config file */
case TREE_ATTR_WPS:
- wps_data_load(gui_syncwps.gui_wps[0].data, buf, true, true);
+ wps_data_load(gui_wps[0].data, buf, true, true);
set_file(buf, global_settings.wps_file,
MAX_FILENAME);
break;
@@ -392,7 +392,7 @@ int ft_enter(struct tree_context* c)
#ifdef HAVE_REMOTE_LCD
/* remote-wps config file */
case TREE_ATTR_RWPS:
- wps_data_load(gui_syncwps.gui_wps[1].data, buf, true, true);
+ wps_data_load(gui_wps[1].data, buf, true, true);
set_file(buf, global_settings.rwps_file,
MAX_FILENAME);
break;
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index d9b40807f7..d24ce05707 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -1,3 +1,21 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 Björn Stenberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
#include "gwps-common.h"
#include "gwps.h"
#include "font.h"
@@ -186,7 +204,8 @@ static char* get_tag(struct wps_data* wps_data,
return id3_get_genre(id3);
case 'v': /* id3 version */
- switch (id3->id3version) {
+ switch (id3->id3version)
+ {
case ID3_VER_1_0:
return "1";
@@ -275,7 +294,8 @@ static char* get_tag(struct wps_data* wps_data,
case 'b': /* progress bar */
*flags |= WPS_REFRESH_PLAYER_PROGRESS;
#ifdef HAVE_LCD_CHARCELLS
- snprintf(buf, buf_size, "%c", wps_data->wps_progress_pat[0]);
+ snprintf(buf, buf_size, "%c",
+ wps_data->wps_progress_pat[0]);
wps_data->full_line_progressbar=0;
return buf;
#else
@@ -300,7 +320,8 @@ static char* get_tag(struct wps_data* wps_data,
#endif
case 'p': /* Playlist Position */
*flags |= WPS_REFRESH_STATIC;
- snprintf(buf, buf_size, "%d", playlist_get_display_index());
+ snprintf(buf, buf_size, "%d",
+ playlist_get_display_index());
return buf;
case 'n': /* Playlist Name (without path) */
@@ -321,7 +342,8 @@ static char* get_tag(struct wps_data* wps_data,
case 'r': /* Remaining Time in Song */
*flags |= WPS_REFRESH_DYNAMIC;
gui_wps_format_time(buf, buf_size,
- id3->length - id3->elapsed - wps_state.ff_rewind_count);
+ id3->length - id3->elapsed -
+ wps_state.ff_rewind_count);
return buf;
case 't': /* Total Time */
@@ -397,7 +419,8 @@ static char* get_tag(struct wps_data* wps_data,
case 'b': /* battery info */
*flags |= WPS_REFRESH_DYNAMIC;
- switch (tag[1]) {
+ switch (tag[1])
+ {
case 'l': /* battery level */
{
int l = battery_level();
@@ -493,17 +516,17 @@ static char* get_tag(struct wps_data* wps_data,
break;
case 'r': /* Runtime database Information */
switch(tag[1])
- {
- case 'p': /* Playcount */
- *flags |= WPS_REFRESH_STATIC;
- snprintf(buf, buf_size, "%ld", cid3->playcount);
- return buf;
- case 'r': /* Rating */
- *flags |= WPS_REFRESH_STATIC;
- *intval = cid3->rating+1;
- snprintf(buf, buf_size, "%d", cid3->rating);
- return buf;
- }
+ {
+ case 'p': /* Playcount */
+ *flags |= WPS_REFRESH_STATIC;
+ snprintf(buf, buf_size, "%ld", cid3->playcount);
+ return buf;
+ case 'r': /* Rating */
+ *flags |= WPS_REFRESH_STATIC;
+ *intval = cid3->rating+1;
+ snprintf(buf, buf_size, "%d", cid3->rating);
+ return buf;
+ }
break;
}
return NULL;
@@ -513,7 +536,8 @@ static char* get_tag(struct wps_data* wps_data,
/* clears the area where the image was shown */
static void clear_image_pos(struct gui_wps *gwps, int n)
{
- if(!gwps) return;
+ if(!gwps)
+ return;
struct wps_data *data = gwps->data;
gwps->display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
gwps->display->fillrect(data->img[n].x, data->img[n].y,
@@ -521,6 +545,7 @@ static void clear_image_pos(struct gui_wps *gwps, int n)
gwps->display->set_drawmode(DRMODE_SOLID);
}
#endif
+
/* Skip to the end of the current %? conditional.
*
* fmt - string to skip it. Should point to somewhere after the leading
@@ -529,15 +554,17 @@ static void clear_image_pos(struct gui_wps *gwps, int n)
*
* Returns the new position in fmt.
*/
-static const char* skip_conditional(struct gui_wps *gwps, const char* fmt, int num)
+static const char* skip_conditional(struct gui_wps *gwps, const char* fmt,
+ int num)
{
int level = 1;
int count = num;
const char *last_alternative = NULL;
#ifdef HAVE_LCD_BITMAP
struct wps_data *data = NULL;
- if(gwps) data = gwps->data;
int last_x=-1, last_y=-1, last_w=-1, last_h=-1;
+ if(gwps)
+ data = gwps->data;
#else
(void)gwps;
#endif
@@ -556,7 +583,7 @@ static const char* skip_conditional(struct gui_wps *gwps, const char* fmt, int n
if(n >= 'A' && n <= 'Z')
n = n - 'A' + 26;
if(last_x != data->img[n].x || last_y != data->img[n].y
- || last_w != data->img[n].w || last_h != data->img[n].h)
+ || last_w != data->img[n].w || last_h != data->img[n].h)
{
last_x = data->img[n].x;
last_y = data->img[n].y;
@@ -639,13 +666,13 @@ static const char* skip_conditional(struct gui_wps *gwps, const char* fmt, int n
* flags - returns the type of the line. See constants i wps-display.h
*/
static void format_display(struct gui_wps *gwps, char* buf,
- int buf_size,
- struct mp3entry* id3,
- struct mp3entry* nid3, /* next song's id3 */
- const char* fmt,
- struct align_pos* align,
- unsigned short* subline_time_mult,
- unsigned char* flags)
+ int buf_size,
+ struct mp3entry* id3,
+ struct mp3entry* nid3, /* next song's id3 */
+ const char* fmt,
+ struct align_pos* align,
+ unsigned short* subline_time_mult,
+ unsigned char* flags)
{
char temp_buf[128];
char* buf_start = buf;
@@ -774,9 +801,9 @@ static void format_display(struct gui_wps *gwps, char* buf,
case '?':
fmt++;
- value = get_tag(gwps->data, id3, nid3, fmt, temp_buf, sizeof(temp_buf),
- &tag_length, subline_time_mult, flags,
- &intval);
+ value = get_tag(gwps->data, id3, nid3, fmt, temp_buf,
+ sizeof(temp_buf),&tag_length,
+ subline_time_mult, flags, &intval);
while (*fmt && ('<' != *fmt))
fmt++;
@@ -796,9 +823,9 @@ static void format_display(struct gui_wps *gwps, char* buf,
break;
default:
- value = get_tag(gwps->data, id3, nid3, fmt, temp_buf, sizeof(temp_buf),
- &tag_length, subline_time_mult, flags,
- &intval);
+ value = get_tag(gwps->data, id3, nid3, fmt, temp_buf,
+ sizeof(temp_buf), &tag_length,
+ subline_time_mult, flags,&intval);
fmt += tag_length;
if (value)
@@ -882,9 +909,9 @@ void fade(bool fade_in)
}
/* Set format string to use for WPS, splitting it into lines */
-void gui_wps_format(struct wps_data *data, const char *bmpdir, size_t bmpdirlen)
+void gui_wps_format(struct wps_data *data, const char *bmpdir,
+ size_t bmpdirlen)
{
- if(!data) return;
char* buf = data->format_buffer;
char* start_of_line = data->format_buffer;
int line = 0;
@@ -894,10 +921,13 @@ void gui_wps_format(struct wps_data *data, const char *bmpdir, size_t bmpdirlen)
(void)bmpdir;
(void)bmpdirlen;
#else
- unsigned char* img_buf_ptr = data->img_buf; /* where are in image buffer? */
+ unsigned char* img_buf_ptr = data->img_buf; /* where in image buffer */
int img_buf_free = IMG_BUFSIZE; /* free space in image buffer */
#endif
+ if(!data)
+ return;
+
for (line=0; line<WPS_MAX_LINES; line++)
{
for (subline=0; subline<WPS_MAX_SUBLINES; subline++)
@@ -1095,9 +1125,10 @@ static void wps_display_images(struct gui_wps *gwps)
display->set_drawmode(DRMODE_SOLID);
display->mono_bitmap(data->img[n].ptr, data->img[n].x,
- data->img[n].y, data->img[n].w, data->img[n].h);
+ data->img[n].y, data->img[n].w,
+ data->img[n].h);
display->update_rect(data->img[n].x, data->img[n].y,
- data->img[n].w, data->img[n].h);
+ data->img[n].w, data->img[n].h);
}
}
display->set_drawmode(DRMODE_SOLID);
@@ -1106,9 +1137,11 @@ static void wps_display_images(struct gui_wps *gwps)
void gui_wps_reset(struct gui_wps *gui_wps)
{
- if(!gui_wps || !gui_wps->data) return;
+ if(!gui_wps || !gui_wps->data)
+ return;
gui_wps->data->wps_loaded = false;
- memset(&gui_wps->data->format_buffer, 0, sizeof (gui_wps->data->format_buffer));
+ memset(&gui_wps->data->format_buffer, 0,
+ sizeof(gui_wps->data->format_buffer));
}
bool gui_wps_refresh(struct gui_wps *gwps, int ffwd_offset,
@@ -1125,7 +1158,8 @@ bool gui_wps_refresh(struct gui_wps *gwps, int ffwd_offset,
struct wps_data *data = gwps->data;
struct wps_state *state = gwps->state;
struct screen *display = gwps->display;
- if(!gwps || !data || !state || !display){
+ if(!gwps || !data || !state || !display)
+ {
return false;
}
#ifdef HAVE_LCD_BITMAP
@@ -1263,13 +1297,15 @@ bool gui_wps_refresh(struct gui_wps *gwps, int ffwd_offset,
{
#define PROGRESS_BAR_HEIGHT 6 /* this should probably be defined elsewhere; config-*.h perhaps? */
int sby = i*h + offset + (h > 7 ? (h - 6) / 2 : 1);
- gui_scrollbar_draw(display, 0, sby, display->width, PROGRESS_BAR_HEIGHT,
- state->id3->length?state->id3->length:1, 0,
- state->id3->length?state->id3->elapsed + state->ff_rewind_count:0,
- HORIZONTAL);
+ gui_scrollbar_draw(display, 0, sby, display->width,
+ PROGRESS_BAR_HEIGHT,
+ state->id3->length?state->id3->length:1, 0,
+ state->id3->length?state->id3->elapsed + state->ff_rewind_count:0,
+ HORIZONTAL);
#ifdef AB_REPEAT_ENABLE
if ( ab_repeat_mode_enabled() )
- ab_draw_markers(state->id3->length, 0, sby, LCD_WIDTH, PROGRESS_BAR_HEIGHT);
+ ab_draw_markers(state->id3->length, 0, sby, LCD_WIDTH,
+ PROGRESS_BAR_HEIGHT);
#endif
update_line = true;
}
@@ -1553,6 +1589,7 @@ static bool draw_player_progress(struct gui_wps *gwps)
int songpos = 0;
int i,j;
struct wps_state *state = gwps->state;
+ struct screen *display = gwps->display;
if (!state->id3)
return false;
@@ -1579,7 +1616,7 @@ static bool draw_player_progress(struct gui_wps *gwps)
player_progressbar[i] += binline[i*5+j];
}
}
- gwps->display->define_pattern(gwps->data->wps_progress_pat[0], player_progressbar);
+ display->define_pattern(gwps->data->wps_progress_pat[0], player_progressbar);
return true;
}
@@ -1622,6 +1659,8 @@ static void draw_player_fullbar(struct gui_wps *gwps, char* buf, int buf_size)
char timestr[7];
struct wps_state *state = gwps->state;
+ struct screen *display = gwps->display;
+ struct wps_data *data = gwps->data;
for (i=0; i < buf_size; i++)
buf[i] = ' ';
@@ -1683,8 +1722,9 @@ static void draw_player_fullbar(struct gui_wps *gwps, char* buf, int buf_size)
}
}
- gwps->display->define_pattern(gwps->data->wps_progress_pat[lcd_char_pos+1],player_progressbar);
- buf[lcd_char_pos]=gwps->data->wps_progress_pat[lcd_char_pos+1];
+ display->define_pattern(data->wps_progress_pat[lcd_char_pos+1],
+ player_progressbar);
+ buf[lcd_char_pos]=data->wps_progress_pat[lcd_char_pos+1];
}
@@ -1714,9 +1754,9 @@ static void draw_player_fullbar(struct gui_wps *gwps, char* buf, int buf_size)
}
}
- gwps->display->define_pattern(gwps->data->wps_progress_pat[7],player_progressbar);
+ display->define_pattern(data->wps_progress_pat[7],player_progressbar);
- buf[songpos/5]=gwps->data->wps_progress_pat[7];
+ buf[songpos/5]=data->wps_progress_pat[7];
}
}
#endif
@@ -1735,11 +1775,11 @@ bool setvol(void)
gui_syncstatusbar_draw(&statusbars, false);
int i;
FOR_NB_SCREENS(i)
- gui_wps_refresh(&gui_syncwps.gui_wps[i], 0, WPS_REFRESH_NON_STATIC);
+ gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_NON_STATIC);
settings_save();
#ifdef HAVE_LCD_CHARCELLS
gui_syncsplash(0, false, "Vol: %d %% ",
- sound_val2phys(SOUND_VOLUME, global_settings.volume));
+ sound_val2phys(SOUND_VOLUME, global_settings.volume));
return true;
#endif
return false;
@@ -1763,8 +1803,10 @@ bool ffwd_rew(int button)
bool usb = false;
int i = 0;
- while (!exit) {
- switch ( button ) {
+ while (!exit)
+ {
+ switch ( button )
+ {
case WPS_FFWD:
#ifdef WPS_RC_FFWD
case WPS_RC_FFWD:
@@ -1779,8 +1821,9 @@ bool ffwd_rew(int button)
if (direction == 1)
{
/* fast forwarding, calc max step relative to end */
- max_step =
- (wps_state.id3->length - (wps_state.id3->elapsed + ff_rewind_count)) *
+ max_step = (wps_state.id3->length -
+ (wps_state.id3->elapsed +
+ ff_rewind_count)) *
FF_REWIND_MAX_PERCENT / 100;
}
else
@@ -1814,7 +1857,7 @@ bool ffwd_rew(int button)
audio_pause();
#if CONFIG_KEYPAD == PLAYER_PAD
FOR_NB_SCREENS(i)
- gui_syncwps.gui_wps[i].display->stop_scroll();
+ gui_wps[i].display->stop_scroll();
#endif
if (direction > 0)
status_set_ffmode(STATUS_FASTFORWARD);
@@ -1833,26 +1876,22 @@ bool ffwd_rew(int button)
}
if (direction > 0) {
- if ((wps_state.id3->elapsed + ff_rewind_count) > wps_state.id3->length)
- ff_rewind_count = wps_state.id3->length - wps_state.id3->elapsed;
+ if ((wps_state.id3->elapsed + ff_rewind_count) >
+ wps_state.id3->length)
+ ff_rewind_count = wps_state.id3->length -
+ wps_state.id3->elapsed;
}
else {
if ((int)(wps_state.id3->elapsed + ff_rewind_count) < 0)
ff_rewind_count = -wps_state.id3->elapsed;
}
- if(wps_state.wps_time_countup == false){
- FOR_NB_SCREENS(i)
- gui_wps_refresh(&gui_syncwps.gui_wps[i], ff_rewind_count,
- WPS_REFRESH_PLAYER_PROGRESS |
- WPS_REFRESH_DYNAMIC);
- }
- else{
- FOR_NB_SCREENS(i)
- gui_wps_refresh(&gui_syncwps.gui_wps[i], -ff_rewind_count,
- WPS_REFRESH_PLAYER_PROGRESS |
- WPS_REFRESH_DYNAMIC);
- }
+ FOR_NB_SCREENS(i)
+ gui_wps_refresh(&gui_wps[i],
+ (wps_state.wps_time_countup == false)?
+ ff_rewind_count:-ff_rewind_count,
+ WPS_REFRESH_PLAYER_PROGRESS |
+ WPS_REFRESH_DYNAMIC);
break;
@@ -1889,7 +1928,7 @@ bool ffwd_rew(int button)
/* let audio thread update id3->elapsed before calling wps_refresh */
yield();
FOR_NB_SCREENS(i)
- gui_wps_refresh(&gui_syncwps.gui_wps[i], 0, WPS_REFRESH_ALL);
+ gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL);
return usb;
}
@@ -1911,13 +1950,14 @@ bool gui_wps_display(void)
{
FOR_NB_SCREENS(i)
{
- gui_syncwps.gui_wps[i].display->clear_display();
- if (!gui_syncwps.gui_wps[i].data->wps_loaded) {
- if ( !gui_syncwps.gui_wps[i].data->format_buffer[0] ) {
+ gui_wps[i].display->clear_display();
+ if (!gui_wps[i].data->wps_loaded) {
+ if ( !gui_wps[i].data->format_buffer[0] ) {
/* set the default wps for the main-screen */
- if(i == 0){
+ if(i == 0)
+ {
#ifdef HAVE_LCD_BITMAP
- wps_data_load(gui_syncwps.gui_wps[i].data,
+ wps_data_load(gui_wps[i].data,
"%s%?it<%?in<%in. |>%it|%fn>\n"
"%s%?ia<%ia|%?d2<%d2|(root)>>\n"
"%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n"
@@ -1927,7 +1967,7 @@ bool gui_wps_display(void)
"%pb\n"
"%pm\n", false, false);
#else
- wps_data_load(gui_syncwps.gui_wps[i].data,
+ wps_data_load(gui_wps[i].data,
"%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d2> - %?id<%id|%d1>\n"
"%pc%?ps<*|/>%pt\n", false, false);
#endif
@@ -1936,7 +1976,7 @@ bool gui_wps_display(void)
/* set the default wps for the remote-screen */
else if(i == 1)
{
- wps_data_load(gui_syncwps.gui_wps[i].data,
+ wps_data_load(gui_wps[i].data,
"%s%?ia<%ia|%?d2<%d2|(root)>>\n"
"%s%?it<%?in<%in. |>%it|%fn>\n"
"%al%pc/%pt%ar[%pp:%pe]\n"
@@ -1950,13 +1990,13 @@ bool gui_wps_display(void)
}
yield();
FOR_NB_SCREENS(i)
- gui_wps_refresh(&gui_syncwps.gui_wps[i], 0, WPS_REFRESH_ALL);
+ gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL);
gui_syncstatusbar_draw(&statusbars, true);
FOR_NB_SCREENS(i)
{
#ifdef HAVE_LCD_BITMAP
- wps_display_images(&gui_syncwps.gui_wps[i]);
- gui_syncwps.gui_wps[i].display->update();
+ wps_display_images(&gui_wps[i]);
+ gui_wps[i].display->update();
#endif
}
return false;
@@ -1980,12 +2020,11 @@ bool update(struct gui_wps *gwps)
if (gwps->state->id3)
memcpy(gwps->state->current_track_path, gwps->state->id3->path,
- sizeof(gwps->state->current_track_path));
+ sizeof(gwps->state->current_track_path));
}
- if (gwps->state->id3){
+ if (gwps->state->id3)
gui_wps_refresh(gwps, 0, WPS_REFRESH_NON_STATIC);
- }
gui_syncstatusbar_draw(&statusbars, false);
@@ -1998,7 +2037,7 @@ void display_keylock_text(bool locked)
char* s;
int i;
FOR_NB_SCREENS(i)
- gui_syncwps.gui_wps[i].display->stop_scroll();
+ gui_wps[i].display->stop_scroll();
#ifdef HAVE_LCD_CHARCELLS
if(locked)
diff --git a/apps/gui/gwps-common.h b/apps/gui/gwps-common.h
index 5cf052898d..fe7f2f66da 100644
--- a/apps/gui/gwps-common.h
+++ b/apps/gui/gwps-common.h
@@ -1,18 +1,32 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 Björn Stenberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
#ifndef _GWPS_COMMON_
#define _GWPS_COMMON_
#include <stdbool.h>
#include <sys/types.h> /* for size_t */
-/* to avoid the unnecessary include if gwps.h */
-struct mp3entry;
-struct gui_img;
-struct wps_data;
-struct gui_wps;
-struct align_pos;
+#include "gwps.h"
void gui_wps_format_time(char* buf, int buf_size, long time);
void fade(bool fade_in);
-void gui_wps_format(struct wps_data *data, const char *bmpdir, size_t bmpdirlen);
+void gui_wps_format(struct wps_data *data, const char *bmpdir,
+ size_t bmpdirlen);
bool gui_wps_refresh(struct gui_wps *gwps, int ffwd_offset,
unsigned char refresh_mode);
bool gui_wps_display(void);
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index 4fc9acbece..f06ea5baf1 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -1,3 +1,21 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 Jerome Kuptz
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -42,12 +60,15 @@
#define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps"
/* currently only on wps_state is needed */
struct wps_state wps_state;
-struct gui_syncwps gui_syncwps;
-struct wps_data wps_datas[NB_SCREENS];
+struct gui_wps gui_wps[NB_SCREENS];
+static struct wps_data wps_datas[NB_SCREENS];
-bool keys_locked = false;
+static bool keys_locked = false;
-long gui_wps_show()
+/* change the path to the current played track */
+static void wps_state_update_ctp(const char *path);
+
+long gui_wps_show(void)
{
long button = 0, lastbutton = 0;
bool ignore_keyup = true;
@@ -67,10 +88,8 @@ long gui_wps_show()
#else
FOR_NB_SCREENS(i)
{
- if(global_settings.statusbar)
- gui_syncwps.gui_wps[i].display->setmargins(0, STATUSBAR_HEIGHT);
- else
- gui_syncwps.gui_wps[i].display->setmargins(0, 0);
+ gui_wps[i].display->setmargins(0, global_settings.statusbar?
+ STATUSBAR_HEIGHT:0);
}
#endif
@@ -87,7 +106,7 @@ long gui_wps_show()
if (gui_wps_display())
return 0;
FOR_NB_SCREENS(i)
- gui_wps_refresh(&gui_syncwps.gui_wps[i], 0, WPS_REFRESH_ALL);
+ gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL);
wps_state_update_ctp(wps_state.id3->path);
}
@@ -119,7 +138,7 @@ long gui_wps_show()
bool pm=false;
FOR_NB_SCREENS(i)
{
- if(gui_syncwps.gui_wps[i].data->peak_meter_enabled)
+ if(gui_wps[i].data->peak_meter_enabled)
pm = true;
}
@@ -137,8 +156,12 @@ long gui_wps_show()
if (TIME_AFTER(current_tick, next_refresh)) {
FOR_NB_SCREENS(i)
- gui_wps_refresh(&gui_syncwps.gui_wps[i], 0, WPS_REFRESH_PEAK_METER);
- next_refresh += HZ / PEAK_METER_FPS;
+ {
+ if(gui_wps[i].data->peak_meter_enabled)
+ gui_wps_refresh(&gui_wps[i], 0,
+ WPS_REFRESH_PEAK_METER);
+ next_refresh += HZ / PEAK_METER_FPS;
+ }
}
}
@@ -213,7 +236,7 @@ long gui_wps_show()
status_set_audio(false);
#endif
FOR_NB_SCREENS(i)
- gui_syncwps.gui_wps[i].display->stop_scroll();
+ gui_wps[i].display->stop_scroll();
/* set dir browser to current playing song */
if (global_settings.browse_current &&
@@ -232,7 +255,8 @@ long gui_wps_show()
#ifdef WPS_RC_PAUSE
case WPS_RC_PAUSE:
#ifdef WPS_RC_PAUSE_PRE
- if ((button == WPS_RC_PAUSE) && (lastbutton != WPS_RC_PAUSE_PRE))
+ if ((button == WPS_RC_PAUSE) &&
+ (lastbutton != WPS_RC_PAUSE_PRE))
break;
#endif
#endif
@@ -333,7 +357,8 @@ long gui_wps_show()
#ifdef AB_REPEAT_ENABLE
/* if we're in A/B repeat mode and the current position
is past the A marker, jump back to the A marker... */
- if ( ab_repeat_mode_enabled() && ab_after_A_marker(wps_state.id3->elapsed) )
+ if ( ab_repeat_mode_enabled()
+ && ab_after_A_marker(wps_state.id3->elapsed) )
{
ab_jump_to_A_marker();
break;
@@ -391,7 +416,8 @@ long gui_wps_show()
#ifdef AB_REPEAT_ENABLE
/* if we're in A/B repeat mode and the current position is
before the A marker, jump to the A marker... */
- if ( ab_repeat_mode_enabled() && ab_before_A_marker(wps_state.id3->elapsed) )
+ if ( ab_repeat_mode_enabled()
+ && ab_before_A_marker(wps_state.id3->elapsed) )
{
ab_jump_to_A_marker();
break;
@@ -417,17 +443,16 @@ long gui_wps_show()
#endif
#endif
FOR_NB_SCREENS(i)
- gui_syncwps.gui_wps[i].display->stop_scroll();
+ gui_wps[i].display->stop_scroll();
if (main_menu())
return true;
#ifdef HAVE_LCD_BITMAP
FOR_NB_SCREENS(i)
{
- if(global_settings.statusbar)
- gui_syncwps.gui_wps[i].display->setmargins(0, STATUSBAR_HEIGHT);
- else
- gui_syncwps.gui_wps[i].display->setmargins(0, 0);
+ gui_wps[i].display->setmargins(0,
+ global_settings.statusbar?
+ STATUSBAR_HEIGHT:0);
}
#endif
restore = true;
@@ -552,8 +577,9 @@ long gui_wps_show()
if (update_track)
{
bool upt = false;
- FOR_NB_SCREENS(i){
- if(update(&gui_syncwps.gui_wps[i]))
+ FOR_NB_SCREENS(i)
+ {
+ if(update(&gui_wps[i]))
upt = true;
}
if (upt)
@@ -577,7 +603,7 @@ long gui_wps_show()
fade(0);
FOR_NB_SCREENS(i)
- gui_syncwps.gui_wps[i].display->stop_scroll();
+ gui_wps[i].display->stop_scroll();
bookmark_autobookmark();
audio_stop();
#ifdef AB_REPEAT_ENABLE
@@ -617,7 +643,7 @@ long gui_wps_show()
if (wps_state.id3){
FOR_NB_SCREENS(i)
- gui_wps_refresh(&gui_syncwps.gui_wps[i], 0, WPS_REFRESH_NON_STATIC);
+ gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_NON_STATIC);
}
}
if (button != BUTTON_NONE)
@@ -674,11 +700,17 @@ static void wps_reset(struct wps_data *data)
/* to setup up the wps-data from a format-buffer (isfile = false)
from a (wps-)file (isfile = true)*/
-bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool display)
+bool wps_data_load(struct wps_data *wps_data,
+ const char *buf,
+ bool isfile,
+ bool display)
{
int i, s;
int fd;
- if(!wps_data || !buf) return false;
+
+ if(!wps_data || !buf)
+ return false;
+
if(!isfile)
{
wps_clear(wps_data);
@@ -694,9 +726,10 @@ bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool
* wants to be a virtual file. Feel free to modify dirbrowse()
* if you're feeling brave.
*/
- if (! strcmp(buf, WPS_DEFAULTCFG) || !strcmp(buf, RWPS_DEFAULTCFG) ) {
- wps_reset(wps_data);
- return false;
+ if (! strcmp(buf, WPS_DEFAULTCFG) || !strcmp(buf, RWPS_DEFAULTCFG) )
+ {
+ wps_reset(wps_data);
+ return false;
}
size_t bmpdirlen;
char *bmpdir = strrchr(buf, '.');
@@ -706,7 +739,8 @@ bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool
if (fd >= 0)
{
- int numread = read(fd, wps_data->format_buffer, sizeof(wps_data->format_buffer) - 1);
+ int numread = read(fd, wps_data->format_buffer,
+ sizeof(wps_data->format_buffer) - 1);
if (numread > 0)
{
@@ -733,24 +767,19 @@ bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool
any_defined_line = false;
for (i=0; i<WPS_MAX_LINES; i++)
{
- if (wps_data->format_lines[i][s])
+ if (wps_data->format_lines[i][s] &&
+ wps_data->format_lines[i][s][0])
{
- if (*(wps_data->format_lines[i][s]) == 0)
- {
- FOR_NB_SCREENS(z)
- screens[z].puts(0,i," ");
- }
- else
- {
- FOR_NB_SCREENS(z)
- screens[z].puts(0,i,wps_data->format_lines[i][s]);
- }
+ FOR_NB_SCREENS(z)
+ screens[z].puts(0, i,
+ wps_data->
+ format_lines[i][s]);
any_defined_line = true;
}
else
{
FOR_NB_SCREENS(z)
- screens[z].puts(0,i," ");
+ screens[z].puts(0, i, " ");
}
}
if (any_defined_line)
@@ -759,7 +788,7 @@ bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool
FOR_NB_SCREENS(z)
screens[z].update();
#endif
- sleep(HZ/2);
+ sleep(HZ/2);
}
}
}
@@ -775,7 +804,6 @@ bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool
/* wps_data end */
/* wps_state */
-struct wps_state wps_state;
void wps_state_init(void)
{
@@ -785,23 +813,31 @@ void wps_state_init(void)
wps_state.nid3 = NULL;
wps_state.current_track_path[0] = '\0';
}
+
+#if 0
+/* these are obviously not used? */
+
void wps_state_update_ff_rew(bool ff_rew)
{
wps_state.ff_rewind = ff_rew;
}
+
void wps_state_update_paused(bool paused)
{
wps_state.paused = paused;
}
-void wps_state_update_ctp(const char *path)
-{
- memcpy(wps_state.current_track_path, path, sizeof(wps_state.current_track_path));
-}
void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3)
{
wps_state.id3 = id3;
wps_state.nid3 = nid3;
}
+#endif
+
+static void wps_state_update_ctp(const char *path)
+{
+ memcpy(wps_state.current_track_path, path,
+ sizeof(wps_state.current_track_path));
+}
/* wps_state end*/
/* initial setup of a wps */
@@ -838,7 +874,7 @@ void gui_sync_wps_screen_init(void)
{
int i;
FOR_NB_SCREENS(i)
- gui_wps_set_disp(&gui_syncwps.gui_wps[i], &screens[i]);
+ gui_wps_set_disp(&gui_wps[i], &screens[i]);
}
void gui_sync_wps_init(void)
@@ -846,8 +882,7 @@ void gui_sync_wps_init(void)
int i;
FOR_NB_SCREENS(i)
{
- gui_wps_init(&gui_syncwps.gui_wps[i]);
- gui_wps_set_data(&gui_syncwps.gui_wps[i], &wps_datas[i]);
+ gui_wps_init(&gui_wps[i]);
+ gui_wps_set_data(&gui_wps[i], &wps_datas[i]);
}
}
-
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h
index b5fddd556f..d8cc6a78c0 100644
--- a/apps/gui/gwps.h
+++ b/apps/gui/gwps.h
@@ -145,7 +145,7 @@
#define WPS_INCVOL BUTTON_UP
#define WPS_DECVOL BUTTON_DOWN
#define WPS_PAUSE BUTTON_OFF
-/* #define WPS_MENU Ondio can't have both main menu and context menu in wps */
+/* #define WPS_MENU Ondio can't have both main menu and context menu in wps */
#define WPS_BROWSE (BUTTON_MENU | BUTTON_REL)
#define WPS_BROWSE_PRE BUTTON_MENU
#define WPS_KEYLOCK (BUTTON_MENU | BUTTON_DOWN)
@@ -183,7 +183,7 @@
#define WPS_INCVOL BUTTON_UP
#define WPS_DECVOL BUTTON_DOWN
#define WPS_PAUSE BUTTON_OFF
-/* #define WPS_MENU iPod can't have both main menu and context menu in wps */
+/* #define WPS_MENU iPod can't have both main menu and context menu in wps */
#define WPS_BROWSE (BUTTON_MENU | BUTTON_REL)
#define WPS_BROWSE_PRE BUTTON_MENU
#define WPS_KEYLOCK (BUTTON_MENU | BUTTON_DOWN)
@@ -253,6 +253,8 @@ struct wps_data
#ifdef HAVE_LCD_BITMAP
struct gui_img img[MAX_IMAGES];
unsigned char img_buf[IMG_BUFSIZE];
+ bool wps_sb_tag;
+ bool show_sb_on_wps;
#endif
#ifdef HAVE_LCD_CHARCELLS
unsigned char wps_progress_pat[8];
@@ -274,7 +276,10 @@ void wps_data_init(struct wps_data *wps_data);
/* to setup up the wps-data from a format-buffer (isfile = false)
from a (wps-)file (isfile = true)*/
-bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool display);
+bool wps_data_load(struct wps_data *wps_data,
+ const char *buf,
+ bool isfile,
+ bool display);
/* wps_data end */
@@ -301,13 +306,6 @@ void wps_state_init(void);
else we are in normal mode */
void wps_state_update_ff_rew(bool ff_rew);
-/* change the paused-status
- to indicate if playback is currently paused or not */
-void wps_state_update_paused(bool paused);
-
-/* change the path to the current played track */
-void wps_state_update_ctp(const char *path);
-
/* change the tag-information of the current played track
and the following track */
void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3);
@@ -318,7 +316,7 @@ void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3);
and the screen on which the wps-content should be drawn */
struct gui_wps
{
- struct screen * display;
+ struct screen * display;
struct wps_data *data;
struct wps_state *state;
};
@@ -333,16 +331,11 @@ void gui_wps_set_data(struct gui_wps *gui_wps, struct wps_data *data);
void gui_wps_set_disp(struct gui_wps *gui_wps, struct screen *display);
/* gui_wps end */
-struct gui_syncwps
-{
- struct gui_wps gui_wps[NB_SCREENS];
-};
long gui_wps_show(void);
/* currently only on wps_state is needed */
extern struct wps_state wps_state;
-extern struct gui_syncwps gui_syncwps;
-extern struct wps_data wps_datas[NB_SCREENS];
+extern struct gui_wps gui_wps[NB_SCREENS];
void gui_sync_wps_init(void);
void gui_sync_data_wps_init(void);
diff --git a/apps/settings.c b/apps/settings.c
index 2e5014fce7..36bd332ae3 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -890,20 +890,20 @@ void settings_apply(void)
global_settings.wps_file[0] != 0xff ) {
snprintf(buf, sizeof buf, WPS_DIR "/%s.wps",
global_settings.wps_file);
- wps_data_load(gui_syncwps.gui_wps[0].data, buf, true, false);
+ wps_data_load(gui_wps[0].data, buf, true, false);
}
else
- wps_data_init(gui_syncwps.gui_wps[0].data);
+ wps_data_init(gui_wps[0].data);
#ifdef HAVE_REMOTE_LCD
if ( global_settings.rwps_file[0] &&
global_settings.rwps_file[0] != 0xff ) {
snprintf(buf, sizeof buf, WPS_DIR "/%s.rwps",
global_settings.rwps_file);
- wps_data_load(gui_syncwps.gui_wps[1].data, buf, true, false);
+ wps_data_load(gui_wps[1].data, buf, true, false);
}
else
- wps_data_init(gui_syncwps.gui_wps[1].data);
+ wps_data_init(gui_wps[1].data);
#endif
#ifdef HAVE_LCD_BITMAP
@@ -1166,12 +1166,12 @@ bool settings_load_config(const char* file)
/* check for the string values */
if (!strcasecmp(name, "wps")) {
- if (wps_data_load(gui_syncwps.gui_wps[0].data,value,true, false))
+ if (wps_data_load(gui_wps[0].data,value,true, false))
set_file(value, global_settings.wps_file, MAX_FILENAME);
}
#ifdef HAVE_REMOTE_LCD
else if (!strcasecmp(name, "rwps")) {
- if (wps_data_load(gui_syncwps.gui_wps[1].data,value,true, false))
+ if (wps_data_load(gui_wps[1].data,value,true, false))
set_file(value, global_settings.rwps_file, MAX_FILENAME);
}
#endif
diff --git a/apps/tree.c b/apps/tree.c
index 284fdcbdc7..89a8522743 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -816,7 +816,8 @@ static bool dirbrowse(void)
else
{
DEBUGF("Playing file thumbnail: %s/%s%s\n",
- currdir, dircache[lasti].name, file_thumbnail_ext);
+ currdir, dircache[lasti].name,
+ file_thumbnail_ext);
/* no fallback necessary, we knew in advance
that the file exists */
ft_play_filename(currdir, dircache[lasti].name);