28 Commits

Author SHA1 Message Date
László Monda
28f5999cbb Bump firmware version to 8.4.2, update changelog and versions.h 2018-08-02 13:00:31 +02:00
László Monda
fe7505a2df Merge branch 'master' of github.com:UltimateHackingKeyboard/firmware 2018-08-02 12:51:22 +02:00
László Monda
b6ac16074c Merge pull request #149 from UltimateHackingKeyboard/secondary-role
Fix various secondary role bugs
2018-08-02 03:41:25 +02:00
Eric Tang
0bf205c5d2 Keep sticky modifiers active when modifier-only keys are pressed 2018-08-01 18:12:12 -07:00
Eric Tang
e4a99a9400 Make sticky modifiers work consistently 2018-08-01 16:36:29 -07:00
Eric Tang
1e9b5833eb Correctly handle keypresses which triggers a secondary role 2018-08-01 15:53:55 -07:00
Eric Tang
79b052fca7 Remove redundant conditions 2018-07-31 16:12:51 -07:00
László Monda
baee0b5682 Bump firmware version to 8.4.1, update changelog, package.json, versions.h 2018-07-31 23:57:33 +02:00
László Monda
6153d54f59 Merge pull request #144 from UltimateHackingKeyboard/sleep-wake
Make some improvements to the sleep/wake code
2018-07-26 22:47:40 +02:00
Eric Tang
0a6ebe2903 Remove the old code for detecting new keypresses 2018-07-25 15:16:15 -07:00
László Monda
1fbbeb0f33 Bump firmware version to 8.4.0, update changelog, package.json, versions.h 2018-07-24 15:30:18 +02:00
László Monda
456f0e9e58 Merge branch 'master' of github.com:UltimateHackingKeyboard/firmware 2018-07-24 14:50:53 +02:00
László Monda
0248a0e79f Set debounce press and release time to 50ms by default. 2018-07-24 14:50:16 +02:00
Eric Tang
0e5ec29433 Tweak the logic of the USB stack test 2018-07-22 21:22:48 -07:00
Eric Tang
2d7cd68459 Make some improvements to the sleep/wake code 2018-07-22 13:13:29 -07:00
László Monda
5ac10fabcb Add back simulateKeypresses. 2018-07-22 16:24:05 +02:00
László Monda
b11017609d Merge pull request #143 from UltimateHackingKeyboard/usb-variables
Expose variables via USB
2018-07-22 16:04:55 +02:00
Eric Tang
c3a5d258e5 Rename the test mode for clarity 2018-07-20 17:31:00 -07:00
Eric Tang
a2866feb77 Temporarily allow the USB stack test to be activated through USB 2018-07-20 17:23:44 -07:00
Eric Tang
8c50192d6c Introduce a new way of activating the test mode 2018-07-20 17:17:59 -07:00
Eric Tang
63d82d92db Expose variables via USB 2018-07-20 17:17:30 -07:00
László Monda
1bced1be13 Merge branch 'debounce-configuration' 2018-07-16 18:24:38 +02:00
Eric Tang
86196d438c Add a test mode 2018-07-05 20:15:33 -07:00
Eric Tang
d722b3d173 Make debounce times configurable on the fly 2018-07-05 14:41:19 -07:00
Eric Tang
2ef5c49090 Merge branch 'interrupt-removal' 2018-07-05 14:34:33 -07:00
Eric Tang
5a137392ee Remove the key scanning interrupt 2018-07-05 12:43:38 -07:00
Eric Tang
27d12ea31f Remove the debouncing interrupt 2018-07-05 12:33:55 -07:00
Eric Tang
9ba09ec8eb Convert key_state_t to a bit field 2018-07-05 11:50:13 -07:00
29 changed files with 338 additions and 178 deletions

View File

@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to the [UHK Versioning](VERSIONING.md) conventions. and this project adheres to the [UHK Versioning](VERSIONING.md) conventions.
## [8.4.2] - 2018-08-02
Device Protocol: 4.4.0 | Module Protocol: 4.0.0 | User Config: 4.1.0 | Hardware Config: 1.0.0
- Fix various bugs related to secondary role handling and sticky modifier states.
## [8.4.1] - 2018-07-31
Device Protocol: 4.4.0 | Module Protocol: 4.0.0 | User Config: 4.1.0 | Hardware Config: 1.0.0
- Make some improvements to the sleep/wake code.
## [8.4.0] - 2018-07-24
Device Protocol: 4.**4.0** | Module Protocol: 4.0.0 | User Config: 4.1.0 | Hardware Config: 1.0.0
- Rewrite the key debouncer and set the press and release timeouts to 50ms.
- Add hardcoded test keymap.
- Make debounce timeouts configurable via USB. `DEVICEPROTOCOL:MINOR`
- Make the hardcoded test keymap able to trigger via USB. `DEVICEPROTOCOL:MINOR`
- Allow the USB stack test mode to be activated via USB. `DEVICEPROTOCOL:MINOR`
## [8.3.3] - 2018-07-03 ## [8.3.3] - 2018-07-03
Device Protocol: 4.3.1 | Module Protocol: 4.0.0 | User Config: 4.1.0 | Hardware Config: 1.0.0 Device Protocol: 4.3.1 | Module Protocol: 4.0.0 | User Config: 4.1.0 | Hardware Config: 1.0.0

View File

