From e8502519e4fb25f63a4246f900bb9a7f0c1b32be Mon Sep 17 00:00:00 2001 From: Jason Williams Date: Fri, 16 May 2025 14:53:21 -0600 Subject: [PATCH] Adding command to skip to the next image, and removing mqtt test code --- index.js | 8 +++++++- mqtt-test.js | 16 ---------------- 2 files changed, 7 insertions(+), 17 deletions(-) delete mode 100644 mqtt-test.js diff --git a/index.js b/index.js index 5aeb1c1..b78bff7 100644 --- a/index.js +++ b/index.js @@ -66,13 +66,18 @@ function displayImage(filename) { } function displayWifi() { - console.log('Displaying wifi connection information for 10 minutes') + console.log('Displaying wifi connection information for 10 minutes...') clearTimeout(ticker) frame.display_png('img/wifi.png') frame.show() ticker = setTimeout(displayAlbum, 600000) } +function skipToNext() { + clearTimeout(ticker) + displayAlbum() +} + // Subscribe to our MQTT topic... mqttclient.on('connect', () => { mqttclient.subscribe('pictureframe/command') @@ -83,6 +88,7 @@ mqttclient.on('message', (topic, message) => { message = message.toString() console.log('MQTT command received: ' + message) + if (message == 'skip') skipToNext() if (message == 'wifi') displayWifi() if (message == 'reset') { clearTimeout(ticker) diff --git a/mqtt-test.js b/mqtt-test.js deleted file mode 100644 index a6f65a5..0000000 --- a/mqtt-test.js +++ /dev/null @@ -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()) -})