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 / 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'
@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 / 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 / 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 / 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 / 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 / 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 / pirate-audio-google-music-support.md
Last active September 19, 2021 23:45
Pirate Audio Google Music Support
  1. Clone the Pirate Audio GitHub repo and install:
git clone https://github.com/pimoroni/pirate-audio
cd pirate-audio/mopidy
sudo ./install.sh

Detailed Pirate Audio installation instructions can be found here.

@sandyjmacdonald
sandyjmacdonald / install.sh
Created February 5, 2020 11:12
Temporary Pimoroni Pirate Audio installer fix
#!/bin/bash
DATESTAMP=`date "+%Y-%m-%d-%H-%M-%S"`
MOPIDY_CONFIG="/etc/mopidy/mopidy.conf"
MOPIDY_SUDOERS="/etc/sudoers.d/010_mopidy-nopasswd"
EXISTING_CONFIG=false
PYTHON_MAJOR_VERSION=3
PIP_BIN=pip3
function add_to_config_text {
@sandyjmacdonald
sandyjmacdonald / usb-midi-cc-controller.ino
Created October 2, 2020 18:53
USB MIDI CC controller with Adafruit Trinket M0 and Pimoroni Potentiometer Breakout.
// USB MIDI CC controller with Trinket M0 and Pimoroni Potentiometer Breakout.
// Adapted from Chris Parrot's Potentiometer example.
#include <IOExpander.h>
#include <Adafruit_DotStar.h>
#include <MIDIUSB.h>
// Global constants
static const unsigned int DELAY_MS = 1000 / 30;