Add Gamma flag and Brightness control to node-red-node-pi-neopixel (#431)

This commit is contained in:
cymplecy
2018-04-14 23:17:12 +01:00
committed by Dave Conway-Jones
parent 025f97206f
commit 0f55fc160e
4 changed files with 63 additions and 18 deletions

24
hardware/neopixel/neopixel.html Normal file → Executable file
View File

@@ -31,6 +31,16 @@
<option value="grb">GRB</option>
</select>
</div>
<div class="form-row">
<label for="node-input-brightness"><i class="fa fa-sun-o"></i> Brightness</label>
<input type="text" id="node-input-brightness" placeholder="number" style="width:60px;"> &nbsp;(0-100)
</div>
<div class="form-row">
<label for="node-input-gamma"> </label>
<label for="node-input-gamma" style="width:70%">
<input type="checkbox" id="node-input-gamma" style="display:inline-block; width:22px; vertical-align:baseline;"> Apply gamma correction
</label>
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
@@ -53,6 +63,8 @@
<!-- <p>The whole strip is set by <code>msg.payload</code> with a CSV string <i>r,g,b</i> -->
<p>A range of pixels from <i>x</i> to <i>y</i> can be set by <code>msg.payload</code>
with a CSV string <i>x,y,r,g,b</i>
<p>By default, gamma correction is enabled but it can disabled which can be useful for working with low brightness levels</p>
<p><code>msg.brightness</code> can be used to dynamically set brightness level</p>
<p>The pixels data line should be connected to Pi physical pin 12 - GPIO 18. <i>Note:</i>
this may conflict with audio playback.</p>
<p align="right"><a href="http://flows.nodered.org/node/node-red-node-pi-neopixel#usage">More info&nbsp;&nbsp;</a></p>
@@ -69,7 +81,9 @@
fgnd: { value:"" },
wipe: { value:"40", required:true, validate:RED.validators.number() },
mode: { value:"pcent" },
rgb: { value:"rgb" }
rgb: { value:"rgb" },
brightness: { value:"100", required:true, validate:RED.validators.number() },
gamma: { value: true }
},
inputs:1,
outputs:0,
@@ -82,6 +96,14 @@
return this.name?"node_label_italic":"";
},
oneditprepare: function() {
if (this.gamma === undefined) {
this.gamma = true;
$("#node-input-gamma").prop('checked', true);
}
if (this.brightness === undefined) {
this.brighness = "100";
$("#node-input-brightness").val("100");
}
var setstate = function () {
if ($('#node-input-mode').val().indexOf("shift") !== -1) {
$("#bgcol").hide();