Mercurial > louis > kiibohd-controller
diff Scan/MatrixARM/matrix_scan.c @ 299:c856f826bd49
Adding DebounceThrottleDiv define to slow down the debounce rate.
By default:
DebounceThrottleDiv = 0;
This is the default infinity behaviour right now (may be changed in the future).
Increasing DebounceThrottleDiv will increase the scan rate divider.
DebounceThrottleDiv = 1; # Scans half as much
DebounceThrottleDiv = 2; # Scans a quarter as much
DebounceThrottleDiv = 3; # Scans an eigth as much
etc.
For ARM based uCs (like the Infinity) the maximum divider is 32.
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Fri, 06 Mar 2015 22:18:15 -0800 |
parents | 57f40871c726 |
children | e464aaa4730f |
line wrap: on
line diff
--- a/Scan/MatrixARM/matrix_scan.c Mon Mar 02 01:58:53 2015 -0800 +++ b/Scan/MatrixARM/matrix_scan.c Fri Mar 06 22:18:15 2015 -0800 @@ -26,6 +26,7 @@ // Project Includes #include <cli.h> +#include <kll.h> #include <led.h> #include <print.h> #include <macro.h> @@ -38,6 +39,14 @@ +// ----- Defines ----- + +#if ( DebounceThrottleDiv_define > 0 ) +nat_ptr_t Matrix_divCounter = 0; +#endif + + + // ----- Function Declarations ----- // CLI Functions @@ -232,6 +241,15 @@ // 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 )