# Python Inventor / virtual desk station

A functional application twin, not a native RP2350 emulator. Actual CPython 3.14.2 runs inside the same locally hosted Pyodide 314.0.7 distribution used by the AI Lab. No Python service, package installation or physical hardware connection is required. Python loads only on Run. Each program runs in its own terminable Worker, with a four-minute limit, 6000 driver calls, 300 output messages, 2000 CSV rows and bounded drawing commands. Stop also terminates a Python infinite loop.

## Try it

Select Python Inventor. The 2D circuit opens first. Choose Weather station / Focus timer / Data logger, then Try experiment. Open 3D Build to inspect the same wires, buttons, dial and live OLED. Changes to the circuit affect the virtual driver: disconnected power, I2C, pull-ups or encoder wires make the corresponding device unavailable. A/B clicks here and in 2D/3D refer to the same circuit buttons. A is toggle-on/off; it is not a timed physical contact. Encoder press is a virtual input; no quadrature edge timing or mechanical bounce is claimed.

## Reference wiring

Pico 2 W (RP2350), powered by virtual USB, with AiRO-fitted headers. A 400-point breadboard uses its real five-hole groups and centre separation.

| Device | Connection |
|---|---|
| OLED VIN/GND | 3.3 V / GND |
| OLED SDA/SCL | GP12 / GP13, I2C0 |
| OLED configuration | SSD1306 128×64, configured for I2C at 0x3C before sale |
| BME280 VIN/GND | 3.3 V / GND |
| BME280 SDI/SCK | GP12 SDA / GP13 SCL |
| BME280 CS/SDO | Both 3.3 V, I2C address 0x77 |
| SDA/SCL pull-ups | Each 4.7 kΩ to 3.3 V |
| Encoder C/A/B | GND / GP14 / GP15 |
| Encoder SW1/SW2 | GP16 / GND, virtual input pull-up |
| Button A/B | GP26 / GP27 to GND, virtual input pull-ups |

Exact breakout revisions, OLED solder jumpers, onboard pull-ups, encoder orientation and physical button continuity must be checked before producing kit instructions. The simulator uses a configurable four-pin OLED connection abstraction and selected BME280 pins; it does not reproduce every optional breakout pin. Enclosures, USB cable and guides are passive kit contents, not simulated circuits. Prices/BOM are unchanged.

## Virtual Python API

`from airo_pico import station, display`

- `await station.scan()` → available virtual I2C addresses (60, 119).
- `await station.read()` → dictionary: seconds, temperature (°C), humidity (%), pressure (hPa), dial (0–100), pressed (encoder switch), a and b. Requires wired environment sensor and encoder. Unwired A/B read released.
- `await station.sleep(seconds)` → 0.01–30 seconds, real browser time.
- `await station.log(sample)` → append a numeric sample to downloadable CSV.
- `display.fill(0 or 1)`, `text(text,x,y,colour=1)`, `pixel(x,y,colour=1)`, `rect(x,y,width,height,colour=1,fill=False)` → queue drawing operations.
- `await display.show()` → draw the shared 128×64 canvas framebuffer. Text uses the browser monospace font; it is not the SSD1306 MicroPython 8×8 ROM font. Pixel and rectangle coordinates clip to the framebuffer.

The display canvas is copied onto the 2D OLED and used as the 3D OLED texture. Environment sliders supply synthetic measurements, not a simulated thermal/pressure system or BME280 calibration registers. The dial is a position input, not an electrical quadrature decoder. This API is deliberately named airo_pico: it is not advertised as a machine/SSD1306/BME280 firmware compatibility layer. Adapt drivers and timing before hardware upload. Exact RP2350 native execution remains a separate unfinished milestone.

Save experiment includes Python and environment/dial/power/encoder-press state. Save in the circuit toolbar includes wiring and A/B switch state. Load wiring first, then experiment. The .py export runs against this virtual API. CSV contains only numeric/boolean experiment data; nothing is sent to a server.

## Primary references

- Raspberry Pi Pico 2 W: https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html
- RP2 MicroPython I2C examples: https://docs.micropython.org/en/latest/rp2/quickref.html#hardware-i2c-bus
- Raspberry Pi beginner pathway: https://projects.raspberrypi.org/en/pathways/pico-intro
- Adafruit SSD1306: https://learn.adafruit.com/monochrome-oled-breakouts/arduino-library-and-examples
- Adafruit BME280 pinouts/address: https://learn.adafruit.com/adafruit-bme280-humidity-barometric-pressure-temperature-sensor-breakout/pinouts
- PEC11 reference: https://www.adafruit.com/product/377
- Runtime provenance and licences: ../python/SOURCE.json, ../python/LICENSE.txt and ../python/CPYTHON-LICENSE.txt.
