Merge remote-tracking branch 'origin/master' into develop
Resolved Conflicts: keyboards/kc60/rules.mk keyboards/xd96/rules.mk lib/python/qmk/cli/__init__.py
This commit is contained in:
commit
ac3b7d79e0
938 changed files with 35990 additions and 13003 deletions
|
@ -237,7 +237,7 @@
|
|||
#define FR_PERM S(A(FR_LUGR)) // ‰
|
||||
// Row 4
|
||||
#define FR_GTEQ S(A(FR_LABK)) // ≥
|
||||
#define FR_LSAQ S(A(FR_W)) // ›
|
||||
#define FR_RSAQ S(A(FR_W)) // ›
|
||||
#define FR_FRSL S(A(FR_X)) // ⁄
|
||||
#define FR_CENT S(A(FR_C)) // ¢
|
||||
#define FR_SQRT S(A(FR_V)) // √
|
||||
|
|
137
quantum/led.c
Normal file
137
quantum/led.c
Normal file
|
@ -0,0 +1,137 @@
|
|||
/* Copyright 2020 zvecr<git@zvecr.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "quantum.h"
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
# include "backlight.h"
|
||||
extern backlight_config_t backlight_config;
|
||||
#else
|
||||
// Cannot use BACKLIGHT_CAPS_LOCK without backlight being enabled
|
||||
# undef BACKLIGHT_CAPS_LOCK
|
||||
#endif
|
||||
|
||||
#ifndef LED_PIN_ON_STATE
|
||||
# define LED_PIN_ON_STATE 1
|
||||
#endif
|
||||
|
||||
#if defined(BACKLIGHT_CAPS_LOCK)
|
||||
/** \brief Caps Lock indicator using backlight (for keyboards without dedicated LED)
|
||||
*/
|
||||
static void handle_backlight_caps_lock(led_t led_state) {
|
||||
// Use backlight as Caps Lock indicator
|
||||
uint8_t bl_toggle_lvl = 0;
|
||||
|
||||
if (led_state.caps_lock && !backlight_config.enable) {
|
||||
// Turning Caps Lock ON and backlight is disabled in config
|
||||
// Toggling backlight to the brightest level
|
||||
bl_toggle_lvl = BACKLIGHT_LEVELS;
|
||||
} else if (!led_state.caps_lock && backlight_config.enable) {
|
||||
// Turning Caps Lock OFF and backlight is enabled in config
|
||||
// Toggling backlight and restoring config level
|
||||
bl_toggle_lvl = backlight_config.level;
|
||||
}
|
||||
|
||||
// Set level without modify backlight_config to keep ability to restore state
|
||||
backlight_set(bl_toggle_lvl);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** \brief Lock LED set callback - keymap/user level
|
||||
*
|
||||
* \deprecated Use led_update_user() instead.
|
||||
*/
|
||||
__attribute__((weak)) void led_set_user(uint8_t usb_led) {}
|
||||
|
||||
/** \brief Lock LED set callback - keyboard level
|
||||
*
|
||||
* \deprecated Use led_update_kb() instead.
|
||||
*/
|
||||
__attribute__((weak)) void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); }
|
||||
|
||||
/** \brief Lock LED update callback - keymap/user level
|
||||
*
|
||||
* \return True if led_update_kb() should run its own code, false otherwise.
|
||||
*/
|
||||
__attribute__((weak)) bool led_update_user(led_t led_state) { return true; }
|
||||
|
||||
/** \brief Lock LED update callback - keyboard level
|
||||
*
|
||||
* \return Ignored for now.
|
||||
*/
|
||||
__attribute__((weak)) bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if (res) {
|
||||
#if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN)
|
||||
# if LED_PIN_ON_STATE == 0
|
||||
// invert the whole thing to avoid having to conditionally !led_state.x later
|
||||
led_state.raw = ~led_state.raw;
|
||||
# endif
|
||||
|
||||
# ifdef LED_NUM_LOCK_PIN
|
||||
writePin(LED_NUM_LOCK_PIN, led_state.num_lock);
|
||||
# endif
|
||||
# ifdef LED_CAPS_LOCK_PIN
|
||||
writePin(LED_CAPS_LOCK_PIN, led_state.caps_lock);
|
||||
# endif
|
||||
# ifdef LED_SCROLL_LOCK_PIN
|
||||
writePin(LED_SCROLL_LOCK_PIN, led_state.scroll_lock);
|
||||
# endif
|
||||
# ifdef LED_COMPOSE_PIN
|
||||
writePin(LED_COMPOSE_PIN, led_state.compose);
|
||||
# endif
|
||||
# ifdef LED_KANA_PIN
|
||||
writePin(LED_KANA_PIN, led_state.kana);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/** \brief Initialise any LED related hardware and/or state
|
||||
*/
|
||||
__attribute__((weak)) void led_init_ports(void) {
|
||||
#ifdef LED_NUM_LOCK_PIN
|
||||
setPinOutput(LED_NUM_LOCK_PIN);
|
||||
writePin(LED_NUM_LOCK_PIN, !LED_PIN_ON_STATE);
|
||||
#endif
|
||||
#ifdef LED_CAPS_LOCK_PIN
|
||||
setPinOutput(LED_CAPS_LOCK_PIN);
|
||||
writePin(LED_CAPS_LOCK_PIN, !LED_PIN_ON_STATE);
|
||||
#endif
|
||||
#ifdef LED_SCROLL_LOCK_PIN
|
||||
setPinOutput(LED_SCROLL_LOCK_PIN);
|
||||
writePin(LED_SCROLL_LOCK_PIN, !LED_PIN_ON_STATE);
|
||||
#endif
|
||||
#ifdef LED_COMPOSE_PIN
|
||||
setPinOutput(LED_COMPOSE_PIN);
|
||||
writePin(LED_COMPOSE_PIN, !LED_PIN_ON_STATE);
|
||||
#endif
|
||||
#ifdef LED_KANA_PIN
|
||||
setPinOutput(LED_KANA_PIN);
|
||||
writePin(LED_KANA_PIN, !LED_PIN_ON_STATE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** \brief Entrypoint for protocol to LED binding
|
||||
*/
|
||||
__attribute__((weak)) void led_set(uint8_t usb_led) {
|
||||
#ifdef BACKLIGHT_CAPS_LOCK
|
||||
handle_backlight_caps_lock((led_t)usb_led);
|
||||
#endif
|
||||
|
||||
led_set_kb(usb_led);
|
||||
led_update_kb((led_t)usb_led);
|
||||
}
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
# include "backlight.h"
|
||||
extern backlight_config_t backlight_config;
|
||||
#endif
|
||||
|
||||
#ifdef FAUXCLICKY_ENABLE
|
||||
|
@ -605,6 +604,10 @@ void matrix_init_quantum() {
|
|||
if (!eeconfig_is_enabled()) {
|
||||
eeconfig_init();
|
||||
}
|
||||
#if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN)
|
||||
// TODO: remove calls to led_init_ports from keyboards and remove ifdef
|
||||
led_init_ports();
|
||||
#endif
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
# ifdef LED_MATRIX_ENABLE
|
||||
led_matrix_init();
|
||||
|
@ -732,55 +735,6 @@ void api_send_unicode(uint32_t unicode) {
|
|||
#endif
|
||||
}
|
||||
|
||||
/** \brief Lock LED set callback - keymap/user level
|
||||
*
|
||||
* \deprecated Use led_update_user() instead.
|
||||
*/
|
||||
__attribute__((weak)) void led_set_user(uint8_t usb_led) {}
|
||||
|
||||
/** \brief Lock LED set callback - keyboard level
|
||||
*
|
||||
* \deprecated Use led_update_kb() instead.
|
||||
*/
|
||||
__attribute__((weak)) void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); }
|
||||
|
||||
/** \brief Lock LED update callback - keymap/user level
|
||||
*
|
||||
* \return True if led_update_kb() should run its own code, false otherwise.
|
||||
*/
|
||||
__attribute__((weak)) bool led_update_user(led_t led_state) { return true; }
|
||||
|
||||
/** \brief Lock LED update callback - keyboard level
|
||||
*
|
||||
* \return Ignored for now.
|
||||
*/
|
||||
__attribute__((weak)) bool led_update_kb(led_t led_state) { return led_update_user(led_state); }
|
||||
|
||||
__attribute__((weak)) void led_init_ports(void) {}
|
||||
|
||||
__attribute__((weak)) void led_set(uint8_t usb_led) {
|
||||
#if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
|
||||
// Use backlight as Caps Lock indicator
|
||||
uint8_t bl_toggle_lvl = 0;
|
||||
|
||||
if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK) && !backlight_config.enable) {
|
||||
// Turning Caps Lock ON and backlight is disabled in config
|
||||
// Toggling backlight to the brightest level
|
||||
bl_toggle_lvl = BACKLIGHT_LEVELS;
|
||||
} else if (IS_LED_OFF(usb_led, USB_LED_CAPS_LOCK) && backlight_config.enable) {
|
||||
// Turning Caps Lock OFF and backlight is enabled in config
|
||||
// Toggling backlight and restoring config level
|
||||
bl_toggle_lvl = backlight_config.level;
|
||||
}
|
||||
|
||||
// Set level without modify backlight_config to keep ability to restore state
|
||||
backlight_set(bl_toggle_lvl);
|
||||
#endif
|
||||
|
||||
led_set_kb(usb_led);
|
||||
led_update_kb((led_t)usb_led);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Override these functions in your keymap file to play different tunes on
|
||||
// different events such as startup and bootloader jump
|
||||
|
@ -788,5 +742,3 @@ __attribute__((weak)) void led_set(uint8_t usb_led) {
|
|||
__attribute__((weak)) void startup_user() {}
|
||||
|
||||
__attribute__((weak)) void shutdown_user() {}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
@ -34,6 +34,12 @@ static void init(void) {
|
|||
# ifdef DRIVER_ADDR_2
|
||||
IS31FL3731_init(DRIVER_ADDR_2);
|
||||
# endif
|
||||
# ifdef DRIVER_ADDR_3
|
||||
IS31FL3731_init(DRIVER_ADDR_3);
|
||||
# endif
|
||||
# ifdef DRIVER_ADDR_4
|
||||
IS31FL3731_init(DRIVER_ADDR_4);
|
||||
# endif
|
||||
# elif defined(IS31FL3733)
|
||||
IS31FL3733_init(DRIVER_ADDR_1, 0);
|
||||
# elif defined(IS31FL3737)
|
||||
|
@ -60,6 +66,12 @@ static void init(void) {
|
|||
# ifdef DRIVER_ADDR_2
|
||||
IS31FL3731_update_led_control_registers(DRIVER_ADDR_2, 1);
|
||||
# endif
|
||||
# ifdef DRIVER_ADDR_3
|
||||
IS31FL3731_update_led_control_registers(DRIVER_ADDR_3, 2);
|
||||
# endif
|
||||
# ifdef DRIVER_ADDR_4
|
||||
IS31FL3731_update_led_control_registers(DRIVER_ADDR_4, 3);
|
||||
# endif
|
||||
# elif defined(IS31FL3733)
|
||||
IS31FL3733_update_led_control_registers(DRIVER_ADDR_1, 0);
|
||||
IS31FL3733_update_led_control_registers(DRIVER_ADDR_2, 1);
|
||||
|
@ -76,6 +88,12 @@ static void flush(void) {
|
|||
# ifdef DRIVER_ADDR_2
|
||||
IS31FL3731_update_pwm_buffers(DRIVER_ADDR_2, 1);
|
||||
# endif
|
||||
# ifdef DRIVER_ADDR_3
|
||||
IS31FL3731_update_pwm_buffers(DRIVER_ADDR_3, 2);
|
||||
# endif
|
||||
# ifdef DRIVER_ADDR_4
|
||||
IS31FL3731_update_pwm_buffers(DRIVER_ADDR_4, 3);
|
||||
# endif
|
||||
}
|
||||
|
||||
const rgb_matrix_driver_t rgb_matrix_driver = {
|
||||
|
|
|
@ -52,6 +52,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
||||
#define SOFT_SERIAL_PIN D0 // or D1, D2, D3, E6
|
||||
|
||||
//#define LED_NUM_LOCK_PIN B0
|
||||
//#define LED_CAPS_LOCK_PIN B1
|
||||
//#define LED_SCROLL_LOCK_PIN B2
|
||||
//#define LED_COMPOSE_PIN B3
|
||||
//#define LED_KANA_PIN B4
|
||||
|
||||
//#define BACKLIGHT_PIN B7
|
||||
//#define BACKLIGHT_LEVELS 3
|
||||
//#define BACKLIGHT_BREATHING
|
||||
|
|
|
@ -47,8 +47,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
/* COL2ROW, ROW2COL */
|
||||
#define DIODE_DIRECTION COL2ROW
|
||||
|
||||
//#define LED_NUM_LOCK_PIN D0
|
||||
//#define LED_CAPS_LOCK_PIN D1
|
||||
//#define LED_SCROLL_LOCK_PIN D6
|
||||
|
||||
#define BACKLIGHT_PIN D4
|
||||
#define BACKLIGHT_LEVELS 3
|
||||
//#define BACKLIGHT_LEVELS 3
|
||||
//#define BACKLIGHT_BREATHING
|
||||
|
||||
#define RGBLED_NUM 16
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue