aboutsummaryrefslogtreecommitdiff
path: root/keyboard
diff options
context:
space:
mode:
authorMathias Andersson <wraul@dbox.se>2013-05-20 21:08:21 +0200
committerMathias Andersson <wraul@dbox.se>2013-05-27 20:53:11 +0200
commit28aeef231b95f15ad0ddbc368781e986f559aaa8 (patch)
treeafac1e8522557ac65fc4f24614b5d401be83aea2 /keyboard
parent9e84c89535c4091522f8053a0d96b6c2ab7cc51c (diff)
downloadqmk_firmware-28aeef231b95f15ad0ddbc368781e986f559aaa8.tar.gz
qmk_firmware-28aeef231b95f15ad0ddbc368781e986f559aaa8.zip
Fix Phantom sleep LED.
Diffstat (limited to 'keyboard')
-rw-r--r--keyboard/phantom/config.h4
-rw-r--r--keyboard/phantom/led.c27
-rw-r--r--keyboard/phantom/matrix.c12
3 files changed, 33 insertions, 10 deletions
diff --git a/keyboard/phantom/config.h b/keyboard/phantom/config.h
index 09f758cd0..6f5389336 100644
--- a/keyboard/phantom/config.h
+++ b/keyboard/phantom/config.h
@@ -39,6 +39,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
39/* Set 0 if need no debouncing */ 39/* Set 0 if need no debouncing */
40#define DEBOUNCE 7 40#define DEBOUNCE 7
41 41
42/* Set LED brightness 0-255.
43 * This have no effect if sleep LED is enabled. */
44#define LED_BRIGHTNESS 250
45
42/* key combination for command */ 46/* key combination for command */
43#define IS_COMMAND() ( \ 47#define IS_COMMAND() ( \
44 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ 48 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
diff --git a/keyboard/phantom/led.c b/keyboard/phantom/led.c
index 109004ba8..f4e9108f0 100644
--- a/keyboard/phantom/led.c
+++ b/keyboard/phantom/led.c
@@ -16,19 +16,34 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17 17
18#include <avr/io.h> 18#include <avr/io.h>
19#include "stdint.h"
20#include "led.h" 19#include "led.h"
21 20
22 21
23void led_set(uint8_t usb_led) 22void led_set(uint8_t usb_led)
24{ 23{
25 if (!(usb_led & (1<<USB_LED_CAPS_LOCK))) 24 if (usb_led & (1<<USB_LED_CAPS_LOCK))
26 DDRB &= ~(1<<6); 25 {
27 else 26 // Output high.
28 DDRB |= (1<<6); 27 DDRB |= (1<<6);
28 PORTB |= (1<<6);
29 }
30 else
31 {
32 // Output low.
33 DDRB &= ~(1<<6);
34 PORTB &= ~(1<<6);
35 }
29 36
30 if (!(usb_led & (1<<USB_LED_SCROLL_LOCK))) 37 if (usb_led & (1<<USB_LED_SCROLL_LOCK))
38 {
39 // Output high.
31 DDRB &= ~(1<<7); 40 DDRB &= ~(1<<7);
41 PORTB |= (1<<7);
42 }
32 else 43 else
33 DDRB |= (1<<7); 44 {
45 // Output low.
46 DDRB &= ~(1<<7);
47 PORTB &= ~(1<<7);
48 }
34} 49}
diff --git a/keyboard/phantom/matrix.c b/keyboard/phantom/matrix.c
index c91c0d99a..6c3ae49c3 100644
--- a/keyboard/phantom/matrix.c
+++ b/keyboard/phantom/matrix.c
@@ -32,6 +32,7 @@ static void init_rows(void);
32static void unselect_cols(void); 32static void unselect_cols(void);
33static void select_col(uint8_t col); 33static void select_col(uint8_t col);
34 34
35#ifndef SLEEP_LED_ENABLE
35/* LEDs are on output compare pins OC1B OC1C 36/* LEDs are on output compare pins OC1B OC1C
36 This activates fast PWM mode on them. 37 This activates fast PWM mode on them.
37 Prescaler 256 and 8-bit counter results in 38 Prescaler 256 and 8-bit counter results in
@@ -51,12 +52,13 @@ void setup_leds(void)
51 TCCR1B |= // Timer control register 1B 52 TCCR1B |= // Timer control register 1B
52 (1<<WGM12) | // Fast PWM 8-bit 53 (1<<WGM12) | // Fast PWM 8-bit
53 (1<<CS12); // Prescaler 256 54 (1<<CS12); // Prescaler 256
54 OCR1B = 250; // Output compare register 1B 55 OCR1B = LED_BRIGHTNESS; // Output compare register 1B
55 OCR1C = 250; // Output compare register 1C 56 OCR1C = LED_BRIGHTNESS; // Output compare register 1C
56 // LEDs: LED_A -> PORTB6, LED_B -> PORTB7 57 // LEDs: LED_A -> PORTB6, LED_B -> PORTB7
57 DDRB &= 0x3F; 58 DDRB |= (1<<6) | (1<<7);
58 PORTB &= 0x3F; 59 PORTB &= ~((1<<6) | (1<<7));
59} 60}
61#endif
60 62
61inline 63inline
62uint8_t matrix_rows(void) 64uint8_t matrix_rows(void)
@@ -79,7 +81,9 @@ void matrix_init(void)
79 // initialize row and col 81 // initialize row and col
80 unselect_cols(); 82 unselect_cols();
81 init_rows(); 83 init_rows();
84#ifndef SLEEP_LED_ENABLE
82 setup_leds(); 85 setup_leds();
86#endif
83 87
84 // initialize matrix state: all keys off 88 // initialize matrix state: all keys off
85 for (uint8_t i = 0; i < MATRIX_ROWS; i++) { 89 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {