summaryrefslogtreecommitdiff
path: root/keyboards/input_club
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/input_club')
-rw-r--r--keyboards/input_club/k_type/config.h4
-rw-r--r--keyboards/input_club/k_type/i2c_master.h1
-rw-r--r--keyboards/input_club/k_type/is31fl3733-dual.c35
-rw-r--r--keyboards/input_club/k_type/is31fl3733-dual.h7
-rw-r--r--keyboards/input_club/k_type/k_type-rgbdriver.c22
-rw-r--r--keyboards/input_club/k_type/k_type.c2
-rw-r--r--keyboards/input_club/k_type/post_rules.mk4
7 files changed, 46 insertions, 29 deletions
diff --git a/keyboards/input_club/k_type/config.h b/keyboards/input_club/k_type/config.h
index d6abd39a83..c188038a82 100644
--- a/keyboards/input_club/k_type/config.h
+++ b/keyboards/input_club/k_type/config.h
@@ -34,7 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_ONESHOT
#ifdef RGB_MATRIX_ENABLE
-//#include "gpio.h"
// RGB Matrix Animation modes. Explicitly enabled
// For full list of effects, see:
// https://docs.qmk.fm/#/feature_rgb_matrix?id=rgb-matrix-effects
@@ -106,7 +105,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND
# define IS31FL3733_I2C_ADDRESS_2 IS31FL3733_I2C_ADDRESS_GND_GND
# define IS31FL3733_DRIVER_COUNT 2
+# define IS31FL3733_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
# define DRIVER_1_LED_TOTAL 64
# define DRIVER_2_LED_TOTAL 55
-# define RGB_MATRIX_LED_COUNT (DRIVER_1_LED_TOTAL + DRIVER_2_LED_TOTAL)
+# define RGB_MATRIX_LED_COUNT IS31FL3733_LED_COUNT
#endif
diff --git a/keyboards/input_club/k_type/i2c_master.h b/keyboards/input_club/k_type/i2c_master.h
index d4e9d6878f..db4f12e43c 100644
--- a/keyboards/input_club/k_type/i2c_master.h
+++ b/keyboards/input_club/k_type/i2c_master.h
@@ -26,6 +26,7 @@
#include <ch.h>
#include <hal.h>
+#include "gpio.h"
#ifndef I2C_COUNT
# define I2C_COUNT 1
diff --git a/keyboards/input_club/k_type/is31fl3733-dual.c b/keyboards/input_club/k_type/is31fl3733-dual.c
index 54e9d76960..0b6c6a607c 100644
--- a/keyboards/input_club/k_type/is31fl3733-dual.c
+++ b/keyboards/input_club/k_type/is31fl3733-dual.c
@@ -60,6 +60,19 @@
# define IS31FL3733_GLOBALCURRENT 0xFF
#endif
+#ifndef IS31FL3733_SYNC_1
+# define IS31FL3733_SYNC_1 IS31FL3733_SYNC_NONE
+#endif
+#ifndef IS31FL3733_SYNC_2
+# define IS31FL3733_SYNC_2 IS31FL3733_SYNC_NONE
+#endif
+#ifndef IS31FL3733_SYNC_3
+# define IS31FL3733_SYNC_3 IS31FL3733_SYNC_NONE
+#endif
+#ifndef IS31FL3733_SYNC_4
+# define IS31FL3733_SYNC_4 IS31FL3733_SYNC_NONE
+#endif
+
// Transfer buffer for TWITransmitData()
uint8_t g_twi_transfer_buffer[20];
@@ -125,6 +138,24 @@ bool is31fl3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffe
return true;
}
+void is31fl3733_init_drivers(void) {
+ i2c_init(&I2CD1, I2C1_SCL_PIN, I2C1_SDA_PIN);
+ is31fl3733_init(0, IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_1);
+# ifdef USE_I2C2
+ i2c_init(&I2CD2, I2C2_SCL_PIN, I2C2_SDA_PIN);
+ is31fl3733_init(1, IS31FL3733_I2C_ADDRESS_2, IS31FL3733_SYNC_2);
+# endif
+
+ for (int i = 0; i < IS31FL3733_LED_COUNT; i++) {
+ is31fl3733_set_led_control_register(i, true, true, true);
+ }
+
+ is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0);
+# ifdef USE_I2C2
+ is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1);
+# endif
+}
+
void is31fl3733_init(uint8_t bus, uint8_t addr, uint8_t sync) {
// In order to avoid the LEDs being driven with garbage data
// in the LED driver's PWM registers, shutdown is enabled last.
@@ -173,7 +204,7 @@ void is31fl3733_init(uint8_t bus, uint8_t addr, uint8_t sync) {
void is31fl3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31fl3733_led_t led;
- if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
+ if (index >= 0 && index < IS31FL3733_LED_COUNT) {
memcpy_P(&led, (&g_is31fl3733_leds[index]), sizeof(led));
if (g_pwm_buffer[led.driver][led.r] == red && g_pwm_buffer[led.driver][led.g] == green && g_pwm_buffer[led.driver][led.b] == blue) {
@@ -187,7 +218,7 @@ void is31fl3733_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
}
void is31fl3733_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
- for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
+ for (int i = 0; i < IS31FL3733_LED_COUNT; i++) {
is31fl3733_set_color(i, red, green, blue);
}
}
diff --git a/keyboards/input_club/k_type/is31fl3733-dual.h b/keyboards/input_club/k_type/is31fl3733-dual.h
index 33943af320..696c234b67 100644
--- a/keyboards/input_club/k_type/is31fl3733-dual.h
+++ b/keyboards/input_club/k_type/is31fl3733-dual.h
@@ -46,8 +46,9 @@ typedef struct is31fl3733_led_t {
uint8_t b;
} __attribute__((packed)) is31fl3733_led_t;
-extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT];
+extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT];
+void is31fl3733_init_drivers(void);
void is31fl3733_init(uint8_t bus, uint8_t addr, uint8_t sync);
bool is31fl3733_write_register(uint8_t index, uint8_t addr, uint8_t reg, uint8_t data);
bool is31fl3733_write_pwm_buffer(uint8_t index, uint8_t addr, uint8_t *pwm_buffer);
@@ -80,6 +81,10 @@ void is31fl3733_flush(void);
#define IS31FL3733_PWM_FREQUENCY_2K1_HZ 0x03
#define IS31FL3733_PWM_FREQUENCY_1K05_HZ 0x04
+#define IS31FL3733_SYNC_NONE 0b00
+#define IS31FL3733_SYNC_MASTER 0b01
+#define IS31FL3733_SYNC_SLAVE 0b10
+
#define A_1 0x00
#define A_2 0x01
#define A_3 0x02
diff --git a/keyboards/input_club/k_type/k_type-rgbdriver.c b/keyboards/input_club/k_type/k_type-rgbdriver.c
index 1e8132e6dc..e4d2d2d04b 100644
--- a/keyboards/input_club/k_type/k_type-rgbdriver.c
+++ b/keyboards/input_club/k_type/k_type-rgbdriver.c
@@ -16,30 +16,10 @@
#ifdef RGB_MATRIX_ENABLE
# include "rgb_matrix.h"
-# include "i2c_master.h"
# include "is31fl3733-dual.h"
-# include "gpio.h"
-
-static void init(void) {
- i2c_init(&I2CD1, I2C1_SCL_PIN, I2C1_SDA_PIN);
- is31fl3733_init(0, IS31FL3733_I2C_ADDRESS_1, 0);
-# ifdef USE_I2C2
- i2c_init(&I2CD2, I2C2_SCL_PIN, I2C2_SDA_PIN);
- is31fl3733_init(1, IS31FL3733_I2C_ADDRESS_2, 0);
-# endif
- for (int index = 0; index < RGB_MATRIX_LED_COUNT; index++) {
- bool enabled = true;
- // This only caches it for later
- is31fl3733_set_led_control_register(index, enabled, enabled, enabled);
- }
- is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0);
-# ifdef USE_I2C2
- is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1);
-# endif
-}
const rgb_matrix_driver_t rgb_matrix_driver = {
- .init = init,
+ .init = is31fl3733_init_drivers,
.flush = is31fl3733_flush,
.set_color = is31fl3733_set_color,
.set_color_all = is31fl3733_set_color_all,
diff --git a/keyboards/input_club/k_type/k_type.c b/keyboards/input_club/k_type/k_type.c
index c6d06b51dc..e97007fc70 100644
--- a/keyboards/input_club/k_type/k_type.c
+++ b/keyboards/input_club/k_type/k_type.c
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef RGB_MATRIX_ENABLE
# include "is31fl3733-dual.h"
-const is31fl3733_led_t PROGMEM g_is31fl3733_leds[RGB_MATRIX_LED_COUNT] = {
+const is31fl3733_led_t PROGMEM g_is31fl3733_leds[IS31FL3733_LED_COUNT] = {
{ 0, B_1, A_1, C_1 },
{ 0, B_2, A_2, C_2 },
{ 0, B_3, A_3, C_3 },
diff --git a/keyboards/input_club/k_type/post_rules.mk b/keyboards/input_club/k_type/post_rules.mk
index 897e422b05..ba750e2624 100644
--- a/keyboards/input_club/k_type/post_rules.mk
+++ b/keyboards/input_club/k_type/post_rules.mk
@@ -1,5 +1,5 @@
ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
# Additional files for RGB lighting
- SRC += k_type-rgbdriver.c
- QUANTUM_LIB_SRC += i2c_master.c is31fl3733-dual.c
+ SRC += k_type-rgbdriver.c is31fl3733-dual.c
+ QUANTUM_LIB_SRC += i2c_master.c
endif