multi-channel branch: compile-time error if USE_SIMPLE_UI is undefined

Bug #2027883 reported by Durval Menezes
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Flashlight Firmware Repository
New
Undecided
Unassigned

Bug Description

As reported here: https://budgetlightforum.com/t/anduril-2-feature-change-suggestions/218045/199

Please find proposed fix to it in the attached patch (against rev. 721 and 725, but also applies to rev. 728 after applying `sed 's/MISCHIEF_MANAGED/EVENT_HANDLED/g'

Revision history for this message
Durval Menezes (jm262) wrote :
Revision history for this message
Durval Menezes (jm262) wrote :

I just noticed this didn't made its away into the latest revs yet, so here's it updated to rev. 767.

Revision history for this message
Johno Crawford (johno-crawford) wrote :

Doesn't it make more sense to just remove the else?

=== modified file 'ToyKeeper/spaghetti-monster/anduril/channel-modes.c' (properties changed: -x to +x)
--- old/ToyKeeper/spaghetti-monster/anduril/channel-modes.c 2023-08-25 22:21:04 +0000
+++ new/ToyKeeper/spaghetti-monster/anduril/channel-modes.c 2023-11-04 11:58:37 +0000
@@ -130,7 +130,7 @@

     #if NUM_CHANNEL_MODES > 1
     // channel toggle menu on ... 9H?
- else if (event == EV_click9_hold) {
+ if (event == EV_click9_hold) {
         push_state(channel_mode_config_state, 0);
         return EVENT_HANDLED;
     }

Revision history for this message
Durval Menezes (jm262) wrote :

> Doesn't it make more sense to just remove the else?

That would change the behavior of the code, in the sense that the following `if` would then be run regardless of the last one's result, instead of only if it's false.

Granted, in its context that would be mostly harmless (apart from a few wasted cycles), but in these cases (other people's code, etc) I subscribe to the "smallest change is the best change" school of thought.

Just my opinion, of course.

Revision history for this message
Johno Crawford (johno-crawford) wrote (last edit ):

But you are mixing USE_CHANNEL_MODE_ARGS and NUM_CHANNEL_MODES, to avoid changing the behaviour in code, use less cycles and keep features loosely coupled we could do something like this, wdyt?

--- old/ToyKeeper/spaghetti-monster/anduril/channel-modes.c 2023-08-25 22:21:04 +0000
+++ new/ToyKeeper/spaghetti-monster/anduril/channel-modes.c 2023-11-05 16:39:13 +0000
@@ -126,11 +126,14 @@
     if (cfg.simple_ui_active) {
         return EVENT_NOT_HANDLED;
     }
+ #if NUM_CHANNEL_MODES > 1
+ else
+ #endif
     #endif

     #if NUM_CHANNEL_MODES > 1
- // channel toggle menu on ... 9H?
- else if (event == EV_click9_hold) {
+ // channel toggle menu on ... 9H? (only if not in SIMPLE UI or if SIMPLE UI is inactive)
+ if (event == EV_click9_hold) {
         push_state(channel_mode_config_state, 0);
         return EVENT_HANDLED;
     }

Revision history for this message
Durval Menezes (jm262) wrote :

> But you are mixing USE_CHANNEL_MODE_ARGS and NUM_CHANNEL_MODES, to avoid changing the behaviour in code, use less cycles and keep features loosely coupled we could do something like this, wdyt?

I'm not quite sure I follow you there, but in any case we're discussing this in the wrong place -- as TK (the firmware author) has just published in this repo's main page, it has been abandoned and everything has migrated over to https://github.com/ToyKeeper/anduril; please feel free to repost your suggestions as an issue there, and if you're willing, even submit a pull request to TK herself.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.