MiniDrv - simple firmware (source code)

I think that may actually be due to using on-time no-mem rather than offtime no-mem. Basically, it kills off the mode memory after it has been on for a given amount of time. Using offtime would mean the mode advance or reset is chosen by how long the light is off during each button press, rather than by how long it was on last time it was used.

You should be able to get offtime no-mem on most drivers, even without an offtime capacitor, by using a memory decay trick. This is supported in a few firmwares, including ToyKeeper/STAR_noinit and alexvh/basic_off_time_driver. Or if you have an OTC, there are more to choose from.

Is there something I can just add (a line)to the above firmware, instead of using a totally different firmware?

Did that...

(sent from my phone, sorry for bad formatting)

So that one will work with the light always starting from low? Plus it will enable to toggle through the sequence of modes after a longer time of use,in say medium?

Thanks!

Werner,

what did you actually add/edit to do the delay thing.

and what does sleep mode do? does it influence the memory as well?

ChibiM, to answer your questions earlier… The “noinit” thing basically means that a variable will not be set to 0 when the MCU receives power. Instead, it will be left in whatever state it was in before.

This is useful for measuring short vs long offtime because it takes about half a second for the MCU’s RAM to lose its contents after power is disconnected.

To use this trick you just set a “noinit” variable to a known value (0 works well since it usually decays to 1s) and then check it again at boot. If it’s still 0, you know the power must not have been off for very long. If it’s non-zero, the memory has already decayed and you can assume the power was off for a while. Use this to determine whether to go to the next mode or go back to the first mode.

Additionally, if you want it to always start at the same mode, there is no need to store anything in eeprom. Just store the current mode in a “noinit” variable and reset it to zero on short-press. This can make things even simpler than the code DrJones posted above.

Sleep mode can be used to optimize power a bit, but the difference in power is pretty tiny (less than 0.3mA) compared to the amount used to drive the LED (~5mA to ~3000mA, generally). Also, the MCU can’t go completely into sleep mode or the PWM counter will stop.

Thanks Toykeeper, but it sounds like your are speaking a different language ;)I have no idea what you are saying.

Would it be possible to use this minidrv text, and add the lines you are talking about? so I can see it.

Oh, DrJones already did that in the example linked above. To turn off mode memory in that code, just uncomment the line which says “NOMEM” at the end.

The “cookie” bit is what implements the offtime detection. I’m not sure why it’s using 1338 though, since tests show that most bits decay to 1 while off… so a base value of 0 will detect memory decay more reliably than all 1s or a randomly-chosen value.

I just copied this exact text, and I only get 1 mode!

what does that mean? Im not a programmer.. so what does Uncomment mean? lets talk noob ;)

Bits of code can be disabled by being “commented out”.

In C (and recent versions of C) this means putting two slashes at the front of the line, or surrounding a block with a slash and star:

This line is normal.
// This line is commented out.
/*
  This section
  is commented out.
*/

In the above, only the “normal” line will have any effect. The others are basically turned off so they will be ignored. It’s an easy way to enable or disable pieces of code without actually deleting them.

They call it commenting or uncommenting because the slashes convert the text between active code and a “comment” (typically used to explain what the code is doing).

Sorry for another question. but the code I flashed still only has 1 mode.. post #58

If you only want to browse all modes take away all that cookie stuff and keep only mode.

Thanks for your help, but again.. please let me know with an example, I dont know what you guys are talking!

dont explain, but show!

No need to use this limited one if you only want to set a few modes and be done with it. I wrote a simple firmware that you don’t need to know how to code to use.

Just set your modes and flash, no explanation needed.

Hi guardior. Thanks for tuning in.
The thing I want is a 4/5 mode driver, that will always start from Low when powered off.
But has to move to the next mode while in use.

I dont need any strobes etc.. Thats why I like the minidrv. Yours seem to have strobe, beacon etc.

You just set whatever modes you want and flash.

Edit: My firmware doesn’t got off-time so if you want that too you have to look elsewhere. I didn’t even know what off-time was until ToyKeeper explained it in this thread. I don’t think I like off-time anyway so probably would never implement it.

ok. thanks! will keep waiting for someone else to tune in and help!

Will this work with only nanjg 7135 drivers or will it work with FET+1 drivers as well? I have a BLF A6/C8 driver.

It would need to be modified to support a two-channel driver like a FET+1.