2002-08-30 11:04:41 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2002 Bj<EFBFBD>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.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
|
|
|
|
/* ID3 formatting based on code from the MAD Winamp plugin (in_mad.dll),
|
|
|
|
|
* Copyright (C) 2000-2001 Robert Leslie.
|
|
|
|
|
* See http://www.mars.org/home/rob/proj/mpeg/ for more information.
|
|
|
|
|
*/
|
|
|
|
|
|
2002-08-30 11:04:41 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include "lcd.h"
|
2002-09-12 13:33:59 +00:00
|
|
|
|
#include "font.h"
|
2002-08-30 11:04:41 +00:00
|
|
|
|
#include "mpeg.h"
|
|
|
|
|
#include "id3.h"
|
|
|
|
|
#include "settings.h"
|
|
|
|
|
#include "playlist.h"
|
|
|
|
|
#include "kernel.h"
|
2002-09-01 19:50:45 +00:00
|
|
|
|
#include "system.h"
|
2002-08-30 11:04:41 +00:00
|
|
|
|
#include "status.h"
|
2002-08-30 13:08:37 +00:00
|
|
|
|
#include "wps-display.h"
|
2002-09-01 19:50:45 +00:00
|
|
|
|
#include "debug.h"
|
2002-09-27 09:31:31 +00:00
|
|
|
|
#include "mas.h"
|
2002-09-18 14:08:05 +00:00
|
|
|
|
#include "lang.h"
|
2002-12-05 15:37:07 +00:00
|
|
|
|
#include "powermgmt.h"
|
2003-02-15 00:03:23 +00:00
|
|
|
|
#include "sprintf.h"
|
2002-09-27 09:31:31 +00:00
|
|
|
|
|
2002-08-30 11:04:41 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
#include "icons.h"
|
|
|
|
|
#include "widgets.h"
|
2002-09-27 09:31:31 +00:00
|
|
|
|
#include "peakmeter.h"
|
2002-08-30 11:04:41 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
#define WPS_CONFIG ROCKBOX_DIR "/default.wps"
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-09-01 19:50:45 +00:00
|
|
|
|
#define MAX_LINES 10
|
2002-09-02 12:46:32 +00:00
|
|
|
|
#else
|
|
|
|
|
#define MAX_LINES 2
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
#define FORMAT_BUFFER_SIZE 300
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2003-01-10 09:55:50 +00:00
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2003-03-05 23:01:55 +00:00
|
|
|
|
static unsigned char wps_progress_pat[8]={0,0,0,0,0,0,0,0};
|
2003-02-27 14:00:36 +00:00
|
|
|
|
static bool full_line_progressbar=0;
|
2003-01-13 11:48:41 +00:00
|
|
|
|
static bool draw_player_progress(struct mp3entry* id3, int ff_rewwind_count);
|
2003-02-27 14:00:36 +00:00
|
|
|
|
static void draw_player_fullbar(char* buf, int buf_size,
|
|
|
|
|
struct mp3entry* id3, int ff_rewwind_count);
|
2003-03-05 23:01:55 +00:00
|
|
|
|
static char map_fullbar_char(char ascii_val);
|
2003-01-10 09:55:50 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
static char format_buffer[FORMAT_BUFFER_SIZE];
|
|
|
|
|
static char* format_lines[MAX_LINES];
|
2002-10-29 12:09:15 +00:00
|
|
|
|
static unsigned char line_type[MAX_LINES];
|
2002-08-30 11:04:41 +00:00
|
|
|
|
static int ff_rewind_count;
|
2002-08-31 04:58:35 +00:00
|
|
|
|
bool wps_time_countup = true;
|
2002-09-27 11:24:47 +00:00
|
|
|
|
static bool wps_loaded = false;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2002-12-05 15:21:18 +00:00
|
|
|
|
static const char* const genres[] = {
|
|
|
|
|
"Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge",
|
|
|
|
|
"Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", "Other", "Pop", "R&B",
|
|
|
|
|
"Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska",
|
|
|
|
|
"Death Metal", "Pranks", "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop",
|
|
|
|
|
"Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental",
|
|
|
|
|
"Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "AlternRock",
|
|
|
|
|
"Bass", "Soul", "Punk", "Space", "Meditative", "Instrumental Pop",
|
|
|
|
|
"Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno-Industrial",
|
|
|
|
|
"Electronic", "Pop-Folk", "Eurodance", "Dream", "Southern Rock", "Comedy",
|
|
|
|
|
"Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle",
|
|
|
|
|
"Native American", "Cabaret", "New Wave", "Psychadelic", "Rave",
|
|
|
|
|
"Showtunes", "Trailer", "Lo-Fi", "Tribal", "Acid Punk", "Acid Jazz",
|
|
|
|
|
"Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock",
|
|
|
|
|
|
|
|
|
|
/* winamp extensions */
|
|
|
|
|
"Folk", "Folk-Rock", "National Folk", "Swing", "Fast Fusion", "Bebob",
|
|
|
|
|
"Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock",
|
|
|
|
|
"Progressive Rock", "Psychedelic Rock", "Symphonic Rock", "Slow Rock",
|
|
|
|
|
"Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech",
|
|
|
|
|
"Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass",
|
|
|
|
|
"Primus", "Porn Groove", "Satire", "Slow Jam", "Club", "Tango", "Samba",
|
|
|
|
|
"Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle",
|
|
|
|
|
"Duet", "Punk Rock", "Drum Solo", "A capella", "Euro-House", "Dance Hall"
|
|
|
|
|
};
|
|
|
|
|
|
2003-02-11 15:03:28 +00:00
|
|
|
|
char* wps_get_genre(unsigned int genre)
|
|
|
|
|
{
|
|
|
|
|
if (genre < sizeof(genres)/sizeof(char*))
|
|
|
|
|
return (char*)genres[genre];
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-12-05 15:21:18 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
/* Set format string to use for WPS, splitting it into lines */
|
|
|
|
|
static void wps_format(char* fmt)
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-09-01 19:50:45 +00:00
|
|
|
|
char* buf = format_buffer;
|
|
|
|
|
int line = 0;
|
|
|
|
|
|
|
|
|
|
strncpy(format_buffer, fmt, sizeof(format_buffer));
|
|
|
|
|
format_buffer[sizeof(format_buffer) - 1] = 0;
|
|
|
|
|
format_lines[line] = buf;
|
|
|
|
|
|
|
|
|
|
while (*buf)
|
|
|
|
|
{
|
2002-09-04 14:17:41 +00:00
|
|
|
|
switch (*buf)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
|
|
|
|
case '\r':
|
2002-09-04 14:17:41 +00:00
|
|
|
|
*buf = 0;
|
|
|
|
|
break;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
case '\n': /* LF */
|
2002-09-04 14:17:41 +00:00
|
|
|
|
*buf = 0;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
2002-09-04 14:17:41 +00:00
|
|
|
|
if (++line < MAX_LINES)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
2002-09-04 14:17:41 +00:00
|
|
|
|
/* the next line starts on the next byte */
|
|
|
|
|
format_lines[line] = buf+1;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-09-04 14:17:41 +00:00
|
|
|
|
buf++;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-09-04 14:17:41 +00:00
|
|
|
|
if(buf != format_lines[line])
|
|
|
|
|
/* the last line didn't terminate with a newline */
|
|
|
|
|
line++;
|
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
for (; line < MAX_LINES; line++)
|
|
|
|
|
{
|
|
|
|
|
format_lines[line] = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2002-10-09 23:13:25 +00:00
|
|
|
|
void wps_reset(void)
|
|
|
|
|
{
|
|
|
|
|
wps_loaded = false;
|
|
|
|
|
memset(&format_buffer, 0, sizeof format_buffer);
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-08 15:42:40 +00:00
|
|
|
|
bool wps_load(char* file, bool display)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
|
|
|
|
char buffer[FORMAT_BUFFER_SIZE];
|
|
|
|
|
int fd;
|
2002-09-02 12:46:32 +00:00
|
|
|
|
|
|
|
|
|
fd = open(file, O_RDONLY);
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
|
|
|
|
if (-1 != fd)
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-09-01 19:50:45 +00:00
|
|
|
|
int numread = read(fd, buffer, sizeof(buffer) - 1);
|
|
|
|
|
|
|
|
|
|
if (numread > 0)
|
|
|
|
|
{
|
|
|
|
|
buffer[numread] = 0;
|
|
|
|
|
wps_format(buffer);
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-30 11:04:41 +00:00
|
|
|
|
close(fd);
|
2002-09-02 12:46:32 +00:00
|
|
|
|
|
2002-10-08 15:42:40 +00:00
|
|
|
|
if ( display ) {
|
2002-09-02 12:46:32 +00:00
|
|
|
|
int i;
|
|
|
|
|
lcd_clear_display();
|
2002-09-02 13:32:31 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-09-02 12:46:32 +00:00
|
|
|
|
lcd_setmargins(0,0);
|
2002-09-02 13:32:31 +00:00
|
|
|
|
#endif
|
2002-09-02 12:46:32 +00:00
|
|
|
|
for (i=0; i<MAX_LINES && format_lines[i]; i++)
|
|
|
|
|
lcd_puts(0,i,format_lines[i]);
|
|
|
|
|
lcd_update();
|
|
|
|
|
sleep(HZ);
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-09 05:26:36 +00:00
|
|
|
|
wps_loaded = true;
|
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
return numread > 0;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
/* Format time into buf.
|
|
|
|
|
*
|
|
|
|
|
* buf - buffer to format to.
|
|
|
|
|
* buf_size - size of buffer.
|
|
|
|
|
* time - time to format, in milliseconds.
|
|
|
|
|
*/
|
|
|
|
|
static void format_time(char* buf, int buf_size, int time)
|
|
|
|
|
{
|
|
|
|
|
snprintf(buf, buf_size, "%d:%02d", time / 60000, time % 60000 / 1000);
|
|
|
|
|
}
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
/* Extract a part from a path.
|
|
|
|
|
*
|
|
|
|
|
* buf - buffer extract part to.
|
|
|
|
|
* buf_size - size of buffer.
|
|
|
|
|
* path - path to extract from.
|
|
|
|
|
* level - what to extract. 0 is file name, 1 is parent of file, 2 is
|
|
|
|
|
* parent of parent, etc.
|
|
|
|
|
*
|
|
|
|
|
* Returns buf if the desired level was found, NULL otherwise.
|
|
|
|
|
*/
|
|
|
|
|
static char* get_dir(char* buf, int buf_size, char* path, int level)
|
|
|
|
|
{
|
|
|
|
|
char* sep;
|
|
|
|
|
char* last_sep;
|
|
|
|
|
int len;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
sep = path + strlen(path);
|
|
|
|
|
last_sep = sep;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
while (sep > path)
|
|
|
|
|
{
|
|
|
|
|
if ('/' == *(--sep))
|
|
|
|
|
{
|
|
|
|
|
if (!level)
|
|
|
|
|
{
|
2002-08-30 11:04:41 +00:00
|
|
|
|
break;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
level--;
|
|
|
|
|
last_sep = sep - 1;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
if (level || (last_sep <= sep))
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-09-01 19:50:45 +00:00
|
|
|
|
return NULL;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
|
|
|
|
len = MIN(last_sep - sep, buf_size - 1);
|
|
|
|
|
strncpy(buf, sep + 1, len);
|
|
|
|
|
buf[len] = 0;
|
|
|
|
|
return buf;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
/* Get the tag specified by the two characters at fmt.
|
|
|
|
|
*
|
|
|
|
|
* id3 - ID3 data to get tag values from.
|
|
|
|
|
* tag - string (of two characters) specifying the tag to get.
|
|
|
|
|
* buf - buffer to certain tags, such as track number, play time or
|
|
|
|
|
* directory name.
|
|
|
|
|
* buf_size - size of buffer.
|
2002-10-29 12:09:15 +00:00
|
|
|
|
* flags - returns the type of the line. See constants i wps-display.h
|
2002-09-01 19:50:45 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the tag. NULL indicates the tag wasn't available.
|
|
|
|
|
*/
|
2002-09-02 12:46:32 +00:00
|
|
|
|
static char* get_tag(struct mp3entry* id3,
|
|
|
|
|
char* tag,
|
|
|
|
|
char* buf,
|
|
|
|
|
int buf_size,
|
2002-10-29 12:09:15 +00:00
|
|
|
|
unsigned char* flags)
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-09-01 19:50:45 +00:00
|
|
|
|
if ((0 == tag[0]) || (0 == tag[1]))
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-09-01 19:50:45 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (tag[0])
|
|
|
|
|
{
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'i': /* ID3 Information */
|
2002-10-29 12:09:15 +00:00
|
|
|
|
*flags |= WPS_REFRESH_STATIC;
|
2002-09-02 12:46:32 +00:00
|
|
|
|
switch (tag[1])
|
|
|
|
|
{
|
|
|
|
|
case 't': /* ID3 Title */
|
|
|
|
|
return id3->title;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'a': /* ID3 Artist */
|
|
|
|
|
return id3->artist;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'n': /* ID3 Track Number */
|
|
|
|
|
if (id3->tracknum)
|
|
|
|
|
{
|
|
|
|
|
snprintf(buf, buf_size, "%d", id3->tracknum);
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 'd': /* ID3 Album/Disc */
|
|
|
|
|
return id3->album;
|
2002-12-05 14:55:14 +00:00
|
|
|
|
|
|
|
|
|
case 'y': /* year */
|
|
|
|
|
if (id3->year) {
|
|
|
|
|
snprintf(buf, buf_size, "%d", id3->year);
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
|
|
|
|
break;
|
2002-12-05 15:21:18 +00:00
|
|
|
|
|
|
|
|
|
case 'g': /* genre */
|
|
|
|
|
if (id3->genre < sizeof(genres)/sizeof(char*))
|
|
|
|
|
return (char*)genres[id3->genre];
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
|
|
|
|
break;
|
2002-12-09 15:01:37 +00:00
|
|
|
|
|
|
|
|
|
case 'v': /* id3 version */
|
|
|
|
|
switch (id3->id3version) {
|
|
|
|
|
case ID3_VER_1_0:
|
|
|
|
|
return "1";
|
|
|
|
|
|
|
|
|
|
case ID3_VER_1_1:
|
|
|
|
|
return "1.1";
|
|
|
|
|
|
|
|
|
|
case ID3_VER_2_2:
|
|
|
|
|
return "2.2";
|
|
|
|
|
|
|
|
|
|
case ID3_VER_2_3:
|
|
|
|
|
return "2.3";
|
|
|
|
|
|
|
|
|
|
case ID3_VER_2_4:
|
|
|
|
|
return "2.4";
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
2002-09-02 12:46:32 +00:00
|
|
|
|
break;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'f': /* File Information */
|
2002-10-29 12:09:15 +00:00
|
|
|
|
*flags |= WPS_REFRESH_STATIC;
|
2002-09-02 12:46:32 +00:00
|
|
|
|
switch(tag[1])
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'v': /* VBR file? */
|
|
|
|
|
return id3->vbr ? "(avg)" : NULL;
|
|
|
|
|
|
|
|
|
|
case 'b': /* File Bitrate */
|
|
|
|
|
snprintf(buf, buf_size, "%d", id3->bitrate);
|
|
|
|
|
return buf;
|
|
|
|
|
|
|
|
|
|
case 'f': /* File Frequency */
|
|
|
|
|
snprintf(buf, buf_size, "%d", id3->frequency);
|
|
|
|
|
return buf;
|
|
|
|
|
|
|
|
|
|
case 'p': /* File Path */
|
|
|
|
|
return id3->path;
|
|
|
|
|
|
|
|
|
|
case 'm': /* File Name - With Extension */
|
|
|
|
|
return get_dir(buf, buf_size, id3->path, 0);
|
|
|
|
|
|
|
|
|
|
case 'n': /* File Name */
|
|
|
|
|
if (get_dir(buf, buf_size, id3->path, 0))
|
|
|
|
|
{
|
|
|
|
|
/* Remove extension */
|
|
|
|
|
char* sep = strrchr(buf, '.');
|
|
|
|
|
|
|
|
|
|
if (NULL != sep)
|
|
|
|
|
{
|
|
|
|
|
*sep = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case 's': /* File Size (in kilobytes) */
|
|
|
|
|
snprintf(buf, buf_size, "%d", id3->filesize / 1024);
|
|
|
|
|
return buf;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
2002-09-02 12:46:32 +00:00
|
|
|
|
break;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'p': /* Playlist/Song Information */
|
|
|
|
|
switch(tag[1])
|
|
|
|
|
{
|
2002-09-06 23:17:02 +00:00
|
|
|
|
case 'b': /* progress bar */
|
2002-10-29 12:09:15 +00:00
|
|
|
|
*flags |= WPS_REFRESH_PLAYER_PROGRESS;
|
2003-01-10 09:55:50 +00:00
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2003-02-27 14:00:36 +00:00
|
|
|
|
snprintf(buf, buf_size, "%c", wps_progress_pat[0]);
|
|
|
|
|
full_line_progressbar=0;
|
2003-01-10 09:55:50 +00:00
|
|
|
|
return buf;
|
|
|
|
|
#else
|
2002-09-02 12:46:32 +00:00
|
|
|
|
return "\x01";
|
2003-01-10 09:55:50 +00:00
|
|
|
|
#endif
|
2003-02-27 14:00:36 +00:00
|
|
|
|
case 'f': /* full-line progress bar */
|
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
|
*flags |= WPS_REFRESH_PLAYER_PROGRESS;
|
|
|
|
|
*flags |= WPS_REFRESH_DYNAMIC;
|
|
|
|
|
full_line_progressbar=1;
|
|
|
|
|
/* we need 11 characters (full line) for progress-bar */
|
|
|
|
|
snprintf(buf, buf_size, " ");
|
|
|
|
|
return buf;
|
|
|
|
|
#endif
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'p': /* Playlist Position */
|
2002-10-29 12:09:15 +00:00
|
|
|
|
*flags |= WPS_REFRESH_STATIC;
|
2002-09-02 12:46:32 +00:00
|
|
|
|
snprintf(buf, buf_size, "%d", id3->index + 1);
|
|
|
|
|
return buf;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
2002-10-15 11:49:15 +00:00
|
|
|
|
case 'n': /* Playlist Name (without path) */
|
2002-10-29 12:09:15 +00:00
|
|
|
|
*flags |= WPS_REFRESH_STATIC;
|
2002-10-17 09:34:48 +00:00
|
|
|
|
return playlist_name(buf, buf_size);
|
2002-10-15 11:49:15 +00:00
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'e': /* Playlist Total Entries */
|
2002-10-29 12:09:15 +00:00
|
|
|
|
*flags |= WPS_REFRESH_STATIC;
|
2002-10-09 13:42:59 +00:00
|
|
|
|
snprintf(buf, buf_size, "%d", playlist_amount());
|
2002-09-02 12:46:32 +00:00
|
|
|
|
return buf;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'c': /* Current Time in Song */
|
2002-10-29 12:09:15 +00:00
|
|
|
|
*flags |= WPS_REFRESH_DYNAMIC;
|
2002-09-02 12:46:32 +00:00
|
|
|
|
format_time(buf, buf_size, id3->elapsed + ff_rewind_count);
|
|
|
|
|
return buf;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'r': /* Remaining Time in Song */
|
2002-10-29 12:09:15 +00:00
|
|
|
|
*flags |= WPS_REFRESH_DYNAMIC;
|
2002-09-04 03:54:13 +00:00
|
|
|
|
format_time(buf, buf_size,
|
|
|
|
|
id3->length - id3->elapsed - ff_rewind_count);
|
2002-09-02 12:46:32 +00:00
|
|
|
|
return buf;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 't': /* Total Time */
|
2002-10-29 12:09:15 +00:00
|
|
|
|
*flags |= WPS_REFRESH_STATIC;
|
2002-09-02 12:46:32 +00:00
|
|
|
|
format_time(buf, buf_size, id3->length);
|
|
|
|
|
return buf;
|
2002-09-27 09:31:31 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
case 'm': /* Peak Meter */
|
2002-10-29 12:09:15 +00:00
|
|
|
|
*flags |= WPS_REFRESH_PEAK_METER;
|
2002-09-27 09:31:31 +00:00
|
|
|
|
return "\x01";
|
|
|
|
|
#endif
|
2002-12-05 15:37:07 +00:00
|
|
|
|
case 's': /* shuffle */
|
|
|
|
|
if ( global_settings.playlist_shuffle )
|
|
|
|
|
return "s";
|
|
|
|
|
else
|
|
|
|
|
return NULL;
|
|
|
|
|
break;
|
2003-03-10 15:56:14 +00:00
|
|
|
|
|
|
|
|
|
case 'v': /* volume */
|
|
|
|
|
*flags |= WPS_REFRESH_DYNAMIC;
|
|
|
|
|
snprintf(buf, buf_size, "%d%%", global_settings.volume);
|
|
|
|
|
return buf;
|
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2002-12-05 15:37:07 +00:00
|
|
|
|
|
|
|
|
|
case 'b': /* battery info */
|
|
|
|
|
switch (tag[1]) {
|
|
|
|
|
case 'l': /* battery level */
|
|
|
|
|
snprintf(buf, buf_size, "%d%%", battery_level());
|
|
|
|
|
return buf;
|
|
|
|
|
|
|
|
|
|
case 't': /* estimated battery time */
|
|
|
|
|
snprintf(buf, buf_size, "%dh %dm",
|
|
|
|
|
battery_time() / 60,
|
|
|
|
|
battery_time() % 60);
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'd': /* Directory path information */
|
|
|
|
|
{
|
2002-09-07 12:34:10 +00:00
|
|
|
|
int level = tag[1] - '0';
|
2002-10-29 14:47:42 +00:00
|
|
|
|
*flags |= WPS_REFRESH_STATIC;
|
2002-09-07 12:34:10 +00:00
|
|
|
|
/* d1 through d9 */
|
|
|
|
|
if ((0 < level) && (9 > level))
|
|
|
|
|
{
|
|
|
|
|
return get_dir(buf, buf_size, id3->path, level);
|
|
|
|
|
}
|
2002-09-02 12:46:32 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Skip to the end of the current %? conditional.
|
|
|
|
|
*
|
|
|
|
|
* fmt - string to skip it. Should point to somewhere after the leading
|
|
|
|
|
* "<" char (and before or at the last ">").
|
|
|
|
|
* to_else - if true, skip to the else part (after the "|", if any), else skip
|
|
|
|
|
* to the end (the ">").
|
|
|
|
|
*
|
|
|
|
|
* Returns the new position in fmt.
|
|
|
|
|
*/
|
|
|
|
|
static char* skip_conditional(char* fmt, bool to_else)
|
|
|
|
|
{
|
|
|
|
|
int level = 1;
|
|
|
|
|
|
|
|
|
|
while (*fmt)
|
|
|
|
|
{
|
|
|
|
|
switch (*fmt++)
|
|
|
|
|
{
|
|
|
|
|
case '%':
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '|':
|
|
|
|
|
if (to_else && (1 == level))
|
|
|
|
|
return fmt;
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case '>':
|
|
|
|
|
if (0 == --level)
|
|
|
|
|
{
|
|
|
|
|
if (to_else)
|
|
|
|
|
fmt--;
|
|
|
|
|
|
|
|
|
|
return fmt;
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (*fmt++)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
case '%':
|
|
|
|
|
case '|':
|
|
|
|
|
case '<':
|
|
|
|
|
case '>':
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '?':
|
|
|
|
|
while (*fmt && ('<' != *fmt))
|
|
|
|
|
fmt++;
|
|
|
|
|
|
|
|
|
|
if ('<' == *fmt)
|
|
|
|
|
fmt++;
|
|
|
|
|
|
|
|
|
|
level++;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fmt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Generate the display based on id3 information and format string.
|
|
|
|
|
*
|
|
|
|
|
* buf - char buffer to write the display to.
|
|
|
|
|
* buf_size - the size of buffer.
|
|
|
|
|
* id3 - the ID3 data to format with.
|
|
|
|
|
* fmt - format description.
|
2002-10-29 12:09:15 +00:00
|
|
|
|
* flags - returns the type of the line. See constants i wps-display.h
|
2002-09-01 19:50:45 +00:00
|
|
|
|
*/
|
|
|
|
|
static void format_display(char* buf,
|
|
|
|
|
int buf_size,
|
|
|
|
|
struct mp3entry* id3,
|
|
|
|
|
char* fmt,
|
2002-10-29 12:09:15 +00:00
|
|
|
|
unsigned char* flags)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
|
|
|
|
char temp_buf[128];
|
|
|
|
|
char* buf_end = buf + buf_size - 1; /* Leave room for end null */
|
|
|
|
|
char* value = NULL;
|
|
|
|
|
int level = 0;
|
|
|
|
|
|
|
|
|
|
while (fmt && *fmt && buf < buf_end)
|
|
|
|
|
{
|
|
|
|
|
switch (*fmt)
|
|
|
|
|
{
|
|
|
|
|
case '%':
|
|
|
|
|
++fmt;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '|':
|
|
|
|
|
case '>':
|
|
|
|
|
if (level > 0)
|
|
|
|
|
{
|
|
|
|
|
fmt = skip_conditional(fmt, false);
|
|
|
|
|
level--;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
/* Else fall through */
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
*buf++ = *fmt++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (*fmt)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
*buf++ = '%';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 's':
|
2002-10-29 12:09:15 +00:00
|
|
|
|
*flags |= WPS_REFRESH_SCROLL;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
++fmt;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '%':
|
|
|
|
|
case '|':
|
|
|
|
|
case '<':
|
|
|
|
|
case '>':
|
|
|
|
|
*buf++ = *fmt++;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '?':
|
|
|
|
|
fmt++;
|
|
|
|
|
value = get_tag(id3, fmt, temp_buf, sizeof(temp_buf), flags);
|
|
|
|
|
|
|
|
|
|
while (*fmt && ('<' != *fmt))
|
|
|
|
|
fmt++;
|
|
|
|
|
|
|
|
|
|
if ('<' == *fmt)
|
|
|
|
|
fmt++;
|
|
|
|
|
|
|
|
|
|
/* No value, so skip to else part */
|
2003-03-10 14:02:52 +00:00
|
|
|
|
if ((!value) || (!strlen(value)))
|
2002-09-01 19:50:45 +00:00
|
|
|
|
fmt = skip_conditional(fmt, true);
|
|
|
|
|
|
|
|
|
|
level++;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
value = get_tag(id3, fmt, temp_buf, sizeof(temp_buf), flags);
|
|
|
|
|
fmt += 2;
|
|
|
|
|
|
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
while (*value && (buf < buf_end))
|
|
|
|
|
*buf++ = *value++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*buf = 0;
|
2002-11-05 23:49:08 +00:00
|
|
|
|
|
|
|
|
|
/* If no flags have been set, the line didn't contain any format codes.
|
|
|
|
|
We still want to refresh it. */
|
|
|
|
|
if(*flags == 0)
|
|
|
|
|
*flags = WPS_REFRESH_STATIC;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-10-29 12:09:15 +00:00
|
|
|
|
bool wps_refresh(struct mp3entry* id3, int ffwd_offset, unsigned char refresh_mode)
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-09-01 19:50:45 +00:00
|
|
|
|
char buf[MAX_PATH];
|
2002-10-29 12:09:15 +00:00
|
|
|
|
unsigned char flags;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
int i;
|
2002-10-30 23:01:27 +00:00
|
|
|
|
bool update_line;
|
2002-09-27 10:18:48 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-10-31 07:42:36 +00:00
|
|
|
|
int h = font_get(FONT_UI)->height;
|
2002-09-27 09:31:31 +00:00
|
|
|
|
/* to find out wether the peak meter is enabled we
|
|
|
|
|
assume it wasn't until we find a line that contains
|
|
|
|
|
the peak meter. We can't use peak_meter_enabled itself
|
|
|
|
|
because that would mean to turn off the meter thread
|
|
|
|
|
temporarily. (That shouldn't matter unless yield
|
|
|
|
|
or sleep is called but who knows...)
|
|
|
|
|
*/
|
|
|
|
|
bool enable_pm = false;
|
2002-09-27 10:18:48 +00:00
|
|
|
|
#endif
|
2003-01-13 11:48:41 +00:00
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2003-03-05 23:01:55 +00:00
|
|
|
|
for (i=0; i<8; i++) {
|
2003-02-27 14:00:36 +00:00
|
|
|
|
if (wps_progress_pat[i]==0)
|
|
|
|
|
wps_progress_pat[i]=lcd_get_locked_pattern();
|
|
|
|
|
}
|
2003-01-13 11:48:41 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-08-30 11:04:41 +00:00
|
|
|
|
if (!id3)
|
|
|
|
|
{
|
|
|
|
|
lcd_stop_scroll();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ff_rewind_count = ffwd_offset;
|
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
for (i = 0; i < MAX_LINES; i++)
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-10-30 23:01:27 +00:00
|
|
|
|
update_line = false;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
if ( !format_lines[i] )
|
|
|
|
|
break;
|
|
|
|
|
|
2002-10-29 12:09:15 +00:00
|
|
|
|
if ((line_type[i] & refresh_mode) ||
|
|
|
|
|
(refresh_mode == WPS_REFRESH_ALL))
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-10-29 12:09:15 +00:00
|
|
|
|
flags = 0;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
format_display(buf, sizeof(buf), id3, format_lines[i], &flags);
|
2002-10-29 12:09:15 +00:00
|
|
|
|
line_type[i] = flags;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
2003-01-22 12:48:12 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-10-29 12:09:15 +00:00
|
|
|
|
/* progress */
|
|
|
|
|
if (flags & refresh_mode & WPS_REFRESH_PLAYER_PROGRESS) {
|
2002-09-06 23:17:02 +00:00
|
|
|
|
int offset = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;
|
2003-01-28 17:00:49 +00:00
|
|
|
|
int percent=
|
|
|
|
|
id3->length?
|
|
|
|
|
(id3->elapsed + ff_rewind_count) * 100 / id3->length:0;
|
2002-09-06 23:17:02 +00:00
|
|
|
|
slidebar(0, i*h + offset + 1, LCD_WIDTH, 6,
|
2003-01-28 17:00:49 +00:00
|
|
|
|
percent, Grow_Right);
|
2002-10-30 23:01:27 +00:00
|
|
|
|
update_line = true;
|
2003-01-23 14:28:16 +00:00
|
|
|
|
}
|
|
|
|
|
if (flags & refresh_mode & WPS_REFRESH_PEAK_METER) {
|
|
|
|
|
/* peak meter */
|
|
|
|
|
int peak_meter_y;
|
|
|
|
|
int offset = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;
|
|
|
|
|
|
|
|
|
|
update_line = true;
|
|
|
|
|
peak_meter_y = i * h + offset;
|
|
|
|
|
|
|
|
|
|
/* The user might decide to have the peak meter in the last
|
|
|
|
|
line so that it is only displayed if no status bar is
|
|
|
|
|
visible. If so we neither want do draw nor enable the
|
|
|
|
|
peak meter. */
|
|
|
|
|
if (peak_meter_y + h <= LCD_HEIGHT) {
|
|
|
|
|
/* found a line with a peak meter -> remember that we must
|
|
|
|
|
enable it later */
|
|
|
|
|
enable_pm = true;
|
|
|
|
|
peak_meter_draw(0, peak_meter_y, LCD_WIDTH,
|
|
|
|
|
MIN(h, LCD_HEIGHT - peak_meter_y));
|
2002-10-31 07:42:36 +00:00
|
|
|
|
}
|
2002-10-29 12:09:15 +00:00
|
|
|
|
}
|
2003-01-22 12:48:12 +00:00
|
|
|
|
#else
|
|
|
|
|
/* progress */
|
|
|
|
|
if (flags & refresh_mode & WPS_REFRESH_PLAYER_PROGRESS) {
|
2003-02-27 14:00:36 +00:00
|
|
|
|
if (full_line_progressbar)
|
|
|
|
|
draw_player_fullbar(buf, sizeof(buf),
|
|
|
|
|
id3, ff_rewind_count);
|
|
|
|
|
else
|
|
|
|
|
draw_player_progress(id3, ff_rewind_count);
|
2003-01-22 12:48:12 +00:00
|
|
|
|
}
|
2003-01-23 14:28:16 +00:00
|
|
|
|
#endif
|
2003-01-22 12:48:12 +00:00
|
|
|
|
if (flags & WPS_REFRESH_SCROLL) {
|
2003-01-23 14:28:16 +00:00
|
|
|
|
/* scroll line */
|
|
|
|
|
if (refresh_mode & WPS_REFRESH_SCROLL) {
|
|
|
|
|
lcd_puts_scroll(0, i, buf);
|
2003-01-30 07:23:20 +00:00
|
|
|
|
update_line = true;
|
2003-01-23 14:28:16 +00:00
|
|
|
|
}
|
2003-01-22 12:48:12 +00:00
|
|
|
|
}
|
2002-10-30 23:01:27 +00:00
|
|
|
|
/* dynamic / static line */
|
2003-01-30 07:23:20 +00:00
|
|
|
|
else if ((flags & refresh_mode & WPS_REFRESH_DYNAMIC) ||
|
|
|
|
|
(flags & refresh_mode & WPS_REFRESH_STATIC))
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
2002-10-30 23:01:27 +00:00
|
|
|
|
update_line = true;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
lcd_puts(0, i, buf);
|
|
|
|
|
}
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
2002-10-31 07:42:36 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-10-30 23:01:27 +00:00
|
|
|
|
if (update_line) {
|
|
|
|
|
lcd_update_rect(0, i * h, LCD_WIDTH, h);
|
|
|
|
|
}
|
2002-10-31 07:42:36 +00:00
|
|
|
|
#endif
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
2002-09-27 10:18:48 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-09-27 09:31:31 +00:00
|
|
|
|
/* Now we know wether the peak meter is used.
|
|
|
|
|
So we can enable / disable the peak meter thread */
|
|
|
|
|
peak_meter_enabled = enable_pm;
|
2002-09-27 10:18:48 +00:00
|
|
|
|
#endif
|
2002-09-06 23:17:02 +00:00
|
|
|
|
|
2002-08-30 11:04:41 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-09 22:05:41 +00:00
|
|
|
|
bool wps_display(struct mp3entry* id3)
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
|
|
|
|
lcd_clear_display();
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
2002-09-24 07:49:16 +00:00
|
|
|
|
if (!id3 && !(mpeg_status() & MPEG_STATUS_PLAY))
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2002-09-18 14:08:05 +00:00
|
|
|
|
lcd_puts(0, 0, str(LANG_END_PLAYLIST_PLAYER));
|
2002-08-30 11:04:41 +00:00
|
|
|
|
#else
|
2002-09-18 14:08:05 +00:00
|
|
|
|
lcd_puts(0, 2, str(LANG_END_PLAYLIST_RECORDER));
|
2002-10-09 22:05:41 +00:00
|
|
|
|
lcd_update();
|
2002-08-30 11:04:41 +00:00
|
|
|
|
#endif
|
2003-01-28 22:33:55 +00:00
|
|
|
|
status_set_playmode(STATUS_STOP);
|
|
|
|
|
status_draw();
|
2002-10-09 22:05:41 +00:00
|
|
|
|
sleep(HZ);
|
|
|
|
|
return true;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2002-09-01 19:50:45 +00:00
|
|
|
|
if (!wps_loaded) {
|
|
|
|
|
if ( !format_buffer[0] ) {
|
2002-08-30 11:04:41 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2003-02-11 12:57:13 +00:00
|
|
|
|
wps_format("%s%?it<%?in<%in. |>%it|%fn>\n"
|
|
|
|
|
"%s%?ia<%ia|%?d2<%d2|(root)>>\n"
|
|
|
|
|
"%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n"
|
|
|
|
|
"\n"
|
|
|
|
|
"%pc/%pt [%pp:%pe]\n"
|
|
|
|
|
"%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n"
|
2002-09-27 09:31:31 +00:00
|
|
|
|
"%pb\n"
|
|
|
|
|
"%pm\n");
|
2002-08-30 11:04:41 +00:00
|
|
|
|
#else
|
2003-02-11 12:57:13 +00:00
|
|
|
|
wps_format("%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d2> - %?id<%id|%d1>\n"
|
|
|
|
|
"%pc%?ps<*|/>%pt\n");
|
2002-08-30 11:04:41 +00:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-01-23 14:28:16 +00:00
|
|
|
|
yield();
|
2002-10-29 12:09:15 +00:00
|
|
|
|
wps_refresh(id3, 0, WPS_REFRESH_ALL);
|
2002-08-30 11:04:41 +00:00
|
|
|
|
status_draw();
|
|
|
|
|
lcd_update();
|
2002-10-09 22:05:41 +00:00
|
|
|
|
return false;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-27 14:00:36 +00:00
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2003-01-13 11:48:41 +00:00
|
|
|
|
static bool draw_player_progress(struct mp3entry* id3, int ff_rewwind_count)
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-08-31 05:32:38 +00:00
|
|
|
|
char player_progressbar[7];
|
2002-08-30 13:08:37 +00:00
|
|
|
|
char binline[36];
|
2002-08-30 11:04:41 +00:00
|
|
|
|
int songpos = 0;
|
2002-08-30 13:08:37 +00:00
|
|
|
|
int i,j;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2002-10-11 11:39:36 +00:00
|
|
|
|
if (!id3)
|
|
|
|
|
return false;
|
|
|
|
|
|
2002-08-31 04:58:35 +00:00
|
|
|
|
memset(binline, 1, sizeof binline);
|
|
|
|
|
memset(player_progressbar, 1, sizeof player_progressbar);
|
2003-01-10 09:55:50 +00:00
|
|
|
|
|
2002-09-04 01:51:09 +00:00
|
|
|
|
if(id3->elapsed >= id3->length)
|
|
|
|
|
songpos = 0;
|
2002-08-31 04:58:35 +00:00
|
|
|
|
else
|
2002-09-04 01:51:09 +00:00
|
|
|
|
{
|
|
|
|
|
if(wps_time_countup == false)
|
|
|
|
|
songpos = ((id3->elapsed - ff_rewwind_count) * 36) / id3->length;
|
|
|
|
|
else
|
|
|
|
|
songpos = ((id3->elapsed + ff_rewwind_count) * 36) / id3->length;
|
|
|
|
|
}
|
2002-08-30 13:08:37 +00:00
|
|
|
|
for (i=0; i < songpos; i++)
|
2002-08-31 04:58:35 +00:00
|
|
|
|
binline[i] = 0;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
|
2002-08-30 13:08:37 +00:00
|
|
|
|
for (i=0; i<=6; i++) {
|
|
|
|
|
for (j=0;j<5;j++) {
|
|
|
|
|
player_progressbar[i] <<= 1;
|
|
|
|
|
player_progressbar[i] += binline[i*5+j];
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-02-27 14:00:36 +00:00
|
|
|
|
lcd_define_pattern(wps_progress_pat[0], player_progressbar);
|
2002-10-11 11:39:36 +00:00
|
|
|
|
return true;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
2003-02-27 14:00:36 +00:00
|
|
|
|
|
|
|
|
|
static void draw_player_fullbar(char* buf, int buf_size,
|
|
|
|
|
struct mp3entry* id3, int ff_rewwind_count)
|
|
|
|
|
{
|
2003-03-05 23:01:55 +00:00
|
|
|
|
int i,j,lcd_char_pos;
|
2003-02-27 14:00:36 +00:00
|
|
|
|
|
|
|
|
|
char player_progressbar[7];
|
|
|
|
|
char binline[36];
|
2003-03-05 23:01:55 +00:00
|
|
|
|
char numbers[12][4][3]={{{1,1,1},{1,0,1},{1,0,1},{1,1,1}},/*0*/
|
2003-02-27 14:00:36 +00:00
|
|
|
|
{{0,1,0},{1,1,0},{0,1,0},{0,1,0}},/*1*/
|
|
|
|
|
{{1,1,1},{0,0,1},{0,1,0},{1,1,1}},/*2*/
|
|
|
|
|
{{1,1,1},{0,0,1},{0,1,1},{1,1,1}},/*3*/
|
|
|
|
|
{{1,0,0},{1,1,0},{1,1,1},{0,1,0}},/*4*/
|
|
|
|
|
{{1,1,1},{1,1,0},{0,0,1},{1,1,0}},/*5*/
|
|
|
|
|
{{1,1,1},{1,0,0},{1,1,1},{1,1,1}},/*6*/
|
|
|
|
|
{{1,1,1},{0,0,1},{0,1,0},{1,0,0}},/*7*/
|
|
|
|
|
{{1,1,1},{1,1,1},{1,0,1},{1,1,1}},/*8*/
|
|
|
|
|
{{1,1,1},{1,1,1},{0,0,1},{1,1,1}},/*9*/
|
2003-03-05 23:01:55 +00:00
|
|
|
|
{{0,0,0},{0,1,0},{0,0,0},{0,1,0}},/*:*/
|
|
|
|
|
{{0,0,0},{0,0,0},{0,0,0},{0,0,0}}};/*<blank>*/
|
2003-02-27 14:00:36 +00:00
|
|
|
|
|
|
|
|
|
int songpos = 0;
|
2003-03-05 23:01:55 +00:00
|
|
|
|
int digits[6];
|
2003-02-27 14:20:08 +00:00
|
|
|
|
int time;
|
2003-03-05 23:01:55 +00:00
|
|
|
|
char timestr[7];
|
2003-02-27 14:20:08 +00:00
|
|
|
|
|
2003-02-27 14:00:36 +00:00
|
|
|
|
for (i=0; i < buf_size; i++)
|
|
|
|
|
buf[i] = ' ';
|
|
|
|
|
|
|
|
|
|
if(id3->elapsed >= id3->length)
|
2003-03-05 23:01:55 +00:00
|
|
|
|
songpos = 55;
|
2003-02-27 14:00:36 +00:00
|
|
|
|
else {
|
|
|
|
|
if(wps_time_countup == false)
|
|
|
|
|
songpos = ((id3->elapsed - ff_rewwind_count) * 55) / id3->length;
|
|
|
|
|
else
|
|
|
|
|
songpos = ((id3->elapsed + ff_rewwind_count) * 55) / id3->length;
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-27 14:20:08 +00:00
|
|
|
|
time=(id3->elapsed + ff_rewind_count);
|
2003-02-27 14:00:36 +00:00
|
|
|
|
|
2003-03-05 23:01:55 +00:00
|
|
|
|
memset(timestr, 0, sizeof(timestr));
|
|
|
|
|
format_time(timestr, sizeof(timestr), time);
|
|
|
|
|
for(lcd_char_pos=0; lcd_char_pos<6; lcd_char_pos++) {
|
|
|
|
|
digits[lcd_char_pos] = map_fullbar_char(timestr[lcd_char_pos]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* build the progressbar-icons */
|
|
|
|
|
for (lcd_char_pos=0; lcd_char_pos<6; lcd_char_pos++) {
|
2003-02-27 14:00:36 +00:00
|
|
|
|
memset(binline, 0, sizeof binline);
|
|
|
|
|
memset(player_progressbar, 0, sizeof player_progressbar);
|
|
|
|
|
|
|
|
|
|
/* make the character (progressbar & digit)*/
|
2003-03-05 23:01:55 +00:00
|
|
|
|
for (i=0; i<7; i++) {
|
2003-02-27 14:00:36 +00:00
|
|
|
|
for (j=0;j<5;j++) {
|
|
|
|
|
/* make the progressbar */
|
2003-03-05 23:01:55 +00:00
|
|
|
|
if (lcd_char_pos==(songpos/5)) {
|
2003-02-27 14:00:36 +00:00
|
|
|
|
/* partial */
|
|
|
|
|
if ((j<(songpos%5))&&(i>4))
|
|
|
|
|
binline[i*5+j] = 1;
|
|
|
|
|
else
|
|
|
|
|
binline[i*5+j] = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2003-03-05 23:01:55 +00:00
|
|
|
|
if (lcd_char_pos<(songpos/5)) {
|
2003-02-27 14:00:36 +00:00
|
|
|
|
/* full character */
|
|
|
|
|
if (i>4)
|
|
|
|
|
binline[i*5+j] = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* insert the digit */
|
|
|
|
|
if ((j<3)&&(i<4)) {
|
2003-03-05 23:01:55 +00:00
|
|
|
|
if (numbers[digits[lcd_char_pos]][i][j]==1)
|
2003-02-27 14:00:36 +00:00
|
|
|
|
binline[i*5+j] = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i=0; i<=6; i++) {
|
|
|
|
|
for (j=0;j<5;j++) {
|
|
|
|
|
player_progressbar[i] <<= 1;
|
|
|
|
|
player_progressbar[i] += binline[i*5+j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-05 23:01:55 +00:00
|
|
|
|
lcd_define_pattern(wps_progress_pat[lcd_char_pos+1],player_progressbar);
|
|
|
|
|
buf[lcd_char_pos]=wps_progress_pat[lcd_char_pos+1];
|
2003-02-27 14:00:36 +00:00
|
|
|
|
|
|
|
|
|
}
|
2003-03-05 23:01:55 +00:00
|
|
|
|
|
2003-02-27 14:00:36 +00:00
|
|
|
|
/* make rest of the progressbar if necessary */
|
2003-03-05 23:01:55 +00:00
|
|
|
|
if (songpos/5>5) {
|
2003-02-27 14:00:36 +00:00
|
|
|
|
|
2003-03-05 23:01:55 +00:00
|
|
|
|
/* set the characters positions that use the full 5 pixel wide bar */
|
|
|
|
|
for (lcd_char_pos=6; lcd_char_pos < (songpos/5); lcd_char_pos++)
|
|
|
|
|
buf[lcd_char_pos] = 0x86; /* '_' */
|
|
|
|
|
|
|
|
|
|
/* build the partial bar character for the tail character position */
|
2003-02-27 14:00:36 +00:00
|
|
|
|
memset(binline, 0, sizeof binline);
|
|
|
|
|
memset(player_progressbar, 0, sizeof player_progressbar);
|
|
|
|
|
|
2003-03-05 23:01:55 +00:00
|
|
|
|
for (i=5; i<7; i++) {
|
2003-02-27 14:00:36 +00:00
|
|
|
|
for (j=0;j<5;j++) {
|
|
|
|
|
if (j<(songpos%5)) {
|
|
|
|
|
binline[i*5+j] = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-05 23:01:55 +00:00
|
|
|
|
for (i=0; i<7; i++) {
|
2003-02-27 14:00:36 +00:00
|
|
|
|
for (j=0;j<5;j++) {
|
|
|
|
|
player_progressbar[i] <<= 1;
|
|
|
|
|
player_progressbar[i] += binline[i*5+j];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-05 23:01:55 +00:00
|
|
|
|
lcd_define_pattern(wps_progress_pat[7],player_progressbar);
|
2003-02-27 14:00:36 +00:00
|
|
|
|
|
2003-03-05 23:01:55 +00:00
|
|
|
|
buf[songpos/5]=wps_progress_pat[7];
|
2003-02-27 14:00:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-05 23:01:55 +00:00
|
|
|
|
static char map_fullbar_char(char ascii_val)
|
|
|
|
|
{
|
|
|
|
|
if (ascii_val >= '0' && ascii_val <= '9') {
|
|
|
|
|
return(ascii_val - '0');
|
|
|
|
|
}
|
|
|
|
|
else if (ascii_val == ':') {
|
|
|
|
|
return(10);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return(11); /* anything besides a number or ':' is mapped to <blank> */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-30 11:04:41 +00:00
|
|
|
|
#endif
|
2002-10-31 07:42:36 +00:00
|
|
|
|
|
|
|
|
|
/* -----------------------------------------------------------------
|
|
|
|
|
* vim: et sw=4 ts=8 sts=4 tw=78
|
|
|
|
|
*/
|