]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
moves backlight functionality to keyboard files and updates template makefile
authorJack Humbert <jack.humb@gmail.com>
Sat, 30 Apr 2016 02:19:40 +0000 (22:19 -0400)
committerJack Humbert <jack.humb@gmail.com>
Sat, 30 Apr 2016 02:19:40 +0000 (22:19 -0400)
previously there were two backlight.c files (bad)

15 files changed:
keyboard/atomic/Makefile
keyboard/atomic/atomic.c
keyboard/atomic/atomic.h
keyboard/atomic/backlight.c [deleted file]
keyboard/planck/Makefile
keyboard/planck/backlight.c [deleted file]
keyboard/planck/planck.c
keyboard/planck/planck.h
keyboard/preonic/Makefile
keyboard/preonic/backlight.c [deleted file]
keyboard/preonic/preonic.c
keyboard/preonic/preonic.h
quantum/template/Makefile
quantum/template/template.c
quantum/template/template.h

index 1d91c34b7feddb202ec6a7b61b1bb3627e20a7b7..c1a0a6db422027bb60da073b670b8f5f15e32455 100644 (file)
@@ -171,10 +171,6 @@ endif
 
 endif
 
-ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
-       SRC := backlight.c $(SRC)
-endif
-
 # Optimize size but this may cause error "relocation truncated to fit"
 #EXTRALDFLAGS = -Wl,--relax
 
index 5e31264e68e1239b1c8659a6584fc9d6aabc7867..3996497161cc2400c5ed5f5cce938a45cf47fb64 100644 (file)
@@ -57,3 +57,64 @@ void led_set_kb(uint8_t usb_led) {
 
        led_set_user(usb_led);
 }
+
+#ifdef BACKLIGHT_ENABLE
+#define CHANNEL OCR1C
+
+void backlight_init_ports()
+{
+
+    // Setup PB7 as output and output low.
+    DDRB |= (1<<7);
+    PORTB &= ~(1<<7);
+    
+    // Use full 16-bit resolution. 
+    ICR1 = 0xFFFF;
+
+    // I could write a wall of text here to explain... but TL;DW
+    // Go read the ATmega32u4 datasheet.
+    // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
+    
+    // Pin PB7 = OCR1C (Timer 1, Channel C)
+    // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
+    // (i.e. start high, go low when counter matches.)
+    // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
+    // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
+    
+    TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
+    TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
+
+    backlight_init();
+}
+
+void backlight_set(uint8_t level)
+{
+    if ( level == 0 )
+    {
+        // Turn off PWM control on PB7, revert to output low.
+        TCCR1A &= ~(_BV(COM1C1));
+        CHANNEL = 0x0;
+        // Prevent backlight blink on lowest level
+        PORTB &= ~(_BV(PORTB7));
+    }
+    else if ( level == BACKLIGHT_LEVELS )
+    {
+        // Prevent backlight blink on lowest level
+        PORTB &= ~(_BV(PORTB7));
+        // Turn on PWM control of PB7
+        TCCR1A |= _BV(COM1C1);
+        // 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));
+    }
+}
+
+#endif
\ No newline at end of file
index d5461e424d4b56d13c0f84dd98900055b800c6ed..0c7aeb1cc8be6e1a0e58bef0d887cebae749975a 100644 (file)
@@ -3,8 +3,11 @@
 
 #include "matrix.h"
 #include "keymap_common.h"
-#include "backlight.h"
+#ifdef BACKLIGHT_ENABLE
+    #include "backlight.h"
+#endif
 #include <stddef.h>
+#include <avr/io.h>
 
 // This a shortcut to help you visually see your layout.
 // The following is an example using the Planck MIT layout
