Anduril 2 feature change suggestions

Anduril 2 Feature request, specifically for Emisar D2 running Stock Firmware 2021 12 13 0135

When I use my Emisar D2, the switch button light turns ON with the main LEDs.

I would like the button to stay OFF when the main LEDs are On. It would also be nice if the Blink at Top of Ramp could be turned Off.

can someone build me a hex file please? :wink:

I would prefer to retain the Stock Firmware feature that uses 3H from On (NOT 3C), to switch from LED #1, to LED #2

shown w Red LED #2 On, the Green button light is ON. I would prefer it Off.
Imgur

Yes, agree for the rest of flashlight😬

Will have a look at that right away (that’s what sleepless nights are for! :grin:)

OK, from the date (2021-12-13) I presume this is not the ‘development’ multi-channel branch, but the ‘stable’ anduril2 branch, and probably at or around rev.642 (it would be so much easier if Anduril would just blink the rev along with, or even instead of, the build date…)

By 0135, you mean the model number, right? I ask because checking the MODELS file, I see this:
0135 emisar-d4sv2-tintramp [...]

OTOH I see no specific code for the D2, so I infer it uses the same code as the D2SV2 above – but would like confirmation.

I believe you are correct in all regards

about rev642 matching the firmware date

that 0135 is the model number,

and it seems to use the same firmware as the emisar-d4sv2-tintramp

thank you for taking the time to help me :beer:

1 Thank

He is a very good human and so gently

2 Thanks

Perfect! I will get to it momentarily!

No problem, it’s a pleasure to be able to contribute, however humbly, to that wonderful community that is BLF, where I have learned (and continue to learn) so much.

:blush:

it means a lot to me, very grateful for your help

btw, if you have the opportunity to also add your 8C Aux on/off toggle to this build, that would be great!

so the complete change list would be

  1. turn off button light when main LEDs are On
  2. turn off the blink at top of ramp
  3. add your custom 8C toggle for Aux On/Off

:heart_eyes:

1 Thank

No prob, mate! You are more than welcome!

Consider it done! :+1:

Perfect!

Specially RE: #1, I only ask for your patience because I don’t have a D2 (and worse, none of my lights have this “button led” thing), so I can’t test it before sending it to you – add to that the fact that I’ve not dwelt in that part of the code before, and the result is that I will probably need a few interactions to get it right.

I will also follow the “first principle of the ignorant engineer”, that an old friend of mine who was actually an engineer once stated as “when you don’t know what you are doing, change just one thing at a time”:wink: so I will first send you the hex with #1, and when we get that right, will send you #2 plus #3 (I think there will not much of a problem bunching these two together as #3 is pretty much tested and working by now).

To keep what will probably be useless traffic off this thread, let’s interact over PMs and when it’s ready and done, I will post the final and hopefully working version here along with my patches to the source.

I already have a first candidate for #1 ready, sending the link to you via PM now.

1 Thank

1 and 2 are very simple there are compile time options already in place for both, just undef them… Or anyway the top ramp blink is that way, and use of aux leds looks to be that simple, I’ve not actually tried to turn it off.

Re; a light to test with, I thought you had an FC13?

It reminds me though, is the code for the 8C aux mod uploaded/posted somewhere?
I’d really like to incorporate it into my custom build. :smiley:

1and 2 are done
I have received a Hex File built by dmenezes for Emisar D2 that

  1. keeps the button light OFF :heart_eyes: when main LEDs are On
  2. has No Blink at top of ramp.

major Thanks! to dmenezes :beer: :beers: :partying_face: :+1:

2 Thanks

In obedience of Anduril’s licence (GPL), here are the sources for my patches (against rev.642 on the anduril2 branch):

#1: 642-DONT_USE_BUTTON_LED_WHILE_ON.diff:

--- ./642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/anduril.c.orig-2023090901 2021-01-25 02:21:06.000000000 -0300
+++ ./642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/anduril.c 2023-09-09 17:09:02.906883996 -0300
@@ -270,6 +270,11 @@
     if (! setting_rgb_mode_now) rgb_led_voltage_readout(1);
     #endif
 
