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 for talking to tinamous; not library quality at this point! | |
class Tinamous { | |
_account = null; | |
_device = null; | |
_password = null; | |
_clientid = null; | |
_mqttclient = null; | |
_connectcb = null; |
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
// Ensure we have a default reading | |
lastreading <- { "mass_pm1.0":0, "mass_pm2.5":0, "mass_pm4.0":0, "mass_pm10":0 }; | |
// Code to convert particlate density to AQI index | |
// based on https://gist.github.com/kfury/822bbba2cb0f946abb73baa156722ab1 | |
function Linear(AQIhigh, AQIlow, Conchigh, Conclow, Conc) { | |
local a=((Conc-Conclow)/(Conchigh-Conclow))*(AQIhigh-AQIlow)+AQIlow; | |
return math.floor(a+0.5); | |
} |
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
// Ensure we have a default reading | |
lastreading <- { "pm10":0, "pm25":0, "pm100":0 }; | |
// Code to convert particlate density to AQI index | |
// based on https://gist.github.com/kfury/822bbba2cb0f946abb73baa156722ab1 | |
function Linear(AQIhigh, AQIlow, Conchigh, Conclow, Conc) { | |
local a=((Conc-Conclow)/(Conchigh-Conclow))*(AQIhigh-AQIlow)+AQIlow; | |
return math.floor(a+0.5); | |
} |
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
// Streaming audio player - agent side | |
// 20180909 hugo@electricimp.com | |
// ToDo: lots. Like, parsing the WAV header, transcoding in the agent, etc | |
// Summary: | |
// - device asks agent to play a URL | |
// - agent fetches AGENT_CHUNK sized blocks from the URL using range fetches | |
// - agent chops these up into DEVICE_CHUNK sized pieces and puts them in | |
// send_queue. It then refills send_queue every time it gets down to half |
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
const css = @" | |
body { | |
background: #35a8dd; | |
color: white; | |
font-family: ""Helvetica Neue"", ""Helvetica"",""sans""; | |
} | |
" | |
http.onrequest(function(req,res) { | |
if (req.path == "/camera.jpg") { |
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
// electric imp client for FIND | |
// hugo@electricimp.com 20161225 | |
const FIND_GROUP = "group"; | |
const FIND_USERNAME = "username"; | |
const FIND_LOCATION = "someplace"; | |
device.on("location", function(scan) { | |
server.log(http.jsonencode(scan)); | |