Skip to content

Instantly share code, notes, and snippets.

View waveform80's full-sized avatar

Dave Jones waveform80

View GitHub Profile
@waveform80
waveform80 / README.rst
Created October 16, 2018 22:07
opencv-python piwheels build scripts

opencv-python build scripts

This is all extremely hacky so you'll probably need to play around with it to get it working. On a fresh Raspbian Jessie or Raspbian Stretch install, add all the build-deps we usually have on a piwheels build slave (see https://github.com/bennuttall/piwheels/blob/master/deploy_slave.sh and install all the -dev stuff and python libs, basically). Next, add a 1Gb swap file.

In the default "pi" user, make a "packaging" directory and stuff opencv-python-build and opencv-setup.py under there. Make opencv-python-build executable and edit the for-loops

#!/usr/bin/python3
import pygame
from picamera import PiCamera
from pygame.locals import *
from sense_hat import SenseHat
from time import sleep
import sys
sys.path.append("..")
from mcp_utils import McpUtils
from norad import get_tle
import re
from turtle import *
compass = {'r': 'd', 'd': 'l', 'l': 'u', 'u': 'r'}
angle = lambda a, b, r=0: r if a == b else angle(compass[a], b, r + 90)
letters = {
'H': 'u50d25r25u25d50',
'd': 'u25r25u25d50l25R25',
'e': 'u25r25d12l25D13r25',
'l': 'u50D50',
import re
from turtle import *
compass = {'r': 'd', 'd': 'l', 'l': 'u', 'u': 'r'}
angle = lambda a, b, r=0: r if a == b else angle(compass[a], b, r + 90)
cmds = (
'd50u25r25u25d50R35l25u25r25d12l25R35D13u50R10d50R10u25r25d25l25R55'
'U50d50r15u25d25r15u50R10D25d25r25u25l25R35d25u25r25R10U25d50R35U25l25d25r25u50'
)
p = re.split(r'(\d+)', cmds)
@waveform80
waveform80 / Blueberry-Muffins.rst
Last active March 5, 2018 18:17
Blueberry Muffins

Blueberry Muffins

Makes 12

Ingredients

@waveform80
waveform80 / README.md
Created March 2, 2018 18:13
A quick hack to see if it's feasible to detect shadowed modules on import

Shadow.py

This is a rough'n'ready experiment to see if it's feasible to detect shadowed modules on import. A shadowed module is one where a user has inadvertently named a module the same as a module on the standard search path (a common example in education is "turtle.py" and my own unfortunately named "picamera.py" :).

If this module is imported, it tweaks the standard import machinery to check for such shadowing the first time a module is imported. If it finds any, it raises ShadowWarning (which descends from ImportWarning) giving the path of the imported module, and the path of the first module

# WARNING: This probably won't work with current versions of the
# mmalobj layer; it was made while the layer was still being
# developed.
import io
import curses
import datetime as dt
from picamera import array, mmal, mmalobj as mo, PiCameraMMALError
from threading import Thread, Lock
from PIL import Image, ImageDraw, ImageFont
@waveform80
waveform80 / astro_cam.py
Created June 16, 2017 16:42
Faster astro-cam demo
from picamera import PiCamera
from sense_hat import SenseHat
from PIL import Image
from signal import pause
class DisplayOutput():
def __init__(self):
self.hat = SenseHat()
def write(self, buf):
@waveform80
waveform80 / README.md
Last active August 3, 2020 21:39
Extract thumbnails from images captured by picamera.

Relies upon PIL to parse the initial JPEG structure and then does its own TIFF/Exif parsing because PIL's isn't up to dealing with the "full" Exif structure; looks like it gives up after IFD0.

Only tested with the V1 camera module, but I expect it'll work with either model. There's lots of stuff in here which isn't as efficient as it could be and a fair bit of cruft, but it's only a demo :)

@waveform80
waveform80 / 1.md
Last active December 7, 2016 15:18 — forked from bennuttall/gpiozero.md
Multi-paradigm programming with GPIO Zero

Multi-paradigm programming with GPIO Zero

Like Python itself, GPIO Zero is an API with multiple programming paradigms. Users can begin with a simple approach, and have the opportunity to expand into using more advanced techniques to achieve more.