luxdrv - custom modes driver firmware with ramping

Thanks DrJones. My mother loves the modified code.

Is there a way to increase delay time between blinks for battery level. Sometimes it's difficult to read out number of blinks.

I'm not too comfortable with C but i presume it's defined in case 252 line...

Yes, add some "SLEEP;" in this segment:

{PWM=8; SLEEP;SLEEP; PWM=0; SLEEP; i-=5;}

like

{PWM=8; SLEEP;SLEEP;SLEEP;SLEEP; PWM=0; SLEEP;SLEEP; i-=5;}

makes it twice as long

Adding one "SLEEP" to off state was enough to slow things down a little bit... Actually this firmware is very easy to modify (even for user with very limited programming language knowledge) and adapt to certain wishes. I really want to thank you for sharing it with all of us :beer:

Thanks DrJones for your driver v0.30,it is great! By some reasons I do not need memorizing of last used mode,need always to start from lowest level,without a dummy mode.Which way I can disable memory function in your code and set low to be always first?Acualy I am more familiar with Tido code and managed to implement all above mentioned in his version,but unfortunately I can not inplement your battery indicator in inside his beacon mode -something not working.That is why decided to try your version as it is already have battery indicator.Or , is there the way to transfer such function to Tido simple version of driver?Lets say to make some mix of functions...

Edit: one more question-is it possible to move blinking modes(and beacon with battery indicator) into extended hidden group?

You could also try looking at the mother of Luxdrv here.

You can see how I implemented the battery readout in Tido's program. Now you can also switch the memory on/off (done in SOS mode).

sixty545,many thanks for reply! I t copied your code to AvrStudio.Code looks much more familiar because is based on Tido code.

Now editing brightness of main modes,removing strobe and police strobe.I am planning to leave only Softbeacon for battery readout.Is it possible in your SIMPLE setup to disable memory function completely, in order to start always from low and remove sos mode also?

Sorry for cutting too much your version,sure you spent many hours improving it.But my father wish to have 4-5 simple modes,no blinking modes,no memory,battery monitor+battery readout.

To not hijack this thread, I PM'd you the solution.

mrmate: I'll answer your question anyway:

To eliminate memory, find the line (about line 145)

if (ticks==LOCKTIME) eepsave(mode); //lock mode after 1.5s

and change it to

if (ticks==LOCKTIME) eepsave(1); //lock mode after 1.5s

Next time it's switched on, it will use 1st mode again.

There's no extended mode group, because you don't have to cycle through all modes anyway - there isn't even memory, so you always start with 1st mode, and you only get to the blinkies if you don't stop tapping at a 'normal' mode. No-Memory (and the luxdrv UI even with memory (sixty545's idea)) sort of hides every mode behind all it's predecessors.

You could repeat the "normal" modes in the mode list to push the 'extended' modes further back and make them more hidden.

DrJones,thank you for answering my question! After testing such setup I agree with you that extended modes not needed as blinkies are far at the end and no need to cycle all modes in order to get the first one.Definetly ,such UI seems rather convenient.

Dr Jones, what are the output levels of the 6 steps by default (particularly the lowest) and how low can the ramping go?

Dr Jones,

Firstly I would like to thank you for posting this because I have searched everywhere for this as the programming is much more difficult than other μc (say picaxe μc’s). Secondly, I wanted to know if it is possible to program the chip to make possible another mode where the electrical output is changed from the default pin to another so I can add an led fader circuit to it. Or if it is possible to program an LED fader mode.

Also, could you tell me the name of this type of programming so I could learn it?

Thanks again

If it is possible to program an LED fader mode, where the led contstantly fades in and out, could you get me started by coding a bit of it or showing me a website where I could learn to code the fading mode my self

Welcome aboard, donkey55!

Well, the ramping in luxdrv does that - in 25 steps though, so it's not a smooth fade. Also it always writes into EEPROM, which wears that out after some hours, so you could copy that procedure and omit the EEPROM writing.

Additionally, TIDO's firmware and sixty545's variant have that, see here and here (posts #254 and 264).

The output pin can be changed in these lines, which refer to pin6, PB1, OC0B

#define outpin 1
#define PWM OCR0B //PWM-value

to pin 5, PB0, OCR0A:

#define outpin 0
#define PWM OCR0A //PWM-value

It must be one of these two pin though, since only these have hardware PWM.

When building luxdrv with Atmel Studio 6, I get this:

Error 1 Cannot find include file: avr/pgmspace.h 33
Error 2 PROGMEM: Unknown instruction or macro 43
Error 3 uint8_t: Unknown instruction or macro 43
Error 4 modes: Unknown instruction or macro 43
Error 5 syntax error, unexpected ‘=’ 43

If include this in the tool chain path:
…/…/…/…/…/…/…/Program Files (x86)/Atmel/Atmel Studio 6.0/extensions/Atmel/AVRGCC/3.4.1.81/AVRToolchain/avr/include

The errors turn into this:

Error 1 typedef: Unknown instruction or macro …/…/…/…/…/…/…/Program Files (x86)/Atmel/Atmel Studio 6.0/extensions/Atmel/AVRGCC/3.4.1.81/AVRToolchain/avr/include\stdint.h 121 0 luxdrvChig
Error 2 signed: Unknown instruction or macro …/…/…/…/…/…/…/Program Files (x86)/Atmel/Atmel Studio 6.0/extensions/Atmel/AVRGCC/3.4.1.81/AVRToolchain/avr/include\stdint.h 121 0 luxdrvChig
Error 3 syntax error, unexpected FUNCTION …/…/…/…/…/…/…/Program Files (x86)/Atmel/Atmel Studio 6.0/extensions/Atmel/AVRGCC/3.4.1.81/AVRToolchain/avr/include\stdint.h 121 0 luxdrvChig

Okay, seriously I don’t know what I’m doing. This seems more difficult than it should be. And frustrating.

Maybe you could just include the other files in the download so I don’t have to compile my own? (although that removes the possibility of customization)

I have now successfully compiled Tido’s code in Atmel Studio 6, so I officially know how to do it. Yay!

By copying the method I used to make his work, I got further this time with luxdrv, but I now get this error:

Error 1 variable ‘modes’ must be const in order to be put into read-only section by means of ‘attribute((progmem))’ Line: 41

If I change this line:
PROGMEM byte modes={ 0, 6,51,255, 254, 251, 252, 253 }; // with ramping
to this:
const PROGMEM byte modes={ 0, 6,51,255, 254, 251, 252, 253 }; // with ramping

it compiles, but is also too big. :frowning:

I don’t know, it seems to be the same problem referred to here:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&theme=print&p=860835

I was just about to write that - prepend const.

About size - well, it seems that AVRstudio4+winAVR produce slightly smaller code. However most people do not need that 5-minute-timer. Just deactivate it :)

Change

PROGMEM byte modes[]={ 0, 6,51,255, 254, 251, 252, 253 };

#define TIMER 5 //use timer (5 min, max 6 in this setup)

to

PROGMEM byte modes[]={ 0, 6,51,255, 254, 251, 252 };

//#define TIMER 5 //use timer (5 min, max 6 in this setup)

(delete "253" and prepend "//")

I just about laughed out loud, because I had the exact same thought process, and even already removed the timer before I read this!

I’m seconds away from flashing my new file to the chip, so here goes nothing, THANK YOU!

:slight_smile:

How did you solve the library problem btw?