diff options
author | Ante Vukorepa <o.orcinus@gmail.com> | 2015-07-25 17:11:31 +0200 |
---|---|---|
committer | Ante Vukorepa <o.orcinus@gmail.com> | 2015-07-25 17:11:31 +0200 |
commit | 1f52d60ef1d9aa551cb3db41999bec6bf71cf5f2 (patch) | |
tree | 6d0f4261db35d6de47fb6be74e372af46d6172c4 /keyboard/planck/backlight.c | |
parent | b8c8ecbcd67481ed69b3da95da0630bcf8e8a238 (diff) |
Fixed brightness control; Reduced number of brightness levels to 4.
Diffstat (limited to 'keyboard/planck/backlight.c')
-rw-r--r-- | keyboard/planck/backlight.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/keyboard/planck/backlight.c b/keyboard/planck/backlight.c index 06f103b4ac..f69364b2af 100644 --- a/keyboard/planck/backlight.c +++ b/keyboard/planck/backlight.c @@ -36,14 +36,26 @@ void backlight_set(uint8_t level) { // Turn off PWM control on PB7, revert to output low. TCCR1A &= ~(_BV(COM1C1)); - // CHANNEL = level << OFFSET | 0x0FFF; - CHANNEL = ((1 << level) - 1); + CHANNEL = 0x0; + // Prevent backlight blink on lowest level + PORTB &= ~(_BV(PORTB7)); } - else + else if ( level == BACKLIGHT_LEVELS ) { + // Prevent backlight blink on lowest level + PORTB &= ~(_BV(PORTB7)); // Turn on PWM control of PB7 TCCR1A |= _BV(COM1C1); - // CHANNEL = level << OFFSET | 0x0FFF; - CHANNEL = ((1 << level) - 1); + // Set the brightness + CHANNEL = 0xFFFF; + } + else + { + // Prevent backlight blink on lowest level + PORTB &= ~(_BV(PORTB7)); + // Turn on PWM control of PB7 + TCCR1A |= _BV(COM1C1); + // Set the brightness + CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); } }
\ No newline at end of file |