2002-07-22 22:41:32 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by 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 "lcd.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "power.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include "settings.h"
|
|
|
|
#include "status.h"
|
2002-07-23 08:35:35 +00:00
|
|
|
#include "mpeg.h"
|
2002-08-07 10:35:26 +00:00
|
|
|
#include "wps.h"
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
#include "icons.h"
|
|
|
|
#endif
|
2002-08-07 11:41:31 +00:00
|
|
|
#include "powermgmt.h"
|
2002-08-07 10:35:26 +00:00
|
|
|
|
2002-08-07 12:45:02 +00:00
|
|
|
static enum playmode current_mode = STATUS_STOP;
|
2002-07-22 22:41:32 +00:00
|
|
|
|
2002-08-07 10:35:26 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
bool statusbar_enabled = true;
|
2002-08-07 13:36:52 +00:00
|
|
|
long switch_tick;
|
2002-08-07 13:05:13 +00:00
|
|
|
bool plug_state;
|
2002-08-07 10:35:26 +00:00
|
|
|
#endif
|
|
|
|
|
2002-07-22 22:41:32 +00:00
|
|
|
void status_init(void)
|
|
|
|
{
|
|
|
|
status_set_playmode(STATUS_STOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
void status_set_playmode(enum playmode mode)
|
|
|
|
{
|
|
|
|
current_mode = mode;
|
|
|
|
}
|
|
|
|
|
2002-08-07 10:35:26 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
bool statusbar(bool state)
|
|
|
|
{
|
|
|
|
bool laststate=statusbar_enabled;
|
|
|
|
|
|
|
|
statusbar_enabled=state;
|
|
|
|
|
|
|
|
return(laststate);
|
|
|
|
}
|
|
|
|
|
|
|
|
void statusbar_toggle(void)
|
|
|
|
{
|
|
|
|
statusbar_enabled=!statusbar_enabled;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-07-22 22:41:32 +00:00
|
|
|
void status_draw(void)
|
|
|
|
{
|
2002-07-22 22:59:06 +00:00
|
|
|
#if defined(HAVE_LCD_CHARCELLS) && !defined(SIMULATOR)
|
2002-07-22 22:41:32 +00:00
|
|
|
int battlevel = battery_level();
|
2002-07-23 08:35:35 +00:00
|
|
|
int volume = mpeg_val2phys(SOUND_VOLUME, global_settings.volume);
|
2002-07-22 22:41:32 +00:00
|
|
|
|
|
|
|
lcd_icon(ICON_BATTERY, true);
|
|
|
|
if(battlevel > 25)
|
2002-07-23 08:35:35 +00:00
|
|
|
lcd_icon(ICON_BATTERY_1, true);
|
2002-07-22 22:41:32 +00:00
|
|
|
else
|
2002-07-23 08:35:35 +00:00
|
|
|
lcd_icon(ICON_BATTERY_1, false);
|
2002-07-22 22:41:32 +00:00
|
|
|
if(battlevel > 50)
|
2002-07-23 08:35:35 +00:00
|
|
|
lcd_icon(ICON_BATTERY_2, true);
|
2002-07-22 22:41:32 +00:00
|
|
|
else
|
2002-07-23 08:35:35 +00:00
|
|
|
lcd_icon(ICON_BATTERY_2, false);
|
2002-07-22 22:41:32 +00:00
|
|
|
if(battlevel > 75)
|
2002-07-23 08:35:35 +00:00
|
|
|
lcd_icon(ICON_BATTERY_3, true);
|
2002-07-22 22:41:32 +00:00
|
|
|
else
|
2002-07-23 08:35:35 +00:00
|
|
|
lcd_icon(ICON_BATTERY_3, false);
|
2002-07-22 22:41:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
lcd_icon(ICON_VOLUME, true);
|
2002-07-23 08:35:35 +00:00
|
|
|
if(volume > 10)
|
|
|
|
lcd_icon(ICON_VOLUME_1, true);
|
2002-07-22 22:41:32 +00:00
|
|
|
else
|
2002-07-23 08:35:35 +00:00
|
|
|
lcd_icon(ICON_VOLUME_1, false);
|
|
|
|
if(volume > 30)
|
|
|
|
lcd_icon(ICON_VOLUME_2, true);
|
2002-07-22 22:41:32 +00:00
|
|
|
else
|
2002-07-23 08:35:35 +00:00
|
|
|
lcd_icon(ICON_VOLUME_2, false);
|
|
|
|
if(volume > 50)
|
|
|
|
lcd_icon(ICON_VOLUME_3, true);
|
2002-07-22 22:41:32 +00:00
|
|
|
else
|
2002-07-23 08:35:35 +00:00
|
|
|
lcd_icon(ICON_VOLUME_3, false);
|
|
|
|
if(volume > 70)
|
|
|
|
lcd_icon(ICON_VOLUME_4, true);
|
2002-07-22 22:41:32 +00:00
|
|
|
else
|
2002-07-23 08:35:35 +00:00
|
|
|
lcd_icon(ICON_VOLUME_4, false);
|
|
|
|
if(volume > 90)
|
|
|
|
lcd_icon(ICON_VOLUME_5, true);
|
2002-07-22 22:41:32 +00:00
|
|
|
else
|
2002-07-23 08:35:35 +00:00
|
|
|
lcd_icon(ICON_VOLUME_5, false);
|
2002-07-22 22:41:32 +00:00
|
|
|
|
|
|
|
switch(current_mode)
|
|
|
|
{
|
2002-07-23 08:35:35 +00:00
|
|
|
case STATUS_PLAY:
|
|
|
|
lcd_icon(ICON_PLAY, true);
|
|
|
|
lcd_icon(ICON_PAUSE, false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STATUS_STOP:
|
|
|
|
lcd_icon(ICON_PLAY, false);
|
|
|
|
lcd_icon(ICON_PAUSE, false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STATUS_PAUSE:
|
|
|
|
lcd_icon(ICON_PLAY, false);
|
|
|
|
lcd_icon(ICON_PAUSE, true);
|
|
|
|
break;
|
2002-07-22 22:41:32 +00:00
|
|
|
}
|
|
|
|
#endif
|
2002-08-07 10:35:26 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
int battlevel = battery_level();
|
|
|
|
int volume = mpeg_val2phys(SOUND_VOLUME, global_settings.volume);
|
|
|
|
|
|
|
|
if(global_settings.statusbar && statusbar_enabled) {
|
|
|
|
statusbar_wipe();
|
|
|
|
#ifdef HAVE_CHARGE_CTRL
|
2002-08-07 13:05:13 +00:00
|
|
|
if(charger_inserted()) {
|
|
|
|
if(!charger_enabled)
|
|
|
|
plug_state=true;
|
2002-08-07 13:36:52 +00:00
|
|
|
else if(TIME_AFTER(current_tick, switch_tick)) {
|
2002-08-07 13:05:13 +00:00
|
|
|
plug_state=!plug_state;
|
2002-08-07 13:36:52 +00:00
|
|
|
switch_tick=current_tick+HZ;
|
2002-08-07 13:05:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
plug_state=false;
|
|
|
|
statusbar_icon_battery(battlevel,plug_state);
|
2002-08-07 10:35:26 +00:00
|
|
|
#else
|
|
|
|
statusbar_icon_battery(battlevel,false);
|
|
|
|
#endif
|
|
|
|
statusbar_icon_volume(volume);
|
|
|
|
statusbar_icon_play_state(current_mode+Icon_Play);
|
|
|
|
if (global_settings.loop_playlist)
|
|
|
|
statusbar_icon_play_mode(Icon_Repeat);
|
|
|
|
else
|
|
|
|
statusbar_icon_play_mode(Icon_Normal);
|
|
|
|
if(global_settings.playlist_shuffle) statusbar_icon_shuffle();
|
|
|
|
if (keys_locked) statusbar_icon_lock();
|
|
|
|
#ifdef HAVE_RTC
|
|
|
|
statusbar_time();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
2002-07-22 22:41:32 +00:00
|
|
|
}
|