#include <Lib/ScanLib.h>
// Project Includes
+#include <cli.h>
#include <led.h>
#include <print.h>
// ----- Macros -----
-// Make sure we haven't overflowed the buffer
-#define bufferAdd(byte) \
- if ( KeyIndex_BufferUsed < KEYBOARD_BUFFER ) \
- KeyIndex_Buffer[KeyIndex_BufferUsed++] = byte
-
// Select mux
#define SET_FULL_MUX(X) ((ADMUX) = (((ADMUX) & ~(FULL_MUX_MASK)) | ((X) & (FULL_MUX_MASK))))
+// ----- Function Declarations -----
+
+void cliFunc_echo ( char* args );
+
+
+
// ----- Variables -----
// Buffer used to inform the macro processing module which keys have been detected as pressed
volatile uint8_t KeyIndex_BufferUsed;
+// Scan Module command dictionary
+char* scanCLIDictName = "DPH Module Commands";
+CLIDictItem scanCLIDict[] = {
+ { "echo", "Example command, echos the arguments.", cliFunc_echo },
+ { 0, 0, 0 } // Null entry for dictionary end
+};
+
+
// TODO dfj variables...needs cleaning up and commenting
// Variables used to calculate the starting sense value (averaging)
// ----- Function Declarations -----
-void dump( void );
+void dump();
void recovery( uint8_t on );
int sampleColumn( uint8_t column );
-void capsense_scan( void );
+void capsense_scan();
-void setup_ADC( void );
+void setup_ADC();
void strobe_w( uint8_t strobe_num );
// ----- Functions -----
// Initial setup for cap sense controller
-inline void scan_setup()
+inline void Scan_setup()
{
+ // Register Scan CLI dictionary
+ CLI_registerDictionary( scanCLIDict, scanCLIDictName );
+
// TODO dfj code...needs cleanup + commenting...
setup_ADC();
// TODO
#endif
- // TODO all this code should probably be in scan_resetKeyboard
+ // TODO all this code should probably be in Scan_resetKeyboard
for ( int i = 0; i < total_strobes; ++i)
{
cur_keymap[i] = 0;
{
sampleColumn( strobe_map[i] );
}
-
-
- // Reset the keyboard before scanning, we might be in a wierd state
- // Also sets the KeyIndex_BufferUsed to 0
- scan_resetKeyboard();
}
// Main Detection Loop
// This is where the important stuff happens
-inline uint8_t scan_loop()
+inline uint8_t Scan_loop()
{
capsense_scan();
// Return non-zero if macro and USB processing should be delayed
// Macro processing will always run if returning 0
- // USB processing only happens once the USB send timer expires, if it has not, scan_loop will be called
+ // USB processing only happens once the USB send timer expires, if it has not, Scan_loop will be called
// after the macro processing has been completed
return 0;
}
-// Reset Keyboard
-void scan_resetKeyboard( void )
-{
- // Empty buffer, now that keyboard has been reset
- KeyIndex_BufferUsed = 0;
-}
-
-
-// Send data to keyboard
-// NOTE: Only used for converters, since the scan module shouldn't handle sending data in a controller
-uint8_t scan_sendData( uint8_t dataPayload )
-{
- return 0;
-}
-
-
-// Reset/Hold keyboard
-// NOTE: Only used for converters, not needed for full controllers
-void scan_lockKeyboard( void )
-{
-}
-
-// NOTE: Only used for converters, not needed for full controllers
-void scan_unlockKeyboard( void )
-{
-}
-
-
// Signal KeyIndex_Buffer that it has been properly read
// NOTE: Only really required for implementing "tricks" in converters for odd protocols
-void scan_finishedWithBuffer( uint8_t sentKeys )
+void Scan_finishedWithBuffer( uint8_t sentKeys )
{
// Convenient place to clear the KeyIndex_Buffer
KeyIndex_BufferUsed = 0;
// Signal KeyIndex_Buffer that it has been properly read and sent out by the USB module
// NOTE: Only really required for implementing "tricks" in converters for odd protocols
-void scan_finishedWithUSBBuffer( uint8_t sentKeys )
+void Scan_finishedWithUSBBuffer( uint8_t sentKeys )
{
return;
}
// Only add the key to the buffer once
// NOTE: Buffer can easily handle multiple adds, just more efficient
// and nicer debug messages :P
- //bufferAdd( key );
+ //Macro_bufferAdd( key );
}
keys_debounce[key]++;
dump_count &= 0x0f;
}
+
+// ----- CLI Command Functions -----
+
+// XXX Just an example command showing how to parse arguments (more complex than generally needed)
+void cliFunc_echo( char* args )
+{
+ char* curArgs;
+ char* arg1Ptr;
+ char* arg2Ptr = args;
+
+ // Parse args until a \0 is found
+ while ( 1 )
+ {
+ print( NL ); // No \r\n by default after the command is entered
+
+ curArgs = arg2Ptr; // Use the previous 2nd arg pointer to separate the next arg from the list
+ CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
+
+ // Stop processing args if no more are found
+ if ( *arg1Ptr == '\0' )
+ break;
+
+ // Print out the arg
+ dPrint( arg1Ptr );
+ }
+}
+