Adding test macros and basic "clicker" choose support
- Better macros are still needed for the clicker - Current macros should be separated as a sub-module - No LEDs implement yet - Caps Lock LED seems to be burnt out...
This commit is contained in:
parent
1877dcfa01
commit
0ac4251e16
@ -92,7 +92,7 @@ static uint8_t betkb_DefaultMap[] = {
|
|||||||
0, // 0x3C
|
0, // 0x3C
|
||||||
KEY_ENTER, // 0x3D
|
KEY_ENTER, // 0x3D
|
||||||
KEY_RIGHT_GUI, // 0x3E
|
KEY_RIGHT_GUI, // 0x3E
|
||||||
KEYPAD_1, // 0x3F
|
KEY_LEFT, // 0x3F (KEYPAD_1)
|
||||||
KEY_TAB, // 0x40
|
KEY_TAB, // 0x40
|
||||||
KEY_Q, // 0x41
|
KEY_Q, // 0x41
|
||||||
KEY_W, // 0x42
|
KEY_W, // 0x42
|
||||||
@ -147,10 +147,10 @@ static uint8_t betkb_DefaultMap[] = {
|
|||||||
KEYPAD_7, // 0x73
|
KEYPAD_7, // 0x73
|
||||||
KEYPAD_8, // 0x74
|
KEYPAD_8, // 0x74
|
||||||
KEYPAD_9, // 0x75
|
KEYPAD_9, // 0x75
|
||||||
KEYPAD_5, // 0x76
|
KEY_UP, // 0x76 (KEYPAD_5)
|
||||||
KEYPAD_6, // 0x77
|
KEYPAD_6, // 0x77
|
||||||
KEYPAD_2, // 0x78
|
KEY_DOWN, // 0x78 (KEYPAD_2)
|
||||||
KEYPAD_3, // 0x79
|
KEY_RIGHT, // 0x79 (KEYPAD_3)
|
||||||
KEYPAD_0, // 0x7A
|
KEYPAD_0, // 0x7A
|
||||||
KEYPAD_00, // 0x7B
|
KEYPAD_00, // 0x7B
|
||||||
KEYPAD_ENTER, // 0x7C
|
KEYPAD_ENTER, // 0x7C
|
||||||
@ -223,7 +223,7 @@ static uint8_t betkb_ColemakMap[] = {
|
|||||||
0, // 0x3C
|
0, // 0x3C
|
||||||
KEY_ENTER, // 0x3D
|
KEY_ENTER, // 0x3D
|
||||||
KEY_RIGHT_GUI, // 0x3E
|
KEY_RIGHT_GUI, // 0x3E
|
||||||
KEYPAD_1, // 0x3F
|
KEY_LEFT, // 0x3F (KEYPAD_1)
|
||||||
KEY_TAB, // 0x40
|
KEY_TAB, // 0x40
|
||||||
KEY_Q, // 0x41
|
KEY_Q, // 0x41
|
||||||
KEY_W, // 0x42
|
KEY_W, // 0x42
|
||||||
@ -278,10 +278,10 @@ static uint8_t betkb_ColemakMap[] = {
|
|||||||
KEYPAD_7, // 0x73
|
KEYPAD_7, // 0x73
|
||||||
KEYPAD_8, // 0x74
|
KEYPAD_8, // 0x74
|
||||||
KEYPAD_9, // 0x75
|
KEYPAD_9, // 0x75
|
||||||
KEYPAD_5, // 0x76
|
KEY_UP, // 0x76 (KEYPAD_5)
|
||||||
KEYPAD_6, // 0x77
|
KEYPAD_6, // 0x77
|
||||||
KEYPAD_2, // 0x78
|
KEY_DOWN, // 0x78 (KEYPAD_2)
|
||||||
KEYPAD_3, // 0x79
|
KEY_RIGHT, // 0x79 (KEYPAD_3)
|
||||||
KEYPAD_0, // 0x7A
|
KEYPAD_0, // 0x7A
|
||||||
KEYPAD_00, // 0x7B
|
KEYPAD_00, // 0x7B
|
||||||
KEYPAD_ENTER, // 0x7C
|
KEYPAD_ENTER, // 0x7C
|
||||||
|
@ -251,37 +251,60 @@ uint8_t sendCode = 0;
|
|||||||
// USBCode Macro Detection
|
// USBCode Macro Detection
|
||||||
int usbcodeMacro( uint8_t usbCode )
|
int usbcodeMacro( uint8_t usbCode )
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
// Keyboard Input Test Macro
|
// Keyboard Input Test Macro
|
||||||
switch ( usbCode )
|
switch ( usbCode )
|
||||||
{
|
{
|
||||||
case KEY_F1:
|
case KEY_F1:
|
||||||
sendCode--;
|
sendCode--;
|
||||||
scan_sendData( 0x90 );
|
//scan_sendData( 0x90 );
|
||||||
scan_sendData( sendCode );
|
scan_sendData( sendCode );
|
||||||
_delay_ms( 200 );
|
_delay_ms( 200 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_F2:
|
case KEY_F2:
|
||||||
scan_sendData( 0x90 );
|
//scan_sendData( 0x90 );
|
||||||
scan_sendData( sendCode );
|
scan_sendData( sendCode );
|
||||||
_delay_ms( 200 );
|
_delay_ms( 200 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_F3:
|
case KEY_F3:
|
||||||
sendCode++;
|
sendCode++;
|
||||||
scan_sendData( 0x90 );
|
//scan_sendData( 0x90 );
|
||||||
scan_sendData( sendCode );
|
scan_sendData( sendCode );
|
||||||
_delay_ms( 200 );
|
_delay_ms( 200 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case KEY_F4:
|
||||||
|
sendCode += 0x10;
|
||||||
|
//scan_sendData( 0x90 );
|
||||||
|
scan_sendData( sendCode );
|
||||||
|
_delay_ms( 200 );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEY_F5:
|
||||||
|
// Set 9th bit to 0
|
||||||
|
UCSR1B &= ~(1 << 0);
|
||||||
|
_delay_ms( 200 );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEY_F6:
|
||||||
|
// Set 9th bit to 1
|
||||||
|
UCSR1B |= (1 << 0);
|
||||||
|
_delay_ms( 200 );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEY_F11:
|
||||||
|
// Set click code
|
||||||
|
KeyIndex_Add_InputSignal = sendCode;
|
||||||
|
_delay_ms( 200 );
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
*/
|
//return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@
|
|||||||
// ----- Defines -----
|
// ----- Defines -----
|
||||||
|
|
||||||
// Pinout Defines
|
// Pinout Defines
|
||||||
#define RESET_PORT PORTB
|
#define HOLD_PORT PORTD
|
||||||
#define RESET_DDR DDRD
|
#define HOLD_DDR DDRD
|
||||||
#define RESET_PIN 0
|
#define HOLD_PIN 3
|
||||||
|
|
||||||
|
|
||||||
// ----- Macros -----
|
// ----- Macros -----
|
||||||
@ -57,6 +57,7 @@
|
|||||||
// Buffer used to inform the macro processing module which keys have been detected as pressed
|
// Buffer used to inform the macro processing module which keys have been detected as pressed
|
||||||
volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
|
volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
|
||||||
volatile uint8_t KeyIndex_BufferUsed;
|
volatile uint8_t KeyIndex_BufferUsed;
|
||||||
|
volatile uint8_t KeyIndex_Add_InputSignal; // Used to pass the (click/input value) to the keyboard for the clicker
|
||||||
|
|
||||||
|
|
||||||
// Buffer Signals
|
// Buffer Signals
|
||||||
@ -133,8 +134,13 @@ inline void scan_setup()
|
|||||||
UBRR1H = (uint8_t)(baud >> 8);
|
UBRR1H = (uint8_t)(baud >> 8);
|
||||||
UBRR1L = (uint8_t)baud;
|
UBRR1L = (uint8_t)baud;
|
||||||
|
|
||||||
// Enable the receiver, transitter, and RX Complete Interrupt as well as 9 bit data
|
// Enable the receiver, and RX Complete Interrupt as well as 9 bit data
|
||||||
UCSR1B = 0x9C;
|
UCSR1B = 0x94;
|
||||||
|
|
||||||
|
// The transmitter is only to be enabled when needed
|
||||||
|
// Set the pin to be pull-up otherwise (use the lowered voltage inverter in order to sink)
|
||||||
|
HOLD_DDR &= ~(1 << HOLD_PIN);
|
||||||
|
HOLD_PORT |= (1 << HOLD_PIN);
|
||||||
|
|
||||||
// Set frame format: 9 data, 1 stop bit, no parity
|
// Set frame format: 9 data, 1 stop bit, no parity
|
||||||
// Asynchrounous USART mode
|
// Asynchrounous USART mode
|
||||||
@ -143,6 +149,9 @@ inline void scan_setup()
|
|||||||
// Initially buffer doesn't need to be cleared (it's empty...)
|
// Initially buffer doesn't need to be cleared (it's empty...)
|
||||||
BufferReadyToClear = 0;
|
BufferReadyToClear = 0;
|
||||||
|
|
||||||
|
// InputSignal is off by default
|
||||||
|
KeyIndex_Add_InputSignal = 0x00;
|
||||||
|
|
||||||
// Reset the keyboard before scanning, we might be in a wierd state
|
// Reset the keyboard before scanning, we might be in a wierd state
|
||||||
scan_resetKeyboard();
|
scan_resetKeyboard();
|
||||||
}
|
}
|
||||||
@ -155,12 +164,13 @@ inline uint8_t scan_loop()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
void processKeyValue( uint8_t keyValue )
|
void processKeyValue( uint8_t keyValue )
|
||||||
{
|
{
|
||||||
// Interpret scan code
|
// Interpret scan code
|
||||||
switch ( keyValue )
|
switch ( keyValue )
|
||||||
{
|
{
|
||||||
|
case 0x00: // Break code from input?
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// Make sure the key isn't already in the buffer
|
// Make sure the key isn't already in the buffer
|
||||||
for ( uint8_t c = 0; c < KeyIndex_BufferUsed + 1; c++ )
|
for ( uint8_t c = 0; c < KeyIndex_BufferUsed + 1; c++ )
|
||||||
@ -169,6 +179,10 @@ void processKeyValue( uint8_t keyValue )
|
|||||||
if ( c == KeyIndex_BufferUsed )
|
if ( c == KeyIndex_BufferUsed )
|
||||||
{
|
{
|
||||||
bufferAdd( keyValue );
|
bufferAdd( keyValue );
|
||||||
|
|
||||||
|
// Only send data if enabled
|
||||||
|
if ( KeyIndex_Add_InputSignal )
|
||||||
|
scan_sendData( KeyIndex_Add_InputSignal );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,19 +227,31 @@ void removeKeyValue( uint8_t keyValue )
|
|||||||
// Send data
|
// Send data
|
||||||
uint8_t scan_sendData( uint8_t dataPayload )
|
uint8_t scan_sendData( uint8_t dataPayload )
|
||||||
{
|
{
|
||||||
|
// Enable the USART Transmitter
|
||||||
|
UCSR1B |= (1 << 3);
|
||||||
|
|
||||||
|
// Debug
|
||||||
|
char tmpStr[6];
|
||||||
|
hexToStr( dataPayload, tmpStr );
|
||||||
|
info_dPrint( "Sending - ", tmpStr );
|
||||||
|
|
||||||
UDR1 = dataPayload;
|
UDR1 = dataPayload;
|
||||||
|
|
||||||
|
// Wait for the payload
|
||||||
|
_delay_us( 800 );
|
||||||
|
|
||||||
|
// Disable the USART Transmitter
|
||||||
|
UCSR1B &= ~(1 << 3);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signal KeyIndex_Buffer that it has been properly read
|
// Signal KeyIndex_Buffer that it has been properly read
|
||||||
// TODO
|
|
||||||
void scan_finishedWithBuffer( void )
|
void scan_finishedWithBuffer( void )
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signal that the keys have been properly sent over USB
|
// Signal that the keys have been properly sent over USB
|
||||||
// TODO
|
|
||||||
void scan_finishedWithUSBBuffer( void )
|
void scan_finishedWithUSBBuffer( void )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -242,19 +268,9 @@ void scan_unlockKeyboard( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reset Keyboard
|
// Reset Keyboard
|
||||||
// TODO?
|
|
||||||
// - Holds the input read line high to flush the buffer
|
|
||||||
// - This does not actually reset the keyboard, but always seems brings it to a sane state
|
|
||||||
// - Won't work fully if keys are being pressed done at the same time
|
|
||||||
void scan_resetKeyboard( void )
|
void scan_resetKeyboard( void )
|
||||||
{
|
{
|
||||||
// Initiate data request line, but don't read the incoming data
|
|
||||||
//REQUEST_DATA(); TODO
|
|
||||||
|
|
||||||
// Not a calculated valued...
|
// Not a calculated valued...
|
||||||
_delay_ms( 50 );
|
_delay_ms( 50 );
|
||||||
|
|
||||||
// Stop request line
|
|
||||||
//STOP_DATA(); TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
extern volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
|
extern volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
|
||||||
extern volatile uint8_t KeyIndex_BufferUsed;
|
extern volatile uint8_t KeyIndex_BufferUsed;
|
||||||
|
extern volatile uint8_t KeyIndex_Add_InputSignal;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user