diff options
Diffstat (limited to 'uisimulator/common')
-rw-r--r-- | uisimulator/common/SOURCES | 5 | ||||
-rw-r--r-- | uisimulator/common/lcd-common.c | 6 | ||||
-rw-r--r-- | uisimulator/common/powermgmt-sim.c | 60 | ||||
-rw-r--r-- | uisimulator/common/stubs.c | 26 |
4 files changed, 26 insertions, 71 deletions
diff --git a/uisimulator/common/SOURCES b/uisimulator/common/SOURCES index a632706a6b..939f1638c3 100644 --- a/uisimulator/common/SOURCES +++ b/uisimulator/common/SOURCES | |||
@@ -9,10 +9,7 @@ sim_tasks.c | |||
9 | fmradio.c | 9 | fmradio.c |
10 | backlight-sim.c | 10 | backlight-sim.c |
11 | stubs.c | 11 | stubs.c |
12 | powermgmt-sim.c | ||
12 | #endif | 13 | #endif |
13 | 14 | ||
14 | io.c | 15 | io.c |
15 | /* this is still needed for application since it has some stubs */ | ||
16 | #if !(CONFIG_PLATFORM & PLATFORM_MAEMO) | ||
17 | powermgmt-sim.c | ||
18 | #endif | ||
diff --git a/uisimulator/common/lcd-common.c b/uisimulator/common/lcd-common.c index 2acf4b386d..47ca114cbc 100644 --- a/uisimulator/common/lcd-common.c +++ b/uisimulator/common/lcd-common.c | |||
@@ -119,3 +119,9 @@ bool lcd_active(void) | |||
119 | return retval; | 119 | return retval; |
120 | } | 120 | } |
121 | #endif | 121 | #endif |
122 | |||
123 | #ifdef HAVE_LCD_SHUTDOWN | ||
124 | void lcd_shutdown(void) | ||
125 | { | ||
126 | } | ||
127 | #endif | ||
diff --git a/uisimulator/common/powermgmt-sim.c b/uisimulator/common/powermgmt-sim.c index e747d7d782..2d9acab51d 100644 --- a/uisimulator/common/powermgmt-sim.c +++ b/uisimulator/common/powermgmt-sim.c | |||
@@ -24,24 +24,25 @@ | |||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #include "kernel.h" | 25 | #include "kernel.h" |
26 | #include "powermgmt.h" | 26 | #include "powermgmt.h" |
27 | #include "power.h" | ||
27 | 28 | ||
28 | #define BATT_MINMVOLT 2500 /* minimum millivolts of battery */ | 29 | #define BATT_MINMVOLT 3300 /* minimum millivolts of battery */ |
29 | #define BATT_MAXMVOLT 4500 /* maximum millivolts of battery */ | 30 | #define BATT_MAXMVOLT 4300 /* maximum millivolts of battery */ |
30 | #define BATT_MAXRUNTIME (10 * 60) /* maximum runtime with full battery in | 31 | #define BATT_MAXRUNTIME (10 * 60) /* maximum runtime with full battery in |
31 | minutes */ | 32 | minutes */ |
32 | 33 | ||
33 | extern void send_battery_level_event(void); | 34 | extern void send_battery_level_event(void); |
34 | extern int last_sent_battery_level; | 35 | extern int last_sent_battery_level; |
35 | extern int battery_percent; | 36 | extern int battery_percent; |
37 | static bool charging = false; | ||
36 | 38 | ||
37 | static unsigned int battery_millivolts = BATT_MAXMVOLT; | 39 | static unsigned int battery_millivolts = BATT_MAXMVOLT; |
38 | /* estimated remaining time in minutes */ | 40 | |
39 | static int powermgmt_est_runningtime_min = BATT_MAXRUNTIME; | 41 | void powermgmt_init_target(void) {} |
40 | 42 | ||
41 | static void battery_status_update(void) | 43 | static void battery_status_update(void) |
42 | { | 44 | { |
43 | static time_t last_change = 0; | 45 | static time_t last_change = 0; |
44 | static bool charging = false; | ||
45 | time_t now; | 46 | time_t now; |
46 | 47 | ||
47 | time(&now); | 48 | time(&now); |
@@ -76,57 +77,34 @@ static void battery_status_update(void) | |||
76 | 77 | ||
77 | battery_percent = 100 * (battery_millivolts - BATT_MINMVOLT) / | 78 | battery_percent = 100 * (battery_millivolts - BATT_MINMVOLT) / |
78 | (BATT_MAXMVOLT - BATT_MINMVOLT); | 79 | (BATT_MAXMVOLT - BATT_MINMVOLT); |
79 | |||
80 | powermgmt_est_runningtime_min = | ||
81 | battery_percent * BATT_MAXRUNTIME / 100; | ||
82 | } | 80 | } |
83 | |||
84 | send_battery_level_event(); | ||
85 | } | 81 | } |
86 | 82 | ||
87 | void battery_read_info(int *voltage, int *level) | 83 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { 3200 }; |
88 | { | 84 | const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = { 3200 }; |
89 | battery_status_update(); | ||
90 | 85 | ||
91 | if (voltage) | 86 | /* make the simulated curve nicely linear */ |
92 | *voltage = battery_millivolts; | 87 | const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = |
88 | { { 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300 } }; | ||
89 | const unsigned short percent_to_volt_charge[11] = | ||
90 | { 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300 }; | ||
93 | 91 | ||
94 | if (level) | ||
95 | *level = battery_percent; | ||
96 | } | ||
97 | 92 | ||
98 | unsigned int battery_voltage(void) | 93 | int _battery_voltage(void) |
99 | { | 94 | { |
100 | battery_status_update(); | 95 | battery_status_update(); |
101 | return battery_millivolts; | 96 | return battery_millivolts; |
102 | } | 97 | } |
103 | 98 | ||
104 | int battery_level(void) | 99 | #if CONFIG_CHARGING |
105 | { | 100 | unsigned int power_input_status(void) |
106 | battery_status_update(); | ||
107 | return battery_percent; | ||
108 | } | ||
109 | |||
110 | int battery_time(void) | ||
111 | { | ||
112 | battery_status_update(); | ||
113 | return powermgmt_est_runningtime_min; | ||
114 | } | ||
115 | |||
116 | bool battery_level_safe(void) | ||
117 | { | ||
118 | return battery_level() >= 10; | ||
119 | } | ||
120 | |||
121 | void set_battery_capacity(int capacity) | ||
122 | { | 101 | { |
123 | (void)capacity; | 102 | return charging ? POWER_INPUT_NONE : POWER_INPUT_MAIN; |
124 | } | 103 | } |
125 | 104 | ||
126 | #if BATTERY_TYPES_COUNT > 1 | 105 | bool charging_state(void) |
127 | void set_battery_type(int type) | ||
128 | { | 106 | { |
129 | (void)type; | 107 | return charging; |
130 | } | 108 | } |
131 | #endif | 109 | #endif |
132 | 110 | ||
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index f8b8fdc912..ba4faff6e2 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c | |||
@@ -317,32 +317,6 @@ bool usb_charging_enable(bool on) | |||
317 | } | 317 | } |
318 | #endif | 318 | #endif |
319 | 319 | ||
320 | #if CONFIG_CHARGING | ||
321 | bool charger_inserted(void) | ||
322 | { | ||
323 | return false; | ||
324 | } | ||
325 | |||
326 | bool power_input_present(void) | ||
327 | { | ||
328 | return false; | ||
329 | } | ||
330 | |||
331 | unsigned int power_input_status(void) | ||
332 | { | ||
333 | #ifdef HAVE_BATTERY_SWITCH | ||
334 | return POWER_INPUT_BATTERY; | ||
335 | #else | ||
336 | return POWER_INPUT_NONE; | ||
337 | #endif | ||
338 | } | ||
339 | |||
340 | bool charging_state(void) | ||
341 | { | ||
342 | return false; | ||
343 | } | ||
344 | #endif /* CONFIG_CHARGING */ | ||
345 | |||
346 | #ifndef USB_NONE | 320 | #ifndef USB_NONE |
347 | bool usb_inserted(void) | 321 | bool usb_inserted(void) |
348 | { | 322 | { |