E-switch UI Development / FSM

I’m not sure there will be room for extra glitch modes. At least, I’m not prioritizing those.

I think I like this. So after 1-second, reversing is still activated by a click then hold, but the first click ramps up a little bit first?

Nice! How about muggles get access to only on/off and ramping. No blinkies, strobes, or other complex operations.

I agree, but I can already hear my friends whining
 “There’s only one brightness?” “Why do I have to hold the button?” :smiley:

I’ll hush up about the blinkies, just don’t take away lightning mode! :smiley:

The “click-release-hold” action is unchanged. It always goes down.

The regular “hold” action still goes up
 unless:

  • The user completed a ramp-up less than one second ago.
  • 
 or the brightness is already at the ceiling.

I just reflashed a Q8 with this newest version of AndĂșril.

Sometimes a hold from off will remain at moon and not ramp. At first I thought this was only occurring shortly after powering off, but I’ve seen it happen after the light has been off for 30+ seconds. It seems intermittent. I can’t replicate this with my D1 running the previous version of AndĂșril. Could this be caused by the new ‘1-second’ ramping reverse rule, like it’s trying to ramp down from moon?

Other ramping functions seem normal.

I’m also getting some faint flickering during the ‘steady’ phase of bike flasher mode. It’s very faint, and seems to go away at some brightness levels along the ramp.

Hey, good catch. Fixed.

If turned off while reversed, it could then try to reverse a hold from off. The amount of time it was off doesn’t matter for that, since it doesn’t measure time while off.

About the bike flasher
 it runs at ~4 kHz PWM now instead of 15.6 kHz, as a side effect of some power management changes I added a few days ago. I’m not sure if it’s worth fixing or not, since the fix would cost a fair amount of space. Basically, all interruptible “delay” operations run at 1/4 CPU speed. This affects modes which use those, such as biking, battcheck, and beacon. It doesn’t slow down PWM in other modes though, like ramping and goodnight, which have no need for explicit delays.

The upside of this is that things like beacon are now much more efficient for longer runtimes. The downside is that the PWM on a few blinky modes might be visible or audible in some circumstances.

:+1:

Eh, probably not. I only noticed the faint flicker while ceiling bouncing the Q8 to check out the new brighter bike flasher levels. I doubt it would be visible on a bike.

I just reflashed the Q8 again. It sure is nice not needing to fire up the soldering iron!

I’ve got some thoughts about it.

  1. How about clearing mode memory on lockout? You do this on physical lockout already and doing the same on software one seems logical.
    After all if I lock it out, I will probably not use it in a moment.
  2. Independently, time-related functions need to increase power consumption only when they are running. So when mode memory is cleared, you can go back to deep sleep.

Hi TK, can I have AndĂșril .hex file? I got tons of error when trying to build with Atmel Studio.
Thanks


Most of the errors are probably due to missing header files.

The complier is looking for a several .c and .h files. You need to download these from TK’s repository.

Some are located here.

Some are located here.

You need to put these files in your project’s folder.

When you create a new Amtel Studio project, it creates a directory structure based on the name of your project. Right click the tab at the top left of Amtel Studio and click “Open Containing Folder.” Drop the .c and .h files into here and run the compiler again.

Another error you are probably encountering is, “Hey, you need to specify ATTINY” in the tk-attiny.h file. Double click the error, then scroll up a few lines and remove the // from one of the lines reading “#define ATTINY” and change the number to the proper ATtiny model number (13, 25, 85 etc.).

Hope this helps!

I’ve got AndĂșril running on a Q8, D1, and D4 now. I love having several lights with the same awesome UI!

I have an EagleEye X6R with a TA driver running Narsil that I’d like to reflash, too. It has a forward-clicky tailswitch and an e-switch on the head.

I’d like it to light up at the memorized level when powered up, so I can use the tailswitch as momentary.

I found this piece of code but I’m unsure what changes to make:

void setup() {
// blink at power-on to let user know power is connected
set_level(RAMP_SIZE/8);
delay_4ms(3);
set_level(0);
load_config();
push_state(off_state, 0);
}

