rickp / lego_mario_controller Goto Github PK
View Code? Open in Web Editor NEWA small python script that connects to a Lego Mario figurine via BLuetooth LE and emits keystrokes for different actions.
A small python script that connects to a Lego Mario figurine via BLuetooth LE and emits keystrokes for different actions.
Hi,
I could not get it to work on name check.
Only with address check. (But that could be my environment related)
#if d.name.lower().startswith("lego mario"):
if d.address == LEGO_CHARACTERISTIC_UUID:
The Mario connects, but is not happy with the IMU?
You hear the 'upswing' Mario sound, immediately followd by a 'downswing' Mario sound, that it is not happy.
diff --git a/src/mario.py b/src/mario.py
index bddee31..e95ede2 100644
--- a/src/mario.py
+++ b/src/mario.py
@@ -17,7 +17,8 @@ BUTTON_TIME_DEFAULT = 0.1
BUTTON_TIME_JUMP = 1.5
# BLE stuff
-LEGO_CHARACTERISTIC_UUID = "00001624-1212-efde-1623-785feabcd123"
+#LEGO_CHARACTERISTIC_UUID = "00001624-1212-efde-1623-785feabcd123"
+LEGO_CHARACTERISTIC_UUID = "C30C5B5B-9B73-41B1-99C3-3E1AAFC7053E"
SUBSCRIBE_IMU_COMMAND = bytearray([0x0A, 0x00, 0x41, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01])
SUBSCRIBE_RGB_COMMAND = bytearray([0x0A, 0x00, 0x41, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01])
@@ -105,6 +106,7 @@ class MarioController:
def notification_handler(self, sender, data):
+ printf("Notify_handler")
# Camera sensor data
if data[0] == 8:
@@ -148,7 +150,8 @@ class MarioController:
self.gui.accel_field.SetLabel("")
devices = await BleakScanner.discover()
for d in devices:
- if d.name.lower().startswith("lego mario"):
+ #if d.name.lower().startswith("lego mario"):
+ if d.address == LEGO_CHARACTERISTIC_UUID:
self.gui.status_field.SetLabel("Found Mario!")
try:
async with BleakClient(d.address) as client:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.