Skip to content

Instantly share code, notes, and snippets.

View imp-guru's full-sized avatar

imp-guru

  • Green Bay, WI
View GitHub Profile
@imp-guru
imp-guru / hex2int
Created July 29, 2014 13:08
Hex to Integer conversion for Electric Imp
// Function to convert a hexidecimal string to an integer
function hex2int(x)
{
// Sanitize the string to all upper
local hex = x.tostring().toupper();
// Create a lookup table for the hex digits, the index represents the decimal value
local hexChars = "0123456789ABCDEF";
// Initialize a variable for the return value
@imp-guru
imp-guru / const_define
Created July 29, 2014 13:01
Define constants for Electric Imp
// Integer constants
const ACTIVE = 0;
const IDLE = 1;
// Hex constants
const READ = 0x80;
const WRITE = 0x00;
const BURST = 0x40;