Skip to content

Instantly share code, notes, and snippets.

View smittytone's full-sized avatar
🕶️
In single-minded pursuit of the groove

Tony Smith smittytone

🕶️
In single-minded pursuit of the groove
View GitHub Profile
@smittytone
smittytone / dlist.sh
Created September 8, 2022 13:02
Bash shell script for macOS which detects and lists USB-connected serial devices
#!/bin/bash
# Save script as `dlist` at a location on your $PATH.
# Run `chmod +x /path/to/dlist`
#
# Connect a USB serial device, eg. a Raspberry Pi Pico, and then
# enter `dlist` at the command line.
#
# You should see something like:
# `/dev/cu.usbserial-01AB8E0B`
@smittytone
smittytone / detect.py
Created February 9, 2022 09:13
Python script to detect whether an FT232H or MCP2221 USB-to-serial adaptor is connected, for Adafruit Blinka
#!/usr/bin/env python3
# Requirements:
# pip install pyftdi
# pip install hid
# brew install hidapi
from os import environ
from pyftdi.usbtools import UsbTools
count = len(UsbTools.find_all([(0x0403, 0x6014)]))
@smittytone
smittytone / dlist.zsh
Last active September 12, 2022 18:48
Z Shell function for macOS which detects and lists USB-connected serial devices
# Add to your `.zshrc` file or use the function's contents as a script.
#
# With the former, add the function, restart your terminal, connect
# a USB serial device, eg. a Raspberry Pi Pico, and then enter `dlist`
# at the command line.
#
# You should see something like this:
# `/dev/cu.usbserial-01AB8E0B`
#
# If you have only one device attached, you can include the function's
@smittytone
smittytone / ps-convert.py
Created November 30, 2021 09:14
PicoSystem Sprite Converter
#!/usr/bin/env python3
"""
ps-convert 1.0.0
================
PicoSystem Sprite Converter
@authors Dan Malec, modified and named by Tony Smith
@copyright 2021
@smittytone
smittytone / makepico.zsh
Created September 2, 2021 19:03
Makepico, a Raspberry Pi Pico project-creation script
#!/bin/zsh
#
# makepico.zsh
#
# Create a baseline Raspberry Pi Pico C-language project
#
# @author Tony Smith
# @copyright 2021, Tony Smith
# @version 2.1.0
@smittytone
smittytone / launch.json
Last active March 26, 2022 18:30
Raspberry Pi Pico Visual Studio Code debugger launch.json file
{
"version": "0.2.0",
"configurations": [
{ "name": "Pico Debug",
"device": "RP2040",
"gdbPath": "arm-none-eabi-gdb",
"cwd": "${workspaceRoot}",
"executable": "${command:cmake.launchTargetPath}",
"request": "launch",
"type": "cortex-debug",
@smittytone
smittytone / device_monitor.py
Created January 23, 2020 22:12
Electric Imp development device status monitor: runs on Raspberry Pi with Pimoroni inkyPhat
#!/usr/bin/env python
# IMPORTS
import requests
from time import time
from threading import Timer
import inkyphat
from PIL import ImageFont
# GLOBALS
@smittytone
smittytone / cctv.py
Created January 23, 2020 22:04
Simple Raspberry Pi-based CCTV app. Requires Pi camera, Dropbox account
#!/usr/bin/python
from picamera import PiCamera
from time import sleep
from subprocess import call
import os
import sys
# CONSTANTS
KEEP_FILES = 10
@smittytone
smittytone / tsl2561.device.lib.nut
Created January 23, 2020 21:18
Squirrel driver for TSL2561 light-level sensor (I2C)
class TSL2561 {
static version = "1.0.0";
// TSL2561 register values
static TSL2561_COMMAND_BIT = "\x80"; // Command register. Bit 7 must be 1
static TSL2561_CONTROL_POWERON = "\x03"; // Power on setting
static TSL2561_CONTROL_POWEROFF = "\x00"; // Power off setting
static TSL2561_REGISTER_TIMING = "\x81"; // Access timing register
@smittytone
smittytone / hd448790.device.lib.nut
Created January 23, 2020 21:11
Squirrel driver for 16 x 2 to 20 x 4 character LCDs driven by a Hitachi HD44780 controller
class LCD {
// A Squirrel class to drive a 16 x 2 to 20 x 4 character LCD driven by a Hitachi HD44780 controller
// via an MCP23008 interface chip on an Adafruit I2C backpack [http://www.adafruit.com/product/292]
// Communicates with any imp I2C bus
// Written by Tony Smith (@smittytone) October 2014
// Version 1.1
static MCP23008_IODIR = "\x00";
static MCP23008_GPIO = "\x09";