diff options
author | Danny <nooges@users.noreply.github.com> | 2018-05-22 15:40:43 -0400 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2018-05-22 12:40:43 -0700 |
commit | 7658f10fba71974bdd6dfc33fbd53deff76b1f83 (patch) | |
tree | aaa3ee07b4507942e67cfa49bf069a3aa50268dc | |
parent | 4b1f60a3f5ed223e34ae8381e57f600551ccf085 (diff) | |
download | qmk_firmware-7658f10fba71974bdd6dfc33fbd53deff76b1f83.tar.gz qmk_firmware-7658f10fba71974bdd6dfc33fbd53deff76b1f83.zip |
Fix led enabled slave (#3022)
* Account for backlight enabled flag when passing backlight level to slave
* Add BL_TOGG to keymap for testing
* Apply backlight fix to Iris
* Port I2C LED backlight control from Iris to Levinson
-rw-r--r-- | keyboards/iris/matrix.c | 11 | ||||
-rw-r--r-- | keyboards/levinson/matrix.c | 25 | ||||
-rw-r--r-- | layouts/community/ortho_4x12/bakingpy/keymap.c | 3 |
3 files changed, 30 insertions, 9 deletions
diff --git a/keyboards/iris/matrix.c b/keyboards/iris/matrix.c index dcfc0216e..7195fb0ea 100644 --- a/keyboards/iris/matrix.c +++ b/keyboards/iris/matrix.c | |||
@@ -30,7 +30,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
30 | #include "pro_micro.h" | 30 | #include "pro_micro.h" |
31 | #include "config.h" | 31 | #include "config.h" |
32 | #include "timer.h" | 32 | #include "timer.h" |
33 | #include "backlight.h" | 33 | |
34 | #ifdef BACKLIGHT_ENABLE | ||
35 | #include "backlight.h" | ||
36 | extern backlight_config_t backlight_config; | ||
37 | #endif | ||
34 | 38 | ||
35 | #ifdef USE_I2C | 39 | #ifdef USE_I2C |
36 | # include "i2c.h" | 40 | # include "i2c.h" |
@@ -86,7 +90,6 @@ static matrix_row_t matrix_debouncing[MATRIX_ROWS]; | |||
86 | static void select_col(uint8_t col); | 90 | static void select_col(uint8_t col); |
87 | #endif | 91 | #endif |
88 | 92 | ||
89 | |||
90 | __attribute__ ((weak)) | 93 | __attribute__ ((weak)) |
91 | void matrix_init_kb(void) { | 94 | void matrix_init_kb(void) { |
92 | matrix_init_user(); | 95 | matrix_init_user(); |
@@ -202,7 +205,7 @@ int i2c_transaction(void) { | |||
202 | 205 | ||
203 | #ifdef BACKLIGHT_ENABLE | 206 | #ifdef BACKLIGHT_ENABLE |
204 | // Write backlight level for slave to read | 207 | // Write backlight level for slave to read |
205 | err = i2c_master_write(get_backlight_level()); | 208 | err = i2c_master_write(backlight_config.enable ? backlight_config.level : 0); |
206 | #else | 209 | #else |
207 | // Write zero, so our byte index is the same | 210 | // Write zero, so our byte index is the same |
208 | err = i2c_master_write(0x00); | 211 | err = i2c_master_write(0x00); |
@@ -244,7 +247,7 @@ int serial_transaction(void) { | |||
244 | 247 | ||
245 | #ifdef BACKLIGHT_ENABLE | 248 | #ifdef BACKLIGHT_ENABLE |
246 | // Write backlight level for slave to read | 249 | // Write backlight level for slave to read |
247 | serial_master_buffer[SERIAL_LED_ADDR] = get_backlight_level(); | 250 | serial_master_buffer[SERIAL_LED_ADDR] = backlight_config.enable ? backlight_config.level : 0; |
248 | #endif | 251 | #endif |
249 | return 0; | 252 | return 0; |
250 | } | 253 | } |
diff --git a/keyboards/levinson/matrix.c b/keyboards/levinson/matrix.c index ed913f34b..7195fb0ea 100644 --- a/keyboards/levinson/matrix.c +++ b/keyboards/levinson/matrix.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | Copyright 2012 Jun Wako <wakojun@gmail.com> | 2 | Copyright 2017 Danny Nguyen <danny@keeb.io> |
3 | 3 | ||
4 | This program is free software: you can redistribute it and/or modify | 4 | This program is free software: you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by | 5 | it under the terms of the GNU General Public License as published by |
@@ -30,7 +30,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
30 | #include "pro_micro.h" | 30 | #include "pro_micro.h" |
31 | #include "config.h" | 31 | #include "config.h" |
32 | #include "timer.h" | 32 | #include "timer.h" |
33 | #include "backlight.h" | 33 | |
34 | #ifdef BACKLIGHT_ENABLE | ||
35 | #include "backlight.h" | ||
36 | extern backlight_config_t backlight_config; | ||
37 | #endif | ||
34 | 38 | ||
35 | #ifdef USE_I2C | 39 | #ifdef USE_I2C |
36 | # include "i2c.h" | 40 | # include "i2c.h" |
@@ -199,6 +203,15 @@ int i2c_transaction(void) { | |||
199 | err = i2c_master_write(0x00); | 203 | err = i2c_master_write(0x00); |
200 | if (err) goto i2c_error; | 204 | if (err) goto i2c_error; |
201 | 205 | ||
206 | #ifdef BACKLIGHT_ENABLE | ||
207 | // Write backlight level for slave to read | ||
208 | err = i2c_master_write(backlight_config.enable ? backlight_config.level : 0); | ||
209 | #else | ||
210 | // Write zero, so our byte index is the same | ||
211 | err = i2c_master_write(0x00); | ||
212 | #endif | ||
213 | if (err) goto i2c_error; | ||
214 | |||
202 | // Start read | 215 | // Start read |
203 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ); | 216 | err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ); |
204 | if (err) goto i2c_error; | 217 | if (err) goto i2c_error; |
@@ -234,7 +247,7 @@ int serial_transaction(void) { | |||
234 | 247 | ||
235 | #ifdef BACKLIGHT_ENABLE | 248 | #ifdef BACKLIGHT_ENABLE |
236 | // Write backlight level for slave to read | 249 | // Write backlight level for slave to read |
237 | serial_master_buffer[SERIAL_LED_ADDR] = get_backlight_level(); | 250 | serial_master_buffer[SERIAL_LED_ADDR] = backlight_config.enable ? backlight_config.level : 0; |
238 | #endif | 251 | #endif |
239 | return 0; | 252 | return 0; |
240 | } | 253 | } |
@@ -276,8 +289,12 @@ void matrix_slave_scan(void) { | |||
276 | int offset = (isLeftHand) ? 0 : ROWS_PER_HAND; | 289 | int offset = (isLeftHand) ? 0 : ROWS_PER_HAND; |
277 | 290 | ||
278 | #ifdef USE_I2C | 291 | #ifdef USE_I2C |
292 | #ifdef BACKLIGHT_ENABLE | ||
293 | // Read backlight level sent from master and update level on slave | ||
294 | backlight_set(i2c_slave_buffer[0]); | ||
295 | #endif | ||
279 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | 296 | for (int i = 0; i < ROWS_PER_HAND; ++i) { |
280 | i2c_slave_buffer[i] = matrix[offset+i]; | 297 | i2c_slave_buffer[i+1] = matrix[offset+i]; |
281 | } | 298 | } |
282 | #else // USE_SERIAL | 299 | #else // USE_SERIAL |
283 | for (int i = 0; i < ROWS_PER_HAND; ++i) { | 300 | for (int i = 0; i < ROWS_PER_HAND; ++i) { |
diff --git a/layouts/community/ortho_4x12/bakingpy/keymap.c b/layouts/community/ortho_4x12/bakingpy/keymap.c index 05ad92fd2..a05f741a7 100644 --- a/layouts/community/ortho_4x12/bakingpy/keymap.c +++ b/layouts/community/ortho_4x12/bakingpy/keymap.c | |||
@@ -34,6 +34,7 @@ enum custom_keycodes { | |||
34 | #define KC_GRVF LT(_FKEYS, KC_GRV) | 34 | #define KC_GRVF LT(_FKEYS, KC_GRV) |
35 | #define KC_ENTS MT(MOD_LSFT, KC_ENT) | 35 | #define KC_ENTS MT(MOD_LSFT, KC_ENT) |
36 | #define KC_BL_S BL_STEP | 36 | #define KC_BL_S BL_STEP |
37 | #define KC_BL_T BL_TOGG | ||
37 | 38 | ||
38 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | 39 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { |
39 | 40 | ||
@@ -81,7 +82,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
81 | //|----+----+----+----+----+----| |----+----+----+----+----+----| | 82 | //|----+----+----+----+----+----| |----+----+----+----+----+----| |
82 | ,CPYP, , ,DOWN,LCBR, RCBR, P1 , P2 , P3 ,MINS, , | 83 | ,CPYP, , ,DOWN,LCBR, RCBR, P1 , P2 , P3 ,MINS, , |
83 | //|----+----+----+----+----+----| |----+----+----+----+----+----| | 84 | //|----+----+----+----+----+----| |----+----+----+----+----+----| |
84 | BL_S, , , , ,DEL , DEL , , P0 ,PDOT, , | 85 | BL_S,BL_T, , , ,DEL , DEL , , P0 ,PDOT, , |
85 | //`----+----+----+----+----+----' `----+----+----+----+----+----' | 86 | //`----+----+----+----+----+----' `----+----+----+----+----+----' |
86 | ), | 87 | ), |
87 | 88 | ||