Переглянути джерело

BlinkerUltimate: if you set the interval while the blinker is running, yet the new interval is applied immediately.

master
Massimo 4 роки тому
джерело
коміт
9cb5f56b32
3 змінених файлів з 23 додано та 10 видалено
  1. +4
    -0
      CHANGELOG.md
  2. +18
    -9
      boolean-logic-ultimate/BlinkerUltimate.js
  3. +1
    -1
      package.json

+ 4
- 0
CHANGELOG.md Переглянути файл

@@ -3,6 +3,10 @@

<a href="http://eepurl.com/gJm095" target="_blank">Subscribe to my channel.</a> Only news about my nodes, no spam, no ads. I'm a github developer, not a merchant.

<p>
<b>Version 1.0.16</b>May 2020<br/>
- BlinkerUltimate: if you set the interval while the blinker is running, yet the new interval is applied immediately.</br>
</p>
<p>
<b>Version 1.0.15</b>May 2020<br/>
- Adjusted status of Boolean Logic ultimate. Replaced the text "null", with --- for better understanding.</br>

+ 18
- 9
boolean-logic-ultimate/BlinkerUltimate.js Переглянути файл

@@ -7,35 +7,44 @@ module.exports = function (RED) {
node.tBlinker = null;// Timer Blinker
node.blinkfrequency = typeof config.blinkfrequency === "undefined" ? 500 : config.blinkfrequency;
node.curPayload = false;
node.isBlinking = false; // Is the timer running?

node.on('input', function (msg) {

if (msg.hasOwnProperty("interval")) {
try {
node.blinkfrequency = msg.interval;
if (node.isBlinking) // 29/05/2020 If was blinking, restart the timer with the new interval
{
if (node.tBlinker !== null) clearInterval(node.tBlinker);
node.tBlinker = setInterval(handleTimer, node.blinkfrequency); // Start the timer that handles the queue of telegrams
}
} catch (error) {
node.blinkfrequency = 500;
setNodeStatus({ fill: "red", shape: "dot", text: "Invalid interval received" });
}
}
if (msg.hasOwnProperty("payload")) {
// 06/11/2019
if (ToBoolean(msg.payload) === true) {
if (node.tBlinker !== null) clearInterval(node.tBlinker);
node.tBlinker = setInterval(handleTimer, node.blinkfrequency); // Start the timer that handles the queue of telegrams
node.isBlinking = true;
setNodeStatus({ fill: "green", shape: "dot", text: "-> On" });
} else {
if (node.tBlinker !== null) clearInterval(node.tBlinker);
node.isBlinking = false;
setNodeStatus({ fill: "red", shape: "dot", text: "|| Off" });
node.send({ payload: false });
node.curPayload = false;
}
}
if (msg.hasOwnProperty("interval")) {
try {
node.blinkfrequency = msg.interval;
} catch (error) {
node.blinkfrequency = 500;
setNodeStatus({ fill: "red", shape: "dot", text: "Invalid interval received" });
}
}
});

node.on('close', function () {
if (node.tBlinker !== null) clearInterval(node.tBlinker);
node.isBlinking = false;
node.send({ payload: false });
});


+ 1
- 1
package.json Переглянути файл

@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-boolean-logic-ultimate",
"version": "1.0.15",
"version": "1.0.16",
"description": "A set of Node-RED enhanced boolean logic, with persisten values after reboot and more",
"author": "Supergiovane (https://github.com/Supergiovane)",
"dependencies": {

Завантаження…
Відмінити
Зберегти