Skip to content

djipko/legomario.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

legomario.py

alt text

Lego Mario is a LEGO (tm) PowerdUp hub. It's a BLE device that supports the LEGO wireless protocol (way more details on that here).

While there are several awesome projects (see below) that support interacting with LEGO Mario figure over BLE and reading sensors it exposes - there was nothing fully fleshed out in Python, that I could find.

legomario.py builds upon the bleak library and implements a subset of LWP that is just about enough to deal with the few sensors LEGO Mario exposes, and aims to expose a Pythonic interface for interacting with your LEGO Mario figure programmatically.

This is best shown with an example:

async def run():
    mario = LegoMario(MARIO_UUID)
    async with mario as mario:
        print(f"{await mario.repr()}")
        await mario.set_volume(50)
        print(f"New vol: {await mario.volume.get()}")

        async for _ in mario.read_ports_changed():
            print(f"{await mario.repr()}")

While it does support most of the interesting stuff tha Mario hub exposes, there are still some bits missing (this was a quick summer holiday hack after all), which I'll be happy to add.

An interesting next step would be to use this to drive a visualisation or an actual game :)

Acknowledgements

These awesome projects have already done the bulk of the reverse engineering and made this much easier to hack up than it would have been.

About

Python library for interacting with the LEGO Mario figure

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages