mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-05-30 21:13:21 +00:00
Change split_common's transport.c I2C to use the synchronization feature of rgblight.c
This commit is contained in:
parent
1aa14c5668
commit
57e124c1de
@ -23,14 +23,16 @@ extern backlight_config_t backlight_config;
|
|||||||
|
|
||||||
typedef struct _I2C_slave_buffer_t {
|
typedef struct _I2C_slave_buffer_t {
|
||||||
uint8_t backlit_level;
|
uint8_t backlit_level;
|
||||||
uint32_t rgb_config;
|
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
|
||||||
|
rgblight_syncinfo_t rgblight_sync;
|
||||||
|
#endif
|
||||||
matrix_row_t smatrix[ROWS_PER_HAND];
|
matrix_row_t smatrix[ROWS_PER_HAND];
|
||||||
} I2C_slave_buffer_t;
|
} I2C_slave_buffer_t;
|
||||||
|
|
||||||
static I2C_slave_buffer_t * const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
|
static I2C_slave_buffer_t * const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_reg;
|
||||||
|
|
||||||
# define I2C_BACKLIT_START offsetof(I2C_slave_buffer_t, backlit_level)
|
# define I2C_BACKLIT_START offsetof(I2C_slave_buffer_t, backlit_level)
|
||||||
# define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgb_config)
|
# define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgblight_sync)
|
||||||
# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix)
|
# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix)
|
||||||
|
|
||||||
# define TIMEOUT 100
|
# define TIMEOUT 100
|
||||||
@ -54,12 +56,13 @@ bool transport_master(matrix_row_t matrix[]) {
|
|||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef RGBLIGHT_ENABLE
|
# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
|
||||||
static uint32_t prev_rgb = ~0;
|
if (rgblight_get_change_flags()) {
|
||||||
uint32_t rgb = rgblight_read_dword();
|
rgblight_syncinfo_t rgblight_sync;
|
||||||
if (rgb != prev_rgb) {
|
rgblight_get_syncinfo(&rgblight_sync);
|
||||||
if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_START, (void *)&rgb, sizeof(rgb), TIMEOUT) >= 0) {
|
if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_START,
|
||||||
prev_rgb = rgb;
|
(void *)&rgblight_sync, sizeof(rgblight_sync), TIMEOUT) >= 0) {
|
||||||
|
rgblight_clear_change_flags();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
@ -76,9 +79,12 @@ void transport_slave(matrix_row_t matrix[]) {
|
|||||||
backlight_set(i2c_buffer->backlit_level);
|
backlight_set(i2c_buffer->backlit_level);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef RGBLIGHT_ENABLE
|
# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
|
||||||
// Update the RGB with the new data
|
// Update the RGB with the new data
|
||||||
rgblight_update_dword(i2c_buffer->rgb_config);
|
if (i2c_buffer->rgblight_sync.status.change_flags != 0) {
|
||||||
|
rgblight_update_sync(&i2c_buffer->rgblight_sync, false);
|
||||||
|
i2c_buffer->rgblight_sync.status.change_flags = 0;
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user