Nanjg 105C Ramping Code Alpha Release

Ha, good job. My brain gets scrambled when trying to work out all the permutations of those PWM registers, thanks for getting that sorted out. So it’s PFWM now? from here on out, haha.

Upping the frequency is going to provide less on time, and should have a dimming effect on the low level PWM of led. PWM_LVL = 1, then start dropping your TOP register (CEIL_LVL) numbers?

Nope, it’s the opposite. Upping the frequency provides less off-time, and the faster it gets the brighter the output appears.

With normal PWM, the ceiling stays in one place and we raise the floor to meet it. But with this new method, we’re moving the ceiling down toward the floor to give the floor a higher percentage of the total room.

These three levels should look pretty similar: 127/255, 50/100, and 10/20. They’re all about 50% total power/brightness. However, the lower the ceiling, the faster the flashes are, so if 127/255 is flashing at 9 kHz, the 10/20 mode would flash at 115 kHz.

DOH!

So… after getting some sleep, I’ve got almost everything working correctly now.

It ramps smoothly from 1/255 (phase-correct PWM) to 255/255, even smoothly ramping between individual levels (only matters at the low end). The low end ramp curve still needs a little tweaking though. It stops at the top/bottom of the brightness range, and auto-reverses when it hits the end or when the user releases the button and long-presses it again within one second. So, it can handle “Oops, passed it! Back up a little…”. A short press will turn it off/on and remember the current level. And a long press from off will always ramp up from the lowest level, so it’s a shortcut to moon. Plus, it continuously gives a realtime voltage readout on the red+green LEDs when the button isn’t being held down.

What it lacks is a shortcut to maximum, a turbo step-down (but low-batt stepdown should be working), and a bit of tweaking on the low end of the ramp. And I’ve only tested on 1xXM-L2, not on a higher-powered setup.

It currently expects a FET driver, so on a 7135 setup it’d need the entire ramp curve recalculated. Also wouldn’t hurt to disable the red+green LED indicators on systems which don’t have those.