@@ -12,7 +12,6 @@
#include "init_peripherals.h" #include "init_peripherals.h"
#include "eeprom.h" #include "eeprom.h"
#include "timer.h" #include "timer.h"
#include "key_debouncer.h"
#include "usb_api.h" #include "usb_api.h"
#include "slave_scheduler.h" #include "slave_scheduler.h"
#include "bootloader/wormhole.h" #include "bootloader/wormhole.h"
@@ -66,8 +65,6 @@ static void initInterruptPriorities(void)
NVIC_SetPriority(PIT_I2C_WATCHDOG_IRQ_ID, 1); NVIC_SetPriority(PIT_I2C_WATCHDOG_IRQ_ID, 1);
NVIC_SetPriority(I2C_EEPROM_BUS_IRQ_ID, 0); NVIC_SetPriority(I2C_EEPROM_BUS_IRQ_ID, 0);
NVIC_SetPriority(PIT_TIMER_IRQ_ID, 3); NVIC_SetPriority(PIT_TIMER_IRQ_ID, 3);
NVIC_SetPriority(PIT_KEY_SCANNER_IRQ_ID, 4);
NVIC_SetPriority(PIT_KEY_DEBOUNCER_IRQ_ID, 4);
NVIC_SetPriority(I2C_MAIN_BUS_IRQ_ID, 4); NVIC_SetPriority(I2C_MAIN_BUS_IRQ_ID, 4);
NVIC_SetPriority(USB_IRQ_ID, 4); NVIC_SetPriority(USB_IRQ_ID, 4);
} }
@@ -159,6 +156,5 @@ void InitPeripherals(void)
TestLed_Init(); TestLed_Init();
LedPwm_Init(); LedPwm_Init();
InitI2cWatchdog(); InitI2cWatchdog();
InitKeyDebouncer();
EEPROM_Init(); EEPROM_Init();
} }

View File

@@ -1,32 +0,0 @@
#include "key_debouncer.h"
#include "fsl_pit.h"
#include "slot.h"
#include "module.h"
#include "key_states.h"
#include "peripherals/test_led.h"
void PIT_KEY_DEBOUNCER_HANDLER(void)
{
TestLed_Toggle();
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
uint8_t *debounceCounter = &KeyStates[slotId][keyId].debounceCounter;
if (*debounceCounter) {
--(*debounceCounter);
}
}
}
PIT_ClearStatusFlags(PIT, PIT_KEY_DEBOUNCER_CHANNEL, PIT_TFLG_TIF_MASK);
}
void InitKeyDebouncer(void)
{
pit_config_t pitConfig;
PIT_GetDefaultConfig(&pitConfig);
PIT_Init(PIT, &pitConfig);
PIT_SetTimerPeriod(PIT, PIT_KEY_DEBOUNCER_CHANNEL, MSEC_TO_COUNT(KEY_DEBOUNCER_INTERVAL_MSEC, PIT_SOURCE_CLOCK));
PIT_EnableInterrupts(PIT, PIT_KEY_DEBOUNCER_CHANNEL, kPIT_TimerInterruptEnable);
EnableIRQ(PIT_KEY_DEBOUNCER_IRQ_ID);
PIT_StartTimer(PIT, PIT_KEY_DEBOUNCER_CHANNEL);
}

View File

@@ -1,18 +0,0 @@
#ifndef __KEY_DEBOUNCER_H__
#define __KEY_DEBOUNCER_H__
// Includes:
#include "peripherals/pit.h"
#include "fsl_common.h"
// Macros:
#define KEY_DEBOUNCER_INTERVAL_MSEC 1
#define KEY_DEBOUNCER_TIMEOUT_MSEC 100
// Functions:
void InitKeyDebouncer(void);
#endif

View File

@@ -1,22 +0,0 @@
#include "fsl_pit.h"
#include "key_scanner.h"
uint32_t KeyScannerCounter;
void PIT_KEY_SCANNER_HANDLER(void)
{
KeyMatrix_ScanRow(&RightKeyMatrix);
KeyScannerCounter++;
PIT_ClearStatusFlags(PIT, PIT_KEY_SCANNER_CHANNEL, PIT_TFLG_TIF_MASK);
}
void InitKeyScanner(void)
{
pit_config_t pitConfig;
PIT_GetDefaultConfig(&pitConfig);
PIT_Init(PIT, &pitConfig);
PIT_SetTimerPeriod(PIT, PIT_KEY_SCANNER_CHANNEL, USEC_TO_COUNT(KEY_SCANNER_INTERVAL_USEC, PIT_SOURCE_CLOCK));
PIT_EnableInterrupts(PIT, PIT_KEY_SCANNER_CHANNEL, kPIT_TimerInterruptEnable);
EnableIRQ(PIT_KEY_SCANNER_IRQ_ID);
PIT_StartTimer(PIT, PIT_KEY_SCANNER_CHANNEL);
}

View File

@@ -1,21 +0,0 @@
#ifndef __KEY_SCANNER_H__
#define __KEY_SCANNER_H__
// Includes:
#include "peripherals/pit.h"
#include "right_key_matrix.h"
// Macros:
#define KEY_SCANNER_INTERVAL_USEC (1000 / RIGHT_KEY_MATRIX_ROWS_NUM)
// Variables:
extern uint32_t KeyScannerCounter;
// Functions:
void InitKeyScanner(void);
#endif

View File

@@ -10,10 +10,11 @@
// Typedefs: // Typedefs:
typedef struct { typedef struct {
bool previous; uint8_t timestamp;
bool current; bool previous : 1;
bool suppressed; bool current : 1;
uint8_t debounceCounter; bool suppressed : 1;
bool debouncing : 1;
} key_state_t; } key_state_t;
// Variables: // Variables:

View File

