Text
oled_print(text), oled_println(text), oled_set_cursor(x, y), oled_set_text_size(size)
// MICROPYTHON CALLS
Function groups and constants for the Replay 2026 Badge MicroPython
API. The exhaustive reference is also available
on-device as /docs/API_REFERENCE.md.
// INIT
init() initializes the badge runtime bindings.
// DISPLAY
oled_print(text), oled_println(text), oled_set_cursor(x, y), oled_set_text_size(size)
oled_clear([show]), oled_show(), oled_invert(enable)
oled_set_font(name), oled_get_fonts(), oled_get_current_font()
oled_set_pixel(x, y, color), oled_get_pixel(x, y), oled_draw_box(x, y, w, h), oled_set_draw_color(color)
oled_text_width(text), oled_text_height()
oled_get_framebuffer(), oled_set_framebuffer(data), oled_get_framebuffer_size()
// CHROME
ui_header(title, [right]), ui_action_bar(...), ui_chrome(...)
ui_inline_hint(x, y, hint), ui_inline_hint_right(right_x, y, hint), ui_measure_hint(hint)
ui_grid_cell(col, row, label, selected, [icon]), ui_grid_footer([description])
ui_list_row(row, label, selected), ui_list_rows_visible()
Button hints accept labels such as A:open,
B:back, X:edit, Y:menu,
Confirm:select, Back:exit,
Left/Right:move, and All:reset.
The native renderer turns recognized button names into the badge's
standard glyphs, so prefer these helpers over hand-drawn footer text.
// PYTHON HELPERS
badge_uiscreen(), chrome(), chrome_tall(), header(), footer(), action_bar(), tall_action_bar(), hint(), hint_row(), inline_hint(), inline_hint_right(), status_box(), spinner()
badge_apprun_app(), with_led_override(), ButtonLatch, GCTicker, DualScreenSession, read_stick_4way(), load_score(), save_score()
badge_kvfrom badge_kv import kv, then use kv.get(), kv.put(), kv.delete(), and kv.keys().
import badge_ui as ui
from badge import *
ui.chrome("My App", right="1/3", left_button="B", left_label="back",
right_button="A", right_label="open")
ui.line(0, "Hello from MicroPython")
ui.inline_hint(0, 53, "Left/Right:move")
oled_show()
// INPUT
button(id), button_pressed(id), button_held_ms(id)
joy_x(), joy_y()
BTN_RIGHT, BTN_DOWN, BTN_LEFT, BTN_UP, BTN_CONFIRM, BTN_BACK
// LEDS
led_brightness(value), led_clear(), led_fill([brightness]), led_set_pixel(x, y, brightness), led_get_pixel(x, y)
led_show_image(name), led_set_frame(rows, [brightness])
led_start_animation(name, [interval_ms]), led_stop_animation()
led_override_begin(), led_override_end()
// BACKGROUND MATRIX
matrix_app_start(callback, [interval_ms], [brightness]),
matrix_app_set_speed(interval_ms),
matrix_app_set_brightness(brightness),
matrix_app_stop(), matrix_app_active(), and
matrix_app_info().
// MOTION
imu_ready(), imu_tilt_x(),
imu_tilt_y(), imu_accel_z(),
imu_face_down(), and imu_motion().
// FEEDBACK
haptic_pulse([strength], [duration_ms], [freq_hz]),
haptic_strength([value]), haptic_off(),
tone(freq_hz, [duration_ms], [duty]),
no_tone(), and tone_playing().
// COMMS
ir_start(), ir_stop(), ir_flush()
ir_send(addr, cmd), ir_available(), ir_read()
ir_send_words(words), ir_read_words(), 1-64 words
ir_set_mode("nec"), ir_nec_send(addr, cmd, [repeats]), ir_nec_read()
ir_set_mode("raw"), ir_raw_capture(), ir_raw_send(buf, [carrier_hz]), ir_activity()
ir_tx_power([percent])
// NETWORK
http_get(url) returns a response body string. http_post(url, body) posts a string body and returns the response body. Responses are capped at 8192 bytes.
serial_available() returns True when at least one USB serial byte is queued. serial_read() reads one byte or returns None.
// IDENTITY
contact() returns editable contact fields:
name, title, company, email, and website.
set_contact(dict) updates any of those fields in
persistent memory. set_time(epoch) sets the badge wall
clock from a Unix epoch timestamp.
// PERSISTENCE
kv_put(key, value), kv_get(key, [default]),
kv_delete(key), and kv_keys() store small
app settings in NVS so they survive firmware updates and filesystem
reflashes. Use badge_kv.kv for a friendlier wrapper.
// CONTROL
Use exit() to return to firmware. Dev builds also expose
dev(*args). rescan_apps() asks the native
app registry to rescan installed MicroPython apps after files change.
set_repl_trace(enable) is a developer diagnostic toggle
for serial REPL tracing.
Filesystem access uses standard
open() and os APIs.
// POINTER
mouse_overlay(enable), mouse_set_bitmap(data, w, h)
mouse_x(), mouse_y(), mouse_set_pos(x, y)
mouse_clicked(), mouse_set_speed(speed), mouse_set_mode(mode)
// C / C++ SURFACE
App authors should treat the Python badge,
badge_ui, badge_app, and
badge_kv modules as the public API. The C/C++ bridge in
firmware/micropython/usermods/temporalbadge/ and
firmware/src/micropython/badge_mp_api/ is for firmware
contributors adding new bindings. Native UI consistency lives in
OLEDLayout and ButtonGlyphs; expose shared
behavior through the MicroPython bindings rather than duplicating C++
internals in app code.
// CONSTANTS
| Group | Constants |
|---|---|
| Buttons | BTN_RIGHT, BTN_DOWN, BTN_LEFT, BTN_UP, BTN_CIRCLE, BTN_CROSS, BTN_SQUARE, BTN_TRIANGLE, BTN_CONFIRM, BTN_SAVE, BTN_BACK, BTN_PRESETS |
| LED Images | IMG_SMILEY, IMG_HEART, IMG_ARROW_UP, IMG_ARROW_DOWN, IMG_X_MARK, IMG_DOT |
| LED Animations | ANIM_SPINNER, ANIM_BLINK_SMILEY, ANIM_PULSE_HEART |
| Mouse Modes | MOUSE_ABSOLUTE, MOUSE_RELATIVE |