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 / github-graph-api.py
Last active December 20, 2022 23:11
Display a GitHub user commit graph on the Pimoroni Galactic Unicorn LED matrix
# Pop this on another machine, and run with:
# python3 github-graph-api.py --host 0.0.0.0
#
# Take note of this machine's IP address, as you'll
# need to add it in the GU code.
import requests
from bs4 import BeautifulSoup, SoupStrainer
from flask import Flask, jsonify, make_response
@sandyjmacdonald
sandyjmacdonald / WIFI_CONFIG.py
Last active July 3, 2022 10:40
An example of simple API to set the colour of the Pimoroni Inventor 2040's LEDs
SSID = ""
PSK = ""
@sandyjmacdonald
sandyjmacdonald / code.py
Last active November 9, 2024 16:42
CircuitPython USB MIDI to serial MIDI converter for Raspberry Pi Pico (RP2040)
# CircuitPython USB MIDI to serial MIDI converter for Raspberry Pi Pico (RP2040).
# IMPORTANT! Should *only be used for MIDI in*, i.e. from USB devices to hardware
# MIDI synths, and *not* in the opposite direction. Doing so could risk damage to
# the microcontroller, your computer, or both.
# Wire a 10Ω resistor from the Tx pin on the Raspberry Pi Pico or other
# RP2040 board to the 3.5mm stereo jack tip, a 33Ω resistor from the 3v3 pin on
# the Raspberry Pi Pico to the 3.5mm stereo jack ring, and the ground pin on the
# Raspberry Pi Pico to the 3.5mm stereo jack sleeve.
@sandyjmacdonald
sandyjmacdonald / code.py
Created May 1, 2021 13:23
MIDI input example for the Pimoroni Tiny 2040 board
# This example lights the RGB LED on Tiny 2040 to a different colour
# for each note in the octave. Listens on all MIDI channels by default.
import board
import adafruit_rgbled
import usb_midi
import adafruit_midi
from adafruit_midi.note_on import NoteOn
@sandyjmacdonald
sandyjmacdonald / code.py
Last active May 26, 2023 12:46
MIDI CC knob controller example for Raspberry Pi Pico
import time
import board
import usb_midi
import adafruit_midi
from analogio import AnalogIn
from adafruit_midi.control_change import ControlChange
# MIDI CC knob controller example for Raspberry Pi Pico
@sandyjmacdonald
sandyjmacdonald / code.py
Created January 23, 2021 11:23
Emergency cat GIF macro example for Pimoroni RGB Keypad for Raspberry Pi Pico
import time
import board
import busio
import usb_hid
from adafruit_bus_device.i2c_device import I2CDevice
import adafruit_dotstar
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
@sandyjmacdonald
sandyjmacdonald / code.py
Created January 21, 2021 22:27
RGB MIDI controller example for Pimoroni RGB Keypad for Raspberry Pi Pico
import time
import board
import busio
import usb_midi
import adafruit_midi
from adafruit_midi.note_off import NoteOff
from adafruit_midi.note_on import NoteOn
from adafruit_bus_device.i2c_device import I2CDevice
import adafruit_dotstar
@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;
@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 / 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.