diff Scan/MatrixARM/matrix_scan.h @ 343:e464aaa4730f

Adding timing based debounce code - Uses expiry timer to decide on when to allow a state change - Initial state transitions are unaffected - Use MinDebounceTime define in kll to configure - ms granularity
author Jacob Alexander <haata@kiibohd.com>
date Fri, 19 Jun 2015 01:50:56 -0700
parents 66eccdd9ced5
children 293154e4aafe
line wrap: on
line diff
--- a/Scan/MatrixARM/matrix_scan.h	Sun Jun 14 14:32:42 2015 -0700
+++ b/Scan/MatrixARM/matrix_scan.h	Fri Jun 19 01:50:56 2015 -0700
@@ -40,6 +40,12 @@
 #error "Debounce threshold is too high... 32 bit max. Check .kll defines."
 #endif
 
+#if   ( MinDebounceTime_define > 0xFF )
+#error "MinDebounceTime is a maximum of 255 ms"
+#elif ( MinDebounceTime_define < 0x00 )
+#error "MinDebounceTime is a minimum 0 ms"
+#endif
+
 
 
 // ----- Enums -----
@@ -126,11 +132,12 @@
 
 // Debounce Element
 typedef struct KeyState {
+	DebounceCounter activeCount;
+	DebounceCounter inactiveCount;
 	KeyPosition     prevState;
 	KeyPosition     curState;
-	DebounceCounter activeCount;
-	DebounceCounter inactiveCount;
-} KeyState;
+	uint8_t         prevDecisionTime;
+} __attribute__((packed)) KeyState;