diff --git a/keyboard/atomic/backlight.c b/keyboard/atomic/backlight.c
deleted file mode 100644 (file)
index 647b57e..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-
-#include <avr/io.h>
-#include "backlight.h"
-#include "atomic.h"
-
-
-#define CHANNEL OCR1C
-
-void backlight_init_ports()
-{
-
-    // Setup PB7 as output and output low.
-    DDRB |= (1<<7);
-    PORTB &= ~(1<<7);
-    
-    // Use full 16-bit resolution. 
-    ICR1 = 0xFFFF;
-
-    // I could write a wall of text here to explain... but TL;DW
-    // Go read the ATmega32u4 datasheet.
-    // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
-    
-    // Pin PB7 = OCR1C (Timer 1, Channel C)
-    // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
-    // (i.e. start high, go low when counter matches.)
-    // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
-    // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
-    
-    TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
-    TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
-
-    backlight_init();
-}
-
-void backlight_set(uint8_t level)
-{
-    if ( level == 0 )
-    {
-        // Turn off PWM control on PB7, revert to output low.
-        TCCR1A &= ~(_BV(COM1C1));
-        CHANNEL = 0x0;
-        // Prevent backlight blink on lowest level
-        PORTB &= ~(_BV(PORTB7));
-    }
-    else if ( level == BACKLIGHT_LEVELS )
-    {
-        // Prevent backlight blink on lowest level
-        PORTB &= ~(_BV(PORTB7));
-        // Turn on PWM control of PB7
-        TCCR1A |= _BV(COM1C1);
-        // 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
index 01d9e3ce9a504e75dcd6b498dfa2f90074b7d0e5..c0c6201cba3ed9c084c8c8145e9d0c5312ee8a71 100644 (file)
@@ -171,10 +171,6 @@ endif
 
 endif
 
-ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
-       SRC := backlight.c $(SRC)
-endif
-
 # Optimize size but this may cause error "relocation truncated to fit"
 #EXTRALDFLAGS = -Wl,--relax
 
diff --git a/keyboard/planck/backlight.c b/keyboard/planck/backlight.c
deleted file mode 100644 (file)
index f69364b..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-
-#include <avr/io.h>
-#include "backlight.h"
-
-#define CHANNEL OCR1C
-
-void backlight_init_ports()
-{
-
-    // Setup PB7 as output and output low.
-    DDRB |= (1<<7);
-    PORTB &= ~(1<<7);
-    
-    // Use full 16-bit resolution. 
-    ICR1 = 0xFFFF;
-
-    // I could write a wall of text here to explain... but TL;DW
-    // Go read the ATmega32u4 datasheet.
-    // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
-    
-    // Pin PB7 = OCR1C (Timer 1, Channel C)
-    // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
-    // (i.e. start high, go low when counter matches.)
-    // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
-    // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
-    
-    TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
-    TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
-
-    backlight_init();
-}
-
-void backlight_set(uint8_t level)
-{
-    if ( level == 0 )
-    {
-        // Turn off PWM control on PB7, revert to output low.
-        TCCR1A &= ~(_BV(COM1C1));
-        CHANNEL = 0x0;
-        // Prevent backlight blink on lowest level
-        PORTB &= ~(_BV(PORTB7));
-    }
-    else if ( level == BACKLIGHT_LEVELS )
-    {
-        // Prevent backlight blink on lowest level
-        PORTB &= ~(_BV(PORTB7));
-        // Turn on PWM control of PB7
-        TCCR1A |= _BV(COM1C1);
-        // 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
index 4b39cf1e8bd89ec8770d0ed8a198cb358b0aebaf..65585015044ed5d7f268cb0c3242029ba9b1b935 100644 (file)
@@ -32,3 +32,64 @@ void matrix_scan_kb(void) {
 void process_action_kb(keyrecord_t *record) {
        process_action_user(record);
 }
+
+#ifdef BACKLIGHT_ENABLE
+#define CHANNEL OCR1C
+
+void backlight_init_ports()
+{
+
+    // Setup PB7 as output and output low.
+    DDRB |= (1<<7);
+    PORTB &= ~(1<<7);
+    
+    // Use full 16-bit resolution. 
+    ICR1 = 0xFFFF;
+
+    // I could write a wall of text here to explain... but TL;DW
+    // Go read the ATmega32u4 datasheet.
+    // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
+    
+    // Pin PB7 = OCR1C (Timer 1, Channel C)
+    // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
+    // (i.e. start high, go low when counter matches.)
+    // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
+    // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
+    
+    TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
+    TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
+
+    backlight_init();
+}
+
+void backlight_set(uint8_t level)
+{
+    if ( level == 0 )
+    {
+        // Turn off PWM control on PB7, revert to output low.
+        TCCR1A &= ~(_BV(COM1C1));
+        CHANNEL = 0x0;
+        // Prevent backlight blink on lowest level
+        PORTB &= ~(_BV(PORTB7));
+    }
+    else if ( level == BACKLIGHT_LEVELS )
+    {
+        // Prevent backlight blink on lowest level
+        PORTB &= ~(_BV(PORTB7));
+        // Turn on PWM control of PB7
+        TCCR1A |= _BV(COM1C1);
+        // 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));
+    }
+}
+
+#endif
\ No newline at end of file
index edcb5fbff6d84d549634ac9e38b7a285df882a3c..c5b59d9998a4cb50f0a5084125224d16a1b0ec24 100644 (file)
@@ -10,6 +10,7 @@
   #include "rgblight.h"
 #endif
 #include <stddef.h>
+#include <avr/io.h>
 #ifdef MIDI_ENABLE
        #include <keymap_midi.h>
 #endif
index 3504e27201b7c021dd57fda1404016b45662ee96..259dd6686be30e2e9d6c23c41857f146fe835928 100644 (file)
@@ -162,11 +162,6 @@ endif
 
 endif
 
-ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
-       SRC := backlight.c $(SRC)
-endif
-
-
 # Optimize size but this may cause error "relocation truncated to fit"
 #EXTRALDFLAGS = -Wl,--relax
 
diff --git a/keyboard/preonic/backlight.c b/keyboard/preonic/backlight.c
deleted file mode 100644 (file)
index f69364b..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-
-#include <avr/io.h>
-#include "backlight.h"
-
-#define CHANNEL OCR1C
-
-void backlight_init_ports()
-{
-
-    // Setup PB7 as output and output low.
-    DDRB |= (1<<7);
-    PORTB &= ~(1<<7);
-    
-    // Use full 16-bit resolution. 
-    ICR1 = 0xFFFF;
-
-    // I could write a wall of text here to explain... but TL;DW
-    // Go read the ATmega32u4 datasheet.
-    // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
-    
-    // Pin PB7 = OCR1C (Timer 1, Channel C)
-    // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
-    // (i.e. start high, go low when counter matches.)
-    // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
-    // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
-    
-    TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
-    TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
-
-    backlight_init();
-}
-
-void backlight_set(uint8_t level)
-{
-    if ( level == 0 )
-    {
-        // Turn off PWM control on PB7, revert to output low.
-        TCCR1A &= ~(_BV(COM1C1));
-        CHANNEL = 0x0;
-        // Prevent backlight blink on lowest level
-        PORTB &= ~(_BV(PORTB7));
-    }
-    else if ( level == BACKLIGHT_LEVELS )
-    {
-        // Prevent backlight blink on lowest level
-        PORTB &= ~(_BV(PORTB7));
-        // Turn on PWM control of PB7
-        TCCR1A |= _BV(COM1C1);
-        // 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
index f639f247a51952e637034b474c6e51ef230621ad..211f8d029645ada6c32ae4079094a84e5d833e68 100644 (file)
@@ -38,4 +38,65 @@ void matrix_scan_kb(void) {
 
 void process_action_kb(keyrecord_t *record) {
        process_action_user(record);
-}
\ No newline at end of file
+}
+
+#ifdef BACKLIGHT_ENABLE
+#define CHANNEL OCR1C
+
+void backlight_init_ports()
+{
+
+    // Setup PB7 as output and output low.
+    DDRB |= (1<<7);
+    PORTB &= ~(1<<7);
+    
+    // Use full 16-bit resolution. 
+    ICR1 = 0xFFFF;
+
+    // I could write a wall of text here to explain... but TL;DW
+    // Go read the ATmega32u4 datasheet.
+    // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
+    
+    // Pin PB7 = OCR1C (Timer 1, Channel C)
+    // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
+    // (i.e. start high, go low when counter matches.)
+    // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
+    // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
+    
+    TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
+    TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
+
+    backlight_init();
+}
+
+void backlight_set(uint8_t level)
+{
+    if ( level == 0 )
+    {
+        // Turn off PWM control on PB7, revert to output low.
+        TCCR1A &= ~(_BV(COM1C1));
+        CHANNEL = 0x0;
+        // Prevent backlight blink on lowest level
+        PORTB &= ~(_BV(PORTB7));
+    }
+    else if ( level == BACKLIGHT_LEVELS )
+    {
+        // Prevent backlight blink on lowest level
+        PORTB &= ~(_BV(PORTB7));
+        // Turn on PWM control of PB7
+        TCCR1A |= _BV(COM1C1);
+        // 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));
+    }
+}
+
+#endif
\ No newline at end of file
index 51ed9ba393bd2280e123601b67de8b5a3991e555..030acdadb40a2a9621806026f56021c2b9670417 100644 (file)
@@ -10,6 +10,7 @@
   #include "rgblight.h"
 #endif
 #include <stddef.h>
+#include <avr/io.h>
 #ifdef MIDI_ENABLE
        #include <keymap_midi.h>
 #endif
index 4fa195468d1fe52a0e624825defd2faa0fb66cba..1a535ef2cbad8f5ec9acf89609ed36c2a1d5b52f 100644 (file)
@@ -111,23 +111,41 @@ OPT_DEFS += -DBOOTLOADER_SIZE=512
 
 
 # Build Options
-#   comment out to disable the options.
-#
-BOOTMAGIC_ENABLE = yes         # Virtual DIP switch configuration(+1000)
-MOUSEKEY_ENABLE = yes          # Mouse keys(+4700)
-EXTRAKEY_ENABLE = yes          # Audio control and System control(+450)
-CONSOLE_ENABLE = yes           # Console for debug(+400)
-COMMAND_ENABLE = yes           # Commands for debug and configuration
-KEYBOARD_LOCK_ENABLE = yes     # Allow locking of keyboard via magic key
+#   change yes to no to disable
+#
+BOOTMAGIC_ENABLE = yes      # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = yes       # Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes       # Audio control and System control(+450)
+CONSOLE_ENABLE = yes        # Console for debug(+400)
+COMMAND_ENABLE = yes        # Commands for debug and configuration
+KEYBOARD_LOCK_ENABLE = yes  # Allow locking of keyboard via magic key
 # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
-# SLEEP_LED_ENABLE = yes       # Breathing sleep LED during USB suspend
-#NKRO_ENABLE = yes                     # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
-# BACKLIGHT_ENABLE = yes       # Enable keyboard backlight functionality
-# MIDI_ENABLE = YES                    # MIDI controls
-# UNICODE_ENABLE = YES         # Unicode
-# BLUETOOTH_ENABLE = yes       # Enable Bluetooth with the Adafruit EZ-Key HID
+SLEEP_LED_ENABLE = no       # Breathing sleep LED during USB suspend
+# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+NKRO_ENABLE = no            # USB Nkey Rollover
+BACKLIGHT_ENABLE = yes      # Enable keyboard backlight functionality
+MIDI_ENABLE = no            # MIDI controls
+UNICODE_ENABLE = no         # Unicode
+BLUETOOTH_ENABLE = no       # Enable Bluetooth with the Adafruit EZ-Key HID
+AUDIO_ENABLE = no           # Audio output on port C6
 
 
+ifdef KEYMAP
+
+ifeq ("$(wildcard keymaps/$(KEYMAP).c)","")
+ifneq ("$(wildcard keymaps/$(KEYMAP)/makefile.mk)","")
+    include keymaps/$(KEYMAP)/makefile.mk
+endif 
+endif
+
+else
+
+ifneq ("$(wildcard keymaps/default/makefile.mk)","")
+    include keymaps/default/makefile.mk
+endif
+
+endif
+
 # Optimize size but this may cause error "relocation truncated to fit"
 #EXTRALDFLAGS = -Wl,--relax
 
index cc52e496ffe8b1579be8d33d5443c4b6666dfd21..6050a2d20c572da19b337d338d777cc395a193d6 100644 (file)
@@ -46,3 +46,64 @@ void led_set_kb(uint8_t usb_led) {
 
        led_set_user(usb_led);
 }
+
+#ifdef BACKLIGHT_ENABLE
+#define CHANNEL OCR1C
+
+void backlight_init_ports()
+{
+
+    // Setup PB7 as output and output low.
+    DDRB |= (1<<7);
+    PORTB &= ~(1<<7);
+    
+    // Use full 16-bit resolution. 
+    ICR1 = 0xFFFF;
+
+    // I could write a wall of text here to explain... but TL;DW
+    // Go read the ATmega32u4 datasheet.
+    // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
+    
+    // Pin PB7 = OCR1C (Timer 1, Channel C)
+    // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
+    // (i.e. start high, go low when counter matches.)
+    // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
+    // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
+    
+    TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
+    TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
+
+    backlight_init();
+}
+
+void backlight_set(uint8_t level)
+{
+    if ( level == 0 )
+    {
+        // Turn off PWM control on PB7, revert to output low.
+        TCCR1A &= ~(_BV(COM1C1));
+        CHANNEL = 0x0;
+        // Prevent backlight blink on lowest level
+        PORTB &= ~(_BV(PORTB7));
+    }
+    else if ( level == BACKLIGHT_LEVELS )
+    {
+        // Prevent backlight blink on lowest level
+        PORTB &= ~(_BV(PORTB7));
+        // Turn on PWM control of PB7
+        TCCR1A |= _BV(COM1C1);
+        // 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));
+    }
+}
+
+#endif
\ No newline at end of file
index b1c34d3cbee294ee1d0364e6264529ade8921c1b..22742105a39b465cd4b223c6a3e073ff9c17aac9 100644 (file)
@@ -3,7 +3,10 @@
 
 #include "matrix.h"
 #include "keymap_common.h"
-#include "backlight.h"
+#ifdef BACKLIGHT_ENABLE
+       #include "backlight.h"
+#endif
+#include <avr/io.h>
 #include <stddef.h>
 
 // This a shortcut to help you visually see your layout.