@@ -6,7 +6,7 @@
#include "bus_pal_hardware.h" #include "bus_pal_hardware.h"
#include "command.h" #include "command.h"
#include "eeprom.h" #include "eeprom.h"
#include "key_scanner.h" #include "right_key_matrix.h"
#include "usb_commands/usb_command_apply_config.h" #include "usb_commands/usb_command_apply_config.h"
#include "peripherals/reset_button.h" #include "peripherals/reset_button.h"
#include "config_parser/config_globals.h" #include "config_parser/config_globals.h"
@@ -44,7 +44,6 @@ int main(void)
} else { } else {
InitSlaveScheduler(); InitSlaveScheduler();
KeyMatrix_Init(&RightKeyMatrix); KeyMatrix_Init(&RightKeyMatrix);
InitKeyScanner();
InitUsb(); InitUsb();
while (1) { while (1) {
@@ -52,6 +51,8 @@ int main(void)
UsbCommand_ApplyConfig(); UsbCommand_ApplyConfig();
IsConfigInitialized = true; IsConfigInitialized = true;
} }
KeyMatrix_ScanRow(&RightKeyMatrix);
++MatrixScanCounter;
UpdateUsbReports(); UpdateUsbReports();
__WFI(); __WFI();
} }

View File

@@ -17,12 +17,4 @@
#define PIT_TIMER_IRQ_ID PIT1_IRQn #define PIT_TIMER_IRQ_ID PIT1_IRQn
#define PIT_TIMER_CHANNEL kPIT_Chnl_1 #define PIT_TIMER_CHANNEL kPIT_Chnl_1
#define PIT_KEY_SCANNER_HANDLER PIT2_IRQHandler
#define PIT_KEY_SCANNER_IRQ_ID PIT2_IRQn
#define PIT_KEY_SCANNER_CHANNEL kPIT_Chnl_2
#define PIT_KEY_DEBOUNCER_HANDLER PIT3_IRQHandler
#define PIT_KEY_DEBOUNCER_IRQ_ID PIT3_IRQn
#define PIT_KEY_DEBOUNCER_CHANNEL kPIT_Chnl_3
#endif #endif

View File

@@ -1,5 +1,7 @@
#include "right_key_matrix.h" #include "right_key_matrix.h"
uint32_t MatrixScanCounter;
key_matrix_t RightKeyMatrix = { key_matrix_t RightKeyMatrix = {
.colNum = RIGHT_KEY_MATRIX_COLS_NUM, .colNum = RIGHT_KEY_MATRIX_COLS_NUM,
.rowNum = RIGHT_KEY_MATRIX_ROWS_NUM, .rowNum = RIGHT_KEY_MATRIX_ROWS_NUM,

View File

@@ -14,5 +14,6 @@
// Variables: // Variables:
extern key_matrix_t RightKeyMatrix; extern key_matrix_t RightKeyMatrix;
extern uint32_t MatrixScanCounter;
#endif #endif

113
right/src/test_switches.c Normal file
View File

@@ -0,0 +1,113 @@
#include "test_switches.h"
#include "led_display.h"
#include "key_action.h"
#include "keymap.h"
bool TestSwitches = false;
static const key_action_t TestKeymap[1][2][MAX_KEY_COUNT_PER_MODULE] = {
// Base layer
{
// Right keyboard half
{
// Row 1
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_7_AND_AMPERSAND } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_8_AND_ASTERISK } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_9_AND_OPENING_PARENTHESIS } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_EQUAL_AND_PLUS } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_BACKSPACE } },
// Row 2
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_U } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_I } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_O } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_P } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_OPENING_BRACKET_AND_OPENING_BRACE } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_CLOSING_BRACKET_AND_CLOSING_BRACE } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_BACKSLASH_AND_PIPE } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_Y } },
// Row 3
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_J } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_K } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_L } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_SEMICOLON_AND_COLON } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_APOSTROPHE_AND_QUOTE } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_PLUS } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_H } },
// Row 4
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_N } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_M } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_COMMA_AND_LESS_THAN_SIGN } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_DOT_AND_GREATER_THAN_SIGN } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_SLASH_AND_QUESTION_MARK } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_SHIFT } },
{ .type = KeyActionType_None },
// Row 5
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_6_AND_RIGHT_ARROW } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_ASTERISK } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_7_AND_HOME } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_8_AND_UP_ARROW } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_9_AND_PAGE_UP } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_0_AND_INSERT } },
},
// Left keyboard half
{
// Row 1
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_GRAVE_ACCENT_AND_TILDE } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_1_AND_EXCLAMATION } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_2_AND_AT } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_3_AND_HASHMARK } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_4_AND_DOLLAR } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_5_AND_PERCENTAGE } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_6_AND_CARET } },
// Row 2
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_ESCAPE } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_Q } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_W } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_E } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_R } },
{ .type = KeyActionType_None },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_T } },
// Row 3
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_MINUS } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_A } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_S } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_D } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_F } },
{ .type = KeyActionType_None },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_G } },
// Row 4
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_SHIFT } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_NON_US_BACKSLASH_AND_PIPE } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_Z } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_X } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_C } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_V } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_B } },
// Row 5
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_1_AND_END } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_2_AND_DOWN_ARROW } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_3_AND_PAGE_DOWN } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_4_AND_LEFT_ARROW } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_SLASH } },
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_KEYPAD_5 } },
{ .type = KeyActionType_None },
}
}
};
void TestSwitches_Activate(void)
{
memcpy(&CurrentKeymap, &TestKeymap, sizeof TestKeymap);
LedDisplay_SetText(3, "TES");
}