Am I on the right track?

Also, how can I format code to read properly when posting here? It becomes a mess if I insert spaces at the start of a line.

For that, it will need to save the memorized level to eeprom so it can remember after power loss. And given how often that level changes, it should probably be wear-levelled. This means bringing in the EEPROM_WL code, which isn’t otherwise used in Anduril, and making changes in a few places. It’ll cost more than a few bytes.

Yes, that’s one of the places which will need changes. It’ll need “push_state(steady_state, value_from_eeprom)” instead of going to the “off” state. And, um, get rid of the initial startup blink. :slight_smile:

The other changes are larger though
 I should probably add another compile-time option for it, because this is a request which will probably come up frequently.

As for posting code, BLF isn’t very good at that. It can be done, by using a <pre> in the fancy post editor, but usually I don’t bother.

Thanks, TK! I’ll wait for a possible compile-time option for ‘power on at memory.’

In the meantime, would a ‘power up on turbo’ option be less complicated? Possibly something I could add/modify myself? Lexel enabled that in the previous install of Narsil when I ordered the TA driver.

I pushed an update with dual-switch support. It costs 172 bytes, if enabled at compile time, mostly due to bringing in wear-levelling functions.

The current method goes to the memorized level at boot, unless the e-switch is held. Then it goes to moon instead. (er, the bottom of the current ramp, whatever level that is, so it varies per-ramp)

Personally, I like having memory after lockout. If anything, I’d prefer to make it time-related, not lockout-related.

As for time-related forgetting, I’d probably want to set the time to something pretty long, like a few hours. I haven’t tried the half-sleep mode yet to find out how much power it uses, but hopefully it’s not much.

I get the impression that perhaps the desired solution would be no memory at all, so it always turns on at a specific level. This might be do-able, and I’ve been trying to leave room for a memory option, but I haven’t thought of a way to fit it into the UI yet
 at least, not a way that I’m happy with.

Wow, you work quickly! You’re spoiling me. :partying_face:

Very nice! I’m gonna update my dual-switch light right now.

Are you familiar with how the wizard character class works in D&D?

Every morning, they prepare their spells. Specifically, they take a guess at what spells they’ll need that day, and then they prepare each one. They cast 99% of each spell, leaving off only the last word or two, so that later in the day they can speak a few syllables and cause something big to happen.

FSM is the first 99% of a bunch of spells, leaving only the last little bit to be completed.

Personally, I desire memory for very short periods, like a minute or two.
I stop by the trail, turn off the light, empty my bladder, turn the light on.
Other than this
I’m yet to find use for it.
I did some searching on how others use it
.I’m surprised I can’t find anything useful really. There are many comments where people just state that they like mode memory or not. Some say that they use it to make sure the light starts on low. The only other that I found was:

But this is a workaround for not having a configurable default mode and mode memory is ill-suited for the task.

I forget; do you have firmware flashing tools? If not, it might be a good idea to get some. I think you would probably enjoy being able to tweak behavior exactly how you like it. At minimum, it would give you access to change compile-time options, but you could probably make deeper changes too.

It’s not something I recommend for everyone, but I think you’re probably serious enough about lights to get some benefit from it.

They are on the way.

:smiley:

I went for a two hour hike last night with a friend and five flashlights running AndĂșril. Two Q8s, Emisar D1, Emisar D4, and EagleEye X6R.

My friend was very impressed with the Q8 and got the hang of ramping very quickly. It was fun to keep handing him lights to try without needing to explain a different UI with each one.

I set the ramp ceilings to turbo-1 for all but the D4, which I set to turbo-55. He ramped the D4 to the ceiling and said, “Wow!” I told him to double-click and he about fell over. :laughing:

Is there a way to set AndĂșril’s ramp ceiling to turbo, or is turbo-1 the max value? Would this be a compile-only option? What if the ramp value was set to ‘turbo-(N-1)’ instead of ‘turbo-N’ when using ramp config? Must ramp ceiling and turbo remain non-equal?

BTW, dual-switch support seems to work great. I really like the ‘hold e-switch and click tailswitch’ to override memory.