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 rgb matrix working on both sides, but they get out of sync
  • Loading branch information
Georg committed Jul 1, 2020
commit 032073b4b65f999d45cf20845fc875aa5f5878a5
2 changes: 1 addition & 1 deletion quantum/quantum.c
Original file line number Diff line number Diff line change
@@ -645,7 +645,7 @@ void matrix_scan_quantum() {
#endif

#ifdef RGB_MATRIX_ENABLE
rgb_matrix_task();
// rgb_matrix_task();
#endif

#ifdef WPM_ENABLE
90 changes: 67 additions & 23 deletions quantum/rgb_matrix.c
Original file line number Diff line number Diff line change
@@ -115,6 +115,22 @@ const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER;
# define RGB_MATRIX_STARTUP_SPD UINT8_MAX / 2
#endif

// split things
#ifdef RGBLIGHT_SPLIT
/* for split keyboard */
# define RGB_MATRIX_SPLIT_SET_CHANGE_MODE change_flags |= RGB_MATRIX_STATUS_CHANGE_MODE
# define RGB_MATRIX_SPLIT_SET_CHANGE_HSVS change_flags |= RGB_MATRIX_STATUS_CHANGE_HSVS
# define RGB_MATRIX_SPLIT_SET_CHANGE_MODEHSVS change_flags |= (RGB_MATRIX_STATUS_CHANGE_MODE | RGB_MATRIX_STATUS_CHANGE_HSVS)
# define RGB_MATRIX_SPLIT_SET_CHANGE_FLAG change_flags |= RGB_MATRIX_STATUS_CHANGE_FLAG
uint8_t change_flags = 0xFF;
#else
# define RGB_MATRIX_SPLIT_SET_CHANGE_MODE
# define RGB_MATRIX_SPLIT_SET_CHANGE_HSVS
# define RGB_MATRIX_SPLIT_SET_CHANGE_MODEHSVS
# define RGB_MATRIX_SPLIT_SET_CHANGE_FLAG

#endif

// globals
bool g_suspend_state = false;
rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
@@ -135,8 +151,6 @@ static rgb_task_states rgb_task_state = SYNCING;
static uint32_t rgb_anykey_timer;
#endif // RGB_DISABLE_TIMEOUT > 0

uint8_t flag = 1; // TODO: REMOVE

// double buffers
static uint32_t rgb_timer_buffer;
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
@@ -468,6 +482,7 @@ void rgb_matrix_toggle(void) {
rgb_matrix_config.enable ^= 1;
rgb_task_state = STARTING;
eeconfig_update_rgb_matrix();

}

void rgb_matrix_enable(void) {
@@ -478,6 +493,7 @@ void rgb_matrix_enable(void) {
void rgb_matrix_enable_noeeprom(void) {
if (!rgb_matrix_config.enable) rgb_task_state = STARTING;
rgb_matrix_config.enable = 1;
RGB_MATRIX_SPLIT_SET_CHANGE_MODE;
}

void rgb_matrix_disable(void) {
@@ -488,6 +504,7 @@ void rgb_matrix_disable(void) {
void rgb_matrix_disable_noeeprom(void) {
if (rgb_matrix_config.enable) rgb_task_state = STARTING;
rgb_matrix_config.enable = 0;
RGB_MATRIX_SPLIT_SET_CHANGE_MODE;
}

uint8_t rgb_matrix_is_enabled(void) { return rgb_matrix_config.enable; }
@@ -497,83 +514,105 @@ void rgb_matrix_step(void) {
if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX) rgb_matrix_config.mode = 1;
rgb_task_state = STARTING;
eeconfig_update_rgb_matrix();

RGB_MATRIX_SPLIT_SET_CHANGE_MODE;
}

void rgb_matrix_step_reverse(void) {
rgb_matrix_config.mode--;
if (rgb_matrix_config.mode < 1) rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1;
rgb_task_state = STARTING;
eeconfig_update_rgb_matrix();

RGB_MATRIX_SPLIT_SET_CHANGE_MODE;
}

void rgb_matrix_increase_hue(void) {
rgb_matrix_config.hsv.h += RGB_MATRIX_HUE_STEP;
eeconfig_update_rgb_matrix();

RGB_MATRIX_SPLIT_SET_CHANGE_HSVS;
}

void rgb_matrix_decrease_hue(void) {
rgb_matrix_config.hsv.h -= RGB_MATRIX_HUE_STEP;
eeconfig_update_rgb_matrix();

RGB_MATRIX_SPLIT_SET_CHANGE_HSVS;
}

void rgb_matrix_increase_sat(void) {
rgb_matrix_config.hsv.s = qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP);
eeconfig_update_rgb_matrix();
RGB_MATRIX_SPLIT_SET_CHANGE_HSVS;
}

void rgb_matrix_decrease_sat(void) {
rgb_matrix_config.hsv.s = qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP);
eeconfig_update_rgb_matrix();
RGB_MATRIX_SPLIT_SET_CHANGE_HSVS;
}

void rgb_matrix_increase_val(void) {
rgb_matrix_config.hsv.v = qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP);
if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
eeconfig_update_rgb_matrix();
RGB_MATRIX_SPLIT_SET_CHANGE_HSVS;
}

void rgb_matrix_decrease_val(void) {
rgb_matrix_config.hsv.v = qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP);
eeconfig_update_rgb_matrix();
RGB_MATRIX_SPLIT_SET_CHANGE_HSVS;
}

