Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
Nicolas Pennequin | 357ffb3 | 2008-05-05 10:32:46 +0000 | [diff] [blame] | 10 | * Copyright (C) 2002 Björn Stenberg |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License |
| 14 | * as published by the Free Software Foundation; either version 2 |
| 15 | * of the License, or (at your option) any later version. |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
Kevin Ferrare | f57d022 | 2005-11-22 21:55:05 +0000 | [diff] [blame] | 21 | |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 22 | #include <stdbool.h> |
| 23 | #include <string.h> |
| 24 | #include <stdio.h> |
| 25 | #include "backlight.h" |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 26 | #include "action.h" |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 27 | #include "lcd.h" |
Dave Chapman | fc865cb | 2006-10-12 20:45:31 +0000 | [diff] [blame] | 28 | #ifdef HAVE_REMOTE_LCD |
| 29 | #include "lcd-remote.h" |
| 30 | #endif |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 31 | #include "lang.h" |
| 32 | #include "icons.h" |
| 33 | #include "font.h" |
Linus Nielsen Feltzing | 8a237a8 | 2005-04-04 12:06:29 +0000 | [diff] [blame] | 34 | #include "audio.h" |
Jörg Hohensohn | f993365 | 2004-01-05 20:42:51 +0000 | [diff] [blame] | 35 | #include "mp3_playback.h" |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 36 | #include "usb.h" |
| 37 | #include "settings.h" |
Markus Braun | 88098be | 2002-10-11 08:56:23 +0000 | [diff] [blame] | 38 | #include "status.h" |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 39 | #include "playlist.h" |
Daniel Stenberg | 79a6cb6 | 2003-02-15 00:03:23 +0000 | [diff] [blame] | 40 | #include "sprintf.h" |
Björn Stenberg | ba371fb | 2003-06-29 16:33:04 +0000 | [diff] [blame] | 41 | #include "kernel.h" |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 42 | #include "power.h" |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 43 | #include "system.h" |
| 44 | #include "powermgmt.h" |
| 45 | #include "adc.h" |
Linus Nielsen Feltzing | 10b92c4 | 2004-03-12 10:20:33 +0000 | [diff] [blame] | 46 | #include "action.h" |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 47 | #include "talk.h" |
Linus Nielsen Feltzing | 5b5003d | 2004-07-24 21:26:41 +0000 | [diff] [blame] | 48 | #include "misc.h" |
Magnus Holmgren | 1e5119b | 2005-07-05 19:33:33 +0000 | [diff] [blame] | 49 | #include "id3.h" |
Jens Arnold | 7f6b640 | 2004-10-12 00:02:51 +0000 | [diff] [blame] | 50 | #include "screens.h" |
Kjell Ericson | 6c2fb55 | 2004-10-19 16:17:35 +0000 | [diff] [blame] | 51 | #include "debug.h" |
Jörg Hohensohn | ce51bc4 | 2005-02-19 16:23:30 +0000 | [diff] [blame] | 52 | #include "led.h" |
Linus Nielsen Feltzing | 674eaca | 2005-04-01 13:41:03 +0000 | [diff] [blame] | 53 | #include "sound.h" |
Kevin Ferrare | e991bee | 2005-11-16 15:12:15 +0000 | [diff] [blame] | 54 | #include "splash.h" |
Kevin Ferrare | 1a1abf2 | 2005-11-20 01:02:14 +0000 | [diff] [blame] | 55 | #include "statusbar.h" |
Kevin Ferrare | 74b6af9 | 2005-11-22 03:38:07 +0000 | [diff] [blame] | 56 | #include "screen_access.h" |
Zakk Roberts | 35d3658 | 2006-04-21 06:20:02 +0000 | [diff] [blame] | 57 | #include "pcmbuf.h" |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 58 | #include "list.h" |
Jonathan Gordon | d152b64 | 2006-12-19 12:26:03 +0000 | [diff] [blame] | 59 | #include "yesno.h" |
Dave Chapman | d746b79 | 2008-03-29 01:14:10 +0000 | [diff] [blame] | 60 | #include "backdrop.h" |
Jonathan Gordon | 95be4fe | 2008-05-11 14:08:46 +0000 | [diff] [blame] | 61 | #include "viewport.h" |
Kevin Ferrare | 1a1abf2 | 2005-11-20 01:02:14 +0000 | [diff] [blame] | 62 | |
Dave Chapman | fc865cb | 2006-10-12 20:45:31 +0000 | [diff] [blame] | 63 | #ifdef HAVE_LCD_BITMAP |
| 64 | #include <bitmaps/usblogo.h> |
| 65 | #endif |
| 66 | |
| 67 | #ifdef HAVE_REMOTE_LCD |
| 68 | #include <bitmaps/remote_usblogo.h> |
| 69 | #endif |
| 70 | |
Jörg Hohensohn | ce51bc4 | 2005-02-19 16:23:30 +0000 | [diff] [blame] | 71 | #ifdef HAVE_MMC |
| 72 | #include "ata_mmc.h" |
| 73 | #endif |
Magnus Holmgren | 4b711c2 | 2005-09-24 15:22:48 +0000 | [diff] [blame] | 74 | #if CONFIG_CODEC == SWCODEC |
| 75 | #include "dsp.h" |
| 76 | #endif |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 77 | |
Markus Braun | 88098be | 2002-10-11 08:56:23 +0000 | [diff] [blame] | 78 | #ifdef HAVE_LCD_BITMAP |
Magnus Holmgren | eab21c6 | 2005-08-11 18:21:14 +0000 | [diff] [blame] | 79 | #define SCROLLBAR_WIDTH 6 |
Markus Braun | 88098be | 2002-10-11 08:56:23 +0000 | [diff] [blame] | 80 | #endif |
| 81 | |
Nils Wallménius | 2e2cbfe | 2007-11-22 19:56:57 +0000 | [diff] [blame] | 82 | /* only used in set_time screen */ |
| 83 | #if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0) |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 84 | static int clamp_value_wrap(int value, int max, int min) |
| 85 | { |
| 86 | if (value > max) |
| 87 | return min; |
| 88 | if (value < min) |
| 89 | return max; |
| 90 | return value; |
| 91 | } |
Nils Wallménius | 2e2cbfe | 2007-11-22 19:56:57 +0000 | [diff] [blame] | 92 | #endif |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 93 | |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 94 | void usb_screen(void) |
| 95 | { |
Daniel Stenberg | 8e43ccb | 2003-12-12 13:34:27 +0000 | [diff] [blame] | 96 | #ifdef USB_NONE |
| 97 | /* nothing here! */ |
| 98 | #else |
Kevin Ferrare | 74b6af9 | 2005-11-22 03:38:07 +0000 | [diff] [blame] | 99 | int i; |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 100 | bool statusbar = global_settings.statusbar; /* force the statusbar */ |
| 101 | global_settings.statusbar = true; |
Dave Chapman | 6c31a9a | 2007-06-06 17:30:01 +0000 | [diff] [blame] | 102 | #if LCD_DEPTH > 1 |
Peter D'Hoye | 93b899d | 2006-05-21 11:00:02 +0000 | [diff] [blame] | 103 | show_main_backdrop(); |
| 104 | #endif |
Nicolas Pennequin | 7fdfa56 | 2007-04-25 21:44:56 +0000 | [diff] [blame] | 105 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 106 | show_remote_main_backdrop(); |
| 107 | #endif |
Dave Chapman | fc865cb | 2006-10-12 20:45:31 +0000 | [diff] [blame] | 108 | FOR_NB_SCREENS(i) |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 109 | { |
Kevin Ferrare | 74b6af9 | 2005-11-22 03:38:07 +0000 | [diff] [blame] | 110 | screens[i].backlight_on(); |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 111 | screens[i].clear_display(); |
| 112 | #if NB_SCREENS > 1 |
| 113 | if (i == SCREEN_REMOTE) |
| 114 | { |
| 115 | screens[i].bitmap(remote_usblogo, |
Marianne Arnold | 99975e9 | 2006-11-20 10:56:22 +0000 | [diff] [blame] | 116 | (LCD_REMOTE_WIDTH-BMPWIDTH_remote_usblogo), |
Dave Chapman | fc865cb | 2006-10-12 20:45:31 +0000 | [diff] [blame] | 117 | (LCD_REMOTE_HEIGHT-BMPHEIGHT_remote_usblogo)/2, |
| 118 | BMPWIDTH_remote_usblogo, BMPHEIGHT_remote_usblogo); |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 119 | } |
| 120 | else |
| 121 | { |
Dave Chapman | fc865cb | 2006-10-12 20:45:31 +0000 | [diff] [blame] | 122 | #endif |
Jens Arnold | d6e9290 | 2006-10-21 12:02:14 +0000 | [diff] [blame] | 123 | #ifdef HAVE_LCD_BITMAP |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 124 | screens[i].transparent_bitmap(usblogo, |
| 125 | (LCD_WIDTH-BMPWIDTH_usblogo), |
Dave Chapman | fc865cb | 2006-10-12 20:45:31 +0000 | [diff] [blame] | 126 | (LCD_HEIGHT-BMPHEIGHT_usblogo)/2, |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 127 | BMPWIDTH_usblogo, BMPHEIGHT_usblogo); |
Dave Chapman | fc865cb | 2006-10-12 20:45:31 +0000 | [diff] [blame] | 128 | #else |
Jens Arnold | 022d026 | 2007-08-18 12:36:15 +0000 | [diff] [blame] | 129 | screens[i].double_height(false); |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 130 | screens[i].puts_scroll(0, 0, "[USB Mode]"); |
| 131 | status_set_param(false); |
| 132 | status_set_audio(false); |
| 133 | status_set_usb(true); |
Kevin Ferrare | 74b6af9 | 2005-11-22 03:38:07 +0000 | [diff] [blame] | 134 | #endif /* HAVE_LCD_BITMAP */ |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 135 | #if NB_SCREENS > 1 |
| 136 | } |
| 137 | #endif |
| 138 | screens[i].update(); |
| 139 | } |
Dave Chapman | fc865cb | 2006-10-12 20:45:31 +0000 | [diff] [blame] | 140 | |
Kevin Ferrare | 74b6af9 | 2005-11-22 03:38:07 +0000 | [diff] [blame] | 141 | gui_syncstatusbar_draw(&statusbars, true); |
| 142 | #ifdef SIMULATOR |
| 143 | while (button_get(true) & BUTTON_REL); |
| 144 | #else |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 145 | usb_acknowledge(SYS_USB_CONNECTED_ACK); |
Markus Braun | 88098be | 2002-10-11 08:56:23 +0000 | [diff] [blame] | 146 | while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) { |
| 147 | if(usb_inserted()) { |
Jörg Hohensohn | 7e1d36f | 2005-02-19 14:45:34 +0000 | [diff] [blame] | 148 | #ifdef HAVE_MMC /* USB-MMC bridge can report activity */ |
| 149 | led(mmc_usb_active(HZ)); |
Kevin Ferrare | 74b6af9 | 2005-11-22 03:38:07 +0000 | [diff] [blame] | 150 | #endif /* HAVE_MMC */ |
Kevin Ferrare | 1a1abf2 | 2005-11-20 01:02:14 +0000 | [diff] [blame] | 151 | gui_syncstatusbar_draw(&statusbars, false); |
Markus Braun | 88098be | 2002-10-11 08:56:23 +0000 | [diff] [blame] | 152 | } |
| 153 | } |
Kevin Ferrare | 74b6af9 | 2005-11-22 03:38:07 +0000 | [diff] [blame] | 154 | #endif /* SIMULATOR */ |
Hardeep Sidhu | 12d1844 | 2003-01-09 03:53:46 +0000 | [diff] [blame] | 155 | #ifdef HAVE_LCD_CHARCELLS |
| 156 | status_set_usb(false); |
Kevin Ferrare | 74b6af9 | 2005-11-22 03:38:07 +0000 | [diff] [blame] | 157 | #endif /* HAVE_LCD_CHARCELLS */ |
| 158 | FOR_NB_SCREENS(i) |
| 159 | screens[i].backlight_on(); |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 160 | global_settings.statusbar = statusbar; |
Daniel Stenberg | 8e43ccb | 2003-12-12 13:34:27 +0000 | [diff] [blame] | 161 | #endif /* USB_NONE */ |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 162 | } |
| 163 | |
Jens Arnold | 7f6b640 | 2004-10-12 00:02:51 +0000 | [diff] [blame] | 164 | #ifdef HAVE_MMC |
| 165 | int mmc_remove_request(void) |
| 166 | { |
Michael Sevakis | a9b2fb5 | 2007-10-16 01:25:17 +0000 | [diff] [blame] | 167 | struct queue_event ev; |
Kevin Ferrare | 6919d1e | 2005-11-22 04:15:27 +0000 | [diff] [blame] | 168 | int i; |
Kevin Ferrare | 74b6af9 | 2005-11-22 03:38:07 +0000 | [diff] [blame] | 169 | FOR_NB_SCREENS(i) |
| 170 | screens[i].clear_display(); |
Jens Arnold | 4d6374c | 2007-03-16 21:56:08 +0000 | [diff] [blame] | 171 | gui_syncsplash(1, str(LANG_REMOVE_MMC)); |
Steve Bavin | 32a9575 | 2007-10-19 15:31:42 +0000 | [diff] [blame] | 172 | if (global_settings.talk_menu) |
Jens Arnold | 1f6c480 | 2004-11-12 22:19:29 +0000 | [diff] [blame] | 173 | talk_id(LANG_REMOVE_MMC, false); |
Magnus Holmgren | 1e5119b | 2005-07-05 19:33:33 +0000 | [diff] [blame] | 174 | |
Jens Arnold | 7f6b640 | 2004-10-12 00:02:51 +0000 | [diff] [blame] | 175 | while (1) |
| 176 | { |
| 177 | queue_wait_w_tmo(&button_queue, &ev, HZ/2); |
| 178 | switch (ev.id) |
| 179 | { |
Michael Sevakis | 1167e3c | 2007-06-30 02:08:27 +0000 | [diff] [blame] | 180 | case SYS_HOTSWAP_EXTRACTED: |
| 181 | return SYS_HOTSWAP_EXTRACTED; |
Magnus Holmgren | 1e5119b | 2005-07-05 19:33:33 +0000 | [diff] [blame] | 182 | |
Jens Arnold | 7f6b640 | 2004-10-12 00:02:51 +0000 | [diff] [blame] | 183 | case SYS_USB_DISCONNECTED: |
| 184 | return SYS_USB_DISCONNECTED; |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | #endif |
| 189 | |
Nils Wallménius | 3f8c075 | 2007-07-08 15:32:56 +0000 | [diff] [blame] | 190 | /* the charging screen is only used for archos targets */ |
| 191 | #if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) && defined(CPU_SH) |
Jörg Hohensohn | 20caff2 | 2003-07-19 21:43:12 +0000 | [diff] [blame] | 192 | |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 193 | #ifdef HAVE_LCD_BITMAP |
Jens Arnold | 2597a13 | 2006-12-25 14:01:47 +0000 | [diff] [blame] | 194 | static void charging_display_info(bool animate) |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 195 | { |
| 196 | unsigned char charging_logo[36]; |
| 197 | const int pox_x = (LCD_WIDTH - sizeof(charging_logo)) / 2; |
Jörg Hohensohn | 20caff2 | 2003-07-19 21:43:12 +0000 | [diff] [blame] | 198 | const int pox_y = 32; |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 199 | static unsigned phase = 3; |
| 200 | unsigned i; |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 201 | char buf[32]; |
Jörg Hohensohn | eb28d43 | 2003-12-03 07:05:13 +0000 | [diff] [blame] | 202 | (void)buf; |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 203 | |
Jörg Hohensohn | eb28d43 | 2003-12-03 07:05:13 +0000 | [diff] [blame] | 204 | #ifdef NEED_ATA_POWER_BATT_MEASURE |
| 205 | if (ide_powered()) /* FM and V2 can only measure when ATA power is on */ |
| 206 | #endif |
| 207 | { |
Michael Sevakis | 9e8fe0e | 2006-10-30 11:33:38 +0000 | [diff] [blame] | 208 | int battv = battery_voltage(); |
Jens Arnold | 1d1d9a8 | 2007-08-15 23:57:27 +0000 | [diff] [blame] | 209 | snprintf(buf, 32, " Batt: %d.%02dV %d%% ", battv / 1000, |
| 210 | (battv % 1000) / 10, battery_level()); |
Jörg Hohensohn | eb28d43 | 2003-12-03 07:05:13 +0000 | [diff] [blame] | 211 | lcd_puts(0, 7, buf); |
| 212 | } |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 213 | |
Jens Arnold | 0dd1f8e | 2006-06-06 22:23:52 +0000 | [diff] [blame] | 214 | #if CONFIG_CHARGING == CHARGING_CONTROL |
Jörg Hohensohn | 20caff2 | 2003-07-19 21:43:12 +0000 | [diff] [blame] | 215 | |
| 216 | snprintf(buf, 32, "Charge mode:"); |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 217 | lcd_puts(0, 2, buf); |
Jörg Hohensohn | 20caff2 | 2003-07-19 21:43:12 +0000 | [diff] [blame] | 218 | |
Jens Arnold | 0dd1f8e | 2006-06-06 22:23:52 +0000 | [diff] [blame] | 219 | if (charge_state == CHARGING) |
Jörg Hohensohn | 20caff2 | 2003-07-19 21:43:12 +0000 | [diff] [blame] | 220 | snprintf(buf, 32, str(LANG_BATTERY_CHARGE)); |
Jens Arnold | 0dd1f8e | 2006-06-06 22:23:52 +0000 | [diff] [blame] | 221 | else if (charge_state == TOPOFF) |
Jörg Hohensohn | 20caff2 | 2003-07-19 21:43:12 +0000 | [diff] [blame] | 222 | snprintf(buf, 32, str(LANG_BATTERY_TOPOFF_CHARGE)); |
Jens Arnold | 0dd1f8e | 2006-06-06 22:23:52 +0000 | [diff] [blame] | 223 | else if (charge_state == TRICKLE) |
Jörg Hohensohn | 20caff2 | 2003-07-19 21:43:12 +0000 | [diff] [blame] | 224 | snprintf(buf, 32, str(LANG_BATTERY_TRICKLE_CHARGE)); |
| 225 | else |
| 226 | snprintf(buf, 32, "not charging"); |
| 227 | |
| 228 | lcd_puts(0, 3, buf); |
Linus Nielsen Feltzing | ae815a0 | 2004-10-12 08:42:11 +0000 | [diff] [blame] | 229 | if (!charger_enabled) |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 230 | animate = false; |
Jens Arnold | 0dd1f8e | 2006-06-06 22:23:52 +0000 | [diff] [blame] | 231 | #endif /* CONFIG_CHARGING == CHARGING_CONTROL */ |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 232 | |
Magnus Holmgren | 1e5119b | 2005-07-05 19:33:33 +0000 | [diff] [blame] | 233 | |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 234 | /* middle part */ |
| 235 | memset(charging_logo+3, 0x00, 32); |
| 236 | charging_logo[0] = 0x3C; |
| 237 | charging_logo[1] = 0x24; |
| 238 | charging_logo[2] = charging_logo[35] = 0xFF; |
Magnus Holmgren | 1e5119b | 2005-07-05 19:33:33 +0000 | [diff] [blame] | 239 | |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 240 | if (!animate) |
| 241 | { /* draw the outline */ |
| 242 | /* middle part */ |
Peter D'Hoye | 8ed3b32 | 2008-05-23 21:43:40 +0000 | [diff] [blame] | 243 | lcd_mono_bitmap(charging_logo, pox_x, pox_y + 8, |
| 244 | sizeof(charging_logo), 8); |
Jens Arnold | 7e11acb | 2005-06-28 23:15:47 +0000 | [diff] [blame] | 245 | lcd_set_drawmode(DRMODE_FG); |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 246 | /* upper line */ |
Magnus Holmgren | 1e5119b | 2005-07-05 19:33:33 +0000 | [diff] [blame] | 247 | charging_logo[0] = charging_logo[1] = 0x00; |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 248 | memset(charging_logo+2, 0x80, 34); |
Jens Arnold | f894a4c | 2005-07-06 22:58:02 +0000 | [diff] [blame] | 249 | lcd_mono_bitmap(charging_logo, pox_x, pox_y, sizeof(charging_logo), 8); |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 250 | /* lower line */ |
| 251 | memset(charging_logo+2, 0x01, 34); |
Peter D'Hoye | 8ed3b32 | 2008-05-23 21:43:40 +0000 | [diff] [blame] | 252 | lcd_mono_bitmap(charging_logo, pox_x, pox_y + 16, |
| 253 | sizeof(charging_logo), 8); |
Jens Arnold | 7e11acb | 2005-06-28 23:15:47 +0000 | [diff] [blame] | 254 | lcd_set_drawmode(DRMODE_SOLID); |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 255 | } |
| 256 | else |
| 257 | { /* animate the middle part */ |
| 258 | for (i = 3; i<MIN(sizeof(charging_logo)-1, phase); i++) |
| 259 | { |
| 260 | if ((i-phase) % 8 == 0) |
| 261 | { /* draw a "bubble" here */ |
| 262 | unsigned bitpos; |
| 263 | bitpos = (phase + i/8) % 15; /* "bounce" effect */ |
Magnus Holmgren | 1e5119b | 2005-07-05 19:33:33 +0000 | [diff] [blame] | 264 | if (bitpos > 7) |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 265 | bitpos = 14 - bitpos; |
| 266 | charging_logo[i] = 0x01 << bitpos; |
| 267 | } |
| 268 | } |
Peter D'Hoye | 8ed3b32 | 2008-05-23 21:43:40 +0000 | [diff] [blame] | 269 | lcd_mono_bitmap(charging_logo, pox_x, pox_y + 8, |
| 270 | sizeof(charging_logo), 8); |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 271 | phase++; |
| 272 | } |
| 273 | lcd_update(); |
| 274 | } |
Jörg Hohensohn | 20caff2 | 2003-07-19 21:43:12 +0000 | [diff] [blame] | 275 | #else /* not HAVE_LCD_BITMAP */ |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 276 | |
Jens Arnold | ad4e3d6 | 2007-03-26 07:52:13 +0000 | [diff] [blame] | 277 | static unsigned long logo_chars[4]; |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 278 | static const unsigned char logo_pattern[] = { |
Jens Arnold | ad4e3d6 | 2007-03-26 07:52:13 +0000 | [diff] [blame] | 279 | 0x07, 0x04, 0x1c, 0x14, 0x1c, 0x04, 0x07, 0, /* char 1 */ |
| 280 | 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0, /* char 2 */ |
| 281 | 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0, /* char 3 */ |
| 282 | 0x1f, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1f, 0, /* char 4 */ |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 283 | }; |
| 284 | |
| 285 | static void logo_lock_patterns(bool on) |
| 286 | { |
Magnus Holmgren | 1e5119b | 2005-07-05 19:33:33 +0000 | [diff] [blame] | 287 | int i; |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 288 | |
| 289 | if (on) |
| 290 | { |
| 291 | for (i = 0; i < 4; i++) |
| 292 | logo_chars[i] = lcd_get_locked_pattern(); |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 293 | } |
| 294 | else |
| 295 | { |
| 296 | for (i = 0; i < 4; i++) |
| 297 | lcd_unlock_pattern(logo_chars[i]); |
| 298 | } |
| 299 | } |
| 300 | |
Jens Arnold | 2597a13 | 2006-12-25 14:01:47 +0000 | [diff] [blame] | 301 | static void charging_display_info(bool animate) |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 302 | { |
Michael Sevakis | 9e8fe0e | 2006-10-30 11:33:38 +0000 | [diff] [blame] | 303 | int battv; |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 304 | unsigned i, ypos; |
| 305 | static unsigned phase = 3; |
Jens Arnold | ad4e3d6 | 2007-03-26 07:52:13 +0000 | [diff] [blame] | 306 | char buf[32]; |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 307 | |
Michael Sevakis | 9e8fe0e | 2006-10-30 11:33:38 +0000 | [diff] [blame] | 308 | battv = battery_voltage(); |
Jens Arnold | 1d1d9a8 | 2007-08-15 23:57:27 +0000 | [diff] [blame] | 309 | snprintf(buf, sizeof(buf), " %d.%02dV", battv / 1000, (battv % 1000) / 10); |
Jens Arnold | ad4e3d6 | 2007-03-26 07:52:13 +0000 | [diff] [blame] | 310 | lcd_puts(4, 1, buf); |
Magnus Holmgren | 1e5119b | 2005-07-05 19:33:33 +0000 | [diff] [blame] | 311 | |
Jens Arnold | ad4e3d6 | 2007-03-26 07:52:13 +0000 | [diff] [blame] | 312 | memcpy(buf, logo_pattern, 32); /* copy logo patterns */ |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 313 | |
| 314 | if (!animate) /* build the screen */ |
| 315 | { |
| 316 | lcd_double_height(false); |
| 317 | lcd_puts(0, 0, "[Charging]"); |
Jens Arnold | ad4e3d6 | 2007-03-26 07:52:13 +0000 | [diff] [blame] | 318 | for (i = 0; i < 4; i++) |
| 319 | lcd_putc(i, 1, logo_chars[i]); |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 320 | } |
| 321 | else /* animate the logo */ |
| 322 | { |
| 323 | for (i = 3; i < MIN(19, phase); i++) |
| 324 | { |
| 325 | if ((i - phase) % 5 == 0) |
| 326 | { /* draw a "bubble" here */ |
| 327 | ypos = (phase + i/5) % 9; /* "bounce" effect */ |
| 328 | if (ypos > 4) |
| 329 | ypos = 8 - ypos; |
Jens Arnold | ad4e3d6 | 2007-03-26 07:52:13 +0000 | [diff] [blame] | 330 | buf[5 - ypos + 8 * (i/5)] |= 0x10 >> (i%5); |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 331 | } |
| 332 | } |
| 333 | phase++; |
| 334 | } |
Magnus Holmgren | 1e5119b | 2005-07-05 19:33:33 +0000 | [diff] [blame] | 335 | |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 336 | for (i = 0; i < 4; i++) |
Jens Arnold | ad4e3d6 | 2007-03-26 07:52:13 +0000 | [diff] [blame] | 337 | lcd_define_pattern(logo_chars[i], buf + 8 * i); |
Jens Arnold | f9b90e9 | 2007-04-06 22:55:00 +0000 | [diff] [blame] | 338 | |
| 339 | lcd_update(); |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 340 | } |
Jens Arnold | 61753a8 | 2004-11-21 00:44:44 +0000 | [diff] [blame] | 341 | #endif /* (not) HAVE_LCD_BITMAP */ |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 342 | |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 343 | /* blocks while charging, returns on event: |
| 344 | 1 if charger cable was removed |
| 345 | 2 if Off/Stop key was pressed |
| 346 | 3 if On key was pressed |
| 347 | 4 if USB was connected */ |
Michael Sevakis | 9e8fe0e | 2006-10-30 11:33:38 +0000 | [diff] [blame] | 348 | |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 349 | int charging_screen(void) |
| 350 | { |
Jean-Philippe Bernardy | 06f1c0a | 2005-02-12 12:51:06 +0000 | [diff] [blame] | 351 | unsigned int button; |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 352 | int rc = 0; |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 353 | |
| 354 | ide_power_enable(false); /* power down the disk, else would be spinning */ |
| 355 | |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 356 | lcd_clear_display(); |
Jens Arnold | b3e31b9 | 2004-11-20 22:43:38 +0000 | [diff] [blame] | 357 | backlight_set_timeout(global_settings.backlight_timeout); |
Jens Arnold | 748c751 | 2005-05-30 05:57:19 +0000 | [diff] [blame] | 358 | #ifdef HAVE_REMOTE_LCD |
Christian Gmeiner | 7477c09 | 2005-05-30 00:00:22 +0000 | [diff] [blame] | 359 | remote_backlight_set_timeout(global_settings.remote_backlight_timeout); |
Jens Arnold | 748c751 | 2005-05-30 05:57:19 +0000 | [diff] [blame] | 360 | #endif |
Jens Arnold | a6d409d | 2005-11-23 20:12:33 +0000 | [diff] [blame] | 361 | backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged); |
Kevin Ferrare | 1a1abf2 | 2005-11-20 01:02:14 +0000 | [diff] [blame] | 362 | gui_syncstatusbar_draw(&statusbars, true); |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 363 | |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 364 | #ifdef HAVE_LCD_CHARCELLS |
| 365 | logo_lock_patterns(true); |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 366 | #endif |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 367 | charging_display_info(false); |
| 368 | |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 369 | do |
| 370 | { |
Kevin Ferrare | 1a1abf2 | 2005-11-20 01:02:14 +0000 | [diff] [blame] | 371 | gui_syncstatusbar_draw(&statusbars, false); |
Jörg Hohensohn | b5b7304 | 2003-07-18 22:01:13 +0000 | [diff] [blame] | 372 | charging_display_info(true); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 373 | button = get_action(CONTEXT_STD,HZ/3); |
| 374 | if (button == ACTION_STD_OK) |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 375 | rc = 2; |
Jens Arnold | 7c7dd43 | 2005-07-11 19:14:26 +0000 | [diff] [blame] | 376 | else if (usb_detect()) |
| 377 | rc = 3; |
| 378 | else if (!charger_inserted()) |
| 379 | rc = 1; |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 380 | } while (!rc); |
| 381 | |
Jens Arnold | 2996d17 | 2004-11-21 00:17:59 +0000 | [diff] [blame] | 382 | #ifdef HAVE_LCD_CHARCELLS |
| 383 | logo_lock_patterns(false); |
| 384 | #endif |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 385 | return rc; |
| 386 | } |
Nils Wallménius | 3f8c075 | 2007-07-08 15:32:56 +0000 | [diff] [blame] | 387 | #endif /* CONFIG_CHARGING && !HAVE_POWEROFF_WHILE_CHARGING && defined(CPU_SH) */ |
Jörg Hohensohn | 5dd17b1 | 2003-07-17 20:29:51 +0000 | [diff] [blame] | 388 | |
Nils Wallménius | f28da1a | 2007-08-12 19:49:03 +0000 | [diff] [blame] | 389 | #if CONFIG_CHARGING |
Björn Stenberg | 461d6e3 | 2003-12-04 00:08:25 +0000 | [diff] [blame] | 390 | void charging_splash(void) |
| 391 | { |
Jens Arnold | 4d6374c | 2007-03-16 21:56:08 +0000 | [diff] [blame] | 392 | gui_syncsplash(2*HZ, (unsigned char *)str(LANG_BATTERY_CHARGE)); |
Jens Arnold | 3c348df | 2005-01-26 22:48:25 +0000 | [diff] [blame] | 393 | button_clear_queue(); |
Björn Stenberg | 461d6e3 | 2003-12-04 00:08:25 +0000 | [diff] [blame] | 394 | } |
Jens Arnold | cd0bb1c | 2005-05-07 01:30:16 +0000 | [diff] [blame] | 395 | #endif |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 396 | |
| 397 | |
Jens Arnold | 2c7b127 | 2007-03-16 23:47:03 +0000 | [diff] [blame] | 398 | #if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0) |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 399 | |
| 400 | /* little helper function for voice output */ |
Jens Arnold | 8fb3361 | 2004-08-18 01:09:31 +0000 | [diff] [blame] | 401 | static void say_time(int cursorpos, const struct tm *tm) |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 402 | { |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 403 | int value = 0; |
Nils Wallménius | 537b27d | 2007-10-24 10:29:45 +0000 | [diff] [blame] | 404 | int unit = 0; |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 405 | |
Steve Bavin | 32a9575 | 2007-10-19 15:31:42 +0000 | [diff] [blame] | 406 | if (!global_settings.talk_menu) |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 407 | return; |
| 408 | |
| 409 | switch(cursorpos) |
| 410 | { |
| 411 | case 0: |
| 412 | value = tm->tm_hour; |
Nils Wallménius | 537b27d | 2007-10-24 10:29:45 +0000 | [diff] [blame] | 413 | unit = UNIT_HOUR; |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 414 | break; |
| 415 | case 1: |
| 416 | value = tm->tm_min; |
Nils Wallménius | 537b27d | 2007-10-24 10:29:45 +0000 | [diff] [blame] | 417 | unit = UNIT_MIN; |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 418 | break; |
| 419 | case 2: |
| 420 | value = tm->tm_sec; |
Nils Wallménius | 537b27d | 2007-10-24 10:29:45 +0000 | [diff] [blame] | 421 | unit = UNIT_SEC; |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 422 | break; |
| 423 | case 3: |
| 424 | value = tm->tm_year + 1900; |
| 425 | break; |
| 426 | case 5: |
| 427 | value = tm->tm_mday; |
| 428 | break; |
| 429 | } |
Magnus Holmgren | 1e5119b | 2005-07-05 19:33:33 +0000 | [diff] [blame] | 430 | |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 431 | if (cursorpos == 4) /* month */ |
Linus Nielsen Feltzing | 08ebcad | 2004-04-21 21:40:26 +0000 | [diff] [blame] | 432 | talk_id(LANG_MONTH_JANUARY + tm->tm_mon, false); |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 433 | else |
Nils Wallménius | 537b27d | 2007-10-24 10:29:45 +0000 | [diff] [blame] | 434 | talk_value(value, unit, false); |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | |
| 438 | #define INDEX_X 0 |
| 439 | #define INDEX_Y 1 |
Nils Wallménius | 2e80610 | 2007-07-01 12:08:45 +0000 | [diff] [blame] | 440 | |
| 441 | #define SEPARATOR ":" |
Nils Wallménius | 2e80610 | 2007-07-01 12:08:45 +0000 | [diff] [blame] | 442 | bool set_time_screen(const char* title, struct tm *tm) |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 443 | { |
| 444 | bool done = false; |
| 445 | int button; |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 446 | unsigned int i, j, s; |
| 447 | int cursorpos = 0; |
Nils Wallménius | 2e80610 | 2007-07-01 12:08:45 +0000 | [diff] [blame] | 448 | unsigned int julianday; |
| 449 | unsigned int realyear; |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 450 | unsigned int width; |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 451 | unsigned int min, max; |
Nils Wallménius | 3f8c075 | 2007-07-08 15:32:56 +0000 | [diff] [blame] | 452 | unsigned int statusbar_height = 0; |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 453 | unsigned int separator_width, weekday_width; |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 454 | unsigned int prev_line_height; |
| 455 | int daysinmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 456 | unsigned char buffer[20]; |
Jonathan Gordon | aff220c | 2008-05-11 13:59:27 +0000 | [diff] [blame] | 457 | struct viewport vp[NB_SCREENS]; |
| 458 | int nb_lines; |
Jens Arnold | 033ba16 | 2004-08-26 20:30:22 +0000 | [diff] [blame] | 459 | |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 460 | /* 6 possible cursor possitions, 2 values stored for each: x, y */ |
| 461 | unsigned int cursor[6][2]; |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 462 | |
| 463 | int *valptr = NULL; |
Nils Wallménius | 2e80610 | 2007-07-01 12:08:45 +0000 | [diff] [blame] | 464 | unsigned char *ptr[6]; |
Nils Wallménius | 2e80610 | 2007-07-01 12:08:45 +0000 | [diff] [blame] | 465 | |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 466 | if(global_settings.statusbar) |
Nils Wallménius | 2e80610 | 2007-07-01 12:08:45 +0000 | [diff] [blame] | 467 | statusbar_height = STATUSBAR_HEIGHT; |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 468 | |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 469 | /* speak selection when screen is entered */ |
| 470 | say_time(cursorpos, tm); |
| 471 | |
| 472 | while (!done) { |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 473 | /* for easy acess in the drawing loop */ |
| 474 | ptr[0] = buffer; /* hours */ |
| 475 | ptr[1] = buffer + 3; /* minutes */ |
| 476 | ptr[2] = buffer + 6; /* seconds */ |
| 477 | ptr[3] = buffer + 9; /* year */ |
Steve Bavin | fda41b8 | 2007-10-24 15:34:36 +0000 | [diff] [blame] | 478 | ptr[4] = str(LANG_MONTH_JANUARY + tm->tm_mon); /* monthname */ |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 479 | ptr[5] = buffer + 14; /* day of month */ |
| 480 | |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 481 | /* calculate the number of days in febuary */ |
| 482 | realyear = tm->tm_year + 1900; |
| 483 | if((realyear % 4 == 0 && !(realyear % 100 == 0)) || realyear % 400 == 0) |
| 484 | daysinmonth[1] = 29; |
| 485 | else |
| 486 | daysinmonth[1] = 28; |
| 487 | |
| 488 | /* fix day if month or year changed */ |
| 489 | if (tm->tm_mday > daysinmonth[tm->tm_mon]) |
| 490 | tm->tm_mday = daysinmonth[tm->tm_mon]; |
| 491 | |
| 492 | /* calculate day of week */ |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 493 | julianday = tm->tm_mday; |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 494 | for(i = 0; (int)i < tm->tm_mon; i++) { |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 495 | julianday += daysinmonth[i]; |
| 496 | } |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 497 | |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 498 | tm->tm_wday = (realyear + julianday + (realyear - 1) / 4 - |
| 499 | (realyear - 1) / 100 + (realyear - 1) / 400 + 7 - 1) % 7; |
| 500 | |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 501 | /* put all the numbers we want from the tm struct into |
| 502 | an easily printable buffer */ |
Nils Wallménius | ede3731 | 2007-07-02 19:52:19 +0000 | [diff] [blame] | 503 | snprintf(buffer, sizeof(buffer), |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 504 | "%02d " "%02d " "%02d " "%04d " "%02d", |
Nils Wallménius | 2e80610 | 2007-07-01 12:08:45 +0000 | [diff] [blame] | 505 | tm->tm_hour, tm->tm_min, tm->tm_sec, |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 506 | tm->tm_year+1900, tm->tm_mday); |
Nils Wallménius | ede3731 | 2007-07-02 19:52:19 +0000 | [diff] [blame] | 507 | |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 508 | /* convert spaces in the buffer to '\0' to make it possible to work |
Nils Wallménius | 2e80610 | 2007-07-01 12:08:45 +0000 | [diff] [blame] | 509 | directly on the buffer */ |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 510 | for(i=0; i < sizeof(buffer); i++) |
| 511 | { |
| 512 | if(buffer[i] == ' ') |
| 513 | buffer[i] = '\0'; |
| 514 | } |
| 515 | |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 516 | FOR_NB_SCREENS(s) |
Nils Wallménius | 2e80610 | 2007-07-01 12:08:45 +0000 | [diff] [blame] | 517 | { |
Jonathan Gordon | aff220c | 2008-05-11 13:59:27 +0000 | [diff] [blame] | 518 | viewport_set_defaults(&vp[s], s); |
| 519 | nb_lines = viewport_get_nb_lines(&vp[s]); |
| 520 | |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 521 | /* minimum lines needed is 2 + title line */ |
Jonathan Gordon | aff220c | 2008-05-11 13:59:27 +0000 | [diff] [blame] | 522 | if (nb_lines < 4) |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 523 | { |
Jonathan Gordon | aff220c | 2008-05-11 13:59:27 +0000 | [diff] [blame] | 524 | vp[s].font = FONT_SYSFIXED; |
| 525 | nb_lines = viewport_get_nb_lines(&vp[s]); |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | /* recalculate the positions and offsets */ |
Jonathan Gordon | aff220c | 2008-05-11 13:59:27 +0000 | [diff] [blame] | 529 | if (nb_lines >= 3) |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 530 | screens[s].getstringsize(title, NULL, &prev_line_height); |
Nils Wallménius | 2e80610 | 2007-07-01 12:08:45 +0000 | [diff] [blame] | 531 | else |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 532 | prev_line_height = 0; |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 533 | |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 534 | screens[s].getstringsize(SEPARATOR, &separator_width, NULL); |
| 535 | |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 536 | /* weekday */ |
Peter D'Hoye | 8ed3b32 | 2008-05-23 21:43:40 +0000 | [diff] [blame] | 537 | screens[s].getstringsize(str(LANG_WEEKDAY_SUNDAY + tm->tm_wday), |
| 538 | &weekday_width, NULL); |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 539 | screens[s].getstringsize(" ", &separator_width, NULL); |
| 540 | |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 541 | for(i=0, j=0; i < 6; i++) |
| 542 | { |
| 543 | if(i==3) /* second row */ |
| 544 | { |
| 545 | j = weekday_width + separator_width;; |
| 546 | prev_line_height *= 2; |
| 547 | } |
| 548 | screens[s].getstringsize(ptr[i], &width, NULL); |
| 549 | cursor[i][INDEX_Y] = prev_line_height + statusbar_height; |
| 550 | cursor[i][INDEX_X] = j; |
| 551 | j += width + separator_width; |
| 552 | } |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 553 | |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 554 | /* draw the screen */ |
Jonathan Gordon | aff220c | 2008-05-11 13:59:27 +0000 | [diff] [blame] | 555 | screens[s].set_viewport(&vp[s]); |
Jonathan Gordon | aff220c | 2008-05-11 13:59:27 +0000 | [diff] [blame] | 556 | screens[s].clear_viewport(); |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 557 | /* display the screen title */ |
| 558 | screens[s].puts_scroll(0, 0, title); |
Nils Wallménius | aedf68a | 2007-07-21 08:28:48 +0000 | [diff] [blame] | 559 | |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 560 | /* these are not selectable, so we draw them outside the loop */ |
Peter D'Hoye | 8ed3b32 | 2008-05-23 21:43:40 +0000 | [diff] [blame] | 561 | /* name of the week day */ |
| 562 | screens[s].putsxy(0, cursor[3][INDEX_Y], |
| 563 | str(LANG_WEEKDAY_SUNDAY + tm->tm_wday)); |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 564 | |
| 565 | /* draw the selected item with drawmode set to |
| 566 | DRMODE_SOLID|DRMODE_INVERSEVID, all other selectable |
| 567 | items with drawmode DRMODE_SOLID */ |
| 568 | for(i=0; i<6; i++) |
| 569 | { |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 570 | if (cursorpos == (int)i) |
Jonathan Gordon | aff220c | 2008-05-11 13:59:27 +0000 | [diff] [blame] | 571 | vp[s].drawmode = (DRMODE_SOLID|DRMODE_INVERSEVID); |
Peter D'Hoye | 8ed3b32 | 2008-05-23 21:43:40 +0000 | [diff] [blame] | 572 | |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 573 | screens[s].putsxy(cursor[i][INDEX_X], |
| 574 | cursor[i][INDEX_Y], ptr[i]); |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 575 | |
Jonathan Gordon | aff220c | 2008-05-11 13:59:27 +0000 | [diff] [blame] | 576 | vp[s].drawmode = DRMODE_SOLID; |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 577 | |
Peter D'Hoye | 8ed3b32 | 2008-05-23 21:43:40 +0000 | [diff] [blame] | 578 | screens[s].putsxy(cursor[i/4 +1][INDEX_X] - separator_width, |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 579 | cursor[0][INDEX_Y], SEPARATOR); |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | /* print help text */ |
Jonathan Gordon | aff220c | 2008-05-11 13:59:27 +0000 | [diff] [blame] | 583 | if (nb_lines > 4) |
Nils Wallménius | b311367 | 2007-08-05 19:19:39 +0000 | [diff] [blame] | 584 | screens[s].puts(0, 4, str(LANG_TIME_SET_BUTTON)); |
Jonathan Gordon | aff220c | 2008-05-11 13:59:27 +0000 | [diff] [blame] | 585 | if (nb_lines > 5) |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 586 | screens[s].puts(0, 5, str(LANG_TIME_REVERT)); |
Jonathan Gordon | aff220c | 2008-05-11 13:59:27 +0000 | [diff] [blame] | 587 | screens[s].update_viewport(); |
| 588 | screens[s].set_viewport(NULL); |
Nils Wallménius | 2e80610 | 2007-07-01 12:08:45 +0000 | [diff] [blame] | 589 | } |
Kevin Ferrare | 1a1abf2 | 2005-11-20 01:02:14 +0000 | [diff] [blame] | 590 | gui_syncstatusbar_draw(&statusbars, true); |
Nils Wallménius | 3f8c075 | 2007-07-08 15:32:56 +0000 | [diff] [blame] | 591 | |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 592 | /* set the most common numbers */ |
| 593 | min = 0; |
| 594 | max = 59; |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 595 | /* calculate the minimum and maximum for the number under cursor */ |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 596 | switch(cursorpos) { |
| 597 | case 0: /* hour */ |
| 598 | max = 23; |
| 599 | valptr = &tm->tm_hour; |
| 600 | break; |
| 601 | case 1: /* minute */ |
| 602 | valptr = &tm->tm_min; |
| 603 | break; |
| 604 | case 2: /* second */ |
| 605 | valptr = &tm->tm_sec; |
| 606 | break; |
| 607 | case 3: /* year */ |
| 608 | min = 1; |
| 609 | max = 200; |
| 610 | valptr = &tm->tm_year; |
| 611 | break; |
| 612 | case 4: /* month */ |
| 613 | max = 11; |
| 614 | valptr = &tm->tm_mon; |
| 615 | break; |
| 616 | case 5: /* day */ |
| 617 | min = 1; |
| 618 | max = daysinmonth[tm->tm_mon]; |
| 619 | valptr = &tm->tm_mday; |
| 620 | break; |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 621 | } |
| 622 | |
Jonathan Gordon | 3d73b8e | 2007-07-15 10:30:11 +0000 | [diff] [blame] | 623 | button = get_action(CONTEXT_SETTINGS_TIME, TIMEOUT_BLOCK); |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 624 | switch ( button ) { |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 625 | case ACTION_STD_PREV: |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 626 | cursorpos = clamp_value_wrap(--cursorpos, 5, 0); |
| 627 | say_time(cursorpos, tm); |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 628 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 629 | case ACTION_STD_NEXT: |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 630 | cursorpos = clamp_value_wrap(++cursorpos, 5, 0); |
| 631 | say_time(cursorpos, tm); |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 632 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 633 | case ACTION_SETTINGS_INC: |
Jonathan Gordon | d12f81d | 2006-08-21 07:03:15 +0000 | [diff] [blame] | 634 | case ACTION_SETTINGS_INCREPEAT: |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 635 | *valptr = clamp_value_wrap(++(*valptr), max, min); |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 636 | say_time(cursorpos, tm); |
| 637 | break; |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 638 | case ACTION_SETTINGS_DEC: |
Jonathan Gordon | d12f81d | 2006-08-21 07:03:15 +0000 | [diff] [blame] | 639 | case ACTION_SETTINGS_DECREPEAT: |
Nils Wallménius | 7567e99 | 2007-11-22 19:46:27 +0000 | [diff] [blame] | 640 | *valptr = clamp_value_wrap(--(*valptr), max, min); |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 641 | say_time(cursorpos, tm); |
| 642 | break; |
Björn Stenberg | 6c33c51 | 2004-09-19 21:58:37 +0000 | [diff] [blame] | 643 | |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 644 | case ACTION_STD_OK: |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 645 | done = true; |
| 646 | break; |
Björn Stenberg | 6c33c51 | 2004-09-19 21:58:37 +0000 | [diff] [blame] | 647 | |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 648 | case ACTION_STD_CANCEL: |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 649 | done = true; |
| 650 | tm->tm_year = -1; |
| 651 | break; |
| 652 | |
Linus Nielsen Feltzing | ade5d7b | 2004-07-26 16:06:59 +0000 | [diff] [blame] | 653 | default: |
| 654 | if (default_event_handler(button) == SYS_USB_CONNECTED) |
| 655 | return true; |
| 656 | break; |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 657 | } |
| 658 | } |
Linus Nielsen Feltzing | 1de3dd5 | 2004-04-21 06:49:12 +0000 | [diff] [blame] | 659 | return false; |
| 660 | } |
Jens Arnold | 2c7b127 | 2007-03-16 23:47:03 +0000 | [diff] [blame] | 661 | #endif /* defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0) */ |
Linus Nielsen Feltzing | 5b5003d | 2004-07-24 21:26:41 +0000 | [diff] [blame] | 662 | |
Jens Arnold | e23348a | 2005-06-22 22:22:23 +0000 | [diff] [blame] | 663 | #if (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF) |
Linus Nielsen Feltzing | 5b5003d | 2004-07-24 21:26:41 +0000 | [diff] [blame] | 664 | bool shutdown_screen(void) |
| 665 | { |
| 666 | int button; |
| 667 | bool done = false; |
Jonathan Gordon | 8055825 | 2006-10-09 12:14:25 +0000 | [diff] [blame] | 668 | long time_entered = current_tick; |
Linus Nielsen Feltzing | 5b5003d | 2004-07-24 21:26:41 +0000 | [diff] [blame] | 669 | |
| 670 | lcd_stop_scroll(); |
| 671 | |
Jens Arnold | 4d6374c | 2007-03-16 21:56:08 +0000 | [diff] [blame] | 672 | gui_syncsplash(0, str(LANG_CONFIRM_SHUTDOWN)); |
Linus Nielsen Feltzing | bdbb0ef | 2004-07-24 21:35:38 +0000 | [diff] [blame] | 673 | |
Jonathan Gordon | 8055825 | 2006-10-09 12:14:25 +0000 | [diff] [blame] | 674 | while(!done && TIME_BEFORE(current_tick,time_entered+HZ*2)) |
Linus Nielsen Feltzing | 5b5003d | 2004-07-24 21:26:41 +0000 | [diff] [blame] | 675 | { |
Jonathan Gordon | 8055825 | 2006-10-09 12:14:25 +0000 | [diff] [blame] | 676 | button = get_action(CONTEXT_STD,HZ); |
Linus Nielsen Feltzing | 5b5003d | 2004-07-24 21:26:41 +0000 | [diff] [blame] | 677 | switch(button) |
| 678 | { |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 679 | case ACTION_STD_CANCEL: |
Linus Nielsen Feltzing | 91216a5 | 2005-09-14 09:08:26 +0000 | [diff] [blame] | 680 | sys_poweroff(); |
Linus Nielsen Feltzing | 5b5003d | 2004-07-24 21:26:41 +0000 | [diff] [blame] | 681 | break; |
| 682 | |
Jens Arnold | c897c24 | 2007-07-22 13:08:00 +0000 | [diff] [blame] | 683 | /* do nothing here, because ACTION_NONE might be caused |
Michael Sevakis | 9e8fe0e | 2006-10-30 11:33:38 +0000 | [diff] [blame] | 684 | * by timeout or button release. In case of timeout the loop |
Jonathan Gordon | 8055825 | 2006-10-09 12:14:25 +0000 | [diff] [blame] | 685 | * is terminated by TIME_BEFORE */ |
Jens Arnold | c897c24 | 2007-07-22 13:08:00 +0000 | [diff] [blame] | 686 | case ACTION_NONE: |
Jonathan Gordon | 8055825 | 2006-10-09 12:14:25 +0000 | [diff] [blame] | 687 | break; |
| 688 | |
Linus Nielsen Feltzing | 5b5003d | 2004-07-24 21:26:41 +0000 | [diff] [blame] | 689 | default: |
Linus Nielsen Feltzing | ade5d7b | 2004-07-26 16:06:59 +0000 | [diff] [blame] | 690 | if(default_event_handler(button) == SYS_USB_CONNECTED) |
| 691 | return true; |
Jonathan Gordon | 8055825 | 2006-10-09 12:14:25 +0000 | [diff] [blame] | 692 | done = true; |
Linus Nielsen Feltzing | 5b5003d | 2004-07-24 21:26:41 +0000 | [diff] [blame] | 693 | break; |
| 694 | } |
| 695 | } |
| 696 | return false; |
| 697 | } |
Linus Nielsen Feltzing | bdbb0ef | 2004-07-24 21:35:38 +0000 | [diff] [blame] | 698 | #endif |
Björn Stenberg | 6c33c51 | 2004-09-19 21:58:37 +0000 | [diff] [blame] | 699 | |
Magnus Holmgren | 87e41e8 | 2007-02-11 08:06:24 +0000 | [diff] [blame] | 700 | static const int id3_headers[]= |
| 701 | { |
| 702 | LANG_ID3_TITLE, |
| 703 | LANG_ID3_ARTIST, |
| 704 | LANG_ID3_ALBUM, |
| 705 | LANG_ID3_ALBUMARTIST, |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 706 | LANG_ID3_GROUPING, |
Dan Everton | f4a61f0 | 2007-08-03 10:00:42 +0000 | [diff] [blame] | 707 | LANG_ID3_DISCNUM, |
Magnus Holmgren | 87e41e8 | 2007-02-11 08:06:24 +0000 | [diff] [blame] | 708 | LANG_ID3_TRACKNUM, |
| 709 | LANG_ID3_COMMENT, |
| 710 | LANG_ID3_GENRE, |
| 711 | LANG_ID3_YEAR, |
| 712 | LANG_ID3_LENGTH, |
| 713 | LANG_ID3_PLAYLIST, |
| 714 | LANG_ID3_BITRATE, |
Barry Wardell | 8a52d70 | 2007-07-28 16:32:24 +0000 | [diff] [blame] | 715 | LANG_ID3_FREQUENCY, |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 716 | #if CONFIG_CODEC == SWCODEC |
Magnus Holmgren | 87e41e8 | 2007-02-11 08:06:24 +0000 | [diff] [blame] | 717 | LANG_ID3_TRACK_GAIN, |
| 718 | LANG_ID3_ALBUM_GAIN, |
Magnus Holmgren | eab21c6 | 2005-08-11 18:21:14 +0000 | [diff] [blame] | 719 | #endif |
Magnus Holmgren | 87e41e8 | 2007-02-11 08:06:24 +0000 | [diff] [blame] | 720 | LANG_ID3_PATH, |
| 721 | }; |
Magnus Holmgren | eab21c6 | 2005-08-11 18:21:14 +0000 | [diff] [blame] | 722 | |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 723 | static char * id3_get_info(int selected_item, void* data, |
| 724 | char *buffer, size_t buffer_len) |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 725 | { |
| 726 | struct mp3entry* id3 =(struct mp3entry*)data; |
| 727 | int info_no=selected_item/2; |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 728 | if(!(selected_item%2)) |
| 729 | {/* header */ |
Magnus Holmgren | 87e41e8 | 2007-02-11 08:06:24 +0000 | [diff] [blame] | 730 | return( str(id3_headers[info_no])); |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 731 | } |
| 732 | else |
| 733 | {/* data */ |
| 734 | |
| 735 | char * info=NULL; |
| 736 | switch(info_no) |
| 737 | { |
| 738 | case 0:/*LANG_ID3_TITLE*/ |
| 739 | info=id3->title; |
| 740 | break; |
| 741 | case 1:/*LANG_ID3_ARTIST*/ |
| 742 | info=id3->artist; |
| 743 | break; |
| 744 | case 2:/*LANG_ID3_ALBUM*/ |
| 745 | info=id3->album; |
| 746 | break; |
Miika Pekkarinen | 4e97664 | 2007-02-10 12:09:28 +0000 | [diff] [blame] | 747 | case 3:/*LANG_ID3_ALBUMARTIST*/ |
| 748 | info=id3->albumartist; |
| 749 | break; |
Magnus Holmgren | ead3de3 | 2007-08-08 12:34:19 +0000 | [diff] [blame] | 750 | case 4:/*LANG_ID3_GROUPING*/ |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 751 | info=id3->grouping; |
| 752 | break; |
| 753 | case 5:/*LANG_ID3_DISCNUM*/ |
Dan Everton | f4a61f0 | 2007-08-03 10:00:42 +0000 | [diff] [blame] | 754 | if (id3->disc_string) |
| 755 | info = id3->disc_string; |
| 756 | else if (id3->discnum) |
Magnus Holmgren | 0e2852b | 2007-10-28 12:47:49 +0000 | [diff] [blame] | 757 | { |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 758 | snprintf(buffer, buffer_len, "%d", id3->discnum); |
Dan Everton | f4a61f0 | 2007-08-03 10:00:42 +0000 | [diff] [blame] | 759 | info = buffer; |
| 760 | } |
| 761 | break; |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 762 | case 6:/*LANG_ID3_TRACKNUM*/ |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 763 | if (id3->track_string) |
| 764 | info = id3->track_string; |
| 765 | else if (id3->tracknum) |
| 766 | { |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 767 | snprintf(buffer, buffer_len, "%d", id3->tracknum); |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 768 | info = buffer; |
| 769 | } |
| 770 | break; |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 771 | case 7:/*LANG_ID3_COMMENT*/ |
Miika Pekkarinen | 4e97664 | 2007-02-10 12:09:28 +0000 | [diff] [blame] | 772 | info=id3->comment; |
| 773 | break; |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 774 | case 8:/*LANG_ID3_GENRE*/ |
Robert Kukla | 79a2a93 | 2007-03-02 21:49:42 +0000 | [diff] [blame] | 775 | info = id3->genre_string; |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 776 | break; |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 777 | case 9:/*LANG_ID3_YEAR*/ |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 778 | if (id3->year_string) |
| 779 | info = id3->year_string; |
| 780 | else if (id3->year) |
| 781 | { |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 782 | snprintf(buffer, buffer_len, "%d", id3->year); |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 783 | info = buffer; |
| 784 | } |
| 785 | break; |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 786 | case 10:/*LANG_ID3_LENGTH*/ |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 787 | format_time(buffer, buffer_len, id3->length); |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 788 | info=buffer; |
| 789 | break; |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 790 | case 11:/*LANG_ID3_PLAYLIST*/ |
Peter D'Hoye | 8ed3b32 | 2008-05-23 21:43:40 +0000 | [diff] [blame] | 791 | snprintf(buffer, buffer_len, "%d/%d", |
| 792 | playlist_get_display_index(), playlist_amount()); |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 793 | info=buffer; |
| 794 | break; |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 795 | case 12:/*LANG_ID3_BITRATE*/ |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 796 | snprintf(buffer, buffer_len, "%d kbps%s", id3->bitrate, |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 797 | id3->vbr ? str(LANG_ID3_VBR) : (const unsigned char*) ""); |
| 798 | info=buffer; |
| 799 | break; |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 800 | case 13:/*LANG_ID3_FREQUENCY*/ |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 801 | snprintf(buffer, buffer_len, "%ld Hz", id3->frequency); |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 802 | info=buffer; |
| 803 | break; |
| 804 | #if CONFIG_CODEC == SWCODEC |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 805 | case 14:/*LANG_ID3_TRACK_GAIN*/ |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 806 | info=id3->track_gain_string; |
| 807 | break; |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 808 | case 15:/*LANG_ID3_ALBUM_GAIN*/ |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 809 | info=id3->album_gain_string; |
| 810 | break; |
Dan Everton | eecfe9f | 2007-08-08 10:19:56 +0000 | [diff] [blame] | 811 | case 16:/*LANG_ID3_PATH*/ |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 812 | #else |
Magnus Holmgren | ead3de3 | 2007-08-08 12:34:19 +0000 | [diff] [blame] | 813 | case 14:/*LANG_ID3_PATH*/ |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 814 | #endif |
| 815 | info=id3->path; |
| 816 | break; |
| 817 | } |
Magnus Holmgren | 2a20bfe | 2007-05-02 17:01:02 +0000 | [diff] [blame] | 818 | return info && *info ? info : (char*) str(LANG_ID3_NO_INFO); |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 819 | } |
| 820 | } |
| 821 | |
Björn Stenberg | 6c33c51 | 2004-09-19 21:58:37 +0000 | [diff] [blame] | 822 | bool browse_id3(void) |
| 823 | { |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 824 | struct gui_synclist id3_lists; |
| 825 | struct mp3entry* id3 = audio_current_track(); |
| 826 | int key; |
Björn Stenberg | 6c33c51 | 2004-09-19 21:58:37 +0000 | [diff] [blame] | 827 | |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 828 | gui_synclist_init(&id3_lists, &id3_get_info, id3, true, 2, NULL); |
Magnus Holmgren | 87e41e8 | 2007-02-11 08:06:24 +0000 | [diff] [blame] | 829 | gui_synclist_set_nb_items(&id3_lists, |
| 830 | sizeof(id3_headers)/sizeof(id3_headers[0])*2); |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 831 | gui_synclist_draw(&id3_lists); |
Jonathan Gordon | bc0943e | 2006-09-12 08:55:47 +0000 | [diff] [blame] | 832 | gui_syncstatusbar_draw(&statusbars, true); |
Kevin Ferrare | f77ac7a | 2006-07-02 12:28:27 +0000 | [diff] [blame] | 833 | while (true) { |
Jonathan Gordon | 07d3db2 | 2006-08-17 09:28:04 +0000 | [diff] [blame] | 834 | gui_syncstatusbar_draw(&statusbars, false); |
Jonathan Gordon | 10af966 | 2006-08-17 05:40:14 +0000 | [diff] [blame] | 835 | key = get_action(CONTEXT_LIST,HZ/2); |
Michael Sevakis | 9e8fe0e | 2006-10-30 11:33:38 +0000 | [diff] [blame] | 836 | if(key!=ACTION_NONE && key!=ACTION_UNKNOWN |
Jonathan Gordon | cf1cef5 | 2007-09-17 10:08:50 +0000 | [diff] [blame] | 837 | && !gui_synclist_do_button(&id3_lists, &key,LIST_WRAP_UNLESS_HELD)) |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 838 | { |
Kevin Ferrare | f64280f | 2006-07-02 16:18:59 +0000 | [diff] [blame] | 839 | return(default_event_handler(key) == SYS_USB_CONNECTED); |
Linus Nielsen Feltzing | 224c0a1 | 2006-08-15 12:27:07 +0000 | [diff] [blame] | 840 | } |
Björn Stenberg | 6c33c51 | 2004-09-19 21:58:37 +0000 | [diff] [blame] | 841 | } |
Björn Stenberg | 6c33c51 | 2004-09-19 21:58:37 +0000 | [diff] [blame] | 842 | } |
| 843 | |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 844 | static char* runtime_get_data(int selected_item, void* data, |
| 845 | char* buffer, size_t buffer_len) |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 846 | { |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 847 | (void)data; |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 848 | unsigned char *headers[] = {str(LANG_RUNNING_TIME), str(LANG_TOP_TIME) }; |
| 849 | int t; |
| 850 | if(!(selected_item%2)) |
| 851 | return headers[selected_item/2]; |
| 852 | |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 853 | if(selected_item/2) |
| 854 | t = global_status.topruntime; |
| 855 | |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 856 | else t = global_status.runtime; |
| 857 | |
Nils Wallménius | 6848961 | 2008-04-09 15:25:17 +0000 | [diff] [blame] | 858 | snprintf(buffer, buffer_len, "%dh %dm %ds", |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 859 | t / 3600, (t % 3600) / 60, t % 60); |
| 860 | return buffer; |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 861 | } |
| 862 | |
Stéphane Doyon | 22e3d56 | 2007-11-07 03:58:13 +0000 | [diff] [blame] | 863 | static int runtime_speak_data(int selected_item, void* data) |
| 864 | { |
Jonathan Gordon | c14430a | 2007-11-07 09:28:07 +0000 | [diff] [blame] | 865 | (void) data; |
Stéphane Doyon | 22e3d56 | 2007-11-07 03:58:13 +0000 | [diff] [blame] | 866 | long title_ids[] = {LANG_RUNNING_TIME, LANG_TOP_TIME}; |
| 867 | talk_ids(false, |
| 868 | title_ids[selected_item/2], |
| 869 | TALK_ID((selected_item == 0) ? global_status.runtime |
| 870 | : global_status.topruntime, UNIT_TIME)); |
| 871 | return 0; |
| 872 | } |
| 873 | |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 874 | |
Jonathan Gordon | d152b64 | 2006-12-19 12:26:03 +0000 | [diff] [blame] | 875 | bool view_runtime(void) |
| 876 | { |
Nils Wallménius | 33c4446 | 2008-04-26 09:30:24 +0000 | [diff] [blame] | 877 | static const char *lines[]={ID2P(LANG_CLEAR_TIME)}; |
| 878 | static const struct text_message message={lines, 1}; |
Jonathan Gordon | d152b64 | 2006-12-19 12:26:03 +0000 | [diff] [blame] | 879 | |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 880 | struct gui_synclist lists; |
| 881 | int action; |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 882 | gui_synclist_init(&lists, runtime_get_data, NULL, false, 2, NULL); |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 883 | #if !defined(HAVE_LCD_CHARCELLS) |
| 884 | gui_synclist_set_title(&lists, str(LANG_RUNNING_TIME), NOICON); |
| 885 | #else |
| 886 | gui_synclist_set_title(&lists, NULL, NOICON); |
Jonathan Gordon | 5dd08e1 | 2007-02-17 10:59:30 +0000 | [diff] [blame] | 887 | #endif |
Stéphane Doyon | 22e3d56 | 2007-11-07 03:58:13 +0000 | [diff] [blame] | 888 | if(global_settings.talk_menu) |
| 889 | gui_synclist_set_voice_callback(&lists, runtime_speak_data); |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 890 | gui_synclist_set_icon_callback(&lists, NULL); |
| 891 | gui_synclist_set_nb_items(&lists, 4); |
Stéphane Doyon | 22e3d56 | 2007-11-07 03:58:13 +0000 | [diff] [blame] | 892 | gui_synclist_speak_item(&lists); |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 893 | while(1) |
Jonathan Gordon | d152b64 | 2006-12-19 12:26:03 +0000 | [diff] [blame] | 894 | { |
Jonathan Gordon | 9a6f419 | 2007-02-18 05:32:06 +0000 | [diff] [blame] | 895 | #if CONFIG_CHARGING |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 896 | if (charger_inserted() |
Jonathan Gordon | d152b64 | 2006-12-19 12:26:03 +0000 | [diff] [blame] | 897 | #ifdef HAVE_USB_POWER |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 898 | || usb_powered() |
Jonathan Gordon | d152b64 | 2006-12-19 12:26:03 +0000 | [diff] [blame] | 899 | #endif |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 900 | ) |
Jonathan Gordon | d152b64 | 2006-12-19 12:26:03 +0000 | [diff] [blame] | 901 | { |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 902 | global_status.runtime = 0; |
Jonathan Gordon | d152b64 | 2006-12-19 12:26:03 +0000 | [diff] [blame] | 903 | } |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 904 | else |
| 905 | #endif |
| 906 | { |
| 907 | global_status.runtime += ((current_tick - lasttime) / HZ); |
| 908 | } |
| 909 | lasttime = current_tick; |
| 910 | gui_synclist_draw(&lists); |
| 911 | gui_syncstatusbar_draw(&statusbars, true); |
Stéphane Doyon | 22e3d56 | 2007-11-07 03:58:13 +0000 | [diff] [blame] | 912 | list_do_action(CONTEXT_STD, HZ, |
| 913 | &lists, &action, LIST_WRAP_UNLESS_HELD); |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 914 | if(action == ACTION_STD_CANCEL) |
| 915 | break; |
| 916 | if(action == ACTION_STD_OK) { |
| 917 | if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES) |
| 918 | { |
| 919 | if (!(gui_synclist_get_sel_pos(&lists)/2)) |
| 920 | global_status.runtime = 0; |
| 921 | else |
| 922 | global_status.topruntime = 0; |
Stéphane Doyon | 22e3d56 | 2007-11-07 03:58:13 +0000 | [diff] [blame] | 923 | gui_synclist_speak_item(&lists); |
Dominik Riebeling | 339d812 | 2007-04-10 20:56:15 +0000 | [diff] [blame] | 924 | } |
Jonathan Gordon | d152b64 | 2006-12-19 12:26:03 +0000 | [diff] [blame] | 925 | } |
Dominik Riebeling | a3f1e9f | 2007-04-10 21:40:44 +0000 | [diff] [blame] | 926 | if(default_event_handler(action) == SYS_USB_CONNECTED) |
| 927 | return true; |
Jonathan Gordon | d152b64 | 2006-12-19 12:26:03 +0000 | [diff] [blame] | 928 | } |
Jonathan Gordon | d152b64 | 2006-12-19 12:26:03 +0000 | [diff] [blame] | 929 | return false; |
| 930 | } |