Babka firmware development

72 posts / 0 new
Last post

Pages

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL
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

Edited by: gchart on 01/18/2018 - 14:37
dekozn
Offline
Last seen: 1 hour 52 min ago
Joined: 06/17/2016 - 09:04
Posts: 767
Location: Be

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.

Idiot proofing something only creates improved idiots.

pilotdog68
pilotdog68's picture
Offline
Last seen: 3 weeks 6 days ago
Joined: 05/30/2013 - 23:31
Posts: 6420
Location: Held against my will in IOWA, USA

dekozn wrote:
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

My Favorite Modded Lights: X6R, S8 , X2R , M6, SP03

Major Projects:  Illuminated Tailcap, TripleDown/TripleStack Driver

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

Yup Sad

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

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.

SIGShooter
SIGShooter's picture
Offline
Last seen: 31 min 53 sec ago
Joined: 07/14/2013 - 02:10
Posts: 1793
Location: northern california

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

9mm/40cal/45cal bullets and large/small pistol primers available for sale in San Francisco Bay area

wle
wle's picture
Offline
Last seen: 16 hours 13 min ago
Joined: 01/07/2015 - 13:49
Posts: 1485
Location: atlanta ga

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

========
"You never have the wind with you - it's either against you, or you're having a good day."
--Daniel Behrman, "The Man Who Loved Bicycles".
========
It never gets easy, you just go faster.

--Greg Lemond.
========
,ø¤º°`°º¤ø¸,ø¤º°`°º¤ø¸,ø¤º°`°º¤ø¸
              __o
    __o     _`\<,_      __o
  _`\<,_   (*)/ (*)   _`\<,_
 (*)/ (*)            (*)/ (*)
,ø¤º°`°º¤ø¸,ø¤º°`°º¤ø¸,ø¤º°`°º¤ø¸
========

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

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.

Woytas
Offline
Last seen: 1 year 3 weeks ago
Joined: 01/08/2016 - 01:02
Posts: 308
Location: Poland

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.

Lightbringer
Lightbringer's picture
Offline
Last seen: 2 hours 32 min ago
Joined: 08/30/2016 - 14:12
Posts: 9976
Location: nyc
Woytas wrote:
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.

09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

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.

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

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.

Tom E
Tom E's picture
Offline
Last seen: 3 hours 30 min ago
Joined: 08/19/2012 - 08:23
Posts: 12408
Location: LI NY

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.

sixty545
Offline
Last seen: 6 months 1 week ago
Joined: 10/25/2010 - 14:15
Posts: 702
Location: Denmark (GMT + 1)
Tom E wrote:

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.


This feature is also known as “short cycle” memory, maybe first defined or termed by Dr Jones.

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

http://budgetlightforum.com/comment/23691#comment-23691

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

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

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 ?

Tom E
Tom E's picture
Offline
Last seen: 3 hours 30 min ago
Joined: 08/19/2012 - 08:23
Posts: 12408
Location: LI NY

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

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

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

Box
Offline
Last seen: 3 weeks 4 days ago
Joined: 08/26/2014 - 06:53
Posts: 636
Location: Australia

pilotdog68 wrote:
dekozn wrote:
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


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
gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

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 Smile

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

A couple minor updates, see the changlog in OP

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

A couple minor updates, see OP for details

Lexel
Lexel's picture
Offline
Last seen: 1 day 19 hours ago
Joined: 11/01/2016 - 08:00
Posts: 5533
Location: Germany

Can you do a setting so that it always get on at 100% another tap gets you to strobe then reversed mode toggle
Tactical configuration for self defense

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

I’ve never used a tactical setup. So basically just 100% and Strobe, no memory?

I’m right at the max size of the code as it is, but I’ll see if I can trim something down for some new options like that.

Lexel
Lexel's picture
Offline
Last seen: 1 day 19 hours ago
Joined: 11/01/2016 - 08:00
Posts: 5533
Location: Germany

Yeah for tactical no memory and starting at 100% is ok group can stay as it is just reversed with hidden modes

For defence just turn light on and get max output is important

Mitko
Mitko's picture
Offline
Last seen: 2 weeks 4 days ago
Joined: 09/19/2014 - 05:20
Posts: 1537
Location: Bulgaria

perfect firmware,thanks gchart for helping me out perfecting git even more! Quite helpull BLF fella

prisma
Offline
Last seen: 1 week 4 days ago
Joined: 12/02/2011 - 11:07
Posts: 132
Location: Germany

I tried your FW the first time today and it works fine for me. Thank you very much gchart!

It is the only one I found for Attiny13 with LVP, Batt Check, Turbo timer and without hardware modification (is there another one…?). And it can be further customized for my needs Thumbs Up

flucero28
Offline
Last seen: 2 months 2 weeks ago
Joined: 04/24/2012 - 11:24
Posts: 44
Location: New Mexico

Hello Gchart,

I hate to keep bothering you. Your version of babka based off biscotti is perfect for me. I finally got biscotti to work however, when I try to compile your babka I get several errors in reference to delay in ms:

Do you have any suggestions?

Thank you,

Frank

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

Hi Frank, no bother at all! It looks like the compiler isn’t finding the “_delay_ms” function. It should be in the “tk-delay.h” include file. Do you have that file in the same directory as your C file? (or nearby with the C file pointing to appropriate directory)

Also, there’s a new version that I just thought to upload, you can find it here. Highlights:

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

flucero28
Offline
Last seen: 2 months 2 weeks ago
Joined: 04/24/2012 - 11:24
Posts: 44
Location: New Mexico

Thank you gchart! I will double check when I get home from work today, and will be trying the new version!

Frank

flucero28
Offline
Last seen: 2 months 2 weeks ago
Joined: 04/24/2012 - 11:24
Posts: 44
Location: New Mexico

Got the tk-delay.h issue resolved however now when I run it as copied from your page it states it is 1132 bytes and 110.5% full. Do I need to disable features or am I doing something wrong in atmelstudio? I have optimization set for -0s.

Thank you,

Frank

gchart
gchart's picture
Offline
Last seen: 1 hour 50 min ago
Joined: 03/19/2016 - 11:57
Posts: 1808
Location: Central IL

Wow, that’s a considerable size difference. You shouldn’t need to disable anything. I’m guessing it’s a compile option in Atmel. You say you have “-0s” selected… how about language standard C99? Make sure to use both of those.

Pages