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 / bmp180.device.nut
Last active August 29, 2015 14:02
Electric Imp Squirrel class for Bosch BMP180 Temperature and Pressure Sensor
class BMP180_Sensor
{
// Squirrel Class for Bosch BMP180 Temperature and Pressure Sensor
// [http://www.adafruit.com/datasheets/BST-BMP180-DS000-09.pdf]
// As used on the Adafruit BMP180 breakout board
// [http://www.adafruit.com/products/1603]
// Bus: I2C
// Code by Tony Smith (@smittytone) June 2014
// Version 1.0
@smittytone
smittytone / zx81.device.nut
Created June 10, 2014 08:38
Sinclair ZX81 Character set stub for Squirrel
// Constants for the alphanumeric character set
static charset = [
[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00], // Space - Ascii 32
[0x00,0x10,0x10,0x10,0x10,0x00,0x10,0x00], // !
[0x00,0x24,0x24,0x00,0x00,0x00,0x00,0x00], // ”
[0x00,0x24,0x7E,0x24,0x24,0x7E,0x24,0x00], // #
[0x00,0x08,0x3E,0x28,0x3E,0x0A,0x3E,0x08], // $
[0x00,0x62,0x64,0x08,0x10,0x26,0x46,0x00], // %
[0x00,0x10,0x28,0x10,0x2A,0x44,0x3A,0x00], // &
@smittytone
smittytone / onewire.device.nut
Last active August 29, 2015 14:02
Electric Imp Squirrel class for handling 1-Wire devices over a UART bus
// Squirrel Class for accessing 1-Wire devices, eg.
// Maxim Integrated DS18B20 temperature sensor
// [http://www.maximintegrated.com/datasheet/index.mvp/id/2812]
// via two-wire UART. The imp does not support 1-Wire natively
// Bus: UART
// Code by Tony Smith (@smittytone) June 2014
// Version 1.0
@smittytone
smittytone / ssd1306a.device.nut
Last active July 10, 2019 16:46
Electric Imp Squirrel class for SSD1306 with alternative, proportionally spaced character set, and 128 x 32 and 128 x 64 OLED support
class SSD1306_OLED {
// Squirrel Class for Solomon SSD1306 OLED controller chip
// [http://www.adafruit.com/datasheets/SSD1306.pdf]
// As used on the Adafruit SSD1306 I2C breakout board
// [http://www.adafruit.com/products/931]
// Bus: I2C
// Code by Tony Smith (@smittytone) June 2014
// Version 1.0.1
@smittytone
smittytone / ht16k33quad.class.nut
Last active August 29, 2015 14:06
Electric Imp Squirrel Class to control Adafruit HT16K33-based 4-digit, 7-segment LED via I2C
class HT16K33QUAD
{
// Squirrel class for 0.54-inch four-digit, 14-segment LED displays driven by the HT16K33 controller
// For example: http://shop.pimoroni.com/products/quad-alphanumeric-display-0-54-digits-w-i2c-backpack
// and: http://www.adafruit.com/product/1912
// Communicates with any imp I2C bus
// Written by Tony Smith (@smittytone) August/September 2014
// Version 1.0
@smittytone
smittytone / statuslight.py
Last active January 23, 2020 20:58
Python source code for macOS task-complete notifier project
#!/usr/bin/env python
import time
import sys
import os
import Adafruit_GPIO as GPIO
import Adafruit_GPIO.FT232H as FT232H
# This class code derivaes from Adafruit's tutorial
# at https://learn.adafruit.com/adafruit-ft232h-breakout
@smittytone
smittytone / max7219pro.device.lib.nut
Created January 23, 2020 21:03
Squirrel class for 8x8 LED matrix displays driven by the MAX7219 controller
enum MAX7219_REGISTER {
BCD = 0x09,
BRIGHT = 0x0A,
SCAN = 0x0B,
PWR_MODE = 0x0C,
TEST_MODE = 0x0F
}
enum MAX7219_STATE {
HI = 1,
@smittytone
smittytone / mcp9808.device.lib.nut
Created January 23, 2020 21:06
Squirrel class for MCP9808 temperature sensor (I2C)
// MCP9808 'constants'
const MCP9808_REG_CONFIG = 0x01;
const MCP9808_REG_UPPER_TEMP = 0x02;
const MCP9808_REG_LOWER_TEMP = 0x03;
const MCP9808_REG_CRIT_TEMP = 0x04;
const MCP9808_REG_TEMP = 0x05;
const MCP9808_REG_MANUF_ID = 0x06;
const MCP9808_REG_DEVICE_ID = 0x07;
const MCP9808_REG_RESOLUTION = 0x08;
@smittytone
smittytone / tm1637.device.lib.nut
Created January 23, 2020 21:08
Squirrel driver for Grove TM1637 segment LED display
const GROVE_TM1637_HIGH = 1;
const GROVE_TM1637_LOW = 0;
const GROVE_TM1637_ADDR_AUTO = 0x40;
const GROVE_TM1637_ADDR_FIXED = 0x44;
const GROVE_TM1637_DATA_CMD = 0xC0;
const GROVE_TM1637_DISPLAY_CMD = 0x88;
class GroveTM1637 {
// 'Private' properties
@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";