I’ve got to go to bed, but here’s a real hackjob I’ve been working on this evening. It compiles, but I don’t have time to flash it and assemble a driver before bed. There may be serious oversights.
This is intended as a proof-of-concept for a VaraPower style driver (rotary potentiometer chooses brightness) which includes low-voltage-warning and low-voltage-shutdown.
Here is what I did [thankfully not written in the order I did it]:
- used “STAR_1.1.c” as a base
- stripped out everything that I don’t think this style of driver needs, modes, turbo, etc
- replaced the main loop with the two-way ADC loop from the Nov 4, 2014 [1263cd98f9] version of MTN_momentary_temp.c
- changed the way the ADC loop switches ADC channel so that it toggles Vref back and forth as well - I think/hope? Bitwise operations are difficult for me.
- replaced the temperature stuff with a command to just patch that ADC value to PWM_level. Maybe ideally there would be a rolling average here, but that can come later.
- hacked up the LVP flashing to go full brightness during flashes
- hacked up the LVP to semi-function without modes. Ideally it should flash quickly 3 times every ~3 seconds until we hit critical, then flash 10 times and shutdown.
- copied and pasted a couple of variable initializations
* There are certainly some power savings tricks missing.
* I actually don’t see why we couldn’t add the potentiometer as a third ADC input and keep the temp monitoring.
* Come to think of it, now I can imagine how to include “stepdown” in a way that makes sense. After the 3 quick flashes, implement a ceiling value. Progressively half it or whatever is reasonable. Potentiometer throw remains the same, but the actual PWM value produced is capped @ whatever whenever it is set.
if (ADC > ceiling_value) {PWM_LVL = ceiling_value} else {PWM_LVL = ADC}
Bingo?
As far as hooking it up… I think PB2 (eg just like normal) should be voltage monitoring and PB3 [Pin 2, Star 4] should be for the pot. You hookup the pot between Vcc and GND with the sweeper hooked up to PB3.
Here it is: http://photo.jesusthepirate.com/blf/VeraPunk/v002.c
I’m sorry in advance.