+    #if defined(USE_BUTTON_LED) && defined(DONT_USE_BUTTON_LED_WHILE_ON)
+    // turn button led off while the flashlight is on
+    button_led_set(0);
+    #endif
+
     if (0) {}  // placeholder
 
     #ifdef USE_VERSION_CHECK
--- ./642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h.orig-2023090901       2021-10-31 06:19:13.000000000 -0300
+++ ./642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h       2023-09-09 17:09:49.100193496 -0300
@@ -9,6 +9,8 @@
 // the aux LEDs are front-facing, so turn them off while main LEDs are on
 // it also has an independent LED in the button
 #define USE_BUTTON_LED
+#define DONT_USE_BUTTON_LED_WHILE_ON   //turn button LED off when the flashlight is on
+
 // TODO: the whole "indicator LED" thing needs to be refactored into
 //       "aux LED(s)" and "button LED(s)" since they work a bit differently
 // enabling this option breaks the button LED on D4v2.5

#2: 642-DONT_BLINK_AT_RAMP_CEIL.diff

--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h.orig-2023090902 2021-10-31 06:19:13.000000000 -0300
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/cfg-emisar-d4sv2-tintramp.h 2023-09-09 17:20:33.786628035 -0300
@@ -16,6 +16,8 @@
 #undef USE_INDICATOR_LED_WHILE_RAMPING
 #endif
 
+#undef BLINK_AT_RAMP_CEIL      //Do NOT blink at ramp ceil
+
 // has two channels of independent LEDs
 #define USE_TINT_RAMPING
 // how much to increase total brightness at middle tint

See above: you are right about #2. For #1, I looked for but wasn’t able to find an existing #define, so I created my own.

#3 is being way more work than I expected because there were a lot of changes in the parts of Anduril code it depends on, between the multi-channel branch where I implemented it first, and the anduril2 branch which we’re working on for @jon_slider’s D2, so I’m still working on it.

1 Thank

I do have one. But the FC13 switch LEDs are treated in Anduril as RGB_AUX_LEDs, not BUTTON_LEDs like the one in the D2 switch – so, different parts of the code.

Sure! Here’s the complete patch for the latest version: 721-8C_quick_aux_switch_-_20230616.diff · GitHub
(Originally posted here in BLF at: Anduril 2 feature change suggestions - #423 by dmenezes)

Please freel free to :slight_smile: I’m actually very pleased people find it useful! :+1:

1 Thank

Finally finished it, here’s the tested and working hex: http://www.durval.com/xfer-only/anduril.emisar-d4sv2-tintramp_-_DONT_USE_BUTTON_LED_WHILE_ON_+_DONT_BLINK_AT_RAMP_CEIL_+_8C_QUICK_AUX_SWITCH_-_2023090904.zip

And the patch source:
#3: 642-8C_QUICK_AUX_SWITCH.diff

--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/off-mode.c.orig-2023090904  2021-09-01 00:07:45.000000000 -0400
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/off-mode.c  2023-09-10 14:06:07.362758269 -0300
@@ -318,6 +318,49 @@
     }
     #endif  // end 7 clicks
 
+    #ifdef USE_QUICK_AUX_SWITCH
+        #ifdef USE_INDICATOR_LED
+        // 8 clicks: if indicator LEDs (aka "aux LEDs") are not off, change them to off; if they're already off, change them to low
+        //  See: https://budgetlightforum.com/t/anduril-2-feature-change-suggestions/218045/145
+        else if (event == EV_8clicks) {
+            uint8_t mode = (indicator_led_mode & 3);
+            uint8_t previous_mode = (previous_indicator_led_mode & 3);
+            if (mode) {
+                previous_mode = mode;
+                mode = 0;
+           } else {
+                mode = previous_mode;
+                previous_mode = 0;
+            }
+            indicator_led_mode = (indicator_led_mode & 0b11111100) | mode;
+            previous_indicator_led_mode = (previous_indicator_led_mode & 0b11111100) | previous_mode;
+            // redundant, sleep tick does the same thing
+            //indicator_led_update(indicator_led_mode & 0x03, arg);
+            save_config();
+            return MISCHIEF_MANAGED;
+        }
+        #elif defined(USE_AUX_RGB_LEDS)
+        // 8 clicks: if RGB aux LED pattern is not off, change it to off; if it's already off, change it to low
+        else if (event == EV_8clicks) {
+            uint8_t mode = (rgb_led_off_mode >> 4);
+            uint8_t previous_mode = (previous_rgb_led_off_mode >> 4);
+            if (mode) {
+                previous_mode = mode;
+                mode = 0;
+            } else {
+                mode = previous_mode;
+                previous_mode = 0;
+            }
+            rgb_led_off_mode = (mode << 4) | (rgb_led_off_mode & 0x0f);
+            previous_rgb_led_off_mode = (previous_mode << 4) | (previous_rgb_led_off_mode & 0x0f);
+            rgb_led_update(rgb_led_off_mode, 0);
+            save_config();
+            blink_once();
+            return MISCHIEF_MANAGED;
+        }
+        #endif  // end 8 clicks
+    #endif
+
     #ifdef USE_GLOBALS_CONFIG
     // 9 clicks, but hold last click: configure misc global settings
     else if ((event == EV_click9_hold) && (!arg)) {
--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/load-save-config.c.orig-2023090904  2021-11-03 07:16:05.000000000 -0300
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/load-save-config.c  2023-09-10 14:07:11.145032045 -0300
@@ -95,6 +95,15 @@
         #ifdef USE_AUTOLOCK
         autolock_time = eeprom[autolock_time_e];
         #endif
+        #ifdef USE_QUICK_AUX_SWITCH
+            #ifdef USE_INDICATOR_LED
+                previous_indicator_led_off_mode = eeprom[previous_indicator_led_off_mode_e];
+            #endif
+            #ifdef USE_AUX_RGB_LEDS
+                previous_rgb_led_off_mode = eeprom[previous_rgb_led_off_mode_e];
+                previous_rgb_led_lockout_mode = eeprom[previous_rgb_led_lockout_mode_e];
+            #endif
+        #endif
     }
     #ifdef START_AT_MEMORIZED_LEVEL
     if (load_eeprom_wl()) {
@@ -174,6 +183,15 @@
     #ifdef USE_AUTOLOCK
     eeprom[autolock_time_e] = autolock_time;
     #endif
+    #ifdef USE_QUICK_AUX_SWITCH
+        #ifdef USE_INDICATOR_LED
+            eeprom[previous_indicator_led_off_mode_e] = previous_indicator_led_off_mode;
+        #endif
+        #ifdef USE_AUX_RGB_LEDS
+            eeprom[previous_rgb_led_off_mode_e] = previous_rgb_led_off_mode;
+            eeprom[previous_rgb_led_lockout_mode_e] = previous_rgb_led_lockout_mode;
+        #endif
+    #endif
 
     save_eeprom();
 }
--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/lockout-mode.c.orig-2023090904      2021-12-13 19:19:19.000000000 -0300
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/lockout-mode.c      2023-09-10 14:02:23.150724506 -0300
@@ -187,6 +187,49 @@
     }
     #endif
 
