Merge remote-tracking branch 'origin/develop' into xap

This commit is contained in:
zvecr 2023-11-01 01:19:30 +00:00
commit 60cf8ba553
223 changed files with 5317 additions and 1244 deletions

View file

@ -45,6 +45,10 @@
// Combos
"COMBO_TERM": {"info_key": "combo.term", "value_type": "int"},
"DIP_SWITCH_MATRIX_GRID": {"info_key": "dip_switch.matrix_grid", "value_type": "array.array.int", "to_json": false},
"DIP_SWITCH_PINS": {"info_key": "dip_switch.pins", "value_type": "array"},
"DIP_SWITCH_PINS_RIGHT": {"info_key": "split.dip_switch.right.pins", "value_type": "array"},
// Dynamic Keymap
"DYNAMIC_KEYMAP_EEPROM_MAX_ADDR": {"info_key": "dynamic_keymap.eeprom_max_addr", "value_type": "int"},
"DYNAMIC_KEYMAP_LAYER_COUNT": {"info_key": "dynamic_keymap.layer_count", "value_type": "int"},
@ -150,6 +154,8 @@
// Split Keyboard
"SOFT_SERIAL_PIN": {"info_key": "split.soft_serial_pin"},
"SOFT_SERIAL_SPEED": {"info_key": "split.soft_serial_speed"},
"SPLIT_HAND_MATRIX_GRID": {"info_key": "split.handedness.matrix_grid", "value_type": "array", "to_c": false},
"SPLIT_HAND_PIN": {"info_key": "split.handedness.pin"},
"SPLIT_USB_DETECT": {"info_key": "split.usb_detect.enabled", "value_type": "bool"},
"SPLIT_USB_TIMEOUT": {"info_key": "split.usb_detect.timeout", "value_type": "int"},
"SPLIT_USB_TIMEOUT_POLL": {"info_key": "split.usb_detect.polling_interval", "value_type": "int"},
@ -214,4 +220,9 @@
"PRODUCT": {"info_key": "keyboard_name", "warn_duplicate": false, "value_type": "str", "deprecated": true, "replace_with": "`keyboard_name` in info.json"},
"PRODUCT_ID": {"info_key": "usb.pid", "value_type": "hex", "deprecated": true, "replace_with": "`usb.pid` in info.json"},
"VENDOR_ID": {"info_key": "usb.vid", "value_type": "hex", "deprecated": true, "replace_with": "`usb.vid` in info.json"},
// Items we want flagged in lint
"VIAL_KEYBOARD_UID": {"info_key": "_invalid.vial_uid", "invalid": true},
"VIAL_UNLOCK_COMBO_COLS": {"info_key": "_invalid.vial_unlock_cols", "invalid": true},
"VIAL_UNLOCK_COMBO_ROWS": {"info_key": "_invalid.vial_unlock_rows", "invalid": true}
}

View file

@ -17,6 +17,7 @@
"BOOTLOADER": {"info_key": "bootloader", "warn_duplicate": false},
"BOOTMAGIC_ENABLE": {"info_key": "bootmagic.enabled", "value_type": "bool"},
"CAPS_WORD_ENABLE": {"info_key": "caps_word.enabled", "value_type": "bool"},
"DIP_SWITCH_ENABLE": {"info_key": "dip_switch.enabled", "value_type": "bool"},
"DEBOUNCE_TYPE": {"info_key": "build.debounce_type"},
"EEPROM_DRIVER": {"info_key": "eeprom.driver"},
"ENCODER_ENABLE": {"info_key": "encoder.enabled", "value_type": "bool"},

View file

