aboutsummaryrefslogtreecommitdiff
path: root/keyboards/neson_design
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/neson_design')
-rw-r--r--keyboards/neson_design/700e/700e.c61
-rw-r--r--keyboards/neson_design/700e/config.h1
-rw-r--r--keyboards/neson_design/n6/config.h1
-rw-r--r--keyboards/neson_design/n6/n6.c61
4 files changed, 69 insertions, 55 deletions
diff --git a/keyboards/neson_design/700e/700e.c b/keyboards/neson_design/700e/700e.c
index c6ba94c834..cee22cf78d 100644
--- a/keyboards/neson_design/700e/700e.c
+++ b/keyboards/neson_design/700e/700e.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
typedef struct {
uint8_t state;
@@ -295,7 +296,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();
@@ -313,17 +313,10 @@ void housekeeping_task_kb(void)
} else if (rgb_state.state == CAPS_ALERT) {
if (rgb_state.alert) {
is31fl3731_set_color_all(ALERM_LED_R, ALERM_LED_G, ALERM_LED_B);
- rgb_led_t leds[4];
- for (int i = 0; i < 4; i++) {
- leds[i].r = ALERM_LED_G;
- leds[i].g = ALERM_LED_R;
- leds[i].b = ALERM_LED_B;
- }
- ws2812_setleds(leds, 4);
+ ws2812_set_color_all(ALERM_LED_G, ALERM_LED_R, ALERM_LED_B);
} else {
is31fl3731_set_color_all(0, 0, 0);
- rgb_led_t leds[4] = {0};
- ws2812_setleds(leds, 4);
+ ws2812_set_color_all(0, 0, 0);
}
if (timer_elapsed(rgb_state.ticks) > ALERT_INTERVAL) {
@@ -333,28 +326,40 @@ void housekeeping_task_kb(void)
}
is31fl3731_flush();
+ ws2812_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, green, red, blue);
}
- rgb_led_t leds[4];
- for (int i = 0; i < 4; i++) {
- leds[i].r = start_led[IS31FL3731_LED_COUNT+i].g;
- leds[i].g = start_led[IS31FL3731_LED_COUNT+i].r;
- leds[i].b = start_led[IS31FL3731_LED_COUNT+i].b;
+}
+
+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);
}
- //ws2812_setleds(start_led+IS31FL3731_LED_COUNT, 4);
- ws2812_setleds(leds, 4);
+}
+
+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)
diff --git a/keyboards/neson_design/700e/config.h b/keyboards/neson_design/700e/config.h
index d92c9deb5d..2c2d02cad1 100644
--- a/keyboards/neson_design/700e/config.h
+++ b/keyboards/neson_design/700e/config.h
@@ -21,5 +21,6 @@
#define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND
#define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC
#define IS31FL3731_LED_COUNT 64
+#define WS2812_LED_COUNT 4
#define USB_SUSPEND_WAKEUP_DELAY 1000
diff --git a/keyboards/neson_design/n6/config.h b/keyboards/neson_design/n6/config.h
index 92aa189fae..dd67c11851 100644
--- a/keyboards/neson_design/n6/config.h
+++ b/keyboards/neson_design/n6/config.h
@@ -21,3 +21,4 @@
#define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND
#define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC
#define IS31FL3731_LED_COUNT 64
+#define WS2812_LED_COUNT 1
diff --git a/keyboards/neson_design/n6/n6.c b/keyboards/neson_design/n6/n6.c
index ef5035dcde..03bb88c40b 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 {
@@ -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)