From 4931510ad38aadb1769c9241bfad0c3d77ad687f Mon Sep 17 00:00:00 2001 From: Balz Guenat Date: Mon, 1 Jan 2018 23:47:51 +0100 Subject: backlight breathing overhaul (#2187) * add breathing to bananasplit * backlight breathing overhaul * fix the backlight_tick thing. * fix for vision_division backlight * fix a few keymaps and probably break breathing for some weirdly set-up boards. * remove BL_x keycodes because they made unreasonable assumptions * some fixes for BL keycodes * integer cie lightness scaling * use cie lightness for non-breathing backlight and make breathing able to reach true max brightness --- keyboards/atomic/keymaps/pvc/keymap.c | 12 ++++++------ keyboards/bananasplit/config.h | 2 +- keyboards/bananasplit/keymaps/coloneljesus/config.h | 2 ++ keyboards/bananasplit/keymaps/coloneljesus/keymap.c | 16 ++++++++-------- keyboards/jd45/keymaps/mjt/keymap.c | 8 ++++---- keyboards/planck/keymaps/cbbrowne/keymap.c | 4 ++-- keyboards/planck/keymaps/experimental/keymap.c | 4 ++-- keyboards/planck/keymaps/khord/keymap.c | 4 ++-- keyboards/planck/keymaps/pvc/keymap.c | 12 ++++++------ keyboards/planck/keymaps/zach/zach_common_functions.c | 2 +- keyboards/planck/keymaps/zrichard/keymap.c | 12 ++++++------ keyboards/preonic/keymaps/zach/zach_common_functions.c | 2 +- keyboards/vision_division/keymaps/default/keymap.c | 14 +++++++------- keyboards/xd75/keymaps/cbbrowne/keymap.c | 4 ++-- 14 files changed, 50 insertions(+), 48 deletions(-) (limited to 'keyboards') diff --git a/keyboards/atomic/keymaps/pvc/keymap.c b/keyboards/atomic/keymaps/pvc/keymap.c index 4a7cc863e..2e78e64b1 100644 --- a/keyboards/atomic/keymaps/pvc/keymap.c +++ b/keyboards/atomic/keymaps/pvc/keymap.c @@ -345,14 +345,14 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case MACRO_BREATH_SPEED_INC: if (record->event.pressed) { - breathing_speed_inc(1); + breathing_period_inc(); } break; case MACRO_BREATH_SPEED_DEC: if (record->event.pressed) { - breathing_speed_dec(1); + breathing_period_dec(); } break; @@ -374,7 +374,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { layer_on(LAYER_UPPER); - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } @@ -389,7 +389,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { layer_on(LAYER_LOWER); - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } @@ -403,13 +403,13 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case MACRO_FUNCTION: if (record->event.pressed) { - breathing_speed_set(3); + breathing_period_set(3); breathing_enable(); layer_on(LAYER_FUNCTION); } else { - breathing_speed_set(1); + breathing_period_set(1); breathing_self_disable(); layer_off(LAYER_FUNCTION); } diff --git a/keyboards/bananasplit/config.h b/keyboards/bananasplit/config.h index 4bb5b85e0..5649ab4aa 100644 --- a/keyboards/bananasplit/config.h +++ b/keyboards/bananasplit/config.h @@ -42,7 +42,7 @@ along with this program. If not, see . //#define MATRIX_HAS_GHOST /* number of backlight levels */ -#define BACKLIGHT_LEVELS 1 +#define BACKLIGHT_LEVELS 3 /* mapping backlight LEDs to correct Pin */ #define BACKLIGHT_PIN B7 diff --git a/keyboards/bananasplit/keymaps/coloneljesus/config.h b/keyboards/bananasplit/keymaps/coloneljesus/config.h index 5f2cd13fe..92a67f647 100644 --- a/keyboards/bananasplit/keymaps/coloneljesus/config.h +++ b/keyboards/bananasplit/keymaps/coloneljesus/config.h @@ -21,5 +21,7 @@ // place overrides here #define GRAVE_ESC_CTRL_OVERRIDE +#define BACKLIGHT_BREATHING +#define BREATHING_PERIOD 8 #endif diff --git a/keyboards/bananasplit/keymaps/coloneljesus/keymap.c b/keyboards/bananasplit/keymaps/coloneljesus/keymap.c index ac7f1113a..b5889aa19 100644 --- a/keyboards/bananasplit/keymaps/coloneljesus/keymap.c +++ b/keyboards/bananasplit/keymaps/coloneljesus/keymap.c @@ -16,7 +16,7 @@ #include "bananasplit.h" enum custom_keycodes { - WIN_SWITCH_LAYOUT = SAFE_RANGE + WIN_SWITCH_LAYOUT = SAFE_RANGE, }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -57,7 +57,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, \ KC_CAPS, KC_MPRV, KC_VOLU, KC_MNXT, KC_PGUP, KC_INS, KC_HOME, LCTL(KC_LEFT), LCTL(KC_RGHT), KC_END, _______, _______, _______, KC_PSCR, \ _______, KC_MUTE, KC_VOLD, KC_MPLY, KC_PGDN, KC_DEL, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, _______, \ - _______, _______, _______, _______, _______,_______, LCTL(KC_BSPC), LCTL(KC_DEL), _______, _______, _______, _______, _______, \ + _______, BL_STEP, BL_BRTG, _______, _______,_______, LCTL(KC_BSPC), LCTL(KC_DEL), _______, _______, _______, _______, _______, \ _______, _______, _______, _______, _______,_______, _______, _______, _______, _______, RESET \ ), }; @@ -76,19 +76,19 @@ void matrix_scan_user(void) { bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { + case WIN_SWITCH_LAYOUT: { // Sends Alt+Shift on both key down and key up. // Designed to switch between two keyboard layouts on Windows using a locking switch. // Does nothing if right shift is pressed for easy resync. - if (!(get_mods() & MOD_BIT(KC_RSFT))) { + if (!(get_mods() & MOD_BIT(KC_RSFT))) SEND_STRING(SS_DOWN(X_LALT)SS_TAP(X_LSHIFT)SS_UP(X_LALT)); - return false; - } - else - return false; + return false; } + + default: + return true; } - return true; } void led_set_user(uint8_t usb_led) { diff --git a/keyboards/jd45/keymaps/mjt/keymap.c b/keyboards/jd45/keymaps/mjt/keymap.c index 1a7302216..610552ecf 100644 --- a/keyboards/jd45/keymaps/mjt/keymap.c +++ b/keyboards/jd45/keymaps/mjt/keymap.c @@ -50,13 +50,13 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) // action_function_tap may also handle this... if (record->event.pressed) { - breathing_speed_set(3); + breathing_period_set(3); breathing_enable(); layer_on(1); } else { - breathing_speed_set(1); + breathing_period_set(1); breathing_self_disable(); layer_off(1); } @@ -64,13 +64,13 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case M_LAYER2: if (record->event.pressed) { - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); layer_on(2); } else { - breathing_speed_set(1); + breathing_period_set(1); breathing_self_disable(); layer_off(2); } diff --git a/keyboards/planck/keymaps/cbbrowne/keymap.c b/keyboards/planck/keymaps/cbbrowne/keymap.c index d1214dda1..9bae6fb50 100644 --- a/keyboards/planck/keymaps/cbbrowne/keymap.c +++ b/keyboards/planck/keymaps/cbbrowne/keymap.c @@ -220,7 +220,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { layer_on(_RAISE); #ifdef BACKLIGHT_ENABLE - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); #endif update_tri_layer(_LOWER, _RAISE, _ADJUST); @@ -236,7 +236,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { layer_on(_LOWER); #ifdef BACKLIGHT_ENABLE - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); #endif update_tri_layer(_LOWER, _RAISE, _ADJUST); diff --git a/keyboards/planck/keymaps/experimental/keymap.c b/keyboards/planck/keymaps/experimental/keymap.c index 272c09332..feeb137fa 100644 --- a/keyboards/planck/keymaps/experimental/keymap.c +++ b/keyboards/planck/keymaps/experimental/keymap.c @@ -242,7 +242,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { layer_on(_LOWER); #ifdef BACKLIGHT_ENABLE - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); #endif update_tri_layer(_LOWER, _RAISE, _ADJUST); @@ -256,7 +256,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { layer_on(_RAISE); #ifdef BACKLIGHT_ENABLE - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); #endif update_tri_layer(_LOWER, _RAISE, _ADJUST); diff --git a/keyboards/planck/keymaps/khord/keymap.c b/keyboards/planck/keymaps/khord/keymap.c index c8022a389..c515a0d36 100644 --- a/keyboards/planck/keymaps/khord/keymap.c +++ b/keyboards/planck/keymaps/khord/keymap.c @@ -128,12 +128,12 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { break; case MACRO_BREATH_SPEED_INC: if (record->event.pressed) { - breathing_speed_inc(1); + breathing_period_inc(); } break; case MACRO_BREATH_SPEED_DEC: if (record->event.pressed) { - breathing_speed_dec(1); + breathing_period_dec(); } break; case MACRO_BREATH_DEFAULT: diff --git a/keyboards/planck/keymaps/pvc/keymap.c b/keyboards/planck/keymaps/pvc/keymap.c index 60f6d925a..820018af6 100644 --- a/keyboards/planck/keymaps/pvc/keymap.c +++ b/keyboards/planck/keymaps/pvc/keymap.c @@ -323,14 +323,14 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case MACRO_BREATH_SPEED_INC: if (record->event.pressed) { - breathing_speed_inc(1); + breathing_period_inc(); } break; case MACRO_BREATH_SPEED_DEC: if (record->event.pressed) { - breathing_speed_dec(1); + breathing_period_dec(); } break; @@ -352,7 +352,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { layer_on(LAYER_UPPER); - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } @@ -367,7 +367,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { layer_on(LAYER_LOWER); - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } @@ -381,13 +381,13 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case MACRO_FUNCTION: if (record->event.pressed) { - breathing_speed_set(3); + breathing_period_set(3); breathing_enable(); layer_on(LAYER_FUNCTION); } else { - breathing_speed_set(1); + breathing_period_set(1); breathing_self_disable(); layer_off(LAYER_FUNCTION); } diff --git a/keyboards/planck/keymaps/zach/zach_common_functions.c b/keyboards/planck/keymaps/zach/zach_common_functions.c index f824b4033..e6aeaa50a 100644 --- a/keyboards/planck/keymaps/zach/zach_common_functions.c +++ b/keyboards/planck/keymaps/zach/zach_common_functions.c @@ -270,7 +270,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { PLAY_SONG(tone_ctrl_mod); #endif #ifdef BACKLIGHT_BREATHING - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); #endif } diff --git a/keyboards/planck/keymaps/zrichard/keymap.c b/keyboards/planck/keymaps/zrichard/keymap.c index c40492f5e..cf4478cee 100755 --- a/keyboards/planck/keymaps/zrichard/keymap.c +++ b/keyboards/planck/keymaps/zrichard/keymap.c @@ -332,14 +332,14 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case MACRO_BREATH_SPEED_INC: if (record->event.pressed) { - breathing_speed_inc(1); + breathing_period_inc(); } break; case MACRO_BREATH_SPEED_DEC: if (record->event.pressed) { - breathing_speed_dec(1); + breathing_period_dec(); } break; @@ -361,7 +361,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { layer_on(LAYER_UPPER); - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } @@ -376,7 +376,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { layer_on(LAYER_LOWER); - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } @@ -390,13 +390,13 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case MACRO_FUNCTION: if (record->event.pressed) { - breathing_speed_set(3); + breathing_period_set(3); breathing_enable(); layer_on(LAYER_FUNCTION); } else { - breathing_speed_set(1); + breathing_period_set(1); breathing_self_disable(); layer_off(LAYER_FUNCTION); } diff --git a/keyboards/preonic/keymaps/zach/zach_common_functions.c b/keyboards/preonic/keymaps/zach/zach_common_functions.c index f824b4033..e6aeaa50a 100644 --- a/keyboards/preonic/keymaps/zach/zach_common_functions.c +++ b/keyboards/preonic/keymaps/zach/zach_common_functions.c @@ -270,7 +270,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { PLAY_SONG(tone_ctrl_mod); #endif #ifdef BACKLIGHT_BREATHING - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); #endif } diff --git a/keyboards/vision_division/keymaps/default/keymap.c b/keyboards/vision_division/keymaps/default/keymap.c index c40bf1ef6..31b107661 100644 --- a/keyboards/vision_division/keymaps/default/keymap.c +++ b/keyboards/vision_division/keymaps/default/keymap.c @@ -406,21 +406,21 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case MACRO_BREATH_SPEED_INC: if (record->event.pressed) { - breathing_speed_inc(1); + breathing_period_inc(); } break; case MACRO_BREATH_SPEED_DEC: if (record->event.pressed) { - breathing_speed_dec(1); + breathing_period_dec(); } break; case MACRO_BREATH_DEFAULT: if (record->event.pressed) { - breathing_defaults(); + breathing_period_default(); } break; @@ -435,7 +435,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { layer_on(LAYER_UPPER); - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } @@ -450,7 +450,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { layer_on(LAYER_LOWER); - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } @@ -464,13 +464,13 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) case MACRO_FUNCTION: if (record->event.pressed) { - breathing_speed_set(3); + breathing_period_set(3); breathing_enable(); layer_on(LAYER_FUNCTION); } else { - breathing_speed_set(1); + breathing_period_set(1); breathing_self_disable(); layer_off(LAYER_FUNCTION); } diff --git a/keyboards/xd75/keymaps/cbbrowne/keymap.c b/keyboards/xd75/keymaps/cbbrowne/keymap.c index 5496ed40d..ec98b6d5a 100644 --- a/keyboards/xd75/keymaps/cbbrowne/keymap.c +++ b/keyboards/xd75/keymaps/cbbrowne/keymap.c @@ -265,7 +265,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { layer_on(_RAISE); #ifdef BACKLIGHT_ENABLE - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); #endif update_tri_layer(_LOWER, _RAISE, _ADJUST); @@ -281,7 +281,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { layer_on(_LOWER); #ifdef BACKLIGHT_ENABLE - breathing_speed_set(2); + breathing_period_set(2); breathing_pulse(); #endif update_tri_layer(_LOWER, _RAISE, _ADJUST); -- cgit v1.2.3