Skip to content
SDK Docs
Discord Order Now

Reference

API reference

Every glasses import, export and phone companion method in one place.

Glasses functions are imported from the mira WebAssembly module; phone methods live on miraCompanion. Arguments and return values are 32-bit integers unless noted.

Exports

Your module exports memory and these functions. None of them return a value.

app_init()
Called once when the app opens.
app_render(elapsed_ms)
Called repeatedly while the app runs, with the milliseconds since the previous call.
app_event(event)
Called with an input event. See Input.
app_stop()
Called right before the app closes.

Frames

begin()
Starts a new frame.
present()
Shows the frame. Only changed areas repaint.
frame_checkpoint() → i32
Saves everything drawn so far in this frame.
frame_restore() → i32
Restores the last checkpoint. Returns 0 when there’s nothing to restore.

Shapes

Coordinates are pixels on the 640 × 480 canvas. gray is 0 to 15.

line(x0, y0, x1, y1, width, gray)
A line.
fill_rect(x, y, w, h, gray)
A filled rectangle.
stroke_rect(x, y, w, h, line, gray)
A rectangle outline.
fill_round_rect(x, y, w, h, radius, gray)
A filled rounded rectangle.
stroke_round_rect(x, y, w, h, radius, line, gray)
A rounded rectangle outline.
fill_circle(cx, cy, radius, gray)
A filled circle.
stroke_circle(cx, cy, radius, line, gray)
A circle outline.
fill_triangle(x0, y0, x1, y1, x2, y2, gray)
A filled triangle.

Text and images

text(x, y, w, h, gray, font, align, line_spacing, utf8, len)
UTF-8 text clipped to its box. Fonts 0 to 3 are 24, 18, 32 and 40 px; align 0 left, 1 center, 2 right.
bitmap4(x, y, w, h, pixels, len)
A 4-bit grayscale image. Rows are ceil(w / 2) bytes, left pixel in the high nibble. Gray 15 is transparent.
bitmap4_rotated(x, y, w, h, pixels, len, degrees)
The same image rotated around its center.
bitmap1(x, y, w, h, mask, len, gray)
A one-color mask up to 32 × 32. Rows are ceil(w / 8) bytes, most significant bit first.

Device

now_ms() → i32
A millisecond clock for timing.
device_status(out, capacity) → i32
Writes 10 bytes: battery, charging, audio link, phone link, clock set, hour, minute, month, day, weekday. See Device and media.
display_brightness_get() → i32
Brightness in percent.
display_brightness_set(percent) → i32
Sets brightness from 0 to 100 and returns the value applied.
display_power_get() → i32
1 while the display is awake, 0 while it’s asleep.
display_power_set(on)
1 wakes the display or resets its idle timer; 0 sleeps it.
media_state(out, capacity) → i32
Available and playing bytes, then null-terminated title and artist. Use a 164-byte buffer.
media_command(command) → i32
0 previous, 1 play or pause, 2 next, 3 volume up, 4 volume down.
audio_level(channel) → i32
Loudness from 0 to 255. Channel 0 is the microphone, 1 is MIRA’s spoken replies.

Head tracking

Angles are centidegrees. Reading orientation or raw motion pauses the look-up dashboard until imu_stop().

imu_yaw_cdeg() → i32
Heading. Positive turns right.
imu_pitch_cdeg() → i32
Tilt. Positive looks up.
imu_roll_cdeg() → i32
Roll.
imu_ready() → i32
1 once calibrated data has arrived. Call a getter first.
imu_threshold(above_cdeg, below_cdeg) → i32
1 above, 0 below, -1 not ready, -2 full tracking active elsewhere. Leaves the dashboard working.
imu_raw_read(out) → i32
Nine 32-bit floats: accelerometer, gyroscope, magnetometer. Returns 1 when fresh.
imu_stop()
Releases head tracking.

Phone requests

ble_request asks the MIRA app on the phone to do work the glasses can’t, such as live transcription. It returns a request ID right away; poll for the answer on later frames.

ble_request(method, payload, len) → i32
Sends a request and returns its ID. Up to 8 can be in flight, with payloads up to 384 bytes.
ble_response_len(id) → i32
The response size once it’s ready. -1 pending, -2 unknown ID, -3 timed out after 8 seconds. Phone-side errors come back as -100 - status.
ble_response_read(id, out, capacity) → i32
Copies the response, which can be read once. -4 means the buffer is too small.
MethodDoes
0x0001Starts live transcription.
0x0002Stops live transcription.
0x0003Returns the latest transcript: a state byte, a final byte, then the text as UTF-8.

Rust helpers

The guide includes shared Rust modules. These are the ones most apps use.

content::cursor(x, y, visible)
Points the shared cursor at your focused control.
content::double_tap_local(claim)
Delivers double tap to your app instead of opening the sidebar.
content::holds_local(claim)
Delivers long press, hold start and hold end to your app.
content::sidebar_open() → bool
True while the sidebar covers your app.
content::overlay_visible() → bool
True while a notification or the dashboard covers your app.
content::context_changed() → bool
True when either of the above changed since you last asked.
content::imu::stop()
Same as imu_stop().
companion::Companion::new(name)
The ordered message bridge to your phone companion. tick(elapsed) returns the next message once; send(json) returns false while busy.
companion::Realtime::new(name)
The latest-value channel paired with setLatestForApp. Call tick every frame.
retained_frame::start(changed) / checkpoint()
Keeps static drawing between frames.
app_icon!(…)
Defines the 32 × 32 sidebar icon.

Phone companion

Methods on miraCompanion. Unless noted, each returns a promise.

sendToApp(value)
Sends an ordered JSON message to the glasses, up to 3,500 bytes.
setSnapshotForApp(value)
Replaces pending state the glasses page through, up to 3,500 bytes.
setLatestForApp(value)
Sets small realtime state, up to 380 bytes. Only the newest value is kept.
onFromApp(handler) → unsubscribe
Calls handler(message) for each message from the glasses. Not a promise.
storeGet(key) / storeSet(key, value) / storeRemove(key)
Small string storage on the phone.
getMediaState() / mediaCommand(code)
What’s playing, and playback controls.
getIMU() / stopIMU()
Motion readings from the glasses, and releasing them.
startCapture() / stopCapture()
Starts and stops glasses microphone audio.
onCapture(handler) → unsubscribe
Receives audio frames. Not a promise.
bindPasteButton(button, onPaste)
Shows the iOS Paste control over a button. Returns {ready, dispose()}.
fetch(input, init) / WebSocket
Standard networking, made from the phone.