DebounceDivThreshold = 0xFFFF; # Default debounce
#DebounceDivThreshold = 0xFFFFFFFF; # Max debounce
+# This defines how often the matrix is scanned
+# By, default the key matrix is scanned once per macro processing loop
+# For fast uCs and bouncy switches, this can be non-ideal
+# 0 - Bit-shift of 0
+# 1 - Bit-shift of 1 (i.e. divide by 2)
+# 2 - Bit-shift of 2 (i.e. divide by 4)
+# 3 - Bit-shift of 3 (i.e. divide by 8)
+# etc.
+# Depending on the architecture, this is either a maximum of 16 or 32
+# Increasing this value will increase switch latency
+DebounceThrottleDiv => DebounceThrottleDiv_define;
+DebounceThrottleDiv = 0; # Default
+#DebounceThrottleDiv = 2; # /4 divider
+
// Project Includes
#include <cli.h>
+#include <kll.h>
#include <led.h>
#include <print.h>
#include <macro.h>
+// ----- Defines -----
+
+#if ( DebounceThrottleDiv_define > 0 )
+nat_ptr_t Matrix_divCounter = 0;
+#endif
+
+
+
// ----- Function Declarations -----
// CLI Functions
// NOTE: scanNum should be reset to 0 after a USB send (to reset all the counters)
void Matrix_scan( uint16_t scanNum )
{
+#if ( DebounceThrottleDiv_define > 0 )
+ // Scan-rate throttling
+ // By scanning using a divider, the scan rate slowed down
+ // DebounceThrottleDiv_define == 1 means -> /2 or half scan rate
+ // This helps with bouncy switches on fast uCs
+ if ( !( Matrix_divCounter++ & (1 << ( DebounceThrottleDiv_define - 1 )) ) )
+ return;
+#endif
+
// Increment stats counters
if ( scanNum > matrixMaxScans ) matrixMaxScans = scanNum;
if ( scanNum == 0 )