E-switch UI Development / FSM

I suppose that’s the problem with open source.

Personally, I prefer the design and execution of Hank’s lights and Anduril is icing on the cake. I will always choose his lights compared to the clones. I would hazard a guess that a lot of other flashaholics would too.

Not sure if this is the correct thread to ask but… I have an Astrolux C8 with a bleeder resistor on the driver and a lit tailcap. Everything worked well but the turbo step down was too quick so I changed TURBO_TIMEOUT to 255 in the A6 firmware (blf-a6.c) and flashed it to my C8. I didn’t specify fuse values when flashing. Upon testing I noticed I couldn’t step backwards anymore. Is this due to a core timings change somewhere in the firmware? Should I play around with the resistors again to get the modes working properly? If it helps, I bought the C8 new from BG one year ago.

Sounds about right, the fuse settings. Had the same issue after flashing my BLF A6. The timing was way off. After reflashing it with the correct fuse values, it worked correctly again :slight_smile:

Doesn’t flashing without specifying the fuse values leave them unchanged? Or are you saying I need new fuse values for the (presumably) newer firmware?

Fuse values, are based on what type of MCU you are flashing. ATtiny13, 25, 85 etc.

Last time I flashed my A6 I used these settings:

It probably needs different values for the OTC calibration. The CAP_SHORT / CAP_MED values might not match the hardware.

Specifically, it may be a good idea to use the blf-a6 branch of the code instead of trunk, because it’s what the light probably shipped with. The copy in trunk has had updates and the calibration is set back to a default which I think matches MtnElectronics’ drivers instead of Banggood’s drivers.

Looking at it now, the blf-a6 branch uses values of 245 and 180, while the trunk branch uses 190 and 94. So that may be what you’re running into.

Banggood’s drivers don’t really have the standby drain configured very well to begin with, and the lighted tailcap makes it worse. Here’s what I measured a few years ago. The blue line is ideal, and is what trunk uses by default. The red line is what Banggood’s drivers do. And when you add a lighted tailcap, it follows an even higher line.

Thanks TK, very helpful and informative post as usual. I’ll check it out on the weekend. :beer: :beer:

Update: worked like a charm! :beer:

I just wanted to post a suggestion for improvement.

When clicking 4 times to exit lockout, it would be nice the if the behavior were:

4-clicks, the light turns on to the last memorized mode
click, click, click, hold, the light turns on to moonlight and starts ramping up
5-clicks, the light turns on to ramp ceiling
click, click, click, click, hold, the light turns on to ramp ceiling and starts ramping down

etc.

Essentially, the fourth click should act as if the light were already out of lockout. This makes sense since if you’re taking the light out of lockout, the next thing you’re going to do is probably turn it on.

I’ve considered doing something like this… making it so anything which exits an “off” or “lockout” mode will also turn the light on. That would mean 4 clicks to exit lockout would go to the regular ramp mode instead of “off” mode. And it might also mean 6 clicks to enter muggle mode would turn the light on.

However, I have no plans to do the other changes mentioned:

Basically, it sounds like the suggestion is: Reduce the “exit lockout” mapping from 4 clicks to 3 clicks, and force the button timing to reset after the 3rd click so it will start counting from 0 again. This would mean 5 clicks to access the ceiling, 6 clicks for battcheck, 7 clicks to go immediately back to lockout mode, etc.

But I intend to keep 5, 6, 7, and other clicks the same as they are now — momentary moon without unlocking the light. The most likely changes are:

  • Maybe remap 3-click aux LED controls to 7 clicks, to improve consistency between “off” and lockout modes.
  • Maybe remap 4-click “exit lockout” so it goes to an “on” state instead of “off”.

Ah I didn’t realize you are able to adjust aux LEDs in lockout. That complicates things somewhat.

Anyways what you are describing sounds like what I was suggesting.

Both sound sensible :+1:

A thought just struck me, and I have to put this out there…

Imagine a website that can build a custom anduril.hex file for you :heart_eyes:

Imagine a GUI, with some simple drop down menus and boxes to tick.
Select host, select emitter. Select or deselect what extras you want.

Perhaps an advanced menu where you could rearrange what 3 clicks, 4 clicks does, etc.

And then boom, it spits out a freshly assembled .hex :slight_smile:

I would wish that in the ramp config of the stepped ramping there was a forth option to adjust the speed of the ramp. I would like it to be a bit faster.
I would also like a way to adjust the button release timeout from a menu for the light to turn off way faster. Like with computer mouse, I prefer quite fast double click, with anduril I tend to activate turbo while I don’t need it.

