2002-12-03 22:41:50 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Linus Nielsen Feltzing
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "config.h"
|
|
|
|
#include "options.h"
|
|
|
|
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "font.h"
|
|
|
|
#include "button.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "sprintf.h"
|
|
|
|
#include <string.h>
|
|
|
|
#include "settings.h"
|
|
|
|
#include "power.h"
|
|
|
|
#include "powermgmt.h"
|
|
|
|
#include "status.h"
|
2003-01-14 13:49:28 +00:00
|
|
|
#include "debug.h"
|
2002-12-03 22:41:50 +00:00
|
|
|
|
|
|
|
#include "lang.h"
|
|
|
|
|
2002-12-05 13:47:20 +00:00
|
|
|
#define SMALL_STEP_SIZE 15*60 /* Seconds */
|
2002-12-03 22:41:50 +00:00
|
|
|
#define LARGE_STEP_SIZE 30*60 /* Seconds */
|
|
|
|
#define THRESHOLD 60 /* Minutes */
|
|
|
|
#define MAX_TIME 5*60*60 /* Hours */
|
|
|
|
|
|
|
|
bool sleeptimer_screen(void)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
int w, h;
|
|
|
|
#endif
|
|
|
|
unsigned long seconds;
|
|
|
|
int hours, minutes;
|
|
|
|
int button;
|
|
|
|
bool done = false;
|
|
|
|
char buf[32];
|
|
|
|
int oldtime, newtime;
|
2002-12-03 22:49:48 +00:00
|
|
|
int amount = 0;
|
2003-01-14 13:49:28 +00:00
|
|
|
int org_timer=get_sleep_timer();
|
|
|
|
bool changed=false;
|
2002-12-03 22:41:50 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
lcd_setfont(FONT_UI);
|
|
|
|
lcd_getstringsize("M", &w, &h);
|
|
|
|
lcd_setmargins(w, 8);
|
|
|
|
#endif
|
|
|
|
|
2003-01-14 13:49:28 +00:00
|
|
|
lcd_clear_display();
|
|
|
|
lcd_puts_scroll(0, 0, str(LANG_SLEEP_TIMER));
|
|
|
|
|
2002-12-03 22:41:50 +00:00
|
|
|
while(!done)
|
|
|
|
{
|
2003-01-14 13:49:28 +00:00
|
|
|
button = button_get_w_tmo(HZ);
|
2002-12-03 22:41:50 +00:00
|
|
|
switch(button)
|
|
|
|
{
|
2003-01-14 13:49:28 +00:00
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
|
|
|
case BUTTON_LEFT:
|
|
|
|
case BUTTON_PLAY:
|
2002-12-03 22:41:50 +00:00
|
|
|
#else
|
2003-01-14 13:49:28 +00:00
|
|
|
case BUTTON_PLAY:
|
|
|
|
#endif
|
|
|
|
done = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef HAVE_RECORDER_KEYPAD
|
2002-12-03 22:41:50 +00:00
|
|
|
case BUTTON_OFF:
|
2003-01-14 13:49:28 +00:00
|
|
|
#else
|
|
|
|
case BUTTON_STOP:
|
|
|
|
case BUTTON_MENU:
|
2002-12-03 22:41:50 +00:00
|
|
|
#endif
|
2003-01-14 13:49:28 +00:00
|
|
|
if (changed) {
|
|
|
|
lcd_stop_scroll();
|
|
|
|
lcd_puts(0, 0, str(LANG_MENU_SETTING_CANCEL));
|
2003-01-15 14:16:21 +00:00
|
|
|
lcd_update();
|
2003-01-14 13:49:28 +00:00
|
|
|
set_sleep_timer(org_timer);
|
|
|
|
sleep(HZ/2);
|
|
|
|
}
|
|
|
|
done = true;
|
|
|
|
break;
|
2002-12-03 22:41:50 +00:00
|
|
|
|
2003-12-12 13:34:27 +00:00
|
|
|
#if defined(HAVE_PLAYER_KEYPAD) || defined(HAVE_NEO_KEYPAD)
|
2002-12-03 22:41:50 +00:00
|
|
|
case BUTTON_RIGHT:
|
|
|
|
#else
|
|
|
|
case BUTTON_UP:
|
|
|
|
#endif
|
|
|
|
oldtime = (get_sleep_timer()+59) / 60;
|
|
|
|
if(oldtime < THRESHOLD)
|
|
|
|
amount = SMALL_STEP_SIZE;
|
|
|
|
else
|
|
|
|
amount = LARGE_STEP_SIZE;
|
|
|
|
|
|
|
|
newtime = oldtime * 60 + amount;
|
|
|
|
if(newtime > MAX_TIME)
|
|
|
|
newtime = MAX_TIME;
|
2003-01-14 13:49:28 +00:00
|
|
|
|
|
|
|
changed=true;
|
2002-12-03 22:41:50 +00:00
|
|
|
set_sleep_timer(newtime);
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef HAVE_PLAYER_KEYPAD
|
|
|
|
case BUTTON_LEFT:
|
|
|
|
#else
|
|
|
|
case BUTTON_DOWN:
|
|
|
|
#endif
|
|
|
|
oldtime = (get_sleep_timer()+59) / 60;
|
|
|
|
if(oldtime <= THRESHOLD)
|
|
|
|
amount = SMALL_STEP_SIZE;
|
|
|
|
else
|
|
|
|
amount = LARGE_STEP_SIZE;
|
|
|
|
|
|
|
|
newtime = oldtime*60 - amount;
|
|
|
|
if(newtime < 0)
|
|
|
|
newtime = 0;
|
|
|
|
|
2003-01-14 13:49:28 +00:00
|
|
|
changed=true;
|
2002-12-03 22:41:50 +00:00
|
|
|
set_sleep_timer(newtime);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
seconds = get_sleep_timer();
|
|
|
|
|
|
|
|
if(seconds)
|
|
|
|
{
|
|
|
|
seconds += 59; /* Round up for a "friendlier" display */
|
|
|
|
hours = seconds / 3600;
|
|
|
|
minutes = (seconds - (hours * 3600)) / 60;
|
|
|
|
snprintf(buf, 32, "%d:%02d",
|
|
|
|
hours, minutes);
|
|
|
|
lcd_puts(0, 1, buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lcd_puts(0, 1, str(LANG_OFF));
|
|
|
|
}
|
|
|
|
|
2003-04-23 11:26:25 +00:00
|
|
|
status_draw(true);
|
2002-12-03 22:41:50 +00:00
|
|
|
|
|
|
|
lcd_update();
|
|
|
|
}
|
2003-01-14 13:49:28 +00:00
|
|
|
lcd_stop_scroll();
|
2002-12-03 22:41:50 +00:00
|
|
|
return false;
|
|
|
|
}
|