Skip to content

brian.bremote.BRemote

brian.bremote

BRemote class objects

class BRemote()

A paired BRemote controller. Instances are returned by brian.bremote.list().

Button class objects

class Button()

A button of the remote.

is_pressed

def is_pressed() -> bool

Returns:

True if the button is currently pressed.

was_just_pressed

def was_just_pressed() -> bool

Returns:

True if a press edge occurred since the last poll or wait. Consumes the edge (returns False on subsequent calls until the next press).

was_just_released

def was_just_released() -> bool

Returns:

True if a release edge occurred since the last poll or wait. Consumes the edge (returns False on subsequent calls until the next release).

wait_for_press

def wait_for_press(timeout_ms: Optional[int] = None) -> bool

Waits for the next button press edge.

This function is blocking and abortable from MicroPython.

Arguments:

  • timeout_ms: Maximum number of milliseconds to wait.
  • If the timeout is not provided or is None, the function will wait indefinitely.

Raises:

  • BRemoteDisconnectedError: If the remote disconnects while waiting.

Returns:

success: - True: If the desired button event was caught. - False: If the timeout ran out or the wait was aborted.

wait_for_release

def wait_for_release(timeout_ms: Optional[int] = None) -> bool

Waits for the next button release edge.

This function is blocking and abortable from MicroPython.

Arguments:

  • timeout_ms: Maximum number of milliseconds to wait.
  • If the timeout is not provided or is None, the function will wait indefinitely.

Raises:

  • BRemoteDisconnectedError: If the remote disconnects while waiting.

Returns:

success: - True: If the desired button event was caught. - False: If the timeout ran out or the wait was aborted.

wait_for_press_and_release

def wait_for_press_and_release(timeout_ms: Optional[int] = None) -> bool

Waits for next button press and release event.

This function is blocking and abortable from MicroPython.

Arguments:

  • timeout_ms: Maximum number of milliseconds to wait.
  • If the timeout is not provided or is None, the function will wait indefinitely.

Raises:

  • BRemoteDisconnectedError: If the remote disconnects while waiting.

Returns:

success: - True: If the desired button event was caught. - False: If the timeout ran out or the wait was aborted.

joystick_btn

Joystick click (press-to-click) button.

aux_btn

Auxiliary button.

power_btn

Power button.

hair_trigger_20

Virtual button: pressed when analog trigger crosses 20%

hair_trigger_50

Virtual button: pressed when analog trigger crosses 50%.

hair_trigger_99

Virtual button: pressed when analog trigger crosses 99%.

is_connected

def is_connected() -> bool

Returns:

True when this remote is operational and the last OpInput is younger than 200 ms.

is_reconnecting

def is_reconnecting() -> bool

Returns:

True while Brian is trying to restore a lost link (OpOutput keepalive active). Set atomically with is_connected when input goes stale or the driver enters the reconnecting session phase. Cleared when OpInput resumes or the 5-minute reconnecting deadline expires.

wait_until_connected

def wait_until_connected(timeout_ms: Optional[int] = None) -> bool

Waits until this remote is operational (fresh OpInput). This function is blocking.

Arguments:

  • timeout_ms: Maximum number of milliseconds to wait.
  • If the timeout is not provided or is None, the function will wait indefinitely.

Returns:

success: - True: If the remote became connected. - False: If the timeout ran out or the wait was aborted.

mac_str

def mac_str() -> str

Returns:

Remote MAC address as an uppercase hex string (AA:BB:CC:DD:EE:FF).

age_us

def age_us() -> int

Returns:

Age of the last received packet in microseconds. Returns a very large value (UINT32_MAX) when no packet has ever been received.

total_packets_received

def total_packets_received() -> int

Returns:

Total validated OpInput packets received while the session is operational. Resets when the ESP-NOW session ends (resetSession).

joystick_x

def joystick_x() -> float

Returns:

Current joystick X axis value in range -1.0 ~ 1.0.

joystick_y

def joystick_y() -> float

Returns:

Current joystick Y axis value in range -1.0 ~ 1.0.

battery_level

def battery_level() -> int

Returns:

Remote controller battery level in percents (0–100). Returns 0 when not connected.

is_battery_charging

def is_battery_charging() -> bool

Returns:

True when the remote reports that its battery is charging. Returns False when not connected.

is_overheating

def is_overheating() -> bool

Returns:

True when the remote temperature exceeds the overheating threshold. Returns False when not connected.

trigger

def trigger() -> float

Returns:

Current trigger position in range 0.0 ~ 1.0 (analog input, not a digital button).

motion

def motion() -> Optional[float]

Returns:

Peak |ax|+|ay|+|az|+|gx|+|gy|+|gz| (g + dps) since the last packet. Returns None when not connected or on IMU I2C error.

play_tone

def play_tone(tone: int, duration_ms: int) -> None

Play a tone on the remote controller speaker.

Arguments:

  • tone: Frequency in Hz.
  • duration_ms: Tone duration in milliseconds.

stop_tone

def stop_tone() -> None

Stop any tone currently playing on the remote controller.

set_color

def set_color(color: LedColor = 'DEFAULT_COLOR_FROM_SETTINGS') -> None

Set the user LED color on this remote.

Arguments:

  • color: Target color. When unfilled default color from settings is used.