Adding command to skip to the next image, and removing mqtt test code
This commit is contained in:
8
index.js
8
index.js
@@ -66,13 +66,18 @@ function displayImage(filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function displayWifi() {
|
function displayWifi() {
|
||||||
console.log('Displaying wifi connection information for 10 minutes')
|
console.log('Displaying wifi connection information for 10 minutes...')
|
||||||
clearTimeout(ticker)
|
clearTimeout(ticker)
|
||||||
frame.display_png('img/wifi.png')
|
frame.display_png('img/wifi.png')
|
||||||
frame.show()
|
frame.show()
|
||||||
ticker = setTimeout(displayAlbum, 600000)
|
ticker = setTimeout(displayAlbum, 600000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function skipToNext() {
|
||||||
|
clearTimeout(ticker)
|
||||||
|
displayAlbum()
|
||||||
|
}
|
||||||
|
|
||||||
// Subscribe to our MQTT topic...
|
// Subscribe to our MQTT topic...
|
||||||
mqttclient.on('connect', () => {
|
mqttclient.on('connect', () => {
|
||||||
mqttclient.subscribe('pictureframe/command')
|
mqttclient.subscribe('pictureframe/command')
|
||||||
@@ -83,6 +88,7 @@ mqttclient.on('message', (topic, message) => {
|
|||||||
message = message.toString()
|
message = message.toString()
|
||||||
console.log('MQTT command received: ' + message)
|
console.log('MQTT command received: ' + message)
|
||||||
|
|
||||||
|
if (message == 'skip') skipToNext()
|
||||||
if (message == 'wifi') displayWifi()
|
if (message == 'wifi') displayWifi()
|
||||||
if (message == 'reset') {
|
if (message == 'reset') {
|
||||||
clearTimeout(ticker)
|
clearTimeout(ticker)
|
||||||
|
|||||||
16
mqtt-test.js
16
mqtt-test.js
@@ -1,16 +0,0 @@
|
|||||||
const mqtt = require('mqtt')
|
|
||||||
const client = mqtt.connect('mqtt://mqtt.srv.jnf.me', {
|
|
||||||
clientId: 'pictureframe_' + Math.random().toString(16).substr(2, 8),
|
|
||||||
username: 'pictureframe',
|
|
||||||
password: 'pictureframe'
|
|
||||||
})
|
|
||||||
|
|
||||||
client.on('connect', () => {
|
|
||||||
client.subscribe('pictureframe/#', (err) => {
|
|
||||||
if (err) console.log(err)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
client.on('message', (topic, message) => {
|
|
||||||
console.log(topic + ' : ' + message.toString())
|
|
||||||
})
|
|
||||||
Reference in New Issue
Block a user