HAPI output components — zero-overhead, composable output layers for embedded and desktop targets.
Part of the InternetOfPins project family.
OneOutput provides the base output API and device components used by higher-level IOP libraries (OneMenu, etc.). It defines OutDef — a HAPI chain wrapper that composes output layers into a single zero-cost type — along with position, area, and device abstractions.
The base API for all output chains. Provides default no-op implementations of the output interface:
clear() // clear the display
nl() // newline
put(T) // write a value
flush() // flush the output buffer
resume() // re-sync device state
getPos() // current cursor position
setPos(Pos) // move cursor
free() // available area remaining
setColors(fg,bg) // set foreground/background colourCloses a chain of output layers into a named, usable type:
using Out = OutDef<PrefixComp, ConsoleOut>;
Out o;
o << "hello"; // flows through PrefixComp → ConsoleOutVirtual-dispatch variant of OutDef — exposes the output interface through IOut for runtime polymorphism when the concrete chain type cannot be known at a call site.
Tag component that injects a static reference to the underlying hardware or stream device into the chain. Used by upper layers to access the raw device.
| Component | Platform | Description |
|---|---|---|
StreamOut<Out, out> |
non-Arduino | Wraps any std::ostream; put() calls out <<, nl() calls std::endl |
ConsoleOut |
non-Arduino | Alias for StreamOut<decltype(std::cout), std::cout> |
PrintOut<Out, out> |
Arduino | Wraps any Print-derived object; put() calls out.print() |
#include <oneOutput/oneOutput.h>
using namespace oneOutput;
// Basic console output
OutDef<ConsoleOut> out;
out << "hello " << 42;
out.nl();
// Custom component layered above the device
struct PrefixComp : PrefixTag {
template<typename O>
struct Part : O {
using Base = O;
string prefix{};
template<typename T>
void put(const T& v) { Base::put(prefix); Base::put(v); }
};
};
OutDef<PrefixComp, ConsoleOut> out2;
auto& pc = hapi::find<TagIs<PrefixTag>>(out2);
pc.prefix = ">> ";
out2 << "msg"; // prints: >> msgtemplate<typename T> struct XY { T x; T y; };
using Pos = XY<SizeT>; // cursor position
using Area = XY<SizeT>; // width × height region- HAPI — chain topology and query machinery
MIT — see LICENSE.
Author: Rui Azevedo (neu-rah) · Azores, Portugal