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"
|
2002-08-30 00:58:55 +00:00
|
|
|
#ifdef HAVE_RTC
|
|
|
|
#include "rtc.h"
|
|
|
|
#endif
|
2002-08-07 10:35:26 +00:00
|
|
|
#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 13:36:52 +00:00
|
|
|
long switch_tick;
|
2002-09-04 22:29:04 +00:00
|
|
|
int battery_charge_step = 0;
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-08-07 13:05:13 +00:00
|
|
|
bool plug_state;
|
2002-08-09 11:56:54 +00:00
|
|
|
bool battery_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-30 00:39:31 +00:00
|
|
|
status_draw();
|
2002-07-22 22:41:32 +00:00
|
|
|
}
|
|
|
|
|
2002-10-15 12:53:33 +00:00
|
|
|
#if defined(HAVE_LCD_CHARCELLS)
|
|
|
|
static bool record = false;
|
|
|
|
static bool audio = false;
|
|
|
|
static bool param = false;
|
|
|
|
static bool usb = false;
|
|
|
|
|
|
|
|
void status_set_record(bool b)
|
|
|
|
{
|
|
|
|
record = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void status_set_audio(bool b)
|
|
|
|
{
|
|
|
|
audio = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void status_set_param(bool b)
|
|
|
|
{
|
|
|
|
param = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
void status_set_usb(bool b)
|
|
|
|
{
|
|
|
|
usb = b;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_LCD_CHARCELLS */
|
|
|
|
|
2002-07-22 22:41:32 +00:00
|
|
|
void status_draw(void)
|
|
|
|
{
|
|
|
|
int battlevel = battery_level();
|
2002-07-23 08:35:35 +00:00
|
|
|
int volume = mpeg_val2phys(SOUND_VOLUME, global_settings.volume);
|
2002-08-30 19:52:33 +00:00
|
|
|
#if defined(HAVE_LCD_BITMAP) && defined(HAVE_RTC)
|
2002-08-30 19:44:58 +00:00
|
|
|
int hour, minute;
|
|
|
|
#endif
|
2002-09-30 21:27:53 +00:00
|
|
|
|
|
|
|
if ( !global_settings.statusbar )
|
|
|
|
return;
|
|
|
|
|
2002-08-30 00:39:31 +00:00
|
|
|
#if defined(HAVE_LCD_CHARCELLS)
|
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-08-21 11:51:24 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2002-07-22 22:41:32 +00:00
|
|
|
}
|
2002-09-04 22:29:04 +00:00
|
|
|
if(charger_inserted())
|
|
|
|
{
|
|
|
|
if(TIME_AFTER(current_tick, switch_tick))
|
|
|
|
{
|
|
|
|
lcd_icon(ICON_BATTERY, true);
|
|
|
|
lcd_icon(ICON_BATTERY_1, false);
|
|
|
|
lcd_icon(ICON_BATTERY_2, false);
|
|
|
|
lcd_icon(ICON_BATTERY_3, false);
|
|
|
|
switch(battery_charge_step)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
battery_charge_step++;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
lcd_icon(ICON_BATTERY_1, true);
|
|
|
|
battery_charge_step++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
lcd_icon(ICON_BATTERY_1, true);
|
|
|
|
lcd_icon(ICON_BATTERY_2, true);
|
|
|
|
battery_charge_step++;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
lcd_icon(ICON_BATTERY_1, true);
|
|
|
|
lcd_icon(ICON_BATTERY_2, true);
|
|
|
|
lcd_icon(ICON_BATTERY_3, true);
|
|
|
|
battery_charge_step = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
battery_charge_step = 0;
|
|
|
|
break;
|
|
|
|
}
|
2002-09-04 22:32:19 +00:00
|
|
|
switch_tick = current_tick + (HZ/2);
|
2002-09-04 22:29:04 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
lcd_icon(ICON_BATTERY, true);
|
|
|
|
if(battlevel > 25)
|
|
|
|
lcd_icon(ICON_BATTERY_1, true);
|
|
|
|
else
|
|
|
|
lcd_icon(ICON_BATTERY_1, false);
|
|
|
|
if(battlevel > 50)
|
|
|
|
lcd_icon(ICON_BATTERY_2, true);
|
|
|
|
else
|
|
|
|
lcd_icon(ICON_BATTERY_2, false);
|
|
|
|
if(battlevel > 75)
|
|
|
|
lcd_icon(ICON_BATTERY_3, true);
|
|
|
|
else
|
|
|
|
lcd_icon(ICON_BATTERY_3, false);
|
|
|
|
}
|
2002-10-05 13:12:01 +00:00
|
|
|
|
|
|
|
lcd_icon(ICON_REPEAT, global_settings.repeat_mode != REPEAT_OFF);
|
|
|
|
lcd_icon(ICON_1, global_settings.repeat_mode == REPEAT_ONE);
|
|
|
|
|
2002-10-15 12:53:33 +00:00
|
|
|
lcd_icon(ICON_RECORD, record);
|
|
|
|
lcd_icon(ICON_AUDIO, audio);
|
|
|
|
lcd_icon(ICON_PARAM, param);
|
|
|
|
lcd_icon(ICON_USB, usb);
|
|
|
|
|
2002-07-22 22:41:32 +00:00
|
|
|
#endif
|
2002-08-07 10:35:26 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2002-09-01 19:50:45 +00:00
|
|
|
if (global_settings.statusbar) {
|
2002-08-07 10:35:26 +00:00
|
|
|
statusbar_wipe();
|
|
|
|
#ifdef HAVE_CHARGE_CTRL
|
2002-08-07 13:05:13 +00:00
|
|
|
if(charger_inserted()) {
|
2002-08-12 12:31:36 +00:00
|
|
|
battery_state = true;
|
2002-08-13 14:58:09 +00:00
|
|
|
plug_state = true;
|
|
|
|
if(charger_enabled) { /* animate battery if charging */
|
|
|
|
battlevel = battery_charge_step * 34; /* 34 for a better look */
|
|
|
|
battlevel = battlevel > 100 ? 100 : battlevel;
|
|
|
|
if(TIME_AFTER(current_tick, switch_tick)) {
|
|
|
|
battery_charge_step=(battery_charge_step+1)%4;
|
|
|
|
switch_tick = current_tick + HZ;
|
|
|
|
}
|
2002-08-07 13:05:13 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-09 11:56:54 +00:00
|
|
|
else {
|
2002-08-07 13:05:13 +00:00
|
|
|
plug_state=false;
|
2002-08-12 14:16:50 +00:00
|
|
|
if(battery_level_safe())
|
2002-08-12 12:31:36 +00:00
|
|
|
battery_state = true;
|
2002-08-13 14:58:09 +00:00
|
|
|
else /* blink battery if level is low */
|
2002-08-09 11:56:54 +00:00
|
|
|
if(TIME_AFTER(current_tick, switch_tick)) {
|
2002-08-12 12:31:36 +00:00
|
|
|
switch_tick = current_tick+HZ;
|
|
|
|
battery_state =! battery_state;
|
2002-08-09 11:56:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-30 00:39:31 +00:00
|
|
|
if (battery_state)
|
|
|
|
statusbar_icon_battery(battlevel, plug_state);
|
2002-08-07 10:35:26 +00:00
|
|
|
#else
|
2002-08-12 12:31:36 +00:00
|
|
|
statusbar_icon_battery(battlevel, false);
|
2002-08-07 10:35:26 +00:00
|
|
|
#endif
|
|
|
|
statusbar_icon_volume(volume);
|
2002-08-12 12:31:36 +00:00
|
|
|
statusbar_icon_play_state(current_mode + Icon_Play);
|
2002-10-08 10:24:29 +00:00
|
|
|
switch (global_settings.repeat_mode) {
|
|
|
|
case REPEAT_ONE:
|
|
|
|
statusbar_icon_play_mode(Icon_RepeatOne);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REPEAT_ALL:
|
|
|
|
statusbar_icon_play_mode(Icon_Repeat);
|
|
|
|
break;
|
|
|
|
}
|
2002-08-12 12:31:36 +00:00
|
|
|
if(global_settings.playlist_shuffle)
|
|
|
|
statusbar_icon_shuffle();
|
|
|
|
if (keys_locked)
|
|
|
|
statusbar_icon_lock();
|
2002-08-07 10:35:26 +00:00
|
|
|
#ifdef HAVE_RTC
|
2002-08-30 19:44:58 +00:00
|
|
|
hour = rtc_read(3);
|
|
|
|
hour = ((hour & 0x30) >> 4) * 10 + (hour & 0x0f);
|
|
|
|
minute = rtc_read(2);
|
|
|
|
minute = ((minute & 0x70) >> 4) * 10 + (minute & 0x0f);
|
|
|
|
statusbar_time(hour, minute);
|
2002-08-20 14:33:02 +00:00
|
|
|
#endif
|
2002-08-30 00:39:31 +00:00
|
|
|
|
2002-08-20 19:40:35 +00:00
|
|
|
lcd_update_rect(0, 0, LCD_WIDTH, STATUSBAR_HEIGHT);
|
2002-08-07 10:35:26 +00:00
|
|
|
}
|
|
|
|
#endif
|
2002-07-22 22:41:32 +00:00
|
|
|
}
|