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 Timer { | |
static version = "1.0.0"; | |
/* | |
* Private Properties | |
*/ | |
_repeat = true; | |
_period = 0; | |
_timer = 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
// Get GSV (satellites in view) NMEA sentences from modem | |
// NOTE #1 See https://gpsd.gitlab.io/gpsd/NMEA.html#_nmea_standard_sentences | |
// for sentence details | |
// NOTE #2 Assumes you have an existing configured and enabled gnss-session | |
// instance, as per https://developer.electricimp.com/api/gnss-session/enable | |
// Callback to process read sentences | |
function processSentences(result) { | |
if (result.status == 0) { | |
// No error, so just output each received sentence, |
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
// Hold a reference to the GNSS Session object | |
gnssSession <- null; | |
// Store device location | |
location <- { "lat": 0, "lon": 0 }; | |
function isGnssEnabled() { | |
// Is GNSS ready to use? | |
if (gnssSession == null) return false; | |
try { |
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
/* | |
* Demonstrate pulse counting using an imp UART | |
* | |
* This code uses the falling edge of the input signal to trigger a UART receive. | |
* A framing error will be generated, but we ignore this - and the data - | |
* and just use the event information. | |
* | |
* Copyright 2020, Twilio. | |
* | |
*/ |
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
/* | |
* Load the libraries that we need: | |
* Rocky to serve the API, | |
* MessageManager to handle the agent-device interaction | |
*/ | |
#require "Rocky.agent.lib.nut:3.0.0" | |
#require "MessageManager.lib.nut:2.4.0" | |
/* | |
* Instantiate instances of Rocky and MessageManager |
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 Wake Pin example code | |
* | |
* Requires any imp (but not relevant to imp005) | |
* | |
* Copyright 2020 Twilio | |
* License: MIT | |
* | |
*/ |
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
// Register an handler to deal with incoming 'trigger' | |
// messsages from the device -- it just logs the event | |
device.on("trigger", function(isCut) { | |
if (isCut) server.log("Beam cut"); | |
}); |
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
// IMPORTS | |
// Get the temperature sensor library | |
#require "HTS221.device.lib.nut:2.0.2" | |
// CLASSES | |
// The following driver class and enum provides support | |
// for the TM1637 display chip | |
enum TM1637_LED_CLASS { | |
ADDR_AUTO = 0x40, | |
CMD_SET_ADDR = 0xC0, |
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
// Simple Remote Monitoring Application Agent Code | |
// --------------------------------------------------- | |
// CLOUD SERVICE LIBRARY | |
// --------------------------------------------------- | |
// Libraries must be required before all other code | |
// Initial State Library | |
#require "InitialState.class.nut:1.0.0" | |
#require "IBMWatson.class.nut:1.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
// APPLICATION LIBRARIES | |
// Include the temperature/humidity sensor Library | |
#require "HTS221.device.lib.nut:2.0.2" | |
// APPLICATION CONSTANTS | |
// The I2C address for the sensor | |
const I2C_ADDR = 0xBE; | |
// APPLICATION GLOBALS | |
// Set up the imp I2C bus the sensor is connected to |
NewerOlder