E-switch UI Development / FSM

I haven’t implemented it yet… just thinking about how it should work. It had occurred to me that it might be nice if the alarm clock mode also worked as a momentary low mode during the waiting period, but only if it doesn’t cost much space.

Or I guess it could do the good-night thing instead, but that adds some complications. I’ll keep it in mind though, in case a simple solution appears.

… actually, I already thought of a fairly simple way to do it — push goodnight mode, then make it pop itself at the end instead of turning off. This way it can be accessed from both off and from alarm clock mode. Hmm. But that also means it would inherit the parent mode’s event mappings for unhandled events. And it’d be less friendly in a mode group rotation. That’s problematic. I’ll have to give it more thought. The modes weren’t designed to be nested.

Mostly just looking for ideas at this point, for how people would use it. So this is good feedback.

Very cool that you are working with OKLuma. Was hoping that would happen.
Extremely cool gift of a DC2! That means you are a compensated consultant.

Unfortunately, the programming side of things are well outside my range of skills, I don’t have any decent input to offer.

Please do carry on, you are making our hobby more interesting and enjoyable

That sounds great. That’s something I’d probably use quite a bit.

Looking at the config for other modes, it seems like setting up multiple things is straightforward (in the UI, at least, I’m not sure how much complexity it adds to the code). Just configuring hours would work pretty well but you could add:

  • Delay granularity to tens of minutes, so 8 taps then 3 taps would be 8 hours and 30 minutes
  • Customisable brightness. 150lm is probably fine but it would be nice if this was flexible. It could be based on the mode memory but that could give unexpected results.
  • Customisable ramp duration.

I’m being a bit picky and know first hand that adding in more features and code into something isn’t always the best decision, so take these suggestions with a grain of salt.

Wow, look'n good! t looks like the Olight Baton mode is identical to what I have in Narsil/NarsilM ramping?

Not familiar at all with OKLuma, or the DC2. Just saw the DC1 on his website though: https://okluma.com/

Weird, never heard of them before. Guess the DC2 is not yet for sale...

The Olight Baton UI is one click for on or off, but it’s more of a staircase than a ramp… and it only goes up. Normally their lights only have moon, low, med, and high. Holding the button cycles between them in that order, with a loop from high to low. I gave my Baton clone 7 levels instead of 4, but otherwise it’s mostly the same.

It’s a very simple UI and the code for it is simple too. I include it with FSM because it makes a nice reference example, and because it’s kind of nice despite how basic it is. The plan is to include clones of several popular interfaces and at least one or two unique ones.

A big goal here is to keep the interface logic separated from the hardware support code, so that most of the interfaces “just work” on most of the hardware. Adding a new driver, or adding a new interface, should be mostly independent of each other. I guess it’s similar to how traditional software separates hardware drivers from software applications, only scaled down to fit in a flashlight.

I hadn’t heard of him either until a few months ago. He does premium hand-made lights in relatively small quantities. They’re similar to Sinner’s lights, but a bit longer and narrower with different styling. He has been working on his own custom firmware lately and used bistro as a base, so he sent me a sample of his new DC2 to say thanks. I really should put up a photo review soon since it’s a beautiful light, but I’ve been preoccupied just trying to keep up with all the BLF projects lately.

Jeff has been making lights for a couple of years now. His design is really a continuation of the TriEDC that Mac popularized on CPF years ago. He’s a machinist in Oklahoma who kinda jumped in to fill the gap left after Mac disappeared, if you followed any of that drama. Jeff makes great lights, super clean machining and nice to hold and use, but with simple off-the-shelf guts (so far). The DC2 is his newest design, basically a stretched DC1 to fit an 18650. He just shipped the first batch. I didn’t buy one, but I do have one of his DC1 lights (earlier run, back when he called them the TinyDC). I basically treated mine like a host though - stripped all the guts out and rebuilt it, because that’s the BLF way :slight_smile:

I’m kind of anxious to do that too. The H17F driver is very practical, but it doesn’t have any of the fun stuff I like to put on my personal lights. However, that will have to wait. It’s my only H17F light and I’m not done poking it.

Understandable. The H17f is really a great driver. Mine was early production, just a basic Qlite driver, nothing exciting. Besides, I really wanted to build a lighted tailswitch onto a McClicky, so I did.

I’m almost certain he switched to reverse-clicky omtens when he switched to H17f’s though, because McClickies don’t really take high currents very well. I put a mtnelec FET+1/Bistro in mine, but I’m really kinda…careful with my light and never run it on turbo for long. If I melt the McClicky then I ruin all the work that went into that switch mod, and I do not want to do that.

@TK: Not sure where i read your comments regarding party strobes and frozen motion, but that rang a bell. There are several kind of strobes i would be glad to have in a powerful flashlight.

One would be a ‘motion freezing’ mode with adjustable timing. Not sure how short you can expect the pulse to be or whether it can be used for photography but that would be really cool, at least up to some scale and speed of motion. It may not work at catching real fast things though?

Another would be a really wild party strobe, cycling through different patterns, possibly with ‘tap tempo’ feature to sync on the music.

I have the adjustable motion-freezing strobe already working. It changes the pulse width depending on the frequency, and works pretty well for things like spinning fans and falling water. At the moment it only has two pulse widths though… 1ms and 0.3ms. I’ve been meaning to check if it’s a good idea to use more, but it works reasonably well as-is.

