Skip to content

Commit 406f368

Browse files
committed
Add more docs & hardware guides
1 parent ac8337e commit 406f368

12 files changed

+473
-21
lines changed

Diff for: _includes/docs-toc.html

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
<li><a href="/docs/index.html" {% if page.url == "/docs/index.html" %}class="active"{% endif %}><i class="icon icon-caret-right"></i> Documentation</a></li>
2-
<li><a href="/docs/getting-started.html" {% if page.url == "/docs/getting-started.html" %}class="active"{% endif %}><i class="icon icon-caret-right"></i> Getting Started</a></li>
3-
<li><a href="/docs/configuration.html" {% if page.url == "/docs/configuration.html" %}class="active"{% endif %}><i class="icon icon-caret-right"></i> Configuration</a></li>
4-
<li><a href="/docs/writing-functions.html" {% if page.url == "/docs/writing-functions.html" %}class="active"{% endif %}><i class="icon icon-caret-right"></i> Writing Functions</a></li>
5-
<li><a href="/docs/creating-nodes.html" {% if page.url == "/docs/creating-nodes.html" %}class="active"{% endif %}><i class="icon icon-caret-right"></i> Creating Nodes</a></li>
1+
<li><a href="/docs/index.html" {% if page.url == "/docs/index.html" %}class="active"{% endif %}>Documentation</a></li>
2+
<li><a href="#">Getting Started</a>
3+
<ul>
4+
<li><a href="/docs/getting-started/installation.html" {% if page.url == "/docs/getting-started/installation.html" %}class="active"{% endif %}>Installation</a>
5+
<li><a href="/docs/getting-started/running.html" {% if page.url == "/docs/getting-started/running.html" %}class="active"{% endif %}>Running</a>
6+
<li><a href="/docs/getting-started/first-flow.html" {% if page.url == "/docs/getting-started/first-flow.html" %}class="active"{% endif %}>Creating your first flow</a>
7+
</ul>
8+
</li>
9+
<li><a href="/docs/configuration.html" {% if page.url == "/docs/configuration.html" %}class="active"{% endif %}>Configuration</a></li>
10+
<li><a href="/docs/writing-functions.html" {% if page.url == "/docs/writing-functions.html" %}class="active"{% endif %}>Writing Functions</a></li>
11+
<li><a href="/docs/creating-nodes.html" {% if page.url == "/docs/creating-nodes.html" %}class="active"{% endif %}>Creating Nodes</a></li>
12+
<li><a href="#">Hardware</a>
13+
<ul>
14+
<li><a href="/docs/hardware/arduino.html" {% if page.url == "/docs/hardware/arduino.html" %}class="active"{% endif %}>Arduino</a>
15+
<li><a href="/docs/hardware/raspberrypi.html" {% if page.url == "/docs/hardware/raspberrypi.html" %}class="active"{% endif %}>Raspberry Pi</a>
16+
<li><a href="/docs/hardware/beagleboneblack.html" {% if page.url == "/docs/hardware/beagleboneblack.html" %}class="active"{% endif %}>BeagleBone Black</a>
17+
</ul>
18+
</li>

Diff for: css/style.css

