Created
January 27, 2015 15:56
-
-
Save electricimp/8df501a16ad8167bf8b4 to your computer and use it in GitHub Desktop.
Persistent Storage Example
This file contains hidden or 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
function sendPrefs(value) | |
{ | |
// Clock has requested the current set-up data | |
device.send("clock.set.prefs", clockPrefs) | |
} | |
. . . | |
// Register device-sent request for settings | |
device.on("clock.get.prefs", sendPrefs) |
This file contains hidden or 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
function setPrefs(prefsTable) | |
{ | |
// Parse the set-up data table provided by the agent | |
hr24_flag = prefsTable.hr24mode | |
bst_flag = prefsTable.dst | |
utc_flag = prefsTable.utc | |
utc_offset = prefsTable.utcOffset | |
led_brightness = prefsTable.brightness | |
} | |
. . . | |
// Register callback for incoming settings data | |
agent.on("clock.set.prefs", setPrefs) | |
// Issue a request for settings | |
agent.send("clock.get.prefs", 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment