Babka firmware development

I’m put together a single-channel attiny13 firmware (for Qlites, nanjg105c, etc) based on ToyKeeper’s excellent Biscotti work. It is stable and has almost everything I personally want, but feel free to share ideas & opinions!

The configuration options are:

  1. Mode Groups menu
  2. Memory Toggle
  3. Hidden Strobe Modes toggle (Strobe, Beacon, SOS)
  4. Hidden 8-Bar Batt Check toggle (if strobes are enabled, Batt Check appears at the end of them)
  5. Turbo timer toggle (default is 5 minutes, steps or ramps down to 50%)
  6. Reset to Defaults

The Mode Groups options are:

  1. 100%
  2. 20, 100
  3. 5, 35, 100%
  4. 1, 10, 35, 100
  5. 100, 35, 10, 1
  6. 100, 35, 5%
  7. 100, 20
  8. 100%, Strobe
  9. 20, 100, Strobe
  10. 5, 35, 100%, Strobe
  11. 1, 10, 35, 100, Strobe
  12. 100, 35, 10, 1, Strobe
  13. 100, 35, 5%, Strobe
  14. 100, 20, Strobe

The hidden modes are accessible via a triple-tap of the switch. If hidden strobe modes are enabled, successive taps proceed through the modes until you reach the last one, then you go back to the lowest solid mode.

Source code can be found here
The original version can be found here

Changelog 2017-05-09:

  • Simplified Turbo Timer options to just Off / On (instead of Off / 3 min / 5 min)
  • Lots of optimizations (smarter about INLINE functions, register variables, global vars, etc)
  • Flexible-length mode groups
  • Increase from 4 mode group options to 14 (can have up to 16)
  • Fast Presses redundancy
  • Option for turbo ramp-down instead of abrupt stepdown (set at compile time)
  • Room for even more, currently compiles to ~956 bytes

Changelog 2016-11-10:

  • Prevent a triple-tap from taking you to the beginning of the strobe modes if you’re already in the strobe modes
  • To make room for the above, code now assumes that group #1 has 1 mode, group #2 has 2 modes, etc instead of actually counting

Changelog 2016-10-30:

  • Mode groups sub-menu now uses the same blink-buzz action as the main menu (also saves space, making room for the next change)
  • Added menu option 8: Reset to defaults
  • Added new #define DEFAULTS to easily set the default options (used for first boot and Reset option)

Changelog 2016-10-26:

  • Firmware now has a name (“Babka”, a Polish sweet bread, in keeping inline with the bread and “B” theme)
  • Biking Strobe has been removed
  • Removed a couple Turbo Timer options (went from 6 to 3)
  • Added Memory toggle
  • Added Hidden Blinkies toggle
  • Added Hidden Batt Check toggle

I like the way nitecore does it: if you put in a cell the light will blink according to the charge of the cell. You have to remove or manually lock out the light to do this. Don’t know if that is possible.

Unfortunately that’s not possible on a clicky light, as every button tap is essentially locking out the light.

OP:
I use Battcheck much more than any other strobey modes, so I think it’s good to have it easily accessible. I don’t have any bright ideas though

Yup :frowning:

Maybe I’ll come up with some whiz-bang idea later. But for now, I just added battcheck as a hidden mode (via triple click) for the solid-modes-only mode groups.

To be honest, I never use the strobe modes. I just have them there in case someone I build a light for likes them. I’ll stick to the solid mode groups for myself; the triple-tap for battcheck will work fine.

My guess is that very few use the strobe modes so the triple tap for battery check should be fine. When you’re done I’d like to get the source and compile code if you don’t mind.

Thanks

just something where i can set the light levels where i want, 5 would be nice
no blinky

single click from off turns it on, in LOW or FIREFLY.
single clicks from on go to next level, though i would like it to go up AND then back down, sequence being FLMH T HMLF where F=firefly, T=turbo
double click from any on mode would be off
double click from off is H or turbo

that’s it
maybe a blinky but hard to get to

wle

I do like the idea of adding the memory toggle back in (so it can start on the lowest mode whenever you turn it back on). I hope to be able to squeeze that back in.

But some of these things aren’t possible with your typical clicky switch, nanjg105c driver (think S2, S3, C8, etc). Doing things like double-click for off (or from off to turbo) would require an e-switch. And reversing would be possible, unless you’re thinking of reversing via a medium press - that would require the addition of an offtime capacitor to the driver. Possible, but most people don’t have one.

When it comes to the modes - for me first one (ML – 10% – 35% – 100%) looks good, but personally I’d like:
ML – 2% – 10% – 35% – 100%
Those 2% in the middle allows for example convenient reading, where ML is too low and 10% is too high.

Mmmm, I see your point, but when I need a boost to see smeared newsprint on a crossword puzzle or such, even if the critter comes on in firefly mode, I just hold it closer to see, vs ramping up the lumens.

My gripe about too many modes is that you never really know which mode you’re in. So you might think you’re on low, it’s really on medium, and you click right through to firefly when you really want 100%. At least with wider spacing, it’s (a little) easier to tell.

The more modes, the more you have to cycle through to get back to where you think you want, haha.

I called it ML, but it may not be a true ML to some. It’s around 1%. For my tastes, that’s just about right for reading and navigating a dark house at night.

And LB, you’re spot on! I don’t like anything more than 4 modes. I lose track of where I’m at and they start blending in together.

Also, I think I’ve settled on name: Babka. It’s a Polish bread, in keeping a tie back to the Biscotti name (types of bread, starts with a B).

And I’m think of creating a second version that drops Biking Strobe (to make space, and it’s something I’d never use) and add a memory toggle, batt check toggle, etc.

Normally 4 modes is about my max on a clicky, but 10% is too bright for me following moon. I'd prefer 5%, 7% at most.

I also prefer memory, but with the reset back to mode #1 so I don't have to nav thru the hi modes to get to the lo mode. This is what I do in my clicky firmware. This feature is also known as "short cycle" memory, maybe first defined or termed by Dr Jones. It has pros and cons, though. Might go to 5 modes with this setup.

The short cycle memory functon was invented by sixty545 in feb.2011:

https://budgetlightforum.com/t/-/744/250

The name “Short Cycle Memory” was later used/proposed by DrJones.

I think what I’ve always thought of as “memory” is Short Cycle Memory. Essentially saying that from Hi, you reset back to Low, right? As opposed to going L - M - H - M - L ?

No, you go from any mode, not just hi, to low. Changing modes always starts from the first mode.

Big update, and source code is now included. See the OP.

My NC P20 is a clicky and it has this function. I’m a noob at this firmware stuff so no idea how they do it

The P20 has a dual-switch setup. And based on reading the manual, it sounds like that MODE button may be an e-switch. If LEDs in the tailcap can blink without the light being turned on, there’s juice flowing even with the light turned off. Such is not the case in your run-of-the-mill clicky.

Cool light though! Nitecore, while expensive, does make some nice lights. My P12GT was my first intro into the li-ion world, had me a bit spoiled :slight_smile:

A couple minor updates, see the changlog in OP