diff options
| author | Eric Tang <e_l_tang@outlook.com> | 2016-06-12 15:01:55 -0700 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2016-06-12 18:01:55 -0400 |
| commit | 6955719075a9a07524814e4183f3f90f83db1c6a (patch) | |
| tree | 4992f68783514c307c327a8fe88fc41d29550a56 | |
| parent | 92759be3226c83087959015be097b66d8c7e2f21 (diff) | |
| download | qmk_firmware-6955719075a9a07524814e4183f3f90f83db1c6a.tar.gz qmk_firmware-6955719075a9a07524814e4183f3f90f83db1c6a.zip | |
Move LED strip initialization (#397)
| -rw-r--r-- | keyboard/clueboard1/clueboard1.c | 4 | ||||
| -rw-r--r-- | keyboard/clueboard2/clueboard2.c | 4 | ||||
| -rw-r--r-- | keyboard/cluepad/cluepad.c | 4 | ||||
| -rw-r--r-- | keyboard/planck/planck.c | 16 | ||||
| -rw-r--r-- | keyboard/preonic/preonic.c | 17 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.c | 6 |
6 files changed, 18 insertions, 33 deletions
diff --git a/keyboard/clueboard1/clueboard1.c b/keyboard/clueboard1/clueboard1.c index 289e4644d..136ddf15b 100644 --- a/keyboard/clueboard1/clueboard1.c +++ b/keyboard/clueboard1/clueboard1.c | |||
| @@ -11,10 +11,6 @@ void matrix_scan_user(void) { | |||
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | void matrix_init_kb(void) { | 13 | void matrix_init_kb(void) { |
| 14 | #ifdef RGBLIGHT_ENABLE | ||
| 15 | rgblight_init(); | ||
| 16 | #endif | ||
| 17 | |||
| 18 | matrix_init_user(); | 14 | matrix_init_user(); |
| 19 | } | 15 | } |
| 20 | 16 | ||
diff --git a/keyboard/clueboard2/clueboard2.c b/keyboard/clueboard2/clueboard2.c index 437f8d1e4..8493c564c 100644 --- a/keyboard/clueboard2/clueboard2.c +++ b/keyboard/clueboard2/clueboard2.c | |||
| @@ -26,10 +26,6 @@ void matrix_init_kb(void) { | |||
| 26 | init_backlight_pin(); | 26 | init_backlight_pin(); |
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | #ifdef RGBLIGHT_ENABLE | ||
| 30 | rgblight_init(); | ||
| 31 | #endif | ||
| 32 | |||
| 33 | // JTAG disable for PORT F. write JTD bit twice within four cycles. | 29 | // JTAG disable for PORT F. write JTD bit twice within four cycles. |
| 34 | MCUCR |= (1<<JTD); | 30 | MCUCR |= (1<<JTD); |
| 35 | MCUCR |= (1<<JTD); | 31 | MCUCR |= (1<<JTD); |
diff --git a/keyboard/cluepad/cluepad.c b/keyboard/cluepad/cluepad.c index d55b99960..a4dbd6fdc 100644 --- a/keyboard/cluepad/cluepad.c +++ b/keyboard/cluepad/cluepad.c | |||
| @@ -21,10 +21,6 @@ void matrix_init_kb(void) { | |||
| 21 | init_backlight_pin(); | 21 | init_backlight_pin(); |
| 22 | #endif | 22 | #endif |
| 23 | 23 | ||
| 24 | #ifdef RGBLIGHT_ENABLE | ||
| 25 | rgblight_init(); | ||
| 26 | #endif | ||
| 27 | |||
| 28 | // JTAG disable for PORT F. write JTD bit twice within four cycles. | 24 | // JTAG disable for PORT F. write JTD bit twice within four cycles. |
| 29 | MCUCR |= (1<<JTD); | 25 | MCUCR |= (1<<JTD); |
| 30 | MCUCR |= (1<<JTD); | 26 | MCUCR |= (1<<JTD); |
diff --git a/keyboard/planck/planck.c b/keyboard/planck/planck.c index da7b3a170..f1a76266e 100644 --- a/keyboard/planck/planck.c +++ b/keyboard/planck/planck.c | |||
| @@ -19,10 +19,6 @@ void matrix_init_kb(void) { | |||
| 19 | backlight_init_ports(); | 19 | backlight_init_ports(); |
| 20 | #endif | 20 | #endif |
| 21 | 21 | ||
| 22 | #ifdef RGBLIGHT_ENABLE | ||
| 23 | rgblight_init(); | ||
| 24 | #endif | ||
| 25 | |||
| 26 | // Turn status LED on | 22 | // Turn status LED on |
| 27 | DDRE |= (1<<6); | 23 | DDRE |= (1<<6); |
| 28 | PORTE |= (1<<6); | 24 | PORTE |= (1<<6); |
| @@ -61,20 +57,20 @@ void backlight_init_ports() | |||
| 61 | // Setup PB7 as output and output low. | 57 | // Setup PB7 as output and output low. |
| 62 | DDRB |= (1<<7); | 58 | DDRB |= (1<<7); |
| 63 | PORTB &= ~(1<<7); | 59 | PORTB &= ~(1<<7); |
| 64 | 60 | ||
| 65 | // Use full 16-bit resolution. | 61 | // Use full 16-bit resolution. |
| 66 | ICR1 = 0xFFFF; | 62 | ICR1 = 0xFFFF; |
| 67 | 63 | ||
| 68 | // I could write a wall of text here to explain... but TL;DW | 64 | // I could write a wall of text here to explain... but TL;DW |
| 69 | // Go read the ATmega32u4 datasheet. | 65 | // Go read the ATmega32u4 datasheet. |
| 70 | // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on | 66 | // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on |
| 71 | 67 | ||
| 72 | // Pin PB7 = OCR1C (Timer 1, Channel C) | 68 | // Pin PB7 = OCR1C (Timer 1, Channel C) |
| 73 | // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 | 69 | // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 |
| 74 | // (i.e. start high, go low when counter matches.) | 70 | // (i.e. start high, go low when counter matches.) |
| 75 | // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 | 71 | // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 |
| 76 | // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 | 72 | // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 |
| 77 | 73 | ||
| 78 | TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010; | 74 | TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010; |
| 79 | TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; | 75 | TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; |
| 80 | 76 | ||
| @@ -100,7 +96,7 @@ void backlight_set(uint8_t level) | |||
| 100 | // Set the brightness | 96 | // Set the brightness |
| 101 | CHANNEL = 0xFFFF; | 97 | CHANNEL = 0xFFFF; |
| 102 | } | 98 | } |
| 103 | else | 99 | else |
| 104 | { | 100 | { |
| 105 | // Turn on PWM control of PB7 | 101 | // Turn on PWM control of PB7 |
| 106 | TCCR1A |= _BV(COM1C1); | 102 | TCCR1A |= _BV(COM1C1); |
| @@ -303,4 +299,4 @@ ISR(TIMER1_COMPA_vect) | |||
| 303 | 299 | ||
| 304 | 300 | ||
| 305 | 301 | ||
| 306 | #endif \ No newline at end of file | 302 | #endif |
diff --git a/keyboard/preonic/preonic.c b/keyboard/preonic/preonic.c index 13e05c65a..773451bf0 100644 --- a/keyboard/preonic/preonic.c +++ b/keyboard/preonic/preonic.c | |||
| @@ -20,11 +20,6 @@ void matrix_init_kb(void) { | |||
| 20 | backlight_init_ports(); | 20 | backlight_init_ports(); |
| 21 | #endif | 21 | #endif |
| 22 | 22 | ||
| 23 | #ifdef RGBLIGHT_ENABLE | ||
| 24 | rgblight_init(); | ||
| 25 | #endif | ||
| 26 | |||
| 27 | |||
| 28 | // Turn status LED on | 23 | // Turn status LED on |
| 29 | DDRE |= (1<<6); | 24 | DDRE |= (1<<6); |
| 30 | PORTE |= (1<<6); | 25 | PORTE |= (1<<6); |
| @@ -49,20 +44,20 @@ void backlight_init_ports() | |||
| 49 | // Setup PB7 as output and output low. | 44 | // Setup PB7 as output and output low. |
| 50 | DDRB |= (1<<7); | 45 | DDRB |= (1<<7); |
| 51 | PORTB &= ~(1<<7); | 46 | PORTB &= ~(1<<7); |
| 52 | 47 | ||
| 53 | // Use full 16-bit resolution. | 48 | // Use full 16-bit resolution. |
| 54 | ICR1 = 0xFFFF; | 49 | ICR1 = 0xFFFF; |
| 55 | 50 | ||
| 56 | // I could write a wall of text here to explain... but TL;DW | 51 | // I could write a wall of text here to explain... but TL;DW |
| 57 | // Go read the ATmega32u4 datasheet. | 52 | // Go read the ATmega32u4 datasheet. |
| 58 | // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on | 53 | // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on |
| 59 | 54 | ||
| 60 | // Pin PB7 = OCR1C (Timer 1, Channel C) | 55 | // Pin PB7 = OCR1C (Timer 1, Channel C) |
| 61 | // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 | 56 | // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 |
| 62 | // (i.e. start high, go low when counter matches.) | 57 | // (i.e. start high, go low when counter matches.) |
| 63 | // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 | 58 | // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 |
| 64 | // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 | 59 | // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 |
| 65 | 60 | ||
| 66 | TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010; | 61 | TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010; |
| 67 | TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; | 62 | TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; |
| 68 | 63 | ||
| @@ -88,7 +83,7 @@ void backlight_set(uint8_t level) | |||
| 88 | // Set the brightness | 83 | // Set the brightness |
| 89 | CHANNEL = 0xFFFF; | 84 | CHANNEL = 0xFFFF; |
| 90 | } | 85 | } |
| 91 | else | 86 | else |
| 92 | { | 87 | { |
| 93 | // Prevent backlight blink on lowest level | 88 | // Prevent backlight blink on lowest level |
| 94 | PORTB &= ~(_BV(PORTB7)); | 89 | PORTB &= ~(_BV(PORTB7)); |
| @@ -99,4 +94,4 @@ void backlight_set(uint8_t level) | |||
| 99 | } | 94 | } |
| 100 | } | 95 | } |
| 101 | 96 | ||
| 102 | #endif \ No newline at end of file | 97 | #endif |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index bd543c45e..34e1ceeca 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -46,6 +46,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 46 | #ifdef ADB_MOUSE_ENABLE | 46 | #ifdef ADB_MOUSE_ENABLE |
| 47 | # include "adb.h" | 47 | # include "adb.h" |
| 48 | #endif | 48 | #endif |
| 49 | #ifdef RGBLIGHT_ENABLE | ||
| 50 | # include "rgblight.h" | ||
| 51 | #endif | ||
| 49 | 52 | ||
| 50 | #ifdef MATRIX_HAS_GHOST | 53 | #ifdef MATRIX_HAS_GHOST |
| 51 | static bool is_row_ghosting(uint8_t row){ | 54 | static bool is_row_ghosting(uint8_t row){ |
| @@ -89,6 +92,9 @@ void keyboard_init(void) { | |||
| 89 | #ifdef BACKLIGHT_ENABLE | 92 | #ifdef BACKLIGHT_ENABLE |
| 90 | backlight_init(); | 93 | backlight_init(); |
| 91 | #endif | 94 | #endif |
| 95 | #ifdef RGBLIGHT_ENABLE | ||
| 96 | rgblight_init(); | ||
| 97 | #endif | ||
| 92 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) | 98 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) |
| 93 | keyboard_nkro = true; | 99 | keyboard_nkro = true; |
| 94 | #endif | 100 | #endif |
