Remove unnecessary comments, clean up code
This commit is contained in:
@@ -6,12 +6,12 @@
|
||||
|
||||
extern BLEHidAdafruit blehid;
|
||||
|
||||
// ─── Tap detection setup ──────────────────────────────────────────────────────
|
||||
// Tap detection setup
|
||||
// REG_TAP_THS_6D bits[4:0] = tapThreshold (1–31); 1 LSB = FS/32 = 62.5 mg at ±2g.
|
||||
// REG_INT_DUR2 at ODR=416 Hz:
|
||||
// SHOCK[7:6] = 2 → 38 ms max tap duration
|
||||
// QUIET[5:4] = 2 → 19 ms refractory after tap
|
||||
// DUR[3:0] = 6 → 115 ms max inter-tap window for double detection
|
||||
// SHOCK[7:6] = 2 → 38 ms max tap duration
|
||||
// QUIET[5:4] = 2 → 19 ms refractory after tap
|
||||
// DUR[3:0] = 6 → 115 ms max inter-tap window for double detection
|
||||
void applyTapThreshold() {
|
||||
uint8_t thr = cfg.tapThreshold;
|
||||
if (thr < 1) thr = 1;
|
||||
@@ -30,18 +30,7 @@ void setupTapDetection() {
|
||||
Serial.print(" (~"); Serial.print(cfg.tapThreshold * 62.5f, 0); Serial.println(" mg)");
|
||||
}
|
||||
|
||||
// ─── Tap processing ───────────────────────────────────────────────────────────
|
||||
// Only double-tap is mapped to an action. Single-tap is ignored (it always fires
|
||||
// before the double is confirmed and cannot be reliably disambiguated on this
|
||||
// hardware without an unacceptable latency penalty).
|
||||
//
|
||||
// The LSM6DS3 sets SINGLE_TAP immediately on first contact — we wait until
|
||||
// DOUBLE_TAP is set (within the hardware DUR window of 115 ms) before acting.
|
||||
// An additional TAP_CONFIRM_MS guard ensures the TAP_SRC register has settled.
|
||||
//
|
||||
// IMPORTANT: call mouseButtonPress(bitmask) — single arg only. The two-arg
|
||||
// overload takes (conn_hdl, buttons) and sends the wrong button value.
|
||||
|
||||
// Tap processing
|
||||
static enum { TAP_IDLE, TAP_PENDING, TAP_EXECUTING } tapState = TAP_IDLE;
|
||||
static unsigned long tapPendingMs = 0;
|
||||
static uint8_t pendingButton = 0; // 0 = key action pending
|
||||
@@ -83,7 +72,7 @@ static void fireTapAction(unsigned long now) {
|
||||
}
|
||||
|
||||
void processTaps(unsigned long now) {
|
||||
// ── Release ───────────────────────────────────────────────────────────────
|
||||
// Release
|
||||
if (tapState == TAP_EXECUTING) {
|
||||
if (now - clickDownMs >= CLICK_HOLD_MS) {
|
||||
if (pendingButton) {
|
||||
@@ -99,7 +88,7 @@ void processTaps(unsigned long now) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ── Poll TAP_SRC ──────────────────────────────────────────────────────────
|
||||
// Poll TAP_SRC
|
||||
uint8_t tapSrc = imuReadReg(REG_TAP_SRC);
|
||||
bool tapIA = !!(tapSrc & 0x40);
|
||||
bool doubleTap = !!(tapSrc & 0x10);
|
||||
|
||||
Reference in New Issue
Block a user