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
|
|
|
|
|
2004-05-19 08:30:48 +00:00
|
|
|
|
/* ID3 formatting based on code from the MAD Winamp plugin (in_mad.dll),
|
|
|
|
|
* Copyright (C) 2000-2001 Robert Leslie.
|
2002-09-01 19:50:45 +00:00
|
|
|
|
* 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"
|
2003-03-17 00:57:39 +00:00
|
|
|
|
#include "hwcompat.h"
|
2002-09-12 13:33:59 +00:00
|
|
|
|
#include "font.h"
|
2005-04-04 12:06:29 +00:00
|
|
|
|
#include "audio.h"
|
2002-08-30 11:04:41 +00:00
|
|
|
|
#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"
|
2003-04-23 09:17:34 +00:00
|
|
|
|
#include "backlight.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
|
2005-06-07 13:46:48 +00:00
|
|
|
|
#define MAX_LINES (LCD_HEIGHT/5+1)
|
2004-01-14 07:59:06 +00:00
|
|
|
|
#define FORMAT_BUFFER_SIZE 800
|
2002-09-02 12:46:32 +00:00
|
|
|
|
#else
|
|
|
|
|
#define MAX_LINES 2
|
2004-01-14 07:59:06 +00:00
|
|
|
|
#define FORMAT_BUFFER_SIZE 400
|
2002-09-02 12:46:32 +00:00
|
|
|
|
#endif
|
2004-01-14 07:59:06 +00:00
|
|
|
|
#define MAX_SUBLINES 12
|
|
|
|
|
#define DEFAULT_SUBLINE_TIME_MULTIPLIER 20 /* (10ths of sec) */
|
2004-05-19 08:30:48 +00:00
|
|
|
|
#define BASE_SUBLINE_TIME 10 /* base time that multiplier is applied to
|
2004-01-14 07:59:06 +00:00
|
|
|
|
(1/HZ sec, or 100ths of sec) */
|
|
|
|
|
#define SUBLINE_RESET -1
|
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;
|
2004-08-18 01:09:31 +00:00
|
|
|
|
static bool draw_player_progress(const 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,
|
2004-08-18 01:09:31 +00:00
|
|
|
|
const 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];
|
2004-01-14 07:59:06 +00:00
|
|
|
|
static char* format_lines[MAX_LINES][MAX_SUBLINES];
|
|
|
|
|
static unsigned char line_type[MAX_LINES][MAX_SUBLINES];
|
2004-10-25 13:14:26 +00:00
|
|
|
|
static unsigned short time_mult[MAX_LINES][MAX_SUBLINES];
|
2004-05-19 08:30:48 +00:00
|
|
|
|
static long subline_expire_time[MAX_LINES];
|
2004-01-14 07:59:06 +00:00
|
|
|
|
static int curr_subline[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-09-01 19:50:45 +00:00
|
|
|
|
/* Set format string to use for WPS, splitting it into lines */
|
2004-08-18 01:09:31 +00:00
|
|
|
|
static void wps_format(const char* fmt)
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-09-01 19:50:45 +00:00
|
|
|
|
char* buf = format_buffer;
|
2003-11-04 13:46:37 +00:00
|
|
|
|
char* start_of_line = format_buffer;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
int line = 0;
|
2004-01-14 07:59:06 +00:00
|
|
|
|
int subline;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
strncpy(format_buffer, fmt, sizeof(format_buffer));
|
|
|
|
|
format_buffer[sizeof(format_buffer) - 1] = 0;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2004-01-14 07:59:06 +00:00
|
|
|
|
for (line=0; line<MAX_LINES; line++)
|
|
|
|
|
{
|
|
|
|
|
for (subline=0; subline<MAX_SUBLINES; subline++)
|
|
|
|
|
{
|
|
|
|
|
format_lines[line][subline] = 0;
|
|
|
|
|
time_mult[line][subline] = 0;
|
|
|
|
|
}
|
|
|
|
|
subline_expire_time[line] = 0;
|
|
|
|
|
curr_subline[line] = SUBLINE_RESET;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
line = 0;
|
|
|
|
|
subline = 0;
|
|
|
|
|
format_lines[line][subline] = buf;
|
|
|
|
|
|
2003-12-04 14:06:00 +00:00
|
|
|
|
while ((*buf) && (line < MAX_LINES))
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
2002-09-04 14:17:41 +00:00
|
|
|
|
switch (*buf)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
2004-01-14 07:59:06 +00:00
|
|
|
|
/* skip % sequences so "%;" doesn't start a new subline */
|
2004-05-19 08:30:48 +00:00
|
|
|
|
case '%':
|
2004-01-14 07:59:06 +00:00
|
|
|
|
buf++;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '\r': /* CR */
|
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;
|
2003-11-04 13:46:37 +00:00
|
|
|
|
|
2004-01-14 07:59:06 +00:00
|
|
|
|
if (*start_of_line != '#') /* A comment? */
|
2003-11-04 13:46:37 +00:00
|
|
|
|
line++;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2003-12-04 14:06:00 +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 */
|
2004-01-14 07:59:06 +00:00
|
|
|
|
subline = 0;
|
|
|
|
|
format_lines[line][subline] = buf+1;
|
|
|
|
|
start_of_line = format_lines[line][subline];
|
2002-09-01 19:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2003-12-04 14:06:00 +00:00
|
|
|
|
|
2004-01-14 07:59:06 +00:00
|
|
|
|
case ';': /* start a new subline */
|
|
|
|
|
*buf = 0;
|
|
|
|
|
subline++;
|
|
|
|
|
if (subline < MAX_SUBLINES)
|
|
|
|
|
{
|
|
|
|
|
format_lines[line][subline] = buf+1;
|
|
|
|
|
}
|
|
|
|
|
else /* exceeded max sublines, skip rest of line */
|
|
|
|
|
{
|
2004-05-19 08:30:48 +00:00
|
|
|
|
while (*(++buf))
|
2004-01-14 07:59:06 +00:00
|
|
|
|
{
|
|
|
|
|
if ((*buf == '\r') || (*buf == '\n'))
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
buf--;
|
|
|
|
|
subline = 0;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-12-04 14:06:00 +00:00
|
|
|
|
}
|
2004-01-14 07:59:06 +00:00
|
|
|
|
buf++;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-18 01:09:31 +00:00
|
|
|
|
bool wps_load(const char* file, bool display)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
2004-01-14 07:59:06 +00:00
|
|
|
|
int i, s;
|
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);
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2003-04-30 02:55:23 +00:00
|
|
|
|
if (fd >= 0)
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-09-01 19:50:45 +00:00
|
|
|
|
int numread = read(fd, buffer, sizeof(buffer) - 1);
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
if (numread > 0)
|
|
|
|
|
{
|
|
|
|
|
buffer[numread] = 0;
|
|
|
|
|
wps_format(buffer);
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
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 ) {
|
2004-01-14 07:59:06 +00:00
|
|
|
|
bool any_defined_line;
|
2002-09-02 12:46:32 +00:00
|
|
|
|
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
|
2004-01-14 07:59:06 +00:00
|
|
|
|
for (s=0; s<MAX_SUBLINES; s++)
|
|
|
|
|
{
|
|
|
|
|
any_defined_line = false;
|
|
|
|
|
for (i=0; i<MAX_LINES; i++)
|
|
|
|
|
{
|
2004-05-19 08:30:48 +00:00
|
|
|
|
if (format_lines[i][s])
|
2004-01-14 07:59:06 +00:00
|
|
|
|
{
|
|
|
|
|
if (*format_lines[i][s] == 0)
|
|
|
|
|
lcd_puts(0,i," ");
|
|
|
|
|
else
|
|
|
|
|
lcd_puts(0,i,format_lines[i][s]);
|
|
|
|
|
any_defined_line = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lcd_puts(0,i," ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (any_defined_line)
|
|
|
|
|
{
|
|
|
|
|
lcd_update();
|
|
|
|
|
sleep(HZ/2);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-09-02 12:46:32 +00:00
|
|
|
|
}
|
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
|
|
|
|
}
|
2004-05-19 08:30:48 +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.
|
|
|
|
|
*/
|
2005-02-12 12:40:35 +00:00
|
|
|
|
static void format_time(char* buf, int buf_size, long time)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
2004-07-14 10:18:11 +00:00
|
|
|
|
if ( time < 3600000 ) {
|
|
|
|
|
snprintf(buf, buf_size, "%d:%02d",
|
2005-02-12 12:40:35 +00:00
|
|
|
|
(int) (time % 3600000 / 60000), (int) (time % 60000 / 1000));
|
2004-07-14 10:18:11 +00:00
|
|
|
|
} else {
|
|
|
|
|
snprintf(buf, buf_size, "%d:%02d:%02d",
|
2005-02-12 12:40:35 +00:00
|
|
|
|
(int) (time / 3600000), (int) (time % 3600000 / 60000),
|
|
|
|
|
(int) (time % 60000 / 1000));
|
2004-07-14 10:18:11 +00:00
|
|
|
|
}
|
2002-09-01 19:50:45 +00:00
|
|
|
|
}
|
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.
|
2004-05-19 08:30:48 +00:00
|
|
|
|
* level - what to extract. 0 is file name, 1 is parent of file, 2 is
|
2002-09-01 19:50:45 +00:00
|
|
|
|
* parent of parent, etc.
|
|
|
|
|
*
|
|
|
|
|
* Returns buf if the desired level was found, NULL otherwise.
|
|
|
|
|
*/
|
2004-08-18 01:09:31 +00:00
|
|
|
|
static char* get_dir(char* buf, int buf_size, const char* path, int level)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
2004-08-18 01:09:31 +00:00
|
|
|
|
const char* sep;
|
|
|
|
|
const char* last_sep;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
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
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
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.
|
2004-05-19 08:30:48 +00:00
|
|
|
|
* nid3 - next-song ID3 data to get tag values from.
|
2002-09-01 19:50:45 +00:00
|
|
|
|
* tag - string (of two characters) specifying the tag to get.
|
2004-05-19 08:30:48 +00:00
|
|
|
|
* buf - buffer to certain tags, such as track number, play time or
|
2002-09-01 19:50:45 +00:00
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2004-05-19 08:30:48 +00:00
|
|
|
|
static char* get_tag(struct mp3entry* cid3,
|
|
|
|
|
struct mp3entry* nid3,
|
2004-08-18 01:09:31 +00:00
|
|
|
|
const char* tag,
|
2004-05-19 08:30:48 +00:00
|
|
|
|
char* buf,
|
2002-09-02 12:46:32 +00:00
|
|
|
|
int buf_size,
|
2004-01-14 07:59:06 +00:00
|
|
|
|
unsigned char* tag_len,
|
2004-10-25 13:14:26 +00:00
|
|
|
|
unsigned short* subline_time_mult,
|
2002-10-29 12:09:15 +00:00
|
|
|
|
unsigned char* flags)
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2004-05-19 08:30:48 +00:00
|
|
|
|
struct mp3entry *id3 = cid3; /* default to current song */
|
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
if ((0 == tag[0]) || (0 == tag[1]))
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2004-01-14 07:59:06 +00:00
|
|
|
|
*tag_len = 0;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2004-01-14 07:59:06 +00:00
|
|
|
|
*tag_len = 2;
|
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
switch (tag[0])
|
|
|
|
|
{
|
2004-05-19 08:30:48 +00:00
|
|
|
|
case 'I': /* ID3 Information */
|
|
|
|
|
id3 = nid3; /* display next-song data */
|
2004-05-21 22:17:23 +00:00
|
|
|
|
*flags |= WPS_REFRESH_DYNAMIC;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
if(!id3)
|
|
|
|
|
return NULL; /* no such info (yet) */
|
|
|
|
|
/* fall-through */
|
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;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'n': /* ID3 Track Number */
|
2003-06-04 15:09:35 +00:00
|
|
|
|
if (id3->track_string)
|
|
|
|
|
return id3->track_string;
|
|
|
|
|
|
|
|
|
|
if (id3->tracknum) {
|
2002-09-02 12:46:32 +00:00
|
|
|
|
snprintf(buf, buf_size, "%d", id3->tracknum);
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
2003-06-04 15:09:35 +00:00
|
|
|
|
return NULL;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-02 12:46:32 +00:00
|
|
|
|
case 'd': /* ID3 Album/Disc */
|
|
|
|
|
return id3->album;
|
2002-12-05 14:55:14 +00:00
|
|
|
|
|
2003-06-04 15:09:35 +00:00
|
|
|
|
case 'c': /* ID3 Composer */
|
|
|
|
|
return id3->composer;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-12-05 14:55:14 +00:00
|
|
|
|
case 'y': /* year */
|
2003-06-04 15:09:35 +00:00
|
|
|
|
if( id3->year_string )
|
|
|
|
|
return id3->year_string;
|
|
|
|
|
|
2002-12-05 14:55:14 +00:00
|
|
|
|
if (id3->year) {
|
|
|
|
|
snprintf(buf, buf_size, "%d", id3->year);
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
2003-06-04 15:09:35 +00:00
|
|
|
|
return NULL;
|
2002-12-05 15:21:18 +00:00
|
|
|
|
|
|
|
|
|
case 'g': /* genre */
|
2004-05-22 01:38:41 +00:00
|
|
|
|
return id3_get_genre(id3);
|
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
|
|
|
|
|
2004-05-19 08:30:48 +00:00
|
|
|
|
case 'F': /* File Information */
|
|
|
|
|
id3 = nid3;
|
2004-05-21 22:17:23 +00:00
|
|
|
|
*flags |= WPS_REFRESH_DYNAMIC;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
if(!id3)
|
|
|
|
|
return NULL; /* no such info (yet) */
|
|
|
|
|
/* fall-through */
|
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 */
|
2003-04-01 15:32:03 +00:00
|
|
|
|
if(id3->bitrate)
|
|
|
|
|
snprintf(buf, buf_size, "%d", id3->bitrate);
|
|
|
|
|
else
|
|
|
|
|
snprintf(buf, buf_size, "?");
|
2002-09-02 12:46:32 +00:00
|
|
|
|
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
|
2004-11-22 21:20:54 +00:00
|
|
|
|
if(is_new_player()) {
|
2003-03-17 00:57:39 +00:00
|
|
|
|
*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, " ");
|
2003-12-12 13:34:27 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-03-17 00:57:39 +00:00
|
|
|
|
/* Tell the user if we have an OldPlayer */
|
|
|
|
|
snprintf(buf, buf_size, " <Old LCD> ");
|
|
|
|
|
}
|
2003-02-27 14:00:36 +00:00
|
|
|
|
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;
|
2003-07-01 21:05:43 +00:00
|
|
|
|
snprintf(buf, buf_size, "%d", playlist_get_display_index());
|
2002-09-02 12:46:32 +00:00
|
|
|
|
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;
|
2004-01-26 17:05:21 +00:00
|
|
|
|
return playlist_name(NULL, 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;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
format_time(buf, buf_size,
|
2002-09-04 03:54:13 +00:00
|
|
|
|
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 */
|
2004-03-02 07:56:58 +00:00
|
|
|
|
*flags |= WPS_REFRESH_DYNAMIC;
|
2002-12-05 15:37:07 +00:00
|
|
|
|
switch (tag[1]) {
|
|
|
|
|
case 'l': /* battery level */
|
2004-03-21 15:59:41 +00:00
|
|
|
|
{
|
|
|
|
|
int l = battery_level();
|
|
|
|
|
if (l > -1)
|
2004-03-21 16:25:08 +00:00
|
|
|
|
snprintf(buf, buf_size, "%d%%", l);
|
2004-03-21 15:59:41 +00:00
|
|
|
|
else
|
|
|
|
|
return "?%";
|
2002-12-05 15:37:07 +00:00
|
|
|
|
return buf;
|
2004-03-21 15:59:41 +00:00
|
|
|
|
}
|
2002-12-05 15:37:07 +00:00
|
|
|
|
|
|
|
|
|
case 't': /* estimated battery time */
|
2003-11-19 14:14:41 +00:00
|
|
|
|
{
|
|
|
|
|
int t = battery_time();
|
|
|
|
|
if (t >= 0)
|
|
|
|
|
snprintf(buf, buf_size, "%dh %dm", t / 60, t % 60);
|
|
|
|
|
else
|
|
|
|
|
strncpy(buf, "?h ?m", buf_size);
|
2002-12-05 15:37:07 +00:00
|
|
|
|
return buf;
|
2003-11-19 14:14:41 +00:00
|
|
|
|
}
|
2002-12-05 15:37:07 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2004-05-19 08:30:48 +00:00
|
|
|
|
case 'D': /* Directory path information */
|
|
|
|
|
id3 = nid3; /* next song please! */
|
2004-05-21 22:17:23 +00:00
|
|
|
|
*flags |= WPS_REFRESH_DYNAMIC;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
if(!id3)
|
|
|
|
|
return NULL; /* no such info (yet) */
|
|
|
|
|
/* fall-through */
|
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;
|
2004-01-14 07:59:06 +00:00
|
|
|
|
|
|
|
|
|
case 't': /* set sub line time multiplier */
|
2004-05-19 08:30:48 +00:00
|
|
|
|
{
|
2004-01-14 07:59:06 +00:00
|
|
|
|
int d = 1;
|
|
|
|
|
int time_mult = 0;
|
|
|
|
|
bool have_point = false;
|
|
|
|
|
bool have_tenth = false;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
|
|
|
|
while (((tag[d] >= '0') &&
|
2004-01-14 07:59:06 +00:00
|
|
|
|
(tag[d] <= '9')) ||
|
2004-05-19 08:30:48 +00:00
|
|
|
|
(tag[d] == '.'))
|
2004-01-14 07:59:06 +00:00
|
|
|
|
{
|
2004-05-19 08:30:48 +00:00
|
|
|
|
if (tag[d] != '.')
|
2004-01-14 07:59:06 +00:00
|
|
|
|
{
|
|
|
|
|
time_mult = time_mult * 10;
|
|
|
|
|
time_mult = time_mult + tag[d] - '0';
|
2004-05-19 08:30:48 +00:00
|
|
|
|
if (have_point)
|
2004-01-14 07:59:06 +00:00
|
|
|
|
{
|
|
|
|
|
have_tenth = true;
|
|
|
|
|
d++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
else
|
2004-01-14 07:59:06 +00:00
|
|
|
|
{
|
|
|
|
|
have_point = true;
|
|
|
|
|
}
|
|
|
|
|
d++;
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2004-01-14 07:59:06 +00:00
|
|
|
|
if (have_tenth == false)
|
|
|
|
|
time_mult *= 10;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
|
|
|
|
*subline_time_mult = time_mult;
|
2004-01-14 07:59:06 +00:00
|
|
|
|
*tag_len = d;
|
|
|
|
|
|
|
|
|
|
buf[0] = 0;
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2002-08-30 11:04:41 +00:00
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Skip to the end of the current %? conditional.
|
|
|
|
|
*
|
2004-05-19 08:30:48 +00:00
|
|
|
|
* fmt - string to skip it. Should point to somewhere after the leading
|
2002-09-01 19:50:45 +00:00
|
|
|
|
* "<" 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.
|
|
|
|
|
*/
|
2004-08-18 01:09:31 +00:00
|
|
|
|
static const char* skip_conditional(const char* fmt, bool to_else)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
|
|
|
|
int level = 1;
|
|
|
|
|
|
|
|
|
|
while (*fmt)
|
|
|
|
|
{
|
|
|
|
|
switch (*fmt++)
|
|
|
|
|
{
|
|
|
|
|
case '%':
|
|
|
|
|
break;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
case '|':
|
|
|
|
|
if (to_else && (1 == level))
|
|
|
|
|
return fmt;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
continue;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
case '>':
|
2004-05-19 08:30:48 +00:00
|
|
|
|
if (0 == --level)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
|
|
|
|
if (to_else)
|
|
|
|
|
fmt--;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
return fmt;
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
switch (*fmt++)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
case '%':
|
|
|
|
|
case '|':
|
|
|
|
|
case '<':
|
|
|
|
|
case '>':
|
|
|
|
|
break;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
case '?':
|
|
|
|
|
while (*fmt && ('<' != *fmt))
|
|
|
|
|
fmt++;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
if ('<' == *fmt)
|
|
|
|
|
fmt++;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
level++;
|
|
|
|
|
break;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
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.
|
2004-05-19 08:30:48 +00:00
|
|
|
|
* nid3 - the ID3 data of the next song (might by NULL)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
* 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
|
|
|
|
*/
|
2004-05-19 08:30:48 +00:00
|
|
|
|
static void format_display(char* buf,
|
|
|
|
|
int buf_size,
|
|
|
|
|
struct mp3entry* id3,
|
|
|
|
|
struct mp3entry* nid3, /* next song's id3 */
|
2004-08-18 01:09:31 +00:00
|
|
|
|
const char* fmt,
|
2004-10-25 13:14:26 +00:00
|
|
|
|
unsigned short* subline_time_mult,
|
2002-10-29 12:09:15 +00:00
|
|
|
|
unsigned char* flags)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
|
|
|
|
char temp_buf[128];
|
2004-01-14 07:59:06 +00:00
|
|
|
|
char* buf_start = buf;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
char* buf_end = buf + buf_size - 1; /* Leave room for end null */
|
|
|
|
|
char* value = NULL;
|
|
|
|
|
int level = 0;
|
2004-01-14 07:59:06 +00:00
|
|
|
|
unsigned char tag_length;
|
|
|
|
|
|
|
|
|
|
*subline_time_mult = DEFAULT_SUBLINE_TIME_MULTIPLIER;
|
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
while (fmt && *fmt && buf < buf_end)
|
|
|
|
|
{
|
|
|
|
|
switch (*fmt)
|
|
|
|
|
{
|
|
|
|
|
case '%':
|
|
|
|
|
++fmt;
|
|
|
|
|
break;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
case '|':
|
|
|
|
|
case '>':
|
2004-05-19 08:30:48 +00:00
|
|
|
|
if (level > 0)
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
|
|
|
|
fmt = skip_conditional(fmt, false);
|
|
|
|
|
level--;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
/* Else fall through */
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
*buf++ = *fmt++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
switch (*fmt)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
*buf++ = '%';
|
|
|
|
|
break;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
case 's':
|
2002-10-29 12:09:15 +00:00
|
|
|
|
*flags |= WPS_REFRESH_SCROLL;
|
2002-09-01 19:50:45 +00:00
|
|
|
|
++fmt;
|
|
|
|
|
break;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
case '%':
|
|
|
|
|
case '|':
|
|
|
|
|
case '<':
|
|
|
|
|
case '>':
|
2004-01-14 07:59:06 +00:00
|
|
|
|
case ';':
|
2002-09-01 19:50:45 +00:00
|
|
|
|
*buf++ = *fmt++;
|
|
|
|
|
break;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
case '?':
|
|
|
|
|
fmt++;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
value = get_tag(id3, nid3, fmt, temp_buf, sizeof(temp_buf),
|
2004-01-14 07:59:06 +00:00
|
|
|
|
&tag_length, subline_time_mult, flags);
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
while (*fmt && ('<' != *fmt))
|
|
|
|
|
fmt++;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
if ('<' == *fmt)
|
|
|
|
|
fmt++;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
/* 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;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
default:
|
2004-05-19 08:30:48 +00:00
|
|
|
|
value = get_tag(id3, nid3, fmt, temp_buf, sizeof(temp_buf),
|
2004-01-14 07:59:06 +00:00
|
|
|
|
&tag_length, subline_time_mult, flags);
|
|
|
|
|
fmt += tag_length;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
if (value)
|
|
|
|
|
{
|
|
|
|
|
while (*value && (buf < buf_end))
|
|
|
|
|
*buf++ = *value++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-09-01 19:50:45 +00:00
|
|
|
|
*buf = 0;
|
2002-11-05 23:49:08 +00:00
|
|
|
|
|
2004-01-14 07:59:06 +00:00
|
|
|
|
/* if resulting line is an empty line, set the subline time to 0 */
|
|
|
|
|
if (*buf_start == 0)
|
|
|
|
|
*subline_time_mult = 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
|
|
|
|
}
|
|
|
|
|
|
2004-05-19 08:30:48 +00:00
|
|
|
|
bool wps_refresh(struct mp3entry* id3,
|
|
|
|
|
struct mp3entry* nid3,
|
|
|
|
|
int ffwd_offset,
|
2004-01-14 07:59:06 +00:00
|
|
|
|
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;
|
2004-01-14 07:59:06 +00:00
|
|
|
|
bool only_one_subline;
|
|
|
|
|
bool new_subline_refresh;
|
|
|
|
|
int search;
|
|
|
|
|
int search_start;
|
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;
|
2003-08-06 16:16:21 +00:00
|
|
|
|
int offset = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;
|
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
|
2004-05-19 08:30:48 +00:00
|
|
|
|
because that would mean to turn off the meter thread
|
|
|
|
|
temporarily. (That shouldn't matter unless yield
|
2002-09-27 09:31:31 +00:00
|
|
|
|
or sleep is called but who knows...)
|
|
|
|
|
*/
|
|
|
|
|
bool enable_pm = false;
|
2002-09-27 10:18:48 +00:00
|
|
|
|
#endif
|
2004-01-14 07:59:06 +00:00
|
|
|
|
|
|
|
|
|
/* reset to first subline if refresh all flag is set */
|
|
|
|
|
if (refresh_mode == WPS_REFRESH_ALL)
|
|
|
|
|
{
|
|
|
|
|
for (i=0; i<MAX_LINES; i++)
|
|
|
|
|
{
|
|
|
|
|
curr_subline[i] = SUBLINE_RESET;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
{
|
2004-01-14 07:59:06 +00:00
|
|
|
|
new_subline_refresh = false;
|
|
|
|
|
only_one_subline = false;
|
|
|
|
|
|
|
|
|
|
/* if time to advance to next sub-line */
|
|
|
|
|
if (TIME_AFTER(current_tick, subline_expire_time[i] - 1) ||
|
2004-05-19 08:30:48 +00:00
|
|
|
|
(curr_subline[i] == SUBLINE_RESET))
|
2004-01-14 07:59:06 +00:00
|
|
|
|
{
|
|
|
|
|
/* search all sublines until the next subline with time > 0
|
|
|
|
|
is found or we get back to the subline we started with */
|
|
|
|
|
if (curr_subline[i] == SUBLINE_RESET)
|
|
|
|
|
search_start = 0;
|
|
|
|
|
else
|
|
|
|
|
search_start = curr_subline[i];
|
2004-05-19 08:30:48 +00:00
|
|
|
|
for (search=0; search<MAX_SUBLINES; search++)
|
2004-01-14 07:59:06 +00:00
|
|
|
|
{
|
|
|
|
|
curr_subline[i]++;
|
|
|
|
|
|
|
|
|
|
/* wrap around if beyond last defined subline or MAX_SUBLINES */
|
|
|
|
|
if ((!format_lines[i][curr_subline[i]]) ||
|
|
|
|
|
(curr_subline[i] == MAX_SUBLINES))
|
|
|
|
|
{
|
|
|
|
|
if (curr_subline[i] == 1)
|
|
|
|
|
only_one_subline = true;
|
|
|
|
|
curr_subline[i] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* if back where we started after search or
|
|
|
|
|
only one subline is defined on the line */
|
|
|
|
|
if (((search > 0) && (curr_subline[i] == search_start)) ||
|
|
|
|
|
only_one_subline)
|
|
|
|
|
{
|
|
|
|
|
/* no other subline with a time > 0 exists */
|
|
|
|
|
subline_expire_time[i] = current_tick + 100 * HZ;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-05-19 08:30:48 +00:00
|
|
|
|
/* get initial time multiplier and
|
2004-01-14 07:59:06 +00:00
|
|
|
|
line type flags for this subline */
|
2004-05-19 08:30:48 +00:00
|
|
|
|
format_display(buf, sizeof(buf), id3, nid3,
|
|
|
|
|
format_lines[i][curr_subline[i]],
|
2004-01-14 07:59:06 +00:00
|
|
|
|
&time_mult[i][curr_subline[i]],
|
|
|
|
|
&line_type[i][curr_subline[i]]);
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2004-01-14 07:59:06 +00:00
|
|
|
|
/* only use this subline if subline time > 0 */
|
|
|
|
|
if (time_mult[i][curr_subline[i]] > 0)
|
|
|
|
|
{
|
|
|
|
|
new_subline_refresh = true;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
subline_expire_time[i] = current_tick +
|
|
|
|
|
BASE_SUBLINE_TIME * time_mult[i][curr_subline[i]];
|
2004-01-14 07:59:06 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2002-10-30 23:01:27 +00:00
|
|
|
|
update_line = false;
|
2004-01-14 07:59:06 +00:00
|
|
|
|
|
|
|
|
|
if ( !format_lines[i][curr_subline[i]] )
|
2002-09-01 19:50:45 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2004-05-19 08:30:48 +00:00
|
|
|
|
if ((line_type[i][curr_subline[i]] & refresh_mode) ||
|
2004-01-14 07:59:06 +00:00
|
|
|
|
(refresh_mode == WPS_REFRESH_ALL) ||
|
|
|
|
|
new_subline_refresh)
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
2002-10-29 12:09:15 +00:00
|
|
|
|
flags = 0;
|
2004-05-19 08:30:48 +00:00
|
|
|
|
format_display(buf, sizeof(buf), id3, nid3,
|
2004-01-14 07:59:06 +00:00
|
|
|
|
format_lines[i][curr_subline[i]],
|
|
|
|
|
&time_mult[i][curr_subline[i]],
|
|
|
|
|
&flags);
|
|
|
|
|
line_type[i][curr_subline[i]] = flags;
|
|
|
|
|
|
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) {
|
2004-07-09 04:57:38 +00:00
|
|
|
|
scrollbar(0, i*h + offset + 1, LCD_WIDTH, 6,
|
|
|
|
|
id3->length?id3->length:1, 0,
|
|
|
|
|
id3->length?id3->elapsed + ff_rewind_count:0,
|
|
|
|
|
HORIZONTAL);
|
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;
|
|
|
|
|
|
|
|
|
|
update_line = true;
|
|
|
|
|
peak_meter_y = i * h + offset;
|
|
|
|
|
|
2004-05-19 08:30:48 +00:00
|
|
|
|
/* The user might decide to have the peak meter in the last
|
|
|
|
|
line so that it is only displayed if no status bar is
|
2003-01-23 14:28:16 +00:00
|
|
|
|
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
|
2004-01-14 07:59:06 +00:00
|
|
|
|
|
2003-01-22 12:48:12 +00:00
|
|
|
|
if (flags & WPS_REFRESH_SCROLL) {
|
2004-01-14 07:59:06 +00:00
|
|
|
|
|
2003-01-23 14:28:16 +00:00
|
|
|
|
/* scroll line */
|
2004-01-14 07:59:06 +00:00
|
|
|
|
if ((refresh_mode & WPS_REFRESH_SCROLL) ||
|
|
|
|
|
new_subline_refresh) {
|
2003-01-23 14:28:16 +00:00
|
|
|
|
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
|
|
|
|
}
|
2004-01-14 07:59:06 +00:00
|
|
|
|
else if (flags & (WPS_REFRESH_DYNAMIC | WPS_REFRESH_STATIC))
|
2002-09-01 19:50:45 +00:00
|
|
|
|
{
|
2004-01-14 07:59:06 +00:00
|
|
|
|
/* dynamic / static line */
|
|
|
|
|
if ((refresh_mode & (WPS_REFRESH_DYNAMIC|WPS_REFRESH_STATIC)) ||
|
|
|
|
|
new_subline_refresh)
|
|
|
|
|
{
|
|
|
|
|
update_line = true;
|
|
|
|
|
lcd_puts(0, i, buf);
|
|
|
|
|
}
|
2002-09-01 19:50:45 +00:00
|
|
|
|
}
|
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) {
|
2003-08-06 16:16:21 +00:00
|
|
|
|
lcd_update_rect(0, i*h + offset, LCD_WIDTH, h);
|
2002-10-30 23:01:27 +00:00
|
|
|
|
}
|
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
|
2004-05-19 08:30:48 +00:00
|
|
|
|
/* Now we know wether the peak meter is used.
|
2002-09-27 09:31:31 +00:00
|
|
|
|
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
|
|
|
|
|
2004-12-18 10:29:47 +00:00
|
|
|
|
#if defined(CONFIG_BACKLIGHT) && !defined(SIMULATOR)
|
2003-04-23 09:17:34 +00:00
|
|
|
|
if (global_settings.caption_backlight && id3) {
|
|
|
|
|
/* turn on backlight n seconds before track ends, and turn it off n
|
|
|
|
|
seconds into the new track. n == backlight_timeout, or 5s */
|
2004-05-19 08:30:48 +00:00
|
|
|
|
int n =
|
2003-04-23 09:17:34 +00:00
|
|
|
|
backlight_timeout_value[global_settings.backlight_timeout] * 1000;
|
|
|
|
|
|
|
|
|
|
if ( n < 1000 )
|
|
|
|
|
n = 5000; /* use 5s if backlight is always on or off */
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2003-04-23 09:17:34 +00:00
|
|
|
|
if ((id3->elapsed < 1000) ||
|
|
|
|
|
((id3->length - id3->elapsed) < (unsigned)n))
|
|
|
|
|
backlight_on();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2002-08-30 11:04:41 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2004-05-19 08:30:48 +00:00
|
|
|
|
bool wps_display(struct mp3entry* id3,
|
|
|
|
|
struct mp3entry* nid3)
|
2002-08-30 11:04:41 +00:00
|
|
|
|
{
|
|
|
|
|
lcd_clear_display();
|
2002-09-01 19:50:45 +00:00
|
|
|
|
|
2005-04-04 12:06:29 +00:00
|
|
|
|
if (!id3 && !(audio_status() & AUDIO_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-04-09 11:55:04 +00:00
|
|
|
|
global_settings.resume_index = -1;
|
2003-04-23 11:26:25 +00:00
|
|
|
|
status_draw(true);
|
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();
|
2004-05-19 08:30:48 +00:00
|
|
|
|
wps_refresh(id3, nid3, 0, WPS_REFRESH_ALL);
|
2003-04-23 11:26:25 +00:00
|
|
|
|
status_draw(true);
|
2002-08-30 11:04:41 +00:00
|
|
|
|
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
|
2004-08-18 01:09:31 +00:00
|
|
|
|
static bool draw_player_progress(const 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,
|
2004-08-18 01:09:31 +00:00
|
|
|
|
const struct mp3entry* id3,
|
|
|
|
|
int ff_rewwind_count)
|
2003-02-27 14:00:36 +00:00
|
|
|
|
{
|
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];
|
2004-08-26 20:30:22 +00:00
|
|
|
|
static const char numbers[12][4][3]={
|
|
|
|
|
{{1,1,1},{1,0,1},{1,0,1},{1,1,1}},/*0*/
|
|
|
|
|
{{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*/
|
|
|
|
|
{{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];
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2003-02-27 14:00:36 +00:00
|
|
|
|
for (i=0; i < buf_size; i++)
|
|
|
|
|
buf[i] = ' ';
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2003-02-27 14:00:36 +00:00
|
|
|
|
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);
|
2004-05-19 08:30:48 +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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2003-02-27 14:00:36 +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];
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
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];
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
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) {
|
2004-05-19 08:30:48 +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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
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];
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-05-19 08:30:48 +00:00
|
|
|
|
|
2003-03-05 23:01:55 +00:00
|
|
|
|
lcd_define_pattern(wps_progress_pat[7],player_progressbar);
|
2004-05-19 08:30:48 +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
|
|
|
|
|
*/
|