Massimo преди 4 години
родител
ревизия
73de42ad7e
променени са 6 файла, в които са добавени 139 реда и са изтрити 2 реда
  1. +4
    -0
      CHANGELOG.md
  2. +13
    -0
      README.md
  3. +50
    -0
      boolean-logic-ultimate/BlinkerUltimate.html
  4. +69
    -0
      boolean-logic-ultimate/BlinkerUltimate.js
  5. Двоични данни
      img/blinker.png
  6. +3
    -2
      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.13</b><br/>
- NEW: added blinker node. Thanks to @Marco for the suggestion.</br>
</p>
<p>
<b>Version 1.0.12</b><br/>
- Boolean Logic, FilterUltimate and InvertUltimate now output the entire message input, replacing only topic and payload.</br>

+ 13
- 0
README.md Целия файл

@@ -106,6 +106,19 @@ If the input payload is true, the node will send <code>true</code> on output 1 a
If the input payload is false, the node will send nothing on output 1, and <code>false</code> on oputput 2<br />
The input message is preserved and passed to the output pin, changing only the topic and the payload. If the input message has it's own topic, it'll be preserved as well.

# BLINKER ULTIMATE

The pourpose of this node is to blink a led or something.<br />
Pass <code>msg.payload = true</code> to start blinking</br>
Pass <code>msg.payload = false</code> to stop blinking</br>

<img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/img/blinker.png' width='60%'>

<details><summary>CLICK HERE, copy and paste it into your flow</summary>
<code>
[{"id":"33d76f42.58e088","type":"BlinkerUltimate","z":"c3456bd7.8ee9d8","name":"Blinker","blinkfrequency":"500","x":260,"y":340,"wires":[["ad7488b.2a1d9f8"]]},{"id":"ac0d404f.70cc","type":"inject","z":"c3456bd7.8ee9d8","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":320,"wires":[["33d76f42.58e088"]]},{"id":"bfdc64c6.06e2d","type":"inject","z":"c3456bd7.8ee9d8","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":360,"wires":[["33d76f42.58e088"]]},{"id":"ad7488b.2a1d9f8","type":"debug","z":"c3456bd7.8ee9d8","name":"Led","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":410,"y":340,"wires":[]},{"id":"865e29f9.4d1e98","type":"comment","z":"c3456bd7.8ee9d8","name":"Blink a signalling led","info":"","x":110,"y":280,"wires":[]}]
</code>
</details>

[license-image]: https://img.shields.io/badge/license-MIT-blue.svg
[license-url]: https://github.com/Supergiovane/node-red-contrib-boolean-logic-ultimate/master/LICENSE

+ 50
- 0
boolean-logic-ultimate/BlinkerUltimate.html Целия файл

@@ -0,0 +1,50 @@
<script type="text/javascript">
RED.nodes.registerType('BlinkerUltimate',{
category: 'boolean logic ultimate',
color: '#ff8080',
defaults: {
name: {
value: "Blinker"
},
blinkfrequency: {
value: "500"
}
},
inputs:1,
outputs:1,
icon: "light.png",
label:
function() {
return (this.name||"Blinker") + " (" + this.blinkfrequency + "ms)";
},
paletteLabel: function() {
return "BlinkerUltimate";
}
});
</script>

<script type="text/x-red" data-template-name="BlinkerUltimate">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-blinkfrequency"><i class="fa fa-clock-o"></i> Blink every (in milliseconds)</label>
<input type="text" id="node-input-triggertopic" placeholder="Name">
</div>
</script>

<script type="text/x-red" data-help-name="BlinkerUltimate">
<p>
<a href="https://www.paypal.me/techtoday" target="_blank"><img src='https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square' width='30%'></a>
and
<a href="http://eepurl.com/gJm095" target="_blank">Subscribe to my channel</a> for news about my nodes.
</p>
<p>The meaning of this node is to blink a light or something else.<br/>
<p>Pass msg.payload = true to start blinking</br>
Pass msg.payload = false to stop blinking</br>
</p>
<a href="https://www.paypal.me/techtoday" target="_blank"><img src='https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square' width='30%'></a>

</script>

+ 69
- 0
boolean-logic-ultimate/BlinkerUltimate.js Целия файл

@@ -0,0 +1,69 @@
module.exports = function (RED) {
function BlinkerUltimate(config) {
RED.nodes.createNode(this, config);
this.config = config;
var node = this;
setNodeStatus({ fill: "grey", shape: "ring", text: "|| Off" });
node.tBlinker = null;// Timer Blinker
node.blinkfrequency = typeof config.blinkfrequency === "undefined" ? 500 : config.blinkfrequency;
node.curPayload = false;

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

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
setNodeStatus({ fill: "green", shape: "dot", text: "-> On" });
} else {
if (node.tBlinker !== null) clearInterval(node.tBlinker);
setNodeStatus({ fill: "red", shape: "dot", text: "|| Off" });
node.send({ payload: false });
}
}

});

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


function setNodeStatus({ fill, shape, text }) {
var dDate = new Date();
node.status({ fill: fill, shape: shape, text: text + " (" + dDate.getDate() + ", " + dDate.toLocaleTimeString() + ")" })
}


function ToBoolean(value) {
var res = false;

if (typeof value === 'boolean') {
res = value;
}
else if (typeof value === 'number' || typeof value === 'string') {
// Is it formated as a decimal number?
if (decimal.test(value)) {
var v = parseFloat(value);
res = v != 0;
}
else {
res = value.toLowerCase() === "true";
}
}

return res;
};


function handleTimer() {
node.curPayload = !node.curPayload;
node.send({ payload: node.curPayload });
}
}


RED.nodes.registerType("BlinkerUltimate", BlinkerUltimate);
}

Двоични данни
img/blinker.png Целия файл

Before After
Width: 1056  |  Height: 342  |  Size: 39KB

+ 3
- 2
package.json Целия файл

@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-boolean-logic-ultimate",
"version": "1.0.12",
"version": "1.0.13",
"description": "A set of Node-RED enhanced boolean logic, with persisten values after reboot and more",
"author": "Supergiovane (https://github.com/Supergiovane)",
"dependencies": {
@@ -23,7 +23,8 @@
"BooleanLogicUltimate": "boolean-logic-ultimate/BooleanLogicUltimate.js",
"InvertUltimate": "boolean-logic-ultimate/InvertUltimate.js",
"FilterUltimate": "boolean-logic-ultimate/FilterUltimate.js",
"InterruptFlowUltimate": "boolean-logic-ultimate/InterruptFlowUltimate.js"
"InterruptFlowUltimate": "boolean-logic-ultimate/InterruptFlowUltimate.js",
"BlinkerUltimate": "boolean-logic-ultimate/BlinkerUltimate.js"
}
}

Loading…
Отказ
Запис