aboutsummaryrefslogtreecommitdiff
path: root/keyboards/neson_design/n6/n6.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/neson_design/n6/n6.c')
-rw-r--r--keyboards/neson_design/n6/n6.c65
1 files changed, 36 insertions, 29 deletions
diff --git a/keyboards/neson_design/n6/n6.c b/keyboards/neson_design/n6/n6.c
index ef5035dcde..e4538257f1 100644
--- a/keyboards/neson_design/n6/n6.c
+++ b/keyboards/neson_design/n6/n6.c
@@ -18,9 +18,11 @@
*/
#include "quantum.h"
-#include "i2c_master.h"
-#include "drivers/led/issi/is31fl3731.h"
-#include "ws2812.h"
+
+#ifdef RGBLIGHT_ENABLE
+# include "i2c_master.h"
+# include "drivers/led/issi/is31fl3731.h"
+# include "ws2812.h"
enum {
SELF_TESTING,
@@ -67,7 +69,6 @@ enum {
#endif
#define ST_RIGHT_END (ST_RIGHT_BEGIN+ST_RIGHT_SIZE-1)
-#ifdef RGBLIGHT_ENABLE
extern rgblight_config_t rgblight_config;
typedef struct {
@@ -103,12 +104,12 @@ static void update_ticks(void)
static void self_testing(void)
{
if (timer_elapsed(rgb_state.ticks) < ST_INTERVAL) return;
- HSV hsv;
+ hsv_t hsv;
hsv.h = rgblight_config.hue;
hsv.s = rgblight_config.sat;
hsv.v = rgblight_config.val;
- RGB led = hsv_to_rgb(hsv);
+ rgb_t led = hsv_to_rgb(hsv);
switch(rgb_state.testing) {
case ST_STAGE_1:
if (rgb_state.index !=0 ) {
@@ -299,8 +300,6 @@ void matrix_init_kb(void)
gpio_set_pin_output(LED_CAPS_LOCK_PIN);
gpio_write_pin_low(LED_CAPS_LOCK_PIN);
- is31fl3731_init_drivers();
-
update_ticks();
matrix_init_user();
}
@@ -310,22 +309,12 @@ void housekeeping_task_kb(void)
if (rgb_state.state == SELF_TESTING) {
self_testing();
} else if (rgb_state.state == CAPS_ALERT) {
- //gold 0xFF, 0xD9, 0x00
- rgb_led_t led = {
- .r = 0xFF,
- //.g = 0xD9,
- .g = 0xA5,
- .b = 0x00,
- };
if (rgb_state.alert) {
- is31fl3731_set_color_all(led.r, led.g, led.b);
- ws2812_setleds(&led, 1);
+ is31fl3731_set_color_all(0xFF, 0xA5, 0x00);
+ ws2812_set_color_all(0xFF, 0xA5, 0x00);
} else {
- led.r = 0;
- led.g = 0;
- led.b = 0;
is31fl3731_set_color_all(0, 0, 0);
- ws2812_setleds(&led, 1);
+ ws2812_set_color_all(0, 0, 0);
}
if (timer_elapsed(rgb_state.ticks) > ALERT_INTERVAL) {
@@ -337,19 +326,37 @@ void housekeeping_task_kb(void)
is31fl3731_flush();
}
-void setleds_custom(rgb_led_t *start_led, uint16_t num_leds)
-{
- if (rgb_state.state != NORMAL) return;
+void init_custom(void) {
+ is31fl3731_init_drivers();
+ ws2812_init();
+}
- for (uint8_t i = 0; i < IS31FL3731_LED_COUNT; i++) {
- is31fl3731_set_color(i, start_led[i].r, start_led[i].g, start_led[i].b);
+void set_color_custom(int index, uint8_t red, uint8_t green, uint8_t blue) {
+ if (index < IS31FL3731_LED_COUNT) {
+ is31fl3731_set_color(index, red, green, blue);
+ } else if (index < IS31FL3731_LED_COUNT + WS2812_LED_COUNT) {
+ ws2812_set_color(index - IS31FL3731_LED_COUNT, red, green, blue);
}
- ws2812_setleds(start_led+IS31FL3731_LED_COUNT, 1);
+}
+
+void set_color_all_custom(uint8_t red, uint8_t green, uint8_t blue) {
+ for (int i = 0; i < RGBLIGHT_LED_COUNT; i++) {
+ set_color_custom(i, red, green, blue);
+ }
+}
+
+void flush_custom(void) {
+ if (rgb_state.state != NORMAL) return;
+
+ is31fl3731_flush();
+ ws2812_flush();
}
const rgblight_driver_t rgblight_driver = {
- .init = ws2812_init,
- .setleds = setleds_custom,
+ .init = init_custom,
+ .set_color = set_color_custom,
+ .set_color_all = set_color_all_custom,
+ .flush = flush_custom,
};
bool led_update_kb(led_t led_state)