summaryrefslogtreecommitdiff
path: root/keyboard/planck/backlight.c
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2015-05-07 15:34:46 -0400
committerJack Humbert <jack.humb@gmail.com>2015-05-07 15:34:46 -0400
commitcb3e499cc7dbff2607bc43cb05fc8c29a2eb9d30 (patch)
tree7d2b519d63b058bd841b311a75ea077de12f1d7f /keyboard/planck/backlight.c
parent1e0ae2936bfacc9d8048f64719c38b6f78790bb9 (diff)
backlight stuff
Diffstat (limited to 'keyboard/planck/backlight.c')
-rw-r--r--keyboard/planck/backlight.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/keyboard/planck/backlight.c b/keyboard/planck/backlight.c
index ee7e31ee9c..a560687ec0 100644
--- a/keyboard/planck/backlight.c
+++ b/keyboard/planck/backlight.c
@@ -2,9 +2,11 @@
#include <avr/io.h>
#include "backlight.h"
+#define CHANNEL OCR1C
-void backlight_init_ports()
+void backlight_init_ports(uint8_t level)
{
+
// Setup PB7 as output and output low.
DDRB |= (1<<7);
PORTB &= ~(1<<7);
@@ -24,9 +26,8 @@ void backlight_init_ports()
TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
-
- // Default to zero duty cycle.
- OCR1C = 0x0000;
+
+ backlight_init();
}
void backlight_set(uint8_t level)
@@ -35,12 +36,14 @@ 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);
}
else
{
// Turn on PWM control of PB7
TCCR1A |= _BV(COM1C1);
- OCR1C = level << 12 | 0x0FFF;
+ // CHANNEL = level << OFFSET | 0x0FFF;
+ CHANNEL = ((1 << level) - 1);
}
-}
-
+} \ No newline at end of file