Skip to content

Instantly share code, notes, and snippets.

View WayneKeenan's full-sized avatar

Wayne Keenan WayneKeenan

  • Eastbourne, UK
  • 13:04 (UTC +01:00)
View GitHub Profile
@WayneKeenan
WayneKeenan / build.sh
Last active August 16, 2023 08:24
Build Pico W examples
# You will need: cmake, make and an arm-none-eabi-gcc compiler on your PATH already.
export PROJECT_DIR=$PWD # or anywhere else.
export PICO_SDK_PATH=${PROJECT_DIR}/pico-sdk
export PICO_EXAMPLES_PATH=${PROJECT_DIR}/pico-examples
export PICO_EXTRAS_PATH=${PROJECT_DIR}/pico-extras
git clone https://github.com/raspberrypi/pico-sdk.git
git clone https://github.com/raspberrypi/pico-extras.git
from gpiozero import LED
from bubblepy import peripheral, gatt
@gatt.service(0x1234)
class Light:
def __init__(self):
self.led = LED(17)
@gatt.characteristic(0xABCD, ['write'], "Set Light State")
@WayneKeenan
WayneKeenan / microbit_gpiozero_buttons.py
Created September 19, 2018 11:48
gpiozero buttons on the microbit
from gpiozero import Button
def buttonA_pressed():
print("Button A")
def buttonB_pressed():
print("Button B")
buttonA = Button(13)
buttonA.when_pressed(buttonA_pressed)
# python3 -m venv my-venv
# source my-venv/bin/activate
# pip3 install --upgrade pip setuptools wheel
# hg clone https://bitbucket.org/ronaldoussoren/pyobjc pyobjc # e.g. homebrew install mercurial
# cd pyobj
# python3 install.py # You will need XCode installed in order to compile the native extensions.
# python3 ../test_4.1.py
# deactivate
import objc
# python3 -m venv my-venv
# source my-venv/bin/activate
# pip3 install --upgrade pip setuptools wheel
# python3 dispatch_test.py
# deactivate
import ctypes
import objc
from PyObjCTools import AppHelper
import CoreBluetooth
@WayneKeenan
WayneKeenan / test_macos_pyobjc_dispatch_observer.py
Last active November 14, 2017 08:04
test_macos_pyobjc_dispatch_observer.py
import threading
from logging import getLogger, basicConfig, DEBUG
from time import sleep
import objc
from Foundation import *
from PyObjCTools import AppHelper
import CoreBluetooth
from ctypes import cdll, Structure, POINTER, pointer, c_int, c_char_p, c_void_p, cast
# http://python.net/crew/theller/ctypes/tutorial.html
@WayneKeenan
WayneKeenan / main.py
Last active November 2, 2017 05:11
PiCraftZero test script, demoing self install of its 2 dependancies for PiratePython
#!/usr/bin/env python3
import pip
pip.main(['install', 'gpiozero'])
pip.main(['install', 'picraftzero']) # Joypad and Web Remote controls with multiple camera support, please see
# https://github.com/WayneKeenan/picraftzero
from picraftzero import Joystick, Wheelbase, steering_mixer, start
# Joystick axis range is: (left/down) -100 .. 100 (right/up)
@WayneKeenan
WayneKeenan / mac-vagrant-howto.rst
Created October 22, 2017 12:51 — forked from tbonesteaks/mac-vagrant-howto.rst
brew, vagrant, virtualbox, and vagrant file howto...

Vagrant on Mac w Virtualbox

NSoT engineers have built Vagrantfiles for you to deploy NSoT software in a multitude of linux environments. This tutorial will help you load a Macintonsh computer (OS X) with Vagrant, Virtual Box, and dependencies so that you can start virtual servers and test the software.

NSoT publishes complete installation instructions for linux distributions, branch versions, and Vagrantfiles in addition to, not an alternative for the pip install method:

$ pip-install nsot
@WayneKeenan
WayneKeenan / virtualbox-vagrant-nuclear-option.sh
Created October 22, 2017 12:49 — forked from tjbenton/virtualbox-vagrant-nuclear-option.sh
Completely uninstall VirtualBox and Vagrant and reinstall through brew
# update brew because `brew update` is broken after updating to El Capitan
cd `brew --prefix`
git fetch origin
git reset --hard origin/master
sudo shutdown -r now # restart the computer
# open terminal and run the following
brew update
brew cleanup
import re
import json
import requests
from pprint import pformat
from time import sleep
from gpiozero import Energenie
lamp = Energenie(1)
QUERY_URL='https://www.govtrack.us/api/v2/role?current=true&role_type=president'