Skip to content

Latest commit

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

OneInput

HAPI Compatibility: Works with new Check/Apply/ApplyPack API (2026-Q2)

Composable physical input library for IOP — debounce, click, hold, and quadrature encoder, assembled as HAPI chains. Zero dynamic allocation, pure-static dispatch.

Part of the InternetOfPins project family.

Overview

Input chains are assembled outermost (menu adapter) to innermost (ISR attachment). The same components work on AVR (PCINT), ESP32/ESP8266 (attachInterrupt), or any other target that provides the onEdge / onRise / onFall primitives.

The chain begin() wires all interrupts. After that, dispatching is driven by either a user ISR (AVR) or attachInterrupt callbacks (ESP32/ESP8266).

Components

ComponentRole
EncoderQuadrature decoder: onEdge(ab)onUp() / onDown()
BtnCaptureISR→queue bridge: onRise() / onFall() → polled event queue
Debounce<Ms>Rejects transitions shorter than Ms milliseconds
Click<Ms>Detects press+release within Ms ms → onClick()
Hold<Ms>Detects press held beyond Ms ms → onHold()

Platform pin cores

AVR — PCINT-driven (direct register)

#include<oneInput/oneInput.h>
#include<chips/avr/avrPort.h>// Encoder on PC0+PC1 (Arduino A0+A1), PCINT group 1using EncHW = oneInput::InputDef<
oneInput::Encoder,
oneInput::avr::AvrEncPins</*group*/1, hw::avr::chip::PortC, /*bitA*/0, /*bitB*/1>
>;
// Button on PC2 (Arduino A2)using BtnHW = oneInput::InputDef<
oneInput::BtnCapture,
oneInput::Hold<800>,
oneInput::Click<300>,
oneInput::Debounce<20>,
oneInput::avr::AvrBtnPin</*group*/1, hw::avr::chip::PortC, /*bit*/2>
>;
// User must provide the ISRISR(PCINT1_vect) { EncHW::dispatch(); BtnHW::dispatch(); }

ESP32 / ESP8266 — attachInterrupt-driven

#include<oneInput/oneInput.h>// No user ISR — begin() calls attachInterrupt internallyusing EncHW = oneInput::InputDef<
oneInput::Encoder,
oneInput::Esp32EncPins<32, 33> // CLK=32, DT=33
>;
using BtnHW = oneInput::InputDef<
oneInput::BtnCapture,
oneInput::Hold<800>,
oneInput::Click<300>,
oneInput::Debounce<20>,
oneInput::Esp32BtnPin<25>
>;

Wiring to OneMenu

EncIn<HW, Steps> and BtnIn<HW> are HAPI components that translate hardware events into menu navigation commands (CKE::Up, CKE::Down, CKE::Enter, CKE::Esc).

#include<oneMenu/menu/IO/IOP/encIn.h>
#include<oneMenu/menu/IO/IOP/btnIn.h>using Enc = oneMenu::EncIn<EncHW, 4>; // 4 steps per detentusing Btn = oneMenu::BtnIn<BtnHW>;
// Use inside InDef (alongside PCKbd, SerialIn, etc.)
InDef<Enc, Btn, SerialIn, PCKbd> in;

Steps is the number of quadrature transitions per physical detent — 4 for most encoders, 2 for half-step types.

License

MIT — see LICENSE.

Author: Rui Azevedo (neu-rah) · Azores, Portugal

About

IOP composable physical input library — PCINT/GPIO interrupt chains, debounce, click, hold, encoder

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages