1
0
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:
Nick O'Leary 2016-03-04 22:23:43 +00:00
parent f4971aff69
commit 9301ab6c97
5 changed files with 22 additions and 3 deletions

View File

@ -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.color` - the colour of the text, default: `white`
- `msg.background` - the colour of the background, default: `off` - `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` - `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).

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-pi-sense-hat", "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", "description" : "A Node-RED node to interact with a Raspberry Pi Sense HAT",
"repository" : { "repository" : {
"type":"git", "type":"git",

View File

@ -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.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> <li><code>msg.speed</code> - the scroll speed. A value in the range 1 (slower) to 5 (faster), default: <code>3</code></li>
</ul> </ul>
<p><b>Set the screen brightness</b></p>
<p>Format: <code>D&lt;level&gt;</code></p>
<p><code>level</code> must be 0 (low) or 1 (high).</p>
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
RED.nodes.registerType('rpi-sensehat in',{ RED.nodes.registerType('rpi-sensehat in',{

View File

@ -232,8 +232,8 @@ module.exports = function(RED) {
HAT.close(this,done); HAT.close(this,done);
}); });
var handleTextMessage = function(line,msg) { var handleTextMessage = function(line,msg) {
var textCol = colours.getRGB(msg.color||msg.colour); var textCol = colours.getRGB(msg.color||msg.colour)||"255,255,255";
var backCol = colours.getRGB(msg.background); var backCol = colours.getRGB(msg.background)||"0,0,0";
var speed = null; var speed = null;
if (!isNaN(msg.speed)) { if (!isNaN(msg.speed)) {
speed = msg.speed; speed = msg.speed;
@ -245,6 +245,7 @@ module.exports = function(RED) {
command += ","+backCol; command += ","+backCol;
} }
} }
if (speed) { if (speed) {
var s = parseInt(speed); var s = parseInt(speed);
if (s >= 1 && s <= 5) { if (s >= 1 && s <= 5) {
@ -325,6 +326,8 @@ module.exports = function(RED) {
command = line.toUpperCase(); command = line.toUpperCase();
} else if (/^F(H|V)$/i.test(line)) { } else if (/^F(H|V)$/i.test(line)) {
command = line.toUpperCase(); command = line.toUpperCase();
} else if (/^D(0|1)$/i.test(line)) {
command = line.toUpperCase();
} else { } else {
command = handleTextMessage(line,msg); command = handleTextMessage(line,msg);
} }

View File

@ -21,6 +21,7 @@
# F[H|V] - flip horizontal|vertical # F[H|V] - flip horizontal|vertical
# X[0|1] - high frequency reporting (accel/gyro/orientation/compass) off|on # X[0|1] - high frequency reporting (accel/gyro/orientation/compass) off|on
# Y[0|1] - low frequency reporting (temperature/humidity/pressure) off|on # Y[0|1] - low frequency reporting (temperature/humidity/pressure) off|on
# D[0|1] - Set light level low|high
# #
# Outputs: # Outputs:
# Xaccel.x,y,z,gyro.x,y,z,orientation.roll,pitch,yaw,compass # Xaccel.x,y,z,gyro.x,y,z,orientation.roll,pitch,yaw,compass
@ -126,6 +127,11 @@ def process_command(data):
lf_enabled = False lf_enabled = False
else: else:
lf_enabled = True lf_enabled = True
elif data[0] == "D":
if data[1] == '0':
SH.low_light = True
else:
SH.low_light = False
else: else:
if threading.activeCount() == 2: if threading.activeCount() == 2:
scroll.interrupt() scroll.interrupt()