movement: prevent invalid tick frequency from breaking scheduled tasks
This commit is contained in:
@@ -152,14 +152,19 @@ static void _movement_handle_scheduled_tasks(void) {
|
||||
}
|
||||
|
||||
void movement_request_tick_frequency(uint8_t freq) {
|
||||
if (freq == 128) return; // Movement uses the 128 Hz tick internally
|
||||
// Movement uses the 128 Hz tick internally
|
||||
if (freq == 128) return;
|
||||
|
||||
// Movement requires at least a 1 Hz tick.
|
||||
// If we are asked for an invalid frequency, default back to 1 Hz.
|
||||
if (freq == 0 || __builtin_popcount(freq) != 1) freq = 1;
|
||||
|
||||
// disable all callbacks except the 128 Hz one
|
||||
watch_rtc_disable_matching_periodic_callbacks(0xFE);
|
||||
|
||||
movement_state.subsecond = 0;
|
||||
movement_state.tick_frequency = freq;
|
||||
if (freq) watch_rtc_register_periodic_callback(cb_tick, freq);
|
||||
watch_rtc_register_periodic_callback(cb_tick, freq);
|
||||
}
|
||||
|
||||
void movement_illuminate_led(void) {
|
||||
|
||||
Reference in New Issue
Block a user