E-switch UI Development / FSM

849 posts / 0 new
Last post
goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 9 min ago
Joined: 12/03/2015 - 21:28
Posts: 1021

zifzif wrote:
I had that same “region ‘text’ …” error when trying to compile Narsil a few months ago. If I recall, changing the configuration from “debug” to “release” solved the problem.
Success! My Q8 is happily running Candle Mode in celebration. Party Thanks for the tip!

Thanks again to ToyKeeper for the excellent Andúril UI, and for the ongoing improvements and tech support. Thumbs Up

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. Smile

zifzif
Offline
Last seen: 5 months 4 weeks ago
Joined: 04/28/2017 - 11:43
Posts: 32
ToyKeeper wrote:
… should work by plugging those values into Atmel Studio…

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.

zifzif
Offline
Last seen: 5 months 4 weeks ago
Joined: 04/28/2017 - 11:43
Posts: 32
goshdogit wrote:
Thanks for the tip!

No problem!

goshdogit wrote:
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?

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

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 9 min ago
Joined: 12/03/2015 - 21:28
Posts: 1021

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. Big Smile

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.

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 9 min ago
Joined: 12/03/2015 - 21:28
Posts: 1021

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. Big Smile

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 1 min ago
Joined: 01/12/2013 - 14:40
Posts: 9963
Location: (469219) 2016 HO3

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.

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 9 min ago
Joined: 12/03/2015 - 21:28
Posts: 1021

ToyKeeper wrote:
Would it bother the tactical crowd to have a glowing button interfering with their stealth in momentary blast mode?
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.’ LOL

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… Big Smile

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

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 9 min ago
Joined: 12/03/2015 - 21:28
Posts: 1021

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? Big Smile

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 1 min ago
Joined: 01/12/2013 - 14:40
Posts: 9963
Location: (469219) 2016 HO3

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…

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 9 min ago
Joined: 12/03/2015 - 21:28
Posts: 1021

ToyKeeper wrote:
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.
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. Big Smile

ToyKeeper wrote:
Probably not today, but I’ll put it on the list…
Great! Can we have a peek at what else is on your list? Party
ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 1 min ago
Joined: 01/12/2013 - 14:40
Posts: 9963
Location: (469219) 2016 HO3
goshdogit wrote:
Can we have a peek at what else is on your list? Party

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 20×4 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? Big Smile

Phlogiston
Phlogiston's picture
Offline
Last seen: 19 hours 14 min ago
Joined: 10/27/2016 - 16:57
Posts: 849
Location: Scotland

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 Smile ]

bexamous
Offline
Last seen: 5 months 3 weeks ago
Joined: 02/15/2018 - 16:54
Posts: 2
Location: United States

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:

Presets: LOW/NORMAL/HIGH/TURBO

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.

(https://github.com/bexamous/flashlight-firmware/compare/RampingPresets)

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 9 min ago
Joined: 12/03/2015 - 21:28
Posts: 1021

bexamous wrote:
I’ll have to try switching anduril as starting point.
I’m starting to sound like a broken record, but Andúril is, by far, my favorite UI. Big Smile

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.

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 9 min ago
Joined: 12/03/2015 - 21:28
Posts: 1021

ToyKeeper wrote:
Is this enough of a peek? Big Smile
Quite! Party

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

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 1 min ago
Joined: 01/12/2013 - 14:40
Posts: 9963
Location: (469219) 2016 HO3

Phlogiston wrote:
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 Smile ]

That sounds familiar… and yes, that’s pretty much what I was getting at. All the fiddly bits! 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.

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

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.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 1 min ago
Joined: 01/12/2013 - 14:40
Posts: 9963
Location: (469219) 2016 HO3
goshdogit wrote:
Be sure to also check out TK’s DarkHorse UI, a clone of the Zebralight UI.

As suggested, DarkHorse seems closest to the UI described.

bexamous wrote:
From off …

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.

kzrm316
kzrm316's picture
Offline
Last seen: 11 months 2 weeks ago
Joined: 09/10/2015 - 20:17
Posts: 87

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

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 1 min ago
Joined: 01/12/2013 - 14:40
Posts: 9963
Location: (469219) 2016 HO3

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);
            set_level(lvl);
        }
        else {
            set_state(off_state, 0);
        }
    }
    ...
}
kzrm316
kzrm316's picture
Offline
Last seen: 11 months 2 weeks ago
Joined: 09/10/2015 - 20:17
Posts: 87

But mine doesn’t turn off. It steps down at exactly 3v, and when I gradually set my power supply down to 2.4v it steps down to very low mode but doesn’t turn off.

Hunter
Offline
Last seen: 4 months 3 weeks ago
Joined: 12/23/2015 - 07:30
Posts: 256
Location: Denmark

Hello TK, good folks from this thread,

Could I ask someone willing to help out to compile momentary.c for me, I need .hex file to load to mcu.
For some reason it is harder than it looks, firs fail was: “spaghetti-monster.h: No such file or directory”
then I find this header file, put it in the folder with my project, I hit rebuild AVRGCC1 and get 4 errors now,
several: expected ‘=’, or ‘,’,’;’, ‘asm’ or ‘attribute’before ‘int_fast8_t’ and
fsm-event.h: No such file or directory!
So now I download all those fsm-… files and hit Rebuild AVRGCC1 one
more time and I get 23 errors and 7 warnings !!! Tired
If I add one more .h file I will probably get 50 errors… Sad
Why is this so hard Crying

