Skip to main content

Control the MSN i-Buddy USB figure from Python

Project description

ibuddy

Control your MSN i-Buddy USB figure from Python.

The i-Buddy is a small USB HID figure with a head LED (7 colors), heart light, flapping wings, and a swiveling torso. This library gives you full control over all of it.

pip install ibuddy

Windows only - The i-Buddy uses Windows HID APIs for communication.

Quick Start

from ibuddy import IBuddyDevice

with IBuddyDevice() as buddy:
    buddy.demo()

That's it. Plug in your i-Buddy, run the code, and watch it go.

Usage

Connecting

The library uses a context manager so the device is always properly reset when you're done:

from ibuddy import IBuddyDevice

with IBuddyDevice() as buddy:
    buddy.head_color("red")
    buddy.flap(3)
# Automatically resets and closes

Head LED

Set the head to one of 7 named colors:

buddy.head_color("red")         # Hold for 0.3s (default)
buddy.head_color("blue", 1.0)   # Hold for 1 second
buddy.head_color("green", 0)    # Set and return immediately

# Available colors: red, green, blue, cyan, magenta, yellow, white

Or set raw RGB bits directly:

buddy.set_head_color(1, 0, 0)  # Red (r=1, g=0, b=0)
buddy._send()                   # Send the command

Heart LED

buddy.heart(True)         # Turn on for 0.3s
buddy.heart(False)        # Turn off for 0.3s
buddy.heart(True, 1.0)    # Stay on for 1 second
buddy.heart(False, 0)     # Turn off immediately

buddy.heartbeat(times=5, delay=0.2)  # Blink 5 times

Wings

buddy.flap(times=3, delay=0.15)  # Flap 3 times (default)
buddy.flap(10, 0.1)              # Flap 10 times, faster

Torso Swivel

buddy.wiggle(times=3, delay=0.5)  # Wiggle left/right 3 times
buddy.wiggle(5, 0.3)              # Faster wiggle

Combos

buddy.rainbow(times=2)     # Cycle all 7 colors twice
buddy.celebrate()           # Wiggle + flap + heartbeat + rainbow
buddy.demo()                # Full demo of every feature

Low-Level Control

buddy.set_wing(True)        # Wings up
buddy.set_wing(False)       # Wings down
buddy.set_swivel("left")    # Swivel left
buddy.set_swivel("right")   # Swivel right
buddy.set_heart(True)       # Heart on
buddy.reset()               # Everything off

After setting state manually, call buddy._send() to push it to the device.

API Reference

IBuddyDevice(auto_reset=True)

Main device class. Connects to the i-Buddy on creation.

Parameter Type Default Description
auto_reset bool True Reset all outputs on connection

High-Level Methods

Method Parameters Description
head_color(name, duration=0.3) color name, seconds Set head LED color
heart(on, duration=0.3) bool, seconds Turn heart on/off
flap(times=3, delay=0.15) count, seconds Flap wings
wiggle(times=3, delay=0.5) count, seconds Swivel torso
heartbeat(times=3, delay=0.2) count, seconds Blink heart
rainbow(times=2, duration=0.3) cycles, seconds Cycle all colors
celebrate() - Party mode
demo() - Full feature demo
reset() - Turn everything off

Low-Level Methods

Method Parameters Description
set_head_color(r, g, b) 0 or 1 each Set raw RGB bits
set_heart(on) bool Set heart state
set_wing(up) bool Set wing position
set_swivel(direction) "left"/"right" Set swivel direction
close() - Reset and disconnect

Exceptions

Exception When
IBuddyError Base exception for all ibuddy errors
IBuddyNotFoundError i-Buddy not plugged in
IBuddyConnectionError Device found but can't be opened
IBuddyInvalidColorError Unknown color name

Available Colors

Name RGB
red (1, 0, 0)
green (0, 1, 0)
blue (0, 0, 1)
cyan (0, 1, 1)
magenta (1, 0, 1)
yellow (1, 1, 0)
white (1, 1, 1)

Requirements

  • Windows
  • Python 3.9+
  • pywinusb (installed automatically)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ibuddy-1.0.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ibuddy-1.0.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file ibuddy-1.0.1.tar.gz.

File metadata

  • Download URL: ibuddy-1.0.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for ibuddy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b8c9765ec017a7ef4165eddd7437f7f67636653c5fc82fb8b5dad0375d33a328
MD5 ade5183e5f8cdabc1a4ae4eae3b8c35a
BLAKE2b-256 83108e4124724eac240f3f33bd5c91cf0f3cc1dee77a879b99489a2037e0b5bc

See more details on using hashes here.

File details

Details for the file ibuddy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ibuddy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for ibuddy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 04cf9f91ce64fc805edb2935fcbf0e48d0e12557e2e43350da356a8fe6d9a90a
MD5 e44dbac00111c43b4b430bd06e931d63
BLAKE2b-256 8ee1e7484ffb68fa28b521d2660770e09148d32973f950e06ea47a38fc1d7879

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page