mirror of https://github.com/arendst/Tasmota.git
Update AC-Dimmer power calculation
Power on AC-Dimmer is based on integral over the sinus. Implement mapping table to get a more linear power behavior.
This commit is contained in:
parent
93c81a716a
commit
7dd0003617
|
@ -31,6 +31,17 @@ typedef struct gamma_table_t {
|
|||
uint16_t to_gamma;
|
||||
} gamma_table_t;
|
||||
|
||||
const gamma_table_t ac_dimmer_table[] = { // don't put in PROGMEM for performance reasons
|
||||
{ 0, 0 },
|
||||
{ 5, 144 },
|
||||
{ 10, 205 },
|
||||
{ 50, 500 },
|
||||
{ 90, 795 },
|
||||
{ 95, 866 },
|
||||
{ 100, 1000 },
|
||||
{ 0xFFFF, 0xFFFF } // fail-safe if out of range
|
||||
};
|
||||
|
||||
const gamma_table_t gamma_table[] = { // don't put in PROGMEM for performance reasons
|
||||
{ 1, 1 },
|
||||
{ 4, 1 },
|
||||
|
@ -318,6 +329,11 @@ uint16_t ledGammaReverse_internal(uint16_t vg, const struct gamma_table_t *gt_pt
|
|||
}
|
||||
}
|
||||
|
||||
// 10 bits power select to 10 bits timing based on sinus curve
|
||||
uint16_t ac_zero_cross_power(uint16_t v) {
|
||||
return ledGamma_internal(v, ac_dimmer_table)/10;
|
||||
}
|
||||
|
||||
// 10 bits in, 10 bits out
|
||||
uint16_t ledGamma10_10(uint16_t v) {
|
||||
return ledGamma_internal(v, gamma_table);
|
||||
|
@ -345,4 +361,4 @@ uint16_t ledGammaFast(uint16_t v) {
|
|||
|
||||
uint16_t leddGammaReverseFast(uint16_t vg) {
|
||||
return ledGammaReverse_internal(vg, gamma_table_fast);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue