Skip to main content

ComponentBase

Abstract base class for all hardware components. Every component (sensor or actuator) extends ComponentBase, which registers it with the beginAll() / tickAll() lifecycle system.

C++
#include "blokdots.h"

You do not instantiate ComponentBase directly — use a concrete class like DigitalActor, AnalogSensor, AnalogActor, or Button.

#Lifecycle

ComponentBase registers two callbacks in its constructor:

CallbackCalled byPurpose
begin()blokdots::beginAll() in setup()One-time initialization (e.g., pinMode)
tick()blokdots::tickAll() in loop()Per-loop update (e.g., animations, sensor reads)

Subclasses override these protected methods:

C++
class MyComponent : public ComponentBase {
protected:
  void begin() override { /* initialize hardware */ }
  void tick() override  { /* update each loop */ }
};