]> git.donarmstrong.com Git - kiibohd-controller.git/blobdiff - Scan/MatrixARM/matrix_scan.c
Adding configurable DebounceDivThreshold
[kiibohd-controller.git] / Scan / MatrixARM / matrix_scan.c
index 136270756ecbf3f6ea4d2d41a17aab10ea3a2693..eaea368f4b01e6a8635879e4f9ba1b25e92ca3dc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2014 by Jacob Alexander
+/* Copyright (C) 2014-2015 by Jacob Alexander
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -49,10 +49,12 @@ void cliFunc_matrixState( char* args );
 // ----- Variables -----
 
 // Scan Module command dictionary
-const char matrixCLIDictName[] = "Matrix Module Commands";
-const CLIDictItem matrixCLIDict[] = {
-       { "matrixDebug",  "Enables matrix debug mode, prints out each scan code." NL "\t\tIf argument \033[35mT\033[0m is given, prints out each scan code state transition.", cliFunc_matrixDebug },
-       { "matrixState",  "Prints out the current scan table N times." NL "\t\t \033[1mO\033[0m - Off, \033[1;33mP\033[0m - Press, \033[1;32mH\033[0m - Hold, \033[1;35mR\033[0m - Release, \033[1;31mI\033[0m - Invalid", cliFunc_matrixState },
+CLIDict_Entry( matrixDebug,  "Enables matrix debug mode, prints out each scan code." NL "\t\tIf argument \033[35mT\033[0m is given, prints out each scan code state transition." );
+CLIDict_Entry( matrixState,  "Prints out the current scan table N times." NL "\t\t \033[1mO\033[0m - Off, \033[1;33mP\033[0m - Press, \033[1;32mH\033[0m - Hold, \033[1;35mR\033[0m - Release, \033[1;31mI\033[0m - Invalid" );
+
+CLIDict_Def( matrixCLIDict, "Matrix Module Commands" ) = {
+       CLIDict_Item( matrixDebug ),
+       CLIDict_Item( matrixState ),
        { 0, 0, 0 } // Null entry for dictionary end
 };
 
@@ -189,7 +191,7 @@ void Matrix_setup()
                Matrix_scanArray[ item ].prevState     = KeyState_Off;
                Matrix_scanArray[ item ].curState      = KeyState_Off;
                Matrix_scanArray[ item ].activeCount   = 0;
-               Matrix_scanArray[ item ].inactiveCount = 0xFFFF; // Start at 'off' steady state
+               Matrix_scanArray[ item ].inactiveCount = DebounceDivThreshold_define; // Start at 'off' steady state
        }
 
        // Clear scan stats counters
@@ -273,14 +275,14 @@ void Matrix_scan( uint16_t scanNum )
                        if ( Matrix_pin( Matrix_rows[ sense ], Type_Sense ) )
                        {
                                // Only update if not going to wrap around
-                               if ( state->activeCount < 0xFFFF ) state->activeCount += 1;
+                               if ( state->activeCount < DebounceDivThreshold_define ) state->activeCount += 1;
                                state->inactiveCount >>= 1;
                        }
                        // Signal Not Detected
                        else
                        {
                                // Only update if not going to wrap around
-                               if ( state->inactiveCount < 0xFFFF ) state->inactiveCount += 1;
+                               if ( state->inactiveCount < DebounceDivThreshold_define ) state->inactiveCount += 1;
                                state->activeCount >>= 1;
                        }