@ -20,7 +20,15 @@
}
}
}
}
},
"dip_switch_config": {
"type": "object",
"properties": {
"pins": {
"$ref": "qmk.definitions.v1#/mcu_pin_array"
}
}
},
},
"type": "object",
"not": { "required": [ "vendorId", "productId" ] }, // reject via keys...
@ -245,6 +253,25 @@
"type": "array",
"items": {"$ref": "qmk.definitions.v1#/filename"}
},
"dip_switch": {
"$ref": "#/definitions/dip_switch_config",
"properties": {
"enabled": {"type": "boolean"},
"matrix_grid": {
"type": "array",
"minItems": 1,
"items": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"type": "integer",
"minimum": 0
}
}
}
}
},
"eeprom": {
"properties": {
"driver": {"type": "string"},
@ -613,10 +640,6 @@
}
}
},
"matrix_grid": {
"type": "array",
"items": {"$ref": "qmk.definitions.v1#/mcu_pin"}
},
"matrix_pins": {
"type": "object",
"additionalProperties": false,
@ -636,6 +659,15 @@
}
}
},
"dip_switch": {
"type": "object",
"additionalProperties": false,
"properties": {
"right": {
"$ref": "#/definitions/dip_switch_config"
}
}
},
"encoder": {
"type": "object",
"additionalProperties": false,
@ -645,9 +677,17 @@
}
}
},
"main": {
"type": "string",
"enum": ["eeprom", "left", "matrix_grid", "pin", "right"]
"handedness": {
"type": "object",
"additionalProperties": false,
"properties": {
"pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
"matrix_grid": {
"$ref": "qmk.definitions.v1#/mcu_pin_array",
"minItems": 2,
"maxItems": 2
}
}
},
"soft_serial_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
"soft_serial_speed": {
@ -699,6 +739,16 @@
"polling_interval": {"$ref": "qmk.definitions.v1#/unsigned_int"},
"timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"}
}
},
"main": {
"type": "string",
"enum": ["eeprom", "left", "matrix_grid", "pin", "right"],
"$comment": "Deprecated: use config.h options for now"
},
"matrix_grid": {
"type": "array",
"items": {"$ref": "qmk.definitions.v1#/mcu_pin"},
"$comment": "Deprecated: use split.handedness.matrix_grid instead"
}
}
},

View file

@ -201,6 +201,20 @@ Configures the [Combo](feature_combo.md) feature.
* The amount of time to recognize a combo in milliseconds.
* Default: `50` (50 ms)
## DIP Switches :id=dip-switch
Configures the [DIP Switches](feature_dip_switch.md) feature.
* `dip_switch`
* `enabled`
* Enable the DIP Switches feature.
* Default: `false`
* `pins`
* A list of GPIO pins connected to the MCU.
* `matrix_grid`
* A list of matrix locations in the key matrix.
* Example: `[ [0,6], [1,6], [2,6] ]`
## EEPROM :id=eeprom
Configures the [EEPROM](eeprom_driver.md) driver.
@ -622,6 +636,10 @@ Configures the [Split Keyboard](feature_split_keyboard.md) feature.
* `bootmagic`
* `matrix`
* See [Bootmagic](#bootmagic) config.
* `dip_switch`
* `right`
* `pins`
* See [DIP Switches](#dip-switch) config.
* `enabled`
* Enable the Split Keyboard feature.
* Default: `false`
@ -629,6 +647,12 @@ Configures the [Split Keyboard](feature_split_keyboard.md) feature.
* `right`
* `rotary`
* See [Encoder](#encoder) config.
* `handedness`
* `pin`
* The GPIO pin connected to determine handedness.
* `matrix_grid`
* The GPIO pins of the matrix position which determines the handedness.
* Example: `["A1", "B5"]`
* `matrix_pins`
* `right`
* See [Matrix](#matrix) config.

View file

@ -126,6 +126,15 @@ static inline void aw20216s_auto_lowpower(pin_t cs_pin) {
aw20216s_write_register(cs_pin, AW20216S_PAGE_FUNCTION, AW20216S_REG_MIXFUNCTION, AW20216S_MIXCR_DEFAULT | AW20216S_LPEN);
}
void aw20216s_init_drivers(void) {
spi_init();
aw20216s_init(AW20216S_CS_PIN_1, AW20216S_EN_PIN_1);
#if defined(AW20216S_CS_PIN_2)
aw20216s_init(AW20216S_CS_PIN_2, AW20216S_EN_PIN_2);
#endif
}
void aw20216s_init(pin_t cs_pin, pin_t en_pin) {
setPinOutput(en_pin);
writePinHigh(en_pin);
@ -155,7 +164,7 @@ void aw20216s_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
}
void aw20216s_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
for (uint8_t i = 0; i < AW20216S_LED_COUNT; i++) {
aw20216s_set_color(i, red, green, blue);
}
}

View file

@ -54,6 +54,10 @@
#define g_aw_leds g_aw20216s_leds
// ========
#if defined(RGB_MATRIX_AW20216S)
# define AW20216S_LED_COUNT RGB_MATRIX_LED_COUNT
#endif
typedef struct aw20216s_led_t {
uint8_t driver : 2;
uint8_t r;
@ -61,8 +65,9 @@ typedef struct aw20216s_led_t {
uint8_t b;
} aw20216s_led_t;
extern const aw20216s_led_t PROGMEM g_aw20216s_leds[RGB_MATRIX_LED_COUNT];
extern const aw20216s_led_t PROGMEM g_aw20216s_leds[AW20216S_LED_COUNT];
void aw20216s_init_drivers(void);
void aw20216s_init(pin_t cs_pin, pin_t en_pin);
void aw20216s_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
void aw20216s_set_color_all(uint8_t red, uint8_t green, uint8_t blue);

View file

@ -68,6 +68,8 @@ void is31fl3218_write_pwm_buffer(uint8_t *pwm_buffer) {
}
void is31fl3218_init(void) {
i2c_init();
// In case we ever want to reinitialize (?)
is31fl3218_write_register(IS31FL3218_REG_RESET, 0x00);
@ -86,11 +88,17 @@ void is31fl3218_init(void) {
// Load PWM registers and LED Control register data
is31fl3218_write_register(IS31FL3218_REG_UPDATE, 0x01);
for (int i = 0; i < IS31FL3218_LED_COUNT; i++) {
is31fl3218_set_led_control_register(i, true);
}
is31fl3218_update_led_control_registers();
}
void is31fl3218_set_value(int index, uint8_t value) {
is31fl3218_led_t led;
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
if (index >= 0 && index < IS31FL3218_LED_COUNT) {
memcpy_P(&led, (&g_is31fl3218_leds[index]), sizeof(led));
}
if (g_pwm_buffer[led.v - IS31FL3218_REG_PWM] == value) {
@ -101,7 +109,7 @@ void is31fl3218_set_value(int index, uint8_t value) {
}
void is31fl3218_set_value_all(uint8_t value) {
for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) {
for (int i = 0; i < IS31FL3218_LED_COUNT; i++) {
is31fl3218_set_value(i, value);
}
}

View file

@ -22,11 +22,15 @@
#define IS31FL3218_I2C_ADDRESS 0x54
#if defined(LED_MATRIX_IS31FL3218)
# define IS31FL3218_LED_COUNT LED_MATRIX_LED_COUNT
#endif
typedef struct is31fl3218_led_t {
uint8_t v;
} __attribute__((packed)) is31fl3218_led_t;
extern const is31fl3218_led_t PROGMEM g_is31fl3218_leds[LED_MATRIX_LED_COUNT];
extern const is31fl3218_led_t PROGMEM g_is31fl3218_leds[IS31FL3218_LED_COUNT];
void is31fl3218_init(void);

View file

@ -68,6 +68,8 @@ void is31fl3218_write_pwm_buffer(uint8_t *pwm_buffer) {
}
void is31fl3218_init(void) {
i2c_init();
// In case we ever want to reinitialize (?)
is31fl3218_write_register(IS31FL3218_REG_RESET, 0x00);
@ -86,11 +88,17 @@ void is31fl3218_init(void) {
// Load PWM registers and LED Control register data
is31fl3218_write_register(IS31FL3218_REG_UPDATE, 0x01);
for (int i = 0; i < IS31FL3218_LED_COUNT; i++) {
is31fl3218_set_led_control_register(i, true, true, true);
}
is31fl3218_update_led_control_registers();
}
void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31fl3218_led_t led;
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
if (index >= 0 && index < IS31FL3218_LED_COUNT) {
memcpy_P(&led, (&g_is31fl3218_leds[index]), sizeof(led));
}
if (g_pwm_buffer[led.r - IS31FL3218_REG_PWM] == red && g_pwm_buffer[led.g - IS31FL3218_REG_PWM] == green && g_pwm_buffer[led.b - IS31FL3218_REG_PWM] == blue) {
@ -103,7 +111,7 @@ void is31fl3218_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
}
void is31fl3218_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 < IS31FL3218_LED_COUNT; i++) {
is31fl3218_set_color(i, red, green, blue);
}
}

View file

@ -22,13 +22,17 @@
#define IS31FL3218_I2C_ADDRESS 0x54
#if defined(RGB_MATRIX_IS31FL3218)
# define IS31FL3218_LED_COUNT RGB_MATRIX_LED_COUNT
#endif
typedef struct is31fl3218_led_t {
uint8_t r;
uint8_t g;
uint8_t b;
} __attribute__((packed)) is31fl3218_led_t;
extern const is31fl3218_led_t PROGMEM g_is31fl3218_leds[RGB_MATRIX_LED_COUNT];
extern const is31fl3218_led_t PROGMEM g_is31fl3218_leds[IS31FL3218_LED_COUNT];
void is31fl3218_init(void);

View file

@ -104,6 +104,36 @@ void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
}
}
void is31fl3731_init_drivers(void) {
i2c_init();
is31fl3731_init(IS31FL3731_I2C_ADDRESS_1);
#if defined(IS31FL3731_I2C_ADDRESS_2)
is31fl3731_init(IS31FL3731_I2C_ADDRESS_2);
# if defined(IS31FL3731_I2C_ADDRESS_3)
is31fl3731_init(IS31FL3731_I2C_ADDRESS_3);
# if defined(IS31FL3731_I2C_ADDRESS_4)
is31fl3731_init(IS31FL3731_I2C_ADDRESS_4);
# endif
# endif
#endif
for (int i = 0; i < IS31FL3731_LED_COUNT; i++) {
is31fl3731_set_led_control_register(i, true);
}
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0);
#if defined(IS31FL3731_I2C_ADDRESS_2)
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_2, 1);
# if defined(IS31FL3731_I2C_ADDRESS_3)
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_3, 2);
# if defined(IS31FL3731_I2C_ADDRESS_4)
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
void is31fl3731_init(uint8_t addr) {
// In order to avoid the LEDs being driven with garbage data
// in the LED driver's PWM registers, first enable software shutdown,
@ -161,7 +191,7 @@ void is31fl3731_init(uint8_t addr) {
void is31fl3731_set_value(int index, uint8_t value) {
is31fl3731_led_t led;
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
if (index >= 0 && index < IS31FL3731_LED_COUNT) {
memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led));
// Subtract 0x24 to get the second index of g_pwm_buffer
@ -175,7 +205,7 @@ void is31fl3731_set_value(int index, uint8_t value) {
}
void is31fl3731_set_value_all(uint8_t value) {
for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) {
for (int i = 0; i < IS31FL3731_LED_COUNT; i++) {
is31fl3731_set_value(i, value);
}
}

View file

@ -57,13 +57,18 @@
#define IS31FL3731_I2C_ADDRESS_SDA 0x76
#define IS31FL3731_I2C_ADDRESS_VCC 0x77
#if defined(LED_MATRIX_IS31FL3731)
# define IS31FL3731_LED_COUNT LED_MATRIX_LED_COUNT
#endif
typedef struct is31fl3731_led_t {
uint8_t driver : 2;
uint8_t v;
} __attribute__((packed)) is31fl3731_led_t;
extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[LED_MATRIX_LED_COUNT];
extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT];
void is31fl3731_init_drivers(void);
void is31fl3731_init(uint8_t addr);
void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data);
void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);

View file

@ -101,6 +101,36 @@ void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
}
}
void is31fl3731_init_drivers(void) {
i2c_init();
is31fl3731_init(IS31FL3731_I2C_ADDRESS_1);
#if defined(IS31FL3731_I2C_ADDRESS_2)
is31fl3731_init(IS31FL3731_I2C_ADDRESS_2);
# if defined(IS31FL3731_I2C_ADDRESS_3)
is31fl3731_init(IS31FL3731_I2C_ADDRESS_3);
# if defined(IS31FL3731_I2C_ADDRESS_4)
is31fl3731_init(IS31FL3731_I2C_ADDRESS_4);
# endif
# endif
#endif
for (int i = 0; i < IS31FL3731_LED_COUNT; i++) {
is31fl3731_set_led_control_register(i, true, true, true);
}
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0);
#if defined(IS31FL3731_I2C_ADDRESS_2)
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_2, 1);
# if defined(IS31FL3731_I2C_ADDRESS_3)
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_3, 2);
# if defined(IS31FL3731_I2C_ADDRESS_4)
is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
void is31fl3731_init(uint8_t addr) {
// In order to avoid the LEDs being driven with garbage data
// in the LED driver's PWM registers, first enable software shutdown,
@ -158,7 +188,7 @@ void is31fl3731_init(uint8_t addr) {
void is31fl3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
is31fl3731_led_t led;
if (index >= 0 && index < RGB_MATRIX_LED_COUNT) {
if (index >= 0 && index < IS31FL3731_LED_COUNT) {
memcpy_P(&led, (&g_is31fl3731_leds[index]), sizeof(led));
// Subtract 0x24 to get the second index of g_pwm_buffer
@ -173,7 +203,7 @@ void is31fl3731_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
}
void is31fl3731_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 < IS31FL3731_LED_COUNT; i++) {
is31fl3731_set_color(i, red, green, blue);
}
}

View file

@ -56,6 +56,10 @@
#define IS31FL3731_I2C_ADDRESS_SDA 0x76
#define IS31FL3731_I2C_ADDRESS_VCC 0x77
#if defined(RGB_MATRIX_IS31FL3731)
# define IS31FL3731_LED_COUNT RGB_MATRIX_LED_COUNT
#endif
typedef struct is31fl3731_led_t {
uint8_t driver : 2;
uint8_t r;
@ -63,8 +67,9 @@ typedef struct is31fl3731_led_t {
uint8_t b;
} __attribute__((packed)) is31fl3731_led_t;
extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[RGB_MATRIX_LED_COUNT];
extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT];
void is31fl3731_init_drivers(void);
void is31fl3731_init(uint8_t addr);
void is31fl3731_write_register(uint8_t addr, uint8_t reg, uint8_t data);
void is31fl3731_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);

