STAR Firmware by JonnyC - Source Code and Explanation

you can take a look at star momentary firmware, there you can see how the second PWM output is used, it’s just a few more lines to be able to use the second PWM output.

In that FW, there is another array with PWM levels for the alternate PWM Channel, and for each flashlight mode you can set separately what the PWM levels are outputted at both channels.

Thank you vex_zg for a prompt reply. It seems more complicated than I thought. The momentary FW deals with modes a little differently and I am not sure how to adjust the off-time FW that I will be using.

I plan to add secondary output to off-time capacitor reverse-clicky star firmware, within a week or two… I can share once I’m done…

I finally built a moonlight special test host tonight, and should be making a STAR derivative very soon with that sort of thing built in. I’ve been busier than I expected, but I’m getting there…

That would be excellent vex_zg and ToyKeeper. I am glad to hear that. Please share the code when you are done. Thank you

Well obviously I’m doing something wrong, I’m just too inexperienced to know what that is. I’m trying to integrate a strobe into Star off-time. Here is my full code.

Please post a diff against your most recent code which compiled correctly.

https://www.diffchecker.com/miv37pun

Your problem is here on line 381:
“else {”

You added an open bracket without a closing bracket. “else {do normal non-blinky flashlight stuff}” is the correct form.

EDIT: try just deleting “else {”.

I tried deleting it first, then also closing the bracket after the if statement, and it still gives the same error. AVRStudio says the error is in line 455.

It compiled fine for me when I deleted it.

Hmm. Maybe I’m having cache problems again… At least now that I know the code isn’t the problem, I should be able to figure it out. Thanks.

Ok it is working now, just had to restart AVRStudio. I still don’t know why it does that…
………………….
If anyone else is interested in it, here is the code.
It is STAR Off-Time, no memory. L > M > H > ~10Hz Strobe

Isn’t it satisfying when you get it working? :slight_smile:

Okay, I got a first pass written. It works but isn’t well-tested.

The “ToyKeeper/starry-offtime/” firmware is basically STAR_off_time except it lets the user set PWM levels individually per channel, and PWM speed per mode. Also, it uses the single solderable star to toggle mode memory instead of mode order. And it drops any attempt to support single-channel PWM, since the whole point of it is to improve how the second channel is handled.

This is an early rev; I’m planning to add some blinky modes as options, so you can add a strobe or beacon or battery check mode if desired. And probably the 3-level offtime handling to let people go both back and forward in the mode sequence. I don’t want to take it too far away from its origins though, so I’ll branch off into a different file before it diverges too far.

Anyway, it’s in my code repo below.

I’m looking to add a basic temperature monitor to STAR OFF-TIME v1.2 using an external temperature sensor like an LM45. (output is 0-100degrees mapped to 0-1v)

I reckon it’d be trivial to just co-op the voltage monitor shutdown procedure and simply feed it the temp monitor output instead, but that would mean losing the LVC functionality.
Is there a relatively simple way to do both? ie keep Low voltage protection and also step down at a critical temperature.

Maybe someone has already done something like this and would be willing to share their code?

Cheers
Linus

JonnyC was working on this; look at the MTN_momentary_temp version of STAR. It’s written for e-switches instead of off-time clicky, but it should at least demonstrate how.

The difficult part is that the attiny13a can only process one ADC reading at a time, so you have to keep switching the ADC channel between voltage and temperature. And you’ll most likely need different code to respond to each, since one steps down as values get lower low while the other steps down as values get higher. Also, one can step back up while the other never does.

You probably won’t need much of the solder star configuration code either, since you’ll have a maximum of one star available after connecting the OTC and temp monitor. Add an e-switch or second PWM channel or indicator LED, and then there are no pins available for stars.

Ah cool, thanks for the tip. I’ll look through that version to see how it’s done, and maybe I can understand it enough to transplant a few code snippets :slight_smile:
Cheers

Please note the operation voltage of the LM45 is 4-10V while the MCP9700/A is 2.3-5V.

Thanks, yes this would be used on a 2s driver running a 5v LDO so operation voltage isn’t a concern. Thanks for posting the alternative for 1s though, didn’t know about that one :slight_smile: