forked from mirrors/qmk_userspace
Add support for ISSI drivers on both sides of a split keyboard (#13842)
* Gets RGB working on a split keyboard with IS31FL3733. Currently needs small tweak to re-enable WS2812 * Added helper function * Trying to integrate the function * Moved functionality into a macro * Swapped conditional for a macro everywhere * Tidying up * More code cleanup * Documentation updates * Fixed formatting via linter * Switching to a function from a macro * Fixed compile error * Fixing WS2812 behavior. UNTESTED. * Updated documentation about the driver addresses. * Fixed code for WS2812 * Trying to add in LED_MATRIX support * Updated effects for LED matrix * Updated third-party effect defines. * Ran format-c on modified files * Apply suggestions from code review Co-authored-by: Ryan <fauxpark@gmail.com> * Move to static inline. Avoids issues with gcc v8+ * Move helper function for LED_matrix to static inline to avoid issues with gcc v8+ Co-authored-by: Vlad Kvitnevskiy <vladkvit@outlook.com> Co-authored-by: Ryan <fauxpark@gmail.com>
This commit is contained in:
parent
7f8faa429e
commit
a29ca1e7f1
33 changed files with 127 additions and 72 deletions
|
@ -17,7 +17,7 @@ bool ALPHAS_MODS(effect_params_t* params) {
|
|||
led_matrix_set_value(i, val1);
|
||||
}
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
return led_matrix_check_finished_leds(led_max);
|
||||
}
|
||||
|
||||
# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
|
|
@ -12,7 +12,7 @@ bool BREATHING(effect_params_t* params) {
|
|||
LED_MATRIX_TEST_LED_FLAGS();
|
||||
led_matrix_set_value(i, val);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
return led_matrix_check_finished_leds(led_max);
|
||||
}
|
||||
|
||||
# endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
|
|
@ -12,5 +12,5 @@ bool effect_runner_dx_dy(effect_params_t* params, dx_dy_f effect_func) {
|
|||
int16_t dy = g_led_config.point[i].y - k_led_matrix_center.y;
|
||||
led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, dx, dy, time));
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
return led_matrix_check_finished_leds(led_max);
|
||||
}
|
||||
|
|
|
@ -13,5 +13,5 @@ bool effect_runner_dx_dy_dist(effect_params_t* params, dx_dy_dist_f effect_func)
|
|||
uint8_t dist = sqrt16(dx * dx + dy * dy);
|
||||
led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, dx, dy, dist, time));
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
return led_matrix_check_finished_leds(led_max);
|
||||
}
|
||||
|
|
|
@ -10,5 +10,5 @@ bool effect_runner_i(effect_params_t* params, i_f effect_func) {
|
|||
LED_MATRIX_TEST_LED_FLAGS();
|
||||
led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, i, time));
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
return led_matrix_check_finished_leds(led_max);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) {
|
|||
uint16_t offset = scale16by8(tick, led_matrix_eeconfig.speed);
|
||||
led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, offset));
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
return led_matrix_check_finished_leds(led_max);
|
||||
}
|
||||
|
||||
#endif // LED_MATRIX_KEYREACTIVE_ENABLED
|
||||
|
|
|
@ -20,7 +20,7 @@ bool effect_runner_reactive_splash(uint8_t start, effect_params_t* params, react
|
|||
}
|
||||
led_matrix_set_value(i, scale8(val, led_matrix_eeconfig.val));
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
return led_matrix_check_finished_leds(led_max);
|
||||
}
|
||||
|
||||
#endif // LED_MATRIX_KEYREACTIVE_ENABLED
|
||||
|
|
|
@ -12,5 +12,5 @@ bool effect_runner_sin_cos_i(effect_params_t* params, sin_cos_i_f effect_func) {
|
|||
LED_MATRIX_TEST_LED_FLAGS();
|
||||
led_matrix_set_value(i, effect_func(led_matrix_eeconfig.val, cos_value, sin_value, i, time));
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
return led_matrix_check_finished_leds(led_max);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ bool SOLID(effect_params_t* params) {
|
|||
LED_MATRIX_TEST_LED_FLAGS();
|
||||
led_matrix_set_value(i, val);
|
||||
}
|
||||
return led_max < DRIVER_LED_TOTAL;
|
||||
return led_matrix_check_finished_leds(led_max);
|
||||
}
|
||||
|
||||
#endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
|
|
@ -156,20 +156,10 @@ uint8_t led_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *l
|
|||
void led_matrix_update_pwm_buffers(void) { led_matrix_driver.flush(); }
|
||||
|
||||
void led_matrix_set_value(int index, uint8_t value) {
|
||||
#if defined(LED_MATRIX_ENABLE) && defined(LED_MATRIX_SPLIT)
|
||||
if (!is_keyboard_left() && index >= k_led_matrix_split[0])
|
||||
# ifdef USE_CIE1931_CURVE
|
||||
led_matrix_driver.set_value(index - k_led_matrix_split[0], pgm_read_byte(&CIE1931_CURVE[value]));
|
||||
# else
|
||||
led_matrix_driver.set_value(index - k_led_matrix_split[0], value);
|
||||
# endif
|
||||
else if (is_keyboard_left() && index < k_led_matrix_split[0])
|
||||
#endif
|
||||
#ifdef USE_CIE1931_CURVE
|
||||
led_matrix_driver.set_value(index, pgm_read_byte(&CIE1931_CURVE[value]));
|
||||
#else
|
||||
led_matrix_driver.set_value(index, value);
|
||||
value = pgm_read_byte(&CIE1931_CURVE[value]);
|
||||
#endif
|
||||
led_matrix_driver.set_value(index, value);
|
||||
}
|
||||
|
||||
void led_matrix_set_value_all(uint8_t value) {
|
||||
|
|
|
@ -38,14 +38,33 @@
|
|||
#endif
|
||||
|
||||
#if defined(LED_MATRIX_LED_PROCESS_LIMIT) && LED_MATRIX_LED_PROCESS_LIMIT > 0 && LED_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL
|
||||
# define LED_MATRIX_USE_LIMITS(min, max) \
|
||||
uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * params->iter; \
|
||||
uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT; \
|
||||
if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL;
|
||||
# if defined(LED_MATRIX_SPLIT)
|
||||
# define LED_MATRIX_USE_LIMITS(min, max)
|
||||
uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * params->iter;
|
||||
uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT;
|
||||
if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL;
|
||||
uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT;
|
||||
if (is_keyboard_left() && (max > k_led_matrix_split[0])) max = k_led_matrix_split[0];
|
||||
if (!(is_keyboard_left()) && (min < k_led_matrix_split[0])) min = k_led_matrix_split[0];
|
||||
# else
|
||||
# define LED_MATRIX_USE_LIMITS(min, max) \
|
||||
uint8_t min = LED_MATRIX_LED_PROCESS_LIMIT * params->iter; \
|
||||
uint8_t max = min + LED_MATRIX_LED_PROCESS_LIMIT; \
|
||||
if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL;
|
||||
# endif
|
||||
#else
|
||||
# define LED_MATRIX_USE_LIMITS(min, max) \
|
||||
uint8_t min = 0; \
|
||||
uint8_t max = DRIVER_LED_TOTAL;
|
||||
# if defined(LED_MATRIX_SPLIT)
|
||||
# define LED_MATRIX_USE_LIMITS(min, max) \
|
||||
uint8_t min = 0; \
|
||||
uint8_t max = DRIVER_LED_TOTAL; \
|
||||
const uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT; \
|
||||
if (is_keyboard_left() && (max > k_led_matrix_split[0])) max = k_led_matrix_split[0]; \
|
||||
if (!(is_keyboard_left()) && (min < k_led_matrix_split[0])) min = k_led_matrix_split[0];
|
||||
# else
|
||||
# define LED_MATRIX_USE_LIMITS(min, max) \
|
||||
uint8_t min = 0; \
|
||||
uint8_t max = DRIVER_LED_TOTAL;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define LED_MATRIX_TEST_LED_FLAGS() \
|
||||
|
@ -147,6 +166,18 @@ typedef struct {
|
|||
void (*flush)(void);
|
||||
} led_matrix_driver_t;
|
||||
|
||||
static inline bool led_matrix_check_finished_leds(uint8_t led_idx) {
|
||||
#if defined(LED_MATRIX_SPLIT)
|
||||
if (is_keyboard_left()) {
|
||||
uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT;
|
||||
return led_idx < k_led_matrix_split[0];
|
||||
} else
|
||||
return led_idx < DRIVER_LED_TOTAL;
|
||||
#else
|
||||
return led_idx < DRIVER_LED_TOTAL;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern const led_matrix_driver_t led_matrix_driver;
|
||||
|
||||
extern led_eeconfig_t led_matrix_eeconfig;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue