This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<busconfig> | |
<policy user="pulse"> | |
<allow send_destination="org.bluez"/> | |
</policy> | |
</busconfig> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Raspberry Pi microSD card benchmark script. | |
# | |
# A script I use to automate the running and reporting of benchmarks I compile | |
# for: http://www.pidramble.com/wiki/benchmarks/microsd-cards | |
# | |
# Usage: | |
# $ wget https://gist.githubusercontent.com/dlech/e922dbdc870d0e1d2c6065363c189345/raw/microsd-benchmarks.sh | |
# $ sudo bash microsd-benchmarks.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "\")' |