Update to CUSTOM_WPS. Now has an If/Else ability. Also updated the docs

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1990 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Justin Heiner 2002-08-27 01:05:19 +00:00
parent 0dbcb43620
commit a7a46c70dd
2 changed files with 124 additions and 40 deletions

View file

@ -73,7 +73,6 @@ static char custom_wps[64];
static void draw_screen(struct mp3entry* id3) static void draw_screen(struct mp3entry* id3)
{ {
int font_height; int font_height;
#ifdef LOADABLE_FONTS #ifdef LOADABLE_FONTS
unsigned char *font = lcd_getcurrentldfont(); unsigned char *font = lcd_getcurrentldfont();
@ -96,12 +95,15 @@ static void draw_screen(struct mp3entry* id3)
else else
{ {
#ifdef CUSTOM_WPS #ifdef CUSTOM_WPS
#ifdef HAVE_LCD_CHARCELLS
static int last_wps = -1; static int last_wps = -1;
if ( last_wps != global_settings.wps_display && if ((last_wps != global_settings.wps_display
global_settings.wps_display == PLAY_DISPLAY_CUSTOM_WPS ) { && global_settings.wps_display == PLAY_DISPLAY_CUSTOM_WPS))
{
load_custom_wps(); load_custom_wps();
last_wps = global_settings.wps_display; last_wps = global_settings.wps_display;
} }
#endif
#endif #endif
switch ( global_settings.wps_display ) { switch ( global_settings.wps_display ) {
case PLAY_DISPLAY_TRACK_TITLE: case PLAY_DISPLAY_TRACK_TITLE:
@ -266,6 +268,11 @@ bool display_custom_wps(int x_val, int y_val, bool do_scroll, char *wps_string)
{ {
char buffer[128]; char buffer[128];
char tmpbuf[64]; char tmpbuf[64];
int con_flag = 0; /* (0)Not inside of if/else
(1)Inside of If
(2)Inside of Else */
char con_if[64];
char con_else[64];
char cchr1; char cchr1;
char cchr2; char cchr2;
char cchr3; char cchr3;
@ -384,11 +391,53 @@ bool display_custom_wps(int x_val, int y_val, bool do_scroll, char *wps_string)
case '%': /* Displays % */ case '%': /* Displays % */
snprintf(tmpbuf, sizeof(tmpbuf), "%%"); snprintf(tmpbuf, sizeof(tmpbuf), "%%");
break; break;
case '?': /* Conditional Display of ID3/File */
switch(con_flag)
{
case 0:
con_if[0] = 0;
con_else[0] = 0;
con_flag = 1;
break;
default:
if(id3->artist && id3->title)
snprintf(tmpbuf, sizeof(tmpbuf), "%s", con_if);
else
snprintf(tmpbuf, sizeof(tmpbuf), "%s", con_else);
con_flag = 0;
break;
}
break;
case ':': /* Seperator for Conditional ID3/File Display */
con_flag = 2;
break;
}
switch(con_flag)
{
case 0:
snprintf(buffer, sizeof(buffer), "%s%s", buffer, tmpbuf);
break;
case 1:
snprintf(con_if, sizeof(con_if), "%s%s", con_if, tmpbuf);
break;
case 2:
snprintf(con_else, sizeof(con_else), "%s%s", con_else, tmpbuf);
break;
} }
snprintf(buffer, sizeof(buffer), "%s%s", buffer, tmpbuf);
break; break;
default: default:
snprintf(buffer, sizeof(buffer), "%s%c", buffer, cchr1); switch(con_flag)
{
case 0:
snprintf(buffer, sizeof(buffer), "%s%c", buffer, cchr1);
break;
case 1:
snprintf(con_if, sizeof(con_if), "%s%c", con_if, cchr1);
break;
case 2:
snprintf(con_else, sizeof(con_else), "%s%c", con_else, cchr1);
break;
}
break; break;
} }
if(seek >= strlen(wps_string)) if(seek >= strlen(wps_string))
@ -474,17 +523,17 @@ int player_id3_show(void)
case 0: case 0:
lcd_puts(0, 0, "Title"); lcd_puts(0, 0, "Title");
snprintf(scroll_text,sizeof(scroll_text), "%s", snprintf(scroll_text,sizeof(scroll_text), "%s",
id3->title); id3->title?id3->title:"<no title>");
break; break;
case 1: case 1:
lcd_puts(0, 0, "Artist"); lcd_puts(0, 0, "Artist");
snprintf(scroll_text,sizeof(scroll_text), "%s", snprintf(scroll_text,sizeof(scroll_text), "%s",
id3->artist); id3->artist?id3->artist:"<no artist>");
break; break;
case 2: case 2:
lcd_puts(0, 0, "Album"); lcd_puts(0, 0, "Album");
snprintf(scroll_text,sizeof(scroll_text), "%s", snprintf(scroll_text,sizeof(scroll_text), "%s",
id3->album); id3->album?id3->album:"<no album>");
break; break;
case 3: case 3:
lcd_puts(0, 0, "Length"); lcd_puts(0, 0, "Length");

View file

@ -1,46 +1,78 @@
Custom WPS Display Custom WPS Display
wps.config File Format Specifications wps.config File Format Specifications
Description
----------- Description / General Info
The Custom WPS Display is used on the Rockbox Player ONLY as a means --------------------------
to customize the WPS to the user's likings. * The Custom WPS Display is used on the Rockbox Player ONLY, as a means
The first line of the 2 line display is the customized line (scrolling). to customize the WPS to the user's likings.
The second line is always the time display. (Elapsed & Total Time). * Plans to implement this feature into the recorder are in progress.
The second line is not able to be customized. * The first line of the 2 line display is the customized line (scrolling).
All characters not preceded by % are displayed as typed. * The second line is always the time display. (Elapsed & Total Time).
* The second line is not able to be customized.
* Any CR's, LF's, or CR/LF's (Commonly known as Newline/Return/Enter) in
the wps.config file will be treated as spaces. IE: Don't use them.
* After editing the wps.config file, you may need to reboot your Rockbox.
* All tags except for %%, %?, and %: contain 3 characters (%xx). Remember
to type the tags correctly, or you will get unexpected output, or even
possibly no output at all.
* All characters not preceded by % are displayed as typed.
File Location File Location
------------- -------------
The configuration file must be located in the root folder of the The configuration file must be located in the root folder of the
device and must be named wps.config (lowercase) device and must be named wps.config (lowercase)
Tags Tags
---- ----
%t : ID3 Title ID3 Info Tags:
%a : ID3 Artist %it : ID3 Title
%n : ID3 Track Number %ia : ID3 Artist
%u : ID3 Album %in : ID3 Track Number
%c : Conditional Title/Filename %id : ID3 Album
Displays "Artist - Title" *or* File Info Tags:
Displays Filename if no ID3 Artist/Title %fc : Conditional Title/Filename
%h : Conditional Title/Filename Displays "Artist - Title" *or*
Displays "Title - Artist" *or* Displays Filename if no ID3 Artist/Title
Displays Filename if no ID3 Artist/Title %fd : Conditional Title/Filename
%b : File Bitrate Displays "Title - Artist" *or*
%f : File Frequency Displays Filename if no ID3 Artist/Title
%p : File Path %fb : File Bitrate
%m : File Name %ff : File Frequency
%s : File Size (In Kilobytes) %fp : File Path
%i : Playlist Position %fn : File Name
%l : Playlist Total Entries %fs : File Size (In Kilobytes)
%e : Elapsed Track Time Playlist/Song Info Tags:
%o : Total Track Time %pp : Playlist Position
%% : Displays a % %pe : Playlist Total Entries
%pc : Current Time In Song
%pt : Total Track Time
Other Tags:
%% : Displays a %
Conditional ID3/File Tags (If/Else block):
The following two tags are completely optional, and meant only for those
that wish to go crazy with customization. It lets you specify what to
do when it finds an ID3 tag, and also when it doesn't find one. It can
be placed anywhere within the wps.config file.
The first condition of the If/Else block is what to do when it DOES find
valid ID3 tags. The second condition is what to do when there are no
valid ID3 tags available.
%? : Start/End an If/Else block
%: : Seperator between If and Else
Example:
To display "Title - Artist" if there is ID3 available, or "Filename"
if there is no ID3, the following string would be used:
%?%it - %ia%:%fn%?
Yes, you are not going crazy (although I may be)... This *IS* more
confusing then Perl :-)
Example wps.config File
Example wps.config File (Without If/Else)
----------------------- -----------------------
%i/%l: %c * %sKB %pp/%pe: %fc * %fsKB
Example Output Example Output
-------------- --------------
@ -53,5 +85,8 @@ File Size: 3500
Elapsed Track Time: 2:23 Elapsed Track Time: 2:23
Total Track Time: 3:01 Total Track Time: 3:01
The output of this on the player would be: The output of this on the player would be:
5/10: My Song.mp3 * 3500KB ---------------------------
2:23/3:01 | 5/10: My Song.mp3 * 3500KB|
| 2:23/3:01 |
---------------------------
Of course, the whole first line wouldn't fit, so it scrolls it.