The “wild party strobe” may be best left to other devices though, particularly ones which have a microphone so it can respond to music. I mean, who wants to spend their time at a party messing with a flashlight to keep it synced to the beat?

* looks around, realizes where she is *

Er, nevermind. Don’t answer that. :slight_smile:

On a related note, did I mention there’s a momentary mode? It could be used for flashing to the beat.

…how about a ‘flickering candle’ mode…? or ‘flickering neon’ mode? or ‘defective old school light’ mode? :smiley:

TK mentioned a ‘defective lightbulb’ mode a while back. :+1:

I love the candle idea! A few thousand flickering lumens in this year’s Jack-O’-Lanterns sounds awesome! :partying_face:

Hmm. It already has a lightning storm thingy, and I probably shouldn’t fill it up with “broken light” modes. Candle in a pumpkin sounds nice but anything placed in a pumpkin has a pretty high risk of getting trashed by cruising drunks after the younger kids go home. Candles are nice other places too, though… I wonder what would be necessary to make it look good.

(Edit: this is the 2nd version of my post, the first one was too confusing, I guess.)

May I describe the E-switch user interface I am currently testing in my D4 and SRK mod?

My main goals when creating this UI were:
1.) Full brightness ramping as in D4.
2.) A momentary function from OFF for both “ON with memorized level” and “turbo”.
3.) A garantueed moon level when switching ON, followed by ramping up when switch is pressed and hold (as D4).
4.) A fast and comfortable software lock out/in option especially for D4 since I don’t want to carry this hot rod in my trouthers pocket without lockout.
5.) A true tactical mode which also allows sending morse codes.
6.) A momentary turbo from OFF and ON.

I realized I can’t have 2.) and 3.) at the same time, so I made them configurable. By simply clicking short-short-short-long I toogle between this modes, the selected state is saved in EEPROM and remembered on power up.
So in the momentary configuration the light goes ON when switch is pressed and hold and returns to OFF when switch is released. In the “guaranteed moonlight” configuration it starts at moonlight when pressed and hold and ramps up after a short break (as D4).

When ON the light ramps up and down similar to the D4.
A short clicks always switches the light ON (with memorized level) and OFF.

In addition to the tactical mode I also added an emergency mode which allows to use all of the battery capacity - of course with the risk of damaging them.
Both tactical and emergency mode can only be left by disconnecting power.

Here is a diagram what happens on different click patterns:

From OFF:
s (short click): switches the light ON with memorized brightness.
s-l (short long): momentary turbo, when releasing the switch the light goes OFF.
s-s-s: unlock light.

From ON and OFF:
s: switches the light ON/OFF.
s-s: maximum brightness (turbo), the next double click returns to last used brightness.
s-s-s: tactical strobe.
s-s-s-s: bike strobe.
s-s-s-s-s: blinks out voltage.
s-l: momentary turbo, returns to previous brightness (and/or strobe) when released.
s-s-l: lock out.
s-s-s-l: toggles momentary and “guaranteed moonlight” mode (see above).
s-s-s-s-s-s-s-l: switches to momentary mode (see below).
s-s-s-s-s-s-s-s-l: switches to emergency mode (see below).
s-s-s-s-s-s-s-s-s-l: configuration.

Special modes:

Tactical mode:
light goes ON with last memorized brightness when switched is pressed and hold, and OFF when switch is released. Nothing else, no LVP and no temperature control. Can be used for sending morse codes. You can drain your battery completely. To leave this mode you have to disconnect power.

Emergency mode:
light goes ON with predefined brightness when clicked and OFF at next click. Nothing else, no LVP and no temperature control. You can drain your battery completely. To leave this mode you have to disconnect power.

Cool. Are you planning to share the code? :slight_smile:

How did you decide on two momentary modes — one with and one without other modes available?
(edit: momentary and tactical modes)

Might be. It’s still experimental and lacks a configuration interface for the common user. I thought some of the ideas might be interesting for your project.

I rewrote my previous post to make it better understandable, hope it answers your question. I can configure two options for “press and hold” from OFF. In the “momentary” configuration it switches the light ON - and OFF when the switch is released. Like a morse switch. In the “guaranteed moonlight (and ramping)” version it behaves exactly like the Emisar D4 when “pressed and hold” from OFF. This two configurations are toggled by a triple click followed by “press and hold” (short-short-short-long).
Everything else is equal for both.

Edit:
the tactical and emergency mode are complete separated. They are just short loops in the very beginning of the code and lack - by intention - LVP and temperature control. You can’t leave this modes without disconnecting power and it’s not possible to do anything else than ON/OFF.

HDS lights have a “candle mode”. Its like an undocumented easter egg. Here’s a video on it. The guy making the video is a bit…eccentric (or more honestly likes to play a character), but you get the idea: https://www.youtube.com/watch?v=GCC3h4gz5LY. Its…okay, not bad. Its not terribly realistic as you’d imagine, but its a pretty good facsimile. I can take more video of mine if you want, but really its just a randomized strobe mode.

The number of clicks required has changed through firmware revisions as Henry adds new features to his lights. Current HDS lights are now 9 clicks to candle.

Must subscribe :smiley: not sure when I am going to read all this :confused:

I like the nice graphical UI diagrams created by toykeeper.
Would like to know if there is some free software which helps to create them.
I tend to forget how to operate my own UIs after a while not using it.

TK uses Inkscape and it’s free

google for tutorials

Wikipedia about Inkscape