16
right/src/test_switches.h Normal file
View File

@@ -0,0 +1,16 @@
#ifndef __TEST_MODE_H__
#define __TEST_MODE_H__
// Includes:
#include <stdbool.h>
// Functions:
void TestSwitches_Activate(void);
// Variables:
extern bool TestSwitches;
#endif

View File

@@ -5,7 +5,7 @@
#include "i2c_watchdog.h" #include "i2c_watchdog.h"
#include "buffer.h" #include "buffer.h"
#include "timer.h" #include "timer.h"
#include "key_scanner.h" #include "right_key_matrix.h"
#include "usb_report_updater.h" #include "usb_report_updater.h"
#include "usb_interfaces/usb_interface_basic_keyboard.h" #include "usb_interfaces/usb_interface_basic_keyboard.h"
#include "usb_interfaces/usb_interface_media_keyboard.h" #include "usb_interfaces/usb_interface_media_keyboard.h"
@@ -20,7 +20,7 @@ void UsbCommand_GetDebugBuffer(void)
SetDebugBufferUint32(5, I2cSlaveScheduler_Counter); SetDebugBufferUint32(5, I2cSlaveScheduler_Counter);
SetDebugBufferUint32(9, I2cWatchdog_WatchCounter); SetDebugBufferUint32(9, I2cWatchdog_WatchCounter);
SetDebugBufferUint32(13, I2cWatchdog_RecoveryCounter); SetDebugBufferUint32(13, I2cWatchdog_RecoveryCounter);
SetDebugBufferUint32(17, KeyScannerCounter); SetDebugBufferUint32(17, MatrixScanCounter);
SetDebugBufferUint32(21, UsbReportUpdateCounter); SetDebugBufferUint32(21, UsbReportUpdateCounter);
SetDebugBufferUint32(25, Timer_GetCurrentTime()); SetDebugBufferUint32(25, Timer_GetCurrentTime());
SetDebugBufferUint32(29, UsbGenericHidActionCounter); SetDebugBufferUint32(29, UsbGenericHidActionCounter);

View File

@@ -0,0 +1,25 @@
#include "usb_protocol_handler.h"
#include "usb_commands/usb_command_get_variable.h"
#include "key_matrix.h"
#include "test_switches.h"
#include "usb_report_updater.h"
void UsbCommand_GetVariable(void)
{
usb_variable_id_t variableId = GetUsbRxBufferUint8(1);
switch (variableId) {
case UsbVariable_TestSwitches:
SetUsbTxBufferUint8(1, TestSwitches);
break;
case UsbVariable_TestUsbStack:
SetUsbTxBufferUint8(1, TestUsbStack);
break;
case UsbVariable_DebounceTimePress:
SetUsbTxBufferUint8(1, DebounceTimePress);
break;
case UsbVariable_DebounceTimeRelease:
SetUsbTxBufferUint8(1, DebounceTimeRelease);
break;
}
}

View File

@@ -0,0 +1,8 @@
#ifndef __USB_COMMAND_GET_VARIABLE_H__
#define __USB_COMMAND_GET_VARIABLE_H__
// Functions:
void UsbCommand_GetVariable(void);
#endif

View File

@@ -0,0 +1,28 @@
#include "usb_protocol_handler.h"
#include "usb_commands/usb_command_set_variable.h"
#include "key_matrix.h"
#include "test_switches.h"
#include "usb_report_updater.h"
void UsbCommand_SetVariable(void)
{
usb_variable_id_t variableId = GetUsbRxBufferUint8(1);
switch (variableId) {
case UsbVariable_TestSwitches:
if (GetUsbRxBufferUint8(2)) {
TestSwitches = true;
TestSwitches_Activate();
}
break;
case UsbVariable_TestUsbStack:
TestUsbStack = GetUsbRxBufferUint8(2);
break;
case UsbVariable_DebounceTimePress:
DebounceTimePress = GetUsbRxBufferUint8(2);
break;
case UsbVariable_DebounceTimeRelease:
DebounceTimeRelease = GetUsbRxBufferUint8(2);
break;
}
}

View File

@@ -0,0 +1,8 @@
#ifndef __USB_COMMAND_SET_VARIABLE_H__
#define __USB_COMMAND_SET_VARIABLE_H__
// Functions:
void UsbCommand_SetVariable(void);
#endif

View File

