Skip to content

Commit e1f2e98

Browse files
committed
minimize value after gamme correction to 1 to prevent LED off during dimming
1 parent 8979b75 commit e1f2e98

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

code/espurna/light.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ unsigned int _toPWM(unsigned long value, bool gamma, bool reverse) {
383383
} else if (value == LIGHT_MAX_VALUE) {
384384
value = LIGHT_LIMIT_PWM;
385385
} else if (gamma) {
386-
value = pow(((float)value/LIGHT_MAX_VALUE),_light_gamma)*LIGHT_LIMIT_PWM;
386+
value = std::max(1UL, (unsigned long)pow(((float)value/LIGHT_MAX_VALUE),_light_gamma)*LIGHT_LIMIT_PWM);
387387
} else {
388388
if (LIGHT_MAX_VALUE != LIGHT_LIMIT_PWM) value = map(value, 0, LIGHT_MAX_VALUE, 0, LIGHT_LIMIT_PWM);
389389
}

0 commit comments

Comments
 (0)