File tree Expand file tree Collapse file tree 4 files changed +18
-3
lines changed
Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,13 @@ config BATTERY_NO_MAPPING
3434
3535endchoice
3636
37+ config BATTERY_LOW_RUNTIME_THRESHOLD
38+ int "Low battery runtime threshold (ms)"
39+ default 10800000
40+ help
41+ Trigger low battery when estimated runtime falls below threshold.
42+ If estimated runtime is not available, low battery will trigger under 10% estimated state of charge.
43+
3744choice
3845 prompt "Status LED color mapping"
3946 default LED_TRI_COLOR
@@ -168,7 +175,7 @@ config USE_ACTIVE_TIMEOUT
168175 help
169176 Delay IMU wake up state or user shutdown during activity.
170177
171- choice
178+ choice
172179 prompt "Activity timeout mode"
173180 default SLEEP_ON_ACTIVE_TIMEOUT
174181 depends on USE_ACTIVE_TIMEOUT
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ const char *config_settings_names[] = {
4949 "imu_timeout_ramp_max" ,
5050 "active_timeout_threshold" ,
5151 "active_timeout_delay" ,
52+ "battery_low_runtime_threshold"
5253};
5354
5455const bool config_0_settings_defaults [16 ] = {
@@ -133,6 +134,7 @@ const int32_t config_3_settings_defaults[16] = {
133134#else
134135 900000 ,
135136#endif
137+ CONFIG_BATTERY_LOW_RUNTIME_THRESHOLD ,
136138};
137139
138140LOG_MODULE_REGISTER (config , LOG_LEVEL_INF );
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ enum config_3_settings_id {
6363 CONFIG_3_IMU_TIMEOUT_RAMP_MAX ,
6464 CONFIG_3_ACTIVE_TIMEOUT_THRESHOLD ,
6565 CONFIG_3_ACTIVE_TIMEOUT_DELAY ,
66+ CONFIG_3_BATTERY_LOW_RUNTIME_THRESHOLD ,
6667 CONFIG_3_SETTINGS_END
6768};
6869
Original file line number Diff line number Diff line change @@ -521,9 +521,14 @@ static void power_thread(void)
521521 // will update average_pptt, and current_battery_pptt
522522 update_battery (battery_pptt );
523523
524- if (battery_available && !battery_low && current_battery_pptt < 1000 )
524+ // use estimated remaining runtime or pptt for battery_low
525+ uint64_t runtime = sys_get_battery_remaining_time_estimate ();
526+ bool runtime_valid = runtime ;
527+ bool runtime_low = k_ticks_to_us_floor64 (runtime ) < CONFIG_3_SETTINGS_READ (CONFIG_3_BATTERY_LOW_RUNTIME_THRESHOLD );
528+ bool pptt_low = current_battery_pptt < 1000 ;
529+ if (battery_available && !battery_low && (runtime_valid ? runtime_low : pptt_low ))
525530 battery_low = true;
526- else if (!battery_available || (battery_low && current_battery_pptt > 1000 )) // hysteresis alrerady provided
531+ else if (!battery_available || (battery_low && ( runtime_valid ? ! runtime_low : ! pptt_low ))) // hysteresis already provided
527532 battery_low = false;
528533
529534 sys_update_battery_tracker_voltage (battery_mV , device_plugged );
You can’t perform that action at this time.
0 commit comments