Skip to content

InternetOfPins/OneOutput

Repository files navigation

OneOutput

HAPI output components — zero-overhead, composable output layers for embedded and desktop targets.

Part of the InternetOfPins project family.

Overview

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.

Components

OutAPI<Cfg>

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 colour

OutDef<OO...>

Closes a chain of output layers into a named, usable type:

using Out = OutDef<PrefixComp, ConsoleOut>;
Out o;
o << "hello";    // flows through PrefixComp → ConsoleOut

IOutDef<OO...>

Virtual-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.

OutputDevice<Out, out>

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.

Device layers

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()

Usage

#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: >> msg

Spatial types

template<typename T> struct XY { T x; T y; };
using Pos  = XY<SizeT>;   // cursor position
using Area = XY<SizeT>;   // width × height region

Dependencies

  • HAPI — chain topology and query machinery

License

MIT — see LICENSE.

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

About

HAPI output API and some components

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages