Added basic led+backlight support
5 files changed, 94 insertions(+), 3 deletions(-) M keyboard/lightsaber/Makefile.lufa A keyboard/lightsaber/backlight.c M keyboard/lightsaber/config.h M keyboard/lightsaber/keymap_winkey.h M keyboard/lightsaber/led.c
M keyboard/lightsaber/Makefile.lufa => keyboard/lightsaber/Makefile.lufa +2 -1
@@ 51,6 51,7 @@ TARGET_DIR = . # List C source files here. (C dependencies are automatically generated.) SRC += keymap.c \ led.c \ backlight.c \ matrix.c @@ CONFIG_H = config.h 103,7 104,7 @@ CONSOLE_ENABLE = yes # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration #SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA #BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality # Boot Section Size in bytes
A keyboard/lightsaber/backlight.c => keyboard/lightsaber/backlight.c +56 -0
@@ 0,0 1,56 @@ /* Copyright 2014 Ralf Schmitt <ralf@bunkertor.net> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <avr/io.h> #include "backlight.h" /* Backlight pin configuration * * Alphas PB1 (high) * Numeric PB2 (high) * Mod+Num PB3 (high) * Backside PD6 (high) * TopRight PD7 (low) * F-Row PE6 (high) * */ void backlight_set(uint8_t level) { // Set as output. DDRB |= (1<<1) | (1<<2) | (1<<3); DDRD |= (1<<6) | (1<<7); DDRE |= (1<<6); if(level & (1<<0)) { PORTB &= ~(1<<1); PORTB &= ~(1<<2); PORTB &= ~(1<<3); PORTD &= ~(1<<6); PORTD |= (1<<7); PORTE &= ~(1<<6); } else { PORTB |= (1<<1); PORTB |= (1<<2); PORTB |= (1<<3); PORTD |= (1<<6); PORTD &= ~(1<<7); PORTE |= (1<<6); } }
M keyboard/lightsaber/config.h => keyboard/lightsaber/config.h +3 -0
@@ 32,6 32,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define MATRIX_ROWS 6 #define MATRIX_COLS 18 /* number of backlight levels */ #define BACKLIGHT_LEVELS 1 /* Set 0 if need no debouncing */ #define DEBOUNCE 5
M keyboard/lightsaber/keymap_winkey.h => keyboard/lightsaber/keymap_winkey.h +2 -1
@@ 3,10 3,11 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, PSCR, SLCK, BRK, \ GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NUMLOCK,KP_SLASH,KP_ASTERISK,KP_MINUS, \ TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, KP_7, KP_8, KP_9, KP_PLUS, \ CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NO, ENT, KP_4, KP_5, KP_6, NO, \ CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,FN0, ENT, KP_4, KP_5, KP_6, NO, \ LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, KP_1, KP_2, KP_3, KP_ENTER, \ LCTL,LGUI,LALT, SPC, NO, RALT,RGUI,RCTL, KP_0, NO, KP_DOT, NO) }; static const uint16_t PROGMEM fn_actions[] = { [0] = ACTION_BACKLIGHT_STEP() };
M keyboard/lightsaber/led.c => keyboard/lightsaber/led.c +31 -1
@@ 1,5 1,5 @@ /* Copyright 2012 Jun Wako <wakojun@gmail.com> Copyright 2014 Ralf Schmitt <ralf@bunkertor.net> This program is free software: you can redistribute it and/or modify @@ it under the terms of the GNU General Public License as published by 19,6 19,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdint.h" #include "led.h" /* LED pin configuration * * Caps PB0 (low) * NumLock PB4 (low) * */ void led_set(uint8_t usb_led) { // Set as output. DDRB |= (1<<0) | (1<<4); if (usb_led & (1<<USB_LED_CAPS_LOCK)) { // Output low. PORTB &= ~(1<<0); } else { // Output high. PORTB |= (1<<0); } if (usb_led & (1<<USB_LED_NUM_LOCK)) { // Output low. PORTB &= ~(1<<4); } else { // Output high. PORTB |= (1<<4); } }