Flashlight Firmware Repository

You may also need to define a MCU and layout, at the top of the file where it says “Pick your driver type”.

For the MCU I choosed the attiny25, and for the layout first I tryed tripledown and than tryed FET_7135, and both give the same error.

I just built Crescendo under Atmel Studio 7 fine - no problems, 986 bytes. Took just a couple mins to dnld the files, create the Solution/Project, add the files in. Be sure you choose the ATtiny13A as the device.

You have to edit tk-attiny.h to uncomment the #define ATTINY 13. That's it.

Be sure you change the build to "Release".

--> Do you want to build it for a 25?

This is what the project should look like:

Hy Tom E.
Yes, I want to build it for the a25.
I will try to look at the tk-attiny.h file.
Just a minute to try that and come back to post.

See clip above...

For the 25, need to change the project properties for the 25 device, and make the change in tk-attiny.h for the 25. I'll try it now.

Ok - for the 25, builds fine, 996 bytes used

Easy peasy, simple simon, wut could be quicker? Of course didn't run it, but compiler says no errors, must be perfect?

Tom E, I tryed to uncomment the #define ATTINY 25 in the tk-attiny.h file, and the project properties was for the 25 from the beginning, but without success.
Tryed to change the build to “release”, and again failure.

Does your project/solution window look like mine? It should.

Hhmm... Still say'n PHASE undefined? What layout are you using?

Might not have the latest tk-attiny.h? Where'd you get it? I got it from the folder just above Crescendo in TK's sandbox. I know it's not polite to play in someone else's sand box .

Ohhh - TK, that BOGOMIPS value in the sandbox is wrong I believe.

Tom E,
SUCCESS
The problem was that I used the tk.attiny.h file that I already previously had.
I downloaded the files that are in TK’s sandbox, and the build finished, flashed the driver and it is working.
Thanks Tom E.
Thanks TK.
I really like ramping UIs, and coupled with TA drivers, for me makes a perfect universal solution.
Thanks again.

If you got the tk-attiny.h from the sandbox, the BOGOMIPS needs to be changed - timing will be off by about 20 or 25%.

Change from:

#define BOGOMIPS (F_CPU/3200)

To:

#define BOGOMIPS (F_CPU/4000)

Perfect.
I even calibrated the voltages and OTC values.
An I wrong, or the crescendo don’t need an otc?

The BOGOMIPS value is already fixed in trunk… I just haven’t merged the branches in a while. However, tracking says I should have a PC again in about two days, so hopefully I can catch up on all the gardening and other code tasks I’ve accumulated.

Getting things done on this notebook feels rather like trying to build a ship inside a bottle. It’d be a whole lot easier without the bottle in the way.

It doesn’t need OTC.

FWIW, since you have a tiny25, you should be able to enable some extra features if you like. It can have a longer smoother ramp, more extra modes, optional memory, etc. The default options, IIRC, are intended to make it fit on tiny13.

Also, as soon as I get my office reassembled, I’m planning to update Crescendo to add thermal regulation and some small UI improvements. Kinda gritting my teeth over the thermal bits because it’s such a pain to test, but it needs to be done.

TK thanks for your hard work, and for the help.
Already changed to a smoother ramp and enabled extra features available on the code.
Will wait for the finished code to mount some drivers flashed with crescendo on many of my flashlights.

I make no promises about how long it’ll take. :wink:

(but seriously, I have a pretty long todo list)

TK, I understand the emense effort and time invested for firmware development.
Don’t worry.
Thanks once more.

Thanks for the information on building Crescendo in Atmel Studio, I was rather lost…

I’ve now managed to get it built and working on a Qlite driver :smiley:

(Also learnt another important lesson, don’t look directly at the LED as it hits the top of the ramp… :person_facepalming: )

Hello all. I would like to learn little bit about this programming. For first try, I like to modify biscotti firmware, I want to have my own group. I want to have something like: 0.1% 1% 10% 20% 30% 40% 60% 80% 100% group. Replacing one of the group within the firmware with that one. How to get this done? First all, I'm completely newbie, so hope you don't mind I asking too much.

I see in the firmware, the groups are:

PROGMEM const uint8_t modegroups[] = {
1, 2, 3, 5, 7, STROBE, BIKING_STROBE, BATTCHECK,
1, 2, 3, 5, 7, 0, 0, 0,
7, 5, 3, 2, 1, 0, 0, 0,
2, 4, 7, STROBE, BIKING_STROBE, BATTCHECK, SOS, 0,
2, 4, 7, 0, 0, 0, 0, 0,
7, 4, 2, 0, 0, 0, 0, 0,
1, 2, 3, 6, STROBE, BIKING_STROBE, BATTCHECK, SOS,
1, 2, 3, 6, 0, 0, 0, 0,
6, 3, 2, 1, 0, 0, 0, 0,
2, 3, 5, 7, 0, 0, 0, 0,
7, 4, STROBE,0,0, 0, 0, 0,
7, 0,
};

What I should edit to get my group in place? Let say I want to replace the last group with my wanna group. I don't know what those numbers represent and how to calculate the things. -.-

Those numbers are indexes into the brightness ramp, defined earlier in the code, and they go from 1 to RAMP_SIZE.

The ramp numbers are PWM levels (pulse widths) for controlling the duty cycle of the light, and they go from 0 to 255. But the lowest usable level can be anything from 1 to 9 depending on the hardware.

Some of the levels you specified are not in the default ramp, so you’ll need to make the ramp longer, which means you’ll need to edit all of the mode groups (not just one). Additionally, you specified 9 levels, and the code only allows up to 8 levels per mode group, so you’ll need to either go for 8 levels or change more of the code.

It may also be necessary to remove something to make room, since the default build comes to 1020 out of the maximum 1024 bytes and doesn’t leave enough room to extend the ramp or the mode group table much.

Because of the way humans perceive brightness, I don’t recommend having high modes spaced so close together. For 9 levels which appear to be evenly-spaced from 0.25 to 1000 lumens, the spacing would be:

trunk/bin/> ./level_calc.py
How many power channels? (1) 
How many total levels do you want? (4) 9
Describe the channels in order of lowest to highest power.
===== Channel 1 =====
Type of channel - 7135 or FET: (7135) 
Lowest visible PWM level: (6) 4
How bright is the lowest level, in lumens? (0.25) 
How bright is the highest level, in lumens? (1000) 
1: visually 0.63 (0.25 lm): 4.00/255
2: visually 1.80 (5.84 lm): 5.40/255
3: visually 2.97 (26.26 lm): 10.53/255
4: visually 4.14 (71.15 lm): 21.80/255
5: visually 5.31 (150.14 lm): 41.63/255
6: visually 6.49 (272.88 lm): 72.45/255
7: visually 7.66 (449.01 lm): 116.67/255
8: visually 8.83 (688.17 lm): 176.71/255
9: visually 10.00 (1000.00 lm): 255.00/255
PWM1 values: 4,5,11,22,42,72,117,177,255

So, that’s 0.025 / 0.5 / 2.6 / 7.1 / 15 / 27 / 45 / 69 / 100%. These numbers are generated with the bin/level_calc.py tool included in the repository.