summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/action.c4
-rw-r--r--quantum/action_tapping.c78
-rw-r--r--quantum/backlight/backlight.c21
-rw-r--r--quantum/color.c2
-rw-r--r--quantum/color.h52
-rw-r--r--quantum/debounce/none.c10
-rw-r--r--quantum/debounce/sym_defer_g.c15
-rw-r--r--quantum/debounce/sym_eager_pr.c4
-rw-r--r--quantum/debounce/tests/asym_eager_defer_pk_tests.cpp29
-rw-r--r--quantum/debounce/tests/debounce_test_common.cpp25
-rw-r--r--quantum/debounce/tests/debounce_test_common.h5
-rw-r--r--quantum/debounce/tests/none_tests.cpp256
-rw-r--r--quantum/debounce/tests/rules.mk5
-rw-r--r--quantum/debounce/tests/sym_defer_g_tests.cpp18
-rw-r--r--quantum/debounce/tests/sym_defer_pk_tests.cpp18
-rw-r--r--quantum/debounce/tests/sym_defer_pr_tests.cpp18
-rw-r--r--quantum/debounce/tests/sym_eager_pk_tests.cpp18
-rw-r--r--quantum/debounce/tests/sym_eager_pr_tests.cpp18
-rw-r--r--quantum/debounce/tests/testlist.mk1
-rw-r--r--quantum/eeconfig.c6
-rw-r--r--quantum/eeconfig.h2
-rw-r--r--quantum/haptic.c12
-rw-r--r--quantum/keyboard.c23
-rw-r--r--quantum/led_matrix/led_matrix.c33
-rw-r--r--quantum/led_matrix/led_matrix.h56
-rw-r--r--quantum/led_matrix/led_matrix_drivers.c223
-rw-r--r--quantum/led_matrix/led_matrix_types.h15
-rw-r--r--quantum/mousekey.c15
-rw-r--r--quantum/painter/lvgl/qp_lvgl.c11
-rw-r--r--quantum/painter/lvgl/qp_lvgl.h4
-rw-r--r--quantum/painter/qp.c121
-rw-r--r--quantum/painter/qp.h35
-rw-r--r--quantum/painter/qp_draw_ellipse.c12
-rw-r--r--quantum/process_keycode/process_auto_shift.c29
-rw-r--r--quantum/process_keycode/process_auto_shift.h1
-rw-r--r--quantum/quantum.c10
-rw-r--r--quantum/quantum.h4
-rw-r--r--quantum/rgb_matrix/animations/flower_blooming_anim.h53
-rw-r--r--quantum/rgb_matrix/animations/rgb_matrix_effects.inc1
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c54
-rw-r--r--quantum/rgb_matrix/rgb_matrix.h75
-rw-r--r--quantum/rgb_matrix/rgb_matrix_drivers.c132
-rw-r--r--quantum/rgb_matrix/rgb_matrix_types.h15
-rw-r--r--quantum/rgblight/rgblight.c137
-rw-r--r--quantum/rgblight/rgblight.h27
-rw-r--r--quantum/util.h4
-rw-r--r--quantum/velocikey.c40
-rw-r--r--quantum/velocikey.h10
-rw-r--r--quantum/via.c10
49 files changed, 1263 insertions, 504 deletions
diff --git a/quantum/action.c b/quantum/action.c
index 6368f7398c..349250472b 100644
--- a/quantum/action.c
+++ b/quantum/action.c
@@ -374,7 +374,7 @@ void process_action(keyrecord_t *record, action_t action) {
if (is_oneshot_layer_active() && event.pressed &&
(action.kind.id == ACT_USAGE || !(IS_MODIFIER_KEYCODE(action.key.code)
# ifndef NO_ACTION_TAPPING
- || (tap_count == 0 && (action.kind.id == ACT_LMODS_TAP || action.kind.id == ACT_RMODS_TAP))
+ || ((action.kind.id == ACT_LMODS_TAP || action.kind.id == ACT_RMODS_TAP) && (action.layer_tap.code <= MODS_TAP_TOGGLE || tap_count == 0))
# endif
))
# ifdef SWAP_HANDS_ENABLE
@@ -497,7 +497,7 @@ void process_action(keyrecord_t *record, action_t action) {
default:
if (event.pressed) {
if (tap_count > 0) {
-# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
+# ifdef HOLD_ON_OTHER_KEY_PRESS
if (
# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
get_hold_on_other_key_press(get_event_keycode(record->event, false), record) &&
diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c
index f94e5e6f69..8f238490f2 100644
--- a/quantum/action_tapping.c
+++ b/quantum/action_tapping.c
@@ -116,25 +116,26 @@ void action_tapping_process(keyrecord_t record) {
* readable. The conditional definition of tapping_keycode and all the
* conditional uses of it are hidden inside macros named TAP_...
*/
-# if (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) || defined(PERMISSIVE_HOLD_PER_KEY) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
-# define TAP_DEFINE_KEYCODE const uint16_t tapping_keycode = get_record_keycode(&tapping_key, false)
-# else
-# define TAP_DEFINE_KEYCODE
-# endif
+# define TAP_DEFINE_KEYCODE const uint16_t tapping_keycode = get_record_keycode(&tapping_key, false)
# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
# ifdef RETRO_TAPPING_PER_KEY
-# define TAP_GET_RETRO_TAPPING get_retro_tapping(tapping_keycode, &tapping_key)
+# define TAP_GET_RETRO_TAPPING(keyp) get_auto_shifted_key(tapping_keycode, keyp) && get_retro_tapping(tapping_keycode, &tapping_key)
# else
-# define TAP_GET_RETRO_TAPPING true
+# define TAP_GET_RETRO_TAPPING(keyp) get_auto_shifted_key(tapping_keycode, keyp)
# endif
-# define MAYBE_RETRO_SHIFTING(ev) (TAP_GET_RETRO_TAPPING && (RETRO_SHIFT + 0) != 0 && TIMER_DIFF_16((ev).time, tapping_key.event.time) < (RETRO_SHIFT + 0))
+/* Used to extend TAPPING_TERM:
+ * indefinitely if RETRO_SHIFT does not have a value
+ * to RETRO_SHIFT if RETRO_SHIFT is set
+ * for possibly retro shifted keys.
+ */
+# define MAYBE_RETRO_SHIFTING(ev, keyp) (get_auto_shifted_key(tapping_keycode, keyp) && TAP_GET_RETRO_TAPPING(keyp) && ((RETRO_SHIFT + 0) == 0 || TIMER_DIFF_16((ev).time, tapping_key.event.time) < (RETRO_SHIFT + 0)))
# define TAP_IS_LT IS_QK_LAYER_TAP(tapping_keycode)
# define TAP_IS_MT IS_QK_MOD_TAP(tapping_keycode)
# define TAP_IS_RETRO IS_RETRO(tapping_keycode)
# else
-# define TAP_GET_RETRO_TAPPING false
-# define MAYBE_RETRO_SHIFTING(ev) false
+# define TAP_GET_RETRO_TAPPING(keyp) false
+# define MAYBE_RETRO_SHIFTING(ev, kp) false
# define TAP_IS_LT false
# define TAP_IS_MT false
# define TAP_IS_RETRO false
@@ -187,20 +188,19 @@ bool process_tapping(keyrecord_t *keyp) {
return true;
}
+# if (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)) || defined(PERMISSIVE_HOLD_PER_KEY) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
TAP_DEFINE_KEYCODE;
+# endif
// process "pressed" tapping key state
if (tapping_key.event.pressed) {
- if (WITHIN_TAPPING_TERM(event) || MAYBE_RETRO_SHIFTING(event)) {
+ if (WITHIN_TAPPING_TERM(event) || MAYBE_RETRO_SHIFTING(event, keyp)) {
if (IS_NOEVENT(event)) {
// early return for tick events
return true;
}
if (tapping_key.tap.count == 0) {
if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
-# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
- retroshift_swap_times();
-# endif
// first tap!
ac_dprintf("Tapping: First tap(0->1).\n");
tapping_key.tap.count = 1;
@@ -218,28 +218,12 @@ bool process_tapping(keyrecord_t *keyp) {
*/
// clang-format off
else if (
+ !event.pressed && waiting_buffer_typed(event) &&
(
- !event.pressed && waiting_buffer_typed(event) &&
- TAP_GET_PERMISSIVE_HOLD
- )
- // Causes nested taps to not wait past TAPPING_TERM/RETRO_SHIFT
- // unnecessarily and fixes them for Layer Taps.
- || (TAP_GET_RETRO_TAPPING &&
- (
- // Rolled over the two keys.
- (tapping_key.tap.interrupted == true && (
- (TAP_IS_LT && TAP_GET_HOLD_ON_OTHER_KEY_PRESS) ||
- (TAP_IS_MT && TAP_GET_HOLD_ON_OTHER_KEY_PRESS)
- )
- )
- // Makes Retro Shift ignore the default behavior of
- // MTs and LTs on nested taps below TAPPING_TERM or RETRO_SHIFT
- || (
- TAP_IS_RETRO
- && (event.key.col != tapping_key.event.key.col || event.key.row != tapping_key.event.key.row)
- && !event.pressed && waiting_buffer_typed(event)
- )
- )
+ TAP_GET_PERMISSIVE_HOLD ||
+ // Causes nested taps to not wait past TAPPING_TERM/RETRO_SHIFT
+ // unnecessarily and fixes them for Layer Taps.
+ TAP_GET_RETRO_TAPPING(keyp)
)
) {
// clang-format on
@@ -284,10 +268,16 @@ bool process_tapping(keyrecord_t *keyp) {
process_record(keyp);
return true;
} else {
- // set interrupted flag when other key preesed during tapping
+ // set interrupted flag when other key pressed during tapping
if (event.pressed) {
tapping_key.tap.interrupted = true;
- if (TAP_GET_HOLD_ON_OTHER_KEY_PRESS) {
+ if (TAP_GET_HOLD_ON_OTHER_KEY_PRESS
+# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
+ // Auto Shift cannot evaluate this early
+ // Retro Shift uses the hold action for all nested taps even without HOLD_ON_OTHER_KEY_PRESS, so this is fine to skip
+ && !(MAYBE_RETRO_SHIFTING(event, keyp) && get_auto_shifted_key(get_record_keycode(keyp, false), keyp))
+# endif
+ ) {
ac_dprintf("Tapping: End. No tap. Interfered by pressed key\n");
process_record(&tapping_key);
tapping_key = (keyrecord_t){0};
@@ -332,6 +322,9 @@ bool process_tapping(keyrecord_t *keyp) {
return true;
} else {
ac_dprintf("Tapping: key event while last tap(>0).\n");
+# if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
+ retroshift_swap_times();
+# endif
process_record(keyp);
return true;
}
@@ -388,7 +381,7 @@ bool process_tapping(keyrecord_t *keyp) {
}
// process "released" tapping key state
else {
- if (WITHIN_TAPPING_TERM(event) || MAYBE_RETRO_SHIFTING(event)) {
+ if (WITHIN_TAPPING_TERM(event) || MAYBE_RETRO_SHIFTING(event, keyp)) {
if (IS_NOEVENT(event)) {
// early return for tick events
return true;
@@ -506,9 +499,16 @@ void waiting_buffer_scan_tap(void) {
return;
}
+# if (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
+ TAP_DEFINE_KEYCODE;
+# endif
for (uint8_t i = waiting_buffer_tail; i != waiting_buffer_head; i = (i + 1) % WAITING_BUFFER_SIZE) {
keyrecord_t *candidate = &waiting_buffer[i];
- if (IS_EVENT(candidate->event) && KEYEQ(candidate->event.key, tapping_key.event.key) && !candidate->event.pressed && WITHIN_TAPPING_TERM(candidate->event)) {
+ // clang-format off
+ if (IS_EVENT(candidate->event) && KEYEQ(candidate->event.key, tapping_key.event.key) && !candidate->event.pressed && (
+ WITHIN_TAPPING_TERM(waiting_buffer[i].event) || MAYBE_RETRO_SHIFTING(waiting_buffer[i].event, &tapping_key)
+ )) {
+ // clang-format on
tapping_key.tap.count = 1;
candidate->tap.count = 1;
process_record(&tapping_key);
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c
index 9d9f944f5d..e89b34696c 100644
--- a/quantum/backlight/backlight.c
+++ b/quantum/backlight/backlight.c
@@ -22,10 +22,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
backlight_config_t backlight_config;
+#ifndef BACKLIGHT_DEFAULT_ON
+# define BACKLIGHT_DEFAULT_ON true
+#endif
+
#ifndef BACKLIGHT_DEFAULT_LEVEL
# define BACKLIGHT_DEFAULT_LEVEL BACKLIGHT_LEVELS
#endif
+#ifndef BACKLIGHT_DEFAULT_BREATHING
+# define BACKLIGHT_DEFAULT_BREATHING false
+#else
+# undef BACKLIGHT_DEFAULT_BREATHING
+# define BACKLIGHT_DEFAULT_BREATHING true
+#endif
+
#ifdef BACKLIGHT_BREATHING
// TODO: migrate to backlight_config_t
static uint8_t breathing_period = BREATHING_PERIOD;
@@ -172,13 +183,9 @@ void eeconfig_update_backlight_current(void) {
}
void eeconfig_update_backlight_default(void) {
- backlight_config.enable = 1;
-#ifdef BACKLIGHT_DEFAULT_BREATHING
- backlight_config.breathing = 1;
-#else
- backlight_config.breathing = 0;
-#endif
- backlight_config.level = BACKLIGHT_DEFAULT_LEVEL;
+ backlight_config.enable = BACKLIGHT_DEFAULT_ON;
+ backlight_config.breathing = BACKLIGHT_DEFAULT_BREATHING;
+ backlight_config.level = BACKLIGHT_DEFAULT_LEVEL;
eeconfig_update_backlight(backlight_config.raw);
}
diff --git a/quantum/color.c b/quantum/color.c
index 767155c9db..395383f428 100644
--- a/quantum/color.c
+++ b/quantum/color.c
@@ -110,7 +110,7 @@ RGB hsv_to_rgb_nocie(HSV hsv) {
}
#ifdef RGBW
-void convert_rgb_to_rgbw(LED_TYPE *led) {
+void convert_rgb_to_rgbw(rgb_led_t *led) {
// Determine lowest value in all three colors, put that into
// the white channel and then shift all colors by that amount
led->w = MIN(led->r, MIN(led->g, led->b));
diff --git a/quantum/color.h b/quantum/color.h
index 135ad623b5..00a3bfb3f8 100644
--- a/quantum/color.h
+++ b/quantum/color.h
@@ -18,6 +18,7 @@
#include <stdint.h>
#include <stdbool.h>
+#include "util.h"
// clang-format off
@@ -73,22 +74,6 @@
// clang-format on
-#if defined(__GNUC__)
-# define PACKED __attribute__((__packed__))
-#else
-# define PACKED
-#endif
-
-#if defined(_MSC_VER)
-# pragma pack(push, 1)
-#endif
-
-#ifdef RGBW
-# define LED_TYPE cRGBW
-#else
-# define LED_TYPE RGB
-#endif
-
#define WS2812_BYTE_ORDER_RGB 0
#define WS2812_BYTE_ORDER_GRB 1
#define WS2812_BYTE_ORDER_BGR 2
@@ -97,26 +82,7 @@
# define WS2812_BYTE_ORDER WS2812_BYTE_ORDER_GRB
#endif
-typedef struct PACKED {
-#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB)
- uint8_t g;
- uint8_t r;
- uint8_t b;
-#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_RGB)
- uint8_t r;
- uint8_t g;
- uint8_t b;
-#elif (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_BGR)
- uint8_t b;
- uint8_t g;
- uint8_t r;
-#endif
-} cRGB;
-
-typedef cRGB RGB;
-
-// WS2812 specific layout
-typedef struct PACKED {
+typedef struct PACKED rgb_led_t {
#if (WS2812_BYTE_ORDER == WS2812_BYTE_ORDER_GRB)
uint8_t g;
uint8_t r;
@@ -130,21 +96,21 @@ typedef struct PACKED {
uint8_t g;
uint8_t r;
#endif
+#ifdef RGBW
uint8_t w;
-} cRGBW;
+#endif
+} rgb_led_t;
-typedef struct PACKED {
+typedef rgb_led_t RGB;
+
+typedef struct PACKED HSV {
uint8_t h;
uint8_t s;
uint8_t v;
} HSV;
-#if defined(_MSC_VER)
-# pragma pack(pop)
-#endif
-
RGB hsv_to_rgb(HSV hsv);
RGB hsv_to_rgb_nocie(HSV hsv);
#ifdef RGBW
-void convert_rgb_to_rgbw(LED_TYPE *led);
+void convert_rgb_to_rgbw(rgb_led_t *led);
#endif
diff --git a/quantum/debounce/none.c b/quantum/debounce/none.c
index 1b8b1dc13a..0a8ccfc4ee 100644
--- a/quantum/debounce/none.c
+++ b/quantum/debounce/none.c
@@ -20,9 +20,15 @@
void debounce_init(uint8_t num_rows) {}
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
- bool cooked_changed = memcmp(raw, cooked, sizeof(matrix_row_t) * num_rows) != 0;
+ bool cooked_changed = false;
- memcpy(cooked, raw, sizeof(matrix_row_t) * num_rows);
+ if (changed) {
+ size_t matrix_size = num_rows * sizeof(matrix_row_t);
+ if (memcmp(cooked, raw, matrix_size) != 0) {
+ memcpy(cooked, raw, matrix_size);
+ cooked_changed = true;
+ }
+ }
return cooked_changed;
}
diff --git a/quantum/debounce/sym_defer_g.c b/quantum/debounce/sym_defer_g.c
index 25e18890af..d96758fab3 100644
--- a/quantum/debounce/sym_defer_g.c
+++ b/quantum/debounce/sym_defer_g.c
@@ -24,6 +24,12 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state.
# define DEBOUNCE 5
#endif
+// Maximum debounce: 255ms
+#if DEBOUNCE > UINT8_MAX
+# undef DEBOUNCE
+# define DEBOUNCE UINT8_MAX
+#endif
+
#if DEBOUNCE > 0
static bool debouncing = false;
static fast_timer_t debouncing_time;
@@ -36,11 +42,10 @@ bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
if (changed) {
debouncing = true;
debouncing_time = timer_read_fast();
- }
-
- if (debouncing && timer_elapsed_fast(debouncing_time) >= DEBOUNCE) {
- if (memcmp(cooked, raw, sizeof(matrix_row_t) * num_rows) != 0) {
- memcpy(cooked, raw, sizeof(matrix_row_t) * num_rows);
+ } else if (debouncing && timer_elapsed_fast(debouncing_time) >= DEBOUNCE) {
+ size_t matrix_size = num_rows * sizeof(matrix_row_t);
+ if (memcmp(cooked, raw, matrix_size) != 0) {
+ memcpy(cooked, raw, matrix_size);
cooked_changed = true;
}
debouncing = false;
diff --git a/quantum/debounce/sym_eager_pr.c b/quantum/debounce/sym_eager_pr.c
index ccc5d20fa2..6cd9308aff 100644
--- a/quantum/debounce/sym_eager_pr.c
+++ b/quantum/debounce/sym_eager_pr.c
@@ -128,8 +128,8 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui
if (existing_row != raw_row) {
if (*debounce_pointer == DEBOUNCE_ELAPSED) {
*debounce_pointer = DEBOUNCE;
- cooked[row] = raw_row;
- cooked_changed |= cooked[row] ^ raw[row];
+ cooked_changed |= cooked[row] ^ raw_row;
+ cooked[row] = raw_row;
counters_need_update = true;
}
}
diff --git a/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp b/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp
index 44b4fe1956..6737f499ab 100644
--- a/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp
+++ b/quantum/debounce/tests/asym_eager_defer_pk_tests.cpp
@@ -392,3 +392,32 @@ TEST_F(DebounceTest, OneKeyDelayedScan8) {
time_jumps_ = true;
runEvents();
}
+
+TEST_F(DebounceTest, AsyncTickOneKeyShort1) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ /* Release key after 1ms delay */
+ {1, {{0, 1, UP}}, {}},
+
+ /*
+ * Until the eager timer on DOWN is observed to finish, the defer timer
+ * on UP can't start. There's no workaround for this because it's not
+ * possible to debounce an event that isn't being tracked.
+ *
+ * sym_defer_pk has the same problem but the test has to track that the
+ * key changed state so the DOWN timer is always allowed to finish
+ * before starting the UP timer.
+ */
+ {5, {}, {}},
+
+ {10, {}, {{0, 1, UP}}}, /* 5ms+5ms after DOWN at time 0 */
+ /* Press key again after 1ms delay */
+ {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ });
+ /*
+ * Debounce implementations should never read the timer more than once per invocation
+ */
+ async_time_jumps_ = DEBOUNCE;
+ runEvents();
+}
diff --git a/quantum/debounce/tests/debounce_test_common.cpp b/quantum/debounce/tests/debounce_test_common.cpp
index b11378b286..fd4b6f01a6 100644
--- a/quantum/debounce/tests/debounce_test_common.cpp
+++ b/quantum/debounce/tests/debounce_test_common.cpp
@@ -26,8 +26,12 @@ extern "C" {
#include "debounce.h"
#include "timer.h"
-void set_time(uint32_t t);
-void advance_time(uint32_t ms);
+void simulate_async_tick(uint32_t t);
+void reset_access_counter(void);
+uint32_t current_access_counter(void);
+uint32_t timer_read_internal(void);
+void set_time(uint32_t t);
+void advance_time(uint32_t ms);
}
void DebounceTest::addEvents(std::initializer_list<DebounceTestEvent> events) {
@@ -58,6 +62,7 @@ void DebounceTest::runEventsInternal() {
/* Initialise keyboard with start time (offset to avoid testing at 0) and all keys UP */
debounce_init(MATRIX_ROWS);
set_time(time_offset_);
+ simulate_async_tick(async_time_jumps_);
std::fill(std::begin(input_matrix_), std::end(input_matrix_), 0);
std::fill(std::begin(output_matrix_), std::end(output_matrix_), 0);
@@ -70,9 +75,9 @@ void DebounceTest::runEventsInternal() {
advance_time(1);
} else {
/* Fast forward to the time for this event, calling debounce() with no changes */
- ASSERT_LT((time_offset_ + event.time_) - timer_read_fast(), 60000) << "Test tries to advance more than 1 minute of time";
+ ASSERT_LT((time_offset_ + event.time_) - timer_read_internal(), 60000) << "Test tries to advance more than 1 minute of time";
- while (timer_read_fast() != time_offset_ + event.time_) {
+ while (timer_read_internal() != time_offset_ + event.time_) {
runDebounce(false);
checkCookedMatrix(false, "debounce() modified cooked matrix");
advance_time(1);
@@ -124,14 +129,20 @@ void DebounceTest::runDebounce(bool changed) {
std::copy(std::begin(input_matrix_), std::end(input_matrix_), std::begin(raw_matrix_));
std::copy(std::begin(output_matrix_), std::end(output_matrix_), std::begin(cooked_matrix_));
+ reset_access_counter();
+
bool cooked_changed = debounce(raw_matrix_, cooked_matrix_, MATRIX_ROWS, changed);
if (!std::equal(std::begin(input_matrix_), std::end(input_matrix_), std::begin(raw_matrix_))) {
FAIL() << "Fatal error: debounce() modified raw matrix at " << strTime() << "\ninput_matrix: changed=" << changed << "\n" << strMatrix(input_matrix_) << "\nraw_matrix:\n" << strMatrix(raw_matrix_);
}
- if (std::equal(std::begin(output_matrix_), std::end(output_matrix_), std::begin(cooked_matrix_)) && cooked_changed) {
- FAIL() << "Fatal error: debounce() did detect a wrong cooked matrix change at " << strTime() << "\noutput_matrix: cooked_changed=" << cooked_changed << "\n" << strMatrix(output_matrix_) << "\ncooked_matrix:\n" << strMatrix(cooked_matrix_);
+ if (std::equal(std::begin(output_matrix_), std::end(output_matrix_), std::begin(cooked_matrix_)) == cooked_changed) {
+ FAIL() << "Fatal error: debounce() reported a wrong cooked matrix change result at " << strTime() << "\noutput_matrix: cooked_changed=" << cooked_changed << "\n" << strMatrix(output_matrix_) << "\ncooked_matrix:\n" << strMatrix(cooked_matrix_);
+ }
+
+ if (current_access_counter() > 1) {
+ FAIL() << "Fatal error: debounce() read the timer multiple times, which is not allowed, at " << strTime() << "\ntimer: access_count=" << current_access_counter() << "\noutput_matrix: cooked_changed=" << cooked_changed << "\n" << strMatrix(output_matrix_) << "\ncooked_matrix:\n" << strMatrix(cooked_matrix_);
}
}
@@ -144,7 +155,7 @@ void DebounceTest::checkCookedMatrix(bool changed, const std::string &error_mess
std::string DebounceTest::strTime() {
std::stringstream text;
- text << "time " << (timer_read_fast() - time_offset_) << " (extra_iterations=" << extra_iterations_ << ", auto_advance_time=" << auto_advance_time_ << ")";
+ text << "time " << (timer_read_internal() - time_offset_) << " (extra_iterations=" << extra_iterations_ << ", auto_advance_time=" << auto_advance_time_ << ")";
return text.str();
}
diff --git a/quantum/debounce/tests/debounce_test_common.h b/quantum/debounce/tests/debounce_test_common.h
index 7319abfbf3..ebbe340c05 100644
--- a/quantum/debounce/tests/debounce_test_common.h
+++ b/quantum/debounce/tests/debounce_test_common.h
@@ -54,8 +54,9 @@ class DebounceTest : public ::testing::Test {
void addEvents(std::initializer_list<DebounceTestEvent> events);
void runEvents();
- fast_timer_t time_offset_ = 7777;
- bool time_jumps_ = false;
+ fast_timer_t time_offset_ = 7777;
+ bool time_jumps_ = false;
+ fast_timer_t async_time_jumps_ = 0;
private:
static bool directionValue(Direction direction);
diff --git a/quantum/debounce/tests/none_tests.cpp b/quantum/debounce/tests/none_tests.cpp
new file mode 100644
index 0000000000..69fdd02101
--- /dev/null
+++ b/quantum/debounce/tests/none_tests.cpp
@@ -0,0 +1,256 @@
+/* Copyright 2021 Simon Arlott
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gtest/gtest.h"
+
+#include "debounce_test_common.h"
+
+TEST_F(DebounceTest, OneKeyShort1) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+
+ {5, {}, {}},
+ /* 0ms delay (fast scan rate) */
+ {5, {{0, 1, UP}}, {{0, 1, UP}}},
+
+ {10, {}, {}},
+ });
+ runEvents();
+}
+
+TEST_F(DebounceTest, OneKeyShort2) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+
+ {5, {}, {}},
+ /* 1ms delay */
+ {6, {{0, 1, UP}}, {{0, 1, UP}}},
+
+ {11, {}, {}},
+ });
+ runEvents();
+}
+
+TEST_F(DebounceTest, OneKeyShort3) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+
+ {5, {}, {}},
+ /* 2ms delay */
+ {7, {{0, 1, UP}}, {{0, 1, UP}}},
+
+ {12, {}, {}},
+ });
+ runEvents();
+}
+
+TEST_F(DebounceTest, OneKeyTooQuick1) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ /* Release key exactly on the debounce time */
+ {5, {{0, 1, UP}}, {{0, 1, UP}}},
+ });
+ runEvents();
+}
+
+TEST_F(DebounceTest, OneKeyTooQuick2) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+
+ {5, {}, {}},
+ {6, {{0, 1, UP}}, {{0, 1, UP}}},
+
+ /* Press key exactly on the debounce time */
+ {11, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ });
+ runEvents();
+}
+
+TEST_F(DebounceTest, OneKeyBouncing1) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ {1, {{0, 1, UP}}, {{0, 1, UP}}},
+ {2, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ {3, {{0, 1, UP}}, {{0, 1, UP}}},
+ {4, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ {5, {{0, 1, UP}}, {{0, 1, UP}}},
+ {6, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ {11, {{0, 1, UP}}, {{0, 1, UP}}}, /* 5ms after DOWN at time 7 */
+ });
+ runEvents();
+}
+
+TEST_F(DebounceTest, OneKeyBouncing2) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ {5, {}, {}},
+ {6, {{0, 1, UP}}, {{0, 1, UP}}},
+ {7, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ {8, {{0, 1, UP}}, {{0, 1, UP}}},
+ {9, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ {10, {{0, 1, UP}}, {{0, 1, UP}}},
+ {15, {}, {}}, /* 5ms after UP at time 10 */
+ });
+ runEvents();
+}
+
+TEST_F(DebounceTest, OneKeyLong) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+
+ {5, {}, {}},
+
+ {25, {{0, 1, UP}}, {{0, 1, UP}}},
+
+ {30, {}, {}},
+
+ {50, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+
+ {55, {}, {}},
+ });
+ runEvents();
+}
+
+TEST_F(DebounceTest, TwoKeysShort) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ {1, {{0, 2, DOWN}}, {{0, 2, DOWN}}},
+
+ {6, {}, {}},
+
+ {7, {{0, 1, UP}}, {{0, 1, UP}}},
+ {8, {{0, 2, UP}}, {{0, 2, UP}}},
+
+ {13, {}, {}},
+ });
+ runEvents();
+}
+
+TEST_F(DebounceTest, TwoKeysSimultaneous1) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}, {0, 2, DOWN}}, {{0, 1, DOWN}, {0, 2, DOWN}}},
+
+ {5, {}, {}},
+ {6, {{0, 1, UP}, {0, 2, UP}}, {{0, 1, UP}, {0, 2, UP}}},
+
+ {11, {}, {}},
+ });
+ runEvents();
+}
+
+TEST_F(DebounceTest, TwoKeysSimultaneous2) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ {1, {{0, 2, DOWN}}, {{0, 2, DOWN}}},
+
+ {5, {}, {}},
+ {6, {}, {}},
+ {7, {{0, 1, UP}}, {{0, 1, UP}}},
+ {8, {{0, 2, UP}}, {{0, 2, UP}}},
+
+ {13, {}, {}},
+ });
+ runEvents();
+}
+
+TEST_F(DebounceTest, OneKeyDelayedScan1) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+
+ /* Processing is very late */
+ {300, {}, {}},
+ /* Immediately release key */
+ {300, {{0, 1, UP}}, {{0, 1, UP}}},
+
+ {305, {}, {}},
+ });
+ time_jumps_ = true;
+ runEvents();
+}
+
+TEST_F(DebounceTest, OneKeyDelayedScan2) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+
+ /* Processing is very late */
+ {300, {}, {}},
+ /* Release key after 1ms */
+ {301, {{0, 1, UP}}, {{0, 1, UP}}},
+
+ {306, {}, {}},
+ });
+ time_jumps_ = true;
+ runEvents();
+}
+
+TEST_F(DebounceTest, OneKeyDelayedScan3) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+
+ /* Release key before debounce expires */
+ {300, {{0, 1, UP}}, {{0, 1, UP}}},
+ });
+ time_jumps_ = true;
+ runEvents();
+}
+
+TEST_F(DebounceTest, OneKeyDelayedScan4) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+
+ /* Processing is a bit late */
+ {50, {}, {}},
+ /* Release key after 1ms */
+ {51, {{0, 1, UP}}, {{0, 1, UP}}},
+
+ {56, {}, {}},
+ });
+ time_jumps_ = true;
+ runEvents();
+}
+
+TEST_F(DebounceTest, AsyncTickOneKeyShort1) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+
+ {5, {}, {}},
+ /* 0ms delay (fast scan rate) */
+ {5, {{0, 1, UP}}, {{0, 1, UP}}},
+
+ {10, {}, {}},
+ });
+ /*
+ * Debounce implementations should never read the timer more than once per invocation
+ */
+ async_time_jumps_ = DEBOUNCE;
+ runEvents();
+}
diff --git a/quantum/debounce/tests/rules.mk b/quantum/debounce/tests/rules.mk
index 8318b1c668..bbc362d4c7 100644
--- a/quantum/debounce/tests/rules.mk
+++ b/quantum/debounce/tests/rules.mk
@@ -18,6 +18,11 @@ DEBOUNCE_COMMON_DEFS := -DMATRIX_ROWS=4 -DMATRIX_COLS=10 -DDEBOUNCE=5
DEBOUNCE_COMMON_SRC := $(QUANTUM_PATH)/debounce/tests/debounce_test_common.cpp \
$(PLATFORM_PATH)/$(PLATFORM_KEY)/timer.c
+debounce_none_DEFS := $(DEBOUNCE_COMMON_DEFS)
+debounce_none_SRC := $(DEBOUNCE_COMMON_SRC) \
+ $(QUANTUM_PATH)/debounce/none.c \
+ $(QUANTUM_PATH)/debounce/tests/none_tests.cpp
+
debounce_sym_defer_g_DEFS := $(DEBOUNCE_COMMON_DEFS)
debounce_sym_defer_g_SRC := $(DEBOUNCE_COMMON_SRC) \
$(QUANTUM_PATH)/debounce/sym_defer_g.c \
diff --git a/quantum/debounce/tests/sym_defer_g_tests.cpp b/quantum/debounce/tests/sym_defer_g_tests.cpp
index 73d3d45e30..33e8b17852 100644
--- a/quantum/debounce/tests/sym_defer_g_tests.cpp
+++ b/quantum/debounce/tests/sym_defer_g_tests.cpp
@@ -236,3 +236,21 @@ TEST_F(DebounceTest, OneKeyDelayedScan4) {
time_jumps_ = true;
runEvents();
}
+
+TEST_F(DebounceTest, AsyncTickOneKeyShort1) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {}},
+
+ {5, {}, {{0, 1, DOWN}}},
+ /* 0ms delay (fast scan rate) */
+ {5, {{0, 1, UP}}, {}},
+
+ {10, {}, {{0, 1, UP}}},
+ });
+ /*
+ * Debounce implementations should never read the timer more than once per invocation
+ */
+ async_time_jumps_ = DEBOUNCE;
+ runEvents();
+}
diff --git a/quantum/debounce/tests/sym_defer_pk_tests.cpp b/quantum/debounce/tests/sym_defer_pk_tests.cpp
index 7542c2dad4..864b7afcc4 100644
--- a/quantum/debounce/tests/sym_defer_pk_tests.cpp
+++ b/quantum/debounce/tests/sym_defer_pk_tests.cpp
@@ -238,3 +238,21 @@ TEST_F(DebounceTest, OneKeyDelayedScan4) {
time_jumps_ = true;
runEvents();
}
+
+TEST_F(DebounceTest, AsyncTickOneKeyShort1) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {}},
+
+ {5, {}, {{0, 1, DOWN}}},
+ /* 0ms delay (fast scan rate) */
+ {5, {{0, 1, UP}}, {}},
+
+ {10, {}, {{0, 1, UP}}},
+ });
+ /*
+ * Debounce implementations should never read the timer more than once per invocation
+ */
+ async_time_jumps_ = DEBOUNCE;
+ runEvents();
+}
diff --git a/quantum/debounce/tests/sym_defer_pr_tests.cpp b/quantum/debounce/tests/sym_defer_pr_tests.cpp
index 417e1f4ca2..3ed360b966 100644
--- a/quantum/debounce/tests/sym_defer_pr_tests.cpp
+++ b/quantum/debounce/tests/sym_defer_pr_tests.cpp
@@ -236,3 +236,21 @@ TEST_F(DebounceTest, OneKeyDelayedScan4) {
time_jumps_ = true;
runEvents();
}
+
+TEST_F(DebounceTest, AsyncTickOneKeyShort1) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {}},
+
+ {5, {}, {{0, 1, DOWN}}},
+ /* 0ms delay (fast scan rate) */
+ {5, {{0, 1, UP}}, {}},
+
+ {10, {}, {{0, 1, UP}}},
+ });
+ /*
+ * Debounce implementations should never read the timer more than once per invocation
+ */
+ async_time_jumps_ = DEBOUNCE;
+ runEvents();
+}
diff --git a/quantum/debounce/tests/sym_eager_pk_tests.cpp b/quantum/debounce/tests/sym_eager_pk_tests.cpp
index d9a02fe33c..39d5b10d8e 100644
--- a/quantum/debounce/tests/sym_eager_pk_tests.cpp
+++ b/quantum/debounce/tests/sym_eager_pk_tests.cpp
@@ -251,3 +251,21 @@ TEST_F(DebounceTest, OneKeyDelayedScan6) {
time_jumps_ = true;
runEvents();
}
+
+TEST_F(DebounceTest, AsyncTickOneKeyShort1) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ {1, {{0, 1, UP}}, {}},
+
+ {5, {}, {{0, 1, UP}}},
+ /* Press key again after 1ms delay (debounce has not yet finished) */
+ {6, {{0, 1, DOWN}}, {}},
+ {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
+ });
+ /*
+ * Debounce implementations should never read the timer more than once per invocation
+ */
+ async_time_jumps_ = DEBOUNCE;
+ runEvents();
+}
diff --git a/quantum/debounce/tests/sym_eager_pr_tests.cpp b/quantum/debounce/tests/sym_eager_pr_tests.cpp
index e91dd9cb87..9a94807a49 100644
--- a/quantum/debounce/tests/sym_eager_pr_tests.cpp
+++ b/quantum/debounce/tests/sym_eager_pr_tests.cpp
@@ -297,3 +297,21 @@ TEST_F(DebounceTest, OneKeyDelayedScan6) {
time_jumps_ = true;
runEvents();
}
+
+TEST_F(DebounceTest, AsyncTickOneKeyShort1) {
+ addEvents({
+ /* Time, Inputs, Outputs */
+ {0, {{0, 1, DOWN}}, {{0, 1, DOWN}}},
+ {1, {{0, 1, UP}}, {}},
+
+ {5, {}, {{0, 1, UP}}},
+ /* Press key again after 1ms delay (debounce has not yet finished) */
+ {6, {{0, 1, DOWN}}, {}},
+ {10, {}, {{0, 1, DOWN}}}, /* 5ms after UP at time 5 */
+ });
+ /*
+ * Debounce implementations should never read the timer more than once per invocation
+ */
+ async_time_jumps_ = DEBOUNCE;
+ runEvents();
+}
diff --git a/quantum/debounce/tests/testlist.mk b/quantum/debounce/tests/testlist.mk
index f7bd520698..dd53633343 100644
--- a/quantum/debounce/tests/testlist.mk
+++ b/quantum/debounce/tests/testlist.mk
@@ -1,4 +1,5 @@
TEST_LIST += \
+ debounce_none \
debounce_sym_defer_g \
debounce_sym_defer_pk \
debounce_sym_defer_pr \
diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c
index 84de025f0e..d9eea13758 100644
--- a/quantum/eeconfig.c
+++ b/quantum/eeconfig.c
@@ -49,15 +49,15 @@ void eeconfig_init_quantum(void) {
eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
eeprom_update_byte(EECONFIG_DEBUG, 0);
- eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0);
- default_layer_state = 0;
+ default_layer_state = (layer_state_t)1 << 0;
+ eeprom_update_byte(EECONFIG_DEFAULT_LAYER, default_layer_state);
// Enable oneshot and autocorrect by default: 0b0001 0100 0000 0000
eeprom_update_word(EECONFIG_KEYMAP, 0x1400);
eeprom_update_byte(EECONFIG_BACKLIGHT, 0);
eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default
eeprom_update_dword(EECONFIG_RGBLIGHT, 0);
eeprom_update_byte(EECONFIG_RGBLIGHT_EXTENDED, 0);
- eeprom_update_byte(EECONFIG_VELOCIKEY, 0);
+ eeprom_update_byte(EECONFIG_UNUSED, 0);
eeprom_update_byte(EECONFIG_UNICODEMODE, 0);
eeprom_update_byte(EECONFIG_STENOMODE, 0);
uint64_t dummy = 0;
diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h
index 85e80226b6..34d85cb91e 100644
--- a/quantum/eeconfig.h
+++ b/quantum/eeconfig.h
@@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define EECONFIG_HANDEDNESS (uint8_t *)14
#define EECONFIG_KEYBOARD (uint32_t *)15
#define EECONFIG_USER (uint32_t *)19
-#define EECONFIG_VELOCIKEY (uint8_t *)23
+#define EECONFIG_UNUSED (uint8_t *)23
// Mutually exclusive
#define EECONFIG_LED_MATRIX (uint32_t *)24
#define EECONFIG_RGB_MATRIX (uint64_t *)24
diff --git a/quantum/haptic.c b/quantum/haptic.c
index 5a700dca38..a1fea29625 100644
--- a/quantum/haptic.c
+++ b/quantum/haptic.c
@@ -20,6 +20,7 @@
#include "debug.h"
#include "usb_device_state.h"
#include "gpio.h"
+#include "keyboard.h"
#ifdef HAPTIC_DRV2605L
# include "drv2605l.h"
@@ -58,6 +59,11 @@ static void set_haptic_config_enable(bool enabled) {
}
void haptic_init(void) {
+// only initialize on secondary boards if the user desires
+#if defined(SPLIT_KEYBOARD) && !defined(SPLIT_HAPTIC_ENABLE)
+ if (!is_keyboard_master()) return;
+#endif
+
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
@@ -99,8 +105,12 @@ void haptic_init(void) {
void haptic_task(void) {
#ifdef HAPTIC_SOLENOID
+// Only run task on seconary boards if the user desires
+# if defined(SPLIT_KEYBOARD) && !defined(SPLIT_HAPTIC_ENABLE)
+ if (!is_keyboard_master()) return;
+# endif
solenoid_check();
-#endif
+#endif // HAPTIC_SOLENOID
}
void eeconfig_debug_haptic(void) {
diff --git a/quantum/keyboard.c b/quantum/keyboard.c
index c2ca15d52d..86a1a9fea3 100644
--- a/quantum/keyboard.c
+++ b/quantum/keyboard.c
@@ -99,9 +99,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef ST7565_ENABLE
# include "st7565.h"
#endif
-#ifdef VELOCIKEY_ENABLE
-# include "velocikey.h"
-#endif
#ifdef VIA_ENABLE
# include "via.h"
#endif
@@ -395,9 +392,6 @@ void quantum_init(void) {
#if defined(UNICODE_COMMON_ENABLE)
unicode_input_mode_init();
#endif
-#ifdef HAPTIC_ENABLE
- haptic_init();
-#endif
}
/** \brief keyboard_init
@@ -462,6 +456,9 @@ void keyboard_init(void) {
#ifdef BLUETOOTH_ENABLE
bluetooth_init();
#endif
+#ifdef HAPTIC_ENABLE
+ haptic_init();
+#endif
#if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE)
debug_enable = true;
@@ -617,10 +614,6 @@ void quantum_task(void) {
decay_wpm();
#endif
-#ifdef HAPTIC_ENABLE
- haptic_task();
-#endif
-
#ifdef DIP_SWITCH_ENABLE
dip_switch_read(false);
#endif
@@ -712,12 +705,6 @@ void keyboard_task(void) {
midi_task();
#endif
-#ifdef VELOCIKEY_ENABLE
- if (velocikey_enabled()) {
- velocikey_decelerate();
- }
-#endif
-
#ifdef JOYSTICK_ENABLE
joystick_task();
#endif
@@ -726,5 +713,9 @@ void keyboard_task(void) {
bluetooth_task();
#endif
+#ifdef HAPTIC_ENABLE
+ haptic_task();
+#endif
+
led_task();
}
diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c
index 1676a60aa3..c13ca94077 100644
--- a/quantum/led_matrix/led_matrix.c
+++ b/quantum/led_matrix/led_matrix.c
@@ -58,35 +58,6 @@ const led_point_t k_led_matrix_center = LED_MATRIX_CENTER;
// -----End led effect includes macros-------
// ------------------------------------------
-#ifndef LED_MATRIX_TIMEOUT
-# define LED_MATRIX_TIMEOUT 0
-#endif
-
-#if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
-# undef LED_MATRIX_MAXIMUM_BRIGHTNESS
-# define LED_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
-#endif
-
-#if !defined(LED_MATRIX_VAL_STEP)
-# define LED_MATRIX_VAL_STEP 8
-#endif
-
-#if !defined(LED_MATRIX_SPD_STEP)
-# define LED_MATRIX_SPD_STEP 16
-#endif
-
-#if !defined(LED_MATRIX_DEFAULT_MODE)
-# define LED_MATRIX_DEFAULT_MODE LED_MATRIX_SOLID
-#endif
-
-#if !defined(LED_MATRIX_DEFAULT_VAL)
-# define LED_MATRIX_DEFAULT_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS
-#endif
-
-#if !defined(LED_MATRIX_DEFAULT_SPD)
-# define LED_MATRIX_DEFAULT_SPD UINT8_MAX / 2
-#endif
-
// globals
led_eeconfig_t led_matrix_eeconfig; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
uint32_t g_led_timer;
@@ -126,7 +97,7 @@ void eeconfig_update_led_matrix(void) {
void eeconfig_update_led_matrix_default(void) {
dprintf("eeconfig_update_led_matrix_default\n");
- led_matrix_eeconfig.enable = 1;
+ led_matrix_eeconfig.enable = LED_MATRIX_DEFAULT_ON;
led_matrix_eeconfig.mode = LED_MATRIX_DEFAULT_MODE;
led_matrix_eeconfig.val = LED_MATRIX_DEFAULT_VAL;
led_matrix_eeconfig.speed = LED_MATRIX_DEFAULT_SPD;
@@ -632,7 +603,7 @@ void led_matrix_decrease_speed(void) {
void led_matrix_set_flags_eeprom_helper(led_flags_t flags, bool write_to_eeprom) {
led_matrix_eeconfig.flags = flags;
eeconfig_flag_led_matrix(write_to_eeprom);
- dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.flags);
+ dprintf("led matrix set flags [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.flags);
}
led_flags_t led_matrix_get_flags(void) {
diff --git a/quantum/led_matrix/led_matrix.h b/quantum/led_matrix/led_matrix.h
index c2533ca49c..77d4f558ac 100644
--- a/quantum/led_matrix/led_matrix.h
+++ b/quantum/led_matrix/led_matrix.h
@@ -25,16 +25,60 @@
#include "led_matrix_types.h"
#include "keyboard.h"
-#ifdef IS31FL3731
+#if defined(LED_MATRIX_IS31FL3218)
+# include "is31fl3218-simple.h"
+#elif defined(LED_MATRIX_IS31FL3731)
# include "is31fl3731-simple.h"
-#elif defined(IS31FLCOMMON)
-# include "is31flcommon.h"
#endif
-#ifdef IS31FL3733
+#ifdef LED_MATRIX_IS31FL3733
# include "is31fl3733-simple.h"
#endif
-#ifdef CKLED2001
-# include "ckled2001-simple.h"
+#ifdef LED_MATRIX_IS31FL3736
+# include "is31fl3736-simple.h"
+#endif
+#ifdef LED_MATRIX_IS31FL3737
+# include "is31fl3737-simple.h"
+#endif
+#ifdef LED_MATRIX_IS31FL3741
+# include "is31fl3741-simple.h"
+#endif
+#if defined(IS31FLCOMMON)
+# include "is31flcommon.h"
+#endif
+#ifdef LED_MATRIX_SNLED27351
+# include "snled27351-simple.h"
+#endif
+
+#ifndef LED_MATRIX_TIMEOUT
+# define LED_MATRIX_TIMEOUT 0
+#endif
+
+#ifndef LED_MATRIX_MAXIMUM_BRIGHTNESS
+# define LED_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
+#endif
+
+#ifndef LED_MATRIX_VAL_STEP
+# define LED_MATRIX_VAL_STEP 8
+#endif
+
+#ifndef LED_MATRIX_SPD_STEP
+# define LED_MATRIX_SPD_STEP 16
+#endif
+
+#ifndef LED_MATRIX_DEFAULT_ON
+# define LED_MATRIX_DEFAULT_ON true
+#endif
+
+#ifndef LED_MATRIX_DEFAULT_MODE
+# define LED_MATRIX_DEFAULT_MODE LED_MATRIX_SOLID
+#endif
+
+#ifndef LED_MATRIX_DEFAULT_VAL
+# define LED_MATRIX_DEFAULT_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS
+#endif
+
+#ifndef LED_MATRIX_DEFAULT_SPD
+# define LED_MATRIX_DEFAULT_SPD UINT8_MAX / 2
#endif
#ifndef LED_MATRIX_LED_FLUSH_LIMIT
diff --git a/quantum/led_matrix/led_matrix_drivers.c b/quantum/led_matrix/led_matrix_drivers.c
index 13c8935d11..f52870aea5 100644
--- a/quantum/led_matrix/led_matrix_drivers.c
+++ b/quantum/led_matrix/led_matrix_drivers.c
@@ -25,13 +25,16 @@
* in their own files.
*/
-#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FLCOMMON) || defined(CKLED2001)
+#if defined(LED_MATRIX_IS31FL3218) || defined(LED_MATRIX_IS31FL3731) || defined(LED_MATRIX_IS31FL3733) || defined(LED_MATRIX_IS31FL3736) || defined(LED_MATRIX_IS31FL3737) || defined(LED_MATRIX_IS31FL3741) || defined(IS31FLCOMMON) || defined(LED_MATRIX_SNLED27351)
# include "i2c_master.h"
static void init(void) {
i2c_init();
-# if defined(IS31FL3731)
+# if defined(LED_MATRIX_IS31FL3218)
+ is31fl3218_init();
+
+# elif defined(LED_MATRIX_IS31FL3731)
is31fl3731_init(LED_DRIVER_ADDR_1);
# if defined(LED_DRIVER_ADDR_2)
is31fl3731_init(LED_DRIVER_ADDR_2);
@@ -43,7 +46,7 @@ static void init(void) {
# endif
# endif
-# elif defined(IS31FL3733)
+# elif defined(LED_MATRIX_IS31FL3733)
# if !defined(LED_DRIVER_SYNC_1)
# define LED_DRIVER_SYNC_1 0
# endif
@@ -67,6 +70,42 @@ static void init(void) {
# endif
# endif
+# elif defined(LED_MATRIX_IS31FL3736)
+ is31fl3736_init(LED_DRIVER_ADDR_1);
+# if defined(LED_DRIVER_ADDR_2)
+ is31fl3736_init(LED_DRIVER_ADDR_2);
+# if defined(LED_DRIVER_ADDR_3)
+ is31fl3736_init(LED_DRIVER_ADDR_3);
+# if defined(LED_DRIVER_ADDR_4)
+ is31fl3736_init(LED_DRIVER_ADDR_4);
+# endif
+# endif
+# endif
+
+# elif defined(LED_MATRIX_IS31FL3737)
+ is31fl3737_init(LED_DRIVER_ADDR_1);
+# if defined(LED_DRIVER_ADDR_2)
+ is31fl3737_init(LED_DRIVER_ADDR_2);
+# if defined(LED_DRIVER_ADDR_3)
+ is31fl3737_init(LED_DRIVER_ADDR_3);
+# if defined(LED_DRIVER_ADDR_4)
+ is31fl3737_init(LED_DRIVER_ADDR_4);
+# endif
+# endif
+# endif
+
+# elif defined(LED_MATRIX_IS31FL3741)
+ is31fl3741_init(LED_DRIVER_ADDR_1);
+# if defined(LED_DRIVER_ADDR_2)
+ is31fl3741_init(LED_DRIVER_ADDR_2);
+# if defined(LED_DRIVER_ADDR_3)
+ is31fl3741_init(LED_DRIVER_ADDR_3);
+# if defined(LED_DRIVER_ADDR_4)
+ is31fl3741_init(LED_DRIVER_ADDR_4);
+# endif
+# endif
+# endif
+
# elif defined(IS31FLCOMMON)
IS31FL_common_init(DRIVER_ADDR_1, ISSI_SSR_1);
# if defined(LED_DRIVER_ADDR_2)
@@ -78,38 +117,49 @@ static void init(void) {
# endif
# endif
# endif
-# elif defined(CKLED2001)
+# elif defined(LED_MATRIX_SNLED27351)
# if defined(LED_DRIVER_SHUTDOWN_PIN)
setPinOutput(LED_DRIVER_SHUTDOWN_PIN);
writePinHigh(LED_DRIVER_SHUTDOWN_PIN);
# endif
- ckled2001_init(DRIVER_ADDR_1);
+ snled27351_init(DRIVER_ADDR_1);
# if defined(DRIVER_ADDR_2)
- ckled2001_init(DRIVER_ADDR_2);
+ snled27351_init(DRIVER_ADDR_2);
# if defined(DRIVER_ADDR_3)
- ckled2001_init(DRIVER_ADDR_3);
+ snled27351_init(DRIVER_ADDR_3);
# if defined(DRIVER_ADDR_4)
- ckled2001_init(DRIVER_ADDR_4);
+ snled27351_init(DRIVER_ADDR_4);
# endif
# endif
# endif
# endif
for (int index = 0; index < LED_MATRIX_LED_COUNT; index++) {
-# if defined(IS31FL3731)
+# if defined(LED_MATRIX_IS31FL3218)
+ is31fl3218_set_led_control_register(index, true);
+# elif defined(LED_MATRIX_IS31FL3731)
is31fl3731_set_led_control_register(index, true);
-# elif defined(IS31FL3733)
+# elif defined(LED_MATRIX_IS31FL3733)
is31fl3733_set_led_control_register(index, true);
+# elif defined(LED_MATRIX_IS31FL3736)
+ is31fl3736_set_led_control_register(index, true);
+# elif defined(LED_MATRIX_IS31FL3737)
+ is31fl3737_set_led_control_register(index, true);
+# elif defined(LED_MATRIX_IS31FL3741)
+ is31fl3741_set_led_control_register(index, true);
# elif defined(IS31FLCOMMON)
IS31FL_simple_set_scaling_buffer(index, true);
-# elif defined(CKLED2001)
- ckled2001_set_led_control_register(index, true);
+# elif defined(LED_MATRIX_SNLED27351)
+ snled27351_set_led_control_register(index, true);
# endif
}
// This actually updates the LED drivers
-# if defined(IS31FL3731)
+# if defined(LED_MATRIX_IS31FL3218)
+ is31fl3218_update_led_control_registers();
+
+# elif defined(LED_MATRIX_IS31FL3731)
is31fl3731_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
# if defined(LED_DRIVER_ADDR_2)
is31fl3731_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
@@ -121,7 +171,7 @@ static void init(void) {
# endif
# endif
-# elif defined(IS31FL3733)
+# elif defined(LED_MATRIX_IS31FL3733)
is31fl3733_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
# if defined(LED_DRIVER_ADDR_2)
is31fl3733_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
@@ -133,6 +183,42 @@ static void init(void) {
# endif
# endif
+# elif defined(LED_MATRIX_IS31FL3736)
+ is31fl3736_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
+# if defined(LED_DRIVER_ADDR_2)
+ is31fl3736_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
+# if defined(LED_DRIVER_ADDR_3)
+ is31fl3736_update_led_control_registers(LED_DRIVER_ADDR_3, 2);
+# if defined(LED_DRIVER_ADDR_4)
+ is31fl3736_update_led_control_registers(LED_DRIVER_ADDR_4, 3);
+# endif
+# endif
+# endif
+
+# elif defined(LED_MATRIX_IS31FL3737)
+ is31fl3737_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
+# if defined(LED_DRIVER_ADDR_2)
+ is31fl3737_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
+# if defined(LED_DRIVER_ADDR_3)
+ is31fl3737_update_led_control_registers(LED_DRIVER_ADDR_3, 2);
+# if defined(LED_DRIVER_ADDR_4)
+ is31fl3737_update_led_control_registers(LED_DRIVER_ADDR_4, 3);
+# endif
+# endif
+# endif
+
+# elif defined(LED_MATRIX_IS31FL3741)
+ is31fl3741_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
+# if defined(LED_DRIVER_ADDR_2)
+ is31fl3741_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
+# if defined(LED_DRIVER_ADDR_3)
+ is31fl3741_update_led_control_registers(LED_DRIVER_ADDR_3, 2);
+# if defined(LED_DRIVER_ADDR_4)
+ is31fl3741_update_led_control_registers(LED_DRIVER_ADDR_4, 3);
+# endif
+# endif
+# endif
+
# elif defined(IS31FLCOMMON)
# ifdef ISSI_MANUAL_SCALING
IS31FL_set_manual_scaling_buffer();
@@ -147,21 +233,33 @@ static void init(void) {
# endif
# endif
# endif
-# elif defined(CKLED2001)
- ckled2001_update_led_control_registers(DRIVER_ADDR_1, 0);
+# elif defined(LED_MATRIX_SNLED27351)
+ snled27351_update_led_control_registers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
- ckled2001_update_led_control_registers(DRIVER_ADDR_2, 1);
+ snled27351_update_led_control_registers(DRIVER_ADDR_2, 1);
# if defined(DRIVER_ADDR_3)
- ckled2001_update_led_control_registers(DRIVER_ADDR_3, 2);
+ snled27351_update_led_control_registers(DRIVER_ADDR_3, 2);
# if defined(DRIVER_ADDR_4)
- ckled2001_update_led_control_registers(DRIVER_ADDR_4, 3);
+ snled27351_update_led_control_registers(DRIVER_ADDR_4, 3);
# endif
# endif
# endif
# endif
}
-# if defined(IS31FL3731)
+# if defined(LED_MATRIX_IS31FL3218)
+static void flush(void) {
+ is31fl3218_update_pwm_buffers();
+}
+
+const led_matrix_driver_t led_matrix_driver = {
+ .init = init,
+ .flush = flush,
+ .set_value = is31fl3218_set_value,
+ .set_value_all = is31fl3218_set_value_all,
+};
+
+# elif defined(LED_MATRIX_IS31FL3731)
static void flush(void) {
is31fl3731_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
# if defined(LED_DRIVER_ADDR_2)
@@ -176,13 +274,13 @@ static void flush(void) {
}
const led_matrix_driver_t led_matrix_driver = {
- .init = init,
- .flush = flush,
- .set_value = is31fl3731_set_value,
+ .init = init,
+ .flush = flush,
+ .set_value = is31fl3731_set_value,
.set_value_all = is31fl3731_set_value_all,
};
-# elif defined(IS31FL3733)
+# elif defined(LED_MATRIX_IS31FL3733)
static void flush(void) {
is31fl3733_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
# if defined(LED_DRIVER_ADDR_2)
@@ -203,6 +301,69 @@ const led_matrix_driver_t led_matrix_driver = {
.set_value_all = is31fl3733_set_value_all,
};
+# elif defined(LED_MATRIX_IS31FL3736)
+static void flush(void) {
+ is31fl3736_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
+# if defined(LED_DRIVER_ADDR_2)
+ is31fl3736_update_pwm_buffers(LED_DRIVER_ADDR_2, 1);
+# if defined(LED_DRIVER_ADDR_3)
+ is31fl3736_update_pwm_buffers(LED_DRIVER_ADDR_3, 2);
+# if defined(LED_DRIVER_ADDR_4)
+ is31fl3736_update_pwm_buffers(LED_DRIVER_ADDR_4, 3);
+# endif
+# endif
+# endif
+}
+
+const led_matrix_driver_t led_matrix_driver = {
+ .init = init,
+ .flush = flush,
+ .set_value = is31fl3736_set_value,
+ .set_value_all = is31fl3736_set_value_all,
+};
+
+# elif defined(LED_MATRIX_IS31FL3737)
+static void flush(void) {
+ is31fl3737_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
+# if defined(LED_DRIVER_ADDR_2)
+ is31fl3737_update_pwm_buffers(LED_DRIVER_ADDR_2, 1);
+# if defined(LED_DRIVER_ADDR_3)
+ is31fl3737_update_pwm_buffers(LED_DRIVER_ADDR_3, 2);
+# if defined(LED_DRIVER_ADDR_4)
+ is31fl3737_update_pwm_buffers(LED_DRIVER_ADDR_4, 3);
+# endif
+# endif
+# endif
+}
+
+const led_matrix_driver_t led_matrix_driver = {
+ .init = init,
+ .flush = flush,
+ .set_value = is31fl3737_set_value,
+ .set_value_all = is31fl3737_set_value_all,
+};
+
+# elif defined(LED_MATRIX_IS31FL3741)
+static void flush(void) {
+ is31fl3741_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
+# if defined(LED_DRIVER_ADDR_2)
+ is31fl3741_update_pwm_buffers(LED_DRIVER_ADDR_2, 1);
+# if defined(LED_DRIVER_ADDR_3)
+ is31fl3741_update_pwm_buffers(LED_DRIVER_ADDR_3, 2);
+# if defined(LED_DRIVER_ADDR_4)
+ is31fl3741_update_pwm_buffers(LED_DRIVER_ADDR_4, 3);
+# endif
+# endif
+# endif
+}
+
+const led_matrix_driver_t led_matrix_driver = {
+ .init = init,
+ .flush = flush,
+ .set_value = is31fl3741_set_value,
+ .set_value_all = is31fl3741_set_value_all,
+};
+
# elif defined(IS31FLCOMMON)
static void flush(void) {
IS31FL_common_update_pwm_register(DRIVER_ADDR_1, 0);
@@ -223,15 +384,15 @@ const led_matrix_driver_t led_matrix_driver = {
.set_value = IS31FL_simple_set_brightness,
.set_value_all = IS31FL_simple_set_brigntness_all,
};
-# elif defined(CKLED2001)
+# elif defined(LED_MATRIX_SNLED27351)
static void flush(void) {
- ckled2001_update_pwm_buffers(DRIVER_ADDR_1, 0);
+ snled27351_update_pwm_buffers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
- ckled2001_update_pwm_buffers(DRIVER_ADDR_2, 1);
+ snled27351_update_pwm_buffers(DRIVER_ADDR_2, 1);
# if defined(DRIVER_ADDR_3)
- ckled2001_update_pwm_buffers(DRIVER_ADDR_3, 2);
+ snled27351_update_pwm_buffers(DRIVER_ADDR_3, 2);
# if defined(DRIVER_ADDR_4)
- ckled2001_update_pwm_buffers(DRIVER_ADDR_4, 3);
+ snled27351_update_pwm_buffers(DRIVER_ADDR_4, 3);
# endif
# endif
# endif
@@ -240,8 +401,8 @@ static void flush(void) {
const led_matrix_driver_t led_matrix_driver = {
.init = init,
.flush = flush,
- .set_value = ckled2001_set_value,
- .set_value_all = ckled2001_set_value_all,
+ .set_value = snled27351_set_value,
+ .set_value_all = snled27351_set_value_all,
};
# endif
#endif
diff --git a/quantum/led_matrix/led_matrix_types.h b/quantum/led_matrix/led_matrix_types.h
index 6709a558bb..5a516ceb10 100644
--- a/quantum/led_matrix/led_matrix_types.h
+++ b/quantum/led_matrix/led_matrix_types.h
@@ -18,16 +18,7 @@
#include <stdint.h>
#include <stdbool.h>
-
-#if defined(__GNUC__)
-# define PACKED __attribute__((__packed__))
-#else
-# define PACKED
-#endif
-
-#if defined(_MSC_VER)
-# pragma pack(push, 1)
-#endif
+#include "util.h"
#if defined(LED_MATRIX_KEYPRESSES) || defined(LED_MATRIX_KEYRELEASES)
# define LED_MATRIX_KEYREACTIVE_ENABLED
@@ -92,7 +83,3 @@ typedef union {
} led_eeconfig_t;
_Static_assert(sizeof(led_eeconfig_t) == sizeof(uint32_t), "LED Matrix EECONFIG out of spec.");
-
-#if defined(_MSC_VER)
-# pragma pack(pop)
-#endif
diff --git a/quantum/mousekey.c b/quantum/mousekey.c
index c982a2f40b..3910811752 100644
--- a/quantum/mousekey.c
+++ b/quantum/mousekey.c
@@ -389,7 +389,20 @@ void mousekey_on(uint8_t code) {
if (mouse_timer == 0) {
mouse_timer = timer_read();
}
-# endif /* #ifdef MK_KINETIC_SPEED */
+# endif
+
+# ifndef MOUSEKEY_INERTIA
+ // If mouse report is not zero, the current mousekey press is overlapping
+ // with another. Restart acceleration for smoother directional transition.
+ if (mouse_report.x || mouse_report.y || mouse_report.h || mouse_report.v) {
+# ifdef MK_KINETIC_SPEED
+ mouse_timer = timer_read() - (MOUSEKEY_INTERVAL << 2);
+# else
+ mousekey_repeat = MOUSEKEY_MOVE_DELTA;
+ mousekey_wheel_repeat = MOUSEKEY_WHEEL_DELTA;
+# endif
+ }
+# endif // ifndef MOUSEKEY_INERTIA
# ifdef MOUSEKEY_INERTIA
diff --git a/quantum/painter/lvgl/qp_lvgl.c b/quantum/painter/lvgl/qp_lvgl.c
index 280aeaf91f..877b2652c6 100644
--- a/quantum/painter/lvgl/qp_lvgl.c
+++ b/quantum/painter/lvgl/qp_lvgl.c
@@ -81,8 +81,8 @@ bool qp_lvgl_attach(painter_device_t device) {
lvgl_state_t *lv_task_handler_state = &lvgl_states[1];
lv_task_handler_state->fnc_id = 1;
- lv_task_handler_state->delay_ms = 5;
- lv_task_handler_state->defer_token = defer_exec_advanced(lvgl_executors, 2, 5, tick_task_callback, lv_task_handler_state);
+ lv_task_handler_state->delay_ms = QP_LVGL_TASK_PERIOD;
+ lv_task_handler_state->defer_token = defer_exec_advanced(lvgl_executors, 2, QP_LVGL_TASK_PERIOD, tick_task_callback, lv_task_handler_state);
if (lv_task_handler_state->defer_token == INVALID_DEFERRED_TOKEN) {
qp_dprintf("qp_lvgl_attach: fail (could not set up qp_lvgl executor)\n");
@@ -96,13 +96,14 @@ bool qp_lvgl_attach(painter_device_t device) {
// Set up lvgl display buffer
static lv_disp_draw_buf_t draw_buf;
// Allocate a buffer for 1/10 screen size
- const size_t count_required = driver->panel_width * driver->panel_height / 10;
- color_buffer = color_buffer ? realloc(color_buffer, sizeof(lv_color_t) * count_required) : malloc(sizeof(lv_color_t) * count_required);
- if (!color_buffer) {
+ const size_t count_required = driver->panel_width * driver->panel_height / 10;
+ void * new_color_buffer = realloc(color_buffer, sizeof(lv_color_t) * count_required);
+ if (!new_color_buffer) {
qp_dprintf("qp_lvgl_attach: fail (could not set up memory buffer)\n");
qp_lvgl_detach();
return false;
}
+ color_buffer = new_color_buffer;
memset(color_buffer, 0, sizeof(lv_color_t) * count_required);
// Initialize the display buffer.
lv_disp_draw_buf_init(&draw_buf, color_buffer, NULL, count_required);
diff --git a/quantum/painter/lvgl/qp_lvgl.h b/quantum/painter/lvgl/qp_lvgl.h
index d9ad5e8df1..87ba3ac0a5 100644
--- a/quantum/painter/lvgl/qp_lvgl.h
+++ b/quantum/painter/lvgl/qp_lvgl.h
@@ -7,6 +7,10 @@
#include "qp.h"
#include "lvgl.h"
+#ifndef QP_LVGL_TASK_PERIOD
+# define QP_LVGL_TASK_PERIOD 5
+#endif
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Quantum Painter - LVGL External API
diff --git a/quantum/painter/qp.c b/quantum/painter/qp.c
index f27bb7892a..609163afe2 100644
--- a/quantum/painter/qp.c
+++ b/quantum/painter/qp.c
@@ -131,49 +131,124 @@ bool qp_flush(painter_device_t device) {
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Quantum Painter External API: qp_get_geometry
+// Quantum Painter External API: qp_get_*
-void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height, painter_rotation_t *rotation, uint16_t *offset_x, uint16_t *offset_y) {
- qp_dprintf("qp_get_geometry: entry\n");
+uint16_t qp_get_width(painter_device_t device) {
+ qp_dprintf("qp_get_width: entry\n");
painter_driver_t *driver = (painter_driver_t *)device;
- if (!driver) {
- qp_dprintf("qp_get_geometry: fail (pointer to NULL)\n");
- return;
+ if (!driver || !driver->validate_ok) {
+ qp_dprintf("qp_get_width: fail (invalid driver)\n");
+ return 0;
+ }
+
+ uint16_t width;
+ switch (driver->rotation) {
+ default:
+ case QP_ROTATION_0:
+ case QP_ROTATION_180:
+ width = driver->panel_width;
+
+ case QP_ROTATION_90:
+ case QP_ROTATION_270:
+ width = driver->panel_height;
+ }
+
+ qp_dprintf("qp_get_width: ok\n");
+ return width;
+}
+
+uint16_t qp_get_height(painter_device_t device) {
+ qp_dprintf("qp_get_height: entry\n");
+ painter_driver_t *driver = (painter_driver_t *)device;
+
+ if (!driver || !driver->validate_ok) {
+ qp_dprintf("qp_get_height: fail (invalid driver)\n");
+ return 0;
}
+ uint16_t height;
switch (driver->rotation) {
default:
case QP_ROTATION_0:
case QP_ROTATION_180:
- if (width) {
- *width = driver->panel_width;
- }
- if (height) {
- *height = driver->panel_height;
- }
- break;
+ height = driver->panel_height;
+
case QP_ROTATION_90:
case QP_ROTATION_270:
- if (width) {
- *width = driver->panel_height;
- }
- if (height) {
- *height = driver->panel_width;
- }
- break;
+ height = driver->panel_width;
+ }
+
+ qp_dprintf("qp_get_height: ok\n");
+ return height;
+}
+
+painter_rotation_t qp_get_rotation(painter_device_t device) {
+ qp_dprintf("qp_get_rotation: entry\n");
+ painter_driver_t *driver = (painter_driver_t *)device;
+
+ if (!driver || !driver->validate_ok) {
+ qp_dprintf("qp_get_rotation: fail (invalid driver)\n");
+ return QP_ROTATION_0;
+ }
+
+ qp_dprintf("qp_get_rotation: ok\n");
+ return driver->rotation;
+}
+
+uint16_t qp_get_offset_x(painter_device_t device) {
+ qp_dprintf("qp_get_offset_x: entry\n");
+ painter_driver_t *driver = (painter_driver_t *)device;
+
+ if (!driver || !driver->validate_ok) {
+ qp_dprintf("qp_get_offset_x: fail (invalid driver)\n");
+ return 0;
+ }
+
+ qp_dprintf("qp_get_offset_x: ok\n");
+ return driver->offset_x;
+}
+
+uint16_t qp_get_offset_y(painter_device_t device) {
+ qp_dprintf("qp_get_offset_y: entry\n");
+ painter_driver_t *driver = (painter_driver_t *)device;
+
+ if (!driver || !driver->validate_ok) {
+ qp_dprintf("qp_get_offset_y: fail (invalid driver)\n");
+ return 0;
+ }
+
+ qp_dprintf("qp_get_offset_y: ok\n");
+ return driver->offset_y;
+}
+
+void qp_get_geometry(painter_device_t device, uint16_t *width, uint16_t *height, painter_rotation_t *rotation, uint16_t *offset_x, uint16_t *offset_y) {
+ qp_dprintf("qp_geometry: entry\n");
+ painter_driver_t *driver = (painter_driver_t *)device;
+
+ if (!driver || !driver->validate_ok) {
+ qp_dprintf("qp_geometry: fail (invalid driver)\n");
+ return;
+ }
+
+ if (width) {
+ *width = qp_get_width(device);
+ }
+
+ if (height) {
+ *height = qp_get_height(device);
}
if (rotation) {
- *rotation = driver->rotation;
+ *rotation = qp_get_rotation(device);
}
if (offset_x) {
- *offset_x = driver->offset_x;
+ *offset_x = qp_get_offset_x(device);
}
if (offset_y) {
- *offset_y = driver->offset_y;
+ *offset_y = qp_get_offset_y(device);
}
qp_dprintf("qp_get_geometry: ok\n");
diff --git a/quantum/painter/qp.h b/quantum/painter/qp.h
index 7222d3b413..68cb40aa59 100644
--- a/quantum/painter/qp.h
+++ b/quantum/painter/qp.h
@@ -176,6 +176,41 @@ bool qp_clear(painter_device_t device);
bool qp_flush(painter_device_t device);
/**
+ * Retrieves the width of the display.
+ *
+ * @param device[in] the handle of the device to control
+ */
+uint16_t qp_get_width(painter_device_t device);
+
+/**
+ * Retrieves the height of the display.
+ *
+ * @param device[in] the handle of the device to control
+ */
+uint16_t qp_get_height(painter_device_t device);
+
+/**
+ * Retrieves the rotation of the display.
+ *
+ * @param device[in] the handle of the device to control
+ */
+painter_rotation_t qp_get_rotation(painter_device_t device);
+
+/**
+ * Retrieves the x-offset of the display.
+ *
+ * @param device[in] the handle of the device to control
+ */
+uint16_t qp_get_offset_x(painter_device_t device);
+
+/**
+ * Retrieves the y-offset of the display.
+ *
+ * @param device[in] the handle of the device to control
+ */
+uint16_t qp_get_offset_y(painter_device_t device);
+
+/**
* Retrieves the size, rotation, and offsets for the display.
*
* @note Any arguments of NULL will be ignored.
diff --git a/quantum/painter/qp_draw_ellipse.c b/quantum/painter/qp_draw_ellipse.c
index e912a3e91f..9e77bca8b0 100644
--- a/quantum/painter/qp_draw_ellipse.c
+++ b/quantum/painter/qp_draw_ellipse.c
@@ -67,10 +67,10 @@ bool qp_ellipse(painter_device_t device, uint16_t x, uint16_t y, uint16_t sizex,
return false;
}
- int16_t aa = ((int16_t)sizex) * ((int16_t)sizex);
- int16_t bb = ((int16_t)sizey) * ((int16_t)sizey);
- int16_t fa = 4 * ((int16_t)aa);
- int16_t fb = 4 * ((int16_t)bb);
+ int32_t aa = ((int32_t)sizex) * ((int32_t)sizex);
+ int32_t bb = ((int32_t)sizey) * ((int32_t)sizey);
+ int32_t fa = 4 * aa;
+ int32_t fb = 4 * bb;
int16_t dx = 0;
int16_t dy = ((int16_t)sizey);
@@ -83,7 +83,7 @@ bool qp_ellipse(painter_device_t device, uint16_t x, uint16_t y, uint16_t sizex,
}
bool ret = true;
- for (int16_t delta = (2 * bb) + (aa * (1 - (2 * sizey))); bb * dx <= aa * dy; dx++) {
+ for (int32_t delta = (2 * bb) + (aa * (1 - (2 * sizey))); bb * dx <= aa * dy; dx++) {
if (!qp_ellipse_helper_impl(device, x, y, dx, dy, filled)) {
ret = false;
break;
@@ -98,7 +98,7 @@ bool qp_ellipse(painter_device_t device, uint16_t x, uint16_t y, uint16_t sizex,
dx = sizex;
dy = 0;
- for (int16_t delta = (2 * aa) + (bb * (1 - (2 * sizex))); aa * dy <= bb * dx; dy++) {
+ for (int32_t delta = (2 * aa) + (bb * (1 - (2 * sizex))); aa * dy <= bb * dx; dy++) {
if (!qp_ellipse_helper_impl(device, x, y, dx, dy, filled)) {
ret = false;
break;
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c
index 9b78214e43..28a21c4b67 100644
--- a/quantum/process_keycode/process_auto_shift.c
+++ b/quantum/process_keycode/process_auto_shift.c
@@ -66,7 +66,7 @@ __attribute__((weak)) bool get_custom_auto_shifted_key(uint16_t keycode, keyreco
return false;
}
-/** \brief Called on physical press, returns whether is Auto Shift key */
+/** \brief Called on physical press, returns whether key is an Auto Shift key */
__attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
#ifndef NO_AUTO_SHIFT_ALPHA
@@ -178,9 +178,8 @@ static bool autoshift_press(uint16_t keycode, uint16_t now, keyrecord_t *record)
}
// Store record to be sent to user functions if there's no release record then.
- autoshift_lastrecord = *record;
- autoshift_lastrecord.event.pressed = false;
- autoshift_lastrecord.event.time = 0;
+ autoshift_lastrecord = *record;
+ autoshift_lastrecord.event.time = 0;
// clang-format off
#if defined(AUTO_SHIFT_REPEAT) || defined(AUTO_SHIFT_REPEAT_PER_KEY)
if (keycode == autoshift_lastkey &&
@@ -409,8 +408,12 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
// If Retro Shift is disabled, possible custom actions shouldn't happen.
// clang-format off
#if defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING)
-# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
- const bool is_hold_on_interrupt = get_hold_on_other_key_press(keycode, record);
+# ifdef HOLD_ON_OTHER_KEY_PRESS
+ const bool is_hold_on_interrupt = (IS_QK_MOD_TAP(keycode)
+# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
+ && get_hold_on_other_key_press(keycode, record)
+# endif
+ );
# else
const bool is_hold_on_interrupt = false;
# endif
@@ -450,8 +453,12 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
#endif
) {
// Fixes modifiers not being applied to rolls with AUTO_SHIFT_MODIFIERS set.
-#ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
- if (autoshift_flags.in_progress && get_hold_on_other_key_press(keycode, record)) {
+#ifdef HOLD_ON_OTHER_KEY_PRESS
+ if (autoshift_flags.in_progress
+# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
+ && get_hold_on_other_key_press(keycode, record)
+# endif
+ ) {
autoshift_end(KC_NO, now, false, &autoshift_lastrecord);
}
#endif
@@ -488,10 +495,8 @@ void retroshift_poll_time(keyevent_t *event) {
}
// Used to swap the times of Retro Shifted key and Auto Shift key that interrupted it.
void retroshift_swap_times(void) {
- if (last_retroshift_time != 0 && autoshift_flags.in_progress) {
- uint16_t temp = retroshift_time;
- retroshift_time = last_retroshift_time;
- last_retroshift_time = temp;
+ if (autoshift_flags.in_progress) {
+ autoshift_time = last_retroshift_time;
}
}
#endif
diff --git a/quantum/process_keycode/process_auto_shift.h b/quantum/process_keycode/process_auto_shift.h
index 885a47b533..1353548aa6 100644
--- a/quantum/process_keycode/process_auto_shift.h
+++ b/quantum/process_keycode/process_auto_shift.h
@@ -56,4 +56,5 @@ uint16_t (get_autoshift_timeout)(uint16_t keycode, keyrecord_t *record);
void set_autoshift_timeout(uint16_t timeout);
void autoshift_matrix_scan(void);
bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record);
+bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record);
// clang-format on
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 3323a5adb6..f721ab0a1f 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -68,10 +68,6 @@
# include "process_unicode_common.h"
#endif
-#ifdef VELOCIKEY_ENABLE
-# include "velocikey.h"
-#endif
-
#ifdef AUDIO_ENABLE
# ifndef GOODBYE_SONG
# define GOODBYE_SONG SONG(GOODBYE_SOUND)
@@ -288,9 +284,9 @@ bool process_record_quantum(keyrecord_t *record) {
}
#endif
-#ifdef VELOCIKEY_ENABLE
- if (velocikey_enabled() && record->event.pressed) {
- velocikey_accelerate();
+#ifdef RGBLIGHT_ENABLE
+ if (record->event.pressed) {
+ preprocess_rgblight();
}
#endif
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 4d183e755f..66e4569991 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -209,6 +209,10 @@ extern layer_state_t layer_state;
# include "pointing_device.h"
#endif
+#ifdef MOUSEKEY_ENABLE
+# include "mousekey.h"
+#endif
+
#ifdef CAPS_WORD_ENABLE
# include "caps_word.h"
# include "process_caps_word.h"
diff --git a/quantum/rgb_matrix/animations/flower_blooming_anim.h b/quantum/rgb_matrix/animations/flower_blooming_anim.h
new file mode 100644
index 0000000000..7629fde858
--- /dev/null
+++ b/quantum/rgb_matrix/animations/flower_blooming_anim.h
@@ -0,0 +1,53 @@
+/* Copyright 2023 HorrorTroll <https://github.com/HorrorTroll>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef ENABLE_RGB_MATRIX_FLOWER_BLOOMING
+RGB_MATRIX_EFFECT(FLOWER_BLOOMING)
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+
+typedef HSV (*flower_blooming_f)(HSV hsv, uint8_t i, uint8_t time);
+
+bool effect_runner_bloom(effect_params_t* params, flower_blooming_f effect_func) {
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t time = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed / 10, 1));
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ if (g_led_config.point[i].y > k_rgb_matrix_center.y) {
+ RGB bgr = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
+ rgb_matrix_set_color(i, bgr.b, bgr.g, bgr.r);
+ } else {
+ RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ }
+ }
+ return rgb_matrix_check_finished_leds(led_max);
+}
+
+static HSV FLOWER_BLOOMING_math(HSV hsv, uint8_t i, uint8_t time) {
+ if (g_led_config.point[i].y > k_rgb_matrix_center.y)
+ hsv.h = g_led_config.point[i].x * 3 - g_led_config.point[i].y * 3 + time;
+ else
+ hsv.h = g_led_config.point[i].x * 3 - g_led_config.point[i].y * 3 - time;
+ return hsv;
+}
+
+bool FLOWER_BLOOMING(effect_params_t* params) {
+ return effect_runner_bloom(params, &FLOWER_BLOOMING_math);
+}
+
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // ENABLE_RGB_MATRIX_FLOWER_BLOOMING
diff --git a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc
index ac7bac428d..df34718838 100644
--- a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc
+++ b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc
@@ -21,6 +21,7 @@
#include "dual_beacon_anim.h"
#include "rainbow_beacon_anim.h"
#include "rainbow_pinwheels_anim.h"
+#include "flower_blooming_anim.h"
#include "raindrops_anim.h"
#include "jellybean_raindrops_anim.h"
#include "hue_breathing_anim.h"
diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c
index 96be615162..8e69616a0e 100644
--- a/quantum/rgb_matrix/rgb_matrix.c
+++ b/quantum/rgb_matrix/rgb_matrix.c
@@ -60,56 +60,6 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) {
// -----End rgb effect includes macros-------
// ------------------------------------------
-#ifndef RGB_MATRIX_TIMEOUT
-# define RGB_MATRIX_TIMEOUT 0
-#endif
-
-#if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
-# undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
-# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
-#endif
-
-#if !defined(RGB_MATRIX_HUE_STEP)
-# define RGB_MATRIX_HUE_STEP 8
-#endif
-
-#if !defined(RGB_MATRIX_SAT_STEP)
-# define RGB_MATRIX_SAT_STEP 16
-#endif
-
-#if !defined(RGB_MATRIX_VAL_STEP)
-# define RGB_MATRIX_VAL_STEP 16
-#endif
-
-#if !defined(RGB_MATRIX_SPD_STEP)
-# define RGB_MATRIX_SPD_STEP 16
-#endif
-
-#if !defined(RGB_MATRIX_DEFAULT_MODE)
-# ifdef ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
-# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT
-# else
-// fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace
-# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_SOLID_COLOR
-# endif
-#endif
-
-#if !defined(RGB_MATRIX_DEFAULT_HUE)
-# define RGB_MATRIX_DEFAULT_HUE 0
-#endif
-
-#if !defined(RGB_MATRIX_DEFAULT_SAT)
-# define RGB_MATRIX_DEFAULT_SAT UINT8_MAX
-#endif
-
-#if !defined(RGB_MATRIX_DEFAULT_VAL)
-# define RGB_MATRIX_DEFAULT_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS
-#endif
-
-#if !defined(RGB_MATRIX_DEFAULT_SPD)
-# define RGB_MATRIX_DEFAULT_SPD UINT8_MAX / 2
-#endif
-
// globals
rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
uint32_t g_rgb_timer;
@@ -149,7 +99,7 @@ void eeconfig_update_rgb_matrix(void) {
void eeconfig_update_rgb_matrix_default(void) {
dprintf("eeconfig_update_rgb_matrix_default\n");
- rgb_matrix_config.enable = 1;
+ rgb_matrix_config.enable = RGB_MATRIX_DEFAULT_ON;
rgb_matrix_config.mode = RGB_MATRIX_DEFAULT_MODE;
rgb_matrix_config.hsv = (HSV){RGB_MATRIX_DEFAULT_HUE, RGB_MATRIX_DEFAULT_SAT, RGB_MATRIX_DEFAULT_VAL};
rgb_matrix_config.speed = RGB_MATRIX_DEFAULT_SPD;
@@ -736,7 +686,7 @@ void rgb_matrix_decrease_speed(void) {
void rgb_matrix_set_flags_eeprom_helper(led_flags_t flags, bool write_to_eeprom) {
rgb_matrix_config.flags = flags;
eeconfig_flag_rgb_matrix(write_to_eeprom);
- dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.flags);
+ dprintf("rgb matrix set flags [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.flags);
}
led_flags_t rgb_matrix_get_flags(void) {
diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h
index 38040fb0cc..8ac263c635 100644
--- a/quantum/rgb_matrix/rgb_matrix.h
+++ b/quantum/rgb_matrix/rgb_matrix.h
@@ -24,26 +24,81 @@
#include "color.h"
#include "keyboard.h"
-#ifdef IS31FL3731
+#if defined(RGB_MATRIX_IS31FL3218)
+# include "is31fl3218.h"
+#elif defined(RGB_MATRIX_IS31FL3731)
# include "is31fl3731.h"
-#elif defined(IS31FL3733)
+#elif defined(RGB_MATRIX_IS31FL3733)
# include "is31fl3733.h"
-#elif defined(IS31FL3736)
+#elif defined(RGB_MATRIX_IS31FL3736)
# include "is31fl3736.h"
-#elif defined(IS31FL3737)
+#elif defined(RGB_MATRIX_IS31FL3737)
# include "is31fl3737.h"
-#elif defined(IS31FL3741)
+#elif defined(RGB_MATRIX_IS31FL3741)
# include "is31fl3741.h"
#elif defined(IS31FLCOMMON)
# include "is31flcommon.h"
-#elif defined(CKLED2001)
-# include "ckled2001.h"
-#elif defined(AW20216)
-# include "aw20216.h"
-#elif defined(WS2812)
+#elif defined(RGB_MATRIX_SNLED27351)
+# include "snled27351.h"
+#elif defined(RGB_MATRIX_AW20216S)
+# include "aw20216s.h"
+#elif defined(RGB_MATRIX_WS2812)
# include "ws2812.h"
#endif
+#ifndef RGB_MATRIX_TIMEOUT
+# define RGB_MATRIX_TIMEOUT 0
+#endif
+
+#ifndef RGB_MATRIX_MAXIMUM_BRIGHTNESS
+# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
+#endif
+
+#ifndef RGB_MATRIX_HUE_STEP
+# define RGB_MATRIX_HUE_STEP 8
+#endif
+
+#ifndef RGB_MATRIX_SAT_STEP
+# define RGB_MATRIX_SAT_STEP 16
+#endif
+
+#ifndef RGB_MATRIX_VAL_STEP
+# define RGB_MATRIX_VAL_STEP 16
+#endif
+
+#ifndef RGB_MATRIX_SPD_STEP
+# define RGB_MATRIX_SPD_STEP 16
+#endif
+
+#ifndef RGB_MATRIX_DEFAULT_ON
+# define RGB_MATRIX_DEFAULT_ON true
+#endif
+
+#ifndef RGB_MATRIX_DEFAULT_MODE
+# ifdef ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
+# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT
+# else
+// fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace
+# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_SOLID_COLOR
+# endif
+#endif
+
+#ifndef RGB_MATRIX_DEFAULT_HUE
+# define RGB_MATRIX_DEFAULT_HUE 0
+#endif
+
+#ifndef RGB_MATRIX_DEFAULT_SAT
+# define RGB_MATRIX_DEFAULT_SAT UINT8_MAX
+#endif
+
+#ifndef RGB_MATRIX_DEFAULT_VAL
+# define RGB_MATRIX_DEFAULT_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS
+#endif
+
+#ifndef RGB_MATRIX_DEFAULT_SPD
+# define RGB_MATRIX_DEFAULT_SPD UINT8_MAX / 2
+#endif
+
#ifndef RGB_MATRIX_LED_FLUSH_LIMIT
# define RGB_MATRIX_LED_FLUSH_LIMIT 16
#endif
diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c
index 695ecc78a4..06d82b9c69 100644
--- a/quantum/rgb_matrix/rgb_matrix_drivers.c
+++ b/quantum/rgb_matrix/rgb_matrix_drivers.c
@@ -24,7 +24,7 @@
* be here if shared between boards.
*/
-#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FL3736) || defined(IS31FL3737) || defined(IS31FL3741) || defined(IS31FLCOMMON) || defined(CKLED2001)
+#if defined(RGB_MATRIX_IS31FL3218) || defined(RGB_MATRIX_IS31FL3731) || defined(RGB_MATRIX_IS31FL3733) || defined(RGB_MATRIX_IS31FL3736) || defined(RGB_MATRIX_IS31FL3737) || defined(RGB_MATRIX_IS31FL3741) || defined(IS31FLCOMMON) || defined(RGB_MATRIX_SNLED27351)
# include "i2c_master.h"
// TODO: Remove this at some later date
@@ -37,7 +37,10 @@
static void init(void) {
i2c_init();
-# if defined(IS31FL3731)
+# if defined(RGB_MATRIX_IS31FL3218)
+ is31fl3218_init();
+
+# elif defined(RGB_MATRIX_IS31FL3731)
is31fl3731_init(DRIVER_ADDR_1);
# if defined(DRIVER_ADDR_2)
is31fl3731_init(DRIVER_ADDR_2);
@@ -49,7 +52,7 @@ static void init(void) {
# endif
# endif
-# elif defined(IS31FL3733)
+# elif defined(RGB_MATRIX_IS31FL3733)
# if !defined(DRIVER_SYNC_1)
# define DRIVER_SYNC_1 0
# endif
@@ -73,7 +76,7 @@ static void init(void) {
# endif
# endif
-# elif defined(IS31FL3736)
+# elif defined(RGB_MATRIX_IS31FL3736)
is31fl3736_init(DRIVER_ADDR_1);
# if defined(DRIVER_ADDR_2)
is31fl3736_init(DRIVER_ADDR_2);
@@ -85,7 +88,7 @@ static void init(void) {
# endif
# endif
-# elif defined(IS31FL3737)
+# elif defined(RGB_MATRIX_IS31FL3737)
is31fl3737_init(DRIVER_ADDR_1);
# if defined(DRIVER_ADDR_2)
is31fl3737_init(DRIVER_ADDR_2);
@@ -97,7 +100,7 @@ static void init(void) {
# endif
# endif
-# elif defined(IS31FL3741)
+# elif defined(RGB_MATRIX_IS31FL3741)
is31fl3741_init(DRIVER_ADDR_1);
# if defined(DRIVER_ADDR_2)
is31fl3741_init(DRIVER_ADDR_2);
@@ -121,14 +124,14 @@ static void init(void) {
# endif
# endif
-# elif defined(CKLED2001)
- ckled2001_init(DRIVER_ADDR_1);
+# elif defined(RGB_MATRIX_SNLED27351)
+ snled27351_init(DRIVER_ADDR_1);
# if defined(DRIVER_ADDR_2)
- ckled2001_init(DRIVER_ADDR_2);
+ snled27351_init(DRIVER_ADDR_2);
# if defined(DRIVER_ADDR_3)
- ckled2001_init(DRIVER_ADDR_3);
+ snled27351_init(DRIVER_ADDR_3);
# if defined(DRIVER_ADDR_4)
- ckled2001_init(DRIVER_ADDR_4);
+ snled27351_init(DRIVER_ADDR_4);
# endif
# endif
# endif
@@ -138,25 +141,30 @@ static void init(void) {
bool enabled = true;
// This only caches it for later
-# if defined(IS31FL3731)
+# if defined(RGB_MATRIX_IS31FL3218)
+ is31fl3218_set_led_control_register(index, enabled, enabled, enabled);
+# elif defined(RGB_MATRIX_IS31FL3731)
is31fl3731_set_led_control_register(index, enabled, enabled, enabled);
-# elif defined(IS31FL3733)
+# elif defined(RGB_MATRIX_IS31FL3733)
is31fl3733_set_led_control_register(index, enabled, enabled, enabled);
-# elif defined(IS31FL3736)
+# elif defined(RGB_MATRIX_IS31FL3736)
is31fl3736_set_led_control_register(index, enabled, enabled, enabled);
-# elif defined(IS31FL3737)
+# elif defined(RGB_MATRIX_IS31FL3737)
is31fl3737_set_led_control_register(index, enabled, enabled, enabled);
-# elif defined(IS31FL3741)
+# elif defined(RGB_MATRIX_IS31FL3741)
is31fl3741_set_led_control_register(index, enabled, enabled, enabled);
# elif defined(IS31FLCOMMON)
IS31FL_RGB_set_scaling_buffer(index, enabled, enabled, enabled);
-# elif defined(CKLED2001)
- ckled2001_set_led_control_register(index, enabled, enabled, enabled);
+# elif defined(RGB_MATRIX_SNLED27351)
+ snled27351_set_led_control_register(index, enabled, enabled, enabled);
# endif
}
// This actually updates the LED drivers
-# if defined(IS31FL3731)
+# if defined(RGB_MATRIX_IS31FL3218)
+ is31fl3218_update_led_control_registers();
+
+# elif defined(RGB_MATRIX_IS31FL3731)
is31fl3731_update_led_control_registers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
is31fl3731_update_led_control_registers(DRIVER_ADDR_2, 1);
@@ -168,7 +176,7 @@ static void init(void) {
# endif
# endif
-# elif defined(IS31FL3733)
+# elif defined(RGB_MATRIX_IS31FL3733)
is31fl3733_update_led_control_registers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
is31fl3733_update_led_control_registers(DRIVER_ADDR_2, 1);
@@ -180,7 +188,7 @@ static void init(void) {
# endif
# endif
-# elif defined(IS31FL3736)
+# elif defined(RGB_MATRIX_IS31FL3736)
is31fl3736_update_led_control_registers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
is31fl3736_update_led_control_registers(DRIVER_ADDR_2, 1);
@@ -192,7 +200,7 @@ static void init(void) {
# endif
# endif
-# elif defined(IS31FL3737)
+# elif defined(RGB_MATRIX_IS31FL3737)
is31fl3737_update_led_control_registers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
is31fl3737_update_led_control_registers(DRIVER_ADDR_2, 1);
@@ -204,7 +212,7 @@ static void init(void) {
# endif
# endif
-# elif defined(IS31FL3741)
+# elif defined(RGB_MATRIX_IS31FL3741)
is31fl3741_update_led_control_registers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
is31fl3741_update_led_control_registers(DRIVER_ADDR_2, 1);
@@ -231,21 +239,33 @@ static void init(void) {
# endif
# endif
-# elif defined(CKLED2001)
- ckled2001_update_led_control_registers(DRIVER_ADDR_1, 0);
+# elif defined(RGB_MATRIX_SNLED27351)
+ snled27351_update_led_control_registers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
- ckled2001_update_led_control_registers(DRIVER_ADDR_2, 1);
+ snled27351_update_led_control_registers(DRIVER_ADDR_2, 1);
# if defined(DRIVER_ADDR_3)
- ckled2001_update_led_control_registers(DRIVER_ADDR_3, 2);
+ snled27351_update_led_control_registers(DRIVER_ADDR_3, 2);
# if defined(DRIVER_ADDR_4)
- ckled2001_update_led_control_registers(DRIVER_ADDR_4, 3);
+ snled27351_update_led_control_registers(DRIVER_ADDR_4, 3);
# endif
# endif
# endif
# endif
}
-# if defined(IS31FL3731)
+# if defined(RGB_MATRIX_IS31FL3218)
+static void flush(void) {
+ is31fl3218_update_pwm_buffers();
+}
+
+const rgb_matrix_driver_t rgb_matrix_driver = {
+ .init = init,
+ .flush = flush,
+ .set_color = is31fl3218_set_color,
+ .set_color_all = is31fl3218_set_color_all,
+};
+
+# elif defined(RGB_MATRIX_IS31FL3731)
static void flush(void) {
is31fl3731_update_pwm_buffers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
@@ -260,13 +280,13 @@ static void flush(void) {
}
const rgb_matrix_driver_t rgb_matrix_driver = {
- .init = init,
- .flush = flush,
- .set_color = is31fl3731_set_color,
+ .init = init,
+ .flush = flush,
+ .set_color = is31fl3731_set_color,
.set_color_all = is31fl3731_set_color_all,
};
-# elif defined(IS31FL3733)
+# elif defined(RGB_MATRIX_IS31FL3733)
static void flush(void) {
is31fl3733_update_pwm_buffers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
@@ -287,7 +307,7 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
.set_color_all = is31fl3733_set_color_all,
};
-# elif defined(IS31FL3736)
+# elif defined(RGB_MATRIX_IS31FL3736)
static void flush(void) {
is31fl3736_update_pwm_buffers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
@@ -308,7 +328,7 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
.set_color_all = is31fl3736_set_color_all,
};
-# elif defined(IS31FL3737)
+# elif defined(RGB_MATRIX_IS31FL3737)
static void flush(void) {
is31fl3737_update_pwm_buffers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
@@ -329,7 +349,7 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
.set_color_all = is31fl3737_set_color_all,
};
-# elif defined(IS31FL3741)
+# elif defined(RGB_MATRIX_IS31FL3741)
static void flush(void) {
is31fl3741_update_pwm_buffers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
@@ -371,15 +391,15 @@ const rgb_matrix_driver_t rgb_matrix_driver = {
.set_color_all = IS31FL_RGB_set_color_all,
};
-# elif defined(CKLED2001)
+# elif defined(RGB_MATRIX_SNLED27351)
static void flush(void) {
- ckled2001_update_pwm_buffers(DRIVER_ADDR_1, 0);
+ snled27351_update_pwm_buffers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
- ckled2001_update_pwm_buffers(DRIVER_ADDR_2, 1);
+ snled27351_update_pwm_buffers(DRIVER_ADDR_2, 1);
# if defined(DRIVER_ADDR_3)
- ckled2001_update_pwm_buffers(DRIVER_ADDR_3, 2);
+ snled27351_update_pwm_buffers(DRIVER_ADDR_3, 2);
# if defined(DRIVER_ADDR_4)
- ckled2001_update_pwm_buffers(DRIVER_ADDR_4, 3);
+ snled27351_update_pwm_buffers(DRIVER_ADDR_4, 3);
# endif
# endif
# endif
@@ -388,46 +408,46 @@ static void flush(void) {
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
.flush = flush,
- .set_color = ckled2001_set_color,
- .set_color_all = ckled2001_set_color_all,
+ .set_color = snled27351_set_color,
+ .set_color_all = snled27351_set_color_all,
};
# endif
-#elif defined(AW20216)
+#elif defined(RGB_MATRIX_AW20216S)
# include "spi_master.h"
static void init(void) {
spi_init();
- aw20216_init(DRIVER_1_CS, DRIVER_1_EN);
-# if defined(DRIVER_2_CS)
- aw20216_init(DRIVER_2_CS, DRIVER_2_EN);
+ aw20216s_init(AW20216S_DRIVER_1_CS, AW20216S_DRIVER_1_EN);
+# if defined(AW20216S_DRIVER_2_CS)
+ aw20216s_init(AW20216S_DRIVER_2_CS, AW20216S_DRIVER_2_EN);
# endif
}
static void flush(void) {
- aw20216_update_pwm_buffers(DRIVER_1_CS, 0);
-# if defined(DRIVER_2_CS)
- aw20216_update_pwm_buffers(DRIVER_2_CS, 1);
+ aw20216s_update_pwm_buffers(AW20216S_DRIVER_1_CS, 0);
+# if defined(AW20216S_DRIVER_2_CS)
+ aw20216s_update_pwm_buffers(AW20216S_DRIVER_2_CS, 1);
# endif
}
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
.flush = flush,
- .set_color = aw20216_set_color,
- .set_color_all = aw20216_set_color_all,
+ .set_color = aw20216s_set_color,
+ .set_color_all = aw20216s_set_color_all,
};
-#elif defined(WS2812)
-# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_CUSTOM_DRIVER)
+#elif defined(RGB_MATRIX_WS2812)
+# if defined(RGBLIGHT_WS2812)
# pragma message "Cannot use RGBLIGHT and RGB Matrix using WS2812 at the same time."
# pragma message "You need to use a custom driver, or re-implement the WS2812 driver to use a different configuration."
# endif
// LED color buffer
-LED_TYPE rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
-bool ws2812_dirty = false;
+rgb_led_t rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
+bool ws2812_dirty = false;
static void init(void) {
ws2812_dirty = false;
diff --git a/quantum/rgb_matrix/rgb_matrix_types.h b/quantum/rgb_matrix/rgb_matrix_types.h
index 53ff7321b8..0a3fd7cc0d 100644
--- a/quantum/rgb_matrix/rgb_matrix_types.h
+++ b/quantum/rgb_matrix/rgb_matrix_types.h
@@ -19,16 +19,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "color.h"
-
-#if defined(__GNUC__)
-# define PACKED __attribute__((__packed__))
-#else
-# define PACKED
-#endif
-
-#if defined(_MSC_VER)
-# pragma pack(push, 1)
-#endif
+#include "util.h"
#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES)
# define RGB_MATRIX_KEYREACTIVE_ENABLED
@@ -94,7 +85,3 @@ typedef union {
} rgb_config_t;
_Static_assert(sizeof(rgb_config_t) == sizeof(uint64_t), "RGB Matrix EECONFIG out of spec.");
-
-#if defined(_MSC_VER)
-# pragma pack(pop)
-#endif
diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c
index 158112f31d..8ac886d441 100644
--- a/quantum/rgblight/rgblight.c
+++ b/quantum/rgblight/rgblight.c
@@ -27,9 +27,6 @@
#ifdef EEPROM_ENABLE
# include "eeprom.h"
#endif
-#ifdef VELOCIKEY_ENABLE
-# include "velocikey.h"
-#endif
#ifdef RGBLIGHT_SPLIT
/* for split keyboard */
@@ -89,6 +86,10 @@ static uint8_t mode_base_table[] = {
# define RGBLIGHT_DEFAULT_SPD 0
#endif
+#if !defined(RGBLIGHT_DEFAULT_ON)
+# define RGBLIGHT_DEFAULT_ON true
+#endif
+
static inline int is_static_effect(uint8_t mode) {
return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL;
}
@@ -115,7 +116,7 @@ animation_status_t animation_status = {};
#endif
#ifndef LED_ARRAY
-LED_TYPE led[RGBLED_NUM];
+rgb_led_t led[RGBLED_NUM];
# define LED_ARRAY led
#endif
@@ -144,17 +145,17 @@ __attribute__((weak)) RGB rgblight_hsv_to_rgb(HSV hsv) {
return hsv_to_rgb(hsv);
}
-void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
+void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1) {
HSV hsv = {hue, sat, val};
RGB rgb = rgblight_hsv_to_rgb(hsv);
setrgb(rgb.r, rgb.g, rgb.b, led1);
}
-void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) {
+void sethsv(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1) {
sethsv_raw(hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val, led1);
}
-void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) {
+void setrgb(uint8_t r, uint8_t g, uint8_t b, rgb_led_t *led1) {
led1->r = r;
led1->g = g;
led1->b = b;
@@ -198,12 +199,13 @@ void eeconfig_update_rgblight_current(void) {
}
void eeconfig_update_rgblight_default(void) {
- rgblight_config.enable = 1;
- rgblight_config.mode = RGBLIGHT_DEFAULT_MODE;
- rgblight_config.hue = RGBLIGHT_DEFAULT_HUE;
- rgblight_config.sat = RGBLIGHT_DEFAULT_SAT;
- rgblight_config.val = RGBLIGHT_DEFAULT_VAL;
- rgblight_config.speed = RGBLIGHT_DEFAULT_SPD;
+ rgblight_config.enable = RGBLIGHT_DEFAULT_ON;
+ rgblight_config.velocikey = 0;
+ rgblight_config.mode = RGBLIGHT_DEFAULT_MODE;
+ rgblight_config.hue = RGBLIGHT_DEFAULT_HUE;
+ rgblight_config.sat = RGBLIGHT_DEFAULT_SAT;
+ rgblight_config.val = RGBLIGHT_DEFAULT_VAL;
+ rgblight_config.speed = RGBLIGHT_DEFAULT_SPD;
RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
eeconfig_update_rgblight(rgblight_config.raw);
}
@@ -211,6 +213,7 @@ void eeconfig_update_rgblight_default(void) {
void eeconfig_debug_rgblight(void) {
dprintf("rgblight_config EEPROM:\n");
dprintf("rgblight_config.enable = %d\n", rgblight_config.enable);
+ dprintf("rgblight_config.velocikey = %d\n", rgblight_config.velocikey);
dprintf("rghlight_config.mode = %d\n", rgblight_config.mode);
dprintf("rgblight_config.hue = %d\n", rgblight_config.hue);
dprintf("rgblight_config.sat = %d\n", rgblight_config.sat);
@@ -516,7 +519,7 @@ void rgblight_decrease_speed_noeeprom(void) {
void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) {
if (rgblight_config.enable) {
- LED_TYPE tmp_led;
+ rgb_led_t tmp_led;
sethsv(hue, sat, val, &tmp_led);
rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
}
@@ -532,7 +535,7 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w
rgblight_status.base_mode = mode_base_table[rgblight_config.mode];
if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) {
// same static color
- LED_TYPE tmp_led;
+ rgb_led_t tmp_led;
#ifdef RGBLIGHT_LAYERS_RETAIN_VAL
// needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val
rgblight_config.val = val;
@@ -576,7 +579,7 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w
_hue = hue - _hue;
}
dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range);
- sethsv(_hue, sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]);
+ sethsv(_hue, sat, val, (rgb_led_t *)&led[i + rgblight_ranges.effect_start_pos]);
}
# ifdef RGBLIGHT_LAYERS_RETAIN_VAL
// needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val
@@ -679,7 +682,7 @@ void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index) {
return;
}
- LED_TYPE tmp_led;
+ rgb_led_t tmp_led;
sethsv(hue, sat, val, &tmp_led);
rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index);
}
@@ -689,9 +692,9 @@ void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index) {
static uint8_t get_interval_time(const uint8_t *default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) {
return
# ifdef VELOCIKEY_ENABLE
- velocikey_enabled() ? velocikey_match_speed(velocikey_min, velocikey_max) :
+ rgblight_velocikey_enabled() ? rgblight_velocikey_match_speed(velocikey_min, velocikey_max) :
# endif
- pgm_read_byte(default_interval_address);
+ pgm_read_byte(default_interval_address);
}
#endif
@@ -717,7 +720,7 @@ void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start,
return;
}
- LED_TYPE tmp_led;
+ rgb_led_t tmp_led;
sethsv(hue, sat, val, &tmp_led);
rgblight_setrgb_range(tmp_led.r, tmp_led.g, tmp_led.b, start, end);
}
@@ -786,8 +789,8 @@ static void rgblight_layers_write(void) {
break; // No more segments
}
// Write segment.count LEDs
- LED_TYPE *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)];
- for (LED_TYPE *led_ptr = &led[segment.index]; led_ptr < limit; led_ptr++) {
+ rgb_led_t *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)];
+ for (rgb_led_t *led_ptr = &led[segment.index]; led_ptr < limit; led_ptr++) {
# ifdef RGBLIGHT_LAYERS_RETAIN_VAL
sethsv(segment.hue, segment.sat, current_val, led_ptr);
# else
@@ -897,15 +900,15 @@ void rgblight_wakeup(void) {
#endif
-__attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) {
+__attribute__((weak)) void rgblight_call_driver(rgb_led_t *start_led, uint8_t num_leds) {
ws2812_setleds(start_led, num_leds);
}
-#ifndef RGBLIGHT_CUSTOM_DRIVER
+#ifndef RGBLIGHT_CUSTOM
void rgblight_set(void) {
- LED_TYPE *start_led;
- uint8_t num_leds = rgblight_ranges.clipping_num_leds;
+ rgb_led_t *start_led;
+ uint8_t num_leds = rgblight_ranges.clipping_num_leds;
if (!rgblight_config.enable) {
for (uint8_t i = rgblight_ranges.effect_start_pos; i < rgblight_ranges.effect_end_pos; i++) {
@@ -931,7 +934,7 @@ void rgblight_set(void) {
# endif
# ifdef RGBLIGHT_LED_MAP
- LED_TYPE led0[RGBLED_NUM];
+ rgb_led_t led0[RGBLED_NUM];
for (uint8_t i = 0; i < RGBLED_NUM; i++) {
led0[i] = led[pgm_read_byte(&led_map[i])];
}
@@ -1049,7 +1052,7 @@ static void rgblight_effect_dummy(animation_status_t *anim) {
**/
}
-void rgblight_task(void) {
+void rgblight_timer_task(void) {
if (rgblight_status.timer_enabled) {
effect_func_t effect_func = rgblight_effect_dummy;
uint16_t interval_time = 2000; // dummy interval
@@ -1230,7 +1233,7 @@ void rgblight_effect_rainbow_swirl(animation_status_t *anim) {
for (i = 0; i < rgblight_ranges.effect_num_leds; i++) {
hue = (RGBLIGHT_RAINBOW_SWIRL_RANGE / rgblight_ranges.effect_num_leds * i + anim->current_hue);
- sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]);
+ sethsv(hue, rgblight_config.sat, rgblight_config.val, (rgb_led_t *)&led[i + rgblight_ranges.effect_start_pos]);
}
rgblight_set();
@@ -1267,10 +1270,10 @@ void rgblight_effect_snake(animation_status_t *anim) {
# endif
for (i = 0; i < rgblight_ranges.effect_num_leds; i++) {
- LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos;
- ledp->r = 0;
- ledp->g = 0;
- ledp->b = 0;
+ rgb_led_t *ledp = led + i + rgblight_ranges.effect_start_pos;
+ ledp->r = 0;
+ ledp->g = 0;
+ ledp->b = 0;
# ifdef RGBW
ledp->w = 0;
# endif
@@ -1340,7 +1343,7 @@ void rgblight_effect_knight(animation_status_t *anim) {
cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % rgblight_ranges.effect_num_leds + rgblight_ranges.effect_start_pos;
if (i >= low_bound && i <= high_bound) {
- sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]);
+ sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (rgb_led_t *)&led[cur]);
} else {
led[cur].r = 0;
led[cur].g = 0;
@@ -1392,7 +1395,7 @@ void rgblight_effect_christmas(animation_status_t *anim) {
for (i = 0; i < rgblight_ranges.effect_num_leds; i++) {
uint8_t local_hue = (i / RGBLIGHT_EFFECT_CHRISTMAS_STEP) % 2 ? hue : hue_green - hue;
- sethsv(local_hue, rgblight_config.sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]);
+ sethsv(local_hue, rgblight_config.sat, val, (rgb_led_t *)&led[i + rgblight_ranges.effect_start_pos]);
}
rgblight_set();
@@ -1415,7 +1418,7 @@ void rgblight_effect_rgbtest(animation_status_t *anim) {
uint8_t b;
if (maxval == 0) {
- LED_TYPE tmp_led;
+ rgb_led_t tmp_led;
sethsv(0, 255, RGBLIGHT_LIMIT_VAL, &tmp_led);
maxval = tmp_led.r;
}
@@ -1439,7 +1442,7 @@ void rgblight_effect_rgbtest(animation_status_t *anim) {
#ifdef RGBLIGHT_EFFECT_ALTERNATING
void rgblight_effect_alternating(animation_status_t *anim) {
for (int i = 0; i < rgblight_ranges.effect_num_leds; i++) {
- LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos;
+ rgb_led_t *ledp = led + i + rgblight_ranges.effect_start_pos;
if (i < rgblight_ranges.effect_num_leds / 2 && anim->pos) {
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, ledp);
} else if (i >= rgblight_ranges.effect_num_leds / 2 && !anim->pos) {
@@ -1512,10 +1515,68 @@ void rgblight_effect_twinkle(animation_status_t *anim) {
// This LED is off, and was NOT selected to start brightening
}
- LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos;
+ rgb_led_t *ledp = led + i + rgblight_ranges.effect_start_pos;
sethsv(c->h, c->s, c->v, ledp);
}
rgblight_set();
}
#endif
+
+void preprocess_rgblight(void) {
+#ifdef VELOCIKEY_ENABLE
+ if (rgblight_velocikey_enabled()) {
+ rgblight_velocikey_accelerate();
+ }
+#endif
+}
+
+void rgblight_task(void) {
+#ifdef RGBLIGHT_USE_TIMER
+ rgblight_timer_task();
+#endif
+
+#ifdef VELOCIKEY_ENABLE
+ if (rgblight_velocikey_enabled()) {
+ rgblight_velocikey_decelerate();
+ }
+#endif
+}
+
+#ifdef VELOCIKEY_ENABLE
+# define TYPING_SPEED_MAX_VALUE 200
+
+static uint8_t typing_speed = 0;
+
+bool rgblight_velocikey_enabled(void) {
+ return rgblight_config.velocikey;
+}
+
+void rgblight_velocikey_toggle(void) {
+ dprintf("rgblight velocikey toggle [EEPROM]: rgblight_config.velocikey = %u\n", !rgblight_config.velocikey);
+ rgblight_config.velocikey = !rgblight_config.velocikey;
+ eeconfig_update_rgblight_current();
+}
+
+void rgblight_velocikey_accelerate(void) {
+ if (typing_speed < TYPING_SPEED_MAX_VALUE) typing_speed += (TYPING_SPEED_MAX_VALUE / 100);
+}
+
+void rgblight_velocikey_decelerate(void) {
+ static uint16_t decay_timer = 0;
+
+ if (timer_elapsed(decay_timer) > 500 || decay_timer == 0) {
+ if (typing_speed > 0) typing_speed -= 1;
+ // Decay a little faster at half of max speed
+ if (typing_speed > TYPING_SPEED_MAX_VALUE / 2) typing_speed -= 1;
+ // Decay even faster at 3/4 of max speed
+ if (typing_speed > TYPING_SPEED_MAX_VALUE / 4 * 3) typing_speed -= 2;
+ decay_timer = timer_read();
+ }
+}
+
+uint8_t rgblight_velocikey_match_speed(uint8_t minValue, uint8_t maxValue) {
+ return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE));
+}
+
+#endif \ No newline at end of file
diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h
index 001058f962..a222ab6b9f 100644
--- a/quantum/rgblight/rgblight.h
+++ b/quantum/rgblight/rgblight.h
@@ -233,7 +233,7 @@ void rgblight_unblink_all_but_layer(uint8_t layer);
#endif
-extern LED_TYPE led[RGBLED_NUM];
+extern rgb_led_t led[RGBLED_NUM];
extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM;
extern const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[3] PROGMEM;
@@ -248,7 +248,8 @@ typedef union {
uint64_t raw;
struct {
bool enable : 1;
- uint8_t mode : 7;
+ bool velocikey : 1;
+ uint8_t mode : 6;
uint8_t hue : 8;
uint8_t sat : 8;
uint8_t val : 8;
@@ -283,9 +284,9 @@ typedef struct _rgblight_ranges_t {
extern rgblight_ranges_t rgblight_ranges;
/* === Utility Functions ===*/
-void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1);
-void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); // without RGBLIGHT_LIMIT_VAL check
-void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1);
+void sethsv(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1);
+void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1); // without RGBLIGHT_LIMIT_VAL check
+void setrgb(uint8_t r, uint8_t g, uint8_t b, rgb_led_t *led1);
/* === Low level Functions === */
void rgblight_set(void);
@@ -385,14 +386,15 @@ void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom);
#define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF)
void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b);
-#ifdef RGBLIGHT_USE_TIMER
+void preprocess_rgblight(void);
void rgblight_task(void);
+
+#ifdef RGBLIGHT_USE_TIMER
void rgblight_timer_init(void);
void rgblight_timer_enable(void);
void rgblight_timer_disable(void);
void rgblight_timer_toggle(void);
#else
-# define rgblight_task()
# define rgblight_timer_init()
# define rgblight_timer_enable()
# define rgblight_timer_disable()
@@ -446,3 +448,14 @@ void rgblight_effect_alternating(animation_status_t *anim);
void rgblight_effect_twinkle(animation_status_t *anim);
#endif
+
+#ifdef VELOCIKEY_ENABLE
+bool rgblight_velocikey_enabled(void);
+void rgblight_velocikey_toggle(void);
+void rgblight_velocikey_accelerate(void);
+void rgblight_velocikey_decelerate(void);
+uint8_t rgblight_velocikey_match_speed(uint8_t minValue, uint8_t maxValue);
+
+# define velocikey_enabled rgblight_velocikey_enabled
+# define velocikey_toggle rgblight_velocikey_toggle
+#endif
diff --git a/quantum/util.h b/quantum/util.h
index 9c034cc404..21e3487b28 100644
--- a/quantum/util.h
+++ b/quantum/util.h
@@ -46,3 +46,7 @@
*/
# define ARRAY_SIZE(array) (__builtin_choose_expr(IS_ARRAY((array)), sizeof((array)) / sizeof((array)[0]), (void)0))
#endif
+
+#if !defined(PACKED)
+# define PACKED __attribute__((__packed__))
+#endif
diff --git a/quantum/velocikey.c b/quantum/velocikey.c
deleted file mode 100644
index 03e91911f6..0000000000
--- a/quantum/velocikey.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "velocikey.h"
-#include "timer.h"
-#include "eeconfig.h"
-#include "eeprom.h"
-#include "util.h"
-
-#define TYPING_SPEED_MAX_VALUE 200
-uint8_t typing_speed = 0;
-
-bool velocikey_enabled(void) {
- return eeprom_read_byte(EECONFIG_VELOCIKEY) == 1;
-}
-
-void velocikey_toggle(void) {
- if (velocikey_enabled())
- eeprom_update_byte(EECONFIG_VELOCIKEY, 0);
- else
- eeprom_update_byte(EECONFIG_VELOCIKEY, 1);
-}
-
-void velocikey_accelerate(void) {
- if (typing_speed < TYPING_SPEED_MAX_VALUE) typing_speed += (TYPING_SPEED_MAX_VALUE / 100);
-}
-
-void velocikey_decelerate(void) {
- static uint16_t decay_timer = 0;
-
- if (timer_elapsed(decay_timer) > 500 || decay_timer == 0) {
- if (typing_speed > 0) typing_speed -= 1;
- // Decay a little faster at half of max speed
- if (typing_speed > TYPING_SPEED_MAX_VALUE / 2) typing_speed -= 1;
- // Decay even faster at 3/4 of max speed
- if (typing_speed > TYPING_SPEED_MAX_VALUE / 4 * 3) typing_speed -= 2;
- decay_timer = timer_read();
- }
-}
-
-uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue) {
- return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE));
-}
diff --git a/quantum/velocikey.h b/quantum/velocikey.h
deleted file mode 100644
index c375f82f71..0000000000
--- a/quantum/velocikey.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma once
-
-#include <stdint.h>
-#include <stdbool.h>
-
-bool velocikey_enabled(void);
-void velocikey_toggle(void);
-void velocikey_accelerate(void);
-void velocikey_decelerate(void);
-uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue);
diff --git a/quantum/via.c b/quantum/via.c
index 2acd7aa90c..643d7aa3c3 100644
--- a/quantum/via.c
+++ b/quantum/via.c
@@ -634,11 +634,6 @@ void via_qmk_rgblight_save(void) {
#if defined(RGB_MATRIX_ENABLE)
-# if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
-# undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
-# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
-# endif
-
void via_qmk_rgb_matrix_command(uint8_t *data, uint8_t length) {
// data = [ command_id, channel_id, value_id, value_data ]
uint8_t *command_id = &(data[0]);
@@ -727,11 +722,6 @@ void via_qmk_rgb_matrix_save(void) {
#if defined(LED_MATRIX_ENABLE)
-# if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
-# undef LED_MATRIX_MAXIMUM_BRIGHTNESS
-# define LED_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
-# endif
-
void via_qmk_led_matrix_command(uint8_t *data, uint8_t length) {
// data = [ command_id, channel_id, value_id, value_data ]
uint8_t *command_id = &(data[0]);