Remove unnecessary comments, clean up code
This commit is contained in:
+18
-18
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
// ─── Feature Flags ────────────────────────────────────────────────────────────
|
||||
// Feature Flags
|
||||
#define FEATURE_CONFIG_SERVICE
|
||||
#define FEATURE_TELEMETRY
|
||||
#define FEATURE_IMU_STREAM
|
||||
@@ -12,10 +12,10 @@
|
||||
#define FEATURE_BOOT_LOOP_DETECT
|
||||
#define FEATURE_PHYSICAL_BUTTONS
|
||||
|
||||
// ─── Debug ────────────────────────────────────────────────────────────────────
|
||||
// Debug
|
||||
// #define DEBUG
|
||||
|
||||
// ─── ATT table size ───────────────────────────────────────────────────────────
|
||||
// ATT table size
|
||||
#define _ATT_BASE 900
|
||||
#ifdef FEATURE_CONFIG_SERVICE
|
||||
#define _ATT_CFG 100 // +20 for cfgGitHash characteristic
|
||||
@@ -35,7 +35,7 @@
|
||||
#define ATT_TABLE_SIZE_CALC (_ATT_BASE + _ATT_CFG + _ATT_TELEM + _ATT_STREAM)
|
||||
#define ATT_TABLE_SIZE (ATT_TABLE_SIZE_CALC < 1536 ? 1536 : ATT_TABLE_SIZE_CALC)
|
||||
|
||||
// ─── IMU register addresses ───────────────────────────────────────────────────
|
||||
// IMU register addresses
|
||||
#define REG_CTRL1_XL 0x10
|
||||
#define REG_TAP_CFG 0x58
|
||||
#define REG_TAP_THS_6D 0x59
|
||||
@@ -46,20 +46,20 @@
|
||||
#define REG_OUT_TEMP_L 0x20
|
||||
#define REG_OUT_TEMP_H 0x21
|
||||
|
||||
// ─── Pins ─────────────────────────────────────────────────────────────────────
|
||||
// Pins
|
||||
#define PIN_VBAT_ENABLE (14)
|
||||
#define PIN_VBAT_READ (32)
|
||||
#define PIN_CHG (23)
|
||||
#define PIN_HICHG (22)
|
||||
|
||||
// ─── Persistence ──────────────────────────────────────────────────────────────
|
||||
// Persistence
|
||||
#define CONFIG_FILENAME "/imu_mouse_cfg.bin"
|
||||
#define CONFIG_MAGIC 0xDEAD123DUL
|
||||
|
||||
// ─── Physical button sentinel ─────────────────────────────────────────────────
|
||||
// Physical button sentinel
|
||||
#define BTN_PIN_NONE 0xFF // Stored in btn*Pin when that button is disabled
|
||||
|
||||
// ─── Runtime feature-override flags (cfg.featureFlags bitmask) ───────────────
|
||||
// Runtime feature-override flags (cfg.featureFlags bitmask)
|
||||
// These mirror the compile-time FEATURE_* defines but can be toggled at runtime
|
||||
// via the web UI and persisted in flash. Bits not listed here are reserved = 0.
|
||||
#define FLAG_TAP_ENABLED 0x01 // Tap detection active (requires restart)
|
||||
@@ -67,12 +67,12 @@
|
||||
#define FLAG_AUTO_RECAL_ENABLED 0x04 // Auto-recalibrate after long idle
|
||||
#define FLAG_ALL_DEFAULT (FLAG_TAP_ENABLED | FLAG_TEMP_COMP_ENABLED | FLAG_AUTO_RECAL_ENABLED)
|
||||
|
||||
// ─── Enums ────────────────────────────────────────────────────────────────────
|
||||
// Enums
|
||||
enum CurveType : uint8_t { CURVE_LINEAR=0, CURVE_SQUARE=1, CURVE_SQRT=2 };
|
||||
enum ChargeMode : uint8_t { CHARGE_OFF=0, CHARGE_SLOW=1, CHARGE_FAST=2 };
|
||||
enum ChargeStatus: uint8_t { CHGSTAT_DISCHARGING=0, CHGSTAT_CHARGING=1, CHGSTAT_FULL=2 };
|
||||
|
||||
// ─── Tap action types ─────────────────────────────────────────────────────────
|
||||
// Tap action types
|
||||
// TAP_ACTION_KEY: fires a raw HID keycode (tapKey) with optional modifier (tapMod).
|
||||
// Modifier byte: bit0=Ctrl, bit1=Shift, bit2=Alt, bit3=GUI (same as HID modifier byte).
|
||||
enum TapAction : uint8_t {
|
||||
@@ -82,7 +82,7 @@ enum TapAction : uint8_t {
|
||||
TAP_ACTION_KEY = 3,
|
||||
};
|
||||
|
||||
// ─── Config (stored in flash) ─────────────────────────────────────────────────
|
||||
// Config (stored in flash)
|
||||
struct Config {
|
||||
uint32_t magic;
|
||||
float sensitivity;
|
||||
@@ -97,7 +97,7 @@ struct Config {
|
||||
uint8_t tapMod; // HID modifier byte (used when tapAction == TAP_ACTION_KEY)
|
||||
float jerkThreshold; // jerk² threshold for tap-freeze detection
|
||||
uint8_t tapFreezeEnabled; // 1 = enable jerk-based cursor freeze during taps
|
||||
uint8_t featureFlags; // bitmask of FLAG_* — runtime feature overrides
|
||||
uint8_t featureFlags; // bitmask of FLAG_* - runtime feature overrides
|
||||
uint8_t btnLeftPin; // BTN_PIN_NONE or Arduino pin number (0-10 = D0-D10)
|
||||
uint8_t btnRightPin;
|
||||
uint8_t btnMiddlePin;
|
||||
@@ -105,7 +105,7 @@ struct Config {
|
||||
extern Config cfg;
|
||||
extern const Config CFG_DEFAULTS;
|
||||
|
||||
// ─── ConfigBlob (over BLE, 25 bytes) ─────────────────────────────────────────
|
||||
// ConfigBlob (over BLE, 25 bytes)
|
||||
struct __attribute__((packed)) ConfigBlob {
|
||||
float sensitivity; // [0]
|
||||
float deadZone; // [4]
|
||||
@@ -119,14 +119,14 @@ struct __attribute__((packed)) ConfigBlob {
|
||||
uint8_t tapMod; // [18] HID modifier
|
||||
uint8_t tapFreezeEnabled; // [19] 1 = enable jerk-based cursor freeze during taps
|
||||
float jerkThreshold; // [20] jerk² tap-freeze threshold
|
||||
uint8_t featureFlags; // [24] FLAG_* bitmask — runtime feature overrides
|
||||
uint8_t featureFlags; // [24] FLAG_* bitmask - runtime feature overrides
|
||||
uint8_t btnLeftPin; // [25] BTN_PIN_NONE or Arduino pin (0-10 = D0-D10)
|
||||
uint8_t btnRightPin; // [26]
|
||||
uint8_t btnMiddlePin; // [27]
|
||||
};
|
||||
static_assert(sizeof(ConfigBlob) == 28, "ConfigBlob must be 28 bytes");
|
||||
|
||||
// ─── TelemetryPacket (24 bytes) ───────────────────────────────────────────────
|
||||
// TelemetryPacket (24 bytes)
|
||||
#ifdef FEATURE_TELEMETRY
|
||||
struct __attribute__((packed)) TelemetryPacket {
|
||||
uint32_t uptimeSeconds; // [0]
|
||||
@@ -143,7 +143,7 @@ static_assert(sizeof(TelemetryPacket) == 28, "TelemetryPacket must be 28 bytes")
|
||||
extern TelemetryPacket telem;
|
||||
#endif
|
||||
|
||||
// ─── ImuPacket (14 bytes) ─────────────────────────────────────────────────────
|
||||
// ImuPacket (14 bytes)
|
||||
#ifdef FEATURE_IMU_STREAM
|
||||
struct __attribute__((packed)) ImuPacket {
|
||||
int16_t gyroX_mDPS; // [0] pitch axis (nod up/down → cursor Y)
|
||||
@@ -159,7 +159,7 @@ struct __attribute__((packed)) ImuPacket {
|
||||
static_assert(sizeof(ImuPacket) == 14, "ImuPacket must be 14 bytes");
|
||||
#endif
|
||||
|
||||
// ─── Tuning constants ─────────────────────────────────────────────────────────
|
||||
// Tuning constants
|
||||
extern const float ALPHA;
|
||||
extern const int LOOP_RATE_MS;
|
||||
extern const int BIAS_SAMPLES;
|
||||
@@ -185,7 +185,7 @@ extern const float BATT_CRITICAL;
|
||||
extern const unsigned long AUTO_RECAL_MS;
|
||||
#endif
|
||||
|
||||
// ─── Global state ─────────────────────────────────────────────────────────────
|
||||
// Global state
|
||||
extern float angleX, angleY;
|
||||
extern float accumX, accumY;
|
||||
extern float gravX, gravY, gravZ;
|
||||
|
||||
Reference in New Issue
Block a user