Skip to content

API Reference

Ahmed Dabak edited this page Jul 25, 2026 · 5 revisions

API Reference

Every public function in one page, grouped by namespace. Facades are the expressive top layer; modules are the hardware-truth layer beneath them; the driver is the raw escape hatch. For the reasoning behind the split, see Architecture.

Entry point: OttoFlow

OttoFlow::start();                       // classic biped kit
OttoFlow::start(Preset preset);          // a known build
OttoFlow::start(const OttoConfig& cfg);  // full custom
bool OttoFlow::isStarted();
const char* OttoFlow::version();         // e.g. "0.1.0"
Otto& OttoFlow::driver();                // needs <OttoFlowDriver.h>

See Installation and Configuration.

Configuration

enum class Preset { Biped, Humanoid };

struct OttoConfig {
  LegServoPins      legs;          // legLeft 2, legRight 3, footLeft 4, footRight 5
  ArmsConfig        arms;          // enabled false, leftPin 6, rightPin 7
  MatrixConfig      matrix;        // din A3, cs A2, clk A1, orientation 1, brightness 4
  UltrasonicConfig  ultrasonic;    // trigger 8, echo 9, medianFilter true, samples 3, timeoutMicros 25000
  BuzzerConfig      buzzer;        // pin 13, muted false, helloOnStart true
  TouchConfig       touch;         // pin A0, toggleMode false
  SoundSensorConfig soundSensor;   // pin A6
  LightSensorConfig lightSensor;   // pin A7
  BluetoothConfig   bluetooth;     // enabled false, rxPin 11, txPin 12, baud 9600
  Mpu6050Config     mpu6050;       // enabled false, i2cAddress 0x68
  bool loadTrimsFromEeprom = true;
};

OttoConfig cfg = Preset::Humanoid;   // preset converts to a config

Full field tables: Configuration.

Facades

Mouth -- details

Mouth::show(Icon icon);
Mouth::showDigit(uint8_t digit);                       // 0..9
Mouth::scrollText(const char* text, uint8_t speedMs = 50);
Mouth::setBrightness(uint8_t level);                   // 0..15
Mouth::clear();

Eyes -- details

long Eyes::distanceCm();
bool Eyes::closerThanCm(long cm);
bool Eyes::fartherThanCm(long cm);
constexpr long Eyes::OUT_OF_RANGE_CM;                  // 999

Voice -- details

Voice::play(Sound sound);
Voice::playToneHz(float hz, long ms, int silenceAfterMs = 0);
Voice::playMelodyHz(const uint16_t* notesHz, const uint8_t* beats, uint8_t count, uint16_t tempoMs);
Voice::playHappyBirthday();
Voice::mute();  Voice::unmute();  bool Voice::isMuted();

Legs -- details

Legs::enable();  Legs::disable();  bool Legs::isEnabled();
Legs::center();  Legs::home();    // home() is an alias for center()

Legs::walkForward(float steps, int periodMs = 1000);
Legs::walkBackward(float steps, int periodMs = 1000);
Legs::turnLeft(float steps, int periodMs = 2000);
Legs::turnRight(float steps, int periodMs = 2000);

Legs::bendLeft(int steps = 1, int periodMs = 1400);    // + bendRight
Legs::shakeLeftLeg(int steps = 1, int periodMs = 2000); // + shakeRightLeg
Legs::jump(float steps = 1, int periodMs = 2000);

Legs::upDown(cycles = 1, periodMs = 1000, amplitude = 20);
Legs::swing(...);  Legs::tiptoeSwing(...);  Legs::jitter(...);
Legs::ascendingTurn(...);
Legs::moonwalkLeft(...);   Legs::moonwalkRight(...);
Legs::crusaitoLeft(...);   Legs::crusaitoRight(...);
Legs::flapForward(...);    Legs::flapBackward(...);

Legs::positionLegLeftDegrees(uint8_t angle);           // + Right / Foot variants
Legs::positionAllDegrees(ll, lr, fl, fr, int durationMs = 200);

Legs::setTrimsDegrees(int ll, int lr, int fl, int fr);
Legs::saveTrimsToEeprom();

Arms -- details

Arms::center();  Arms::home();         // home() is an alias for center()
Arms::up();      Arms::down();         // mirrored: left 180/right 0, left 0/right 180
Arms::raiseBoth(uint8_t deg = 160);   Arms::lowerBoth(uint8_t deg = 20);   // mirrored: right gets 180 - deg
Arms::raiseLeft(uint8_t deg = 160);   Arms::raiseRight(uint8_t deg = 160); // raw single-servo angles
Arms::waveRight(uint8_t times = 2);   Arms::waveLeft(uint8_t times = 2);
Arms::relax();  Arms::hold();  bool Arms::isActive();

Motion -- details

