Add init function to RGBLight driver struct (#23076)

This commit is contained in:
Ryan 2024-03-18 22:03:27 +11:00 committed by GitHub
parent 23b7a02ebe
commit f7cf40fa77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
42 changed files with 306 additions and 93 deletions

View File

@ -67,7 +67,9 @@ static void apa102_send_byte(uint8_t byte) {
}
static void apa102_start_frame(void) {
apa102_init();
gpio_write_pin_low(APA102_DI_PIN);
gpio_write_pin_low(APA102_CI_PIN);
for (uint16_t i = 0; i < 4; i++) {
apa102_send_byte(0);
}
@ -103,7 +105,8 @@ static void apa102_end_frame(uint16_t num_leds) {
apa102_send_byte(0);
}
apa102_init();
gpio_write_pin_low(APA102_DI_PIN);
gpio_write_pin_low(APA102_CI_PIN);
}
static void apa102_send_frame(uint8_t red, uint8_t green, uint8_t blue, uint8_t brightness) {
@ -116,9 +119,6 @@ static void apa102_send_frame(uint8_t red, uint8_t green, uint8_t blue, uint8_t
void apa102_init(void) {
gpio_set_pin_output(APA102_DI_PIN);
gpio_set_pin_output(APA102_CI_PIN);
gpio_write_pin_low(APA102_DI_PIN);
gpio_write_pin_low(APA102_CI_PIN);
}
void apa102_setleds(rgb_led_t *start_led, uint16_t num_leds) {

View File

@ -62,6 +62,8 @@
# define WS2812_LED_COUNT RGB_MATRIX_LED_COUNT
#endif
void ws2812_init(void);
/* User Interface
*
* Input:

View File

@ -21,5 +21,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
void keyboard_post_init_user(void) {
rgblite_init();
rgblite_increase_hue();
}

View File

@ -6,6 +6,10 @@
#include "ws2812.h"
#include "color.h"
static inline void rgblite_init(void) {
ws2812_init();
}
static inline void rgblite_setrgb(RGB rgb) {
rgb_led_t leds[RGBLIGHT_LED_COUNT] = {{.r = rgb.r, .g = rgb.g, .b = rgb.b}};
ws2812_setleds(leds, RGBLIGHT_LED_COUNT);

View File

@ -0,0 +1,200 @@
#include QMK_KEYBOARD_H
#include "version.h"
enum layers {
BASE, // default layer
SYMB, // symbols
MDIA, // media keys
};
enum custom_keycodes {
VRSN = SAFE_RANGE,
};
// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Basic layer
*
* ,--------------------------------------------------. ,--------------------------------------------------.
* | = | 1 | 2 | 3 | 4 | 5 | LEFT | | RIGHT| 6 | 7 | 8 | 9 | 0 | - |
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
* | Del | Q | W | E | R | T | L1 | | L1 | Y | U | I | O | P | \ |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | BkSp | A | S | D | F | G |------| |------| H | J | K | L |; / L2|' / Cmd |
* |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------|
* | LShift |Z/Ctrl| X | C | V | B | | | | N | M | , | . |//Ctrl| RShift |
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
* |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | App | LGui | | Alt |Ctrl/Esc|
* ,------|------|------| |------+--------+------.
* | | | Home | | PgUp | | |
* | Space|Backsp|------| |------| Tab |Enter |
* | |ace | End | | PgDn | | |
* `--------------------' `----------------------'
*/
[BASE] = LAYOUT_ergodox_pretty(
// left hand
KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
KC_DEL, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB), TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN), GUI_T(KC_QUOT),
KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO), MEH_T(KC_NO), KC_N, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLSH), KC_RSFT,
LT(SYMB,KC_GRV), KC_QUOT, LALT(KC_LSFT), KC_LEFT, KC_RGHT, KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, TT(SYMB),
ALT_T(KC_APP), KC_LGUI, KC_LALT, CTL_T(KC_ESC),
KC_HOME, KC_PGUP,
KC_SPC, KC_BSPC, KC_END, KC_PGDN, KC_TAB, KC_ENT
),
/* Keymap 1: Symbol Layer
*
* ,---------------------------------------------------. ,--------------------------------------------------.
* |Version | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 |
* |---------+------+------+------+------+------+------| |------+------+------+------+------+------+--------|
* | | ! | @ | { | } | | | | | | Up | 7 | 8 | 9 | * | F12 |
* |---------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | # | $ | ( | ) | ` |------| |------| Down | 4 | 5 | 6 | + | |
* |---------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | \ | |
* `---------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
* | EPRM | | | | | | | . | 0 | = | |
* `-----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* |Animat| | |Toggle|Solid |
* ,------|------|------| |------+------+------.
* |Bright|Bright| | | |Hue- |Hue+ |
* |ness- |ness+ |------| |------| | |
* | | | | | | | |
* `--------------------' `--------------------'
*/
[SYMB] = LAYOUT_ergodox_pretty(
// left hand
VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
KC_TRNS, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, KC_TRNS, KC_TRNS, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12,
KC_TRNS, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS,
KC_TRNS, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS,
EE_CLR, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_DOT, KC_0, KC_EQL, KC_TRNS,
RGB_MOD, KC_TRNS, RGB_TOG, RGB_M_P,
KC_TRNS, KC_TRNS,
RGB_VAD, RGB_VAI, KC_TRNS, KC_TRNS, RGB_HUD, RGB_HUI
),
/* Keymap 2: Media and mouse keys
*
* ,--------------------------------------------------. ,--------------------------------------------------.
* | | | | | | | | | | | | | | | |
* |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
* | | | | MsUp | | | | | | | | | | | |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play |
* |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
* | | | | | | | | | | | | Prev | Next | | |
* `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
* | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | |
* `----------------------------------' `----------------------------------'
* ,-------------. ,-------------.
* | | | | | |
* ,------|------|------| |------+------+------.
* | | | | | | |Brwser|
* | | |------| |------| |Back |
* | | | | | | | |
* `--------------------' `--------------------'
*/
[MDIA] = LAYOUT_ergodox_pretty(
// left hand
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_WBAK
),
};
// clang-format on
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
case VRSN:
SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
return false;
}
}
return true;
}
// Runs just one time when the keyboard initializes.
void keyboard_post_init_user(void) {
#ifdef RGBLIGHT_COLOR_LAYER_0
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0);
#endif
};
// Runs whenever there is a layer state change.
layer_state_t layer_state_set_user(layer_state_t state) {
ergodox_board_led_off();
ergodox_right_led_1_off();
ergodox_right_led_2_off();
ergodox_right_led_3_off();
uint8_t layer = get_highest_layer(state);
switch (layer) {
case 0:
#ifdef RGBLIGHT_COLOR_LAYER_0
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0);
#endif
break;
case 1:
ergodox_right_led_1_on();
#ifdef RGBLIGHT_COLOR_LAYER_1
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_1);
#endif
break;
case 2:
ergodox_right_led_2_on();
#ifdef RGBLIGHT_COLOR_LAYER_2
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_2);
#endif
break;
case 3:
ergodox_right_led_3_on();
#ifdef RGBLIGHT_COLOR_LAYER_3
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_3);
#endif
break;
case 4:
ergodox_right_led_1_on();
ergodox_right_led_2_on();
#ifdef RGBLIGHT_COLOR_LAYER_4
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_4);
#endif
break;
case 5:
ergodox_right_led_1_on();
ergodox_right_led_3_on();
#ifdef RGBLIGHT_COLOR_LAYER_5
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_5);
#endif
break;
case 6:
ergodox_right_led_2_on();
ergodox_right_led_3_on();
#ifdef RGBLIGHT_COLOR_LAYER_6
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_6);
#endif
break;
case 7:
ergodox_right_led_1_on();
ergodox_right_led_2_on();
ergodox_right_led_3_on();
#ifdef RGBLIGHT_COLOR_LAYER_7
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_7);
#endif
break;
default:
break;
}
return state;
};

