Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View sandyjmacdonald's full-sized avatar

Sandy Macdonald sandyjmacdonald

  • York, UK
View GitHub Profile
@sandyjmacdonald
sandyjmacdonald / rgb-compass.py
Created March 28, 2019 20:37
RGB compass for the Pimoroni Breakout Garden, LSM303D, and RGB matrix
#!/usr/bin/env python
import time
import math
import colorsys
from lsm303d import LSM303D
from rgbmatrix5x5 import RGBMatrix5x5
def raw_heading(minimums, maximums, zero=0):
"""Return a raw compass heading calculated from the magnetometer data."""
@sandyjmacdonald
sandyjmacdonald / bearables.py
Last active November 19, 2017 22:17
Bearables Python library
#!/usr/bin/env python
import time
from smbus import SMBus
from threading import Thread
import atexit
_bus = None
_t_poll = None
_running = False
@sandyjmacdonald
sandyjmacdonald / twitter-mood-light.py
Created March 12, 2017 18:59
Turn your Pimoroni Unicorn pHAT or Mood Light Kit into a Twitter-connected mood light that tracks the mood of your most recent tweets.
## This script will turn your Unicorn pHAT or Mood Light Kit into
## a Twitter-connected mood light that tracks the mood of your most
## recent tweets.
## You'll need to install the unicornhat, textblob, and tweepy Python
## libraries, and run "python -m textblob.download_corpora" to download
## the corpora for textblob the first time you run it.
## Change the start_hue and end_hue values to use a different portion of
## the colour wheel. Change num_tweets to track a larger number of recent
@sandyjmacdonald
sandyjmacdonald / trig.py
Last active October 8, 2018 21:11
Displays a series of trigonometric patterns on the Pimoroni Unicorn HAT
#!/usr/bin/env python
import unicornhat as unicorn
import time, colorsys
import math
unicorn.brightness(0.5)
def compute_z(x, y, t, pattern):
x = x + t
@sandyjmacdonald
sandyjmacdonald / skywriter_palette.py
Created January 4, 2015 20:25
Use the Pimoroni Unicorn HAT and Skywriter as a colour palette
#!/usr/bin/env python
import unicornhat as unicorn
import time, colorsys
import skywriter
import signal
unicorn.brightness(0.4)
unicorn.rotation(270)
@sandyjmacdonald
sandyjmacdonald / unicorn_skywriter.py
Last active December 17, 2019 10:31
Control the Pimoroni Unicorn HAT with the Skywriter
#!/usr/bin/env python
import unicornhat as unicorn
import time, colorsys
import numpy as np
import random
import skywriter
import signal
unicorn.brightness(0.4)
@sandyjmacdonald
sandyjmacdonald / barcode.py
Created April 10, 2012 14:29
Short Python program to create movie barcodes.
#!/usr/bin/env python
# Takes a bunch of screenshots from a movie and converts them into a movie barcode.
# You need to capture the screenshots with the command line version of VLC, which should in OS X,
# Windows and Linux (I think). The command (in a terminal) to do this is:
# vlc /path/to/movie/file --video-filter=scene --scene-prefix=movie --scene-ratio=90 --scene-path=/path/to/folder/to/store/images/
# Note that it plays the movie in real time, so it takes a while.
# You might need to create an alias to vlc with: alias vlc='/Applications/VLC.app/Contents/MacOS/VLC'