]> git.donarmstrong.com Git - kiibohd-controller.git/blob - Scan/ADCTest/scan_loop.c
d1b65031acbe01a18be7334ed29cff78529492ee
[kiibohd-controller.git] / Scan / ADCTest / scan_loop.c
1 /* Copyright (C) 2014 by Jacob Alexander
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to deal
5  * in the Software without restriction, including without limitation the rights
6  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7  * copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19  * THE SOFTWARE.
20  */
21
22 // ----- Includes -----
23
24 // Compiler Includes
25 #include <Lib/ScanLib.h>
26
27 // Project Includes
28 #include <cli.h>
29 #include <led.h>
30 #include <print.h>
31
32 // Local Includes
33 #include "scan_loop.h"
34
35
36
37 // ----- Defines -----
38
39
40
41 // ----- Macros -----
42
43
44
45 // ----- Function Declarations -----
46
47 void cliFunc_echo( char* args );
48
49
50
51 // ----- Variables -----
52
53 // Buffer used to inform the macro processing module which keys have been detected as pressed
54 volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
55 volatile uint8_t KeyIndex_BufferUsed;
56
57
58 // Scan Module command dictionary
59 char*       scanCLIDictName = "ADC Test Module Commands";
60 CLIDictItem scanCLIDict[] = {
61         { "echo", "Example command, echos the arguments.", cliFunc_echo },
62         { 0, 0, 0 } // Null entry for dictionary end
63 };
64
65
66
67 // ----- Functions -----
68
69 // Setup
70 inline void Scan_setup()
71 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR
72 {
73         // Register Scan CLI dictionary
74         CLI_registerDictionary( scanCLIDict, scanCLIDictName );
75 }
76 #elif defined(_mk20dx128_) || defined(_mk20dx256_) // ARM
77 {
78         // Register Scan CLI dictionary
79         CLI_registerDictionary( scanCLIDict, scanCLIDictName );
80 }
81 #endif
82
83
84 // Main Detection Loop
85 inline uint8_t Scan_loop()
86 {
87         return 0;
88 }
89
90
91 // Signal KeyIndex_Buffer that it has been properly read
92 void Scan_finishedWithBuffer( uint8_t sentKeys )
93 {
94 }
95
96
97 // Signal that the keys have been properly sent over USB
98 void Scan_finishedWithUSBBuffer( uint8_t sentKeys )
99 {
100 }
101
102 // Reset Keyboard
103 void Scan_resetKeyboard()
104 {
105 }
106
107
108 // ----- CLI Command Functions -----
109
110 // XXX Just an example command showing how to parse arguments (more complex than generally needed)
111 void cliFunc_echo( char* args )
112 {
113         char* curArgs;
114         char* arg1Ptr;
115         char* arg2Ptr = args;
116
117         print( NL ); // No \n by default after the command is entered
118
119         // Parse args until a \0 is found
120         while ( 1 )
121         {
122                 curArgs = arg2Ptr; // Use the previous 2nd arg pointer to separate the next arg from the list
123                 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
124
125                 // Stop processing args if no more are found
126                 if ( *arg1Ptr == '\0' )
127                         break;
128
129                 // Print out the arg
130                 dPrint( arg1Ptr );
131         }
132 }
133