void rgb_matrix_increase_speed(void) {
rgb_matrix_config.speed = qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP);
eeconfig_update_rgb_matrix();
RGB_MATRIX_SPLIT_SET_CHANGE_HSVS;
}

void rgb_matrix_decrease_speed(void) {
rgb_matrix_config.speed = qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP);
eeconfig_update_rgb_matrix();
RGB_MATRIX_SPLIT_SET_CHANGE_HSVS;
}

uint8_t rgb_matrix_get_speed(void) { return rgb_matrix_config.speed; }

led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; }

void rgb_matrix_set_flags(led_flags_t flags) { rgb_effect_params.flags = flags; }
void rgb_matrix_set_flags(led_flags_t flags) {
rgb_effect_params.flags = flags;
RGB_MATRIX_SPLIT_SET_CHANGE_FLAG;
}

void rgb_matrix_mode(uint8_t mode) {
flag = 1;
rgb_matrix_config.mode = mode;
rgb_task_state = STARTING;
eeconfig_update_rgb_matrix();
RGB_MATRIX_SPLIT_SET_CHANGE_MODE;
}

void rgb_matrix_mode_noeeprom(uint8_t mode) { rgb_matrix_config.mode = mode; }
void rgb_matrix_mode_noeeprom(uint8_t mode) {
rgb_matrix_config.mode = mode;
RGB_MATRIX_SPLIT_SET_CHANGE_MODE;
}

uint8_t rgb_matrix_get_mode(void) { return rgb_matrix_config.mode; }

void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
rgb_matrix_sethsv_noeeprom(hue, sat, val);
eeconfig_update_rgb_matrix();
RGB_MATRIX_SPLIT_SET_CHANGE_HSVS;
}

void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) {
rgb_matrix_config.hsv.h = hue;
rgb_matrix_config.hsv.s = sat;
rgb_matrix_config.hsv.v = val;
if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
RGB_MATRIX_SPLIT_SET_CHANGE_HSVS;
}

HSV rgb_matrix_get_hsv(void) { return rgb_matrix_config.hsv; }
@@ -582,31 +621,36 @@ uint8_t rgb_matrix_get_sat(void) { return rgb_matrix_config.hsv.s; }
uint8_t rgb_matrix_get_val(void) { return rgb_matrix_config.hsv.v; }

#ifdef RGBLIGHT_SPLIT
uint8_t rgb_matrix_get_change_flags(void) { return flag; } // TODO
void rgb_matrix_clear_change_flags(void) {flag = 0;}
uint8_t rgb_matrix_get_change_flags(void) { return change_flags; } // TODO
void rgb_matrix_clear_change_flags(void) { change_flags = 0; }

void rgb_matrix_get_syncinfo(rgb_matrix_syncinfo_t *syncinfo) {
syncinfo->config = rgb_matrix_config;
syncinfo->effect_flags = rgb_matrix_get_flags();
syncinfo->change_flags = change_flags;
}

void rgb_matrix_update_sync(rgb_matrix_syncinfo_t *syncinfo) {
// TODO add change flag
if (syncinfo->config.enable) { // CHANGE MODE or ENABLE
rgb_matrix_enable_noeeprom();
rgb_matrix_mode_noeeprom(syncinfo->config.mode);
rgb_task_state = STARTING;
} else
rgb_matrix_disable();

// CHANGE HSV
rgb_matrix_sethsv_noeeprom(syncinfo->config.hsv.h, syncinfo->config.hsv.s, syncinfo->config.hsv.v);

// CHANGE SPEED
rgb_matrix_config.speed = syncinfo->config.speed;

// CHANGE FLAGS
rgb_matrix_set_flags(syncinfo->effect_flags);
if (syncinfo->change_flags & RGB_MATRIX_STATUS_CHANGE_MODE) {
if (syncinfo->config.enable) { // CHANGE MODE or ENABLE
rgb_matrix_enable_noeeprom();
rgb_matrix_mode_noeeprom(syncinfo->config.mode);
rgb_task_state = STARTING;
} else
rgb_matrix_disable();
}

if (syncinfo->change_flags & RGB_MATRIX_STATUS_CHANGE_HSVS) {
// CHANGE HSV
rgb_matrix_sethsv_noeeprom(syncinfo->config.hsv.h, syncinfo->config.hsv.s, syncinfo->config.hsv.v);
// CHANGE SPEED
rgb_matrix_config.speed = syncinfo->config.speed;
}

if (syncinfo->change_flags & RGB_MATRIX_STATUS_CHANGE_FLAG) {
// CHANGE FLAGS
rgb_matrix_set_flags(syncinfo->effect_flags);
}

// SUSPEND
// rgb_matrix_set_suspend_state(false);
11 changes: 11 additions & 0 deletions quantum/rgb_matrix.h
Original file line number Diff line number Diff line change
@@ -185,6 +185,9 @@ extern rgb_config_t rgb_matrix_config;
extern bool g_suspend_state;
extern uint32_t g_rgb_timer;
extern led_config_t g_led_config;
#ifdef RGBLIGHT_SPLIT
extern uint8_t change_flags;
#endif
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
extern last_hit_t g_last_hit_tracker;
#endif
@@ -193,9 +196,17 @@ extern uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS];
#endif

#ifdef RGBLIGHT_SPLIT

#define RGB_MATRIX_STATUS_CHANGE_MODE (1 << 0)
#define RGB_MATRIX_STATUS_CHANGE_HSVS (1 << 1)
#define RGB_MATRIX_STATUS_CHANGE_FLAG (1 << 2)
// #define RGB_MATRIX_STATUS_CHANGE_TIMER (1 << 3)


typedef struct _rgb_matrix_syncinfo_t {
rgb_config_t config;
led_flags_t effect_flags;
uint8_t change_flags;
// bool suspend_state;
} rgb_matrix_syncinfo_t;

2 changes: 0 additions & 2 deletions quantum/split_common/transport.c
Original file line number Diff line number Diff line change
@@ -295,8 +295,6 @@ void transport_slave(matrix_row_t matrix[]) {
# ifdef WPM_ENABLE
set_current_wpm(serial_m2s_buffer.current_wpm);
# endif

rgb_matrix_task();
}

#endif
7 changes: 7 additions & 0 deletions tmk_core/common/keyboard.c
Original file line number Diff line number Diff line change
@@ -53,6 +53,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef RGBLIGHT_ENABLE
# include "rgblight.h"
#endif
#ifdef RGB_MATRIX_ENABLE
# include "rgb_matrix.h"
#endif
#ifdef ENCODER_ENABLE
# include "encoder.h"
#endif
@@ -359,6 +362,10 @@ void keyboard_task(void) {
rgblight_task();
#endif

#if defined(RGB_MATRIX_ENABLE)
rgb_matrix_task();
#endif

#if defined(BACKLIGHT_ENABLE)
# if defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS)
backlight_task();