Cleaning up the BudKeypad module for the Buffered Macro Module
- Fixed key repeat rate issues - Added the recent function additions to the scan module API
This commit is contained in:
parent
2519ea00e7
commit
108b0d3e8e
@ -64,8 +64,8 @@ set( SRCS
|
|||||||
#| "atmega32u4" # Teensy 2.0
|
#| "atmega32u4" # Teensy 2.0
|
||||||
#| "at90usb646" # Teensy++ 1.0
|
#| "at90usb646" # Teensy++ 1.0
|
||||||
#| "at90usb1286" # Teensy++ 2.0
|
#| "at90usb1286" # Teensy++ 2.0
|
||||||
#set( MCU "atmega32u4" )
|
set( MCU "atmega32u4" )
|
||||||
set( MCU "at90usb1286" )
|
#set( MCU "at90usb1286" )
|
||||||
|
|
||||||
|
|
||||||
#| Compiler flag to set the C Standard level.
|
#| Compiler flag to set the C Standard level.
|
||||||
|
@ -76,7 +76,6 @@
|
|||||||
scanCode = matrix[row*(MAX_ROW_SIZE+1)+col]; \
|
scanCode = matrix[row*(MAX_ROW_SIZE+1)+col]; \
|
||||||
if ( scanCode && !( pin & ( 1 << ( matrix[0*(MAX_ROW_SIZE+1)+col] % 10 ) ) ) ) \
|
if ( scanCode && !( pin & ( 1 << ( matrix[0*(MAX_ROW_SIZE+1)+col] % 10 ) ) ) ) \
|
||||||
{ \
|
{ \
|
||||||
warn_print("YAY!"); \
|
|
||||||
detectArray[scanCode]++; \
|
detectArray[scanCode]++; \
|
||||||
} \
|
} \
|
||||||
break
|
break
|
||||||
@ -243,7 +242,6 @@ inline void matrix_scan( uint8_t *matrix, uint8_t *detectArray )
|
|||||||
// Scan over the pins for each of the columns, and using the pin alias to determine which pin to set
|
// Scan over the pins for each of the columns, and using the pin alias to determine which pin to set
|
||||||
// (e.g. / 10 is for the pin name (A,B,C,etc.) and % 10 is for the position of the pin (A1,A2,etc.))
|
// (e.g. / 10 is for the pin name (A,B,C,etc.) and % 10 is for the position of the pin (A1,A2,etc.))
|
||||||
switch ( matrix[0*(MAX_ROW_SIZE+1)+col] / 10 )
|
switch ( matrix[0*(MAX_ROW_SIZE+1)+col] / 10 )
|
||||||
REG_SET(port##pin); break; \
|
|
||||||
{
|
{
|
||||||
#if defined(__AVR_AT90USB1286__)
|
#if defined(__AVR_AT90USB1286__)
|
||||||
case 0: // PINA
|
case 0: // PINA
|
||||||
|
@ -103,11 +103,51 @@ inline uint8_t scan_loop()
|
|||||||
// This should be resetting VERY quickly, cutting off a potentially valid keypress is not an issue
|
// This should be resetting VERY quickly, cutting off a potentially valid keypress is not an issue
|
||||||
for ( uint8_t key = 1; key < KeyIndex_Size + 1; key++ ) if ( ( KeyIndex_Array[key] & ~(1 << 7) ) > SAMPLE_THRESHOLD )
|
for ( uint8_t key = 1; key < KeyIndex_Size + 1; key++ ) if ( ( KeyIndex_Array[key] & ~(1 << 7) ) > SAMPLE_THRESHOLD )
|
||||||
{
|
{
|
||||||
bufferAdd( key );
|
// Debug output (keypress detected)
|
||||||
|
char tmpStr[6];
|
||||||
|
hexToStr( key, tmpStr );
|
||||||
|
dPrintStrs( tmpStr, " " );
|
||||||
|
|
||||||
|
// Add the key to the buffer, if it isn't already in the current Key Buffer
|
||||||
|
for ( uint8_t c = 0; c < KeyIndex_BufferUsed + 1; c++ )
|
||||||
|
{
|
||||||
|
// Key isn't in the buffer yet
|
||||||
|
if ( c == KeyIndex_BufferUsed )
|
||||||
|
{
|
||||||
|
bufferAdd( key );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Key already in the buffer
|
||||||
|
if ( KeyIndex_Buffer[c] == key )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
KeyIndex_Array[key] = (1 << 7);
|
KeyIndex_Array[key] = (1 << 7);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Remove the key from the buffer only if it was previously known to be pressed
|
||||||
|
if ( KeyIndex_Array[key] & (1 << 7 ) )
|
||||||
|
{
|
||||||
|
// Check for the released key, and shift the other keys lower on the buffer
|
||||||
|
for ( uint8_t c = 0; c < KeyIndex_BufferUsed; c++ )
|
||||||
|
{
|
||||||
|
// Key to release found
|
||||||
|
if ( KeyIndex_Buffer[c] == key )
|
||||||
|
{
|
||||||
|
// Shift keys from c position
|
||||||
|
for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ )
|
||||||
|
KeyIndex_Buffer[k] = KeyIndex_Buffer[k + 1];
|
||||||
|
|
||||||
|
// Decrement Buffer
|
||||||
|
KeyIndex_BufferUsed--;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
KeyIndex_Array[key] = 0x00;
|
KeyIndex_Array[key] = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,3 +155,17 @@ inline uint8_t scan_loop()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Signal that the keys have been properly sent over USB
|
||||||
|
inline void scan_finishedWithUSBBuffer( void )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Signal KeyIndex_Buffer that it has been fully scanned using the macro module
|
||||||
|
inline void scan_finishedWithBuffer( void )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -58,5 +58,16 @@ extern volatile uint8_t KeyIndex_BufferUsed;
|
|||||||
void scan_setup( void );
|
void scan_setup( void );
|
||||||
uint8_t scan_loop( void );
|
uint8_t scan_loop( void );
|
||||||
|
|
||||||
|
|
||||||
|
// Functions available to macro.c
|
||||||
|
uint8_t scan_sendData( uint8_t dataPayload );
|
||||||
|
|
||||||
|
void scan_finishedWithBuffer( void );
|
||||||
|
void scan_finishedWithUSBBuffer( void );
|
||||||
|
void scan_lockKeyboard( void );
|
||||||
|
void scan_unlockKeyboard( void );
|
||||||
|
void scan_resetKeyboard( void );
|
||||||
|
|
||||||
|
|
||||||
#endif // __SCAN_LOOP_H
|
#endif // __SCAN_LOOP_H
|
||||||
|
|
||||||
|
@ -135,8 +135,8 @@ static const uint8_t PROGMEM keyboard_hid_report_desc[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t PROGMEM debug_hid_report_desc[] = {
|
static const uint8_t PROGMEM debug_hid_report_desc[] = {
|
||||||
//0x06, 0x30, 0xFF, // Usage Page 0xFF31 (vendor defined)
|
0x06, 0x30, 0xFF, // Usage Page 0xFF31 (vendor defined)
|
||||||
0x06, 0x31, 0xFF, // Usage Page 0xFF31 (vendor defined)
|
//0x06, 0x31, 0xFF, // Usage Page 0xFF31 (vendor defined)
|
||||||
0x09, 0x74, // Usage 0x74
|
0x09, 0x74, // Usage 0x74
|
||||||
0xA1, 0x53, // Collection 0x53
|
0xA1, 0x53, // Collection 0x53
|
||||||
0x75, 0x08, // report size = 8 bits
|
0x75, 0x08, // report size = 8 bits
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#| Please the {Scan,Macro,USB,Debug}/module.txt for information on the modules and how to create new ones
|
#| Please the {Scan,Macro,USB,Debug}/module.txt for information on the modules and how to create new ones
|
||||||
|
|
||||||
##| Deals with acquiring the keypress information and turning it into a key index
|
##| Deals with acquiring the keypress information and turning it into a key index
|
||||||
set( ScanModule "EpsonQX-10" )
|
set( ScanModule "BudKeypad" )
|
||||||
|
|
||||||
##| Uses the key index and potentially applies special conditions to it, mapping it to a usb key code
|
##| Uses the key index and potentially applies special conditions to it, mapping it to a usb key code
|
||||||
set( MacroModule "buffer" )
|
set( MacroModule "buffer" )
|
||||||
|
Reference in New Issue
Block a user