View file

@ -63,6 +63,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];
@ -126,6 +139,36 @@ bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
return true;
}
void is31fl3733_init_drivers(void) {
i2c_init();
is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_1);
#if defined(IS31FL3733_I2C_ADDRESS_2)
is31fl3733_init(IS31FL3733_I2C_ADDRESS_2, IS31FL3733_SYNC_2);
# if defined(IS31FL3733_I2C_ADDRESS_3)
is31fl3733_init(IS31FL3733_I2C_ADDRESS_3, IS31FL3733_SYNC_3);
# if defined(IS31FL3733_I2C_ADDRESS_4)
is31fl3733_init(IS31FL3733_I2C_ADDRESS_4, IS31FL3733_SYNC_4);
# endif
# endif
#endif
for (int i = 0; i < IS31FL3733_LED_COUNT; i++) {
is31fl3733_set_led_control_register(i, true);
}
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0);
#if defined(IS31FL3733_I2C_ADDRESS_2)
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1);
# if defined(IS31FL3733_I2C_ADDRESS_3)
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_3, 2);
# if defined(IS31FL3733_I2C_ADDRESS_4)
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
void is31fl3733_init(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.
@ -174,7 +217,7 @@ void is31fl3733_init(uint8_t addr, uint8_t sync) {
void is31fl3733_set_value(int index, uint8_t value) {
is31fl3733_led_t led;
if (index >= 0 && index < LED_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.v] == value) {
@ -186,7 +229,7 @@ void is31fl3733_set_value(int index, uint8_t value) {
}
void is31fl3733_set_value_all(uint8_t value) {
for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) {
for (int i = 0; i < IS31FL3733_LED_COUNT; i++) {
is31fl3733_set_value(i, value);
}
}

View file

@ -76,13 +76,18 @@
#define IS31FL3733_I2C_ADDRESS_VCC_SDA 0x5E
#define IS31FL3733_I2C_ADDRESS_VCC_VCC 0x5F
#if defined(LED_MATRIX_IS31FL3733)
# define IS31FL3733_LED_COUNT LED_MATRIX_LED_COUNT
#endif
typedef struct is31fl3733_led_t {
uint8_t driver : 2;
uint8_t v;
} __attribute__((packed)) is31fl3733_led_t;
extern const is31fl3733_led_t PROGMEM g_is31fl3733_leds[LED_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 addr, uint8_t sync);
bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
@ -115,6 +120,10 @@ void is31fl3733_flush(void);
#define IS31FL3733_PWM_FREQUENCY_2K1_HZ 0b011
#define IS31FL3733_PWM_FREQUENCY_1K05_HZ 0b100
#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

View file

@ -62,6 +62,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,36 @@ bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
return true;
}
void is31fl3733_init_drivers(void) {
i2c_init();
is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_1);
#if defined(IS31FL3733_I2C_ADDRESS_2)
is31fl3733_init(IS31FL3733_I2C_ADDRESS_2, IS31FL3733_SYNC_2);
# if defined(IS31FL3733_I2C_ADDRESS_3)
is31fl3733_init(IS31FL3733_I2C_ADDRESS_3, IS31FL3733_SYNC_3);
# if defined(IS31FL3733_I2C_ADDRESS_4)
is31fl3733_init(IS31FL3733_I2C_ADDRESS_4, IS31FL3733_SYNC_4);
# endif
# endif
#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);
#if defined(IS31FL3733_I2C_ADDRESS_2)
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1);
# if defined(IS31FL3733_I2C_ADDRESS_3)
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_3, 2);
# if defined(IS31FL3733_I2C_ADDRESS_4)
is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
void is31fl3733_init(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 +216,7 @@ void is31fl3733_init(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 +230,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);
}
}

