153
edits
m (→firmware design: new section) |
|||
| Line 136: | Line 136: | ||
== firmware design == | == firmware design == | ||
===pseudo code=== | |||
<nowiki> | |||
isr(int0) | isr(int0) | ||
{ | { | ||
freq++ ; | freq++ ; | ||
} | } | ||
isr(counter_2_overflow) | isr(counter_2_overflow) | ||
{ | { | ||
// copy current freq to main line, reset freq. | // copy current freq to main line, reset freq. | ||
} | } | ||
isr(adc_complete) | isr(adc_complete) | ||
{ | { | ||
copy adc value to mainline; | copy adc value to mainline; | ||
} | } | ||
isr(counter1_...) | isr(counter1_...) | ||
{ | { | ||
// implement the lighting policy | // implement the lighting policy | ||
?flip the current MOSFETs bit.. | ?flip the current MOSFETs bit.. | ||
?change the current MOSFET | ?change the current MOSFET | ||
?change the counter target | ?change the counter target | ||
} | } | ||
void | |||
main() | main() | ||
{ | { | ||
setup() ; // set the ports, direction etc. | |||
for(;;) | |||
{ | { | ||
if (newFreq) | |||
{ | |||
{ | { | ||
DISABLE_ISR ; | DISABLE_ISR ; | ||
copy new freq ; | copy new freq ; | ||
} | } | ||
if new freq != old freq | |||
adjust policy; | |||
} | |||
if (newLumons) | |||
{ | |||
{ | { | ||
DISABLE_ISR; | DISABLE_ISR; | ||
copy new lumons; | copy new lumons; | ||
} | } | ||
if new lumons != old lumons | |||
adjust policy ; | |||
} | |||
} | } | ||
} | } | ||
</nowiki> | |||
===policy ideas=== | |||
# if it is dark provide light ASAP. | |||
# if it be comes light, wait for a bit to confim it stays light, and thn start flashing the lights to provide visiblity | |||
# as the speed increases, spend more time with tight focussed lights illuminated | |||
# as the speed decreases, spend more time with flood lights illuminated. | |||
# match the power available to the power cunsumed by the LED strings | |||
policy | ===policy mechanism=== | ||
Four intervals of variable length, applied to selected string of LEDs: off, string-a on, off, string-b on. | |||
The intervals are defined as an array of counter[4]. The LED strings by the MOSFET number in an array of mosfet[4]; | |||
This will allow: | |||
* the fading from spots to floods gradually:). | |||
* day lashing patterns to be set using any two strings of LEDs. | |||
===policy config=== | |||
* night vs day lumonosity value. | |||
* samples of day light required for flashing to start. | |||
* freq exponential smoothing factor (power of 2) | |||
* night freq bounds[4] between {floods | mix | medium | mix | spots} | |||
* day freq bounds[N] between flash patterns | |||
* day flash patterns[N] | |||
===user config=== | |||
policy values in miles per hour? | |||
or are they automated from load/power info? | |||
edits