Flashlight Firmware Repository

I thought it would take much less code. As you said, it doesn’t need to ramp down or delay and check a few times before acting, just set pwm=0 or mode_idx=0 as soon as any positive input is sensed on Pin3.

I thought it would just be as simple as changing mode order on Star3 was/is.

Yeah, I’m not sure if the ADC is even required for this. It might be able to detect the charger based only on whether the pin is “up” or “down”.

Can’t say for sure without trying it though.

… which you could probably do by using a stock build (with the pin 3 “star” enabled) and checking if it uses a different mode order depending on whether the light is plugged in.

Ok, so I flashed it with the FW version that I posted earlier, which still has the Star3 mode order code intact. Without the lead from the charger soldered, it functions correctly. With the connection to the charger but the charger NOT powered, it toggles Star3 and switches the mode order. When power is applied to the charger, mode order switches back to the original order.

Also, the driver will run without external power supply. With only power connected to Pin3 (not pin 8 ) the driver functions normally.

Edit: Just discovered that the Attiny gets extremely hot with the 5v running directly into pin3, so we definitely need a limiter inline.

As useless as my bit of code was at least were making progress I will see if it can get a test rig built this weekend and have a play

Not sure if this works but I’ll try give it a go over the weekend.

Drat, it sounds like the easy method doesn’t work. :frowning:

I've measured some FET drivers PWM on my scope at around 17 KHz, but I've never seen one go up close to 19 KHz.

When I flash that, the driver behaves very strangely. I can’t even work out a pattern.

The driver is responding to the charger being powered, we just need to make it respond in the way that we want.
I tried this, but no dice

Plus, we need to have it check pin 3 continuously, not just when power is first applied.

OK I’ve flashed my latest attempt and I just get the modes in reverse order. My additional Beacon works tho which is a start :slight_smile:

I tried this just to see if it was doing something

If I power the driver with the charger attached but not powered, it comes on in mode 2.
If I power the driver with charger also powered, it comes on in mode 3.

I’d say that’s progress!

The problem is that it doesn’t change if you connect/disconnect the charger while the driver is already on, and I can no longer change modes (it stays in whatever mode it came on in)

-Just tried:
PCMSK = (1 << SWITCH_PIN) | (1 << STAR3_PIN);
But no luck-

It’s just occurred to me that I’m being really stupid. I don’t actually have pin 3 connected. I hadn’t but a resistor inline

OK I’m done for tonight I’ll have another crack at this tomorrow.

I’ve even tried adjusting MTN-Mom as it has temp sensor so any input would shut off but no luck so far.

Yes, but… what happens if you power up the light without the charger attached? It needs to distinguish between either of these two…

  • Charger isn’t attached.
  • Charger is attached but not powered.

… and this:

  • Charger is attached and powered.

Earlier it sounded like “attached and powered” gave the same result as “not attached”, which isn’t very useful.

Given a way to distinguish those different states, making it change while on isn’t terribly difficult.

but the charger will always be attached…. When i say charger, I am referring to the X6R charging circuit, not the actual charging cord

… oh. Then that definitely makes things easier. :slight_smile:

Sometimes I over-complicate things.

I’ve spend a good few hours today playing with this trying different tweaks on different firmwares.

Best I go was tweaking MTN_momentary_temp so that if the temp sensor reads 255 then mode_idx = 0 when I had the if, else the wrong way round it would just set mode to 0 when ever I tried to change mode but when they were to correct way round I just got very odd mode changes.

Hi TK,

Someone asked me to flash some micros for him with this firmware.
http://bazaar.launchpad.net/~toykeeper/flashlight-firmware/trunk/files/head:/ToyKeeper/blf-a6/cypreus2/

His boards are not the FET+1 so my question is will this firmware work with a regular FET driver?

I was thinking maybe if I disable the second channel and change the PWM values for the first?

Or is it more complicated than than?

It should work on a FET-only driver if you disable moon and replace all the 7135 modes with FET modes and recalculate the levels and recalibrate the OTC and voltage values.

I have been making some progress with this Pin3 turn off. The code here turns the light off when the usb cable is connected. :slight_smile:

It does have a bug tho. Once it’s turned the light off and you unplug the charger cable it will allow you to change modes then turn off again after .5s

EDIT: Made one last tweak and now it works!!! Code HERE

I’ve added an extra beacon mode, very long press to activate.

But hey it’s getting there. (BTW voltage monitoring is switched off atm so I know its not interfering with turning off ect…)