Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit c17862c

Browse files
committed
GPIO: change default values
Signed-off-by: Zoltan Kis <[email protected]>
1 parent 5a53e3c commit c17862c

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

board/gpio.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ Configures a GPIO pin using data provided by the `options` argument, that may co
2727
<a name="gpiooptions"></a>
2828
* `name` for pin name, either a number or string, by default `undefined`
2929
* `mapping` for either `"board"` or `"os"` pin mapping, by default `"os"`
30-
* `mode` with valid values `"input"` or `"output"`, by default `"input"`
30+
* `mode` with valid values `"in"` or `"out"`, by default `"out"`
3131
* `activeLow`, by default `false`
32-
* `edge`, by default `"any"`
33-
* `state`, by default `undefined`.
32+
* `edge`, with valid values: `"rising"`, `"falling"`, `"any"`, `"none"`, by default `"none"`
33+
* `state`, by default `undefined`, supported values: `"pull-up"`, `"pull-down"`, `"high-impedance"`.
3434

3535
The method runs the following steps:
3636
- If `options` is a number or string, let `init` be a [GPIOOptions](#gpiooptions) object, let `init.name` be `options` and let the other [GPIOOptions](#gpiooptions) properties take the default values.
@@ -115,14 +115,14 @@ try {
115115
var gpio = require("gpio");
116116

117117
var gpio3 = gpio.open(3); // GPIO input pin with default configuration.
118-
console.log(board.name + " GPIO pin 3 value: " + gpio3.read());
118+
gpio3.write(1); // activate pin
119119
gpio3.close();
120120

121-
var gpio5 = gpio.open({ name: 5, mode: "output", activeLow: true });
121+
var gpio5 = gpio.open({ name: 5, mode: "out", activeLow: true });
122122
gpio5.write(0); // activate pin
123123
gpio5.close();
124124

125-
gpio6 = gpio.open({ pin: 6, edge: "any"});
125+
gpio6 = gpio.open({ pin: 6, mode: "in", edge: "any"});
126126
gpio6.on("data", function(value) {
127127
console.log("GPIO pin 6 has changed; value: " + value);
128128
});
@@ -141,7 +141,7 @@ try {
141141
try {
142142
var gpio = require("board").gpio();
143143
// Configure a GPIO port using default configuration
144-
var gport1 = gpio.port([3,4,5,6,7,8]);
144+
var gport1 = gpio.port([3,4,5,6,7,8], { mode: "in"});
145145

146146
// Set up a change listener on the port value.
147147
gport1.on("data", function(value) {
@@ -153,12 +153,12 @@ try {
153153
}, 2000);
154154

155155
// Initialize and write an output port
156-
var gport2 = gpio.port([5,6,7,8], { mode: "output", activeLow: true });
156+
var gport2 = gpio.port([5,6,7,8], { activeLow: true });
157157
gport2.write(0x21);
158158
gport2.close();
159159

160160
// Configure a GPIO port supported in the platform under a symbolic name
161-
var gport3 = gpio.port("gpio-port-1", { mode: "output", activeLow: true });
161+
var gport3 = gpio.port("gpio-port-1", { activeLow: true });
162162
gport3.write(0x21);
163163
gport3.close();
164164

board/webidl.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ interface GPIOObject {
4545

4646
[NoInterfaceObject]
4747
interface GPIO: {
48-
// has all the properties of GPIOOptions as readonly attributes
49-
5048
unsigned long read();
5149
void write(long value);
5250
void close();
@@ -60,13 +58,13 @@ GPIO implements EventEmitter;
6058
dictionary GPIOOptions {
6159
PinName name;
6260
PinMapping mapping = "os";
63-
GPIOMode mode = "input";
61+
GPIOMode mode = "out";
6462
boolean activeLow = false;
65-
GPIOEdge edge = "any";
63+
GPIOEdge edge = "none";
6664
GPIOState state = "high-impedance";
6765
};
6866

69-
enum GPIOMode { "input", "output" };
67+
enum GPIOMode { "in", "out" };
7068
enum GPIOEdge { "none", "rising", "falling", "any" };
7169
enum GPIOState { "pull-up", "pull-down", "high-impedance" };
7270

0 commit comments

Comments
 (0)