diff options
Diffstat (limited to 'uisimulator')
-rw-r--r-- | uisimulator/battery.c | 102 | ||||
-rw-r--r-- | uisimulator/bitmaps/UI-fiiom3k.bmp | bin | 676310 -> 913878 bytes | |||
-rw-r--r-- | uisimulator/buttonmap/fiio-m3k.c | 24 | ||||
-rw-r--r-- | uisimulator/common/filesystem-sim.c | 2 | ||||
-rw-r--r-- | uisimulator/common/powermgmt-sim.c | 56 | ||||
-rw-r--r-- | uisimulator/common/sim_tasks.c | 11 |
6 files changed, 64 insertions, 131 deletions
diff --git a/uisimulator/battery.c b/uisimulator/battery.c deleted file mode 100644 index b92f4d4bdb..0000000000 --- a/uisimulator/battery.c +++ /dev/null @@ -1,102 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 1999 Robert Hak (rhak@ramapo.edu) - * - * Heavily modified for embedded use by Björn Stenberg (bjorn@haxx.se) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "types.h" -#include "lcd.h" -#include "debug.h" -#define CONFIG_KEYPAD RECORDER_PAD -#include "button.h" - -#ifdef SIMULATOR -#include <stdio.h> -#include <unistd.h> -#endif - -/* I hacked this function to be placed inside because I figure we will need - something like it eventually. - - Args are fairly straight forward. - int xbase: location of "bottom" of battery on screen - int ybase: location of "left" edge of battery on screen - int len: how long is the battery to be (in pixels) - int wid: how tall is the battery to be (in pixels) - int percent: what percentage of the charge has been used - - Note: I am making use of the Logf() function until logging is - straightened out. -*/ - -void draw_battery(int xbase, int ybase, int len, int wid, int percent) -{ - float capacity = 0; - int bar_xoffset = 2; - int bar_yoffset = 2; - int bar_len = 0; - int bar_wid = wid - (bar_xoffset*2); - int i = 0; - - /* We only worry about length and width because if you place - the battery off the screen, its your own damn fault. We log - and then just draw an empty battery */ - if((percent > 100) || (percent < 0) || (len < 0) || (wid < 0)) { -/* debug("Error: Battery data invalid"); */ - percent = 0; - } - - /* top batt. edge */ - lcd_hline(xbase, xbase+len-2, ybase); - - /* bot batt. edge */ - lcd_hine(xbase, xbase+len-2, ybase+wid); - - /* left batt. edge */ - lcd_vline(xbase, ybase, ybase+wid); - - /* right batt. edge */ - lcd_vline(xbase+len, ybase+1, ybase+wid-1); - - /* 2 dots that account for the nub on the right side of the battery */ - lcd_drawpixel(xbase+len-1, ybase+1); - lcd_drawpixel(xbase+len-1, ybase+wid-1); - - if(percent > 0) { - /* % battery is full, 100% is length-bar_xoffset-1 pixels */ - capacity = ((float)percent / 100.0) * (len-(bar_xoffset*2)-1); - bar_len = capacity; - - for(i = 0; i < bar_wid+1; i++) { - lcd_hline(xbase+bar_xoffset, - xbase+bar_xoffset+bar_len, ybase+bar_yoffset+i); - } - } - lcd_update(); -} - - - - - - - - - diff --git a/uisimulator/bitmaps/UI-fiiom3k.bmp b/uisimulator/bitmaps/UI-fiiom3k.bmp Binary files differindex 118424ef5f..54438ea06f 100644 --- a/uisimulator/bitmaps/UI-fiiom3k.bmp +++ b/uisimulator/bitmaps/UI-fiiom3k.bmp diff --git a/uisimulator/buttonmap/fiio-m3k.c b/uisimulator/buttonmap/fiio-m3k.c index 30d1550ca3..ff7a95e82c 100644 --- a/uisimulator/buttonmap/fiio-m3k.c +++ b/uisimulator/buttonmap/fiio-m3k.c @@ -61,9 +61,11 @@ int key_to_button(int keyboard_button) new_btn = BUTTON_MENU; break; case SDL_BUTTON_WHEELUP: + case SDLK_PAGEUP: new_btn = BUTTON_SCROLL_BACK; break; case SDL_BUTTON_WHEELDOWN: + case SDLK_PAGEDOWN: new_btn = BUTTON_SCROLL_FWD; break; case SDLK_BACKSPACE: @@ -82,16 +84,16 @@ int key_to_button(int keyboard_button) } struct button_map bm[] = { - { SDLK_ESCAPE, 12, 55, 15, "Power" }, - { SDLK_KP_MINUS, 12, 188, 15, "Volume -" }, - { SDLK_KP_PLUS, 12, 125, 15, "Volume +" }, - { SDLK_SPACE, 12, 255, 15, "Play" }, - { SDLK_UP, 146, 394, 20, "Up" }, - { SDLK_RETURN, 146, 438, 20, "Select" }, - { SDLK_DOWN, 146, 510, 20, "Down" }, - { SDLK_INSERT, 68, 368, 20, "Menu" }, - { SDLK_LEFT, 68, 532, 20, "Left" }, - { SDLK_RIGHT, 224, 532, 20, "Right" }, - { SDLK_BACKSPACE, 224, 368, 20, "Back" }, + { SDLK_ESCAPE, 14, 63, 15, "Power" }, + { SDLK_KP_MINUS, 14, 219, 15, "Volume -" }, + { SDLK_KP_PLUS, 14, 139, 15, "Volume +" }, + { SDLK_SPACE, 14, 299, 15, "Play" }, + { SDLK_UP, 170, 444, 25, "Up" }, + { SDLK_RETURN, 170, 519, 25, "Select" }, + { SDLK_DOWN, 170, 599, 25, "Down" }, + { SDLK_INSERT, 79, 427, 25, "Menu" }, + { SDLK_LEFT, 79, 620, 25, "Left" }, + { SDLK_RIGHT, 260, 620, 25, "Right" }, + { SDLK_BACKSPACE, 260, 427, 25, "Back" }, { 0, 0, 0, 0, "None" } }; diff --git a/uisimulator/common/filesystem-sim.c b/uisimulator/common/filesystem-sim.c index 8d7fb14931..0a5df0c742 100644 --- a/uisimulator/common/filesystem-sim.c +++ b/uisimulator/common/filesystem-sim.c @@ -309,6 +309,8 @@ int sim_get_os_path(char *buffer, const char *path, size_t bufsize) const char *next; volume = path_strip_volume(p, &next, true); + if (volume == ROOT_VOLUME) + volume = 0; /* FIXME: root no longer implies volume 0 */ if (next > p) { diff --git a/uisimulator/common/powermgmt-sim.c b/uisimulator/common/powermgmt-sim.c index 511648bc9d..1535971e29 100644 --- a/uisimulator/common/powermgmt-sim.c +++ b/uisimulator/common/powermgmt-sim.c @@ -39,9 +39,11 @@ #define POWER_AFTER_CHARGE_TICKS (8 * HZ) #endif -extern int battery_percent; static bool charging = false; -static unsigned int battery_millivolts = BATT_MAXMVOLT; +static unsigned int batt_millivolts = BATT_MAXMVOLT; +static unsigned int batt_percent = 100; +static unsigned int batt_runtime = BATT_MAXRUNTIME; +static unsigned int batt_current = 0; void powermgmt_init_target(void) {} @@ -54,7 +56,7 @@ static void battery_status_update(void) static unsigned int ext_power_until_tick = 0; #endif - if TIME_BEFORE(current_tick, update_after_tick) + if(TIME_BEFORE(current_tick, update_after_tick)) return; update_after_tick = current_tick + HZ; @@ -72,10 +74,9 @@ static void battery_status_update(void) #endif if (charging) { - battery_millivolts += BATT_CHARGE_STEP; - if (battery_millivolts >= BATT_MAXMVOLT) { + batt_millivolts += BATT_CHARGE_STEP; + if (batt_millivolts >= BATT_MAXMVOLT) { charging = false; - battery_percent = 100; #if CONFIG_CHARGING >= CHARGING_MONITOR /* Keep external power until tick */ ext_power_until_tick = current_tick + POWER_AFTER_CHARGE_TICKS; @@ -83,23 +84,22 @@ static void battery_status_update(void) /* Pretend the charger was disconnected */ charger_input_state = CHARGER_UNPLUGGED; #endif - return; } } else { - battery_millivolts -= BATT_DISCHARGE_STEP; - if (battery_millivolts <= BATT_MINMVOLT) { + batt_millivolts -= BATT_DISCHARGE_STEP; + if (batt_millivolts <= BATT_MINMVOLT) { charging = true; - battery_percent = 0; #if CONFIG_CHARGING /* Pretend the charger was connected */ charger_input_state = CHARGER_PLUGGED; #endif - return; } } - battery_percent = 100 * (battery_millivolts - BATT_MINMVOLT) / - (BATT_MAXMVOLT - BATT_MINMVOLT); + batt_percent = (batt_millivolts - BATT_MINMVOLT) / (BATT_MAXMVOLT - BATT_MINMVOLT); + batt_runtime = batt_percent * BATT_MAXRUNTIME; + /* current is completely bogus... */ + batt_current = charging ? BATT_CHARGE_STEP : BATT_DISCHARGE_STEP; } const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { 3200 }; @@ -111,15 +111,36 @@ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = const unsigned short percent_to_volt_charge[11] = { 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300 }; +#if CONFIG_BATTERY_MEASURE & VOLTAGE_MEASURE int _battery_voltage(void) { battery_status_update(); - return battery_millivolts; + return batt_millivolts; } +#endif + +#if CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE +int _battery_level(void) +{ + battery_status_update(); + return batt_percent; +} +#endif #if (CONFIG_BATTERY_MEASURE & TIME_MEASURE) -static int powermgmt_est_runningtime_min; -int _battery_time(void) { return powermgmt_est_runningtime_min; } +int _battery_time(void) +{ + battery_status_update(); + return batt_runtime; +} +#endif + +#if (CONFIG_BATTERY_MEASURE & CURRENT_MEASURE) +int _battery_current(void) +{ + battery_status_update(); + return batt_current; +} #endif #if CONFIG_CHARGING @@ -169,6 +190,7 @@ unsigned int input_millivolts(void) /* Just return a safe value if battery isn't connected */ return 4050; } - return battery_voltage();; + + return battery_voltage(); } #endif diff --git a/uisimulator/common/sim_tasks.c b/uisimulator/common/sim_tasks.c index c862d4d909..c53b9990fd 100644 --- a/uisimulator/common/sim_tasks.c +++ b/uisimulator/common/sim_tasks.c @@ -92,7 +92,9 @@ void sim_thread(void) last_broadcast_tick = current_tick; } - num_acks_to_expect += queue_broadcast(SYS_USB_CONNECTED, 0) - 1; + /* NOTE: Unlike the USB code, we do not subtract one here + * because the sim_queue is not registered for broadcasts! */ + num_acks_to_expect += queue_broadcast(SYS_USB_CONNECTED, 0); DEBUGF("USB inserted. Waiting for %d acks...\n", num_acks_to_expect); break; @@ -145,10 +147,17 @@ void sim_trigger_screendump(void) static bool is_usb_inserted; void sim_trigger_usb(bool inserted) { + int usbmode = -1; if (inserted) + { + send_event(SYS_EVENT_USB_INSERTED, &usbmode); queue_post(&sim_queue, SIM_USB_INSERTED, 0); + } else + { + send_event(SYS_EVENT_USB_EXTRACTED, NULL); queue_post(&sim_queue, SIM_USB_EXTRACTED, 0); + } is_usb_inserted = inserted; } |