@@ -163,23 +163,30 @@ static usb_device_class_config_list_struct_t UsbDeviceCompositeConfigList = {
} }
}}; }};
bool IsHostSleeping = false; volatile bool SleepModeActive = true;
static volatile bool wakeUpHostAllowed;
static void suspendHost(void) { static void suspendUhk(void) {
IsHostSleeping = true; SleepModeActive = true;
LedSlaveDriver_DisableLeds(); LedSlaveDriver_DisableLeds();
} }
void WakeUpHost(bool sendResume) { static void wakeUpUhk(void) {
if (sendResume) { // The device should wake up the host. SleepModeActive = false;
// Send resume signal - this will call USB_DeviceKhciControl(khciHandle, kUSB_DeviceControlResume, NULL);
USB_DeviceSetStatus(UsbCompositeDevice.deviceHandle, kUSB_DeviceStatusBus, NULL);
}
IsHostSleeping = false;
LedSlaveDriver_UpdateLeds(); LedSlaveDriver_UpdateLeds();
} }
void WakeUpHost(void) {
if (!wakeUpHostAllowed) {
return;
}
// Send resume signal - this will call USB_DeviceKhciControl(khciHandle, kUSB_DeviceControlResume, NULL);
USB_DeviceSetStatus(UsbCompositeDevice.deviceHandle, kUSB_DeviceStatusBus, NULL);
while (SleepModeActive) {
;
}
}
static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event, void *param) static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event, void *param)
{ {
usb_status_t status = kStatus_USB_Error; usb_status_t status = kStatus_USB_Error;
@@ -190,10 +197,6 @@ static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event,
return status; return status;
} }
if (IsHostSleeping) {
WakeUpHost(false); // Wake up the keyboard if there is any activity on the bus.
}
switch (event) { switch (event) {
case kUSB_DeviceEventBusReset: case kUSB_DeviceEventBusReset:
UsbCompositeDevice.attach = 0; UsbCompositeDevice.attach = 0;
@@ -201,17 +204,17 @@ static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event,
break; break;
case kUSB_DeviceEventSuspend: case kUSB_DeviceEventSuspend:
if (UsbCompositeDevice.attach) { if (UsbCompositeDevice.attach) {
suspendHost(); // The host sends this event when it goes to sleep, so turn off all the LEDs. suspendUhk(); // The host sends this event when it goes to sleep, so turn off all the LEDs.
status = kStatus_USB_Success; status = kStatus_USB_Success;
} }
break; break;
case kUSB_DeviceEventResume: case kUSB_DeviceEventResume:
// We will just wake up the host if there is any activity on the bus. wakeUpUhk();
// The problem is that the host won't send a resume event when it boots, so the lights will never come back on.
status = kStatus_USB_Success; status = kStatus_USB_Success;
break; break;
case kUSB_DeviceEventSetConfiguration: case kUSB_DeviceEventSetConfiguration:
UsbCompositeDevice.attach = 1; UsbCompositeDevice.attach = 1;
wakeUpUhk();
UsbCompositeDevice.currentConfiguration = *temp8; UsbCompositeDevice.currentConfiguration = *temp8;
UsbGenericHidSetConfiguration(UsbCompositeDevice.genericHidHandle, *temp8); UsbGenericHidSetConfiguration(UsbCompositeDevice.genericHidHandle, *temp8);
UsbBasicKeyboardSetConfiguration(UsbCompositeDevice.basicKeyboardHandle, *temp8); UsbBasicKeyboardSetConfiguration(UsbCompositeDevice.basicKeyboardHandle, *temp8);
@@ -266,6 +269,10 @@ static usb_status_t usbDeviceCallback(usb_device_handle handle, uint32_t event,
case kUSB_DeviceEventGetHidPhysicalDescriptor: case kUSB_DeviceEventGetHidPhysicalDescriptor:
status = USB_DeviceGetHidPhysicalDescriptor(handle, (usb_device_get_hid_physical_descriptor_struct_t *)param); status = USB_DeviceGetHidPhysicalDescriptor(handle, (usb_device_get_hid_physical_descriptor_struct_t *)param);
break; break;
case kUSB_DeviceEventSetRemoteWakeup:
wakeUpHostAllowed = *temp8;
status = kStatus_USB_Success;
break;
} }
return status; return status;

View File

@@ -28,12 +28,12 @@
// Variables: // Variables:
extern bool IsHostSleeping; extern volatile bool SleepModeActive;
extern usb_composite_device_t UsbCompositeDevice; extern usb_composite_device_t UsbCompositeDevice;
//Functions: //Functions:
void InitUsb(void); void InitUsb(void);
void WakeUpHost(bool sendResume); void WakeUpHost(void);
#endif #endif

View File

@@ -17,6 +17,8 @@
#include "usb_commands/usb_command_get_slave_i2c_errors.h" #include "usb_commands/usb_command_get_slave_i2c_errors.h"
#include "usb_commands/usb_command_set_i2c_baud_rate.h" #include "usb_commands/usb_command_set_i2c_baud_rate.h"
#include "usb_commands/usb_command_switch_keymap.h" #include "usb_commands/usb_command_switch_keymap.h"
#include "usb_commands/usb_command_get_variable.h"
#include "usb_commands/usb_command_set_variable.h"
void UsbProtocolHandler(void) void UsbProtocolHandler(void)
{ {
@@ -77,6 +79,12 @@ void UsbProtocolHandler(void)
case UsbCommandId_SwitchKeymap: case UsbCommandId_SwitchKeymap:
UsbCommand_SwitchKeymap(); UsbCommand_SwitchKeymap();
break; break;
case UsbCommandId_GetVariable:
UsbCommand_GetVariable();
break;
case UsbCommandId_SetVariable:
UsbCommand_SetVariable();
break;
default: default:
SetUsbTxBufferUint8(0, UsbStatusCode_InvalidCommand); SetUsbTxBufferUint8(0, UsbStatusCode_InvalidCommand);
break; break;

View File

@@ -34,8 +34,17 @@
UsbCommandId_GetSlaveI2cErrors = 0x0f, UsbCommandId_GetSlaveI2cErrors = 0x0f,
UsbCommandId_SetI2cBaudRate = 0x10, UsbCommandId_SetI2cBaudRate = 0x10,
UsbCommandId_SwitchKeymap = 0x11, UsbCommandId_SwitchKeymap = 0x11,
UsbCommandId_GetVariable = 0x12,
UsbCommandId_SetVariable = 0x13,
} usb_command_id_t; } usb_command_id_t;
typedef enum {
UsbVariable_TestSwitches,
UsbVariable_TestUsbStack,
UsbVariable_DebounceTimePress,
UsbVariable_DebounceTimeRelease
} usb_variable_id_t;
typedef enum { typedef enum {
UsbStatusCode_Success = 0, UsbStatusCode_Success = 0,
UsbStatusCode_InvalidCommand = 1, UsbStatusCode_InvalidCommand = 1,

View File

@@ -13,7 +13,6 @@
#include "layer.h" #include "layer.h"
#include "usb_report_updater.h" #include "usb_report_updater.h"
#include "timer.h" #include "timer.h"
#include "key_debouncer.h"
#include "config_parser/parse_keymap.h" #include "config_parser/parse_keymap.h"
#include "usb_commands/usb_command_get_debug_buffer.h" #include "usb_commands/usb_command_get_debug_buffer.h"
#include "arduino_hid/ConsumerAPI.h" #include "arduino_hid/ConsumerAPI.h"
@@ -25,6 +24,7 @@ uint16_t DoubleTapSwitchLayerTimeout = 150;
static uint16_t DoubleTapSwitchLayerReleaseTimeout = 100; static uint16_t DoubleTapSwitchLayerReleaseTimeout = 100;
static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT]; static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT];
bool TestUsbStack = false;
volatile uint8_t UsbReportUpdateSemaphore = 0; volatile uint8_t UsbReportUpdateSemaphore = 0;
@@ -236,6 +236,7 @@ static void handleSwitchLayerAction(key_state_t *keyState, key_action_t *action)
static uint8_t basicScancodeIndex = 0; static uint8_t basicScancodeIndex = 0;
static uint8_t mediaScancodeIndex = 0; static uint8_t mediaScancodeIndex = 0;
static uint8_t systemScancodeIndex = 0; static uint8_t systemScancodeIndex = 0;
static uint8_t stickyModifiers;
static void applyKeyAction(key_state_t *keyState, key_action_t *action) static void applyKeyAction(key_state_t *keyState, key_action_t *action)
{ {
@@ -247,8 +248,13 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action)
switch (action->type) { switch (action->type) {
case KeyActionType_Keystroke: case KeyActionType_Keystroke:
ActiveUsbBasicKeyboardReport->modifiers |= action->keystroke.modifiers; if (action->keystroke.scancode) {
if (!keyState->previous) {
stickyModifiers = action->keystroke.modifiers;
}
} else {
ActiveUsbBasicKeyboardReport->modifiers |= action->keystroke.modifiers;
}
switch (action->keystroke.keystrokeType) { switch (action->keystroke.keystrokeType) {
case KeystrokeType_Basic: case KeystrokeType_Basic:
if (basicScancodeIndex >= USB_BASIC_KEYBOARD_MAX_KEYS || action->keystroke.scancode == 0) { if (basicScancodeIndex >= USB_BASIC_KEYBOARD_MAX_KEYS || action->keystroke.scancode == 0) {
@@ -271,6 +277,9 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action)
} }
break; break;
case KeyActionType_Mouse: case KeyActionType_Mouse:
if (!keyState->previous) {
stickyModifiers = 0;
}
activeMouseStates[action->mouseAction] = true; activeMouseStates[action->mouseAction] = true;
break; break;
case KeyActionType_SwitchLayer: case KeyActionType_SwitchLayer:
@@ -278,11 +287,13 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action)
break; break;
case KeyActionType_SwitchKeymap: case KeyActionType_SwitchKeymap:
if (!keyState->previous) { if (!keyState->previous) {
stickyModifiers = 0;
SwitchKeymapById(action->switchKeymap.keymapId); SwitchKeymapById(action->switchKeymap.keymapId);
} }
break; break;
case KeyActionType_PlayMacro: case KeyActionType_PlayMacro:
if (!keyState->previous) { if (!keyState->previous) {
stickyModifiers = 0;
Macros_StartMacro(action->playMacro.macroId); Macros_StartMacro(action->playMacro.macroId);
} }
break; break;
@@ -296,8 +307,6 @@ static secondary_role_t secondaryRole;
static void updateActiveUsbReports(void) static void updateActiveUsbReports(void)
{ {
static uint8_t previousModifiers = 0;
if (MacroPlaying) { if (MacroPlaying) {
Macros_ContinueMacro(); Macros_ContinueMacro();
memcpy(ActiveUsbMouseReport, &MacroMouseReport, sizeof MacroMouseReport); memcpy(ActiveUsbMouseReport, &MacroMouseReport, sizeof MacroMouseReport);
@@ -320,40 +329,46 @@ static void updateActiveUsbReports(void)
if (activeLayer == LayerId_Base) { if (activeLayer == LayerId_Base) {
activeLayer = GetActiveLayer(); activeLayer = GetActiveLayer();
} }
bool layerGotReleased = previousLayer != LayerId_Base && activeLayer == LayerId_Base; bool layerChanged = previousLayer != activeLayer;
if (layerChanged) {
stickyModifiers = 0;
}
bool layerGotReleased = layerChanged && activeLayer == LayerId_Base;
LedDisplay_SetLayer(activeLayer); LedDisplay_SetLayer(activeLayer);
#if 0 // Used to toggle key presses at the maximum rate - this was used to reproduce: https://github.com/UltimateHackingKeyboard/firmware/issues/122 if (TestUsbStack) {
static bool simulateKeypresses = false; static bool simulateKeypresses, isEven, isEvenMedia;
static bool isEven = false; static uint32_t mediaCounter = 0;
static bool isEvenMedia = false; key_state_t *testKeyState = &KeyStates[SlotId_LeftKeyboardHalf][0];
static uint32_t mediaCounter = 0;
key_state_t *testKeyState = &KeyStates[SlotId_LeftKeyboardHalf][0]; if (activeLayer == LayerId_Fn && testKeyState->current && !testKeyState->previous) {
if (!testKeyState->previous && testKeyState->current && activeLayer == LayerId_Fn) { simulateKeypresses = !simulateKeypresses;
simulateKeypresses = !simulateKeypresses; }
} if (simulateKeypresses) {
isEven = !isEven;
if (simulateKeypresses) { ActiveUsbBasicKeyboardReport->scancodes[basicScancodeIndex++] = isEven ? HID_KEYBOARD_SC_A : HID_KEYBOARD_SC_BACKSPACE;
isEven = !isEven; if (++mediaCounter % 200 == 0) {
ActiveUsbBasicKeyboardReport->scancodes[basicScancodeIndex++] = isEven ? HID_KEYBOARD_SC_A : HID_KEYBOARD_SC_BACKSPACE; isEvenMedia = !isEvenMedia;
if (++mediaCounter % 200 == 0) { ActiveUsbMediaKeyboardReport->scancodes[mediaScancodeIndex++] = isEvenMedia ? MEDIA_VOLUME_DOWN : MEDIA_VOLUME_UP;
isEvenMedia = !isEvenMedia; }
ActiveUsbMediaKeyboardReport->scancodes[mediaScancodeIndex++] = isEvenMedia ? MEDIA_VOLUME_DOWN : MEDIA_VOLUME_UP; MouseMoveState.xOut = isEven ? -1 : 1;
} }
MouseMoveState.xOut = isEven ? -1 : 1;
} }
#endif
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) { for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) { for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
key_state_t *keyState = &KeyStates[slotId][keyId]; key_state_t *keyState = &KeyStates[slotId][keyId];
key_action_t *action = &CurrentKeymap[activeLayer][slotId][keyId]; key_action_t *action = &CurrentKeymap[activeLayer][slotId][keyId];
if (keyState->debounceCounter) { if (keyState->debouncing) {
keyState->current = keyState->previous; if ((uint8_t)(Timer_GetCurrentTime() - keyState->timestamp) > (keyState->previous ? DebounceTimePress : DebounceTimeRelease)) {
} else if (!keyState->previous && keyState->current) { keyState->debouncing = false;
keyState->debounceCounter = KEY_DEBOUNCER_TIMEOUT_MSEC + 1; } else {
keyState->current = keyState->previous;
}
} else if (keyState->previous != keyState->current) {
keyState->timestamp = Timer_GetCurrentTime();
keyState->debouncing = true;
} }
if (keyState->current) { if (keyState->current) {
@@ -364,7 +379,7 @@ static void updateActiveUsbReports(void)
if (action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole) { if (action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole) {
// Press released secondary role key. // Press released secondary role key.
if (!keyState->previous && action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole && secondaryRoleState == SecondaryRoleState_Released) { if (!keyState->previous && secondaryRoleState == SecondaryRoleState_Released) {
secondaryRoleState = SecondaryRoleState_Pressed; secondaryRoleState = SecondaryRoleState_Pressed;
secondaryRoleSlotId = slotId; secondaryRoleSlotId = slotId;
secondaryRoleKeyId = keyId; secondaryRoleKeyId = keyId;
@@ -375,6 +390,7 @@ static void updateActiveUsbReports(void)
// Trigger secondary role. // Trigger secondary role.
if (!keyState->previous && secondaryRoleState == SecondaryRoleState_Pressed) { if (!keyState->previous && secondaryRoleState == SecondaryRoleState_Pressed) {
secondaryRoleState = SecondaryRoleState_Triggered; secondaryRoleState = SecondaryRoleState_Triggered;
keyState->current = false;
} else { } else {
applyKeyAction(keyState, action); applyKeyAction(keyState, action);
} }
@@ -403,15 +419,12 @@ static void updateActiveUsbReports(void)
// When a layer switcher key gets pressed along with another key that produces some modifiers // When a layer switcher key gets pressed along with another key that produces some modifiers
// and the accomanying key gets released then keep the related modifiers active a long as the // and the accomanying key gets released then keep the related modifiers active a long as the
// layer switcher key stays pressed. Useful for Alt+Tab keymappings and the like. // layer switcher key stays pressed. Useful for Alt+Tab keymappings and the like.
if (activeLayer != LayerId_Base && activeLayer == PreviousHeldLayer && basicScancodeIndex == 0) { ActiveUsbBasicKeyboardReport->modifiers |= stickyModifiers;
ActiveUsbBasicKeyboardReport->modifiers |= previousModifiers;
}
if (secondaryRoleState == SecondaryRoleState_Triggered && IS_SECONDARY_ROLE_MODIFIER(secondaryRole)) { if (secondaryRoleState == SecondaryRoleState_Triggered && IS_SECONDARY_ROLE_MODIFIER(secondaryRole)) {
ActiveUsbBasicKeyboardReport->modifiers |= SECONDARY_ROLE_MODIFIER_TO_HID_MODIFIER(secondaryRole); ActiveUsbBasicKeyboardReport->modifiers |= SECONDARY_ROLE_MODIFIER_TO_HID_MODIFIER(secondaryRole);
} }
previousModifiers = ActiveUsbBasicKeyboardReport->modifiers;
previousLayer = activeLayer; previousLayer = activeLayer;
} }
@@ -423,11 +436,11 @@ void UpdateUsbReports(void)
KeyStates[SlotId_RightKeyboardHalf][keyId].current = RightKeyMatrix.keyStates[keyId]; KeyStates[SlotId_RightKeyboardHalf][keyId].current = RightKeyMatrix.keyStates[keyId];
} }
if (IsHostSleeping) { if (SleepModeActive) {
for (uint8_t slotId = 0; slotId < SLOT_COUNT; slotId++) { for (uint8_t slotId = 0; slotId < SLOT_COUNT; slotId++) {
for (uint8_t keyId = 0; keyId < MAX_KEY_COUNT_PER_MODULE; keyId++) { for (uint8_t keyId = 0; keyId < MAX_KEY_COUNT_PER_MODULE; keyId++) {
if (KeyStates[slotId][keyId].current) { if (KeyStates[slotId][keyId].current) {
WakeUpHost(true); WakeUpHost();
return; return;
} }
} }
@@ -453,10 +466,6 @@ void UpdateUsbReports(void)
bool HasUsbSystemKeyboardReportChanged = memcmp(ActiveUsbSystemKeyboardReport, GetInactiveUsbSystemKeyboardReport(), sizeof(usb_system_keyboard_report_t)) != 0; bool HasUsbSystemKeyboardReportChanged = memcmp(ActiveUsbSystemKeyboardReport, GetInactiveUsbSystemKeyboardReport(), sizeof(usb_system_keyboard_report_t)) != 0;
bool HasUsbMouseReportChanged = memcmp(ActiveUsbMouseReport, GetInactiveUsbMouseReport(), sizeof(usb_mouse_report_t)) != 0; bool HasUsbMouseReportChanged = memcmp(ActiveUsbMouseReport, GetInactiveUsbMouseReport(), sizeof(usb_mouse_report_t)) != 0;
if (IsHostSleeping && (previousLayer != LayerId_Base || HasUsbBasicKeyboardReportChanged || HasUsbMediaKeyboardReportChanged || HasUsbSystemKeyboardReportChanged || HasUsbMouseReportChanged)) {
WakeUpHost(true); // Wake up the host if any key is pressed and the computer is sleeping.
}
if (HasUsbBasicKeyboardReportChanged) { if (HasUsbBasicKeyboardReportChanged) {
usb_status_t status = UsbBasicKeyboardAction(); usb_status_t status = UsbBasicKeyboardAction();
if (status == kStatus_USB_Success) { if (status == kStatus_USB_Success) {

View File

@@ -71,6 +71,7 @@
extern mouse_kinetic_state_t MouseScrollState; extern mouse_kinetic_state_t MouseScrollState;
extern uint32_t UsbReportUpdateCounter; extern uint32_t UsbReportUpdateCounter;
extern volatile uint8_t UsbReportUpdateSemaphore; extern volatile uint8_t UsbReportUpdateSemaphore;
extern bool TestUsbStack;
// Functions: // Functions:

View File

@@ -15,8 +15,8 @@
"commander": "^2.11.0", "commander": "^2.11.0",
"shelljs": "^0.7.8" "shelljs": "^0.7.8"
}, },
"firmwareVersion": "8.3.3", "firmwareVersion": "8.4.2",
"deviceProtocolVersion": "4.3.1", "deviceProtocolVersion": "4.4.0",
"moduleProtocolVersion": "4.0.0", "moduleProtocolVersion": "4.0.0",
"userConfigVersion": "4.1.0", "userConfigVersion": "4.1.0",
"hardwareConfigVersion": "1.0.0", "hardwareConfigVersion": "1.0.0",

View File

@@ -1,6 +1,8 @@
#include "fsl_gpio.h" #include "fsl_gpio.h"
#include "key_matrix.h" #include "key_matrix.h"
uint8_t DebounceTimePress = 50, DebounceTimeRelease = 50;
void KeyMatrix_Init(key_matrix_t *keyMatrix) void KeyMatrix_Init(key_matrix_t *keyMatrix)
{ {
for (key_matrix_pin_t *row = keyMatrix->rows; row < keyMatrix->rows + keyMatrix->rowNum; row++) { for (key_matrix_pin_t *row = keyMatrix->rows; row < keyMatrix->rows + keyMatrix->rowNum; row++) {

View File

@@ -28,6 +28,10 @@
uint8_t keyStates[MAX_KEYS_IN_MATRIX]; uint8_t keyStates[MAX_KEYS_IN_MATRIX];
} key_matrix_t; } key_matrix_t;
// Variables:
extern uint8_t DebounceTimePress, DebounceTimeRelease;
// Functions: // Functions:
void KeyMatrix_Init(key_matrix_t *keyMatrix); void KeyMatrix_Init(key_matrix_t *keyMatrix);

View File

@@ -19,12 +19,12 @@
// Variables: // Variables:
#define FIRMWARE_MAJOR_VERSION 8 #define FIRMWARE_MAJOR_VERSION 8
#define FIRMWARE_MINOR_VERSION 3 #define FIRMWARE_MINOR_VERSION 4
#define FIRMWARE_PATCH_VERSION 3 #define FIRMWARE_PATCH_VERSION 2
#define DEVICE_PROTOCOL_MAJOR_VERSION 4 #define DEVICE_PROTOCOL_MAJOR_VERSION 4
#define DEVICE_PROTOCOL_MINOR_VERSION 3 #define DEVICE_PROTOCOL_MINOR_VERSION 4
#define DEVICE_PROTOCOL_PATCH_VERSION 1 #define DEVICE_PROTOCOL_PATCH_VERSION 0
#define MODULE_PROTOCOL_MAJOR_VERSION 4 #define MODULE_PROTOCOL_MAJOR_VERSION 4
#define MODULE_PROTOCOL_MINOR_VERSION 0 #define MODULE_PROTOCOL_MINOR_VERSION 0