mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Sub-GHz: Fix freq analyzer deadlock by holding Ok
Was more reproducible when using FM238 modulation, by stopping the worker thread in the input callback the system GUI thread was deadlocked when switching scenes if the timing was just right; this should be handled by app thread.
This commit is contained in:
@@ -255,9 +255,9 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
|
||||
need_redraw = true;
|
||||
}
|
||||
} else if(
|
||||
(event->type != InputTypeRelease && event->type != InputTypeRepeat) &&
|
||||
(event->type == InputTypeShort || event->type == InputTypeLong) &&
|
||||
event->key == InputKeyOk) {
|
||||
need_redraw = true;
|
||||
need_redraw = false;
|
||||
bool updated = false;
|
||||
uint32_t frequency_to_save;
|
||||
with_view_model(
|
||||
@@ -286,22 +286,19 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
|
||||
instance->worker, frequency_candidate);
|
||||
if(frequency_candidate > 0 && frequency_candidate != model->frequency_to_save) {
|
||||
model->frequency_to_save = frequency_candidate;
|
||||
frequency_to_save = frequency_candidate;
|
||||
updated = true;
|
||||
}
|
||||
},
|
||||
true);
|
||||
false);
|
||||
|
||||
if(updated) {
|
||||
instance->callback(SubGhzCustomEventViewFreqAnalOkShort, instance->context);
|
||||
}
|
||||
|
||||
// First the device receives short, then when user release button we get long
|
||||
// If it was a long press also send a second event
|
||||
if(event->type == InputTypeLong && frequency_to_save > 0) {
|
||||
// Stop worker
|
||||
if(subghz_frequency_analyzer_worker_is_running(instance->worker)) {
|
||||
subghz_frequency_analyzer_worker_stop(instance->worker);
|
||||
}
|
||||
|
||||
// Worker stopped on app thread instead of GUI thread when switching scene in callback
|
||||
instance->callback(SubGhzCustomEventViewFreqAnalOkLong, instance->context);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user