Skip to content

Commit

Permalink
feat: can now configure the timeout of a tap key
Browse files Browse the repository at this point in the history
  • Loading branch information
heiso committed Nov 12, 2024
1 parent d8b7946 commit 3acdfe5
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 571 deletions.
4 changes: 2 additions & 2 deletions firmware/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="922630805834284133" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-300884557764420635" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="922630805834284133" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-300884557764420635" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
3 changes: 2 additions & 1 deletion firmware/Core/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ extern "C" {
#define DEFAULT_RESET_THRESHOLD 3
#define DEFAULT_RAPID_TRIGGER_OFFSET 40
#define DEFAULT_SCREAMING_VELOCITY_TRIGGER 45
#define DEFAULT_TAP_TIMEOUT 200

#define IDLE_VALUE_APPROX 1800
#define MAX_DISTANCE_APPROX 500
#define IDLE_VALUE_OFFSET 10
#define MAX_DISTANCE_OFFSET 60
#define TAP_TIMEOUT 200
#define IDLE_CYCLES_UNTIL_SLEEP 15

#define ADC_CHANNEL_COUNT 5
Expand Down Expand Up @@ -136,6 +136,7 @@ struct user_config {
uint8_t reset_threshold;
uint8_t rapid_trigger_offset;
uint8_t screaming_velocity_trigger;
uint16_t tap_timeout;
uint16_t keymaps[LAYERS_COUNT][MATRIX_ROWS][MATRIX_COLS];
};
/* USER CODE END ET */
Expand Down
3 changes: 2 additions & 1 deletion firmware/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const struct user_config default_user_config = {
.reset_threshold = DEFAULT_RESET_THRESHOLD,
.rapid_trigger_offset = DEFAULT_RAPID_TRIGGER_OFFSET,
.screaming_velocity_trigger = DEFAULT_SCREAMING_VELOCITY_TRIGGER,
.tap_timeout = DEFAULT_TAP_TIMEOUT,
.keymaps = {
// clang-format off
[_BASE_LAYER] = {
Expand Down Expand Up @@ -307,7 +308,7 @@ int main(void) {

struct key *key = &keys[adc_channel][amux_channel];
uint8_t is_before_reset_offset = key->state.distance_8bits < key->actuation.reset_offset;
uint8_t is_before_timeout = HAL_GetTick() - key->actuation.triggered_at <= TAP_TIMEOUT;
uint8_t is_before_timeout = HAL_GetTick() - key->actuation.triggered_at <= user_config.tap_timeout;

// if might be tap, can be tap or triggered
if (is_before_reset_offset && is_before_timeout) {
Expand Down
Loading

0 comments on commit 3acdfe5

Please sign in to comment.