View File

@ -0,0 +1,2 @@
RGBLIGHT_ENABLE = no
RGB_MATRIX_ENABLE = yes

View File

@ -1 +0,0 @@
// Placeholder. See ../default/keymap.c for details

View File

@ -1,4 +0,0 @@
RGBLIGHT_ENABLE = no
RGB_MATRIX_ENABLE = yes # enable later
SRC += keymaps/default/keymap.c

View File

@ -151,6 +151,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),
};
#ifdef RGBLIGHT_ENABLE
void eeconfig_init_user(void) {
rgblight_enable();
rgblight_sethsv(HSV_CYAN);
@ -158,7 +159,7 @@ void eeconfig_init_user(void) {
user_config.rgb_layer_change = true;
eeconfig_update_user(user_config.raw);
}
#endif
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
@ -168,21 +169,17 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
eeconfig_init();
}
return false;
break;
case VRSN:
if (record->event.pressed) {
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
}
return false;
break;
#ifdef RGBLIGHT_ENABLE
case RGB_SLD:
if (record->event.pressed) {
#ifdef RGBLIGHT_ENABLE
rgblight_mode(1);
#endif
}
return false;
break;
case RGB_LYR: // This allows me to use underglow as layer indication, or as normal
if (record->event.pressed) {
user_config.rgb_layer_change ^= 1; // Toggles the status
@ -191,7 +188,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
layer_state_set(layer_state); // then immediately update the layer color
}
}
return false; break;
return false;
case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // For any of the RGB codes (see quantum_keycodes.h, L400 for reference)
if (record->event.pressed) { //This disables layer indication, as it's assumed that if you're changing this ... you want that disabled
if (user_config.rgb_layer_change) { // only if this is enabled
@ -199,11 +196,13 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
eeconfig_update_user(user_config.raw); // write the setings to EEPROM
}
}
return true; break;
return true;
#endif
}
return true;
}
#ifdef RGBLIGHT_ENABLE
void matrix_init_user(void) {
// Call the keymap level matrix init.
@ -217,11 +216,7 @@ void matrix_init_user(void) {
rgblight_mode_noeeprom(1);
}
}
// Runs constantly in the background, in a loop.
void matrix_scan_user(void) {
};
#endif
layer_state_t layer_state_set_user(layer_state_t state) {
ergodox_board_led_off();
@ -231,39 +226,55 @@ layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case SYMB:
ergodox_right_led_1_on();
#ifdef RGBLIGHT_ENABLE
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_RED); rgblight_mode_noeeprom(1); }
#endif
break;
case MDIA:
ergodox_right_led_2_on();
#ifdef RGBLIGHT_ENABLE
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_GREEN); rgblight_mode_noeeprom(1); }
#endif
break;
case 3:
ergodox_right_led_3_on();
#ifdef RGBLIGHT_ENABLE
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_BLUE); rgblight_mode_noeeprom(1); }
#endif
break;
case 4:
ergodox_right_led_1_on();
ergodox_right_led_2_on();
#ifdef RGBLIGHT_ENABLE
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_ORANGE); rgblight_mode_noeeprom(1); }
#endif
break;
case 5:
ergodox_right_led_1_on();
ergodox_right_led_3_on();
#ifdef RGBLIGHT_ENABLE
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_YELLOW); rgblight_mode_noeeprom(1); }
#endif
break;
case 6:
ergodox_right_led_2_on();
ergodox_right_led_3_on();
#ifdef RGBLIGHT_ENABLE
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_PINK); rgblight_mode_noeeprom(1); }
#endif
break;
case 7:
ergodox_right_led_1_on();
ergodox_right_led_2_on();
ergodox_right_led_3_on();
#ifdef RGBLIGHT_ENABLE
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_WHITE); rgblight_mode_noeeprom(1); }
#endif
break;
default: // for any other layers, or the default layer
#ifdef RGBLIGHT_ENABLE
if (user_config.rgb_layer_change) { rgblight_sethsv_noeeprom(HSV_CYAN); rgblight_mode_noeeprom(1); }
#endif
break;
}
return state;

View File

@ -29,7 +29,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
void matrix_init_user(void) {
#ifdef RGBLIGHT_COLOR_LAYER_0
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_0)
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0);
#endif
};
@ -42,19 +42,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
eeconfig_init();
}
return false;
break;
case VRSN:
if (record->event.pressed) {
SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
}
return false;
break;
#ifdef RGBLIGHT_ENABLE
case RGB_SLD:
if (record->event.pressed) {
rgblight_mode(1);
}
return false;
break;
#endif
}
return true;
@ -70,48 +69,50 @@ layer_state_t layer_state_set_user(layer_state_t state) {
ergodox_right_led_3_off();
switch (layer) {
case 0:
#ifdef RGBLIGHT_COLOR_LAYER_0
#ifdef RGBLIGHT_ENABLE
#ifdef RGBLIGHT_COLOR_LAYER_0
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_0);
#else
#else
rgblight_init();
#endif
#endif
break;
case 1:
ergodox_right_led_1_on();
#ifdef RGBLIGHT_COLOR_LAYER_1
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_1)
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_1);
#endif
break;
case 2:
ergodox_right_led_2_on();
#ifdef RGBLIGHT_COLOR_LAYER_2
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_2)
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_2);
#endif
break;
case 3:
ergodox_right_led_3_on();
#ifdef RGBLIGHT_COLOR_LAYER_3
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_3)
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_3);
#endif
break;
case 4:
ergodox_right_led_1_on();
ergodox_right_led_2_on();
#ifdef RGBLIGHT_COLOR_LAYER_4
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_4)
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_4);
#endif
break;
case 5:
ergodox_right_led_1_on();
ergodox_right_led_3_on();
#ifdef RGBLIGHT_COLOR_LAYER_5
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_5)
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_5);
#endif
break;
case 6:
ergodox_right_led_2_on();
ergodox_right_led_3_on();
#ifdef RGBLIGHT_COLOR_LAYER_6
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_6)
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_6);
#endif
break;
@ -119,7 +120,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
ergodox_right_led_1_on();
ergodox_right_led_2_on();
ergodox_right_led_3_on();
#ifdef RGBLIGHT_COLOR_LAYER_7
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_COLOR_LAYER_7)
rgblight_setrgb(RGBLIGHT_COLOR_LAYER_6);
#endif
break;

