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 dcfc0216ea..7195fb0ead 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/>. #include "pro_micro.h" #include "config.h" #include "timer.h" -#include "backlight.h" + +#ifdef BACKLIGHT_ENABLE + #include "backlight.h" + extern backlight_config_t backlight_config; +#endif #ifdef USE_I2C # include "i2c.h" @@ -86,7 +90,6 @@ static matrix_row_t matrix_debouncing[MATRIX_ROWS]; static void select_col(uint8_t col); #endif - __attribute__ ((weak)) void matrix_init_kb(void) { matrix_init_user(); @@ -202,7 +205,7 @@ int i2c_transaction(void) { #ifdef BACKLIGHT_ENABLE // Write backlight level for slave to read - err = i2c_master_write(get_backlight_level()); + err = i2c_master_write(backlight_config.enable ? backlight_config.level : 0); #else // Write zero, so our byte index is the same err = i2c_master_write(0x00); @@ -244,7 +247,7 @@ int serial_transaction(void) { #ifdef BACKLIGHT_ENABLE // Write backlight level for slave to read - serial_master_buffer[SERIAL_LED_ADDR] = get_backlight_level(); + serial_master_buffer[SERIAL_LED_ADDR] = backlight_config.enable ? backlight_config.level : 0; #endif return 0; } diff --git a/keyboards/levinson/matrix.c b/keyboards/levinson/matrix.c index ed913f34b4..7195fb0ead 100644 --- a/keyboards/levinson/matrix.c +++ b/keyboards/levinson/matrix.c @@ -1,5 +1,5 @@ /* -Copyright 2012 Jun Wako <wakojun@gmail.com> +Copyright 2017 Danny Nguyen <danny@keeb.io> 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 @@ -30,7 +30,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "pro_micro.h" #include "config.h" #include "timer.h" -#include "backlight.h" + +#ifdef BACKLIGHT_ENABLE + #include "backlight.h" + extern backlight_config_t backlight_config; +#endif #ifdef USE_I2C # include "i2c.h" @@ -199,6 +203,15 @@ int i2c_transaction(void) { err = i2c_master_write(0x00); if (err) goto i2c_error; +#ifdef BACKLIGHT_ENABLE + // Write backlight level for slave to read + err = i2c_master_write(backlight_config.enable ? backlight_config.level : 0); +#else + // Write zero, so our byte index is the same + err = i2c_master_write(0x00); +#endif + if (err) goto i2c_error; + // Start read err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ); if (err) goto i2c_error; @@ -234,7 +247,7 @@ int serial_transaction(void) { #ifdef BACKLIGHT_ENABLE // Write backlight level for slave to read - serial_master_buffer[SERIAL_LED_ADDR] = get_backlight_level(); + serial_master_buffer[SERIAL_LED_ADDR] = backlight_config.enable ? backlight_config.level : 0; #endif return 0; } @@ -276,8 +289,12 @@ void matrix_slave_scan(void) { int offset = (isLeftHand) ? 0 : ROWS_PER_HAND; #ifdef USE_I2C +#ifdef BACKLIGHT_ENABLE + // Read backlight level sent from master and update level on slave + backlight_set(i2c_slave_buffer[0]); +#endif for (int i = 0; i < ROWS_PER_HAND; ++i) { - i2c_slave_buffer[i] = matrix[offset+i]; + i2c_slave_buffer[i+1] = matrix[offset+i]; } #else // USE_SERIAL 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 05ad92fd2d..a05f741a72 100644 --- a/layouts/community/ortho_4x12/bakingpy/keymap.c +++ b/layouts/community/ortho_4x12/bakingpy/keymap.c @@ -34,6 +34,7 @@ enum custom_keycodes { #define KC_GRVF LT(_FKEYS, KC_GRV) #define KC_ENTS MT(MOD_LSFT, KC_ENT) #define KC_BL_S BL_STEP +#define KC_BL_T BL_TOGG const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -81,7 +82,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { //|----+----+----+----+----+----| |----+----+----+----+----+----| ,CPYP, , ,DOWN,LCBR, RCBR, P1 , P2 , P3 ,MINS, , //|----+----+----+----+----+----| |----+----+----+----+----+----| - BL_S, , , , ,DEL , DEL , , P0 ,PDOT, , + BL_S,BL_T, , , ,DEL , DEL , , P0 ,PDOT, , //`----+----+----+----+----+----' `----+----+----+----+----+----' ), |