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:
stefanbode 2022-11-24 09:37:07 +01:00 committed by GitHub
parent 93c81a716a
commit 7dd0003617
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 1 deletions

View File

@ -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);
}
}