mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
@@ -32,7 +32,10 @@
|
||||
<script type="text/x-red" data-help-name="smooth">
|
||||
<p>A simple node to provide various functions across several previous values, including max, min, mean, high and low pass filters.</p>
|
||||
<p>Max, Min and Mean work over a specified number of previous values.</p>
|
||||
<p>The High and Low pass filters use a smoothing factor. The higher the number the more the smoothing. E.g. a value of 10 is similar to an α of 0.1. It is analagous to an RC time constant - but there is no time component to this as the time is based on events arriving.</p>
|
||||
<p>The High and Low pass filters use a smoothing factor. The higher the number the more the smoothing. E.g. a value of 10 is
|
||||
similar to an α of 0.1. It is analagous to an RC time constant - but there is no time component to this as the
|
||||
time is based on events arriving.</p>
|
||||
<p>If <code>msg.reset</code> is received (with any value), all the counters and intermediate values are reset to an initial state.</p>
|
||||
<p><b>Note:</b> This only operates on <b>numbers</b>. Anything else will try to be made into a number and rejected if that fails.</p>
|
||||
</script>
|
||||
|
||||
|
@@ -16,6 +16,13 @@ module.exports = function(RED) {
|
||||
var old = null;
|
||||
|
||||
this.on('input', function (msg) {
|
||||
if (msg.hasOwnProperty("reset")) {
|
||||
a = [];
|
||||
tot = 0;
|
||||
tot2 = 0;
|
||||
pop = 0;
|
||||
old = null;
|
||||
}
|
||||
if (msg.hasOwnProperty("payload")) {
|
||||
var n = Number(msg.payload);
|
||||
if (!isNaN(n)) {
|
||||
|
@@ -33,5 +33,7 @@ the more the smoothing. E.g. a value of 10 is similar to an α of 0.1.
|
||||
It is analogous to an RC time constant - but there is no time component to
|
||||
this as the code is based on events arriving.
|
||||
|
||||
If `msg.reset` is received (with any value), all the counters and intermediate values are reset to an initial state.
|
||||
|
||||
**Note:** This node only operates on **numbers**. Anything else will try to be
|
||||
made into a number and rejected if that fails.
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name" : "node-red-node-smooth",
|
||||
"version" : "0.0.9",
|
||||
"version" : "0.0.10",
|
||||
"description" : "A Node-RED node that provides several simple smoothing algorithms for incoming data values.",
|
||||
"dependencies" : {
|
||||
},
|
||||
|
Reference in New Issue
Block a user