]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
backlight stuff
authorJack Humbert <jack.humb@gmail.com>
Thu, 7 May 2015 19:34:46 +0000 (15:34 -0400)
committerJack Humbert <jack.humb@gmail.com>
Thu, 7 May 2015 19:34:46 +0000 (15:34 -0400)
keyboard/planck/Makefile
keyboard/planck/backlight.c
keyboard/planck/backlight.h [deleted file]
keyboard/planck/config.h
keyboard/planck/extended_keymap_common.c
keyboard/planck/extended_keymap_common.h
keyboard/planck/extended_keymaps/extended_keymap_jack.c
keyboard/planck/matrix.c

index e021e9e90bb73132979281f958173de6e8e5ef1d..773783ad1dfeee5cfa2d3c4cff51b5be8ad5b6e7 100644 (file)
@@ -53,7 +53,7 @@ TARGET_DIR = .
 ifdef COMMON
 
        SRC = keymap_common.c \
-       matrix_handwire.c \
+       matrix.c \
        led.c \
        backlight.c
 
@@ -66,7 +66,7 @@ endif
 else
 
 SRC = extended_keymap_common.c \
-       matrix_handwire.c \
+       matrix.c \
        led.c \
        backlight.c
 
index ee7e31ee9cfdf4d15a3203361759af40874c0557..a560687ec02ea2318d41ab46b2e1818e4f3dab5b 100644 (file)
@@ -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
diff --git a/keyboard/planck/backlight.h b/keyboard/planck/backlight.h
deleted file mode 100644 (file)
index 0fe1f4a..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-
-void backlight_init_ports(void);
index 0b0c15247942dac7c09cf777e5d865114731bd80..4e49a2b8979306de46f091f869f693ffd76af6c0 100644 (file)
@@ -23,9 +23,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define VENDOR_ID       0xFEED
 #define PRODUCT_ID      0x6060
 #define DEVICE_VER      0x0001
-#define MANUFACTURER    jackhumbert
+#define MANUFACTURER    Ortholinear Keyboards
 #define PRODUCT         Planck
-#define DESCRIPTION     t.m.k. keyboard firmware for the Planck
+#define DESCRIPTION     A compact ortholinear keyboard
 
 /* key matrix size */
 #define MATRIX_ROWS 4
index f8fc3209fb63de9a8380c3641090b0f015ace553..841b24943123c965b7776c4bf4f57039e2831896 100644 (file)
@@ -22,6 +22,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "action.h"
 #include "action_macro.h"
 #include "debug.h"
+#include "backlight.h"
 
 
 static action_t keycode_to_action(uint16_t keycode);
@@ -46,7 +47,30 @@ action_t action_for_key(uint8_t layer, keypos_t key)
        action_t action;
        action.code = ACTION_MACRO(keycode & 0xFF);
        return action;
-       }
+       } else if (keycode >= BL_0 & keycode <= BL_15) {
+        action_t action;
+        action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F);
+        return action;
+    } else if (keycode == BL_DEC) {
+        action_t action;
+        action.code = ACTION_BACKLIGHT_DECREASE();
+        return action;
+    } else if (keycode == BL_INC) {
+        action_t action;
+        action.code = ACTION_BACKLIGHT_INCREASE();
+        return action;
+    } else if (keycode == BL_TOGG) {
+        action_t action;
+        action.code = ACTION_BACKLIGHT_TOGGLE();
+        return action;
+    } else if (keycode == BL_STEP) {
+        action_t action;
+        action.code = ACTION_BACKLIGHT_STEP();
+        return action;
+    } else if (keycode == RESET) {
+        bootloader_jump();
+        return;
+    }
 
     switch (keycode) {
         case KC_FN0 ... KC_FN31:
index 66712459c6e3478f3095330dd4a4e3c4c59e2007..21d8978b7bb89d9e35884a4f7add76bb700554d9 100644 (file)
@@ -149,4 +149,29 @@ extern const uint16_t fn_actions[];
 
 #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
 
+#define BL_ON 0x4009
+#define BL_OFF 0x4000
+#define BL_0 0x4000
+#define BL_1 0x4001
+#define BL_2 0x4002
+#define BL_3 0x4003
+#define BL_4 0x4004
+#define BL_5 0x4005
+#define BL_6 0x4006
+#define BL_7 0x4007
+#define BL_8 0x4008
+#define BL_9 0x4009
+#define BL_10 0x400A
+#define BL_11 0x400B
+#define BL_12 0x400C
+#define BL_13 0x400D
+#define BL_14 0x400E
+#define BL_15 0x400F
+#define BL_DEC 0x4010
+#define BL_INC 0x4011
+#define BL_TOGG 0x4012
+#define BL_STEP 0x4013
+
+#define RESET 0x5000
+
 #endif
index 416ae83450bbd932f944db6cfd33c2954ecb9d15..de966ca9dfc523dd18b29006abec2b176cc38acf 100644 (file)
@@ -5,7 +5,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   {KC_TAB,  CM_Q,    CM_W,    CM_F,    CM_P,    CM_G,    CM_J,    CM_L,    CM_U,    CM_Y,    CM_SCLN, KC_BSPC},
   {KC_ESC,  CM_A,    CM_R,    CM_S,    CM_T,    CM_D,    CM_H,    CM_N,    CM_E,    CM_I,    CM_O,     KC_QUOT},
   {KC_LSFT, CM_Z,    CM_X,    CM_C,    CM_V,    CM_B,    CM_K,    CM_M,    CM_COMM, CM_DOT,  CM_SLSH, KC_ENT},
-  {M(0), KC_LCTL, KC_LALT, KC_LGUI, FUNC(2),    KC_SPC,   KC_NO,    FUNC(1),   KC_LEFT, KC_DOWN, KC_UP,  KC_RGHT}
+  {BL_STEP, KC_LCTL, KC_LALT, KC_LGUI, FUNC(2),    KC_SPC,   KC_NO,    FUNC(1),   KC_LEFT, KC_DOWN, KC_UP,  KC_RGHT}
 },
 [1] = { /* Jack hard-coded colemak */
   {KC_TAB,  KC_Q,    KC_W,    KC_F,    KC_P,    KC_G,    KC_J,    KC_L,    KC_U,    KC_Y,    KC_SCLN, KC_BSPC},
index e3926caecee9ccb4900b1c7cf27f05b9d9c0c890..156e081d141237160a7a55f9bd211c92b4130796 100644 (file)
@@ -62,8 +62,8 @@ void matrix_init(void)
     MCUCR |= (1<<JTD);
     MCUCR |= (1<<JTD);
 
-    // TODO fix this dependency 
-    backlight_init_ports();
+    // Pass default level here
+    backlight_init_ports(15);
     
     // initialize row and col
     unselect_rows();