📄 screens.c
字号:
/*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id: screens.c,v 1.41 2004/01/26 17:05:21 hardeeps Exp $ * * Copyright (C) 2002 Bj鰎n Stenberg * * 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 <stdbool.h>#include <string.h>#include <stdio.h>#include "backlight.h"#include "button.h"#include "lcd.h"#include "lang.h"#include "icons.h"#include "font.h"#include "mpeg.h"#include "mp3_playback.h"#include "usb.h"#include "settings.h"#include "status.h"#include "playlist.h"#include "sprintf.h"#include "kernel.h"#include "power.h"#include "system.h"#include "powermgmt.h"#include "adc.h"#ifdef HAVE_LCD_BITMAP#define BMPHEIGHT_usb_logo 32#define BMPWIDTH_usb_logo 100static unsigned char usb_logo[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x04, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 0x81, 0x81, 0x81, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xf1, 0x4f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0, 0x00, 0x00, 0xe0, 0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x81, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xe0, 0x70, 0x38, 0x1c, 0x1c, 0x0c, 0x0e, 0x0e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0xf8, 0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x82, 0x7e, 0x00, 0xc0, 0x3e, 0x01, 0x70, 0x4f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00, 0x07, 0x0f, 0x1f, 0x1f, 0x1f, 0x1f, 0x0f, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7b, 0xf3, 0xe3, 0xc3, 0x83, 0x83, 0x83, 0x83, 0xe3, 0xe3, 0xe3, 0xe3, 0xe3, 0xe3, 0x03, 0x03, 0x03, 0x3f, 0x1f, 0x1f, 0x0f, 0x0f, 0x07, 0x02, 0xc0, 0x3e, 0x01, 0xe0, 0x9f, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf0, 0x0f, 0x80, 0x78, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x10, 0x20, 0x40, 0x40, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x81, 0x81, 0x81, 0x81, 0x81, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf0, 0x0f, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x07, 0x00, 0x00, 0x00, 0x00, };#endifvoid usb_display_info(void){ lcd_clear_display();#ifdef HAVE_LCD_BITMAP /* lcd_bitmap() only supports 16 pixels height! */ lcd_bitmap(usb_logo, 6, 16, BMPWIDTH_usb_logo, 8, false); lcd_bitmap(usb_logo+BMPWIDTH_usb_logo, 6, 24, BMPWIDTH_usb_logo, 8, false); lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*2, 6, 32, BMPWIDTH_usb_logo, 8, false); lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*3, 6, 40, BMPWIDTH_usb_logo, 8, false); status_draw(true); lcd_update();#else lcd_puts(0, 0, "[USB Mode]"); status_set_param(false); status_set_audio(false); status_set_usb(true); status_draw(false);#endif}void usb_screen(void){#ifdef USB_NONE /* nothing here! */#else#ifndef SIMULATOR backlight_on(); usb_acknowledge(SYS_USB_CONNECTED_ACK); usb_display_info(); while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) { if(usb_inserted()) { status_draw(false); } }#ifdef HAVE_LCD_CHARCELLS status_set_usb(false);#endif backlight_on();#endif#endif /* USB_NONE */}/* some simulator dummies */#ifdef SIMULATOR#define BATTERY_SCALE_FACTOR 7000unsigned short adc_read(int channel){ (void)channel; return 100;}#endif#ifdef HAVE_LCD_BITMAPvoid charging_display_info(bool animate){ unsigned char charging_logo[36]; const int pox_x = (LCD_WIDTH - sizeof(charging_logo)) / 2; const int pox_y = 32; static unsigned phase = 3; unsigned i; char buf[32]; (void)buf;#ifdef NEED_ATA_POWER_BATT_MEASURE if (ide_powered()) /* FM and V2 can only measure when ATA power is on */#endif { int battery_voltage; int batt_int, batt_frac; battery_voltage = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000; batt_int = battery_voltage / 100; batt_frac = battery_voltage % 100; snprintf(buf, 32, " Batt: %d.%02dV %d%% ", batt_int, batt_frac, battery_level()); lcd_puts(0, 7, buf); }#ifdef HAVE_CHARGE_CTRL snprintf(buf, 32, "Charge mode:"); lcd_puts(0, 2, buf); if (charge_state == 1) snprintf(buf, 32, str(LANG_BATTERY_CHARGE)); else if (charge_state == 2) snprintf(buf, 32, str(LANG_BATTERY_TOPOFF_CHARGE)); else if (charge_state == 3) snprintf(buf, 32, str(LANG_BATTERY_TRICKLE_CHARGE)); else snprintf(buf, 32, "not charging"); lcd_puts(0, 3, buf); if (charger_enabled) { backlight_on(); /* using the light gives good indication */ } else { backlight_off(); animate = false; }#endif /* middle part */ memset(charging_logo+3, 0x00, 32); charging_logo[0] = 0x3C; charging_logo[1] = 0x24; charging_logo[2] = charging_logo[35] = 0xFF; if (!animate) { /* draw the outline */ /* middle part */ lcd_bitmap(charging_logo, pox_x, pox_y + 8, sizeof(charging_logo), 8, true); /* upper line */ charging_logo[0] = charging_logo[1] = 0x00; memset(charging_logo+2, 0x80, 34); lcd_bitmap(charging_logo, pox_x, pox_y, sizeof(charging_logo), 8, false); /* lower line */ memset(charging_logo+2, 0x01, 34); lcd_bitmap(charging_logo, pox_x, pox_y + 16, sizeof(charging_logo), 8, false); } 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 */ if (bitpos > 7) bitpos = 14 - bitpos; charging_logo[i] = 0x01 << bitpos; } } lcd_bitmap(charging_logo, pox_x, pox_y + 8, sizeof(charging_logo), 8, true); phase++; } lcd_update();}#else /* not HAVE_LCD_BITMAP */void charging_display_info(bool animate){ /* ToDo for Player */ (void)animate;}#endif#ifdef HAVE_BATTERIES/* 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 */int charging_screen(void){ int button; int rc = 0;#ifdef HAVE_RECORDER_KEYPAD const int offbutton = BUTTON_OFF;#else const int offbutton = BUTTON_STOP;#endif ide_power_enable(false); /* power down the disk, else would be spinning */ lcd_clear_display(); backlight_on(); status_draw(true);#ifdef HAVE_LCD_BITMAP charging_display_info(false);#else status_set_playmode(STATUS_STOP); lcd_puts(0, 1, "[charging]");#endif do { status_draw(false); charging_display_info(true); button = button_get_w_tmo(HZ/3); if (button == (BUTTON_ON | BUTTON_REL)) rc = 3; else if (button == offbutton) rc = 2; else { if (usb_detect()) rc = 4; else if (!charger_inserted()) rc = 1; } } while (!rc); return rc;}#endif /* HAVE_BATTERIES */#ifdef HAVE_RECORDER_KEYPAD/* returns: 0 if no key was pressed 1 if a key was pressed (or if ON was held down long enough to repeat) 2 if USB was connected */int on_screen(void){ static int pitch = 1000; bool exit = false; bool used = false; while (!exit) { if ( used ) { char* ptr; char buf[32]; int w, h; lcd_clear_display(); lcd_setfont(FONT_SYSFIXED); ptr = str(LANG_PITCH_UP); lcd_getstringsize(ptr,&w,&h); lcd_putsxy((LCD_WIDTH-w)/2, 0, ptr); lcd_bitmap(bitmap_icons_7x8[Icon_UpArrow], LCD_WIDTH/2 - 3, h*2, 7, 8, true); snprintf(buf, sizeof buf, "%d.%d%%", pitch / 10, pitch % 10 ); lcd_getstringsize(buf,&w,&h); lcd_putsxy((LCD_WIDTH-w)/2, h, buf); ptr = str(LANG_PITCH_DOWN); lcd_getstringsize(ptr,&w,&h); lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr); lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow], LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true); ptr = str(LANG_PAUSE); lcd_getstringsize(ptr,&w,&h); lcd_putsxy((LCD_WIDTH-(w/2))/2, LCD_HEIGHT/2 - h/2, ptr); lcd_bitmap(bitmap_icons_7x8[Icon_Pause], (LCD_WIDTH-(w/2))/2-10, LCD_HEIGHT/2 - h/2, 7, 8, true); lcd_update(); } /* use lastbutton, so the main loop can decide whether to exit to browser or not */ switch (button_get(true)) { case BUTTON_UP: case BUTTON_ON | BUTTON_UP: case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT: used = true; pitch++; if ( pitch > 2000 ) pitch = 2000; mpeg_set_pitch(pitch); break; case BUTTON_DOWN: case BUTTON_ON | BUTTON_DOWN: case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT: used = true; pitch--; if ( pitch < 500 ) pitch = 500; mpeg_set_pitch(pitch); break; case BUTTON_ON | BUTTON_PLAY: mpeg_pause(); used = true; break; case BUTTON_PLAY | BUTTON_REL: mpeg_resume(); used = true; break; case BUTTON_ON | BUTTON_PLAY | BUTTON_REL: mpeg_resume(); exit = true; break; case BUTTON_ON | BUTTON_RIGHT: if ( pitch < 2000 ) { pitch += 20; mpeg_set_pitch(pitch); } break; case BUTTON_RIGHT | BUTTON_REL: if ( pitch > 500 ) { pitch -= 20; mpeg_set_pitch(pitch); } break; case BUTTON_ON | BUTTON_LEFT: if ( pitch > 500 ) { pitch -= 20; mpeg_set_pitch(pitch); } break; case BUTTON_LEFT | BUTTON_REL: if ( pitch < 2000 ) { pitch += 20; mpeg_set_pitch(pitch); } break;#ifdef SIMULATOR case BUTTON_ON:#else case BUTTON_ON | BUTTON_REL: case BUTTON_ON | BUTTON_UP | BUTTON_REL: case BUTTON_ON | BUTTON_DOWN | BUTTON_REL:#endif exit = true; break; case BUTTON_ON | BUTTON_REPEAT: used = true;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -