Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

matrix_scan.c 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* Copyright (C) 2016 by Jacob Alexander
  2. *
  3. * This file is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This file is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this file. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. // ----- Includes -----
  17. // Compiler Includes
  18. #include <Lib/ScanLib.h>
  19. // Project Includes
  20. #include <cli.h>
  21. #include <kll_defs.h>
  22. #include <led.h>
  23. #include <print.h>
  24. #include <macro.h>
  25. #include <Lib/delay.h>
  26. // Local Includes
  27. #include "matrix_scan.h"
  28. // Matrix Configuration
  29. //#include <matrix.h>
  30. // ----- Defines -----
  31. // ----- Function Declarations -----
  32. // CLI Functions
  33. void cliFunc_matrixDebug( char* args );
  34. void cliFunc_matrixInfo( char* args );
  35. void cliFunc_matrixState( char* args );
  36. // ----- Variables -----
  37. // Scan Module command dictionary
  38. 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." );
  39. CLIDict_Entry( matrixInfo, "Print info about the configured matrix." );
  40. 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" );
  41. CLIDict_Def( matrixCLIDict, "Matrix Module Commands" ) = {
  42. CLIDict_Item( matrixDebug ),
  43. CLIDict_Item( matrixInfo ),
  44. CLIDict_Item( matrixState ),
  45. { 0, 0, 0 } // Null entry for dictionary end
  46. };
  47. // ----- Functions -----
  48. void Matrix_setup()
  49. {
  50. // Register Matrix CLI dictionary
  51. CLI_registerDictionary( matrixCLIDict, matrixCLIDictName );
  52. }
  53. // Scan the matrix for keypresses
  54. // NOTE: scanNum should be reset to 0 after a USB send (to reset all the counters)
  55. void Matrix_scan( uint16_t scanNum )
  56. {
  57. }
  58. // Called by parent scan module whenever the available current changes
  59. // current - mA
  60. void Matrix_currentChange( unsigned int current )
  61. {
  62. // TODO - Any potential power savings?
  63. }
  64. // ----- CLI Command Functions -----
  65. void cliFunc_matrixInfo( char* args )
  66. {
  67. }
  68. void cliFunc_matrixDebug( char* args )
  69. {
  70. // Parse number from argument
  71. // NOTE: Only first argument is used
  72. char* arg1Ptr;
  73. char* arg2Ptr;
  74. CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
  75. // Set the matrix debug flag depending on the argument
  76. // If no argument, set to scan code only
  77. // If set to T, set to state transition
  78. switch ( arg1Ptr[0] )
  79. {
  80. // T as argument
  81. case 'T':
  82. case 't':
  83. break;
  84. // No argument
  85. case '\0':
  86. break;
  87. // Invalid argument
  88. default:
  89. return;
  90. }
  91. }
  92. void cliFunc_matrixState( char* args )
  93. {
  94. }