Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RGB Matrix Support for Split Keyboards #9613

Closed
wants to merge 47 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4aa5fa8
Branch point for 2020 Aug 29 Breaking Change
noroadsleft May 30, 2020
b2d24ea
Remove iWRAP protocol (#9284)
fauxpark Jun 5, 2020
29b5522
Initial work for consolidation of ChibiOS platform files (#8327)
tzarc Jun 6, 2020
a7614ce
Various tidyups for USB descriptor code (#9005)
fauxpark Jun 7, 2020
da634e9
Convert `CONSUMER2BLUEFRUIT()` and `CONSUMER2RN42()` macros to static…
fauxpark Jun 7, 2020
a81b027
Attempt to fix CI for non-master branches. (#9308)
tzarc Jun 8, 2020
3e3e7d0
Additional cleanups for V-USB code (#9310)
fauxpark Jun 9, 2020
1cfeef1
Remove inclusion of adafruit_ble.h from ssd1306.c (#9355)
fauxpark Jun 17, 2020
d3c256d
Don't compile outputselect.c if Bluetooth is disabled (#9356)
fauxpark Jun 17, 2020
3f6be07
`qmk cformat` on `develop` (#9501)
tzarc Jun 22, 2020
0cc8981
[Keyboard ] Add Lily58L
BenRoe May 16, 2020
58c8985
Fixed "failed" message, if flash worked
Jun 10, 2020
420cf22
Elite-C uses different bootloader
Jun 10, 2020
1253276
First attempt at splitting keyboard
Jun 10, 2020
431bd46
Got multiple files ecosystem up and running
Jun 10, 2020
8d362e8
Circumventing dead keys using the keyboard
Jun 11, 2020
5cab3e2
Using international layer with dead keys (toggle)
Jun 11, 2020
86da7f5
Custom font and portrait OLED
Jun 11, 2020
bd066e7
New icon for rgb value
Jun 11, 2020
5ba7364
New OLED information and better rgb control using encoder
Jun 12, 2020
5a44a59
Better brightness controll and media key
Jun 12, 2020
9705c1f
Added option to swap ESC and CAPSLOCK
Jun 12, 2020
3f52fe8
Swapping CAPSL and TAB for better comfort
Jun 12, 2020
3925502
Moved 0 to better key location
Jun 12, 2020
a7805d0
Simplyfied macro code
Jun 12, 2020
94d6437
Added to tab to more comfortable pos.
Jun 13, 2020
1b999ae
Adding 5ms debounce to config
Jun 15, 2020
f237a0c
Added easier tab, ß and ./, to numpad
Jun 15, 2020
d16a3d5
CAPSL & TAB, added PG Up, Down, Home, End and swapped / & \
Jun 15, 2020
9e4f488
Moved CAPS lock and auto turn off of caps lock with esc
Jun 15, 2020
cbc240f
Added DEL key, removed number row
Jun 19, 2020
310ff84
Reduced size by excluding unneccesseray modules
Jun 28, 2020
7cecc1b
Added RGB Matrix support to lily58l (currently one side only)
Jun 28, 2020
e3c4e06
Implemented logic for split rgb matrix (not working)
Jun 29, 2020
23405e9
Compiles. But that's it. Not working as expected
Jun 29, 2020
5eca66a
Got first results. Needing to implement change flag
Jun 29, 2020
032073b
Got rgb matrix working on both sides, but they get out of sync
Jun 29, 2020
3568c74
Integrated Synctimer from xscorpion2 fork
Jul 1, 2020
7d1fef4
Added synced times between both boards
Jul 1, 2020
54bcb4d
Implemented RGB_MATRIX_SPLIT and moved away from RGBLIGHT_SPLIT
Jul 1, 2020
a388c91
Fixed include and with it compilation bugs
Jul 1, 2020
925354d
Fixing compilation errors, by including split_util only if split
Jul 1, 2020
b08602f
Got it working, but unhappy with solution
Jul 1, 2020
772af1b
Disabled keycode evaluation on slave side
Jul 1, 2020
20153fd
Fixed a sync bug and that slave stored only rgb disabled states to ee…
Jul 1, 2020
fc37398
Increased RGB max value
Jul 1, 2020
dd472d4
readded encoder for rgb config
Jul 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Got it working, but unhappy with solution
TODO: Remove `return true` from `should_process_keypress`
Georg committed Jul 1, 2020

Verified

This commit was signed with the committer’s verified signature.
harshanarayana Harsha Narayana
commit b08602f09ef2f671b3df5503529d3fb125759d57
1 change: 1 addition & 0 deletions keyboards/lily58l/rev1/config.h
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@
#define DRIVER_LED_TOTAL RGBLED_NUM
#define RGB_MATRIX_CENTER {112, 36}
#define RGB_MATRIX_SPLIT RGBLED_SPLIT
#define SPLIT_TRANSPORT_MIRROR

/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE
4 changes: 0 additions & 4 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
@@ -644,10 +644,6 @@ void matrix_scan_quantum() {
led_matrix_task();
#endif

#ifdef RGB_MATRIX_ENABLE
// rgb_matrix_task();
#endif

#ifdef WPM_ENABLE
decay_wpm();
#endif
17 changes: 15 additions & 2 deletions quantum/split_common/matrix.c
Original file line number Diff line number Diff line change
@@ -24,6 +24,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config.h"
#include "transport.h"

#ifdef RGB_MATRIX_ENABLE
#include "rgb_matrix.h"
#endif

#define ERROR_DISCONNECT_COUNT 5

#define ROWS_PER_HAND (MATRIX_ROWS / 2)
@@ -244,7 +248,7 @@ void matrix_post_scan(void) {
if (is_keyboard_master()) {
static uint8_t error_count;

if (!transport_master(matrix + thatHand)) {
if (!transport_master(matrix + thisHand, matrix + thatHand)) {
error_count++;

if (error_count > ERROR_DISCONNECT_COUNT) {
@@ -259,7 +263,16 @@ void matrix_post_scan(void) {

matrix_scan_quantum();
} else {
transport_slave(matrix + thisHand);
transport_slave(matrix + thatHand, matrix + thisHand);
#ifdef SPLIT_TRANSPORT_MIRROR

# if defined(RGB_MATRIX_SPLIT) && defined(RGB_MATRIX_ENABLE)
// matrix_scan_quantum();
// rgb_matrix_task();
// matrix_scan_quantum();
# endif

#endif

matrix_slave_scan_user();
}
38 changes: 29 additions & 9 deletions quantum/split_common/transport.c
Original file line number Diff line number Diff line change
@@ -38,6 +38,9 @@ static pin_t encoders_pad[] = ENCODERS_PAD_A;

typedef struct _I2C_slave_buffer_t {
uint32_t sync_time;
# ifdef SPLIT_TRANSPORT_MIRROR
matrix_row_t mmatrix[ROWS_PER_HAND];
# endif
matrix_row_t smatrix[ROWS_PER_HAND];
uint8_t backlight_level;
# ifdef RGB_SHOULD_SPLIT_MATRIX
@@ -57,7 +60,8 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re

# define I2C_BACKLIGHT_START offsetof(I2C_slave_buffer_t, backlight_level)
# define I2C_RGB_START offsetof(I2C_slave_buffer_t, rgb_sync)
# define I2C_KEYMAP_START offsetof(I2C_slave_buffer_t, smatrix)
# define I2C_KEYMAP_MASTER_START offsetof(I2C_slave_buffer_t, mmatrix)
# define I2C_KEYMAP_SLAVE_START offsetof(I2C_slave_buffer_t, smatrix)
# define I2C_SYNC_TIME_START offsetof(I2C_slave_buffer_t, sync_time)
# define I2C_ENCODER_START offsetof(I2C_slave_buffer_t, encoder_state)
# define I2C_WPM_START offsetof(I2C_slave_buffer_t, current_wpm)
@@ -69,8 +73,11 @@ static I2C_slave_buffer_t *const i2c_buffer = (I2C_slave_buffer_t *)i2c_slave_re
# endif

// Get rows from other half over i2c
bool transport_master(matrix_row_t matrix[]) {
i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_START, (void *)matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);
bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_SLAVE_START, (void *)slave_matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);
#ifdef SPLIT_TRANSPORT_MIRROR
i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_MASTER_START, (void *)master_matrix, sizeof(i2c_buffer->mmatrix), TIMEOUT);
#endif

// write backlight info
# ifdef BACKLIGHT_ENABLE
@@ -116,10 +123,14 @@ bool transport_master(matrix_row_t matrix[]) {
return true;
}

void transport_slave(matrix_row_t matrix[]) {
void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
sync_timer_update(i2c_buffer->sync_time + 1); // 1ms offset to account for transfer speed
// Copy matrix to I2C buffer
memcpy((void *)i2c_buffer->smatrix, (void *)matrix, sizeof(i2c_buffer->smatrix));
memcpy((void *)i2c_buffer->smatrix, (void *)slave_matrix, sizeof(i2c_buffer->smatrix));
#ifdef SPLIT_TRANSPORT_MIRROR
memcpy((void*)master_matrix, (void *)i2c_buffer->mmatrix, sizeof(i2c_buffer->mmatrix));
#endif


// Read Backlight Info
# ifdef BACKLIGHT_ENABLE
@@ -159,6 +170,9 @@ typedef struct _Serial_s2m_buffer_t {
} Serial_s2m_buffer_t;

typedef struct _Serial_m2s_buffer_t {
#ifdef SPLIT_TRANSPORT_MIRROR
matrix_row_t mmatrix[ROWS_PER_HAND];
#endif
uint32_t sync_timer;
# ifdef BACKLIGHT_ENABLE
uint8_t backlight_level;
@@ -255,7 +269,7 @@ void transport_rgb_slave(void) {
# endif


bool transport_master(matrix_row_t matrix[]) {
bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
sync_timer_update(timer_read32());
# ifndef SERIAL_USE_MULTI_TRANSACTION
if (soft_serial_transaction() != TRANSACTION_END) {
@@ -271,7 +285,10 @@ bool transport_master(matrix_row_t matrix[]) {

// TODO: if MATRIX_COLS > 8 change to unpack()
for (int i = 0; i < ROWS_PER_HAND; ++i) {
matrix[i] = serial_s2m_buffer.smatrix[i];
slave_matrix[i] = serial_s2m_buffer.smatrix[i];
#ifdef SPLIT_TRANSPORT_MIRROR
serial_m2s_buffer.mmatrix[i] = master_matrix[i];
#endif
}

# ifdef BACKLIGHT_ENABLE
@@ -293,14 +310,17 @@ bool transport_master(matrix_row_t matrix[]) {
return true;
}

void transport_slave(matrix_row_t matrix[]) {
void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) {
transport_rgb_slave();

sync_timer_update(serial_m2s_buffer.sync_timer + 2); // 2ms offset to account for transfer speed

// TODO: if MATRIX_COLS > 8 change to pack()
for (int i = 0; i < ROWS_PER_HAND; ++i) {
serial_s2m_buffer.smatrix[i] = matrix[i];
serial_s2m_buffer.smatrix[i] = slave_matrix[i];
#ifdef SPLIT_TRANSPORT_MIRROR
master_matrix[i] = serial_m2s_buffer.mmatrix[i];
#endif
}
# ifdef BACKLIGHT_ENABLE
backlight_set(serial_m2s_buffer.backlight_level);
4 changes: 2 additions & 2 deletions quantum/split_common/transport.h
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ void transport_master_init(void);
void transport_slave_init(void);

// returns false if valid data not received from slave
bool transport_master(matrix_row_t matrix[]);
void transport_slave(matrix_row_t matrix[]);
bool transport_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
void transport_slave(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]);
2 changes: 1 addition & 1 deletion tmk_core/common/keyboard.c
Original file line number Diff line number Diff line change
@@ -228,7 +228,7 @@ __attribute__((weak)) bool is_keyboard_master(void) { return true; }
* Override this function if you have a condition where keypresses processing should change:
* - splits where the slave side needs to process for rgb/oled functionality
*/
__attribute__((weak)) bool should_process_keypress(void) { return is_keyboard_master(); }
__attribute__((weak)) bool should_process_keypress(void) { return true; } // return is_keyboard_master(); }

/** \brief keyboard_init
*