// ADVANCED TOPICS

Gotchas

Notes for long-running apps, badge-to-badge IR exchanges, mouse overlay interfaces, orientation handling, and cleanup before exit.

Advanced IR Comms Gotchas

Advanced

mouseoverlay

Point-and-Click UI

mouse_overlay(True) enables a hardware-composited cursor. Joystick movement drives the cursor and button presses become click events.

imunametag

Flip Detection

Use imu_face_down() or continuous imu_tilt_y() values to react when the badge hangs upside down.

uichrome

Native UI Helpers

ui_header(), ui_action_bar(), and badge_ui helpers keep app screens visually consistent with firmware menus.

Badge-to-Badge IR

startrequired

Own the IR Hardware

Call ir_start() before sending or reading. Python gets exclusive access while IR mode is active.

framespayload

Use the Right Frame

Use ir_send(addr, cmd) for compact frames and ir_send_words(words) for multi-word payloads up to 64 32-bit words.

poll50 ms

Read Quickly

Poll ir_read() or ir_read_words() within about 50 ms per frame or receiver buffers can drop data.

Tips and Gotchas

memory128 KB

Manage Heap

Avoid large temporary objects, reuse buffers, call gc.collect(), and split large source files into modules.

displayshow

Refresh Explicitly

Drawing calls update the framebuffer. Call oled_show() before expecting pixels to appear.

ledsoverride

Protect Matrix Drawing

Wrap direct matrix drawing in led_override_begin() and led_override_end() so ambient firmware modes do not overwrite the frame.

inputonce

Do Not Double-Consume

button_pressed() consumes the event. Read it once per loop and store the value.

exitsafety

Escape Chord

Holding all four face buttons for about one second force-exits a stuck app.

cleanupexit

Be a Good Citizen

Before exiting, clear LEDs, stop haptics and tones, stop IR, and disable mouse overlay.