1 /* Copyright (C) 2014 by Jacob Alexander
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:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
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
22 // ----- Includes -----
25 #include <Lib/ScanLib.h>
33 #include "scan_loop.h"
37 // ----- Defines -----
45 // ----- Function Declarations -----
47 void cliFunc_echo( char* args );
51 // ----- Variables -----
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;
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
67 // ----- Functions -----
70 inline void Scan_setup()
71 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR
73 // Register Scan CLI dictionary
74 CLI_registerDictionary( scanCLIDict, scanCLIDictName );
76 #elif defined(_mk20dx128_) || defined(_mk20dx256_) // ARM
78 // Register Scan CLI dictionary
79 CLI_registerDictionary( scanCLIDict, scanCLIDictName );
84 // Main Detection Loop
85 inline uint8_t Scan_loop()
91 // Signal KeyIndex_Buffer that it has been properly read
92 void Scan_finishedWithBuffer( uint8_t sentKeys )
97 // Signal that the keys have been properly sent over USB
98 void Scan_finishedWithUSBBuffer( uint8_t sentKeys )
103 void Scan_resetKeyboard()
108 // ----- CLI Command Functions -----
110 // XXX Just an example command showing how to parse arguments (more complex than generally needed)
111 void cliFunc_echo( char* args )
115 char* arg2Ptr = args;
117 print( NL ); // No \n by default after the command is entered
119 // Parse args until a \0 is found
122 curArgs = arg2Ptr; // Use the previous 2nd arg pointer to separate the next arg from the list
123 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
125 // Stop processing args if no more are found
126 if ( *arg1Ptr == '\0' )