mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Add dim command
This commit is contained in:
parent
f4971aff69
commit
9301ab6c97
@ -118,3 +118,9 @@ The following message properties can be used to customise the appearance:
|
||||
- `msg.color` - the colour of the text, default: `white`
|
||||
- `msg.background` - the colour of the background, default: `off`
|
||||
- `msg.speed` - the scroll speed. A value in the range 1 (slower) to 5 (faster), default: `3`
|
||||
|
||||
#### Set the screen brightness
|
||||
|
||||
Format: `D<level>`
|
||||
|
||||
`level` must be 0 (low) or 1 (high).
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name" : "node-red-node-pi-sense-hat",
|
||||
"version" : "0.0.5",
|
||||
"version" : "0.0.6",
|
||||
"description" : "A Node-RED node to interact with a Raspberry Pi Sense HAT",
|
||||
"repository" : {
|
||||
"type":"git",
|
||||
|
@ -130,6 +130,10 @@ To scroll a single character, append a blank space after it - <code>"A "</code>.
|
||||
<li><code>msg.background</code> - the colour of the background, default: <code>off</code></li>
|
||||
<li><code>msg.speed</code> - the scroll speed. A value in the range 1 (slower) to 5 (faster), default: <code>3</code></li>
|
||||
</ul>
|
||||
|
||||
<p><b>Set the screen brightness</b></p>
|
||||
<p>Format: <code>D<level></code></p>
|
||||
<p><code>level</code> must be 0 (low) or 1 (high).</p>
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
RED.nodes.registerType('rpi-sensehat in',{
|
||||
|
@ -232,8 +232,8 @@ module.exports = function(RED) {
|
||||
HAT.close(this,done);
|
||||
});
|
||||
var handleTextMessage = function(line,msg) {
|
||||
var textCol = colours.getRGB(msg.color||msg.colour);
|
||||
var backCol = colours.getRGB(msg.background);
|
||||
var textCol = colours.getRGB(msg.color||msg.colour)||"255,255,255";
|
||||
var backCol = colours.getRGB(msg.background)||"0,0,0";
|
||||
var speed = null;
|
||||
if (!isNaN(msg.speed)) {
|
||||
speed = msg.speed;
|
||||
@ -245,6 +245,7 @@ module.exports = function(RED) {
|
||||
command += ","+backCol;
|
||||
}
|
||||
}
|
||||
|
||||
if (speed) {
|
||||
var s = parseInt(speed);
|
||||
if (s >= 1 && s <= 5) {
|
||||
@ -325,6 +326,8 @@ module.exports = function(RED) {
|
||||
command = line.toUpperCase();
|
||||
} else if (/^F(H|V)$/i.test(line)) {
|
||||
command = line.toUpperCase();
|
||||
} else if (/^D(0|1)$/i.test(line)) {
|
||||
command = line.toUpperCase();
|
||||
} else {
|
||||
command = handleTextMessage(line,msg);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
# F[H|V] - flip horizontal|vertical
|
||||
# X[0|1] - high frequency reporting (accel/gyro/orientation/compass) off|on
|
||||
# Y[0|1] - low frequency reporting (temperature/humidity/pressure) off|on
|
||||
# D[0|1] - Set light level low|high
|
||||
#
|
||||
# Outputs:
|
||||
# Xaccel.x,y,z,gyro.x,y,z,orientation.roll,pitch,yaw,compass
|
||||
@ -126,6 +127,11 @@ def process_command(data):
|
||||
lf_enabled = False
|
||||
else:
|
||||
lf_enabled = True
|
||||
elif data[0] == "D":
|
||||
if data[1] == '0':
|
||||
SH.low_light = True
|
||||
else:
|
||||
SH.low_light = False
|
||||
else:
|
||||
if threading.activeCount() == 2:
|
||||
scroll.interrupt()
|
||||
|
Loading…
Reference in New Issue
Block a user