Skip to content

Instantly share code, notes, and snippets.

View blindman2k's full-sized avatar

Aron Steg blindman2k

  • Launch Systems Pty Ltd
  • Melbourne, Australia
View GitHub Profile
@blindman2k
blindman2k / MAX3421E.device.nut
Created July 2, 2014 20:31
First attempt at a driver for the MAX3421E USB Host
// -----------------------------------------------------------------------------
// USB Host Shield pinouts
//
// 1- CS (not sure if it's active high/low)
// 2- MISO
// 5- SCLK
// 7- MOSI
// 8- RESET (also not sure about active high/low)
// 9- Interrupt (not sure if this is useful for anything)
@blindman2k
blindman2k / DA14580.agent.nut
Created July 1, 2014 22:42
Dialog DA14580 programmer. Upload a HEX file and it programs the DA14580.
server.log("Agent started, URL is " + http.agenturl());
//------------------------------------------------------------------------------------------------------------------------------
program <- null;
html <- @"<HTML>
<BODY>
<form method='POST' enctype='multipart/form-data'>
@blindman2k
blindman2k / generate_token.html
Last active August 29, 2015 14:02
These files are to support the blog post on Firebase security at https://community.electricimp.com/blog/firebase-security/
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Create or test Firebase tokens - by katowulf</title>
<script type="text/javascript" src="https:////cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script type="text/javascript" src="https://static.firebase.com/v0/firebase.js"></script>
<script type="text/javascript" src="https://cdn.firebase.com/v0/firebase-token-generator.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.4.0/moment.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Base64/0.2.0/base64.min.js"></script>
@blindman2k
blindman2k / newblank.agent.nut
Last active August 29, 2015 14:02
This New Blank model is designed to allow simple HTTP GET commands to read and write the imp and its pins.
/*
* These are the currently supported commands (URLs)
*
* /device/hardware/pinX/configure (DIGITAL_OUT, DIGITAL_IN, ANALOG_OUT, ANALOG_IN, PWM_OUT)
* /device/hardware/pinX/read
* /device/hardware/pinX/write
*
* /device/hardware/X (all hardware.* commands like lightlevel, voltage, etc)
*
* /device/imp/X (all imp.* commands that take no parameters like getssid, rssi, etc)
// -----------------------------------------------------------------------------
class Rocky
{
_handlers = null;
_timeout = 10;
// --------------------[ PUBLIC FUNCTIONS ]---------------------------------
// .........................................................................
@blindman2k
blindman2k / override.nut
Last active August 29, 2015 14:01
Overriding imp's built-in objects can be fun :)
// This is a really simple, reusable wrapper for any internal object to turn it into a class.
// For memory and performance reasons, the built-in classes are not real classes so can't
// be extended in the normal way.
class impWrapper {
_wrapped = null;
constructor(wrapped) {
_wrapped = wrapped;
}
@blindman2k
blindman2k / vformat.nut
Last active August 29, 2015 14:01
vformat gives you the same functionality is format() but allows you to pass in parameters as an arbitrary length array.
function vformat(fmt,...) {
local args = [this,fmt];
if (typeof(vargv[0]) == "array") {
vargv = vargv[0];
}
args.extend(vargv);
return format.acall(args);
}
// ----------------------[ Example use ]----------------------
@blindman2k
blindman2k / agent.nut
Created May 16, 2014 00:18
DA14580 boot code
server.log("Agent started, URL is " + http.agenturl());
//------------------------------------------------------------------------------------------------------------------------------
program <- null;
html <- @"<HTML>
<BODY>
<form method='POST' enctype='multipart/form-data'>
@blindman2k
blindman2k / neo_neopixel.device.nut
Created May 14, 2014 17:42
This is a new Neopixel class designed specifically for rectangular X/Y coordinate systems but still works fine for linear strips. Note the function names have changed.
class NeoPixels {
// when instantiated, the neopixel class will fill this array with blobs to
// represent the waveforms to send the numbers 0 to 255. This allows the blobs to be
// copied in directly, instead of being built for each pixel - which makes the class faster.
bits = null;
// Like bits, this blob holds the waveform to send the color [0,0,0], to clear pixels faster
clearblob = null;
@blindman2k
blindman2k / test_scanwifinetworks.device.nut
Created May 9, 2014 21:44
Uses an impeeduino to test the imp.scanwifinetworks() while in offline mode.
// Pin 2 is the red LED
ACTIVITY <- hardware.pin2;
ACTIVITY.configure(DIGITAL_OUT);
ACTIVITY.write(1);
// Pin 8 is the orange LED
LINK <- hardware.pin8;
LINK.configure(DIGITAL_OUT);
LINK.write(1);