MiniMo - simple firmware for momentary (electronic) switches (source code)

Received my Minimo today!

Once I’ve done my chores, I will break out the soldering iron and play!

Thank you Dr Jones. :smiley:

nice :slight_smile:

3x XM-L2 T6 3B, 15-amp SRK clone driver, PWM values of 0,1,3,8,20,50,120,255

Gives totally unscientific bathroom ceiling bounce lux numbers of:
0.3
1.8
6.4
17.9
47.6
116.8
241

Comfy is right in Post 5. Thank you very much for the generosity of sharing this code DrJones. I look forward to trying it soon.

have you considered soliciting/accepting ‘donations’ from those who use the code?

I just bought a few drivers and I’m planning to use your firmware. Rather than purchase drivers from you, I’m forcing myself to learn how to flash them, with an eye toward eventually learning to modify the code…….but I have no problem compensating you for your ingenuity.

Another reason for doing it myself - I’m having a little trouble deciding which firmware to use (from just reading the text descriptions), so I want to experiment with each. I might also draw flow diagrams for your UIs at some point.

Oh, and thanks for this new addition :slight_smile:

That's a good idea Dthrckt. I'm sure I will eventually be using this code in some of my lights. I would feel better about it that way.

Anyone know what pins are the momentary switch? I can pull up the Attiny13a data sheet and compare it to the code, but I'm hoping someone already knows.

I presume its star 4, same as for lumodrv or mobydrv:

Thank you DrJones for the code!

Do I understand correctly - If I want to get rid of last mode memory and make the light always start on certain mode, I should change the code something like this:

if (mode>0) mode=0;          //was on?  -> off
else mode=2;                      //was off? -> on, start on Med

(might also skip the “lastmode” variable in the definitions)

Right?

comfychair: For a switch on PB4 use "PORTB=16;" there and "if ((PINB&16)==0)" some lines below.

AlexTG: Yes, exactly.

BTW: The minimum value of 5 in the modes[] is a quite safe value for an AMC7135-based driver; 4 might work, too. For drivers with a FET or a buck driver, even lower values may work.

Thank you Sirius9.

Yep, the low-low values 1 2 & 3 didn't work with 7135s when I tried it, only starts to light up at 4. But on the FET drivers even 1 works fine.

Dear DrJones,
Thanks for your sharing of the code.
If I understand correctly that mode=1 -> 8, mode=2 90, mode=3>255. I mean the position of the PWM levels in the line uint8_t modes={0, 8,90,255}; Am I correct?

Yep. Compare that line in the original to this one: http://75.65.123.78/fw/minimo-7mode-pb4.txt

You can also switch it to descending instead of ascending. {0,8,90,255} vs. {0,255,90,8}.

Thanx Doc. I added some simple debouncing, sped up the long click a little (350 msecs), and am using these modes:

const byte modes[]={0, 5, 10, 81, 255 }; // 5=moonlight(2%), 10=4%, 81=32%, 255=100%

The debouncing is below. It just does 3 reads on the I/O pin with a 2 msec delay in between. I'm really not sure if it will do much because no idea if the time delay of 2 msecs is relevant with this hardware. I've seen other driver code that did much longer time delays, interrupt based.

// Do some simple de-bouncing checks
byte inPressed = ((PINB&8) == 0); // 0=not pressed
if (inPressed)
{
_delay_ms (2);
inPressed = ((PINB&8) == 0);
if (inPressed)
{
_delay_ms (2);
inPressed = ((PINB&8) == 0);
}
}

if (inPressed) // qualified button being pressed

...


This firmware seems to be working fine, but I tried it in my troublesome XP-11, and high mode is not working, but had the same problem with another e-switch version (Werner's), so thinking I might have messed up the LED or driver... I think I did have a short going in with the emitter, fixed it, but damage is probably done.

Sub-moonlight with PWM of '1', after adding a big fat toroid inline with LED+...

I like these direct drive FETs much much better than 7135s.

Sweet Comfy. For some reason that fat toroidal inductor reminds me of a slicks on the back of a rear wheel drive dragster.

you’re a star DrJones and thank you for having the courage to put your hard work out there, with nothing but thanks in return. I’ve been fretting about how to turn one of my commuter lights into an e-switch light as it’s out of action due to a crappy Judco switch and this pops up. Thank you so much, it’s much appreciated.

Edited first post to add a "Werner's UI" variant of MiniMo.

Awesome update DrJones...thanks