Motion::disable();   // all servos, legs and arms
Motion::enable();
bool Motion::isEnabled();

Gestures -- details

Gestures::play(Gesture gesture);

Touch, Ears, Balance -- details

bool Touch::isTouched();   bool Touch::wasTapped();

uint8_t Ears::loudnessPercent();
bool    Ears::hearsSoundLouderThanPercent(uint8_t threshold);

float Balance::pitchDegrees();   float Balance::rollDegrees();
bool  Balance::isLevelWithinDegrees(float tol = 15);
bool  Balance::isUpsideDown();
bool  Balance::isShakenHarderThanG(float threshold = 0.6);

Modules

Full descriptions on the Modules page. Signatures:

// Matrix
Matrix::drawIcon(Icon);  Matrix::drawDigit(uint8_t);  Matrix::drawMouthId(uint8_t);
Matrix::drawPixel(uint8_t x, uint8_t y, bool on);  Matrix::drawPattern(unsigned long);
Matrix::scrollText(const char*, uint8_t speedMs = 50);  Matrix::setBrightness(uint8_t);  Matrix::clear();

// Ultrasonic
long Ultrasonic::distanceCm();  long Ultrasonic::readSingleCm();  unsigned long Ultrasonic::echoMicros();

// Buzzer
Buzzer::play(Sound);  Buzzer::playToneHz(float, long, int = 0);
Buzzer::bendTonesHz(float start, float end, float step, long stepMs, int gapMs);
Buzzer::mute();  Buzzer::unmute();  bool Buzzer::isMuted();

// Melody
Melody::playHz(const uint16_t* notesHz, const uint8_t* beats, uint8_t count, uint16_t tempoMs);
Melody::playHappyBirthday();

// LegServos  (dir: 1 forward/left, -1 backward/right)
LegServos::enable();  LegServos::disable();  bool LegServos::isEnabled();  LegServos::center();
LegServos::walk(float, int, int);  LegServos::turn(...);  LegServos::bend(...);  LegServos::shakeLeg(...);
LegServos::jump(float = 1, int = 2000);
LegServos::upDown/swing/tiptoeSwing/jitter/ascendingTurn(float cycles, int periodMs, int amplitude);
LegServos::moonwalk/crusaito/flap(float, int, int, int dir);
LegServos::positionLegLeftDegrees(uint8_t);  // + Right / Foot
LegServos::positionAllDegrees(ll, lr, fl, fr, int = 200);
LegServos::playGesture(Gesture);
LegServos::setTrimsDegrees(int, int, int, int);  LegServos::saveTrimsToEeprom();

// ArmServos
ArmServos::attach();  ArmServos::detach();  bool ArmServos::isAttached();
ArmServos::positionLeftDegrees(uint8_t);  ArmServos::positionRightDegrees(uint8_t);  ArmServos::positionBothDegrees(uint8_t);
ArmServos::positionBothMirroredDegrees(uint8_t);  // left = angle, right = 180 - angle
ArmServos::center();  ArmServos::up();  ArmServos::down();
ArmServos::waveRight(uint8_t = 2);  ArmServos::waveLeft(uint8_t = 2);

// TouchSensor
bool TouchSensor::isTouched();  bool TouchSensor::wasTapped();

// SoundSensor
int SoundSensor::rawLevel();
uint8_t SoundSensor::loudnessPercent(uint16_t windowMs = 50);
bool    SoundSensor::isLouderThanPercent(uint8_t threshold, uint16_t windowMs = 50);

// LightSensor
int LightSensor::raw();  uint8_t LightSensor::brightnessPercent();
bool LightSensor::isDarkerThanPercent(uint8_t);  bool LightSensor::isBrighterThanPercent(uint8_t);

// Bluetooth
bool Bluetooth::begin();  bool Bluetooth::isReady();  Stream& Bluetooth::stream();

// Mpu6050
bool Mpu6050::begin();  bool Mpu6050::isConnected();
Mpu6050::readAccelerationG(float& x, float& y, float& z);
Mpu6050::readRotationDps(float& x, float& y, float& z);
float Mpu6050::temperatureC();
float Mpu6050::pitchDegrees();  float Mpu6050::rollDegrees();
bool  Mpu6050::isLevelWithinDegrees(float = 15);  bool Mpu6050::isUpsideDown();
bool  Mpu6050::isShakenHarderThanG(float = 0.6);

// AppLink
AppLink::begin();  AppLink::begin(Stream&);  AppLink::poll();

Console

Console::begin(unsigned long baud = 9600);   // over USB Serial
Console::begin(Stream& stream);              // e.g. Bluetooth::stream()
Console::poll();                             // every loop iteration

Command reference: Serial Console.

Driver

#include <OttoFlowDriver.h>
Otto& OttoFlow::driver();     // the raw OttoDIYLib instance, valid after start()

See The Driver.

Clone this wiki locally