Skip to content

Instantly share code, notes, and snippets.

View dlech's full-sized avatar

David Lechner dlech

View GitHub Profile
@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"]
)
@dlech
dlech / multitask.py
Last active March 28, 2023 14:09
Example of LEGO SPIKE Prime scratch program translated to MicroPython using generator functions as coroutines
# spike.control.wait_for_seconds doesn't allow decimal points
# so we replace it with the standard MicroPython sleep function instead
from utime import sleep as wait_for_seconds
from utime import ticks_diff, ticks_ms
# See https://docs.micropython.org/en/latest/library/utime.html for more info on the utime module
from spike import (PrimeHub, LightMatrix, Button, StatusLight, ForceSensor, MotionSensor,
Speaker, ColorSensor, App, DistanceSensor, Motor, MotorPair)
from spike.control import wait_until
@dlech
dlech / nsrunloop_asyncio.py
Created June 25, 2020 21:19
NSRunLoop integration with Python asyncio
"""
NSRunLoop integration with Python asyncio.
Created on 2020-06-25 by David Lechner <david@pybricks.com>
"""
import asyncio
import selectors
import objc
from Foundation import NSDate, NSDefaultRunLoopMode, NSFileHandle, NSRunLoop
@dlech
dlech / Program.cs
Created June 14, 2020 00:47
Pybricks BLE UART C#
using System;
using System.Linq;
using System.Threading.Tasks;
using Windows.Devices.Bluetooth;
using Windows.Devices.Bluetooth.GenericAttributeProfile;
using Windows.Devices.Bluetooth.Advertisement;
using Windows.Security.Cryptography;
using Windows.Storage.Streams;
using Buffer = Windows.Storage.Streams.Buffer;
using System.IO;
@dlech
dlech / ble.py
Created April 7, 2020 23:08
ev3dev-stretch D-Bus BlueZ example
#!/usr/bin/env python3
# ev3dev-stretch
# https://github.com/bluez/bluez/blob/5.43/doc/gatt-api.txt
# https://developer.gnome.org/gio/2.50/GDBusProxy.html
import gi
# gi.require_version("GLib", "2.0")
# gi.require_version("GObject", "2.0")
@dlech
dlech / c_cpp_properties.json
Created October 22, 2019 04:21
VS Code C/C++ Extension Config for Pybricks MicroPython
{
"configurations": [
{
"name": "movehub",
"includePath": [
"${workspaceFolder}/lib/cmsis/inc",
"${workspaceFolder}/lib/stm32lib/CMSIS/STM32F0xx/Include",
"${workspaceFolder}/ports/pybricks/lib/libfixmath/libfixmath",
"${workspaceFolder}/ports/pybricks/lib/pbio/include",
"${workspaceFolder}/ports/pybricks/lib/pbio/platform/move_hub",
@dlech
dlech / udev.py
Created June 25, 2019 23:16
MicroPython bindings for libudev
# SPDX-License-Identifier: MIT
# Copyright (c) 2019 David Lechner <david@pybricks.com>
import ffi
from uerrno import ENOENT
_udev = ffi.open('libudev.so.1')
_libc = ffi.open('libc.so.6')
_errno = _libc.var("i", "errno")
@dlech
dlech / Microsoft.PowerShell_profile.ps1
Last active April 3, 2019 00:46
git-posh customization
Import-Module posh-git
# show the git repo name in magenta (really the parent directory name)
$GitPromptSettings.DefaultPromptPrefix.Text = '$(@((git rev-parse --show-toplevel).Split("/"))[-1])'
$GitPromptSettings.DefaultPromptPrefix.ForegroundColor = [ConsoleColor]::Magenta
# show only the relative directory in the git repo
$GitPromptSettings.DefaultPromptPath = '\$(@($pwd.Path.Split("\") | Select-Object -Skip @((git rev-parse --show-toplevel).Split("/")).Length) -join "\")'
@dlech
dlech / .editorconfig
Last active April 1, 2019 20:25
Git bootstrap
root = true
[*.{cfg,editorconfig,git*,py,rst,sh,md}]
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 4
indent_style = space
[*.json]
insert_final_newline = false
diff --git a/arch/arm/boot/dts/am335x-bonegreen-common.dtsi b/arch/arm/boot/dts/am335x-bonegreen-common.dtsi
index 853e6d3a028d..3cbe363d4fbf 100644
--- a/arch/arm/boot/dts/am335x-bonegreen-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bonegreen-common.dtsi
@@ -21,7 +21,7 @@
pinctrl-names = "default";
pinctrl-0 = <&emmc_pins>;
bus-width = <8>;
- status = "okay";
+ status = "disabled";