This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HT16K33BIG | |
{ | |
// Squirrel class for 1.2-inch four-digit, 7-segment LED displays driven by the HT16K33 controller | |
// For example: http://www.adafruit.com/products/1270 | |
// Communicates with any imp I2C bus | |
// Written by Tony Smith (@smittytone) October 2014 | |
// Version 1.0 | |
// HT16K33 registers and HT16K33-specific variables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Twitter Keys | |
const API_KEY = "YOUR API KEY" | |
const API_SECRET = "YOUR API SECRET" | |
const AUTH_TOKEN = "YOUR AUTH TOKEN" | |
const TOKEN_SECRET = "YOUR TOKEN SECRET" | |
// Twitter Access Class | |
class Twitter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WEATHER UPDATE CLASS | |
class WeatherUpdate | |
{ | |
// Simple Squirrel class for interaction with Forecast.io | |
url = "https://api.forecast.io/forecast/" | |
apikey = "YOUR API KEY HERE" | |
function forecastRequest(longitude = 52.205082, latitude = 0.130209) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set up outgoing request object as a global (we may need to cancel it, so we need a reference to it) | |
request <- http.get(webServiceURL, webServiceHeaders) | |
// Define the response handler | |
function handleResponse(responseTable) | |
{ | |
// Called when the imp receives an immediate acknowledgement from the remote service | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set up outgoing request object | |
local request = http.get(webServiceURL, webServiceHeaders) | |
// Define the response handler | |
function handleResponse(responseTable) | |
{ | |
// Called when the imp receives a response from the remote service | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define an HTTP request handler | |
function requestHandler(request, response) | |
{ | |
try | |
{ | |
if ("setting" in request.query) | |
{ | |
// 'setting' is a URL-encoded parameter, ie. '/setting=4' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set the disconnection policy | |
server.setsendtimeoutpolicy(RETURN_ON_ERROR, WAIT_TIL_SENT, 30) | |
// Define the disconnection handler function | |
function disconnectionHandler(reason) | |
{ | |
if (reason != SERVER_CONNECTED) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Agent Globals | |
locationLong <- 999 | |
locationLat <- 999 | |
dummyValue <- 0 | |
// Weather functions | |
function getForecast() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Device Globals | |
dummyValue <- 0 | |
function updateWeatherDisplay(forecast) | |
{ | |
// This function, omitted for clarity, takes the supplied | |
// forecast value and uses it to present a weather icon | |
// on the device's display |