Without making changes to the code, with the clicky version you can't turn the 7135 on to 100% (which is what would be needed for no PWM) and leave the secondary FET output off. With the momentary version it is easy to do that.
What confuses me is that you're talking about two completely different things. At first you're talking about moonlight and low (maybe also medium), then in the next sentence you're talking about turning on the 7135 with no PWM while keeping the FET off.
For the clicky you just set your modes, as normal, then set the threshold PWM level to where you want the secondary output to turn on.
I’m pretty sure that, yes, STAR could be modified to support that. It probably just hasn’t been yet.
I got a Moonlight Special recently and am planning to make a fairly generic off-time clicky firmware for it. Not sure what the exact feature set will be, but it should at least allow independent control of the 1x7135 vs the FET or Nx7135 pins, and should have both a battery check mode and the ability to do short/med/long presses to do three different actions.
I just have to put a test host together first and make some time to write the code. (fortunately, Monday is a holiday so it might happen very soon)
Thanks for posting. I will take a look at this soon!
In the meantime I see that your UI description is very similar to what akv was asking for over in this thread: akv - looking for a good value flashlight so I am going to post a link over there. This sounds very good for akv.
Thanks for the link. I took a look and Baton.c and see a lot of similarities with my code.
I compiled the code and ran it on my test breadboard and found one quirk. The first press from off results in a dim light which then switches to either the last mode or moon depending on the duration of the press. I think this is because you used FAST PWM always. Changing PWM_MODE to PHASE eliminated this quirk.
Indeed. That’s why the comment at the top of the file says “FAST has side effects when PWM=0, can’t shut off light without putting the MCU to sleep”.
Unfortunately, PHASE has some downsides too — it’s often audible (high-pitched whine), and it flashes slow enough that it kind of bothers my eyes. So I usually go with FAST instead, if I use only one.
I had a feeling there was a good reason not to do this… and then wight explained it in another thread. He says:
Also, I think the attiny uses more power at faster clock speeds.
I think I’ll stick with 4.8 MHz for now.
Another potential option to eliminate both the “ghost moon” and audible whine would be to run in phase-correct mode with a PWM ceiling of 128 instead of 255. Or maybe even a ceiling of like 192. Might be high-pitched enough to not be heard. This increases the pulse frequency without increasing the clock speed. The downsides are slightly reduced output resolution and incompatibility with dual PWM.
But if you use PHASE with level of 0, you get true off. You can use FAST for all other levels. For level 255, use PHASE to get true on. This is what is done in STAR_momentary.
The reason STAR-momentary defaults to PHASE at both ends is because I kept bugging JonnyC to do it that way (for exactly the same reason). Most of my other changes have remained separate, but he accepted that one.
As for the Baton UI, I kind of stopped working on it because I found I just didn’t like the interface as much as some others. I’ve mostly been using Ramping_UI_table.c on my e-switch lights instead, or Ferrero_Rocher.c (depends on the light). The ramping UI is similar to Baton, but it does smooth ramping instead of stair-stepping, and it auto-reverses so a long press will go either up or down based on context. I didn’t have enough room to fit a battery check mode or soft lockout though (I’m using realtime batt indicators instead, and no lock).