periph 1.5.4 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/examples/gas/ccs811/complete.js +87 -0
- package/examples/gas/ccs811/demo.js +108 -0
- package/examples/gas/ccs811/minimal.js +20 -0
- package/examples/gas/rrh46410/complete.js +78 -0
- package/examples/gas/rrh46410/demo.js +86 -0
- package/examples/gas/rrh46410/minimal.js +21 -0
- package/examples/gas/rrh62000/complete.js +74 -0
- package/examples/gas/rrh62000/demo.js +87 -0
- package/examples/gas/rrh62000/minimal.js +22 -0
- package/examples/gas/scd30/complete.js +73 -0
- package/examples/gas/scd30/demo.js +102 -0
- package/examples/gas/scd30/minimal.js +20 -0
- package/examples/gas/scd40/complete.js +76 -0
- package/examples/gas/scd40/demo.js +109 -0
- package/examples/gas/scd40/minimal.js +20 -0
- package/examples/light/si1133/complete.js +89 -0
- package/examples/light/si1133/demo.js +93 -0
- package/examples/light/si1133/minimal.js +22 -0
- package/examples/light/si1145/complete.js +93 -0
- package/examples/light/si1145/demo.js +98 -0
- package/examples/light/si1145/minimal.js +22 -0
- package/examples/light/tsl2561/complete.js +74 -0
- package/examples/light/tsl2561/demo.js +46 -0
- package/examples/light/tsl2561/minimal.js +22 -0
- package/examples/light/tsl2591/complete.js +90 -0
- package/examples/light/tsl2591/demo.js +119 -0
- package/examples/light/tsl2591/minimal.js +22 -0
- package/examples/light/vcnl4040/complete.js +102 -0
- package/examples/light/vcnl4040/demo.js +125 -0
- package/examples/light/vcnl4040/minimal.js +25 -0
- package/examples/light/vcnl4200/complete.js +101 -0
- package/examples/light/vcnl4200/demo.js +126 -0
- package/examples/light/vcnl4200/minimal.js +25 -0
- package/examples/pressure/spl06/complete.js +81 -0
- package/examples/pressure/spl06/demo.js +106 -0
- package/examples/pressure/spl06/minimal.js +22 -0
- package/examples/rfid/pn532/complete.js +99 -0
- package/examples/rfid/pn532/demo.js +121 -0
- package/examples/rfid/pn532/minimal.js +22 -0
- package/examples/rfid/st25dv/complete.js +94 -0
- package/examples/rfid/st25dv/demo.js +121 -0
- package/examples/rfid/st25dv/minimal.js +21 -0
- package/examples/rtc/bq32000/complete.js +53 -0
- package/examples/rtc/bq32000/demo.js +77 -0
- package/examples/rtc/bq32000/minimal.js +20 -0
- package/examples/rtc/ds1307/complete.js +54 -0
- package/examples/rtc/ds1307/demo.js +96 -0
- package/examples/rtc/ds1307/minimal.js +20 -0
- package/examples/rtc/ds1371/complete.js +53 -0
- package/examples/rtc/ds1371/demo.js +85 -0
- package/examples/rtc/ds1371/minimal.js +25 -0
- package/package.json +1 -1
- package/src/chips/gas/ccs811.js +400 -0
- package/src/chips/gas/rrh46410.js +534 -0
- package/src/chips/gas/rrh62000.js +418 -0
- package/src/chips/gas/scd30.js +368 -0
- package/src/chips/gas/scd40.js +451 -0
- package/src/chips/light/si1133.js +583 -0
- package/src/chips/light/si1145.js +630 -0
- package/src/chips/light/tsl2561.js +445 -0
- package/src/chips/light/tsl2591.js +561 -0
- package/src/chips/light/vcnl4040.js +576 -0
- package/src/chips/light/vcnl4200.js +592 -0
- package/src/chips/pressure/spl06.js +461 -0
- package/src/chips/rfid/pn532.js +513 -0
- package/src/chips/rfid/st25dv.js +628 -0
- package/src/chips/rtc/bq32000.js +334 -0
- package/src/chips/rtc/ds1307.js +327 -0
- package/src/chips/rtc/ds1371.js +453 -0
- package/src/connection/i2c.js +46 -13
- package/src/connection/smbus.js +21 -8
- package/src/discovery/registry.js +17 -17
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Complete example: exercise every method of VCNL4040Full — proximity, lux,
|
|
4
|
+
// raw ALS / white channels, ALS and PS configuration, thresholds,
|
|
5
|
+
// cancellation, active force, logic output, ID, status and interrupts.
|
|
6
|
+
|
|
7
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
8
|
+
const { VCNL4040Full, alsSensitivity, alsMaxRange } = require('periph/src/chips/light/vcnl4040');
|
|
9
|
+
|
|
10
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
11
|
+
|
|
12
|
+
(async () => {
|
|
13
|
+
const bus = parseInt(process.env.I2C_BUS || '1', 10);
|
|
14
|
+
const connection = new I2CConnection(bus, VCNL4040Full.I2C_ADDRESS);
|
|
15
|
+
const sensor = new VCNL4040Full(connection); // Create VCNL4040 Full driver, (connection)
|
|
16
|
+
await sensor.init(); // Run initialization sequence, () → void
|
|
17
|
+
// checks ID 0x0186, ALS 80 ms on, PS 16 bit / duty 1/160 / 50 mA on
|
|
18
|
+
|
|
19
|
+
console.log((await sensor.deviceId()).toString(16)); // Read the ID register, () → int
|
|
20
|
+
// 0x0186 for the VCNL4040
|
|
21
|
+
console.log(await sensor.readProximity()); // Read proximity, () → int counts
|
|
22
|
+
// PS_DATA; larger = closer
|
|
23
|
+
console.log(await sensor.readLux()); // Read ambient light, () → float lux
|
|
24
|
+
// ALS_DATA × sensitivity of the current integration time
|
|
25
|
+
console.log(await sensor.readAls()); // Read raw ALS, () → int counts
|
|
26
|
+
// ALS_DATA, 0–65535
|
|
27
|
+
await sensor.setWhiteChannel(true); // White channel, (on) → void
|
|
28
|
+
// WHITE_EN is active low: true writes 0
|
|
29
|
+
await sleep(100);
|
|
30
|
+
console.log(await sensor.readWhite()); // Read raw white channel, () → int counts
|
|
31
|
+
// WHITE_DATA, 0–65535
|
|
32
|
+
console.log(alsSensitivity(640), alsMaxRange(640)); // ALS resolution / range, (milliseconds) → float
|
|
33
|
+
// 0.0125 lx/count and 819.2 lx at 640 ms
|
|
34
|
+
|
|
35
|
+
await sensor.setAlsIntegrationTime(160); // ALS integration time, (milliseconds 80/160/320/640) → void
|
|
36
|
+
// 160 ms = 0.05 lx/count, 3276.8 lx range
|
|
37
|
+
console.log(await sensor.getAlsIntegrationTime()); // ALS integration time, () → int ms
|
|
38
|
+
// read back from ALS_CONF
|
|
39
|
+
await sensor.setAlsPersistence(2); // ALS persistence, (count 1/2/4/8) → void
|
|
40
|
+
// consecutive results outside the window
|
|
41
|
+
await sensor.setAlsThresholds(1000, 20000); // ALS window, (low, high counts 0–65535) → void
|
|
42
|
+
// counts = lux / sensitivity
|
|
43
|
+
console.log(await sensor.getAlsThresholds()); // ALS window, () → {low, high}
|
|
44
|
+
// ALS_THDL, ALS_THDH
|
|
45
|
+
await sensor.alsDisable(); // ALS off, () → void
|
|
46
|
+
// ALS_SD = 1
|
|
47
|
+
await sensor.alsEnable(); // ALS on, () → void
|
|
48
|
+
// ALS_SD = 0; next result after one integration
|
|
49
|
+
|
|
50
|
+
await sensor.setPsResolution(16); // PS resolution, (bits 12/16) → void
|
|
51
|
+
// set before the thresholds
|
|
52
|
+
await sensor.setPsDuty(160); // IRED duty, (ratio 40/80/160/320) → void
|
|
53
|
+
// on/off ratio 1/160
|
|
54
|
+
await sensor.setPsIntegrationTime(2); // PS integration time, (t 1/1.5/2/2.5/3/3.5/4/8) → void
|
|
55
|
+
// in units of T
|
|
56
|
+
await sensor.setPsPersistence(2); // PS persistence, (count 1–4) → void
|
|
57
|
+
// consecutive hits for an interrupt
|
|
58
|
+
await sensor.setPsMultiPulse(2); // Multi-pulse, (count 1/2/4/8) → void
|
|
59
|
+
// IRED pulses per measurement
|
|
60
|
+
await sensor.setLedCurrent(100); // IRED current, (milliamperes 50–200) → void
|
|
61
|
+
// 50, 75, 100, 120, 140, 160, 180 or 200 mA
|
|
62
|
+
await sensor.setPsThresholds(1000, 3000); // PS window, (low away, high close) → void
|
|
63
|
+
// 0–4095 at 12 bit
|
|
64
|
+
console.log(await sensor.getPsThresholds()); // PS window, () → {low, high}
|
|
65
|
+
// PS_THDL, PS_THDH
|
|
66
|
+
await sensor.setPsCancellation(0); // Cancellation, (level 0–65535) → void
|
|
67
|
+
// subtracted from every PS result
|
|
68
|
+
await sensor.setPsSunlightCancel(true); // Sunlight cancellation, (on) → void
|
|
69
|
+
// PS_SC_EN
|
|
70
|
+
await sensor.setPsSmartPersistence(true); // Smart persistence, (on) → void
|
|
71
|
+
// faster response with persistence > 1
|
|
72
|
+
await sensor.psDisable(); // PS off, () → void
|
|
73
|
+
// PS_SD = 1
|
|
74
|
+
await sensor.psEnable(); // PS on, () → void
|
|
75
|
+
// PS_SD = 0
|
|
76
|
+
|
|
77
|
+
await sensor.setPsActiveForce(true); // Active-force mode, (on) → void
|
|
78
|
+
// PS measures only on trigger
|
|
79
|
+
console.log(await sensor.triggerPs()); // One PS measurement, () → int counts
|
|
80
|
+
// writes PS_TRIG, waits, reads PS_DATA
|
|
81
|
+
await sensor.setPsActiveForce(false);
|
|
82
|
+
await sensor.setPsLogicOutput(true); // Logic-output mode, (on) → void
|
|
83
|
+
// INT low while close, high once away
|
|
84
|
+
await sleep(1000);
|
|
85
|
+
await sensor.setPsLogicOutput(false);
|
|
86
|
+
|
|
87
|
+
console.log(await sensor.status()); // Interrupt flags, () → int
|
|
88
|
+
// INT_FLAG high byte; reading clears it
|
|
89
|
+
await sensor.enableInterrupt(VCNL4040Full.SOURCE_ALS_HIGH | VCNL4040Full.SOURCE_PS_CLOSE); // Enable sources, (source) → void
|
|
90
|
+
// ALS_INT_EN covers both ALS sources
|
|
91
|
+
console.log(await sensor.pollInterrupt()); // Pending flags, () → int
|
|
92
|
+
// reads and clears INT_FLAG
|
|
93
|
+
await sensor.onInterrupt((f) => console.log('interrupt', f.toString(16))); // Subscribe, (callback(flags), {intPin}) → void
|
|
94
|
+
// falling edge on INT, or poll every 100 ms
|
|
95
|
+
await sleep(10000);
|
|
96
|
+
await sensor.offInterrupt(); // Unsubscribe, () → void
|
|
97
|
+
await sensor.disableInterrupt(VCNL4040Full.SOURCE_ALS_HIGH | VCNL4040Full.SOURCE_ALS_LOW
|
|
98
|
+
| VCNL4040Full.SOURCE_PS_CLOSE | VCNL4040Full.SOURCE_PS_AWAY); // Disable sources, (source) → void
|
|
99
|
+
// clears ALS_INT_EN and PS_INT
|
|
100
|
+
|
|
101
|
+
await connection.close();
|
|
102
|
+
})();
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Demo: presence-activated display light. Prints the ID and settings, reads
|
|
4
|
+
// proximity and lux every 0.2 s for 10 s, calibrates the cancellation with
|
|
5
|
+
// nothing in front of the sensor, reports close/away and room-light events
|
|
6
|
+
// for 15 s, steps through the ALS integration times, the PS resolutions and
|
|
7
|
+
// IRED currents, shows active-force mode and the logic output, then powers
|
|
8
|
+
// both sensors down.
|
|
9
|
+
|
|
10
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
11
|
+
const { VCNL4040Full, alsSensitivity, alsMaxRange } = require('periph/src/chips/light/vcnl4040');
|
|
12
|
+
|
|
13
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
14
|
+
const S = VCNL4040Full;
|
|
15
|
+
const ALL = S.SOURCE_PS_CLOSE | S.SOURCE_PS_AWAY | S.SOURCE_ALS_HIGH | S.SOURCE_ALS_LOW;
|
|
16
|
+
|
|
17
|
+
(async () => {
|
|
18
|
+
const bus = parseInt(process.env.I2C_BUS || '1', 10);
|
|
19
|
+
const connection = new I2CConnection(bus, VCNL4040Full.I2C_ADDRESS);
|
|
20
|
+
const sensor = new VCNL4040Full(connection); // Create VCNL4040 Full driver, (connection)
|
|
21
|
+
await sensor.init(); // Run initialization sequence, () → void
|
|
22
|
+
console.log('ID 0x' + (await sensor.deviceId()).toString(16)); // Read the ID register, () → int
|
|
23
|
+
console.log('ALS integration', await sensor.getAlsIntegrationTime(), 'ms'); // ALS integration time, () → int ms
|
|
24
|
+
|
|
25
|
+
/* Live readings: move a hand towards the sensor. The proximity count
|
|
26
|
+
rises as more IRED light is reflected; the lux value follows the room. */
|
|
27
|
+
await sensor.setWhiteChannel(true); // White channel, (on) → void
|
|
28
|
+
for (let i = 0; i < 50; i++) {
|
|
29
|
+
const p = await sensor.readProximity(); // Read proximity, () → int counts
|
|
30
|
+
const lx = await sensor.readLux(); // Read ambient light, () → float lux
|
|
31
|
+
const w = await sensor.readWhite(); // Read raw white channel, () → int counts
|
|
32
|
+
const a = await sensor.readAls(); // Read raw ALS, () → int counts
|
|
33
|
+
console.log(`proximity ${p} ${lx.toFixed(1)} lx white ${w} als ${a}`);
|
|
34
|
+
await sleep(200);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Calibrate the cancellation: with nothing in front of the sensor the
|
|
38
|
+
count is cross talk from the cover glass; subtracting it makes
|
|
39
|
+
"no target" read close to 0. */
|
|
40
|
+
console.log('remove any object in front of the sensor');
|
|
41
|
+
await sleep(3000);
|
|
42
|
+
let sum = 0;
|
|
43
|
+
for (let i = 0; i < 8; i++) sum += await sensor.readProximity();
|
|
44
|
+
await sensor.setPsCancellation(Math.floor(sum / 8)); // Cancellation, (level 0–65535) → void
|
|
45
|
+
console.log('cancellation level', Math.floor(sum / 8));
|
|
46
|
+
|
|
47
|
+
/* Close/away window: above the high threshold the PS reports "close",
|
|
48
|
+
below the low threshold "away"; persistence 2 ignores single noisy
|
|
49
|
+
samples and smart persistence keeps the response fast. The ALS window
|
|
50
|
+
reports a change of the room light. */
|
|
51
|
+
await sensor.setPsThresholds(300, 1000); // PS window, (low away, high close) → void
|
|
52
|
+
console.log('PS window', await sensor.getPsThresholds()); // PS window, () → {low, high}
|
|
53
|
+
await sensor.setPsPersistence(2); // PS persistence, (count 1–4) → void
|
|
54
|
+
await sensor.setPsSmartPersistence(true); // Smart persistence, (on) → void
|
|
55
|
+
await sensor.setPsSunlightCancel(true); // Sunlight cancellation, (on) → void
|
|
56
|
+
const als = await sensor.readAls();
|
|
57
|
+
await sensor.setAlsThresholds(Math.floor(als / 2), Math.min(65535, als * 2)); // ALS window, (low, high counts) → void
|
|
58
|
+
console.log('ALS window', await sensor.getAlsThresholds()); // ALS window, () → {low, high}
|
|
59
|
+
await sensor.setAlsPersistence(4); // ALS persistence, (count 1/2/4/8) → void
|
|
60
|
+
await sensor.status(); // Interrupt flags, () → int (clears stale flags)
|
|
61
|
+
await sensor.enableInterrupt(ALL); // Enable sources, (source) → void
|
|
62
|
+
await sensor.onInterrupt(async (flags) => { // Subscribe, (callback(flags), {intPin}) → void
|
|
63
|
+
if (flags & S.SOURCE_PS_CLOSE) console.log('close: wake the display');
|
|
64
|
+
if (flags & S.SOURCE_PS_AWAY) console.log('away: dim the display');
|
|
65
|
+
if (flags & (S.SOURCE_ALS_HIGH | S.SOURCE_ALS_LOW)) console.log('room light changed');
|
|
66
|
+
if (flags & S.FLAG_PROTECTION) console.log('PS protection mode');
|
|
67
|
+
});
|
|
68
|
+
console.log('wave a hand in front of the sensor for 15 s');
|
|
69
|
+
await sleep(15000);
|
|
70
|
+
await sensor.offInterrupt(); // Unsubscribe, () → void
|
|
71
|
+
console.log('pending', await sensor.pollInterrupt()); // Pending flags, () → int
|
|
72
|
+
await sensor.disableInterrupt(ALL); // Disable sources, (source) → void
|
|
73
|
+
|
|
74
|
+
/* ALS integration times: longer integration gives finer resolution but a
|
|
75
|
+
smaller range. */
|
|
76
|
+
for (const ms of [80, 160, 320, 640]) {
|
|
77
|
+
await sensor.setAlsIntegrationTime(ms); // ALS integration time, (milliseconds) → void
|
|
78
|
+
await sleep(ms * 2);
|
|
79
|
+
console.log(`${ms} ms ${alsSensitivity(ms)} lx/count range ${alsMaxRange(ms).toFixed(1)} lx ${(await sensor.readLux()).toFixed(2)} lx`);
|
|
80
|
+
}
|
|
81
|
+
await sensor.setAlsIntegrationTime(80);
|
|
82
|
+
|
|
83
|
+
/* PS resolution and IRED current: 12-bit output saturates at 4095; a
|
|
84
|
+
higher IRED current reaches further but costs current (average = pulse
|
|
85
|
+
current × duty ratio). */
|
|
86
|
+
for (const bits of [12, 16]) {
|
|
87
|
+
await sensor.setPsResolution(bits); // PS resolution, (bits 12/16) → void
|
|
88
|
+
for (const ma of [50, 75, 100, 120, 140, 160, 180, 200]) {
|
|
89
|
+
await sensor.setLedCurrent(ma); // IRED current, (milliamperes) → void
|
|
90
|
+
await sleep(50);
|
|
91
|
+
console.log(`${bits} bit ${ma} mA proximity ${await sensor.readProximity()}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
await sensor.setLedCurrent(50);
|
|
95
|
+
await sensor.setPsDuty(320); // IRED duty, (ratio 40/80/160/320) → void
|
|
96
|
+
await sensor.setPsIntegrationTime(1.5); // PS integration time, (t) → void
|
|
97
|
+
await sensor.setPsMultiPulse(2); // Multi-pulse, (count 1/2/4/8) → void
|
|
98
|
+
|
|
99
|
+
/* Active force: the PS stays in standby and measures only when
|
|
100
|
+
triggered, the lowest-power way to sample proximity. */
|
|
101
|
+
await sensor.setPsActiveForce(true); // Active-force mode, (on) → void
|
|
102
|
+
for (let i = 0; i < 5; i++) {
|
|
103
|
+
console.log('triggered proximity', await sensor.triggerPs()); // One PS measurement, () → int counts
|
|
104
|
+
await sleep(500);
|
|
105
|
+
}
|
|
106
|
+
await sensor.setPsActiveForce(false);
|
|
107
|
+
|
|
108
|
+
/* Logic output: INT follows the close/away state directly, e.g. to gate
|
|
109
|
+
a backlight without the host. */
|
|
110
|
+
await sensor.setPsLogicOutput(true); // Logic-output mode, (on) → void
|
|
111
|
+
console.log('INT is now a close/away output for 5 s');
|
|
112
|
+
await sleep(5000);
|
|
113
|
+
await sensor.setPsLogicOutput(false);
|
|
114
|
+
|
|
115
|
+
/* Shut down: both sensors stop measuring; the IRED is off. */
|
|
116
|
+
await sensor.psDisable(); // PS off, () → void
|
|
117
|
+
await sensor.alsDisable(); // ALS off, () → void
|
|
118
|
+
await sensor.psEnable(); // PS on, () → void
|
|
119
|
+
await sensor.alsEnable(); // ALS on, () → void
|
|
120
|
+
await sensor.psDisable();
|
|
121
|
+
await sensor.alsDisable();
|
|
122
|
+
console.log('both sensors shut down');
|
|
123
|
+
|
|
124
|
+
await connection.close();
|
|
125
|
+
})();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Minimal example: read proximity and ambient light five times a second
|
|
4
|
+
// (ALS 80 ms, PS 16 bit, duty 1/160, 50 mA IRED).
|
|
5
|
+
|
|
6
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
7
|
+
const { VCNL4040Minimal } = require('periph/src/chips/light/vcnl4040');
|
|
8
|
+
|
|
9
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
10
|
+
|
|
11
|
+
(async () => {
|
|
12
|
+
const bus = parseInt(process.env.I2C_BUS || '1', 10);
|
|
13
|
+
const connection = new I2CConnection(bus, VCNL4040Minimal.I2C_ADDRESS);
|
|
14
|
+
const sensor = new VCNL4040Minimal(connection); // Create VCNL4040 driver, (connection)
|
|
15
|
+
await sensor.init(); // Run initialization sequence, () → void (checks ID, powers on ALS and PS)
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < 50; i++) {
|
|
18
|
+
const proximity = await sensor.readProximity(); // Read proximity, () → int counts
|
|
19
|
+
const lux = await sensor.readLux(); // Read ambient light, () → float lux
|
|
20
|
+
console.log(`proximity ${proximity} ${lux.toFixed(1)} lx`);
|
|
21
|
+
await sleep(200);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
await connection.close();
|
|
25
|
+
})();
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Complete example: exercise every method of VCNL4200Full — proximity, lux,
|
|
4
|
+
// raw ALS / white channels, ALS and PS configuration, thresholds,
|
|
5
|
+
// cancellation, active force, logic output, ID, status and interrupts.
|
|
6
|
+
|
|
7
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
8
|
+
const { VCNL4200Full, alsSensitivity, alsMaxRange } = require('periph/src/chips/light/vcnl4200');
|
|
9
|
+
|
|
10
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
11
|
+
|
|
12
|
+
(async () => {
|
|
13
|
+
const bus = parseInt(process.env.I2C_BUS || '1', 10);
|
|
14
|
+
const connection = new I2CConnection(bus, VCNL4200Full.I2C_ADDRESS);
|
|
15
|
+
const sensor = new VCNL4200Full(connection); // Create VCNL4200 Full driver, (connection)
|
|
16
|
+
await sensor.init(); // Run initialization sequence, () → void
|
|
17
|
+
// checks ID 0x1058, ALS 50 ms on, PS 16 bit / duty 1/160 / 50 mA on
|
|
18
|
+
|
|
19
|
+
console.log((await sensor.deviceId()).toString(16)); // Read the ID register, () → int
|
|
20
|
+
// 0x1058 for the VCNL4200 (bits 11:8 = version code)
|
|
21
|
+
console.log(await sensor.readProximity()); // Read proximity, () → int counts
|
|
22
|
+
// PS_DATA; larger = closer
|
|
23
|
+
console.log(await sensor.readLux()); // Read ambient light, () → float lux
|
|
24
|
+
// ALS_DATA × sensitivity of the current integration time
|
|
25
|
+
console.log(await sensor.readAls()); // Read raw ALS, () → int counts
|
|
26
|
+
// ALS_DATA, 0–65535
|
|
27
|
+
console.log(await sensor.readWhite()); // Read raw white channel, () → int counts
|
|
28
|
+
// WHITE_DATA, 0–65535
|
|
29
|
+
console.log(alsSensitivity(400), alsMaxRange(400)); // ALS resolution / range, (milliseconds) → float
|
|
30
|
+
// 0.003 lx/count and 197 lx at 400 ms
|
|
31
|
+
|
|
32
|
+
await sensor.setAlsIntegrationTime(100); // ALS integration time, (milliseconds 50/100/200/400) → void
|
|
33
|
+
// 100 ms = 0.012 lx/count, 786 lx range
|
|
34
|
+
console.log(await sensor.getAlsIntegrationTime()); // ALS integration time, () → int ms
|
|
35
|
+
// read back from ALS_CONF
|
|
36
|
+
await sensor.setAlsPersistence(2); // ALS persistence, (count 1/2/4/8) → void
|
|
37
|
+
// consecutive results outside the window
|
|
38
|
+
await sensor.setAlsInterruptChannel(false); // ALS interrupt channel, (white) → void
|
|
39
|
+
// false = ALS channel, true = white channel
|
|
40
|
+
await sensor.setAlsThresholds(1000, 20000); // ALS window, (low, high counts 0–65535) → void
|
|
41
|
+
// counts = lux / sensitivity
|
|
42
|
+
console.log(await sensor.getAlsThresholds()); // ALS window, () → {low, high}
|
|
43
|
+
// ALS_THDL, ALS_THDH
|
|
44
|
+
await sensor.alsDisable(); // ALS off, () → void
|
|
45
|
+
// ALS_SD = 1
|
|
46
|
+
await sensor.alsEnable(); // ALS on, () → void
|
|
47
|
+
// ALS_SD = 0; next result after one integration
|
|
48
|
+
|
|
49
|
+
await sensor.setPsResolution(16); // PS resolution, (bits 12/16) → void
|
|
50
|
+
// set before the thresholds
|
|
51
|
+
await sensor.setPsDuty(160); // IRED duty, (ratio 160/320/640/1280) → void
|
|
52
|
+
// on/off ratio 1/160
|
|
53
|
+
await sensor.setPsIntegrationTime(2); // PS integration time, (t 1/1.5/2/4/8/9) → void
|
|
54
|
+
// in units of T
|
|
55
|
+
await sensor.setPsPersistence(2); // PS persistence, (count 1–4) → void
|
|
56
|
+
// consecutive hits for an interrupt
|
|
57
|
+
await sensor.setPsMultiPulse(2); // Multi-pulse, (count 1/2/4/8) → void
|
|
58
|
+
// IRED pulses per measurement
|
|
59
|
+
await sensor.setLedCurrent(100); // IRED current, (milliamperes 50–200) → void
|
|
60
|
+
// 50, 75, 100, 120, 140, 160, 180 or 200 mA
|
|
61
|
+
await sensor.setPsThresholds(1000, 3000); // PS window, (low away, high close) → void
|
|
62
|
+
// 0–4095 at 12 bit
|
|
63
|
+
console.log(await sensor.getPsThresholds()); // PS window, () → {low, high}
|
|
64
|
+
// PS_THDL, PS_THDH
|
|
65
|
+
await sensor.setPsCancellation(0); // Cancellation, (level 0–65535) → void
|
|
66
|
+
// subtracted from every PS result
|
|
67
|
+
await sensor.setPsSunlight(true); // Sunlight, (cancel, doubleImmunity=false, capability1_5x=false, outputFF=false) → void
|
|
68
|
+
// PS_SC_EN; the flags set PS_SC_ADV, PS_SP and PS_SPO
|
|
69
|
+
await sensor.setPsSmartPersistence(true); // Smart persistence, (on) → void
|
|
70
|
+
// faster response with persistence > 1
|
|
71
|
+
await sensor.psDisable(); // PS off, () → void
|
|
72
|
+
// PS_SD = 1
|
|
73
|
+
await sensor.psEnable(); // PS on, () → void
|
|
74
|
+
// PS_SD = 0
|
|
75
|
+
|
|
76
|
+
await sensor.setPsActiveForce(true); // Active-force mode, (on) → void
|
|
77
|
+
// PS measures only on trigger
|
|
78
|
+
console.log(await sensor.triggerPs()); // One PS measurement, () → int counts
|
|
79
|
+
// writes PS_TRIG, waits, reads PS_DATA
|
|
80
|
+
await sensor.setPsActiveForce(false);
|
|
81
|
+
await sensor.setPsLogicOutput(true); // Logic-output mode, (on) → void
|
|
82
|
+
// INT low while close, high once away
|
|
83
|
+
await sleep(1000);
|
|
84
|
+
await sensor.setPsLogicOutput(false);
|
|
85
|
+
|
|
86
|
+
console.log(await sensor.status()); // Interrupt flags, () → int
|
|
87
|
+
// INT_FLAG high byte; reading clears it
|
|
88
|
+
await sensor.enableInterrupt(VCNL4200Full.SOURCE_ALS_HIGH | VCNL4200Full.SOURCE_PS_CLOSE); // Enable sources, (source) → void
|
|
89
|
+
// ALS_INT_EN covers both ALS sources
|
|
90
|
+
console.log(await sensor.pollInterrupt()); // Pending flags, () → int
|
|
91
|
+
// reads and clears INT_FLAG
|
|
92
|
+
await sensor.onInterrupt((f) => console.log('interrupt', f.toString(16))); // Subscribe, (callback(flags), {intPin}) → void
|
|
93
|
+
// falling edge on INT, or poll every 100 ms
|
|
94
|
+
await sleep(10000);
|
|
95
|
+
await sensor.offInterrupt(); // Unsubscribe, () → void
|
|
96
|
+
await sensor.disableInterrupt(VCNL4200Full.SOURCE_ALS_HIGH | VCNL4200Full.SOURCE_ALS_LOW
|
|
97
|
+
| VCNL4200Full.SOURCE_PS_CLOSE | VCNL4200Full.SOURCE_PS_AWAY); // Disable sources, (source) → void
|
|
98
|
+
// clears ALS_INT_EN and PS_INT
|
|
99
|
+
|
|
100
|
+
await connection.close();
|
|
101
|
+
})();
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Demo: presence-activated display light. Prints the ID and settings, reads
|
|
4
|
+
// proximity and lux every 0.2 s for 10 s, calibrates the cancellation with
|
|
5
|
+
// nothing in front of the sensor, reports close/away and room-light events
|
|
6
|
+
// for 15 s, steps through the ALS integration times, the PS resolutions and
|
|
7
|
+
// IRED currents, shows active-force mode and the logic output, then powers
|
|
8
|
+
// both sensors down.
|
|
9
|
+
|
|
10
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
11
|
+
const { VCNL4200Full, alsSensitivity, alsMaxRange } = require('periph/src/chips/light/vcnl4200');
|
|
12
|
+
|
|
13
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
14
|
+
const S = VCNL4200Full;
|
|
15
|
+
const ALL = S.SOURCE_PS_CLOSE | S.SOURCE_PS_AWAY | S.SOURCE_ALS_HIGH | S.SOURCE_ALS_LOW;
|
|
16
|
+
|
|
17
|
+
(async () => {
|
|
18
|
+
const bus = parseInt(process.env.I2C_BUS || '1', 10);
|
|
19
|
+
const connection = new I2CConnection(bus, VCNL4200Full.I2C_ADDRESS);
|
|
20
|
+
const sensor = new VCNL4200Full(connection); // Create VCNL4200 Full driver, (connection)
|
|
21
|
+
await sensor.init(); // Run initialization sequence, () → void
|
|
22
|
+
console.log('ID 0x' + (await sensor.deviceId()).toString(16)); // Read the ID register, () → int
|
|
23
|
+
console.log('ALS integration', await sensor.getAlsIntegrationTime(), 'ms'); // ALS integration time, () → int ms
|
|
24
|
+
|
|
25
|
+
/* Live readings: move a hand towards the sensor. The proximity count
|
|
26
|
+
rises as more IRED light is reflected; the lux value follows the room. */
|
|
27
|
+
for (let i = 0; i < 50; i++) {
|
|
28
|
+
const p = await sensor.readProximity(); // Read proximity, () → int counts
|
|
29
|
+
const lx = await sensor.readLux(); // Read ambient light, () → float lux
|
|
30
|
+
const w = await sensor.readWhite(); // Read raw white channel, () → int counts
|
|
31
|
+
const a = await sensor.readAls(); // Read raw ALS, () → int counts
|
|
32
|
+
console.log(`proximity ${p} ${lx.toFixed(1)} lx white ${w} als ${a}`);
|
|
33
|
+
await sleep(200);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* Calibrate the cancellation: with nothing in front of the sensor the
|
|
37
|
+
count is cross talk from the cover glass; subtracting it makes
|
|
38
|
+
"no target" read close to 0. */
|
|
39
|
+
console.log('remove any object in front of the sensor');
|
|
40
|
+
await sleep(3000);
|
|
41
|
+
let sum = 0;
|
|
42
|
+
for (let i = 0; i < 8; i++) sum += await sensor.readProximity();
|
|
43
|
+
await sensor.setPsCancellation(Math.floor(sum / 8)); // Cancellation, (level 0–65535) → void
|
|
44
|
+
console.log('cancellation level', Math.floor(sum / 8));
|
|
45
|
+
|
|
46
|
+
/* Close/away window: above the high threshold the PS reports "close",
|
|
47
|
+
below the low threshold "away"; persistence 2 ignores single noisy
|
|
48
|
+
samples and smart persistence keeps the response fast. The ALS window
|
|
49
|
+
reports a change of the room light. */
|
|
50
|
+
await sensor.setPsThresholds(300, 1000); // PS window, (low away, high close) → void
|
|
51
|
+
console.log('PS window', await sensor.getPsThresholds()); // PS window, () → {low, high}
|
|
52
|
+
await sensor.setPsPersistence(2); // PS persistence, (count 1–4) → void
|
|
53
|
+
await sensor.setPsSmartPersistence(true); // Smart persistence, (on) → void
|
|
54
|
+
await sensor.setPsSunlight(true, true); // Sunlight, (cancel, doubleImmunity, capability1_5x, outputFF) → void
|
|
55
|
+
const als = await sensor.readAls();
|
|
56
|
+
await sensor.setAlsThresholds(Math.floor(als / 2), Math.min(65535, als * 2)); // ALS window, (low, high counts) → void
|
|
57
|
+
console.log('ALS window', await sensor.getAlsThresholds()); // ALS window, () → {low, high}
|
|
58
|
+
await sensor.setAlsPersistence(4); // ALS persistence, (count 1/2/4/8) → void
|
|
59
|
+
await sensor.setAlsInterruptChannel(false); // ALS interrupt channel, (white) → void
|
|
60
|
+
await sensor.status(); // Interrupt flags, () → int (clears stale flags)
|
|
61
|
+
await sensor.enableInterrupt(ALL); // Enable sources, (source) → void
|
|
62
|
+
await sensor.onInterrupt(async (flags) => { // Subscribe, (callback(flags), {intPin}) → void
|
|
63
|
+
if (flags & S.SOURCE_PS_CLOSE) console.log('close: wake the display');
|
|
64
|
+
if (flags & S.SOURCE_PS_AWAY) console.log('away: dim the display');
|
|
65
|
+
if (flags & (S.SOURCE_ALS_HIGH | S.SOURCE_ALS_LOW)) console.log('room light changed');
|
|
66
|
+
if (flags & S.FLAG_SUNLIGHT_PROTECT) console.log('PS sunlight protection');
|
|
67
|
+
if (flags & S.FLAG_PS_SATURATED) console.log('PS saturated');
|
|
68
|
+
});
|
|
69
|
+
console.log('wave a hand in front of the sensor for 15 s');
|
|
70
|
+
await sleep(15000);
|
|
71
|
+
await sensor.offInterrupt(); // Unsubscribe, () → void
|
|
72
|
+
console.log('pending', await sensor.pollInterrupt()); // Pending flags, () → int
|
|
73
|
+
await sensor.disableInterrupt(ALL); // Disable sources, (source) → void
|
|
74
|
+
|
|
75
|
+
/* ALS integration times: longer integration gives finer resolution but a
|
|
76
|
+
smaller range. */
|
|
77
|
+
for (const ms of [50, 100, 200, 400]) {
|
|
78
|
+
await sensor.setAlsIntegrationTime(ms); // ALS integration time, (milliseconds) → void
|
|
79
|
+
await sleep(ms * 2);
|
|
80
|
+
console.log(`${ms} ms ${alsSensitivity(ms)} lx/count range ${alsMaxRange(ms).toFixed(1)} lx ${(await sensor.readLux()).toFixed(2)} lx`);
|
|
81
|
+
}
|
|
82
|
+
await sensor.setAlsIntegrationTime(50);
|
|
83
|
+
|
|
84
|
+
/* PS resolution and IRED current: 12-bit output saturates at 4095; a
|
|
85
|
+
higher IRED current reaches further but costs current (average = pulse
|
|
86
|
+
current × duty ratio). */
|
|
87
|
+
for (const bits of [12, 16]) {
|
|
88
|
+
await sensor.setPsResolution(bits); // PS resolution, (bits 12/16) → void
|
|
89
|
+
for (const ma of [50, 75, 100, 120, 140, 160, 180, 200]) {
|
|
90
|
+
await sensor.setLedCurrent(ma); // IRED current, (milliamperes) → void
|
|
91
|
+
await sleep(50);
|
|
92
|
+
console.log(`${bits} bit ${ma} mA proximity ${await sensor.readProximity()}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
await sensor.setLedCurrent(50);
|
|
96
|
+
await sensor.setPsDuty(320); // IRED duty, (ratio 160/320/640/1280) → void
|
|
97
|
+
await sensor.setPsIntegrationTime(1.5); // PS integration time, (t) → void
|
|
98
|
+
await sensor.setPsMultiPulse(2); // Multi-pulse, (count 1/2/4/8) → void
|
|
99
|
+
|
|
100
|
+
/* Active force: the PS stays in standby and measures only when
|
|
101
|
+
triggered, the lowest-power way to sample proximity. */
|
|
102
|
+
await sensor.setPsActiveForce(true); // Active-force mode, (on) → void
|
|
103
|
+
for (let i = 0; i < 5; i++) {
|
|
104
|
+
console.log('triggered proximity', await sensor.triggerPs()); // One PS measurement, () → int counts
|
|
105
|
+
await sleep(500);
|
|
106
|
+
}
|
|
107
|
+
await sensor.setPsActiveForce(false);
|
|
108
|
+
|
|
109
|
+
/* Logic output: INT follows the close/away state directly, e.g. to gate
|
|
110
|
+
a backlight without the host. */
|
|
111
|
+
await sensor.setPsLogicOutput(true); // Logic-output mode, (on) → void
|
|
112
|
+
console.log('INT is now a close/away output for 5 s');
|
|
113
|
+
await sleep(5000);
|
|
114
|
+
await sensor.setPsLogicOutput(false);
|
|
115
|
+
|
|
116
|
+
/* Shut down: both sensors stop measuring; the IRED is off. */
|
|
117
|
+
await sensor.psDisable(); // PS off, () → void
|
|
118
|
+
await sensor.alsDisable(); // ALS off, () → void
|
|
119
|
+
await sensor.psEnable(); // PS on, () → void
|
|
120
|
+
await sensor.alsEnable(); // ALS on, () → void
|
|
121
|
+
await sensor.psDisable();
|
|
122
|
+
await sensor.alsDisable();
|
|
123
|
+
console.log('both sensors shut down');
|
|
124
|
+
|
|
125
|
+
await connection.close();
|
|
126
|
+
})();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Minimal example: read proximity and ambient light five times a second
|
|
4
|
+
// (ALS 50 ms, PS 16 bit, duty 1/160, 50 mA IRED).
|
|
5
|
+
|
|
6
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
7
|
+
const { VCNL4200Minimal } = require('periph/src/chips/light/vcnl4200');
|
|
8
|
+
|
|
9
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
10
|
+
|
|
11
|
+
(async () => {
|
|
12
|
+
const bus = parseInt(process.env.I2C_BUS || '1', 10);
|
|
13
|
+
const connection = new I2CConnection(bus, VCNL4200Minimal.I2C_ADDRESS);
|
|
14
|
+
const sensor = new VCNL4200Minimal(connection); // Create VCNL4200 driver, (connection)
|
|
15
|
+
await sensor.init(); // Run initialization sequence, () → void (checks ID, powers on ALS and PS)
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < 50; i++) {
|
|
18
|
+
const proximity = await sensor.readProximity(); // Read proximity, () → int counts
|
|
19
|
+
const lux = await sensor.readLux(); // Read ambient light, () → float lux
|
|
20
|
+
console.log(`proximity ${proximity} ${lux.toFixed(1)} lx`);
|
|
21
|
+
await sleep(200);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
await connection.close();
|
|
25
|
+
})();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { I2CConnection } = require('../../../src/connection/i2c');
|
|
4
|
+
const { SPL06Full } = require('../../../src/chips/pressure/spl06');
|
|
5
|
+
|
|
6
|
+
const I2C_BUS = parseInt(process.env.I2C_BUS || '1', 10);
|
|
7
|
+
const I2C_ADDR = parseInt(process.env.I2C_ADDR || '0x77', 16);
|
|
8
|
+
const sleep = (ms) => new Promise(r => setTimeout(r, ms));
|
|
9
|
+
|
|
10
|
+
const connection = new I2CConnection(I2C_BUS, I2C_ADDR); // Create I²C connection, (bus=1, addr=0x77) → Connection
|
|
11
|
+
// Default address 0x77 (SDO high or open); 0x76 with SDO low.
|
|
12
|
+
const sensor = new SPL06Full(connection); // Create SPL06 driver, (connection) → void
|
|
13
|
+
// Stores the connection only; no bus traffic yet.
|
|
14
|
+
|
|
15
|
+
async function main() {
|
|
16
|
+
await sensor.init(); // Check ID, read coefficients, apply defaults, () → void
|
|
17
|
+
// ID 0x10, waits for COEF_RDY, 16x pressure / 1x external temperature.
|
|
18
|
+
console.log(sensor.coefficients()); // Decoded calibration, () → {c0, c1, c00, c10, c01, c11, c20, c21, c30}
|
|
19
|
+
// The nine factory coefficients used by every compensation.
|
|
20
|
+
console.log(await sensor.read()); // Temperature and pressure, () → {temperature_c °C, pressure_pa Pa}
|
|
21
|
+
// Command mode: one temperature, then one pressure measurement.
|
|
22
|
+
console.log(await sensor.readPressure()); // Pressure, () → number Pa
|
|
23
|
+
// Measures temperature first, because the compensation needs it.
|
|
24
|
+
console.log(await sensor.readTemperature()); // Temperature, () → number °C
|
|
25
|
+
// One temperature measurement only.
|
|
26
|
+
const [praw, traw] = await sensor.readRaw(); // Raw results, () → [praw, traw]
|
|
27
|
+
// Signed 24-bit values from the result registers.
|
|
28
|
+
console.log(sensor.compensate(praw, traw, 16, 1)); // Compensate raw values, (praw, traw, pOversampling, tOversampling) → {temperature_c, pressure_pa}
|
|
29
|
+
// Pure computation with the stored coefficients; no bus access.
|
|
30
|
+
console.log(await sensor.altitude(101325)); // Altitude, (seaLevelPa=101325) → number m
|
|
31
|
+
// International barometric formula against the given sea-level pressure.
|
|
32
|
+
|
|
33
|
+
await sensor.setPressureConfig(64, 4); // Pressure oversampling and rate, (oversampling=16, rate=1) → void
|
|
34
|
+
// 64x oversampling, 4 background readings per second; sets P_SHIFT.
|
|
35
|
+
await sensor.setTemperatureConfig(2, 4); // Temperature oversampling and rate, (oversampling=1, rate=1) → void
|
|
36
|
+
// 2x oversampling, 4 per second; always keeps the external sensor.
|
|
37
|
+
await sensor.startContinuous(true, true); // Background mode, (pressure=true, temperature=true) → void
|
|
38
|
+
// MEAS_CTRL = 111: the chip measures both on its own.
|
|
39
|
+
console.log(await sensor.readContinuous()); // Latest background result, () → {temperature_c, pressure_pa}
|
|
40
|
+
// Waits for both ready flags; does not start a measurement.
|
|
41
|
+
console.log(await sensor.dataReady()); // Ready flags, () → [pressureReady, temperatureReady]
|
|
42
|
+
// MEAS_CFG.PRS_RDY and TMP_RDY.
|
|
43
|
+
await sensor.stop(); // Standby, () → void
|
|
44
|
+
// MEAS_CTRL = 000.
|
|
45
|
+
|
|
46
|
+
await sensor.enableFifo(); // FIFO on, () → void
|
|
47
|
+
// Background results now queue in the 32-entry FIFO.
|
|
48
|
+
await sensor.startContinuous(); // Background mode, (pressure=true, temperature=true) → void
|
|
49
|
+
// Fill the FIFO for a second.
|
|
50
|
+
await sleep(1000);
|
|
51
|
+
await sensor.stop(); // Standby, () → void
|
|
52
|
+
// Stop adding entries.
|
|
53
|
+
console.log(await sensor.fifoStatus()); // FIFO state, () → [empty, full]
|
|
54
|
+
// FIFO_STS flags.
|
|
55
|
+
console.log(await sensor.readFifo()); // Drain FIFO, () → [{kind, value}]
|
|
56
|
+
// "pressure" in Pa or "temperature" in °C, in measured order.
|
|
57
|
+
await sensor.flushFifo(); // Flush FIFO, () → void
|
|
58
|
+
// Discards any remaining entries.
|
|
59
|
+
await sensor.disableFifo(); // FIFO off, () → void
|
|
60
|
+
// Results go to the result registers again.
|
|
61
|
+
|
|
62
|
+
await sensor.enableInterrupt(SPL06Full.SOURCE_PRESSURE); // Enable interrupt source, (source) → void
|
|
63
|
+
// Pressure-ready interrupt on SDO (active low).
|
|
64
|
+
console.log(await sensor.pollInterrupt()); // Read and clear INT_STS, () → number
|
|
65
|
+
// Bitmask of SOURCE_PRESSURE / SOURCE_TEMPERATURE / SOURCE_FIFO_FULL.
|
|
66
|
+
await sensor.onInterrupt((status) => console.log('INT', status)); // Subscribe, (callback, intPin=null) → void
|
|
67
|
+
// Uses the connection's INT pin, or a 5 ms polling timer without one.
|
|
68
|
+
await sensor.read(); // Trigger a measurement, () → {temperature_c, pressure_pa}
|
|
69
|
+
// The pressure result raises the interrupt.
|
|
70
|
+
await sleep(100);
|
|
71
|
+
await sensor.offInterrupt(); // Unsubscribe, () → void
|
|
72
|
+
// Removes this driver's handler only.
|
|
73
|
+
await sensor.disableInterrupt(SPL06Full.SOURCE_PRESSURE); // Disable interrupt source, (source) → void
|
|
74
|
+
// Clears CFG_REG.INT_PRS.
|
|
75
|
+
|
|
76
|
+
await sensor.reset(); // Soft reset, () → void
|
|
77
|
+
// RESET = 0x09, re-reads the coefficients and restores the init defaults.
|
|
78
|
+
await connection.close();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
main().catch(err => { console.error(err); process.exit(1); });
|