Initial physical button mapping implementation #4

This commit is contained in:
Nik Rozman
2026-03-03 11:44:38 +01:00
parent dcc50150b8
commit 5c36aa041e
8 changed files with 321 additions and 33 deletions

View File

@@ -33,6 +33,7 @@
#include "ble_config.h"
#include "battery.h"
#include "tap.h"
#include "buttons.h"
#include <bluefruit.h>
#include <Adafruit_LittleFS.h>
#include <InternalFileSystem.h>
@@ -60,7 +61,8 @@ Config cfg;
const Config CFG_DEFAULTS = {
CONFIG_MAGIC, 600.0f, 0.060f, 0.08f, CURVE_LINEAR, 0x00, CHARGE_SLOW,
/*tapThreshold=*/12, /*tapAction=*/TAP_ACTION_LEFT, /*tapKey=*/0, /*tapMod=*/0,
/*jerkThreshold=*/2000.0f, /*tapFreezeEnabled=*/1, /*featureFlags=*/FLAG_ALL_DEFAULT
/*jerkThreshold=*/2000.0f, /*tapFreezeEnabled=*/1, /*featureFlags=*/FLAG_ALL_DEFAULT,
/*btnLeftPin=*/BTN_PIN_NONE, /*btnRightPin=*/BTN_PIN_NONE, /*btnMiddlePin=*/BTN_PIN_NONE
};
// ─── Telemetry definition ─────────────────────────────────────────────────────
@@ -224,6 +226,10 @@ void setup() {
if (cfg.featureFlags & FLAG_TAP_ENABLED) setupTapDetection();
#endif
#ifdef FEATURE_PHYSICAL_BUTTONS
setupPhysicalButtons();
#endif
cachedTempC = readIMUTemp();
#ifdef FEATURE_BATTERY_MONITOR
@@ -280,6 +286,9 @@ void setup() {
#ifdef FEATURE_BOOT_LOOP_DETECT
Serial.print(" BOOTDET");
#endif
#ifdef FEATURE_PHYSICAL_BUTTONS
Serial.print(" PHYSBTN");
#endif
Serial.println();
bootStartMs = millis();
@@ -323,6 +332,10 @@ void loop() {
if (cfg.featureFlags & FLAG_TAP_ENABLED) processTaps(now);
#endif
#ifdef FEATURE_PHYSICAL_BUTTONS
processPhysicalButtons();
#endif
if (now - lastTime < (unsigned long)LOOP_RATE_MS) return;
float dt = (now - lastTime) / 1000.0f;
lastTime = now;