Thanks

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 1 min ago
Joined: 01/12/2013 - 14:40
Posts: 9963
Location: (469219) 2016 HO3

I double-checked just now. Built and flashed the latest code, and it stepped down and turned off as expected.

How long did you let it run? It has a minimum amount of time between each step-down, and some of the lower levels may not appear to change because of duplicate entries in the ramp table.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 1 min ago
Joined: 01/12/2013 - 14:40
Posts: 9963
Location: (469219) 2016 HO3

Hunter, you’ll need to check out the entire branch and set up the build environment before compiling. The build options are shown in the bin/build-85.sh script, and it needs at least the ToyKeeper/* tree of the repository in order to compile.

I don’t know the exact steps for this in a GUI like Atmel Studio, because I’ve never used one. In a terminal, though, the steps are:

  • bzr branch lp:~toykeeper/flashlight-firmware/fsm
  • cd fsm/ToyKeeper/spaghetti-monster/momentary
  • ../../../bin/build-85.sh momentary
  • ../../../bin/flash-85.sh momentary.hex

kzrm316
kzrm316's picture
Offline
Last seen: 11 months 2 weeks ago
Joined: 09/10/2015 - 20:17
Posts: 87

ToyKeeper wrote:
I double-checked just now. Built and flashed the latest code, and it stepped down and turned off as expected.

How long did you let it run? It has a minimum amount of time between each step-down, and some of the lower levels may not appear to change because of duplicate entries in the ramp table.

I ran it for about an hour at 2.4v and it stays at very low mode. My anduril is the latest version.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 1 min ago
Joined: 01/12/2013 - 14:40
Posts: 9963
Location: (469219) 2016 HO3

Hunter, it definitely looks like your build environment is missing some things. It can’t even find standard library components.

Unfortunately, I don’t know how to fix that, but perhaps there are answers in Hoop’s guide, Comfychair’s guide, or WarHawk-AVG’s guide?

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 hour 1 min ago
Joined: 01/12/2013 - 14:40
Posts: 9963
Location: (469219) 2016 HO3
kzrm316 wrote:
I ran it for about an hour at 2.4v and it stays at very low mode.

Weird. It should activate in like 10 seconds. At least, mine did… and it was running at 2.6V.

If it’s low enough to trigger step-downs, it should also be able to trigger shutoff. I don’t have a “low” vs “critical” distinction in the code.

Maybe it’s a different version of the code, but LVP has been working since near the beginning. Maybe there’s a relevant hardware difference. IIRC a couple people mentioned the light bled a bit even while off, which would be hard to detect without measuring the mA during LVP. If it’s running at ~2 mA or higher, that probably means the MCU is still on and awake. But if it’s under 1 mA and light is still coming out, or if it never goes under ~3 mA, there may be a leak bypassing the MCU somehow.

ferk
Offline
Last seen: 1 year 1 month ago
Joined: 11/05/2017 - 04:36
Posts: 6
Location: Sweden

@ToyKeeper

I have had NarsilM v1.2 on my Q8 for a long time, but now I’ve flashed your new firmware anduril-q8.2018-01-24.hex
and noticed that the e-switch LED is illuminated when the lamp is turned off.

I’ve been playing around like crazy with this new firmware testing “everything” and after that the e-switch LED is no longer lit when the lamp is off.

I couldn’t figure out how to make the e-switch LED lit again while the lamp is off, so I had to re-flash the Q8 again with the same firmware anduril-q8.2018-01-24.hex and now the e-switch is illuminated again when the lamp is turned off.

My question is, how to toggle between e-switch LED behavior?

Many thanks for all your amazing work!

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 9 min ago
Joined: 12/03/2015 - 21:28
Posts: 1021

ferk wrote:
My question is, how to toggle between e-switch LED behavior?
Isn’t Andúril great? Love

ToyKeeper explained switch illumination settings a few pages back:

ToyKeeper wrote:
It also adds two more config settings — indicator state for regular operation, and indicator state for lockout mode. Each one can be “high”, “low”, or “off”. At some point I’ll probably also add a fourth state for “blinking”.

To configure these, go into lockout mode. Then click 3 times to step through lockout indicator modes (one step per triple-click), or do “click, click, hold” to select a main indicator mode (release when it’s at the desired level).

By default, it uses high for regular operation and low for lockout. But this could also be low/high, off/off, high/high, or whatever.

goshdogit
goshdogit's picture
Offline
Last seen: 5 hours 9 min ago
Joined: 12/03/2015 - 21:28
Posts: 1021
ToyKeeper wrote:
I’ve been talking a bit to someone who makes this thing, to see if it can be made to receive data over USB.

Nice!

Now you’ve got me wanting a double-sided dot matrix VFD from an IBM cash register mounted to my desk… Party

ferk
Offline
Last seen: 1 year 1 month ago
Joined: 11/05/2017 - 04:36
Posts: 6
Location: Sweden

goshdogit wrote:
Isn’t Andúril great? Love

Yes it is!

Now I can switch between the different modes.
Many thanks for your reply.

Pages