diff options
Diffstat (limited to 'firmware/powermgmt.c')
-rw-r--r-- | firmware/powermgmt.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index b1a08bff29..d9014dc047 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c | |||
@@ -81,9 +81,9 @@ enum charge_state_type charge_state = DISCHARGING; | |||
81 | 81 | ||
82 | static int shutdown_timeout = 0; | 82 | static int shutdown_timeout = 0; |
83 | 83 | ||
84 | static void handle_auto_poweroff(void); | 84 | void handle_auto_poweroff(void); |
85 | static int poweroff_timeout = 0; | 85 | static int poweroff_timeout = 0; |
86 | static long last_event_tick; | 86 | static long last_event_tick = 0; |
87 | 87 | ||
88 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 88 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
89 | /* | 89 | /* |
@@ -134,11 +134,6 @@ void battery_read_info(int *voltage, int *level) | |||
134 | *level = voltage_to_battery_level(millivolts); | 134 | *level = voltage_to_battery_level(millivolts); |
135 | } | 135 | } |
136 | 136 | ||
137 | void reset_poweroff_timer(void) | ||
138 | { | ||
139 | last_event_tick = current_tick; | ||
140 | } | ||
141 | |||
142 | #if BATTERY_TYPES_COUNT > 1 | 137 | #if BATTERY_TYPES_COUNT > 1 |
143 | void set_battery_type(int type) | 138 | void set_battery_type(int type) |
144 | { | 139 | { |
@@ -204,11 +199,6 @@ bool battery_level_safe(void) | |||
204 | #endif | 199 | #endif |
205 | } | 200 | } |
206 | 201 | ||
207 | void set_poweroff_timeout(int timeout) | ||
208 | { | ||
209 | poweroff_timeout = timeout; | ||
210 | } | ||
211 | |||
212 | /* look into the percent_to_volt_* table and get a realistic battery level */ | 202 | /* look into the percent_to_volt_* table and get a realistic battery level */ |
213 | static int voltage_to_percent(int voltage, const short* table) | 203 | static int voltage_to_percent(int voltage, const short* table) |
214 | { | 204 | { |
@@ -712,6 +702,16 @@ void shutdown_hw(void) | |||
712 | } | 702 | } |
713 | #endif /* PLATFORM_NATIVE */ | 703 | #endif /* PLATFORM_NATIVE */ |
714 | 704 | ||
705 | void set_poweroff_timeout(int timeout) | ||
706 | { | ||
707 | poweroff_timeout = timeout; | ||
708 | } | ||
709 | |||
710 | void reset_poweroff_timer(void) | ||
711 | { | ||
712 | last_event_tick = current_tick; | ||
713 | } | ||
714 | |||
715 | void sys_poweroff(void) | 715 | void sys_poweroff(void) |
716 | { | 716 | { |
717 | #ifndef BOOTLOADER | 717 | #ifndef BOOTLOADER |
@@ -790,7 +790,7 @@ int get_sleep_timer(void) | |||
790 | return 0; | 790 | return 0; |
791 | } | 791 | } |
792 | 792 | ||
793 | void handle_sleep_timer(void) | 793 | static void handle_sleep_timer(void) |
794 | { | 794 | { |
795 | if (!sleeptimer_active) | 795 | if (!sleeptimer_active) |
796 | return; | 796 | return; |
@@ -817,7 +817,6 @@ void handle_sleep_timer(void) | |||
817 | } | 817 | } |
818 | } | 818 | } |
819 | 819 | ||
820 | |||
821 | /* | 820 | /* |
822 | * We shut off in the following cases: | 821 | * We shut off in the following cases: |
823 | * 1) The unit is idle, not playing music | 822 | * 1) The unit is idle, not playing music |
@@ -830,7 +829,7 @@ void handle_sleep_timer(void) | |||
830 | * 3) We are recording, or recording with pause | 829 | * 3) We are recording, or recording with pause |
831 | * 4) The radio is playing | 830 | * 4) The radio is playing |
832 | */ | 831 | */ |
833 | static void handle_auto_poweroff(void) | 832 | void handle_auto_poweroff(void) |
834 | { | 833 | { |
835 | long timeout = poweroff_timeout*60*HZ; | 834 | long timeout = poweroff_timeout*60*HZ; |
836 | int audio_stat = audio_status(); | 835 | int audio_stat = audio_status(); |
@@ -846,7 +845,7 @@ static void handle_auto_poweroff(void) | |||
846 | } | 845 | } |
847 | #endif | 846 | #endif |
848 | 847 | ||
849 | #ifndef APPLICATION | 848 | #if !(CONFIG_PLATFORM & PLATFORM_HOSTED) |
850 | if (!shutdown_timeout && query_force_shutdown()) { | 849 | if (!shutdown_timeout && query_force_shutdown()) { |
851 | backlight_on(); | 850 | backlight_on(); |
852 | sys_poweroff(); | 851 | sys_poweroff(); |
@@ -863,7 +862,7 @@ static void handle_auto_poweroff(void) | |||
863 | !sleeptimer_active))) { | 862 | !sleeptimer_active))) { |
864 | 863 | ||
865 | if (TIME_AFTER(tick, last_event_tick + timeout) | 864 | if (TIME_AFTER(tick, last_event_tick + timeout) |
866 | #ifndef APPLICATION | 865 | #if !(CONFIG_PLATFORM & PLATFORM_HOSTED) |
867 | && TIME_AFTER(tick, storage_last_disk_activity() + timeout) | 866 | && TIME_AFTER(tick, storage_last_disk_activity() + timeout) |
868 | #endif | 867 | #endif |
869 | ) { | 868 | ) { |