View file

@ -99,6 +99,10 @@
#define IS31FL3733_I2C_ADDRESS_VCC_SDA 0x5E
#define IS31FL3733_I2C_ADDRESS_VCC_VCC 0x5F
#if defined(RGB_MATRIX_IS31FL3733)
# define IS31FL3733_LED_COUNT RGB_MATRIX_LED_COUNT
#endif
typedef struct is31fl3733_led_t {
uint8_t driver : 2;
uint8_t r;
@ -106,8 +110,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 addr, uint8_t sync);
bool is31fl3733_write_register(uint8_t addr, uint8_t reg, uint8_t data);
bool is31fl3733_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
@ -140,6 +145,10 @@ void is31fl3733_flush(void);
#define IS31FL3733_PWM_FREQUENCY_2K1_HZ 0b011
#define IS31FL3733_PWM_FREQUENCY_1K05_HZ 0b100
#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

View file

@ -112,6 +112,36 @@ void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer) {
}
}
void is31fl3736_init_drivers(void) {
i2c_init();
is31fl3736_init(IS31FL3736_I2C_ADDRESS_1);
#if defined(IS31FL3736_I2C_ADDRESS_2)
is31fl3736_init(IS31FL3736_I2C_ADDRESS_2);
# if defined(IS31FL3736_I2C_ADDRESS_3)
is31fl3736_init(IS31FL3736_I2C_ADDRESS_3);
# if defined(IS31FL3736_I2C_ADDRESS_4)
is31fl3736_init(IS31FL3736_I2C_ADDRESS_4);
# endif
# endif
#endif
for (int i = 0; i < IS31FL3736_LED_COUNT; i++) {
is31fl3736_set_led_control_register(i, true);
}
is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_1, 0);
#if defined(IS31FL3736_I2C_ADDRESS_2)
is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_2, 1);
# if defined(IS31FL3736_I2C_ADDRESS_3)
is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_3, 2);
# if defined(IS31FL3736_I2C_ADDRESS_4)
is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_4, 3);
# endif
# endif
#endif
}
void is31fl3736_init(uint8_t addr) {
// In order to avoid the LEDs being driven with garbage data
// in the LED driver's PWM registers, shutdown is enabled last.
@ -159,7 +189,7 @@ void is31fl3736_init(uint8_t addr) {
void is31fl3736_set_value(int index, uint8_t value) {
is31fl3736_led_t led;
if (index >= 0 && index < LED_MATRIX_LED_COUNT) {
if (index >= 0 && index < IS31FL3736_LED_COUNT) {
memcpy_P(&led, (&g_is31fl3736_leds[index]), sizeof(led));
if (g_pwm_buffer[led.driver][led.v] == value) {
@ -171,7 +201,7 @@ void is31fl3736_set_value(int index, uint8_t value) {
}
void is31fl3736_set_value_all(uint8_t value) {
for (int i = 0; i < LED_MATRIX_LED_COUNT; i++) {
for (int i = 0; i < IS31FL3736_LED_COUNT; i++) {
is31fl3736_set_value(i, value);
}
}

View file

@ -71,13 +71,18 @@
#define IS31FL3736_I2C_ADDRESS_VCC_SDA 0x5E
#define IS31FL3736_I2C_ADDRESS_VCC_VCC 0x5F
#if defined(LED_MATRIX_IS31FL3736)
# define IS31FL3736_LED_COUNT LED_MATRIX_LED_COUNT
#endif
typedef struct is31fl3736_led_t {
uint8_t driver : 2;
uint8_t v;
} __attribute__((packed)) is31fl3736_led_t;
extern const is31fl3736_led_t PROGMEM g_is31fl3736_leds[LED_MATRIX_LED_COUNT];
extern const is31fl3736_led_t PROGMEM g_is31fl3736_leds[IS31FL3736_LED_COUNT];
void is31fl3736_init_drivers(void);
void is31fl3736_init(uint8_t addr);
void is31fl3736_write_register(uint8_t addr, uint8_t reg, uint8_t data);
void is31fl3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);

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