Archived
1
0

Added capabilities list debug option

- Changed macro/capabilities data structure to index capabilities rather than specify function pointers
- Used an 8 bit array, this reduced the max number of capabities to 255
	* Shouldn't be an issue, but this can be addressed if the limit is hit...unlikely though
This commit is contained in:
Jacob Alexander 2014-07-24 23:18:38 -07:00
parent ff05e1ccb7
commit f7bacebb26
2 changed files with 46 additions and 17 deletions

View File

@ -43,18 +43,18 @@
// ResultMacro.stateType -> <last key state type> // ResultMacro.stateType -> <last key state type>
typedef struct ResultMacro { typedef struct ResultMacro {
unsigned int *guide; uint8_t *guide;
unsigned int pos; unsigned int pos;
uint8_t state; uint8_t state;
uint8_t stateType; uint8_t stateType;
} ResultMacro; } ResultMacro;
// Guide, key element // Guide, key element
#define ResultGuideSize( guidePtr ) sizeof( ResultGuide ) / 4 - 1 + guidePtr->argCount #define ResultGuideSize( guidePtr ) sizeof( ResultGuide ) - 1 + guidePtr->argCount
typedef struct ResultGuide { typedef struct ResultGuide {
void *function; uint8_t index;
unsigned int argCount; uint8_t argCount;
unsigned int *args; uint8_t args; // This is used as an array pointer (but for packing purposes, must be 8 bit)
} ResultGuide; } ResultGuide;
@ -99,13 +99,13 @@ typedef struct TriggerGuide {
// ----- Macros ----- // ----- Macros -----
#define debugPrint_cap( arg ) (unsigned int) debugPrint_capability, 1, arg #define debugPrint_cap( arg ) 0, 1, arg
void debugPrint_capability( uint8_t state, uint8_t stateType, uint8_t *args ) void debugPrint_capability( uint8_t state, uint8_t stateType, uint8_t *args )
{ {
// Display capability name // Display capability name
if ( stateType == 0xFF && state == 0xFF ) if ( stateType == 0xFF && state == 0xFF )
{ {
print("debugPrint"); print("debugPrint(arg)");
return; return;
} }
@ -119,13 +119,13 @@ void debugPrint_capability( uint8_t state, uint8_t stateType, uint8_t *args )
print( " )" NL ); print( " )" NL );
} }
#define debugPrint2_cap( arg1, arg2 ) (unsigned int) debugPrint2_capability, 2, arg1, arg2 #define debugPrint2_cap( arg1, arg2 ) 1, 2, arg1, arg2
void debugPrint2_capability( uint8_t state, uint8_t stateType, uint8_t *args ) void debugPrint2_capability( uint8_t state, uint8_t stateType, uint8_t *args )
{ {
// Display capability name // Display capability name
if ( stateType == 0xFF && state == 0xFF ) if ( stateType == 0xFF && state == 0xFF )
{ {
print("debugPrint2"); print("debugPrint2(arg1,arg2)");
return; return;
} }
@ -141,6 +141,16 @@ void debugPrint2_capability( uint8_t state, uint8_t stateType, uint8_t *args )
print( " )" NL ); print( " )" NL );
} }
// Total Number of Capabilities
#define CapabilitiesNum sizeof( CapabilitiesList ) / 4
// Indexed Capabilities Table
// TODO Should be moved to the Scan Module
void *CapabilitiesList[] = {
debugPrint_capability,
debugPrint2_capability,
};
// -- Result Macros // -- Result Macros
@ -151,7 +161,7 @@ void debugPrint2_capability( uint8_t state, uint8_t stateType, uint8_t *args )
// Define_RM( index ); // Define_RM( index );
// * index - Result Macro index number // * index - Result Macro index number
// Must be used after Guide_RM // Must be used after Guide_RM
#define Guide_RM( index ) static unsigned int rm##index##_guide[] #define Guide_RM( index ) static uint8_t rm##index##_guide[]
#define Define_RM( index ) { rm##index##_guide, 0, 0, 0 } #define Define_RM( index ) { rm##index##_guide, 0, 0, 0 }
Guide_RM( 0 ) = { 1, debugPrint_cap( 0xDA ), 0 }; Guide_RM( 0 ) = { 1, debugPrint_cap( 0xDA ), 0 };
@ -188,6 +198,7 @@ ResultMacro ResultMacroList[] = {
Guide_TM( 0 ) = { 1, 0x10, 0x01, 0x73, 0 }; Guide_TM( 0 ) = { 1, 0x10, 0x01, 0x73, 0 };
Guide_TM( 1 ) = { 1, 0x0F, 0x01, 0x73, 1, 0x00, 0x01, 0x75, 0 }; Guide_TM( 1 ) = { 1, 0x0F, 0x01, 0x73, 1, 0x00, 0x01, 0x75, 0 };
Guide_TM( 2 ) = { 2, 0xF0, 0x01, 0x73, 0x00, 0x01, 0x74, 0 }; Guide_TM( 2 ) = { 2, 0xF0, 0x01, 0x73, 0x00, 0x01, 0x74, 0 };
Guide_TM( 3 ) = { 1, 0x10, 0x01, 0x76, 0 };
// Total number of trigger macros (tm's) // Total number of trigger macros (tm's)
// Used to create pending tm's table // Used to create pending tm's table
@ -198,6 +209,7 @@ TriggerMacro TriggerMacroList[] = {
Define_TM( 0, 0 ), Define_TM( 0, 0 ),
Define_TM( 1, 1 ), Define_TM( 1, 1 ),
Define_TM( 2, 2 ), Define_TM( 2, 2 ),
Define_TM( 3, 3 ),
}; };
@ -341,7 +353,7 @@ Define_TL( default, 0x72 ) = { 0 };
Define_TL( default, 0x73 ) = { 3, tm(0), tm(1), tm(2) }; Define_TL( default, 0x73 ) = { 3, tm(0), tm(1), tm(2) };
Define_TL( default, 0x74 ) = { 1, tm(2) }; Define_TL( default, 0x74 ) = { 1, tm(2) };
Define_TL( default, 0x75 ) = { 1, tm(1) }; Define_TL( default, 0x75 ) = { 1, tm(1) };
Define_TL( default, 0x76 ) = { 0 }; Define_TL( default, 0x76 ) = { 1, tm(3) };
Define_TL( default, 0x77 ) = { 0 }; Define_TL( default, 0x77 ) = { 0 };
Define_TL( default, 0x78 ) = { 0 }; Define_TL( default, 0x78 ) = { 0 };
Define_TL( default, 0x79 ) = { 0 }; Define_TL( default, 0x79 ) = { 0 };

View File

@ -370,7 +370,20 @@ inline void Macro_setup()
void cliFunc_capList( char* args ) void cliFunc_capList( char* args )
{ {
// TODO print( NL );
info_msg("Capabilities List");
// Iterate through all of the capabilities and display them
for ( unsigned int cap = 0; cap < CapabilitiesNum; cap++ )
{
print( NL "\t" );
printHex( cap );
print(" - ");
// Display/Lookup Capability Name (utilize debug mode of capability)
void (*capability)(uint8_t, uint8_t, uint8_t*) = (void(*)(uint8_t, uint8_t, uint8_t*))(CapabilitiesList[ cap ]);
capability( 0xFF, 0xFF, 0 );
}
} }
void cliFunc_capSelect( char* args ) void cliFunc_capSelect( char* args )
@ -588,20 +601,24 @@ void macroDebugShowResult( unsigned int index )
// Assign TriggerGuide element (key type, state and scancode) // Assign TriggerGuide element (key type, state and scancode)
ResultGuide *guide = (ResultGuide*)(&macro->guide[ pos ]); ResultGuide *guide = (ResultGuide*)(&macro->guide[ pos ]);
// Display Function Index
printHex( guide->index );
print("|");
// Display Function Ptr Address // Display Function Ptr Address
printHex( (unsigned int)guide->function ); printHex( (unsigned int)CapabilitiesList[ guide->index ] );
print("|"); print("|");
// Display/Lookup Capability Name (utilize debug mode of capability) // Display/Lookup Capability Name (utilize debug mode of capability)
void (*capability)(uint8_t, uint8_t, uint8_t*) = (void(*)(uint8_t, uint8_t, uint8_t*))(guide->function); void (*capability)(uint8_t, uint8_t, uint8_t*) = (void(*)(uint8_t, uint8_t, uint8_t*))(CapabilitiesList[ guide->index ]);
capability( 0xFF, 0xFF, 0 ); capability( 0xFF, 0xFF, 0 );
// Display Argument(s) // Display Argument(s)
print("("); print("(");
for ( unsigned int arg = 0; arg < guide->argCount; arg++ ) for ( unsigned int arg = 0; arg < guide->argCount; arg++ )
{ {
// Arguments are only 8 bit values (guides are 32 bit for function pointers) // Arguments are only 8 bit values
printHex( (uint8_t)(unsigned int)(&guide->args)[ arg ] ); printHex( (&guide->args)[ arg ] );
// Only show arg separator if there are args left // Only show arg separator if there are args left
if ( arg + 1 < guide->argCount ) if ( arg + 1 < guide->argCount )