+    #ifdef USE_QUICK_AUX_SWITCH
+         #if defined(USE_INDICATOR_LED)
+         // 8 clicks: if indicator LEDs (aka "aux LEDs") mode is not off, save it and change it to off; if it's already off, change it back to saved
+         //  See: https://budgetlightforum.com/t/anduril-2-feature-change-suggestions/218045/145
+         else if (event == EV_8clicks) {
+             uint8_t mode = indicator_led_mode >> 2;
+                uint8_t previous_mode = previous_indicator_led_mode >> 2;
+             if (mode) {
+                 previous_mode = mode;
+                 mode = 0;
+             } else {
+                 mode = previous_mode;
+                 previous_mode = 0;
+             }
+             indicator_led_mode = (mode << 2) + (indicator_led_mode & 0x03);
+             previous_indicator_led_mode = (previous_mode << 2) + (previous_indicator_led_mode & 0x03);
+             // redundant, sleep tick does the same thing
+             //indicator_led_update(indicator_led_mode >> 2, arg);
+             save_config();
+             return MISCHIEF_MANAGED;
+         }
+         #elif defined(USE_AUX_RGB_LEDS)
+         // 8 clicks: if RGB aux LED pattern mode is not off, save it and change it to off; if it's already off, change it back to saved
+         else if (event == EV_8clicks) {
+             uint8_t mode = (rgb_led_lockout_mode >> 4);
+             uint8_t previous_mode = (previous_rgb_led_lockout_mode >> 4);
+             if (mode) {
+                 previous_mode = mode;
+                 mode = 0;
+             } else {
+                 mode = previous_mode;
+                 previous_mode = 0;
+             }
+             rgb_led_lockout_mode = (mode << 4) | (rgb_led_lockout_mode & 0x0f);
+             previous_rgb_led_lockout_mode = (previous_mode << 4) | (previous_rgb_led_lockout_mode & 0x0f);
+             rgb_led_update(rgb_led_lockout_mode, 0);
+             save_config();
+             blink_once();
+             return MISCHIEF_MANAGED;
+         }
+         #endif // end 8 clicks
+     #endif
+
     return EVENT_NOT_HANDLED;
 }
 
--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/aux-leds.h.orig-2023090904  2021-04-14 02:09:23.000000000 -0400
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/aux-leds.h  2023-09-10 13:57:28.340059657 -0300
@@ -83,5 +83,14 @@
     #endif
 #endif
 
+#ifdef USE_QUICK_AUX_SWITCH
+  #ifdef USE_INDICATOR_LED
+          uint8_t previous_indicator_led_mode = ~INDICATOR_LED_DEFAULT_MODE;
+  #endif
+#endif
 
 #endif
--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h.orig-2023090904      2021-11-03 07:16:05.000000000 -0300
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/load-save-config-fsm.h      2023-09-09 18:00:25.047904773 -0300
@@ -95,6 +95,11 @@
     #ifdef USE_AUTOLOCK
     autolock_time_e,
     #endif
+    #ifdef USE_QUICK_AUX_SWITCH
+    previous_indicator_led_mode_e,
+    previous_rgb_led_off_mode_e,
+    previous_rgb_led_lockout_mode_e,
+    #endif
     eeprom_indexes_e_END
 } eeprom_indexes_e;
 #define EEPROM_BYTES eeprom_indexes_e_END
--- 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/config-default.h.orig-2023090904    2021-12-08 19:36:58.000000000 -0300
+++ 642/~toykeeper/flashlight-firmware/anduril2/ToyKeeper/spaghetti-monster/anduril/config-default.h    2023-09-09 17:49:37.215866774 -0300
@@ -194,4 +194,7 @@
 // those oscillations
 //#define USE_LOWPASS_WHILE_ASLEEP
 
+// enable quick switch to/from current aux mode to off
+#define USE_QUICK_AUX_SWITCH
+
 #endif

Thanks to @jon_slider for coming up with the idea, and for helping me with the testing.

I would just like to add that, to my great surprise, this last mod also worked first try despite its relative complexity.

This goes on to show what a great programmer @Toykeeper is, her code is so well-written that even being a relatively ignorant person (meaning, I know C well, and embedded programming relatively well, but very little flashlight electronics and even less Anduril internals) I was able to ‘parachute’ into her code and easily make these changes. Kudos to her! :+1: :+1: :+1:

2 Thanks

That was Fast!
I LOVE your new D2 Hex

Thanks to dmenezes my D2 now has the following upgrades:

  1. Button Light OFF when main LEDs are On
  2. No Blink at top of ramp
  3. 8C toggles Button and Aux lights On and Off

