Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/boblio-max/origin/llms.txt

Use this file to discover all available pages before exploring further.

Origin was built hardware-first. Where most languages treat GPIO and serial protocols as library afterthoughts, Origin promotes them to top-level language syntax — a single readable line is all it takes to drive a pin HIGH, sweep a servo, or read a byte over I2C. This design philosophy means that embedded scripts stay small, readable, and auditable, with none of the setup boilerplate that accumulates in equivalent Python projects.

Hardware Namespaces

Origin groups hardware control into five distinct command namespaces, each targeting a different layer of the Raspberry Pi I/O stack:
NamespaceWhat it controls
set pinBCM GPIO output pins — drive HIGH or LOW
set servo.anglePCA9685 servo channels via I2C — set angle in degrees
i2cRaw I2C register reads and writes via smbus2
spiSPI bus reads and writes
uartUART serial reads and writes
All hardware commands use the same parenthesis-free, space-separated argument style that the rest of Origin uses. There are no imports, no object instantiation, and no teardown — the runtime handles library setup and GPIO cleanup automatically.

Architecture

Behind the scenes, Origin’s interpreter translates each hardware statement into a Python call during AST-to-Python code generation. The mapping is direct:
  • set pin <n>, <state>_execute_set_pin(n, state) via RPi.GPIO (BCM mode)
  • set servo.angle <n>, <deg>_kit.servo[n].angle = deg via adafruit-circuitpython-servokit
  • i2c.read <addr>, <reg>_execute_i2c_read(addr, reg) via smbus2 — reads 1 byte from register reg
  • i2c.read <addr>, <reg>, <size>_execute_i2c_read(addr, reg, size) — reads size bytes
  • i2c.write <addr>, <reg>, <data>_execute_i2c_write(addr, reg, data) via smbus2
  • spi.read <n>_execute_spi_read(n)
  • spi.write <data>_execute_spi_write(data)
  • uart.read <n>_execute_uart_read(n)
  • uart.write <data>_execute_uart_write(data)
This translation happens transparently — you write clean Origin syntax and the interpreter generates the correct Python library calls, including lazy initialization of the ServoKit instance and GPIO.setmode(GPIO.BCM) configuration.
set pin includes a simulation fallback: on a non-Pi host where RPi.GPIO is unavailable, the runtime prints [SIM] Pin <n> set to <state> instead of raising an error, so you can verify script logic before deployment. The I2C helpers silently return 0 (read) or do nothing (write) when smbus2 is not installed. SPI and UART primitives generate calls to _execute_spi_* and _execute_uart_* helpers — ensure those are present in your runtime environment.

Requirements

To use hardware commands in Origin, you need:
  1. Raspberry Pi hardware — any model with GPIO headers (Pi 3, 4, 5, or Zero 2W recommended)
  2. RPi.GPIO installed (pip install RPi.GPIO) for set pin commands
  3. adafruit-circuitpython-servokit installed (pip install adafruit-circuitpython-servokit) for servo control
  4. smbus2 installed (pip install smbus2) for I2C protocol commands
  5. Interfaces enabled in raspi-config (I2C, SPI, UART as needed)
  6. Appropriate wiring — current-limiting resistors for LEDs, correct power rails for servos
Hardware commands only execute correctly on Raspberry Pi hardware with the required Python libraries installed. Running an Origin script containing set servo.angle, spi, or uart commands on a standard desktop or laptop will raise a NameError because those runtime helpers are not available outside a Pi environment. Use set pin on a non-Pi host to test logic — it prints a [SIM] message instead of crashing.

Quick Reference

# GPIO — drive BCM pin 18 HIGH
set pin 18, 1

# GPIO — drive BCM pin 18 LOW
set pin 18, 0

# Servo — center servo channel 0
set servo.angle 0, 90

# Servo — move servo channel 2 to maximum
set servo.angle 2, 180

# I2C — read 1 byte from register 0x00 at device address 0x40
i2c.read 0x40, 0x00

# I2C — read 4 bytes from register 0x00 at device address 0x40
i2c.read 0x40, 0x00, 4

# I2C — write value 0x01 to register 0x00 at device address 0x48
i2c.write 0x48, 0x00, 0x01

# SPI — write a byte
spi.write 0x01

# SPI — read 2 bytes
spi.read 2

# UART — write a value
uart.write 0xFF

# UART — read 1 byte
uart.read 1

Explore the Hardware Docs

GPIO & Pins

Drive Raspberry Pi GPIO pins HIGH or LOW using the set pin command with BCM numbering.

Servo Control

Position PCA9685 servo channels with set servo.angle and automatic 0–180° clamping.

Protocols

Communicate over I2C, SPI, and UART with Origin’s parenthesis-free protocol primitives.

Build docs developers (and LLMs) love