diff options
Diffstat (limited to 'tv_light/src/tv_light.ino')
| -rw-r--r-- | tv_light/src/tv_light.ino | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tv_light/src/tv_light.ino b/tv_light/src/tv_light.ino index 492069d..caf3a6e 100644 --- a/tv_light/src/tv_light.ino +++ b/tv_light/src/tv_light.ino | |||
| @@ -288,6 +288,8 @@ void flipRelay(struct sensor_t *sensor, bool send_update) | |||
| 288 | 288 | ||
| 289 | inline uint8_t pwmValue(uint8_t level) | 289 | inline uint8_t pwmValue(uint8_t level) |
| 290 | { | 290 | { |
| 291 | // see https://www.mikrocontroller.net/articles/LED-Fading | ||
| 292 | #if 0 | ||
| 291 | static const uint8_t pwmtable[101] PROGMEM = { | 293 | static const uint8_t pwmtable[101] PROGMEM = { |
| 292 | 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, | 294 | 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, |
| 293 | 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, | 295 | 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, |
| @@ -302,6 +304,23 @@ inline uint8_t pwmValue(uint8_t level) | |||
| 302 | 255 | 304 | 255 |
| 303 | }; | 305 | }; |
| 304 | return (uint8_t)pgm_read_byte(&pwmtable[level]); | 306 | return (uint8_t)pgm_read_byte(&pwmtable[level]); |
| 307 | #else | ||
| 308 | // max pwm: 255-19, 101 steps, every step +20 | ||
| 309 | static const uint8_t pwmtable[101] PROGMEM = { | ||
| 310 | 0, 20, 20, 20, 20, 20, 20, 21, 21, 21, | ||
| 311 | 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, | ||
| 312 | 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, | ||
| 313 | 24, 25, 25, 25, 26, 26, 26, 27, 27, 28, | ||
| 314 | 28, 29, 29, 30, 30, 31, 32, 32, 33, 34, | ||
| 315 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, | ||
| 316 | 46, 48, 49, 51, 53, 55, 57, 59, 61, 63, | ||
| 317 | 66, 68, 71, 74, 77, 80, 83, 87, 91, 95, | ||
| 318 | 99, 103, 108, 113, 118, 124, 130, 136, 142, 149, | ||
| 319 | 156, 164, 172, 181, 190, 199, 209, 220, 231, 243, | ||
| 320 | 255 | ||
| 321 | }; | ||
| 322 | return 255 - (uint8_t)pgm_read_byte(&pwmtable[level]); | ||
| 323 | #endif | ||
| 305 | } | 324 | } |
| 306 | 325 | ||
| 307 | void fadeDimmer(struct sensor_t *sensor, uint8_t level, bool send_update) | 326 | void fadeDimmer(struct sensor_t *sensor, uint8_t level, bool send_update) |
