2002-09-24 17:22:12 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-05-05 10:32:46 +00:00
|
|
|
* Copyright (C) 2002 Björn Stenberg
|
2002-09-24 17:22:12 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-09-24 17:22:12 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2005-11-22 21:55:05 +00:00
|
|
|
|
2002-09-24 17:22:12 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "backlight.h"
|
2006-08-15 12:27:07 +00:00
|
|
|
#include "action.h"
|
2002-09-24 17:22:12 +00:00
|
|
|
#include "lcd.h"
|
|
|
|
#include "lang.h"
|
|
|
|
#include "icons.h"
|
|
|
|
#include "font.h"
|
2005-04-04 12:06:29 +00:00
|
|
|
#include "audio.h"
|
2004-01-05 20:42:51 +00:00
|
|
|
#include "mp3_playback.h"
|
2009-10-19 21:28:18 +00:00
|
|
|
#include "usb.h"
|
2002-09-24 17:22:12 +00:00
|
|
|
#include "settings.h"
|
2002-10-11 08:56:23 +00:00
|
|
|
#include "status.h"
|
2002-09-24 17:22:12 +00:00
|
|
|
#include "playlist.h"
|
2003-02-15 00:03:23 +00:00
|
|
|
#include "sprintf.h"
|
2003-06-29 16:33:04 +00:00
|
|
|
#include "kernel.h"
|
2003-07-17 20:29:51 +00:00
|
|
|
#include "power.h"
|
2003-07-18 22:01:13 +00:00
|
|
|
#include "system.h"
|
|
|
|
#include "powermgmt.h"
|
2004-04-21 06:49:12 +00:00
|
|
|
#include "talk.h"
|
2004-07-24 21:26:41 +00:00
|
|
|
#include "misc.h"
|
2008-10-15 06:38:51 +00:00
|
|
|
#include "metadata.h"
|
2004-10-12 00:02:51 +00:00
|
|
|
#include "screens.h"
|
2004-10-19 16:17:35 +00:00
|
|
|
#include "debug.h"
|
2005-02-19 16:23:30 +00:00
|
|
|
#include "led.h"
|
2005-04-01 13:41:03 +00:00
|
|
|
#include "sound.h"
|
2005-11-16 15:12:15 +00:00
|
|
|
#include "splash.h"
|
2005-11-20 01:02:14 +00:00
|
|
|
#include "statusbar.h"
|
2005-11-22 03:38:07 +00:00
|
|
|
#include "screen_access.h"
|
2006-04-21 06:20:02 +00:00
|
|
|
#include "pcmbuf.h"
|
2006-07-02 12:28:27 +00:00
|
|
|
#include "list.h"
|
2006-12-19 12:26:03 +00:00
|
|
|
#include "yesno.h"
|
2008-03-29 01:14:10 +00:00
|
|
|
#include "backdrop.h"
|
2008-05-11 14:08:46 +00:00
|
|
|
#include "viewport.h"
|
2009-10-06 16:57:01 +00:00
|
|
|
#include "language.h"
|
2005-11-20 01:02:14 +00:00
|
|
|
|
2005-09-24 15:22:48 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
#include "dsp.h"
|
|
|
|
#endif
|
2002-09-24 17:22:12 +00:00
|
|
|
|
2008-10-31 21:25:04 +00:00
|
|
|
#if (CONFIG_STORAGE & STORAGE_MMC)
|
2004-10-12 00:02:51 +00:00
|
|
|
int mmc_remove_request(void)
|
|
|
|
{
|
2007-10-16 01:25:17 +00:00
|
|
|
struct queue_event ev;
|
2005-11-22 04:15:27 +00:00
|
|
|
int i;
|
2005-11-22 03:38:07 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].clear_display();
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, ID2P(LANG_REMOVE_MMC));
|
2005-07-05 19:33:33 +00:00
|
|
|
|
2004-10-12 00:02:51 +00:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
queue_wait_w_tmo(&button_queue, &ev, HZ/2);
|
|
|
|
switch (ev.id)
|
|
|
|
{
|
2007-06-30 02:08:27 +00:00
|
|
|
case SYS_HOTSWAP_EXTRACTED:
|
|
|
|
return SYS_HOTSWAP_EXTRACTED;
|
2005-07-05 19:33:33 +00:00
|
|
|
|
2004-10-12 00:02:51 +00:00
|
|
|
case SYS_USB_DISCONNECTED:
|
|
|
|
return SYS_USB_DISCONNECTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-07-08 15:32:56 +00:00
|
|
|
/* the charging screen is only used for archos targets */
|
|
|
|
#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) && defined(CPU_SH)
|
2003-07-19 21:43:12 +00:00
|
|
|
|
2003-07-18 22:01:13 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2006-12-25 14:01:47 +00:00
|
|
|
static void charging_display_info(bool animate)
|
2003-07-18 22:01:13 +00:00
|
|
|
{
|
|
|
|
unsigned char charging_logo[36];
|
|
|
|
const int pox_x = (LCD_WIDTH - sizeof(charging_logo)) / 2;
|
2003-07-19 21:43:12 +00:00
|
|
|
const int pox_y = 32;
|
2003-07-18 22:01:13 +00:00
|
|
|
static unsigned phase = 3;
|
|
|
|
unsigned i;
|
|
|
|
|
2003-12-03 07:05:13 +00:00
|
|
|
#ifdef NEED_ATA_POWER_BATT_MEASURE
|
|
|
|
if (ide_powered()) /* FM and V2 can only measure when ATA power is on */
|
|
|
|
#endif
|
|
|
|
{
|
2006-10-30 11:33:38 +00:00
|
|
|
int battv = battery_voltage();
|
2009-10-17 18:02:48 +00:00
|
|
|
lcd_putsf(0, 7, " Batt: %d.%02dV %d%% ", battv / 1000,
|
2007-08-15 23:57:27 +00:00
|
|
|
(battv % 1000) / 10, battery_level());
|
2003-12-03 07:05:13 +00:00
|
|
|
}
|
2003-07-18 22:01:13 +00:00
|
|
|
|
2009-10-12 18:11:37 +00:00
|
|
|
#ifdef ARCHOS_RECORDER
|
|
|
|
lcd_puts(0, 2, "Charge mode:");
|
2003-07-19 21:43:12 +00:00
|
|
|
|
2009-10-12 18:47:33 +00:00
|
|
|
const char *s;
|
2006-06-06 22:23:52 +00:00
|
|
|
if (charge_state == CHARGING)
|
2009-10-12 18:11:37 +00:00
|
|
|
s = str(LANG_BATTERY_CHARGE);
|
2006-06-06 22:23:52 +00:00
|
|
|
else if (charge_state == TOPOFF)
|
2009-10-12 18:11:37 +00:00
|
|
|
s = str(LANG_BATTERY_TOPOFF_CHARGE);
|
2006-06-06 22:23:52 +00:00
|
|
|
else if (charge_state == TRICKLE)
|
2009-10-12 18:11:37 +00:00
|
|
|
s = str(LANG_BATTERY_TRICKLE_CHARGE);
|
2003-07-19 21:43:12 +00:00
|
|
|
else
|
2009-10-12 18:11:37 +00:00
|
|
|
s = "not charging";
|
2003-07-19 21:43:12 +00:00
|
|
|
|
2009-10-12 18:11:37 +00:00
|
|
|
lcd_puts(0, 3, s);
|
2008-12-24 16:58:41 +00:00
|
|
|
if (!charger_enabled())
|
2003-07-18 22:01:13 +00:00
|
|
|
animate = false;
|
2009-10-12 18:11:37 +00:00
|
|
|
#endif /* ARCHOS_RECORDER */
|
2005-07-05 19:33:33 +00:00
|
|
|
|
2003-07-18 22:01:13 +00:00
|
|
|
/* middle part */
|
|
|
|
memset(charging_logo+3, 0x00, 32);
|
|
|
|
charging_logo[0] = 0x3C;
|
|
|
|
charging_logo[1] = 0x24;
|
|
|
|
charging_logo[2] = charging_logo[35] = 0xFF;
|
2005-07-05 19:33:33 +00:00
|
|
|
|
2003-07-18 22:01:13 +00:00
|
|
|
if (!animate)
|
|
|
|
{ /* draw the outline */
|
|
|
|
/* middle part */
|
2008-05-23 21:43:40 +00:00
|
|
|
lcd_mono_bitmap(charging_logo, pox_x, pox_y + 8,
|
|
|
|
sizeof(charging_logo), 8);
|
2005-06-28 23:15:47 +00:00
|
|
|
lcd_set_drawmode(DRMODE_FG);
|
2003-07-18 22:01:13 +00:00
|
|
|
/* upper line */
|
2005-07-05 19:33:33 +00:00
|
|
|
charging_logo[0] = charging_logo[1] = 0x00;
|
2003-07-18 22:01:13 +00:00
|
|
|
memset(charging_logo+2, 0x80, 34);
|
2005-07-06 22:58:02 +00:00
|
|
|
lcd_mono_bitmap(charging_logo, pox_x, pox_y, sizeof(charging_logo), 8);
|
2003-07-18 22:01:13 +00:00
|
|
|
/* lower line */
|
|
|
|
memset(charging_logo+2, 0x01, 34);
|
2008-05-23 21:43:40 +00:00
|
|
|
lcd_mono_bitmap(charging_logo, pox_x, pox_y + 16,
|
|
|
|
sizeof(charging_logo), 8);
|
2005-06-28 23:15:47 +00:00
|
|
|
lcd_set_drawmode(DRMODE_SOLID);
|
2003-07-18 22:01:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ /* animate the middle part */
|
|
|
|
for (i = 3; i<MIN(sizeof(charging_logo)-1, phase); i++)
|
|
|
|
{
|
|
|
|
if ((i-phase) % 8 == 0)
|
|
|
|
{ /* draw a "bubble" here */
|
|
|
|
unsigned bitpos;
|
|
|
|
bitpos = (phase + i/8) % 15; /* "bounce" effect */
|
2005-07-05 19:33:33 +00:00
|
|
|
if (bitpos > 7)
|
2003-07-18 22:01:13 +00:00
|
|
|
bitpos = 14 - bitpos;
|
2009-06-07 21:27:05 +00:00
|
|
|
charging_logo[i] = BIT_N(bitpos);
|
2003-07-18 22:01:13 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-23 21:43:40 +00:00
|
|
|
lcd_mono_bitmap(charging_logo, pox_x, pox_y + 8,
|
|
|
|
sizeof(charging_logo), 8);
|
2003-07-18 22:01:13 +00:00
|
|
|
phase++;
|
|
|
|
}
|
|
|
|
lcd_update();
|
|
|
|
}
|
2003-07-19 21:43:12 +00:00
|
|
|
#else /* not HAVE_LCD_BITMAP */
|
2004-11-21 00:17:59 +00:00
|
|
|
|
2007-03-26 07:52:13 +00:00
|
|
|
static unsigned long logo_chars[4];
|
2004-11-21 00:17:59 +00:00
|
|
|
static const unsigned char logo_pattern[] = {
|
2007-03-26 07:52:13 +00:00
|
|
|
0x07, 0x04, 0x1c, 0x14, 0x1c, 0x04, 0x07, 0, /* char 1 */
|
|
|
|
0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0, /* char 2 */
|
|
|
|
0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0, /* char 3 */
|
|
|
|
0x1f, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1f, 0, /* char 4 */
|
2004-11-21 00:17:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void logo_lock_patterns(bool on)
|
|
|
|
{
|
2005-07-05 19:33:33 +00:00
|
|
|
int i;
|
2004-11-21 00:17:59 +00:00
|
|
|
|
|
|
|
if (on)
|
|
|
|
{
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
logo_chars[i] = lcd_get_locked_pattern();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
lcd_unlock_pattern(logo_chars[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static void charging_display_info(bool animate)
|
2003-07-18 22:01:13 +00:00
|
|
|
{
|
2006-10-30 11:33:38 +00:00
|
|
|
int battv;
|
2004-11-21 00:17:59 +00:00
|
|
|
unsigned i, ypos;
|
|
|
|
static unsigned phase = 3;
|
2007-03-26 07:52:13 +00:00
|
|
|
char buf[32];
|
2004-11-21 00:17:59 +00:00
|
|
|
|
2006-10-30 11:33:38 +00:00
|
|
|
battv = battery_voltage();
|
2009-10-17 18:02:48 +00:00
|
|
|
lcd_putsf(4, 1, " %d.%02dV", battv / 1000, (battv % 1000) / 10);
|
2005-07-05 19:33:33 +00:00
|
|
|
|
2007-03-26 07:52:13 +00:00
|
|
|
memcpy(buf, logo_pattern, 32); /* copy logo patterns */
|
2004-11-21 00:17:59 +00:00
|
|
|
|
|
|
|
if (!animate) /* build the screen */
|
|
|
|
{
|
|
|
|
lcd_double_height(false);
|
|
|
|
lcd_puts(0, 0, "[Charging]");
|
2007-03-26 07:52:13 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
lcd_putc(i, 1, logo_chars[i]);
|
2004-11-21 00:17:59 +00:00
|
|
|
}
|
|
|
|
else /* animate the logo */
|
|
|
|
{
|
|
|
|
for (i = 3; i < MIN(19, phase); i++)
|
|
|
|
{
|
|
|
|
if ((i - phase) % 5 == 0)
|
|
|
|
{ /* draw a "bubble" here */
|
|
|
|
ypos = (phase + i/5) % 9; /* "bounce" effect */
|
|
|
|
if (ypos > 4)
|
|
|
|
ypos = 8 - ypos;
|
2008-12-12 22:19:42 +00:00
|
|
|
buf[5 - ypos + 8 * (i/5)] |= 0x10u >> (i%5);
|
2004-11-21 00:17:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
phase++;
|
|
|
|
}
|
2005-07-05 19:33:33 +00:00
|
|
|
|
2004-11-21 00:17:59 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
2007-03-26 07:52:13 +00:00
|
|
|
lcd_define_pattern(logo_chars[i], buf + 8 * i);
|
2009-08-20 15:04:47 +00:00
|
|
|
|
2007-04-06 22:55:00 +00:00
|
|
|
lcd_update();
|
2003-07-18 22:01:13 +00:00
|
|
|
}
|
2004-11-21 00:44:44 +00:00
|
|
|
#endif /* (not) HAVE_LCD_BITMAP */
|
2003-07-18 22:01:13 +00:00
|
|
|
|
2003-07-17 20:29:51 +00:00
|
|
|
/* blocks while charging, returns on event:
|
|
|
|
1 if charger cable was removed
|
|
|
|
2 if Off/Stop key was pressed
|
|
|
|
3 if On key was pressed
|
|
|
|
4 if USB was connected */
|
2006-10-30 11:33:38 +00:00
|
|
|
|
2003-07-17 20:29:51 +00:00
|
|
|
int charging_screen(void)
|
|
|
|
{
|
2005-02-12 12:51:06 +00:00
|
|
|
unsigned int button;
|
2003-07-17 20:29:51 +00:00
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
ide_power_enable(false); /* power down the disk, else would be spinning */
|
|
|
|
|
|
|
|
lcd_clear_display();
|
2004-11-20 22:43:38 +00:00
|
|
|
backlight_set_timeout(global_settings.backlight_timeout);
|
2005-05-30 05:57:19 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
2005-05-30 00:00:22 +00:00
|
|
|
remote_backlight_set_timeout(global_settings.remote_backlight_timeout);
|
2005-05-30 05:57:19 +00:00
|
|
|
#endif
|
2005-11-23 20:12:33 +00:00
|
|
|
backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged);
|
2003-07-17 20:29:51 +00:00
|
|
|
|
2004-11-21 00:17:59 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
logo_lock_patterns(true);
|
2003-07-17 20:29:51 +00:00
|
|
|
#endif
|
2004-11-21 00:17:59 +00:00
|
|
|
charging_display_info(false);
|
|
|
|
|
2003-07-17 20:29:51 +00:00
|
|
|
do
|
|
|
|
{
|
2005-11-20 01:02:14 +00:00
|
|
|
gui_syncstatusbar_draw(&statusbars, false);
|
2003-07-18 22:01:13 +00:00
|
|
|
charging_display_info(true);
|
2006-08-15 12:27:07 +00:00
|
|
|
button = get_action(CONTEXT_STD,HZ/3);
|
|
|
|
if (button == ACTION_STD_OK)
|
2003-07-17 20:29:51 +00:00
|
|
|
rc = 2;
|
2008-07-06 12:14:13 +00:00
|
|
|
else if (usb_detect() == USB_INSERTED)
|
2005-07-11 19:14:26 +00:00
|
|
|
rc = 3;
|
|
|
|
else if (!charger_inserted())
|
|
|
|
rc = 1;
|
2003-07-17 20:29:51 +00:00
|
|
|
} while (!rc);
|
|
|
|
|
2004-11-21 00:17:59 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
logo_lock_patterns(false);
|
|
|
|
#endif
|
2003-07-17 20:29:51 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2007-07-08 15:32:56 +00:00
|
|
|
#endif /* CONFIG_CHARGING && !HAVE_POWEROFF_WHILE_CHARGING && defined(CPU_SH) */
|
2003-07-17 20:29:51 +00:00
|
|
|
|
2007-08-12 19:49:03 +00:00
|
|
|
#if CONFIG_CHARGING
|
2003-12-04 00:08:25 +00:00
|
|
|
void charging_splash(void)
|
|
|
|
{
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(2*HZ, str(LANG_BATTERY_CHARGE));
|
2005-01-26 22:48:25 +00:00
|
|
|
button_clear_queue();
|
2003-12-04 00:08:25 +00:00
|
|
|
}
|
2005-05-07 01:30:16 +00:00
|
|
|
#endif
|
2004-04-21 06:49:12 +00:00
|
|
|
|
|
|
|
|
2007-03-16 23:47:03 +00:00
|
|
|
#if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0)
|
2004-04-21 06:49:12 +00:00
|
|
|
|
|
|
|
/* little helper function for voice output */
|
2004-08-18 01:09:31 +00:00
|
|
|
static void say_time(int cursorpos, const struct tm *tm)
|
2004-04-21 06:49:12 +00:00
|
|
|
{
|
|
|
|
int value = 0;
|
2007-10-24 10:29:45 +00:00
|
|
|
int unit = 0;
|
2004-04-21 06:49:12 +00:00
|
|
|
|
2007-10-19 15:31:42 +00:00
|
|
|
if (!global_settings.talk_menu)
|
2004-04-21 06:49:12 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
switch(cursorpos)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
value = tm->tm_hour;
|
2007-10-24 10:29:45 +00:00
|
|
|
unit = UNIT_HOUR;
|
2004-04-21 06:49:12 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
value = tm->tm_min;
|
2007-10-24 10:29:45 +00:00
|
|
|
unit = UNIT_MIN;
|
2004-04-21 06:49:12 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
value = tm->tm_sec;
|
2007-10-24 10:29:45 +00:00
|
|
|
unit = UNIT_SEC;
|
2004-04-21 06:49:12 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
value = tm->tm_year + 1900;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
value = tm->tm_mday;
|
|
|
|
break;
|
|
|
|
}
|
2005-07-05 19:33:33 +00:00
|
|
|
|
2004-04-21 06:49:12 +00:00
|
|
|
if (cursorpos == 4) /* month */
|
2004-04-21 21:40:26 +00:00
|
|
|
talk_id(LANG_MONTH_JANUARY + tm->tm_mon, false);
|
2004-04-21 06:49:12 +00:00
|
|
|
else
|
2007-10-24 10:29:45 +00:00
|
|
|
talk_value(value, unit, false);
|
2004-04-21 06:49:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define INDEX_X 0
|
|
|
|
#define INDEX_Y 1
|
2007-07-01 12:08:45 +00:00
|
|
|
|
|
|
|
#define SEPARATOR ":"
|
2009-10-06 16:57:01 +00:00
|
|
|
|
|
|
|
#define IDX_HOURS 0
|
|
|
|
#define IDX_MINUTES 1
|
|
|
|
#define IDX_SECONDS 2
|
|
|
|
#define IDX_YEAR 3
|
|
|
|
#define IDX_MONTH 4
|
|
|
|
#define IDX_DAY 5
|
|
|
|
|
|
|
|
#define OFF_HOURS 0
|
|
|
|
#define OFF_MINUTES 3
|
|
|
|
#define OFF_SECONDS 6
|
|
|
|
#define OFF_YEAR 9
|
|
|
|
#define OFF_DAY 14
|
|
|
|
|
2007-07-01 12:08:45 +00:00
|
|
|
bool set_time_screen(const char* title, struct tm *tm)
|
2004-04-21 06:49:12 +00:00
|
|
|
{
|
2010-02-11 10:41:06 +00:00
|
|
|
struct viewport viewports[NB_SCREENS];
|
|
|
|
bool done = false, usb = false;
|
2007-11-22 19:46:27 +00:00
|
|
|
int cursorpos = 0;
|
2010-02-11 10:41:06 +00:00
|
|
|
unsigned int s;
|
2009-10-06 16:57:01 +00:00
|
|
|
unsigned char offsets_ptr[] =
|
|
|
|
{ OFF_HOURS, OFF_MINUTES, OFF_SECONDS, OFF_YEAR, 0, OFF_DAY };
|
2004-04-21 06:49:12 +00:00
|
|
|
|
2009-10-06 16:57:01 +00:00
|
|
|
if (lang_is_rtl())
|
|
|
|
{
|
|
|
|
offsets_ptr[IDX_HOURS] = OFF_SECONDS;
|
|
|
|
offsets_ptr[IDX_SECONDS] = OFF_HOURS;
|
|
|
|
offsets_ptr[IDX_YEAR] = OFF_DAY;
|
|
|
|
offsets_ptr[IDX_DAY] = OFF_YEAR;
|
|
|
|
}
|
2007-07-01 12:08:45 +00:00
|
|
|
|
2007-11-22 19:46:27 +00:00
|
|
|
/* speak selection when screen is entered */
|
|
|
|
say_time(cursorpos, tm);
|
|
|
|
|
2010-02-11 10:41:06 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
enum touchscreen_mode old_mode = touchscreen_get_mode();
|
|
|
|
touchscreen_set_mode(TOUCHSCREEN_BUTTON);
|
|
|
|
#endif
|
2007-11-22 19:46:27 +00:00
|
|
|
while (!done) {
|
2009-10-06 16:57:01 +00:00
|
|
|
int button;
|
2010-02-11 10:41:06 +00:00
|
|
|
unsigned int i, realyear, min, max;
|
2009-10-06 16:57:01 +00:00
|
|
|
unsigned char *ptr[6];
|
|
|
|
unsigned char buffer[20];
|
|
|
|
int *valptr = NULL;
|
|
|
|
static unsigned char daysinmonth[] =
|
|
|
|
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
|
|
|
|
2007-07-21 08:28:48 +00:00
|
|
|
/* for easy acess in the drawing loop */
|
2009-10-06 16:57:01 +00:00
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
ptr[i] = buffer + offsets_ptr[i];
|
|
|
|
ptr[IDX_MONTH] = str(LANG_MONTH_JANUARY + tm->tm_mon); /* month name */
|
2007-07-21 08:28:48 +00:00
|
|
|
|
2004-04-21 06:49:12 +00:00
|
|
|
/* calculate the number of days in febuary */
|
|
|
|
realyear = tm->tm_year + 1900;
|
|
|
|
if((realyear % 4 == 0 && !(realyear % 100 == 0)) || realyear % 400 == 0)
|
|
|
|
daysinmonth[1] = 29;
|
|
|
|
else
|
|
|
|
daysinmonth[1] = 28;
|
|
|
|
|
|
|
|
/* fix day if month or year changed */
|
|
|
|
if (tm->tm_mday > daysinmonth[tm->tm_mon])
|
|
|
|
tm->tm_mday = daysinmonth[tm->tm_mon];
|
|
|
|
|
|
|
|
/* calculate day of week */
|
2009-08-11 19:30:19 +00:00
|
|
|
set_day_of_week(tm);
|
2004-04-21 06:49:12 +00:00
|
|
|
|
2007-07-21 08:28:48 +00:00
|
|
|
/* put all the numbers we want from the tm struct into
|
|
|
|
an easily printable buffer */
|
2007-07-02 19:52:19 +00:00
|
|
|
snprintf(buffer, sizeof(buffer),
|
2007-07-21 08:28:48 +00:00
|
|
|
"%02d " "%02d " "%02d " "%04d " "%02d",
|
2007-07-01 12:08:45 +00:00
|
|
|
tm->tm_hour, tm->tm_min, tm->tm_sec,
|
2007-07-21 08:28:48 +00:00
|
|
|
tm->tm_year+1900, tm->tm_mday);
|
2007-07-01 12:08:45 +00:00
|
|
|
|
2007-07-21 08:28:48 +00:00
|
|
|
/* convert spaces in the buffer to '\0' to make it possible to work
|
2007-07-01 12:08:45 +00:00
|
|
|
directly on the buffer */
|
2007-07-21 08:28:48 +00:00
|
|
|
for(i=0; i < sizeof(buffer); i++)
|
|
|
|
{
|
|
|
|
if(buffer[i] == ' ')
|
|
|
|
buffer[i] = '\0';
|
|
|
|
}
|
|
|
|
|
2007-07-15 10:30:11 +00:00
|
|
|
FOR_NB_SCREENS(s)
|
2007-07-01 12:08:45 +00:00
|
|
|
{
|
2009-10-06 16:57:01 +00:00
|
|
|
int pos, nb_lines;
|
|
|
|
unsigned int separator_width, weekday_width;
|
|
|
|
unsigned int j, width, prev_line_height;
|
|
|
|
/* 6 possible cursor possitions, 2 values stored for each: x, y */
|
|
|
|
unsigned int cursor[6][2];
|
2009-10-06 08:20:12 +00:00
|
|
|
struct viewport *vp = &viewports[s];
|
2009-10-06 08:32:37 +00:00
|
|
|
struct screen *screen = &screens[s];
|
2009-10-06 16:57:01 +00:00
|
|
|
static unsigned char rtl_idx[] =
|
|
|
|
{ IDX_SECONDS, IDX_MINUTES, IDX_HOURS, IDX_DAY, IDX_MONTH, IDX_YEAR };
|
2009-10-06 08:20:12 +00:00
|
|
|
|
|
|
|
viewport_set_defaults(vp, s);
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->set_viewport(vp);
|
2009-10-06 08:20:12 +00:00
|
|
|
nb_lines = viewport_get_nb_lines(vp);
|
|
|
|
|
2007-07-15 10:30:11 +00:00
|
|
|
/* minimum lines needed is 2 + title line */
|
2008-05-11 13:59:27 +00:00
|
|
|
if (nb_lines < 4)
|
2007-07-15 10:30:11 +00:00
|
|
|
{
|
2009-10-06 08:20:12 +00:00
|
|
|
vp->font = FONT_SYSFIXED;
|
|
|
|
nb_lines = viewport_get_nb_lines(vp);
|
2007-07-15 10:30:11 +00:00
|
|
|
}
|
2009-10-06 08:20:12 +00:00
|
|
|
|
2007-07-15 10:30:11 +00:00
|
|
|
/* recalculate the positions and offsets */
|
2008-05-11 13:59:27 +00:00
|
|
|
if (nb_lines >= 3)
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->getstringsize(title, NULL, &prev_line_height);
|
2007-07-01 12:08:45 +00:00
|
|
|
else
|
2007-07-15 10:30:11 +00:00
|
|
|
prev_line_height = 0;
|
|
|
|
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->getstringsize(SEPARATOR, &separator_width, NULL);
|
2007-07-21 08:28:48 +00:00
|
|
|
|
2007-07-15 10:30:11 +00:00
|
|
|
/* weekday */
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->getstringsize(str(LANG_WEEKDAY_SUNDAY + tm->tm_wday),
|
2008-05-23 21:43:40 +00:00
|
|
|
&weekday_width, NULL);
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->getstringsize(" ", &separator_width, NULL);
|
2007-07-21 08:28:48 +00:00
|
|
|
|
2007-11-22 19:46:27 +00:00
|
|
|
for(i=0, j=0; i < 6; i++)
|
|
|
|
{
|
|
|
|
if(i==3) /* second row */
|
|
|
|
{
|
2009-03-04 18:15:06 +00:00
|
|
|
j = weekday_width + separator_width;
|
2007-11-22 19:46:27 +00:00
|
|
|
prev_line_height *= 2;
|
|
|
|
}
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->getstringsize(ptr[i], &width, NULL);
|
2010-02-11 10:41:06 +00:00
|
|
|
cursor[i][INDEX_Y] = prev_line_height;
|
2007-11-22 19:46:27 +00:00
|
|
|
cursor[i][INDEX_X] = j;
|
|
|
|
j += width + separator_width;
|
|
|
|
}
|
2007-07-21 08:28:48 +00:00
|
|
|
|
2007-07-15 10:30:11 +00:00
|
|
|
/* draw the screen */
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->set_viewport(vp);
|
|
|
|
screen->clear_viewport();
|
2007-07-15 10:30:11 +00:00
|
|
|
/* display the screen title */
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->puts_scroll(0, 0, title);
|
2007-07-21 08:28:48 +00:00
|
|
|
|
2007-07-15 10:30:11 +00:00
|
|
|
/* these are not selectable, so we draw them outside the loop */
|
2008-05-23 21:43:40 +00:00
|
|
|
/* name of the week day */
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->putsxy(0, cursor[3][INDEX_Y],
|
2008-05-23 21:43:40 +00:00
|
|
|
str(LANG_WEEKDAY_SUNDAY + tm->tm_wday));
|
2007-07-15 10:30:11 +00:00
|
|
|
|
2009-10-06 16:57:01 +00:00
|
|
|
pos = lang_is_rtl() ? rtl_idx[cursorpos] : cursorpos;
|
2007-07-15 10:30:11 +00:00
|
|
|
/* draw the selected item with drawmode set to
|
|
|
|
DRMODE_SOLID|DRMODE_INVERSEVID, all other selectable
|
|
|
|
items with drawmode DRMODE_SOLID */
|
|
|
|
for(i=0; i<6; i++)
|
|
|
|
{
|
2009-10-06 16:57:01 +00:00
|
|
|
if (pos == (int)i)
|
2009-10-06 08:20:12 +00:00
|
|
|
vp->drawmode = (DRMODE_SOLID|DRMODE_INVERSEVID);
|
2008-05-23 21:43:40 +00:00
|
|
|
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->putsxy(cursor[i][INDEX_X],
|
2007-07-15 10:30:11 +00:00
|
|
|
cursor[i][INDEX_Y], ptr[i]);
|
2007-11-22 19:46:27 +00:00
|
|
|
|
2009-10-06 08:20:12 +00:00
|
|
|
vp->drawmode = DRMODE_SOLID;
|
2007-11-22 19:46:27 +00:00
|
|
|
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->putsxy(cursor[i/4 +1][INDEX_X] - separator_width,
|
2007-11-22 19:46:27 +00:00
|
|
|
cursor[0][INDEX_Y], SEPARATOR);
|
2007-07-15 10:30:11 +00:00
|
|
|
}
|
2004-04-21 06:49:12 +00:00
|
|
|
|
2007-07-15 10:30:11 +00:00
|
|
|
/* print help text */
|
2008-05-11 13:59:27 +00:00
|
|
|
if (nb_lines > 4)
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->puts(0, 4, str(LANG_TIME_SET_BUTTON));
|
2008-05-11 13:59:27 +00:00
|
|
|
if (nb_lines > 5)
|
2009-10-06 08:32:37 +00:00
|
|
|
screen->puts(0, 5, str(LANG_TIME_REVERT));
|
|
|
|
screen->update_viewport();
|
|
|
|
screen->set_viewport(NULL);
|
2007-07-01 12:08:45 +00:00
|
|
|
}
|
2007-07-08 15:32:56 +00:00
|
|
|
|
2007-11-22 19:46:27 +00:00
|
|
|
/* set the most common numbers */
|
|
|
|
min = 0;
|
|
|
|
max = 59;
|
2004-04-21 06:49:12 +00:00
|
|
|
/* calculate the minimum and maximum for the number under cursor */
|
2007-11-22 19:46:27 +00:00
|
|
|
switch(cursorpos) {
|
|
|
|
case 0: /* hour */
|
|
|
|
max = 23;
|
|
|
|
valptr = &tm->tm_hour;
|
|
|
|
break;
|
|
|
|
case 1: /* minute */
|
|
|
|
valptr = &tm->tm_min;
|
|
|
|
break;
|
|
|
|
case 2: /* second */
|
|
|
|
valptr = &tm->tm_sec;
|
|
|
|
break;
|
|
|
|
case 3: /* year */
|
|
|
|
min = 1;
|
|
|
|
max = 200;
|
|
|
|
valptr = &tm->tm_year;
|
|
|
|
break;
|
|
|
|
case 4: /* month */
|
|
|
|
max = 11;
|
|
|
|
valptr = &tm->tm_mon;
|
|
|
|
break;
|
|
|
|
case 5: /* day */
|
|
|
|
min = 1;
|
|
|
|
max = daysinmonth[tm->tm_mon];
|
|
|
|
valptr = &tm->tm_mday;
|
|
|
|
break;
|
2004-04-21 06:49:12 +00:00
|
|
|
}
|
|
|
|
|
2007-07-15 10:30:11 +00:00
|
|
|
button = get_action(CONTEXT_SETTINGS_TIME, TIMEOUT_BLOCK);
|
2004-04-21 06:49:12 +00:00
|
|
|
switch ( button ) {
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_PREV:
|
2007-11-22 19:46:27 +00:00
|
|
|
cursorpos = clamp_value_wrap(--cursorpos, 5, 0);
|
|
|
|
say_time(cursorpos, tm);
|
2004-04-21 06:49:12 +00:00
|
|
|
break;
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_NEXT:
|
2007-11-22 19:46:27 +00:00
|
|
|
cursorpos = clamp_value_wrap(++cursorpos, 5, 0);
|
|
|
|
say_time(cursorpos, tm);
|
2004-04-21 06:49:12 +00:00
|
|
|
break;
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_SETTINGS_INC:
|
2006-08-21 07:03:15 +00:00
|
|
|
case ACTION_SETTINGS_INCREPEAT:
|
2007-11-22 19:46:27 +00:00
|
|
|
*valptr = clamp_value_wrap(++(*valptr), max, min);
|
2004-04-21 06:49:12 +00:00
|
|
|
say_time(cursorpos, tm);
|
|
|
|
break;
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_SETTINGS_DEC:
|
2006-08-21 07:03:15 +00:00
|
|
|
case ACTION_SETTINGS_DECREPEAT:
|
2007-11-22 19:46:27 +00:00
|
|
|
*valptr = clamp_value_wrap(--(*valptr), max, min);
|
2004-04-21 06:49:12 +00:00
|
|
|
say_time(cursorpos, tm);
|
|
|
|
break;
|
2004-09-19 21:58:37 +00:00
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_OK:
|
2004-04-21 06:49:12 +00:00
|
|
|
done = true;
|
|
|
|
break;
|
2004-09-19 21:58:37 +00:00
|
|
|
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_CANCEL:
|
2004-04-21 06:49:12 +00:00
|
|
|
done = true;
|
|
|
|
tm->tm_year = -1;
|
|
|
|
break;
|
|
|
|
|
2004-07-26 16:06:59 +00:00
|
|
|
default:
|
|
|
|
if (default_event_handler(button) == SYS_USB_CONNECTED)
|
2010-02-11 10:41:06 +00:00
|
|
|
done = usb = true;
|
2004-07-26 16:06:59 +00:00
|
|
|
break;
|
2004-04-21 06:49:12 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-11 10:41:06 +00:00
|
|
|
FOR_NB_SCREENS(s)
|
|
|
|
screens[s].scroll_stop(&viewports[s]);
|
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
touchscreen_set_mode(old_mode);
|
|
|
|
#endif
|
|
|
|
return usb;
|
2004-04-21 06:49:12 +00:00
|
|
|
}
|
2007-03-16 23:47:03 +00:00
|
|
|
#endif /* defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0) */
|
2004-07-24 21:26:41 +00:00
|
|
|
|
2005-06-22 22:22:23 +00:00
|
|
|
#if (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF)
|
2004-07-24 21:26:41 +00:00
|
|
|
bool shutdown_screen(void)
|
|
|
|
{
|
|
|
|
int button;
|
|
|
|
bool done = false;
|
2006-10-09 12:14:25 +00:00
|
|
|
long time_entered = current_tick;
|
2004-07-24 21:26:41 +00:00
|
|
|
|
|
|
|
lcd_stop_scroll();
|
|
|
|
|
2008-08-15 08:27:39 +00:00
|
|
|
splash(0, str(LANG_CONFIRM_SHUTDOWN));
|
2004-07-24 21:35:38 +00:00
|
|
|
|
2006-10-09 12:14:25 +00:00
|
|
|
while(!done && TIME_BEFORE(current_tick,time_entered+HZ*2))
|
2004-07-24 21:26:41 +00:00
|
|
|
{
|
2006-10-09 12:14:25 +00:00
|
|
|
button = get_action(CONTEXT_STD,HZ);
|
2004-07-24 21:26:41 +00:00
|
|
|
switch(button)
|
|
|
|
{
|
2006-08-15 12:27:07 +00:00
|
|
|
case ACTION_STD_CANCEL:
|
2005-09-14 09:08:26 +00:00
|
|
|
sys_poweroff();
|
2004-07-24 21:26:41 +00:00
|
|
|
break;
|
|
|
|
|
2007-07-22 13:08:00 +00:00
|
|
|
/* do nothing here, because ACTION_NONE might be caused
|
2006-10-30 11:33:38 +00:00
|
|
|
* by timeout or button release. In case of timeout the loop
|
2006-10-09 12:14:25 +00:00
|
|
|
* is terminated by TIME_BEFORE */
|
2007-07-22 13:08:00 +00:00
|
|
|
case ACTION_NONE:
|
2006-10-09 12:14:25 +00:00
|
|
|
break;
|
|
|
|
|
2004-07-24 21:26:41 +00:00
|
|
|
default:
|
2004-07-26 16:06:59 +00:00
|
|
|
if(default_event_handler(button) == SYS_USB_CONNECTED)
|
|
|
|
return true;
|
2006-10-09 12:14:25 +00:00
|
|
|
done = true;
|
2004-07-24 21:26:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2004-07-24 21:35:38 +00:00
|
|
|
#endif
|
2004-09-19 21:58:37 +00:00
|
|
|
|
2007-02-11 08:06:24 +00:00
|
|
|
static const int id3_headers[]=
|
|
|
|
{
|
|
|
|
LANG_ID3_TITLE,
|
|
|
|
LANG_ID3_ARTIST,
|
|
|
|
LANG_ID3_ALBUM,
|
|
|
|
LANG_ID3_ALBUMARTIST,
|
2007-08-08 10:19:56 +00:00
|
|
|
LANG_ID3_GROUPING,
|
2007-08-03 10:00:42 +00:00
|
|
|
LANG_ID3_DISCNUM,
|
2007-02-11 08:06:24 +00:00
|
|
|
LANG_ID3_TRACKNUM,
|
|
|
|
LANG_ID3_COMMENT,
|
|
|
|
LANG_ID3_GENRE,
|
|
|
|
LANG_ID3_YEAR,
|
|
|
|
LANG_ID3_LENGTH,
|
|
|
|
LANG_ID3_PLAYLIST,
|
|
|
|
LANG_ID3_BITRATE,
|
2007-07-28 16:32:24 +00:00
|
|
|
LANG_ID3_FREQUENCY,
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2007-02-11 08:06:24 +00:00
|
|
|
LANG_ID3_TRACK_GAIN,
|
|
|
|
LANG_ID3_ALBUM_GAIN,
|
2005-07-24 15:32:28 +00:00
|
|
|
#endif
|
2007-02-11 08:06:24 +00:00
|
|
|
LANG_ID3_PATH,
|
|
|
|
};
|
2009-08-20 16:47:44 +00:00
|
|
|
|
2008-10-19 03:58:33 +00:00
|
|
|
struct id3view_info {
|
|
|
|
struct mp3entry* id3;
|
|
|
|
int count;
|
2009-08-20 16:47:44 +00:00
|
|
|
int info_id[ARRAYLEN(id3_headers)];
|
2008-10-19 03:58:33 +00:00
|
|
|
};
|
2009-08-20 16:47:44 +00:00
|
|
|
|
|
|
|
static const char* id3_get_info(int selected_item, void* data,
|
|
|
|
char *buffer, size_t buffer_len)
|
2005-08-11 18:21:14 +00:00
|
|
|
{
|
2008-10-19 03:58:33 +00:00
|
|
|
struct id3view_info *info = (struct id3view_info*)data;
|
|
|
|
struct mp3entry* id3 =info->id3;
|
2006-07-02 12:28:27 +00:00
|
|
|
int info_no=selected_item/2;
|
|
|
|
if(!(selected_item%2))
|
|
|
|
{/* header */
|
2009-10-31 12:40:20 +00:00
|
|
|
snprintf(buffer, buffer_len,
|
|
|
|
"[%s]", str(id3_headers[info->info_id[info_no]]));
|
|
|
|
return buffer;
|
2006-07-02 12:28:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{/* data */
|
2005-08-11 18:21:14 +00:00
|
|
|
|
2008-10-19 03:58:33 +00:00
|
|
|
char * val=NULL;
|
|
|
|
switch(info->info_id[info_no])
|
2004-09-19 21:58:37 +00:00
|
|
|
{
|
2006-07-02 12:28:27 +00:00
|
|
|
case 0:/*LANG_ID3_TITLE*/
|
2008-10-19 03:58:33 +00:00
|
|
|
val=id3->title;
|
2006-07-02 12:28:27 +00:00
|
|
|
break;
|
|
|
|
case 1:/*LANG_ID3_ARTIST*/
|
2008-10-19 03:58:33 +00:00
|
|
|
val=id3->artist;
|
2006-07-02 12:28:27 +00:00
|
|
|
break;
|
|
|
|
case 2:/*LANG_ID3_ALBUM*/
|
2008-10-19 03:58:33 +00:00
|
|
|
val=id3->album;
|
2006-07-02 12:28:27 +00:00
|
|
|
break;
|
2007-02-10 12:09:28 +00:00
|
|
|
case 3:/*LANG_ID3_ALBUMARTIST*/
|
2008-10-19 03:58:33 +00:00
|
|
|
val=id3->albumartist;
|
2007-02-10 12:09:28 +00:00
|
|
|
break;
|
2007-08-08 12:34:19 +00:00
|
|
|
case 4:/*LANG_ID3_GROUPING*/
|
2008-10-19 03:58:33 +00:00
|
|
|
val=id3->grouping;
|
2007-08-08 10:19:56 +00:00
|
|
|
break;
|
|
|
|
case 5:/*LANG_ID3_DISCNUM*/
|
2007-08-03 10:00:42 +00:00
|
|
|
if (id3->disc_string)
|
2008-10-19 03:58:33 +00:00
|
|
|
val = id3->disc_string;
|
2007-08-03 10:00:42 +00:00
|
|
|
else if (id3->discnum)
|
2007-10-28 12:47:49 +00:00
|
|
|
{
|
2008-04-09 15:25:17 +00:00
|
|
|
snprintf(buffer, buffer_len, "%d", id3->discnum);
|
2008-10-19 03:58:33 +00:00
|
|
|
val = buffer;
|
2007-08-03 10:00:42 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-08-08 10:19:56 +00:00
|
|
|
case 6:/*LANG_ID3_TRACKNUM*/
|
2006-07-02 12:28:27 +00:00
|
|
|
if (id3->track_string)
|
2008-10-19 03:58:33 +00:00
|
|
|
val = id3->track_string;
|
2006-07-02 12:28:27 +00:00
|
|
|
else if (id3->tracknum)
|
2005-08-11 18:21:14 +00:00
|
|
|
{
|
2008-04-09 15:25:17 +00:00
|
|
|
snprintf(buffer, buffer_len, "%d", id3->tracknum);
|
2008-10-19 03:58:33 +00:00
|
|
|
val = buffer;
|
2005-08-11 18:21:14 +00:00
|
|
|
}
|
2006-07-02 12:28:27 +00:00
|
|
|
break;
|
2007-08-08 10:19:56 +00:00
|
|
|
case 7:/*LANG_ID3_COMMENT*/
|
2010-02-18 05:50:44 +00:00
|
|
|
if (!id3->comment)
|
|
|
|
return NULL;
|
2010-02-18 05:43:51 +00:00
|
|
|
snprintf(buffer, buffer_len, "%s", id3->comment);
|
|
|
|
val=buffer;
|
2007-02-10 12:09:28 +00:00
|
|
|
break;
|
2007-08-08 10:19:56 +00:00
|
|
|
case 8:/*LANG_ID3_GENRE*/
|
2008-10-19 03:58:33 +00:00
|
|
|
val = id3->genre_string;
|
2006-07-02 12:28:27 +00:00
|
|
|
break;
|
2007-08-08 10:19:56 +00:00
|
|
|
case 9:/*LANG_ID3_YEAR*/
|
2006-07-02 12:28:27 +00:00
|
|
|
if (id3->year_string)
|
2008-10-19 03:58:33 +00:00
|
|
|
val = id3->year_string;
|
2006-07-02 12:28:27 +00:00
|
|
|
else if (id3->year)
|
2005-08-11 18:21:14 +00:00
|
|
|
{
|
2008-04-09 15:25:17 +00:00
|
|
|
snprintf(buffer, buffer_len, "%d", id3->year);
|
2008-10-19 03:58:33 +00:00
|
|
|
val = buffer;
|
2005-08-11 18:21:14 +00:00
|
|
|
}
|
2004-09-19 21:58:37 +00:00
|
|
|
break;
|
2007-08-08 10:19:56 +00:00
|
|
|
case 10:/*LANG_ID3_LENGTH*/
|
2008-04-09 15:25:17 +00:00
|
|
|
format_time(buffer, buffer_len, id3->length);
|
2008-10-19 03:58:33 +00:00
|
|
|
val=buffer;
|
2006-07-02 12:28:27 +00:00
|
|
|
break;
|
2007-08-08 10:19:56 +00:00
|
|
|
case 11:/*LANG_ID3_PLAYLIST*/
|
2008-05-23 21:43:40 +00:00
|
|
|
snprintf(buffer, buffer_len, "%d/%d",
|
|
|
|
playlist_get_display_index(), playlist_amount());
|
2008-10-19 03:58:33 +00:00
|
|
|
val=buffer;
|
2006-07-02 12:28:27 +00:00
|
|
|
break;
|
2007-08-08 10:19:56 +00:00
|
|
|
case 12:/*LANG_ID3_BITRATE*/
|
2008-04-09 15:25:17 +00:00
|
|
|
snprintf(buffer, buffer_len, "%d kbps%s", id3->bitrate,
|
2006-07-02 12:28:27 +00:00
|
|
|
id3->vbr ? str(LANG_ID3_VBR) : (const unsigned char*) "");
|
2008-10-19 03:58:33 +00:00
|
|
|
val=buffer;
|
2006-07-02 12:28:27 +00:00
|
|
|
break;
|
2007-08-08 10:19:56 +00:00
|
|
|
case 13:/*LANG_ID3_FREQUENCY*/
|
2008-04-09 15:25:17 +00:00
|
|
|
snprintf(buffer, buffer_len, "%ld Hz", id3->frequency);
|
2008-10-19 03:58:33 +00:00
|
|
|
val=buffer;
|
2006-07-02 12:28:27 +00:00
|
|
|
break;
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2007-08-08 10:19:56 +00:00
|
|
|
case 14:/*LANG_ID3_TRACK_GAIN*/
|
2008-10-19 03:58:33 +00:00
|
|
|
val=id3->track_gain_string;
|
2006-07-02 12:28:27 +00:00
|
|
|
break;
|
2007-08-08 10:19:56 +00:00
|
|
|
case 15:/*LANG_ID3_ALBUM_GAIN*/
|
2008-10-19 03:58:33 +00:00
|
|
|
val=id3->album_gain_string;
|
2006-07-02 12:28:27 +00:00
|
|
|
break;
|
2007-08-08 10:19:56 +00:00
|
|
|
case 16:/*LANG_ID3_PATH*/
|
2005-08-11 18:21:14 +00:00
|
|
|
#else
|
2007-08-08 12:34:19 +00:00
|
|
|
case 14:/*LANG_ID3_PATH*/
|
2005-08-11 18:21:14 +00:00
|
|
|
#endif
|
2008-10-19 03:58:33 +00:00
|
|
|
val=id3->path;
|
2004-09-19 21:58:37 +00:00
|
|
|
break;
|
2006-07-02 12:28:27 +00:00
|
|
|
}
|
2008-10-19 03:58:33 +00:00
|
|
|
return val && *val ? val : NULL;
|
2006-07-02 12:28:27 +00:00
|
|
|
}
|
|
|
|
}
|
2005-06-23 02:20:40 +00:00
|
|
|
|
2006-07-02 12:28:27 +00:00
|
|
|
bool browse_id3(void)
|
|
|
|
{
|
|
|
|
struct gui_synclist id3_lists;
|
|
|
|
struct mp3entry* id3 = audio_current_track();
|
|
|
|
int key;
|
2008-10-19 03:58:33 +00:00
|
|
|
unsigned int i;
|
|
|
|
struct id3view_info info;
|
|
|
|
info.count = 0;
|
|
|
|
info.id3 = id3;
|
2009-08-20 16:47:44 +00:00
|
|
|
for (i = 0; i < ARRAYLEN(id3_headers); i++)
|
2008-10-19 03:58:33 +00:00
|
|
|
{
|
|
|
|
char temp[8];
|
|
|
|
info.info_id[i] = i;
|
|
|
|
if (id3_get_info((i*2)+1, &info, temp, 8) != NULL)
|
|
|
|
info.info_id[info.count++] = i;
|
|
|
|
}
|
2006-07-02 12:28:27 +00:00
|
|
|
|
2008-10-19 03:58:33 +00:00
|
|
|
gui_synclist_init(&id3_lists, &id3_get_info, &info, true, 2, NULL);
|
|
|
|
gui_synclist_set_nb_items(&id3_lists, info.count*2);
|
2006-07-02 12:28:27 +00:00
|
|
|
gui_synclist_draw(&id3_lists);
|
|
|
|
while (true) {
|
2006-08-17 05:40:14 +00:00
|
|
|
key = get_action(CONTEXT_LIST,HZ/2);
|
2006-10-30 11:33:38 +00:00
|
|
|
if(key!=ACTION_NONE && key!=ACTION_UNKNOWN
|
2007-09-17 10:08:50 +00:00
|
|
|
&& !gui_synclist_do_button(&id3_lists, &key,LIST_WRAP_UNLESS_HELD))
|
2006-08-15 12:27:07 +00:00
|
|
|
{
|
2006-07-02 16:18:59 +00:00
|
|
|
return(default_event_handler(key) == SYS_USB_CONNECTED);
|
2006-08-15 12:27:07 +00:00
|
|
|
}
|
2004-09-19 21:58:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-20 16:47:44 +00:00
|
|
|
static const char* runtime_get_data(int selected_item, void* data,
|
|
|
|
char* buffer, size_t buffer_len)
|
2007-04-10 20:56:15 +00:00
|
|
|
{
|
2009-08-20 15:04:47 +00:00
|
|
|
(void)data;
|
2007-04-10 20:56:15 +00:00
|
|
|
int t;
|
2008-08-02 21:32:48 +00:00
|
|
|
switch (selected_item)
|
|
|
|
{
|
|
|
|
case 0: return str(LANG_RUNNING_TIME);
|
|
|
|
case 1: t = global_status.runtime; break;
|
|
|
|
case 2: return str(LANG_TOP_TIME);
|
|
|
|
case 3: t = global_status.topruntime; break;
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
2007-04-10 20:56:15 +00:00
|
|
|
|
2008-04-09 15:25:17 +00:00
|
|
|
snprintf(buffer, buffer_len, "%dh %dm %ds",
|
2007-04-10 20:56:15 +00:00
|
|
|
t / 3600, (t % 3600) / 60, t % 60);
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2007-11-07 03:58:13 +00:00
|
|
|
static int runtime_speak_data(int selected_item, void* data)
|
|
|
|
{
|
2007-11-07 09:28:07 +00:00
|
|
|
(void) data;
|
2007-11-07 03:58:13 +00:00
|
|
|
talk_ids(false,
|
2008-08-02 21:32:48 +00:00
|
|
|
(selected_item < 2) ? LANG_RUNNING_TIME : LANG_TOP_TIME,
|
|
|
|
TALK_ID((selected_item < 2) ? global_status.runtime
|
2007-11-07 03:58:13 +00:00
|
|
|
: global_status.topruntime, UNIT_TIME));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-04-10 20:56:15 +00:00
|
|
|
|
2006-12-19 12:26:03 +00:00
|
|
|
bool view_runtime(void)
|
|
|
|
{
|
2008-04-26 09:30:24 +00:00
|
|
|
static const char *lines[]={ID2P(LANG_CLEAR_TIME)};
|
|
|
|
static const struct text_message message={lines, 1};
|
2006-12-19 12:26:03 +00:00
|
|
|
|
2007-04-10 20:56:15 +00:00
|
|
|
struct gui_synclist lists;
|
|
|
|
int action;
|
2008-03-26 03:35:24 +00:00
|
|
|
gui_synclist_init(&lists, runtime_get_data, NULL, false, 2, NULL);
|
2007-04-10 20:56:15 +00:00
|
|
|
#if !defined(HAVE_LCD_CHARCELLS)
|
|
|
|
gui_synclist_set_title(&lists, str(LANG_RUNNING_TIME), NOICON);
|
|
|
|
#else
|
|
|
|
gui_synclist_set_title(&lists, NULL, NOICON);
|
2007-02-17 10:59:30 +00:00
|
|
|
#endif
|
2007-11-07 03:58:13 +00:00
|
|
|
if(global_settings.talk_menu)
|
|
|
|
gui_synclist_set_voice_callback(&lists, runtime_speak_data);
|
2007-04-10 20:56:15 +00:00
|
|
|
gui_synclist_set_icon_callback(&lists, NULL);
|
|
|
|
gui_synclist_set_nb_items(&lists, 4);
|
2007-11-07 03:58:13 +00:00
|
|
|
gui_synclist_speak_item(&lists);
|
2007-04-10 20:56:15 +00:00
|
|
|
while(1)
|
2006-12-19 12:26:03 +00:00
|
|
|
{
|
2010-02-27 22:47:49 +00:00
|
|
|
global_status.runtime += ((current_tick - lasttime) / HZ);
|
|
|
|
|
2007-04-10 20:56:15 +00:00
|
|
|
lasttime = current_tick;
|
|
|
|
gui_synclist_draw(&lists);
|
2007-11-07 03:58:13 +00:00
|
|
|
list_do_action(CONTEXT_STD, HZ,
|
|
|
|
&lists, &action, LIST_WRAP_UNLESS_HELD);
|
2007-04-10 20:56:15 +00:00
|
|
|
if(action == ACTION_STD_CANCEL)
|
|
|
|
break;
|
|
|
|
if(action == ACTION_STD_OK) {
|
|
|
|
if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES)
|
|
|
|
{
|
|
|
|
if (!(gui_synclist_get_sel_pos(&lists)/2))
|
|
|
|
global_status.runtime = 0;
|
|
|
|
else
|
|
|
|
global_status.topruntime = 0;
|
2007-11-07 03:58:13 +00:00
|
|
|
gui_synclist_speak_item(&lists);
|
2007-04-10 20:56:15 +00:00
|
|
|
}
|
2006-12-19 12:26:03 +00:00
|
|
|
}
|
2007-04-10 21:40:44 +00:00
|
|
|
if(default_event_handler(action) == SYS_USB_CONNECTED)
|
|
|
|
return true;
|
2006-12-19 12:26:03 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2009-06-16 17:04:47 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
static int get_sample(struct touchscreen_calibration *cal, int x, int y, int i,
|
|
|
|
struct screen* screen)
|
|
|
|
{
|
|
|
|
int action;
|
|
|
|
short ts_x, ts_y;
|
|
|
|
|
|
|
|
/* Draw a cross */
|
|
|
|
screen->drawline(x - 10, y, x - 2, y);
|
|
|
|
screen->drawline(x + 2, y, x + 10, y);
|
|
|
|
screen->drawline(x, y - 10, x, y - 2);
|
|
|
|
screen->drawline(x, y + 2, x, y + 10);
|
|
|
|
screen->update();
|
|
|
|
|
|
|
|
/* Wait for a touchscreen press */
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
action = get_action(CONTEXT_STD, TIMEOUT_BLOCK);
|
|
|
|
if(action == ACTION_TOUCHSCREEN)
|
|
|
|
{
|
|
|
|
if(action_get_touchscreen_press(&ts_x, &ts_y) == BUTTON_REL)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if(action == ACTION_STD_CANCEL)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cal->x[i][0] = ts_x;
|
|
|
|
cal->y[i][0] = ts_y;
|
|
|
|
cal->x[i][1] = x;
|
|
|
|
cal->y[i][1] = y;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int calibrate(void)
|
|
|
|
{
|
|
|
|
short points[3][2] = {
|
|
|
|
{LCD_WIDTH/10, LCD_HEIGHT/10},
|
|
|
|
{7*LCD_WIDTH/8, LCD_HEIGHT/2},
|
|
|
|
{LCD_WIDTH/2, 7*LCD_HEIGHT/8}
|
|
|
|
};
|
|
|
|
struct screen* screen = &screens[SCREEN_MAIN];
|
|
|
|
enum touchscreen_mode old_mode = touchscreen_get_mode();
|
|
|
|
struct touchscreen_calibration cal;
|
|
|
|
int i, ret = 0;
|
2009-11-04 23:57:37 +00:00
|
|
|
|
|
|
|
/* hide the statusbar */
|
2009-12-09 07:25:46 +00:00
|
|
|
viewportmanager_theme_enable(SCREEN_MAIN, false, NULL);
|
2009-06-16 17:04:47 +00:00
|
|
|
|
|
|
|
touchscreen_disable_mapping(); /* set raw mode */
|
|
|
|
touchscreen_set_mode(TOUCHSCREEN_POINT);
|
2009-11-04 23:44:27 +00:00
|
|
|
|
2009-06-16 17:04:47 +00:00
|
|
|
for(i=0; i<3; i++)
|
|
|
|
{
|
|
|
|
screen->clear_display();
|
|
|
|
|
|
|
|
if(get_sample(&cal, points[i][0], points[i][1], i, screen))
|
|
|
|
{
|
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ret == 0)
|
|
|
|
touchscreen_calibrate(&cal);
|
|
|
|
else
|
|
|
|
touchscreen_reset_mapping();
|
2009-11-04 23:44:27 +00:00
|
|
|
|
|
|
|
memcpy(&global_settings.ts_calibration_data, &calibration_parameters,
|
|
|
|
sizeof(struct touchscreen_parameter));
|
|
|
|
|
2009-06-16 17:04:47 +00:00
|
|
|
touchscreen_set_mode(old_mode);
|
2009-12-21 05:19:12 +00:00
|
|
|
viewportmanager_theme_undo(SCREEN_MAIN, false);
|
2009-06-16 17:04:47 +00:00
|
|
|
|
2009-11-04 23:44:27 +00:00
|
|
|
settings_save();
|
2009-06-16 17:04:47 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int reset_mapping(void)
|
|
|
|
{
|
|
|
|
touchscreen_reset_mapping();
|
2009-11-04 23:44:27 +00:00
|
|
|
|
|
|
|
memcpy(&global_settings.ts_calibration_data, &calibration_parameters,
|
|
|
|
sizeof(struct touchscreen_parameter));
|
|
|
|
|
|
|
|
settings_save();
|
2009-06-16 17:04:47 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|