View File

@ -19,8 +19,7 @@ SWAP_HANDS_ENABLE= no # Allow swapping hands of keyboard
RGB_MATRIX_ENABLE = no # enable later
# project specific files
SRC += matrix.c \
led_i2c.c
SRC += matrix.c
I2C_DRIVER_REQUIRED = yes
# Disable unsupported hardware

View File

@ -18,10 +18,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef RGBLIGHT_ENABLE
# include "ergodox_ez.h"
# include "ws2812.h"
#include "ergodox_ez.h"
#include "ws2812.h"
void setleds_custom(rgb_led_t *led, uint16_t led_num) {
uint16_t length = 0;
@ -64,7 +62,6 @@ void setleds_custom(rgb_led_t *led, uint16_t led_num) {
}
const rgblight_driver_t rgblight_driver = {
.init = ws2812_init,
.setleds = setleds_custom,
};
#endif // RGBLIGHT_ENABLE

View File

@ -1,2 +1,3 @@
RGBLIGHT_ENABLE = yes
WS2812_DRIVER_REQUIRED = yes
SRC += rgblight_custom.c

View File

@ -1,8 +1,15 @@
#include "keyboard.h"
#include "ws2812.h"
#include "rgbsps.h"
rgb_led_t led[RGBSPS_NUM];
void keyboard_pre_init_kb(void) {
ws2812_init();
keyboard_pre_init_user();
}
void rgbsps_set(uint8_t index, uint8_t r, uint8_t g, uint8_t b) {
led[index].r = r;
led[index].g = g;

View File

@ -90,6 +90,7 @@ void sleep_led_enable(void) {
void keyboard_pre_init_kb(void) {
#ifdef KEYBOARD_ibm_model_m_mschwingen_led_ws2812
ws2812_init();
ws2812_setleds(led, RGBLIGHT_LED_COUNT);
#else
/* Set status LEDs pins to output and Low (on) */

View File

@ -154,6 +154,7 @@ rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
static void rgb_matrix_driver_init(void) {
i2c_init();
is31fl3733_init(0);
ws2812_init();
for (uint8_t index = 0; index < IS31FL3733_LED_COUNT; index++) {
bool enabled = true;
is31fl3733_set_led_control_register(index, enabled, enabled, enabled);

View File

@ -154,6 +154,7 @@ rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
static void rgb_matrix_driver_init(void) {
i2c_init();
is31fl3733_init(0);
ws2812_init();
for (uint8_t index = 0; index < IS31FL3733_LED_COUNT; index++) {
bool enabled = true;
is31fl3733_set_led_control_register(index, enabled, enabled, enabled);

View File

@ -150,6 +150,7 @@ rgb_led_t rgb_matrix_ws2812_array[WS2812_LED_TOTAL];
static void rgb_matrix_driver_init(void) {
i2c_init();
is31fl3733_init(0);
ws2812_init();
for (uint8_t index = 0; index < IS31FL3733_LED_COUNT; index++) {
bool enabled = true;
is31fl3733_set_led_control_register(index, enabled, enabled, enabled);

View File

@ -79,6 +79,7 @@ void setleds_custom(rgb_led_t *start_led, uint16_t num_leds)
}
const rgblight_driver_t rgblight_driver = {
.init = ws2812_init,
.setleds = setleds_custom,
};

View File

@ -55,6 +55,7 @@ void setleds_custom(rgb_led_t *ledarray, uint16_t num_leds) {
}
const rgblight_driver_t rgblight_driver = {
.init = ws2812_init,
.setleds = setleds_custom,
};
#endif

View File

@ -355,6 +355,7 @@ void setleds_custom(rgb_led_t *start_led, uint16_t num_leds)
}
const rgblight_driver_t rgblight_driver = {
.init = ws2812_init,
.setleds = setleds_custom,
};

View File

@ -350,6 +350,7 @@ void setleds_custom(rgb_led_t *start_led, uint16_t num_leds)
}
const rgblight_driver_t rgblight_driver = {
.init = ws2812_init,
.setleds = setleds_custom,
};

View File

@ -84,6 +84,7 @@ void setleds_custom(rgb_led_t *start_led, uint16_t num_leds)
}
const rgblight_driver_t rgblight_driver = {
.init = ws2812_init,
.setleds = setleds_custom,
};
#endif

View File

@ -23,12 +23,6 @@ void ws2812_init(void) {
// Setleds for standard RGB
void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) {
static bool s_init = false;
if (!s_init) {
ws2812_init();
s_init = true;
}
i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(rgb_led_t) * (leds >> 1), WS2812_I2C_TIMEOUT);
i2c_transmit(WS2812_I2C_ADDRESS_RIGHT, (uint8_t *)ledarray+(sizeof(rgb_led_t) * (leds >> 1)), sizeof(rgb_led_t) * (leds - (leds >> 1)), WS2812_I2C_TIMEOUT);
}

View File

@ -24,8 +24,6 @@
// LED color buffer
rgb_led_t rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
static void init(void) {}
static void flush(void) {
ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT);
}
@ -56,7 +54,7 @@ static void setled_all(uint8_t r, uint8_t g, uint8_t b) {
}
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
.init = ws2812_init,
.flush = flush,
.set_color = setled,
.set_color_all = setled_all,

View File

@ -2237,6 +2237,9 @@ void backlight_init_drivers(void)
is31fl3733_update_led_control_registers( 0 );
is31fl3733_update_led_control_registers( 1 );
#else
#if defined(RGB_BACKLIGHT_DAWN60)
ws2812_init();
#endif
// Init the #1 driver
is31fl3731_init( 0 );
// Init the #2 driver (if used)

View File

@ -20,11 +20,13 @@
#undef WS2812_DI_PIN
#define WS2812_DI_PIN RGBLIGHT_DI_PIN
#define ws2812_init ws2812_rgb_init
#define ws2812_setleds ws2812_rgb_setleds
#include "ws2812_bitbang.c"
const rgblight_driver_t rgblight_driver = {
.init = ws2812_init,
.setleds = ws2812_setleds,
};
#endif

View File

@ -155,7 +155,7 @@ static void init(void) {
is31fl3731_update_led_control_registers(1);
//RGB Underglow ws2812
ws2812_init();
}
static void flush(void) {

View File

@ -169,5 +169,6 @@ layer_state_t layer_state_set_user(layer_state_t state) {
// default color
void keyboard_post_init_user(void) {
rgblite_init();
rgblite_setrgb(RGB_GREEN);
}

View File

@ -3,7 +3,11 @@
#include "ws2812.h"
#include "color.h"
static inline void rgblite_setrgb(uint8_t _r, uint8_t _g, uint8_t _b) {
rgb_led_t leds[RGBLED_NUM] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}};
ws2812_setleds(leds, RGBLED_NUM);
static inline void rgblite_init(void) {
ws2812_init();
}
static inline void rgblite_setrgb(uint8_t _r, uint8_t _g, uint8_t _b) {
rgb_led_t leds[RGBLIGHT_LED_COUNT] = {{.r = _r, .g = _g, .b = _b}, {.r = _r, .g = _g, .b = _b}};
ws2812_setleds(leds, RGBLIGHT_LED_COUNT);
}

Some files were not shown because too many files have changed in this diff Show More