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 / led_matrix_01.device.nut
Last active August 2, 2019 12:54
A Squirrel program to display characters and graphics on an 8 x 8 LED matrix connect to an Imp device.
// Matrix LED character set display by Tony Smith
// Based on code from LinkSprite:
// [http://linksprite.com/wiki/index.php5?title=LED_Matrix_Kit]
// Additional code copyright © Electric Imp, 2014
// Maxim Integrated Max7219 Datasheet:
// [http://www.maximintegrated.com/datasheet/index.mvp/id/1339]
// Set the number of available characters in the character set
const alpha_count = 95;
@smittytone
smittytone / i2c_example.agent.nut
Last active August 29, 2015 13:57
Sample code showing the use of I2C with the Electric Imp
// Print light reading trigger URL
server.log("Sensor Agent URL: " + http.agenturl());
// Define funtions
function requestHandler(request, response)
{
// Handle an incoming web request for a reading
@smittytone
smittytone / led_matrix_scroll.agent.nut
Last active August 29, 2015 13:57
Display a side-scrolling message sent over the Internet to an Imp connected to an LED matrix
// Log the URLs we need
server.log("Print message x: " + http.agenturl() + "?message=x&inv=1");
function requestHandler(request, response)
{
try
{
// check if the user sent 'print' as a query parameter
if ("inv" in request.query) device.send("ts.led.inverse", request.query.inv);
@smittytone
smittytone / zx81.ino
Last active May 24, 2020 03:56
Arduino Leonardo code for ZX81 USB Keyboard
// ZX81 USB Keyboard for Leonardo
// (c) Dave Curran
// 2013-04-27
// Modified with Function keys by Tony Smith
// 2014-02-15
#define NUM_ROWS 8
#define NUM_COLS 5
@smittytone
smittytone / one_wire_single.device.nut
Last active August 29, 2015 14:00
Electric Imp UART implementation of 1-Wire for single DS18B20 thermometer
function one_wire_reset()
{
// Configure UART for 1-Wire RESET timing
ow.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS)
ow.write(0xF0)
ow.flush()
if (ow.read() == 0xF0)
{
// UART RX will read TX if there's no device connected
@smittytone
smittytone / one_wire_multi.device.nut
Last active August 29, 2015 14:00
Electric Imp UART implementation of 1-Wire for multiple devices
function one_wire_reset()
{
// Configure UART for 1-Wire RESET timing
ow.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS)
ow.write(0xF0)
ow.flush()
if (ow.read() == 0xF0)
{
// UART RX will read TX if there's no device connected
@smittytone
smittytone / nokia_lcd.device.nut
Last active August 29, 2015 14:00
Electric Imp example code to drive a Nokia 3310/5110 84 x 48 mono LCD
// Nokia 5110 control code for the imp
// Adapted by Tony Smith from a variety of sources:
// http://playground.arduino.cc/Code/PCD8544
// http://www.microsyl.com/index.php/2010/03/24/nokia-lcd-library/
// Assign the control pins to global variables
PIN_RST <- hardware.pin9;
PIN_CE <- hardware.pin8;
PIN_DC <- hardware.pin7;
@smittytone
smittytone / spi.device.nut
Last active August 29, 2015 14:01
SPI on the Electric Imp using Analog Devices' ADXL345 accelerometer
// ADXL345 Register Values
const DEVICE_ID = 0x00; // Device ID register
const POWER_CTL = 0x2D; // Power Control register
const DATA_FORMAT = 0x31; // Data storage format register
const DATAX0 = 0x32; //X-Axis Data 0
const DATAX1 = 0x33; //X-Axis Data 1
const DATAY0 = 0x34; //Y-Axis Data 0
const DATAY1 = 0x35; //Y-Axis Data 1
const DATAZ0 = 0x36; //Z-Axis Data 0
@smittytone
smittytone / max7219.device.nut
Last active May 24, 2017 00:39
Electric Imp Squirrel class for an 8 x 8 monochrome LED matrix driven by the MAX7219
class MAX7219_Matrix
{
// Squirrel class for 8 x 8 LED matrix displays driven by the MAX7219 controller
// For example: https://www.sparkfun.com/products/11861
// Code by Tony Smith (@smittytone) May 2014
// Version 1.0
// Constants for MAX7219
@smittytone
smittytone / ssd1306.device.nut
Last active August 29, 2015 14:02
Electric Imp Squirrel class for the SSD1306 OLED controller
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.2