Skip to content

Commit

Permalink
Add temporary code to split_common/transport.c to test rgblight.c.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtei committed Mar 22, 2019
1 parent 5287e51 commit 71db3e2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions keyboards/handwired/pdhelix/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGBLIGHT_VAL_STEP 8
#define RGBLIGHT_LIMIT_VAL 120 /* The maximum brightness level */
#define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
#define RGBLIGHT_SPLIT
// /*== all animations enable ==*/
// #define RGBLIGHT_ANIMATIONS
// /*== or choose animations ==*/
Expand Down
32 changes: 26 additions & 6 deletions quantum/split_common/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ typedef struct _Serial_m2s_buffer_t {
uint8_t backlight_level;
# endif
# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
rgblight_config_t rgblight_config; // not yet use
rgblight_syncinfo_t rgblight_sync;
//
// When MCUs on both sides drive their respective RGB LED chains,
// it is necessary to synchronize, so it is necessary to communicate RGB
Expand Down Expand Up @@ -123,19 +123,33 @@ void transport_master_init(void) { soft_serial_initiator_init(transactions, TID_
void transport_slave_init(void) { soft_serial_target_init(transactions, TID_LIMIT(transactions)); }

bool transport_master(matrix_row_t matrix[]) {
#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
if (rgblight_get_change_flags()) {
rgblight_get_syncinfo((rgblight_syncinfo_t *)&serial_m2s_buffer.rgblight_sync);
}

if (soft_serial_transaction() != TRANSACTION_END) {
return false;
}

if (serial_m2s_buffer.rgblight_sync.status.change_flags != 0) {
if (serial_m2s_buffer.rgblight_sync.status.change_flags ==
rgblight_get_change_flags()) {
rgblight_clear_change_flags();
}
serial_m2s_buffer.rgblight_sync.status.change_flags = 0;
}
#else
if (soft_serial_transaction()) {
return false;
}
#endif

// TODO: if MATRIX_COLS > 8 change to unpack()
for (int i = 0; i < ROWS_PER_HAND; ++i) {
matrix[i] = serial_s2m_buffer.smatrix[i];
}

# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
// Code to send RGB over serial goes here (not implemented yet)
# endif

# ifdef BACKLIGHT_ENABLE
// Write backlight level for slave to read
serial_m2s_buffer.backlight_level = backlight_config.enable ? backlight_config.level : 0;
Expand All @@ -152,9 +166,15 @@ void transport_slave(matrix_row_t matrix[]) {
# ifdef BACKLIGHT_ENABLE
backlight_set(serial_m2s_buffer.backlight_level);
# endif

if (status0 == TRANSACTION_ACCEPTED) { // if data received
# if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
// Add serial implementation for RGB here
if (serial_m2s_buffer.rgblight_sync.status.change_flags) {
rgblight_update_sync((rgblight_syncinfo_t *)&serial_m2s_buffer.rgblight_sync, false);
}
# endif
status0 = TRANSACTION_END;
}
}

#endif

0 comments on commit 71db3e2

Please sign in to comment.