Skip to content

Instantly share code, notes, and snippets.

View ersatzavian's full-sized avatar

Tom Buttner ersatzavian

View GitHub Profile
@ersatzavian
ersatzavian / wd_blink.ino
Created August 10, 2017 06:07
Quick-and-dirty SoftPWM Blink for a Meb Project
@ersatzavian
ersatzavian / imp002-evb-factory.nut
Created April 25, 2017 17:58
imp002 EVB Test Firmware
#require "FactoryTools.device.nut:1.0.0"
#require "TMP1x2.class.nut:1.0.3"
#require "WS2812.class.nut:2.0.1"
#require "LIS3DH.class.nut:1.0.2"
// Copyright (c) 2015 Electric Imp
// This file is licensed under the MIT License
// http://opensource.org/licenses/MIT
const SSID = "SSID";
@ersatzavian
ersatzavian / irtail_blinkup_fixture.device.nut
Created April 25, 2017 17:02
Using an Electric Imp IR Tail as a BlinkUp fixture
// IR Tail Factory BlinkUp Fixture sample firmware
const SSID = "SSID";
const PASSWORD = "PASSWORD";
const BLINKUP_TIME = 5; // seconds; duration of blinkup
function log(msg) {
if (server.isconnected()) {
server.log(msg);
@ersatzavian
ersatzavian / factory-fixture.device.nut
Created November 5, 2015 23:16
Electric Imp Factory Firmware Example
// Load in the Electric Imp Factory Tools library
#require "FactoryTools.device.nut:1.0.0"
// CONSTS AND GLOBALS ---------------------------------------------------------
// Replace the following two strings with your factory network’s credentials
const SSID = "YOUR_FACTORY_SSID";
const PASSWORD = "YOUR_FACTORY_WIFI_PASSWORD";
const BLINKUP_INTERVAL_SECONDS = 10;
@ersatzavian
ersatzavian / factory-blinkup-box.device.nut
Created November 5, 2015 23:14
Electric Imp Factory BlinkUp Box simple example
// Copyright (c) 2015 Electric Imp
// This file is licensed under the MIT License
// http://opensource.org/licenses/MIT
// Factory Tools Library simplifies detecting Fixture or DUT
#require "FactoryTools.device.nut:1.0.0"
// CFAx33KL Library abstracts the LCD/Keypad used on the Factory BlinkUp Box
#require "CFAx33KL.class.nut:1.0.1"
// CONSTS AND GLOBALS ---------------------------------------------------------
@ersatzavian
ersatzavian / tweetLight.agent.nut
Last active September 24, 2015 08:07
Flash fun colors when someone tweets
// AGENT CODE
#require "twitter.class.nut:1.1.0"
const KEY = "YOUR KEY";
const API_SECRET = "YOUR API SECRET";
const TOKEN = "YOUR TOKEN";
const TOKEN_SECRET = "YOUR TOKEN SECRET";
twitter <- Twitter(KEY, API_SECRET, TOKEN, TOKEN_SECRET);
@ersatzavian
ersatzavian / lightApi.agent.nut
Last active September 9, 2015 22:30
Rocky-Based HTTP API for RGB LEDs
// AGENT CODE
#require "rocky.class.nut:1.2.2"
// instantiate the Rocky framework for our API
app <- Rocky();
// say hello if someone requests our Agent URL
app.get("/", function(context) {
context.send("Try adding a color (red, green, blue) to the path!");
// MX25L3206E SPI Flash
class spiFlash {
// 16 blocks of 64k each = 1mb
static FAT_SIZE = 65536; // 1 block reserved for FAT
static TOTAL_MEMORY = 1048576; // 1 Megabytes
static LOAD_BUFFER_SIZE = 8192; // 8kb
// spi interface
spi = null;
cs_l = null;
@ersatzavian
ersatzavian / turnsignal.agent.nut
Created April 25, 2015 21:34
Turn Signal Example Code
http.onrequest(function(req, resp) {
local state = 0;
if ("state" in req.query) {
state = req.query.state.tointeger();
}
if (req.path == "/green") {
device.send("green", state);
} else if (req.path == "/red") {
device.send("red", state);
device.on("data", function(data) {
server.log(http.jsonencode(data));
});