diff options
author | Jack Humbert <jack.humb@gmail.com> | 2015-10-30 00:48:17 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2015-10-30 00:48:17 -0400 |
commit | eb2795b4d649f062430c859012bc6bd8faa847ff (patch) | |
tree | 2ee3a8fc53542aa16f1632904d8be3f052895cd4 /keyboard/atomic/backlight.c | |
parent | 3ac4f1519fbc90d2357c92cfd00557bdfc024e54 (diff) | |
download | qmk_firmware-eb2795b4d649f062430c859012bc6bd8faa847ff.tar.gz qmk_firmware-eb2795b4d649f062430c859012bc6bd8faa847ff.zip |
atomic up-to-date
Diffstat (limited to 'keyboard/atomic/backlight.c')
-rw-r--r-- | keyboard/atomic/backlight.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/keyboard/atomic/backlight.c b/keyboard/atomic/backlight.c index 06f103b4ac..f69364b2af 100644 --- a/keyboard/atomic/backlight.c +++ b/keyboard/atomic/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 |