Skip to content

Commit 003a55f

Browse files
rwaldronmkellner
authored andcommitted
i2c.c: rename "clock" => "scl" (+ modSsd1306.c). Fixes gh-14
Smoke tested with: - examples/drivers/BMP180 - examples/drivers/HMC5883L - examples/drivers/lis3dh - examples/drivers/mcp23008 (existing and new feature branch) - examples/drivers/mcp23017 (on new feature branch)
1 parent 02b6713 commit 003a55f

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

documentation/pins/pins.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Pin numbers are device dependent.
154154

155155
The following example instantiates an I2C connection to a [temperature sensor](https://www.sparkfun.com/products/11931) with address 0x48 connected to pins 4 and 5.
156156

157-
let sensor = new I2C({sda: 5, clock: 4, address: 0x48});
157+
let sensor = new I2C({sda: 5, scl: 4, address: 0x48});
158158
sensor.write(0); // set register address 0
159159
let value = sensor.read(2); // read two bytes
160160

@@ -171,15 +171,15 @@ The following example instantiates an I2C connection to a [temperature sensor](h
171171

172172
### constructor(dictionary)
173173

174-
The I2C constructor takes a dictionary which contains the pins numbers to use for clock and data, as well as the I2C address of the target device.
174+
The I2C constructor takes a dictionary which contains the pins numbers to use for clock and data (`scl` and `sda` respectively), as well as the I2C address of the target device.
175175

176-
let sensor = new I2C({sda: 5, clock: 4, address: 0x48});
176+
let sensor = new I2C({sda: 5, scl: 4, address: 0x48});
177177

178178
The constructor dictionary has an optional `hz` property to specify the speed of the I2C bus when using this instance.
179179

180-
let sensor = new I2C({sda: 5, clock: 4, address: 0x48, hz: 1000000});
180+
let sensor = new I2C({sda: 5, scl: 4, address: 0x48, hz: 1000000});
181181

182-
Many devices have a default I2C bus. On these devices, the sda and clock parameters may be omitted from the dictionary to use the default I2C bus.
182+
Many devices have a default I2C bus. On these devices, the `sda` and `scl` parameters may be omitted from the dictionary to use the default I2C bus.
183183

184184
let sensor = new I2C({address: 0x48});
185185

examples/drivers/BMP180/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ class BMP180 extends I2C {
119119
}
120120
}
121121

122-
// SDA = GPIO 4 = D2 - CLOCK = GPIO 5 = D1 - NODEMCU
123-
let sensor = new BMP180({sda: 4, clock: 5, address: BMP180_ADDR});
122+
// SDA = GPIO 4 = D2 - SCL = GPIO 5 = D1 - NODEMCU
123+
let sensor = new BMP180({sda: 4, scl: 5, address: BMP180_ADDR});
124124

125125
WiFi.mode = 2;
126126

examples/drivers/HMC5883L/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
HMC5883L - https://cdn.sparkfun.com/datasheets/Sensors/Magneto/HMC5883L-FDS.pdf
1919
*/
2020

21-
import SMBus from "smbus";
21+
import SMBus from "pins/smbus";
2222
import Timer from "timer";
2323

24-
let sensor = new SMBus({sda: 5, clock: 4, address: 0x1E});
24+
let sensor = new SMBus({sda: 5, scl: 4, address: 0x1E});
2525

2626
let id = sensor.readBlock(10, 3); // ID
2727
id = String.fromCharCode(id[0]) + String.fromCharCode(id[1]) + String.fromCharCode(id[2]);

modules/drivers/ssd1306/modSsd1306.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ void xs_SSD1306(xsMachine *the)
214214
else {
215215
xsmcGet(xsVar(0), xsArg(0), xsID_sda);
216216
ssd->config.i2c.sda = xsmcToInteger(xsVar(0));
217-
xsmcGet(xsVar(0), xsArg(0), xsID_clock);
217+
xsmcGet(xsVar(0), xsArg(0), xsID_scl);
218218
ssd->config.i2c.scl = xsmcToInteger(xsVar(0));
219219

220220
ssd->doSPI = 0;

modules/pins/i2c/i2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void xs_i2c(xsMachine *the)
4141
xsmcVars(1);
4242
xsmcGet(xsVar(0), xsArg(0), xsID_sda);
4343
sda = (xsUndefinedType == xsmcTypeOf(xsVar(0))) ? -1 : xsmcToInteger(xsVar(0));
44-
xsmcGet(xsVar(0), xsArg(0), xsID_clock);
44+
xsmcGet(xsVar(0), xsArg(0), xsID_scl);
4545
scl = (xsUndefinedType == xsmcTypeOf(xsVar(0))) ? -1 : xsmcToInteger(xsVar(0));
4646
xsmcGet(xsVar(0), xsArg(0), xsID_address);
4747
address = xsmcToInteger(xsVar(0));

0 commit comments

Comments
 (0)