+20-11
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ ul.toc {
9797
padding: 0;
9898
border: 1px solid #ccc;
9999
}
100-
ul.toc li {
100+
ul.toc > li {
101101
border-bottom: 1px solid #ccc;
102102
background: #eee;
103103
}
104-
ul.toc li:last-child {
104+
ul.toc > li:last-child {
105105
border-bottom: none;
106106
}
107-
ul.toc li a {
107+
ul.toc li a {
108108
padding: 8px 10px;
109109
display: block;
110110
width: 100%;
@@ -115,17 +115,26 @@ ul.toc li a:hover {
115115
text-decoration:none;
116116
background:#ddd;
117117
}
118-
ul.toc li a.active {
118+
ul.toc > li > ul {
119+
margin: 0;
120+
padding:0;
121+
list-style-type: none;
122+
}
123+
124+
ul.toc > li > ul > li {
125+
border-top: 1px solid #dadada;
126+
}
127+
ul.toc > li > ul > li a {
128+
padding: 6px 6px 6px 30px;
129+
}
130+
131+
132+
ul.toc > li a.active {
119133
color: #fff;
120134
background: #a8a8a8; /* Old browsers */
121-
background: -moz-linear-gradient(top, #a8a8a8 0%, #676767 100%); /* FF3.6+ */
122-
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a8a8a8), color-stop(100%,#676767)); /* Chrome,Safari4+ */
123-
background: -webkit-linear-gradient(top, #a8a8a8 0%,#676767 100%); /* Chrome10+,Safari5.1+ */
124-
background: -o-linear-gradient(top, #a8a8a8 0%,#676767 100%); /* Opera 11.10+ */
125-
background: -ms-linear-gradient(top, #a8a8a8 0%,#676767 100%); /* IE10+ */
126-
background: linear-gradient(to bottom, #a8a8a8 0%,#676767 100%); /* W3C */
127-
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a8a8a8', endColorstr='#676767',GradientType=0 ); /* IE6-9 */
128135
}
136+
137+
129138
h3.pagetitle {
130139
padding-bottom: 5px;
131140
padding-right: 10px;

Diff for: docs/configuration.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
toc-index: 2
32
layout: default
43
title: Configuration
54
---

Diff for: docs/creating-nodes.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
---
2-
toc-index: 5
32
layout: default
43
title: Creating Nodes
54
---
65

7-
To be written...
6+
Each node is defined in a pair of files; a `.js` file that defines the server-side
7+
behaviour and a `.html` file that defines the node's properties, edit dialog and
8+
help text.
9+
10+

Diff for: docs/getting-started.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
toc-index: 1
32
layout: default
43
title: Getting Started
54
---

Diff for: docs/getting-started/first-flow.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
layout: default
3+
title: Creating your first flow
4+
---
5+
6+
#### 1. Add an Inject node
7+
8+
The Inject node allows you to inject messages into a flow, either by clicking
9+
the button on the node, or setting a time interval between injects.
10+
11+
Drag one onto the workspace from the palette.
12+
13+
Open the sidebar (Ctrl-Space, or via the dropdown menu) and select the Info tab.
14+
15+
Select the newly added Inject node to see information about its properties and a
16+
description of what it does.
17+
18+
#### 2. Add a Debug node
19+
20+
The Debug node causes any message to be displayed in the Debug sidebar. By
21+
default, it just displays the payload of the message, but it is possible to
22+
display the entire message object.
23+
24+
#### 3. Wire the two together
25+
26+
Connect the Inject and Debug nodes together by dragging between the output port
27+
of one to the input port of the other.
28+
29+
#### 4. Deploy
30+
31+
At this point, the nodes only exist in the editor and must be deployed to the
32+
server.
33+
34+
Click the Deploy button. Simple as that.
35+
36+
With the Debug sidebar tab selected, click the Inject button. You should see
37+
numbers appear in the sidebar. By default, the Inject node uses the number of
38+
milliseconds since January 1st, 1970 as its payload. Let's do something more
39+
useful with that.
40+
41+
#### 5. Add a Function node
42+
43+
The Function node allows you to pass each message though a JavaScript function.
44+
45+
Wire the Function node inbetween the Inject and Debug nodes. You'll need to
46+
delete the existing wire (select it and hit delete on the keyboard).
47+
48+
Double-click on the Function node to bring up the edit dialog. Copy the follow
49+
code into the function field:
50+
51+
// Create a Date object from the payload
52+
var date = new Date(msg.payload);
53+
// Change the payload to be a formated Date string
54+
msg.payload = date.toString();
55+
// Return the message so it can be sent on
56+
return msg;
57+
58+
Click Ok to close the edit dialog and then click the deploy button.
59+
60+
Now when you click the Inject button, the messages in the sidebar will be more
61+
readable time stamps.
62+
63+
***
64+
65+
#### Source
66+
67+
The flow created in this example is represented by the following json. It can be
68+
imported straight into the editor by pasting the json into the Import dialog
69+
(Ctrl-I or via the dropdown menu).
70+
71+
72+
[{"id":"58ffae9d.a7005","type":"debug","name":"","active":true,"complete":false,"x":640,"y":200,"wires":[]},{"id":"17626462.e89d9c","type":"inject","name":"","topic":"","payload":"","repeat":"","once":false,"x":240,"y":200,"wires":[["2921667d.d6de9a"]]},{"id":"2921667d.d6de9a","type":"function","name":"Format timestamp","func":"// Create a Date object from the payload\nvar date = new Date(msg.payload);\n// Change the payload to be a formated Date string\nmsg.payload = date.toString();\n// Return the message so it can be sent on\nreturn msg;","outputs":1,"x":440,"y":200,"wires":[["58ffae9d.a7005"]]}]
73+

Diff for: docs/getting-started/installation.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
layout: default
3+
title: Installation
4+
---
5+
6+
*Eventually, Node-RED will be installable using npm. Until then, the following
7+
guide will help you get started.*
8+
9+
### Install node.js
10+
11+
You can get the latest version from <http://nodejs.org/download/>.
12+
13+
Or, you may want to use a version from your operating system's package manager:
14+
<https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager>
15+
16+
### Get Node-RED
17+
18+
Clone the repository from GitHub:
19+
20+
$ git clone [email protected]:node-red/node-red.git
21+
22+
*TODO: once we have a release, point at the zip as well*
23+
24+
### Install the pre-requisite modules
25+
26+
From the top-level directory of Node-RED, run:
27+
28+
$ npm install
29+
30+
This will install the core pre-requisite modules.
31+
32+
### Installing individual node dependencies
33+
34+
*Eventually, nodes will be npm-installable themselves. This will take care of
35+
all of the dependency management. Until then, it is a bit more manual...*
36+
37+
When Node-RED starts, it attempts to load the nodes from the `nodes/` directory.
38+
Each will have its own set of dependencies that will need to be installed before
39+
the node is available in the palette.
40+
41+
To help identify the dependencies, Node-RED logs any modules it fails to find
42+
for a particular node. You don't have to install these unless you want or need
43+
that node to appear.
44+
45+
Alternatively, a node's `.js` file can be examined to identify the modules it
46+
explicitly requires. For example, the Twitter node is defined in
47+
`nodes/social/27-twitter.js` and contains:
48+
49+
var RED = require("../../red/red");
50+
var ntwitter = require('ntwitter');
51+
var OAuth= require('oauth').OAuth;
52+
53+
Of these, `ntwitter` and `oauth` are neither built-in modules nor ones provided
54+
by Node-RED itself. They can subsequently be installed by running:
55+
56+
$ npm install ntwitter oauth
57+

Diff for: docs/getting-started/running.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
layout: default
3+
title: Running
4+
---
5+
6+
From the top-level directory, run:
7+
8+
$ node red.js
9+
10+
You can then access Node-RED at <http://localhost:1880>.
11+
12+
By default, Node-RED uses a file called `flows_<hostname>.json` to save the
13+
deployed configuration. You can point to a different flow file at start-up:
14+
15+
$ node red.js my_flows.json
16+
17+
18+

Diff for: docs/hardware/arduino.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
layout: default
3+
title: Arduino
4+
---
5+
6+
There are two main ways for interacting with an Arduno using Node-RED. They
7+
both assume the Arduino is connected to the host computer via a USB connection.
8+
9+
***
10+
11+
### Serial
12+
13+
As the Arduino appears as a Serial device, the Serial in/out nodes can be used
14+
to communicate with it.
15+
16+
*TODO: add example of sketch for Serial*
17+
18+
***
19+
20+
### Firmata
21+
22+
[Firmata](http://firmata.org/) is a protocol for communicating between an
23+
Arduino (as well as other microcontrollers) and the host computer, providing
24+
direct access to the IO pins.
25+
26+
#### Installation
27+
28+
First you need to load the default Firmata sketch onto the Arduino using the
29+
standard Arduino software download tools. This is usually found under
30+
*Files - Examples - Firmata - Standard Firmata*.
31+
32+
To ensure you have the Arduino nodes in the Node-RED palette, install the
33+
firmata npm module and restart Node-RED
34+
35+
$ cd node-red
36+
$ npm install firmata
37+
$ node red.js
38+
39+
#### Blink
40+
41+
To run a "blink" flow that uses LED 13, copy the following flow and paste it
42+
into the Import Nodes dialog (*Import From - Clipboard* in the dropdown menu, or
43+
Ctrl-I). After clicking okay, click in the workspace to place the new nodes.
44+
45+
[{"id":"d7663aaf.47194","type":"arduino-board","repeat":"25","device":"/dev/ttyUSB0"},{"id":"8c09ca6c.a975d","type":"arduino out","name":"","pin":"13","state":"OUTPUT","arduino":"d7663aaf.47194","x":509.16667556762695,"y":162.16666984558105,"wires":[]},{"id":"e37b6a97.610968","type":"inject","name":"tick","topic":"","payload":"","repeat":"0.5","once":false,"x":116.16668319702148,"y":62.16666507720947,"wires":[["60b4aeaa.800d58"]]},{"id":"60b4aeaa.800d58","type":"function","name":"Toggle output on input","func":"\n// initialise level as a context variable if currently undefined \n// (context variables persist between calls to the function)\ncontext.level = context.level || false;\n\n// if it's a 0 make it a 1 else make it a 0...\ncontext.level = !context.level;\n\n// set the payload to the level and return\nmsg.payload = context.level;\nreturn msg;","outputs":1,"x":298.1666793823242,"y":113.16665458679199,"wires":[["8c09ca6c.a975d"]]}]
46+
47+
This flow is set to use `/dev/ttyUSB0`. If you need to change that, double click
48+
the node labelled `Pin 13` - the Arduino node. Click the pencil icon and change
49+
the port definition as needed.
50+
51+
Click the deploy button and the flow should start running. LED 13 should start
52+
toggling on and off once a second.
53+
54+
#### Capabilities
55+
56+
The Arduino output node currently supports three modes of operation:
57+
58+
- Digital - 0 or 1
59+
- Analogue - 0 to 255
60+
- Servo - 0 to 180
61+
62+
The Arduino input node, available in the palette but not used in this example,
63+
can support both Digital and Analog pins. The input will send a message whenever
64+
it detects a change. This may be okay for digital inputs as they tend to be
65+
fairly stable, but analog readings often end up being at the full sample rate
66+
(default: 40 times a second...). This can be changed in the configuration of the
67+
serial port to reduce it to a more manageable rate.
68+
69+
Details of the node.js firmata library can be found [here](https://github.com/jgautier/firmata).

0 commit comments

Comments
 (0)