Outstanding!
Thank You!

2 Thanks

Heads-up to all of you interested in my 8C_Quick_Aux_Switch mod: I just refactored it for TK’s latest rev (767), please see my post on the other topic for all the HEXes, source code, etc: Anduril ... 2? - #1685 by dmenezes

Enjoy! :slight_smile:

1 Thank

This is a follow-up from my post in another topic: Wurkkos TS10 Ti (v2) much more aggressive thermal stepdown compared to regular TS10? - #45 by dmenezes

This is what has been working great for me so far, re: setting ceiling to 120 and disabling turbo:

#define RAMP_SMOOTH_CEIL     120
#define RAMP_DISCRETE_CEIL   RAMP_SMOOTH_CEIL
#define DEFAULT_2C_STYLE     0 // disable 2 click turbo

Interesting! I’ve never dabbled with that before, but I think you refer to this, right?
cfg-wurkkos-ts10.h

#define PWM1_LEVELS     1,   1,   2,   2,   3,   3,   4,   5,   6,   6,   8,   9,   9,  10,  10,  11,  12,  13,  14,  15,  16,  17,  18,  19,  19,  20,  21,  22,  23, 23, 24, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 35, 36, 37, 38, 40, 41, 43, 45, 47, 50, 53, 56, 60, 63, 67, 71, 75, 79, 84, 89, 94, 99,104,110,116,122,129,136,143,150,158,166,174,183,192,202,211,222,232,243,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0
#define PWM2_LEVELS     0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  2,  3,  5,  7,  8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 29, 31, 34, 37, 39, 42, 45, 48, 51, 54, 58, 61, 65, 68, 72, 76, 80, 84, 88, 93, 97,102,107,112,117,122,127,133,139,145,151,157,163,170,177,183,191,198,205,213,221,229,238,246,255
#define PWM_TOPS     4095,2893,3917,2806,3252,2703,2684,2660,2640,2370,3000,2900,2630,2549,2246,2193,2030,1961,1889,1716,1642,1569,1497,1428,1290,1232,1176,1122,1070,976,932,890,849,779,745,685,656,605,579,536,514,476,457,424,407,379,364,340,327,314,302,291,280,276,266,262,257,253,253,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255

Given the TS10 is 1+FET, I presume PWM1_LEVELS refers to its single 7035 regulator, and PWM2_LEVELS refers to its FET, is that correct? In that case, what is PWM_TOPS for?

I apologize if I’m asking something obvious, but at least it wasn’t obvious to me after some grepping of the source tree and delving into some of the files that popped up (ramp-mode.c, ../fsm-ramping.c, ../../hwdef-wurkkos-ts10.c, ../../../bin/level_calc.py among others). If there are other files (or forum topics, or blog posts, etc) that I should consult in order to make more sense of these tables, I will be much obliged if someone can point them to me.

TIA!

Here’s TK’s latest and greatest rev. 812 with my 8C-Quick_Aux_Swap mod, all the hexes that build(*): http://durval.com/xfer-only/toykeeper_-_flashlight-firmware_-_multi-channel_-_rev_812-8C_quick_aux_switch_-_00ALL_HEXES_THAT_BUILD.zip

The exact same diff I already posted for rev.767 applied (with a few fuzzies, but no issues) so anyone interested can see the source code there.

(*) Flashlights with an AT85 don’t build because they don’t have enough flash memory to support TK’s latest changes plus my mod, but all the others are building.

There is FW3A Lume1 or I don’t see it?

According to TK’s MODELS file, there’s no fw3a-lume1, only fw3x-lume1:

0314 fw3x-lume1 attiny1634

The ones for fw3a make no reference to lume1:

0311    fw3a                            attiny85
0312    fw3a-219                        attiny85
0313    fw3a-nofet                      attiny85

Does your FW3A blink one of these 3 model codes? If yes, perhaps we can get it to compile by removing some Anduril feature you don’t use, like SIMPLE_UI.

Please tell me how you want to proceed.