Skip to content

Instantly share code, notes, and snippets.

View dlech's full-sized avatar

David Lechner dlech

View GitHub Profile
@dlech
dlech / notes.md
Created February 14, 2026 00:17
gpio-manager install notes

Notes on installing gpio-manager d-bus service from source

sudo make install does not do everyhing, so there are some extra steps:

  • Create gpio-manager user or gpio groups.
    sudo useradd --system gpio-manager
    sudo groupadd --system gpio
    sudo usermod -aG gpio gpio-manager
    

sudo usermod -aG gpio $USER

@dlech
dlech / watch-lego-science.py
Created October 26, 2025 01:27
LEGO Education Science BLE reveng
# SPDX-License-Identifier: MIT
import asyncio
from bleak import BleakScanner
from bleak.uuids import normalize_uuid_16
LEGO_SHORT_UUID = normalize_uuid_16(0xFD02)
@dlech
dlech / badgemagic.py
Last active October 3, 2025 06:54
Python script to program Fossia BadgeMagic using Bluetooth.
# SPDX-License-Identifier: MIT
# Copyright (c) 2025 David Lechner <dlechner@baylibre.com>
#
# /// script
# dependencies = [
# "bleak",
# ]
# ///
"""
@dlech
dlech / main.py
Created April 14, 2024 21:42
Resolver test bench
#!/usr/bin/env pybricks-micropython
# SPDX-License-Identifier: MIT
# Copyright (c) 2024 David Lechner <dlechner@baylibre.com>
import math
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor, InfraredSensor
from pybricks.parameters import Port, Direction, Button
from pybricks.tools import wait
@dlech
dlech / fullscreen.js
Last active July 26, 2023 17:13
Pybricks Code Full Screen Editor TamperMonkey Script
// ==UserScript==
// @name Pybricks Code Full Screen Editor
// @namespace https://pybricks.com/tampermonkey/full-screen-editor
// @version 1.0.0
// @description Full screen text editor for Pybricks Code.
// @author David Lechner
// @match https://code.pybricks.com
// @match https://beta.pybricks.com
// @icon https://pybricks.com/favion.ico
// @grant none
@dlech
dlech / square-names.js
Last active February 8, 2023 22:17
Chess.com square names
// ==UserScript==
// @name Square names
// @source https://gist.github.com/dlech/2e0e9304458b9f7b816a59e3f187a04b
// @namespace com.lechnology.chess.squares
// @version 1.0.0
// @description Display the square names on each square.
// @author David Lechner
// @match https://www.chess.com/*
// @grant none
// ==/UserScript==
@dlech
dlech / spike-prime-large-drive-base-remote.py
Last active June 2, 2021 23:30
Example Pybricks remote control program for SPIKE Prime large drive base (experimental)
from pybricks.hubs import PrimeHub
from pybricks.experimental import Remote
from pybricks.pupdevices import Motor
from pybricks.parameters import Button, Port, Direction
from pybricks.robotics import DriveBase
from pybricks.tools import wait
DRIVE_SPEED = 400
hub = PrimeHub()
@dlech
dlech / gelo.py
Last active September 19, 2023 07:40
A program for LEGO MINDSTORMS Robot Inventor - Gelo model
# SPDX-License-Identifier: MIT
# Copyright (c) 2021 David Lechner <david@pybricks.com>
# A program for LEGO MINDSTORMS Robot Inventor - Gelo
# Developed using MINDSTORMS App v1.3.4 (10.1.0), hub firmware v1.2.01.0103
# Building instructions: https://www.lego.com/cdn/product-assets/product.bi.additional.main.pdf/51515_Gelo.pdf
# Hub API: https://lego.github.io/MINDSTORMS-Robot-Inventor-hub-API/
@dlech
dlech / _websocket.py
Created December 25, 2020 01:16
WebSocket connection for Pybricks v2.x mailboxes
"""WebSocket server compatible with Pybricks v2.x mailboxes."""
# Ref: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers
# Ref: https://tools.ietf.org/html/rfc6455
# Ref: https://github.com/pybricks/pybricks-micropython/blob/v2/bricks/ev3dev/modules/pybricks/messaging.py
# Ref: https://github.com/pybricks/pybricks-micropython/blob/v2/bricks/ev3dev/modules/pybricks/bluetooth.py
# Ref: https://github.com/python/cpython/blob/3.9/Lib/socketserver.py
from ubinascii import b2a_base64
from uhashlib import sha1
@dlech
dlech / music.py
Created December 18, 2020 19:12
background music
from pybricks.hubs import InventorHub
from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor
from pybricks.parameters import Port, Stop, Color, Button
from pybricks.tools import wait, StopWatch
JINGLE_BELLS = (
["B3/4", "B3/4", "B3/2"] * 2 + ["B3/4", "D4/4", "G3/4.", "A3/8", "B3/2.", "R/4"] +
["C4/4", "C4/4", "C4/4.", "C4/8", "C4/4", "B3/4", "B3/4", "B3/8", "B3/8",
"D4/4", "D4/4", "C4/4", "A3/4", "G3/2.", "R/4"]
)