Skip to content

Commit

Permalink
fix(bw): switch & source changes sometimes not saved to SD card (#5435)
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz authored Aug 16, 2024
1 parent 224e118 commit 4b87484
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 48 deletions.
17 changes: 9 additions & 8 deletions radio/src/gui/navigation/navigation_x7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,6 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
newval = !val;
}

if (newval != val) {
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
checkIncDec_Ret = (newval > val ? 1 : -1);
}
else {
checkIncDec_Ret = 0;
}

if (i_flags & INCDEC_SOURCE) {
if (event == EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
Expand Down Expand Up @@ -212,6 +204,15 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
checkIncDecSelection = 0;
}
}

if (newval != val) {
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
checkIncDec_Ret = (newval > val ? 1 : -1);
}
else {
checkIncDec_Ret = 0;
}

return newval;
}

Expand Down
43 changes: 22 additions & 21 deletions radio/src/gui/navigation/navigation_x9d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,6 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
newval = !val;
}

if (newval != val) {
#if !defined(ROTARY_ENCODER_NAVIGATION)
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) &&
(newval != i_min) && stops.contains(newval)) {
bool pause = (newval > val ? !stops.contains(newval + 1)
: !stops.contains(newval - 1));
if (pause) {
pauseEvents(event); // delay before auto-repeat continues
}
}
if (!IS_KEY_REPT(event)) {
AUDIO_KEY_PRESS();
}
#endif
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
checkIncDec_Ret = (newval > val ? 1 : -1);
}
else {
checkIncDec_Ret = 0;
}

if (i_flags & INCDEC_SOURCE) {
if (event == EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event);
Expand Down Expand Up @@ -225,6 +204,28 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
checkIncDecSelection = 0;
}
}

if (newval != val) {
#if !defined(ROTARY_ENCODER_NAVIGATION)
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) &&
(newval != i_min) && stops.contains(newval)) {
bool pause = (newval > val ? !stops.contains(newval + 1)
: !stops.contains(newval - 1));
if (pause) {
pauseEvents(event); // delay before auto-repeat continues
}
}
if (!IS_KEY_REPT(event)) {
AUDIO_KEY_PRESS();
}
#endif
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
checkIncDec_Ret = (newval > val ? 1 : -1);
}
else {
checkIncDec_Ret = 0;
}

return newval;
}

Expand Down
38 changes: 19 additions & 19 deletions radio/src/gui/navigation/navigation_xlite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,6 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
newval = !val;
}

if (newval != val) {
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) &&
(newval != i_min) && stops.contains(newval)) {
bool pause = (newval > val ? !stops.contains(newval + 1)
: !stops.contains(newval - 1));
if (pause) {
pauseEvents(event); // delay before auto-repeat continues
}
}
if (!IS_KEY_REPT(event)) {
AUDIO_KEY_PRESS();
}
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
checkIncDec_Ret = (newval > val ? 1 : -1);
}
else {
checkIncDec_Ret = 0;
}

if (i_flags & INCDEC_SOURCE) {
if (event == EVT_KEY_LONG(KEY_ENTER) && !keysGetState(KEY_SHIFT)) {
killEvents(event);
Expand Down Expand Up @@ -214,6 +195,25 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
}
}

if (newval != val) {
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) &&
(newval != i_min) && stops.contains(newval)) {
bool pause = (newval > val ? !stops.contains(newval + 1)
: !stops.contains(newval - 1));
if (pause) {
pauseEvents(event); // delay before auto-repeat continues
}
}
if (!IS_KEY_REPT(event)) {
AUDIO_KEY_PRESS();
}
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
checkIncDec_Ret = (newval > val ? 1 : -1);
}
else {
checkIncDec_Ret = 0;
}

return newval;
}

Expand Down

0 comments on commit 4b87484

Please sign in to comment.