I kind of think a cool option would be to adjust the turbo level in the software, rather than having to flash a lower turbo version. I think it’d be useful to be able to lower the turbo level to the same as max ramp, meaning double click from off OR on would go to max regulated mode. Basically disabling the FET channel. For the FW3A, the light is really too small to sustain turbo for more than a few seconds anyway, so the option to disable the fet altogether would be interesting. Sort of a better muggle mode, since the FET channel is really what muggles need protecting from.

ToyKeeper, one thing that doesn’t feel right for me with anduril both in stepped and stepless ramping but particularly in stepless ramping is when I’m ramping up and stop too soon (“a tad more light should be just fine”), there is no way to immediately go a bit up.
When inside the window delay, 1H goes down but 1C + 1H also goes down.
Would it be possible to change this ?
I know that I would prefer 1H to always go up and 1C + 1H to always go down because it is how it works outside of the window delay, but to not confuse people who got used to how 1H actually works, would it be possible to have 1C + 1H to go up immediately ?

This is controlled by the compile-time option USE_REVERSING. If you are able to compile Anduril yourself, you can comment that option out in anduril.c (or #undef it in the model config).

IMHO the timeout should be shortened from 1s to maybe 1 or 2 times hold time.

I agree that it could be a useful feature to be able to set the limit of turbo on the fly. Disabling the FET all together probably isn’t feasible as it is used for all unregulated modes, just PWMed to achieve the desired brightness.

Coincidentally, I have a few BLF A6 drivers I’m looking into doing just that (reducing turbo level in the firmware though) so I can use them in single emitter lights without risk of frying the emitter.

@SammysHP, thank you.
I compiled a few times in the past so I should be able to do it again. I changed computer since, so I probably need to reinstall some stuff and read again a few BLF threads to refresh my memory.
I definitely need to dig in the compile time options to make anduril works like I would like. Currently it’s pretty fine except the delayed off to be way to long. I prefer the delayed off over immediate off mainly for not turning off LED (short blink) with a 2C or 1C+1H.
I also need to change the ramp levels. When set to stepped ramping and 5 modes, the steps in brightness doesn’t feel right. The second level after the floor (when set to the lowest (1)) is too bright for me.

With Inferion’s post about using DSM to control output, I’ve been pondering how to possibly add this to FSM. I’m not sure if it will be feasible though. It seems like it would probably require doing the ramp-shape math on the attiny instead of using a full-fledged computer to calculate that… and doing arbitrary power roots in an attiny takes up a lot of space and computing time.

More importantly though, using DSM requires very precise timing on an interrupt which fires off tens of thousands of times per second, and that might not be possible in C. Basically, it changes the PWM duty cycle on every cycle, which allows it to hit in-between levels.

The upside of this is that it could have totally smooth and totally arbitrary adjustment across the entire brightness range, with pretty high resolution. It could potentially also improve thermal regulation, since it’d be doing power calculations in linear space instead of perceptual space. And it should also then be easier to make the turbo level adjustable.

There are a few downsides though:

  • Lots of math required on the attiny chip, to calculate the right values for a multi-channel light with a perceptually-linear ramp.
  • Very tight code loop required, possibly beyond what a C compiler can handle.
  • Probably wouldn’t be feasible to adjust the ramp shape in detail, like how the existing ramp calculator works. For example, on many FET+N+1 drivers, the +N part needs to start significantly above zero, to avoid making the ramp appear to stall at the boundary. This is relatively simple to work around in the current design, but would likely be quite difficult or complicated when using DSM.
  • May be difficult or impossible to get the stepped ramp to exactly hit the channel boundaries.
  • Requires rewriting quite a bit of code, both in the FSM library and in the applications which run on top of it.
  • Requires rewriting the thermal code too, and coming up with completely different abstractions for how the low-level and app-level code interact.

So it’s interesting and I’d like to at least find out if it’s feasible. But I can’t make any promises yet.

A couple months ago, I changed the release timeout from 24 to 18 WDT ticks. This might be enough to make it feel better. If not though, feel free to reduce it more. :slight_smile:

That is largely due to the ramp shape being inconsistent at the bottom end. The effective resolution is not low enough to get the exact levels desired, and I didn’t want to repeat the same level too many times in the ramp, so the lowest part is shortened.

This is something which DSM might help with, but I don’t really know yet. In theory, it might be able to increase the resolution of the bottom end and potentially even make the lowest level lower. But in practice, it might not work.