# PaulBot v1 API Cheat Sheet

This document lists the available HTTP GET endpoints to control your PaulBot via its local web server. You can trigger these directly from your browser, via `curl`, using Python scripts, or using top-level links (`<a href="...">`).

**Base URL**: `http://paulbot3.local` (or `http://dogbot1.local`).

---

## ⚡ Hardware Queue & Buffer Limits

PaulBot has two hardware queue systems to ensure stability:

1. **API Schedule Queue (`/schedule`)**: Maximum **8 scheduled actions** (`MAX_SCHEDULED_ACTIONS` in `board_config.h`). Scheduling more than 8 actions at once will drop extra requests.
2. **Internal Action Queue (`s_queue`)**: The background FreeRTOS task (`dog_actions.c`) queues up to **4 concurrent actions/animations**.

> **Best Practice**: Always add a `delay` token in multi-step routines to avoid filling the internal 4-slot FreeRTOS queue.

---

## 🚀 Mission Script (MScript) Batch Execution

For running multi-step routines in a single browser click without CORS or HTTPS issues:

- **Endpoint**: `GET /api/mission?m=COMMAND1|COMMAND2|COMMAND3` (or `GET /mission?m=...`)
- **Example**: `http://dogbot1.local/api/mission?m=hi|delay:1000|bark|wiggle`
- **Supported Tokens**:
  - `hi`, `wiggle`, `stand`, `lay`, `bow`, `lean`, `rock`, `sway`, `shake` — Movement routines
  - `bark`, `huh`, `yes`, `jump`, `ding`, `random` — Sound effects
  - `delay:ms` or `wait:ms` — Non-blocking pause (e.g. `delay:1000`)
  - `servo:num:angle` — Servo control (e.g. `servo:1:90`)
  - `oled:text` or `msg:text` — Display white text on OLED screen
  - `anim_eyes`, `anim_fireworks`, `anim_matrix`, `anim_heartbeat` — OLED Animations

---

## 🗣️ Voice & Audio API
- **Say a phrase**: `GET /tts?say=My%20name%20is%20Paulbot`
- **Play dog bark clip**: `GET /bark`
- **Play "Huh?"**: `GET /huh`
- **Play "Yes"**: `GET /yes`
- **Play "Jump"**: `GET /jump`
- **Play "Ding"**: `GET /ding`
- **Play Random Sound**: `GET /random`

## 👁️ OLED Display API
- **Change Eye Mood**: `GET /eye_mood?val=X` (0: Happy, 1: Sad, 2: Neutral, 3: Angry)
- **Display Text**: `GET /oled_text?msg=Hello+World`

## 🎆 Display Animations API
- **Direct mode endpoint**: `GET /anim?mode=X` (0: Eyes, 1: Fireworks, 2: Matrix, 3: Heartbeat)
- **Named action aliases**:
  - `GET /anim_eyes`
  - `GET /anim_fireworks`
  - `GET /anim_matrix`
  - `GET /anim_heartbeat`

## 🐾 Movement & Servos
- **Move exact servo angle**: `GET /s1_90`, `GET /s2_180`, etc.
- **Pre-defined Actions**:
  - `GET /hi` (Waves single leg)
  - `GET /wiggle` (Wiggles back and forth)
  - `GET /stand` (Resets to standing position)
  - `GET /lay` (Lays down)
  - `GET /bow` (Bows down)
  - `GET /shake` (Shakes hand)

## 🕒 Scheduling (For Synchronized Dances!)
You can queue an action to happen after a relative delay (Up to **8 max** scheduled at once).

- **Run after delay**: `GET /schedule?action=wiggle&delay=5`
- **Run at exact time**: `GET /schedule?action=hi&at=1714000000`
- **Schedule text-to-speech**: `GET /schedule?action=tts:Hello&delay=10`

## 💡 LED Control
- **Turn ON**: `GET /l1on` or `GET /led?state=on`
- **Turn OFF**: `GET /l1off` or `GET /led?state=off`
- **Toggle**: `GET /toggle` or `GET /led?state=toggle`

---

*Tip: You can test any of these by typing them into your browser's address bar! Example: `http://dogbot1.local/schedule?action=bark&delay=3`*
