From e22f02100dfe49bc90000488558879367e9f1985 Mon Sep 17 00:00:00 2001 From: plodah Date: Fri, 23 Aug 2024 00:56:15 +0100 Subject: [PATCH] Dynamic Macro Recording Timeout --- users/plodah/functions/kc_handler.c | 4 ++++ users/plodah/plodah.c | 16 +++++++++++----- users/plodah/plodah.h | 4 ++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/users/plodah/functions/kc_handler.c b/users/plodah/functions/kc_handler.c index e926d176fc..62cdedd20b 100644 --- a/users/plodah/functions/kc_handler.c +++ b/users/plodah/functions/kc_handler.c @@ -10,6 +10,10 @@ bool kc_handler(uint16_t keycode, keyrecord_t *record) { plodah_typingindicator_start(); # endif // PLODAH_TYPINGINDICATOR_RGBINDEX +# if defined(DYNAMIC_MACRO_ENABLE) && defined(PLODAH_DYNAMIC_MACRO_TIMEOUT) + dynamic_macro_loop_timer = timer_read(); +# endif // defined(DYNAMIC_MACRO_ENABLE) && defined(PLODAH_DYNAMIC_MACRO_TIMEOUT) + switch (keycode) { // Static version keycode case PL_VERS: diff --git a/users/plodah/plodah.c b/users/plodah/plodah.c index 917f933633..044bccecdf 100644 --- a/users/plodah/plodah.c +++ b/users/plodah/plodah.c @@ -19,7 +19,7 @@ #endif // CAPS_WORD_ENABLE #if defined(DYNAMIC_MACRO_ENABLE) && defined (RGB_MATRIX_ENABLE) && defined (PLODAH_DMAC_INDIC_INDEX) bool is_dynamic_macro_recording = false; - //uint16_t dynamic_macro_loop_timer; + uint16_t dynamic_macro_loop_timer; #endif // DYNAMIC_MACRO_ENABLE && RGB_MATRIX_ENABLE && PLODAH_DMAC_INDIC_INDEX //===================// @@ -113,10 +113,14 @@ void matrix_scan_user(void) { # if defined (PLODAH_TYPINGINDICATOR_RGBINDEX) plodah_typingindicator_check(); # endif // PLODAH_TYPINGINDICATOR_RGBINDEX +# if defined(DYNAMIC_MACRO_ENABLE) && defined(PLODAH_DYNAMIC_MACRO_TIMEOUT) + if (timer_elapsed(dynamic_macro_loop_timer) > PLODAH_DYNAMIC_MACRO_TIMEOUT){ + dynamic_macro_stop_recording(); + } +# endif // defined(DYNAMIC_MACRO_ENABLE) && defined(PLODAH_DYNAMIC_MACRO_TIMEOUT) } #endif // (defined(PLODAH_ALTTAB_ENHANCEMENTS_ENABLE)) || ( defined(AUTOCORRECT_ENABLE) && defined(RGB_MATRIX_ENABLE) ) || (defined(PLODAH_TYPINGINDICATOR_RGBINDEX)) - //==========================// // CAPS INDICATOR // //==========================// @@ -149,12 +153,14 @@ void matrix_scan_user(void) { //==========================// // DYNAMIC MACROS // //==========================// -#if defined(DYNAMIC_MACRO_ENABLE) && defined (RGB_MATRIX_ENABLE) && defined (PLODAH_DMAC_INDIC_INDEX) +#if defined(DYNAMIC_MACRO_ENABLE) void dynamic_macro_record_start_user(int8_t direction) { is_dynamic_macro_recording = true; - //dynamic_macro_loop_timer = timer_read(); + # if defined(PLODAH_DYNAMIC_MACRO_TIMEOUT) + dynamic_macro_loop_timer = timer_read(); + # endif // PLODAH_DYNAMIC_MACRO_TIMEOUT } void dynamic_macro_record_end_user(int8_t direction) { is_dynamic_macro_recording = false; } -#endif // DYNAMIC_MACRO_ENABLE && RGB_MATRIX_ENABLE && PLODAH_DMAC_INDIC_INDEX +#endif // DYNAMIC_MACRO_ENABLE diff --git a/users/plodah/plodah.h b/users/plodah/plodah.h index e9424590e3..777ad76696 100644 --- a/users/plodah/plodah.h +++ b/users/plodah/plodah.h @@ -17,6 +17,10 @@ # define DEBOUNCE 20 #endif // DEBOUNCE +# if defined(DYNAMIC_MACRO_ENABLE) && (! defined(PLODAH_DYNAMIC_MACRO_TIMEOUT)) +# define PLODAH_DYNAMIC_MACRO_TIMEOUT 10000 +#endif // DYNAMIC_MACRO_ENABLE + #ifndef TAPPING_TERM # define TAPPING_TERM 180 #endif // TAPPING_TERM