E-switch UI Development / FSM

Exactly, and particularly no size optimation in stock configuration. This is the purpose of debug mode.

Success! My Q8 is happily running Candle Mode in celebration. :partying_face: Thanks for the tip!

Thanks again to ToyKeeper for the excellent Andúril UI, and for the ongoing improvements and tech support. :+1:

When flashing the Emisar D1 and D1S, should I use the ‘#define FSM_EMISAR_D4_DRIVER’ line? How about on an EagleEye X6R running a Texas Avenger driver and single emitter? I think the version of Andúril I’m running on them now predates the driver options.

I’ll wait to reflash my D4 until you are more confident in the thermal regulation. :slight_smile:

Looks like all of those settings match what AS7 is doing already, but there are a lot of errors to sift through. Something tells me my linker is missing some random flag, etc. The strange part is that I’ve been able to compile all of your other firmwares that I’ve tried straight OOTB. I’ll have to dig a little deeper later on, but in the meantime the Q8 *.hex works great! I really like that anyone who picks it up can intuitively use the light, but more interesting features are hidden. A very nice analogue to Bistro’s Muggle Mode.

No problem!

The D4, D1, D1S, and D4Ti all use the same driver. The #define for the D4 will work for all of them. The TA uses 3 power channels, so the #define for the FW3A might work.

Edit: formatting

Andúril’s five-click Momentary mode is awesome, especially because you can’t exit accidentally. I use it frequently on my Emisars and Q8s.

Last September, ToyKeeper added dual-switch support to Andúril. I’ve generally avoided dual-switch lights, but Andúril makes them awesome.

It’s been working great on my EagleEye X6R with a forward-clicky tailswitch and a TA driver piggybacked onto the stock driver PCB.

I hike with a floody headlamp on and a small thrower at the ready. Momentary is perfect for identifying trail markers, landmarks, and the sources of spooky noises. :smiley:

With two switches, momentary brightness can be adjusted on the fly instead of exiting momentary, changing the output level, and re-entering momentary.

Activating the tailswitch while holding the e-switch overrides memory and turns the light on in moon.

I’ve noticed that the indicator LED on my Q8 doesn’t illuminate while the light is off in momentary mode.

Should momentary share the indicator LED setting for lockout?

BTW, Candle Mode is very convincing! I’ve been enjoying it on a Q8 with a yellow spray-paint cap acting as a diffuser. :smiley:

That’s a good question. Should momentary use the same setting as lockout? Would it bother the tactical crowd to have a glowing button interfering with their stealth in momentary blast mode?

TBH, I don’t know who uses momentary mode or what their needs are, so any light people can shed on the topic would be helpful.

Hmm, I hadn’t considered that.

I’ve used momentary for light painting, where an indicator would actually be a bad thing.

I often use momentary on a second light while hiking with a floody headlamp.

I sometimes enable momentary when lending lights to young users. I can set the output based on the situation, and it prevents a light from being left on unattended. Kids seem to enjoy ‘manual strobe.’ :laughing:

Perhaps there could be separate indicator settings for:

  • off, normal operation
  • off, momentary mode
  • off, muggle mode
  • off, lockout mode
  • on, any mode

This is getting out of hand pretty quickly. The indicator config would need its own UI diagram. I think you also mentioned the possibility of a blinking/breathing indicator at some point… :smiley:

OTOH, I’d be happy with indicator settings for just two states, main emitters on and main emitters off.

ToyKeeper, I am loving Candle mode! I keep a Q8 with a diffuser burning on the coffee table in the evenings.

Would it be possible to add a sleep timer to Candle mode? I’d love to use it on my nightstand and while camping.

Ideally, it would retain brightness adjustment and run for an hour before simply ‘burning out,’ rather than dimming gradually like Sunset.

Perhaps it could be named Votive, Tealight, or CandleStub? :smiley:

Hmm… timed candle mode might be interesting. It wouldn’t be easy to make it dim over time, since it fluctuates across a fairly wide range and the low end doesn’t have sufficient resolution, but it could still stop more abruptly after a while.

The main difficulty there is just whether to spend the extra bytes or not.

Perhaps I could refactor some code to make all config-type modes use a single function and thus be smaller overall. This would free up space and reduce the cost of making modes configurable. Probably not today, but I’ll put it on the list…

Yes, abruptly ‘burning out’ is what I was thinking.

I meant it’d be neat to retain Candle mode’s adjustable flame brightness without interfering with the countdown.

I’d be the envy of the camp with a diffused light hanging over my hammock burning Candle mode with a sleep timer. :smiley:

Great! Can we have a peek at what else is on your list? :partying_face:

Aw geez. I have so many lists… Um. Let’s see. At least part of it is visible. And at least some of what’s visible is published. To see that part, check ‘anduril.txt’ in the repository, which was initially a todo list but is now mostly done… Also, try “egrep ‘TODO|FIXME’ anduril.c” to see some other items…

But I also have a variety of other lists which aren’t public. So many, in fact, that I wrote an aggregator system to merge the entire hierarchy together into a single flattened list with scores and priorities and recurring due dates and even a snooze button. It’s called “TKDO”.

And then another aggregator to merge that together with some other systems and data sources, to boil it all down to a single number plus some randomized convenience hints about what sorts of productive things I could be doing right now. That one is called, um, something I can’t say here without violating profanity rules. Let’s call it a “screwometer” since the number shows, in percent, how “screwed” I am. It even graphs the status over time.

The graph is a relatively recent addition, so it hasn’t had time to populate much history, and I’m still tweaking the factors and coefficients, but here’s a sample of the past 24 hours:

Lower is better. If it’s dropping, that means I’m getting stuff done. If it’s rising, that means I’m probably either slacking or asleep or doing something it can’t automatically measure. Currently rising since I’m chatting on BLF.

This may have all scrolled off by the time anyone sees this post (edit: nevermind, I linked to a frozen copy instead of a live version), but at the moment it shows me a graph starting at about 38, which then drops to about 20, then rises again to 34% or so. Then it starts dropping again but hasn’t gone far yet. This suggests that I got stuff done yesterday, tasks piled up while I was asleep, and now I’m starting again. But today’s peak is lower than yesterday’s, which means I’m doing something right.

If things go well, I’m hoping to build a USB nixie-style clock I can use to display the current number and trend… but for now I’ve got it displaying on an old 20x4 LCD, the same one I wrote LCDproc for back in the 90s. I don’t have a serial port any more though, so I kinda hacked together a couple of AVR reflashing cables plus some floating wires to give the display power and data. Still haven’t figured out exactly why it’s getting inverted and bitshifted data, but I can work around that (“1 + (254 - (byte << 1))”) until a proper usb-serial adapter shows up.

Is this enough of a peek? :smiley:

I just took a moment to contemplate the stacks and stacks of paperwork and books and techno-toys and Post-It notes and tools and electronic parts in this room.

Whenever something new arrives, it lands on top, then gradually settles to its natural depth within the geological strata as I pull more interesting things out from lower down and put them on top instead. Visitors can assess my priorities by noting that the books, parts and techno-toys are normally on top.

[performs an ironic bow, as from one engineer to another :slight_smile: ]

Ah cool, I didn’t realize this existed… I had started fooling with stock D4 firmware for fun. I’ll have to try switching anduril as starting point.

Not super interesting or anyting, but I dunno I find UIs interesting so:


No auto-saved mode-memory but LOW/NORMAL/HIGH levels can all be explictly saved.

From off:
LongPress -> Turn on at LOW and ramp…
Click -> Turn on at NORMAL.
Click-Press -> Momentary TURBO while Press is held, then back to off.
Click-Click -> Turn on to HIGH.

From on:
Click -> Turn off.
LongPress -> Ramp up.
Click-Press -> Momentary TURBO while Press is held, then back previous level.
Click-Click -> Jump to HIGH unless in HIGH then jump to NORMAL.
Click-Click-Press -> Jump to LOW and ramp.
Click-Click-Click -> Save current level to active preset.

(Comparing master...RampingPresets · bexamous/flashlight-firmware · GitHub)

I’m starting to sound like a broken record, but Andúril is, by far, my favorite UI. :smiley:

Your UI looks good. I like the momentary turbo while on.

Be sure to also check out TK’s DarkHorse UI, a clone of the Zebralight UI.

Quite! :partying_face:

Please share photos of your Nixie project when you get to it!

That sounds familiar… and yes, that’s pretty much what I was getting at. All the fiddly bits! :slight_smile:

The LCD I’m using now has been buried for about 15 years, and I had to go down into a crawlspace storage area to find it. Although it wasn’t being used I couldn’t get rid of it because of its history… got slashdotted, accidentally kept a company from going out of business, got a free trip to Canada, and somehow the project hasn’t died even after 20 years. And now it’s useful again.

I hope it’s not disappointing, but I might go with a nixie-style VFD instead of actual nixie tubes. That way, instead of 10 distinct digits and a dot, I get a 16-segment display and a dot… so it can display arbitrary text. I’ve been talking a bit to someone who makes this thing, to see if it can be made to receive data over USB.

As suggested, DarkHorse seems closest to the UI described.

In general, FSM is probably going to be the easiest way to create a new e-switch UI. It’s designed specifically to make it easy to go from a description to working code — by structuring the code to resemble the description, and by hiding all the annoying fiddly bits under the hood. If you can describe the states and the event mappings between those states, as already done a few posts ago, you can probably turn it into a working UI.

Does the anduril have the low voltage shutdown? I noticed that it just ramps down at low voltage but doesn’t shut off.

Yes, it shuts down at low voltage. But not unless it has stepped down all the way and is still low. Here's the code for that:

void low_voltage() {
    // in normal or muggle mode, step down or turn off
    else if ((state == steady_state) || (state == muggle_state)) {
        if (actual_level > 1) {
            uint8_t lvl = (actual_level >> 1) + (actual_level >> 2);
        else {
            set_state(off_state, 0);