init commit

This commit is contained in:
feeling001@gmail.com
2026-06-18 15:04:18 +02:00
commit 8bab06b72a
22 changed files with 3258 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
#pragma once
/**
* @file TouchManager.h
* @brief Capacitive touch button handler for ESP32-S3 native touch pins.
*
* Supports three touch pads:
* TOUCH_NEXT — Advance to the next display page
* TOUCH_PREV — Go to the previous display page
* TOUCH_ACTION — Trigger a full e-ink refresh
*
* Combo detection:
* TOUCH_NEXT + TOUCH_PREV held for AP_COMBO_MS → enter WiFi AP mode
*
* The ESP32-S3 touch peripheral returns a raw capacitance value; a reading
* *below* the threshold means the pad is being touched (lower = more contact).
*/
#include "Config.h"
class TouchManager {
public:
/** @brief Initialise touch pads. Call from setup(). */
void begin();
/** @brief Poll all pads; must be called from loop(). */
void update();
// ── Event accessors (consumed once per call) ──────────────────────────────
bool nextPressed() { bool v = _evNext; _evNext = false; return v; }
bool prevPressed() { bool v = _evPrev; _evPrev = false; return v; }
bool actionPressed() { bool v = _evAction; _evAction = false; return v; }
bool apCombo() { bool v = _evApCombo; _evApCombo = false; return v; }
private:
// Per-pad state machine
struct PadState {
uint8_t pin;
bool wasDown = false;
uint32_t pressedAt = 0;
bool longFired = false;
};
PadState _pads[3] = {
{Pins::TOUCH_NEXT},
{Pins::TOUCH_PREV},
{Pins::TOUCH_ACTION}
};
uint32_t _lastDebounce = 0;
uint32_t _comboPressAt = 0;
bool _comboActive = false;
bool _evNext = false;
bool _evPrev = false;
bool _evAction = false;
bool _evApCombo = false;
bool _isTouched(uint8_t pin) const;
};
extern TouchManager touchManager;