periph 1.3.2 → 1.3.3

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.
Files changed (76) hide show
  1. package/README.md +18 -0
  2. package/examples/accelerometer/bma180/complete.js +83 -0
  3. package/examples/accelerometer/bma180/demo.js +47 -0
  4. package/examples/accelerometer/bma180/minimal.js +21 -0
  5. package/examples/accelerometer/fxos8700/complete.js +111 -0
  6. package/examples/accelerometer/fxos8700/demo.js +80 -0
  7. package/examples/accelerometer/fxos8700/minimal.js +20 -0
  8. package/examples/accelerometer/lis3dh/complete.js +123 -0
  9. package/examples/accelerometer/lis3dh/demo.js +99 -0
  10. package/examples/accelerometer/lis3dh/minimal.js +19 -0
  11. package/examples/accelerometer/lsm303/complete.js +82 -0
  12. package/examples/accelerometer/lsm303/demo.js +96 -0
  13. package/examples/accelerometer/lsm303/minimal.js +23 -0
  14. package/examples/accelerometer/mma8451q/complete.js +96 -0
  15. package/examples/accelerometer/mma8451q/demo.js +120 -0
  16. package/examples/accelerometer/mma8451q/minimal.js +20 -0
  17. package/examples/adc_dac/ad5243/complete.js +52 -0
  18. package/examples/adc_dac/ad5243/demo.js +50 -0
  19. package/examples/adc_dac/ad5243/minimal.js +23 -0
  20. package/examples/adc_dac/ad5248/complete.js +49 -0
  21. package/examples/adc_dac/ad5248/demo.js +42 -0
  22. package/examples/adc_dac/ad5248/minimal.js +21 -0
  23. package/examples/adc_dac/ads1013/complete.js +51 -0
  24. package/examples/adc_dac/ads1013/demo.js +51 -0
  25. package/examples/adc_dac/ads1013/minimal.js +21 -0
  26. package/examples/adc_dac/ads1014/complete.js +88 -0
  27. package/examples/adc_dac/ads1014/demo.js +52 -0
  28. package/examples/adc_dac/ads1014/minimal.js +21 -0
  29. package/examples/adc_dac/ads1113/complete.js +47 -0
  30. package/examples/adc_dac/ads1113/demo.js +39 -0
  31. package/examples/adc_dac/ads1113/minimal.js +20 -0
  32. package/examples/adc_dac/ads1114/complete.js +77 -0
  33. package/examples/adc_dac/ads1114/demo.js +47 -0
  34. package/examples/adc_dac/ads1114/minimal.js +20 -0
  35. package/examples/adc_dac/ads1115/complete.js +82 -0
  36. package/examples/adc_dac/ads1115/demo.js +55 -0
  37. package/examples/adc_dac/ads1115/minimal.js +20 -0
  38. package/examples/display/pcf8578/complete.js +58 -0
  39. package/examples/display/pcf8578/demo.js +62 -0
  40. package/examples/display/pcf8578/minimal.js +19 -0
  41. package/examples/display/pcf8579/complete.js +58 -0
  42. package/examples/display/pcf8579/demo.js +61 -0
  43. package/examples/display/pcf8579/minimal.js +19 -0
  44. package/examples/imu/icm20948/complete.js +114 -0
  45. package/examples/imu/icm20948/demo.js +79 -0
  46. package/examples/imu/icm20948/minimal.js +22 -0
  47. package/examples/io_expander/mcp23008/complete.js +70 -0
  48. package/examples/io_expander/mcp23008/demo.js +58 -0
  49. package/examples/io_expander/mcp23008/minimal.js +20 -0
  50. package/examples/memory/mb85rc/complete.js +40 -0
  51. package/examples/memory/mb85rc/demo.js +58 -0
  52. package/examples/memory/mb85rc/minimal.js +15 -0
  53. package/examples/motor/drv2605/complete.js +100 -0
  54. package/examples/motor/drv2605/demo.js +55 -0
  55. package/examples/motor/drv2605/minimal.js +24 -0
  56. package/package.json +1 -1
  57. package/src/chips/accelerometer/bma180.js +573 -0
  58. package/src/chips/accelerometer/fxos8700.js +1600 -0
  59. package/src/chips/accelerometer/lis3dh.js +1341 -0
  60. package/src/chips/accelerometer/lsm303.js +1471 -0
  61. package/src/chips/accelerometer/mma8451q.js +1406 -0
  62. package/src/chips/adc_dac/_ads111x_base.js +272 -0
  63. package/src/chips/adc_dac/ad5243.js +231 -0
  64. package/src/chips/adc_dac/ad5248.js +194 -0
  65. package/src/chips/adc_dac/ads1013.js +219 -0
  66. package/src/chips/adc_dac/ads1014.js +509 -0
  67. package/src/chips/adc_dac/ads1113.js +112 -0
  68. package/src/chips/adc_dac/ads1114.js +201 -0
  69. package/src/chips/adc_dac/ads1115.js +232 -0
  70. package/src/chips/display/pcf8578.js +452 -0
  71. package/src/chips/display/pcf8579.js +451 -0
  72. package/src/chips/imu/icm20948.js +849 -0
  73. package/src/chips/io_expander/mcp23008.js +558 -0
  74. package/src/chips/memory/mb85rc.js +166 -0
  75. package/src/chips/motor/drv2605.js +592 -0
  76. package/src/discovery/registry.js +20 -19
@@ -0,0 +1,201 @@
1
+ 'use strict';
2
+
3
+ const { ADS111xBase, RATES, REG_CONFIG, SOURCE_CONVERSION_READY, SOURCE_COMPARATOR } = require('./_ads111x_base');
4
+
5
+ /**
6
+ * ADS1114 16-bit ΔΣ ADC (one differential input (AIN0 − AIN1), PGA and comparator) — minimal interface.
7
+ *
8
+ * Texas Instruments I²C ADC, four addresses (0x48–0x4B) via the ADDR strap,
9
+ * no ID register. Construction performs no I²C traffic; every conversion
10
+ * writes the full Config word (single-shot, ±2.048 V, 128 SPS defaults) and
11
+ * leaves the chip in power-down. Registers are 16-bit big-endian behind a
12
+ * write-only Address Pointer; the implementation is shared with its siblings
13
+ * in `_ads111x_base`.
14
+ */
15
+ class ADS1114Minimal extends ADS111xBase {
16
+ /**
17
+ * Run a single-shot conversion of AIN0 − AIN1.
18
+ * @returns {Promise<number>} Signed 16-bit code (−32768…32767).
19
+ */
20
+ async readRaw() {
21
+ return this._convert(0);
22
+ }
23
+
24
+ /**
25
+ * Run a single-shot conversion and return volts (raw × 62.5 µV at the default range).
26
+ * @returns {Promise<number>} Voltage AIN0 − AIN1 in V.
27
+ */
28
+ async readVoltage() {
29
+ return (await this.readRaw()) * 0.0000625;
30
+ }
31
+ }
32
+
33
+ /**
34
+ * ADS1114 full interface — extends Minimal with gain, data rate, continuous conversion, status and reset, the comparator, thresholds and the ALERT/RDY interrupt API.
35
+ */
36
+ class ADS1114Full extends ADS1114Minimal {
37
+ /**
38
+ * Run a single-shot conversion and return volts at the current gain.
39
+ * @returns {Promise<number>} Voltage AIN0 − AIN1 in V.
40
+ */
41
+ async readVoltage() {
42
+ return (await this.readRaw()) * this._lsb();
43
+ }
44
+
45
+ /**
46
+ * Start continuous conversion at the current data rate (MODE ← 0).
47
+ * @returns {Promise<void>}
48
+ */
49
+ async startContinuous() {
50
+ await this._startContinuous(0);
51
+ }
52
+
53
+ /**
54
+ * Set the full-scale range used by all following reads. Thresholds are not
55
+ * rescaled — rewrite them after a gain change.
56
+ * @param {number} pga - PGA_6_144 … PGA_0_256 (0–5).
57
+ * @returns {Promise<void>}
58
+ * @throws {RangeError} If pga is outside 0–5 (6 and 7 alias ±0.256 V).
59
+ */
60
+ async setGain(pga) {
61
+ await this._setGain(pga);
62
+ }
63
+
64
+ /** @returns {number} The configured PGA code (0–5). */
65
+ getGain() { return this._pga; }
66
+
67
+ /** @returns {number} ±FSR of the current gain in volts. */
68
+ fullScale() { return this._fullScale(); }
69
+
70
+ /** @returns {number} Size of one code in volts (fullScale() / 32768). */
71
+ lsb() { return this._lsb(); }
72
+
73
+ /**
74
+ * Set the data rate used by all following conversions.
75
+ * @param {number} dr - DR_8 … DR_860 (0–7).
76
+ * @returns {Promise<void>}
77
+ * @throws {RangeError} If dr is outside 0–7.
78
+ */
79
+ async setDataRate(dr) {
80
+ await this._setDataRate(dr);
81
+ }
82
+
83
+ /** @returns {number} The configured DR code (0–7). */
84
+ getDataRate() { return this._dr; }
85
+
86
+ /** @returns {number} The configured data rate in samples per second. */
87
+ dataRateSps() { return RATES[this._dr]; }
88
+
89
+ /**
90
+ * Read the most recent completed result without touching Config.
91
+ * @returns {Promise<number>} Signed 16-bit code.
92
+ */
93
+ async readContinuousRaw() { return this._readContinuousRaw(); }
94
+
95
+ /**
96
+ * Read the most recent continuous result in volts.
97
+ * @returns {Promise<number>} Voltage in V.
98
+ */
99
+ async readContinuous() { return (await this._readContinuousRaw()) * this._lsb(); }
100
+
101
+ /**
102
+ * Return to single-shot / power-down mode (MODE ← 1).
103
+ * @returns {Promise<void>}
104
+ */
105
+ async stopContinuous() { await this._stopContinuous(); }
106
+
107
+ /** @returns {Promise<boolean>} True while CONFIG.OS reads 0 (single-shot mode only). */
108
+ async isConverting() { return this._isConverting(); }
109
+
110
+ /** @returns {Promise<number>} The raw 16-bit CONFIG register. */
111
+ async readConfig() { return this._readReg(REG_CONFIG); }
112
+
113
+ /**
114
+ * Write the reset values back and clear cached settings. Not an I²C general-call reset.
115
+ * @returns {Promise<void>}
116
+ */
117
+ async reset() { await this._reset(true); }
118
+
119
+ /**
120
+ * Configure the comparator and route it to ALERT/RDY.
121
+ * @param {number} [mode=COMP_TRADITIONAL] - COMP_TRADITIONAL or COMP_WINDOW.
122
+ * @param {number} [polarity=ACTIVE_LOW] - ACTIVE_LOW or ACTIVE_HIGH.
123
+ * @param {boolean} [latch=false] - True to latch until clearAlert().
124
+ * @param {number} [queue=QUEUE_1] - QUEUE_1, QUEUE_2 or QUEUE_4 consecutive out-of-range samples.
125
+ * @returns {Promise<void>}
126
+ * @throws {RangeError} On an invalid argument or when the last thresholds have high <= low.
127
+ */
128
+ async configureComparator(mode = 0, polarity = 0, latch = false, queue = 0) {
129
+ await this._configureComparator(mode, polarity, latch, queue);
130
+ }
131
+
132
+ /** Set COMP_QUE to 11; ALERT/RDY becomes high-impedance. @returns {Promise<void>} */
133
+ async disableComparator() { await this._disableComparator(); }
134
+
135
+ /** Write LO_THRESH (signed code, same scale as CONVERSION). @param {number} raw @returns {Promise<void>} */
136
+ async setLowThresholdRaw(raw) { await this._setLowThresholdRaw(raw); }
137
+
138
+ /** Write HI_THRESH (signed code, same scale as CONVERSION). @param {number} raw @returns {Promise<void>} */
139
+ async setHighThresholdRaw(raw) { await this._setHighThresholdRaw(raw); }
140
+
141
+ /**
142
+ * Write both thresholds from volts at the current gain.
143
+ * @param {number} low - Lower threshold in volts.
144
+ * @param {number} high - Upper threshold in volts.
145
+ * @returns {Promise<void>}
146
+ * @throws {RangeError} If high <= low.
147
+ */
148
+ async setThresholds(low, high) { await this._setThresholds(low, high); }
149
+
150
+ /** @returns {Promise<number[]>} [low, high] read back, sign-extended. */
151
+ async getThresholdsRaw() { return this._getThresholdsRaw(); }
152
+
153
+ /** Read CONVERSION to release a latched comparator output. @returns {Promise<void>} */
154
+ async clearAlert() { await this._clearAlert(); }
155
+
156
+ /**
157
+ * Route one source to ALERT/RDY (the other is disabled).
158
+ * @param {number} source - SOURCE_CONVERSION_READY or SOURCE_COMPARATOR.
159
+ * @returns {Promise<void>}
160
+ */
161
+ async enableInterrupt(source) { await this._enableInterrupt(source); }
162
+
163
+ /** Release ALERT/RDY (COMP_QUE ← 11). @param {number} source @returns {Promise<void>} */
164
+ async disableInterrupt(source) { await this._disableComparator(); }
165
+
166
+ /**
167
+ * Return the enabled source constant if ALERT/RDY is asserted, else 0.
168
+ * Samples `connection.intPin` when present; without a pin
169
+ * SOURCE_CONVERSION_READY falls back to CONFIG.OS (single-shot only). A
170
+ * latched comparator alert is cleared by reading CONVERSION.
171
+ * @returns {Promise<number>}
172
+ */
173
+ async pollInterrupt() { return this._pollInterrupt(); }
174
+
175
+ /**
176
+ * Subscribe to ALERT/RDY events: `connection.intPin` edges when wired,
177
+ * otherwise a 5 ms polling loop that calls back when the status changes.
178
+ * @param {function(number): void} callback - Receives the pollInterrupt() value.
179
+ * @returns {Promise<void>}
180
+ */
181
+ async onInterrupt(callback) { await this._onInterrupt(callback); }
182
+
183
+ /** Unsubscribe and stop delivery. @returns {Promise<void>} */
184
+ async offInterrupt() { await this._offInterrupt(); }
185
+ }
186
+
187
+ /** Default 7-bit I²C address (ADDR = GND). Valid range 0x48–0x4B. */
188
+ ADS1114Minimal.I2C_ADDRESS = 0x48;
189
+
190
+ /** Data-rate codes (DR[2:0]). */
191
+ Object.assign(ADS1114Full, { DR_8: 0, DR_16: 1, DR_32: 2, DR_64: 3, DR_128: 4, DR_250: 5, DR_475: 6, DR_860: 7 });
192
+
193
+ /** Full-scale range codes (PGA[2:0]). */
194
+ Object.assign(ADS1114Full, { PGA_6_144: 0, PGA_4_096: 1, PGA_2_048: 2, PGA_1_024: 3, PGA_0_512: 4, PGA_0_256: 5 });
195
+
196
+ /** Comparator mode, polarity, queue and interrupt-source values. */
197
+ Object.assign(ADS1114Full, { COMP_TRADITIONAL: 0, COMP_WINDOW: 1, ACTIVE_LOW: 0, ACTIVE_HIGH: 1,
198
+ QUEUE_1: 0, QUEUE_2: 1, QUEUE_4: 2,
199
+ SOURCE_CONVERSION_READY, SOURCE_COMPARATOR });
200
+
201
+ module.exports = { ADS1114Minimal, ADS1114Full };
@@ -0,0 +1,232 @@
1
+ 'use strict';
2
+
3
+ const { ADS111xBase, RATES, REG_CONFIG, SOURCE_CONVERSION_READY, SOURCE_COMPARATOR } = require('./_ads111x_base');
4
+
5
+ /**
6
+ * ADS1115 16-bit ΔΣ ADC (four-channel multiplexer, PGA and comparator) — minimal interface.
7
+ *
8
+ * Texas Instruments I²C ADC, four addresses (0x48–0x4B) via the ADDR strap,
9
+ * no ID register. Construction performs no I²C traffic; every conversion
10
+ * writes the full Config word (single-shot, ±2.048 V, 128 SPS defaults) and
11
+ * leaves the chip in power-down. Registers are 16-bit big-endian behind a
12
+ * write-only Address Pointer; the implementation is shared with its siblings
13
+ * in `_ads111x_base`.
14
+ */
15
+ class ADS1115Minimal extends ADS111xBase {
16
+ /**
17
+ * Run a single-shot conversion of AIN<channel> against GND.
18
+ * @param {number} [channel=0] - Input 0–3 (clamped).
19
+ * @returns {Promise<number>} Signed 16-bit code (−32768…32767).
20
+ */
21
+ async readRaw(channel = 0) {
22
+ const ch = Math.max(0, Math.min(3, channel));
23
+ return this._convert(4 + ch);
24
+ }
25
+
26
+ /**
27
+ * Run a single-shot conversion and return volts (raw × 62.5 µV at the default range).
28
+ * @param {number} [channel=0] - Input 0–3 (clamped).
29
+ * @returns {Promise<number>} Voltage in V.
30
+ */
31
+ async readVoltage(channel = 0) {
32
+ return (await this.readRaw(channel)) * 0.0000625;
33
+ }
34
+ }
35
+
36
+ /**
37
+ * ADS1115 full interface — extends Minimal with gain, data rate, differential reads, continuous conversion, status and reset, the comparator, thresholds and the ALERT/RDY interrupt API.
38
+ */
39
+ class ADS1115Full extends ADS1115Minimal {
40
+ /**
41
+ * Run a single-shot conversion of AIN<channel> and return volts at the current gain.
42
+ * @param {number} [channel=0] - Input 0–3 (clamped).
43
+ * @returns {Promise<number>} Voltage in V.
44
+ */
45
+ async readVoltage(channel = 0) {
46
+ return (await this.readRaw(channel)) * this._lsb();
47
+ }
48
+
49
+ /**
50
+ * Single-shot signed differential conversion.
51
+ * @param {number} pair - DIFF_0_1, DIFF_0_3, DIFF_1_3 or DIFF_2_3.
52
+ * @returns {Promise<number>} Signed 16-bit code.
53
+ * @throws {RangeError} If pair is outside 0–3.
54
+ */
55
+ async readDifferentialRaw(pair) {
56
+ if (!Number.isInteger(pair) || pair < 0 || pair > 3) throw new RangeError('pair must be 0-3');
57
+ return this._convert(pair);
58
+ }
59
+
60
+ /**
61
+ * Single-shot differential conversion in volts (raw × lsb()).
62
+ * @param {number} pair - DIFF_0_1 … DIFF_2_3.
63
+ * @returns {Promise<number>} Voltage in V.
64
+ */
65
+ async readDifferential(pair) {
66
+ return (await this.readDifferentialRaw(pair)) * this._lsb();
67
+ }
68
+
69
+ /**
70
+ * Start continuous conversion on any MUX code (MODE ← 0).
71
+ * @param {number} [mux=4] - MUX_AIN0_GND … MUX_AIN3_GND or a differential MUX_* code (0–7).
72
+ * @returns {Promise<void>}
73
+ * @throws {RangeError} If mux is outside 0–7.
74
+ */
75
+ async startContinuous(mux = ADS1115Full.MUX_AIN0_GND) {
76
+ await this._startContinuous(mux);
77
+ }
78
+
79
+ /**
80
+ * Set the full-scale range used by all following reads. Thresholds are not
81
+ * rescaled — rewrite them after a gain change.
82
+ * @param {number} pga - PGA_6_144 … PGA_0_256 (0–5).
83
+ * @returns {Promise<void>}
84
+ * @throws {RangeError} If pga is outside 0–5 (6 and 7 alias ±0.256 V).
85
+ */
86
+ async setGain(pga) {
87
+ await this._setGain(pga);
88
+ }
89
+
90
+ /** @returns {number} The configured PGA code (0–5). */
91
+ getGain() { return this._pga; }
92
+
93
+ /** @returns {number} ±FSR of the current gain in volts. */
94
+ fullScale() { return this._fullScale(); }
95
+
96
+ /** @returns {number} Size of one code in volts (fullScale() / 32768). */
97
+ lsb() { return this._lsb(); }
98
+
99
+ /**
100
+ * Set the data rate used by all following conversions.
101
+ * @param {number} dr - DR_8 … DR_860 (0–7).
102
+ * @returns {Promise<void>}
103
+ * @throws {RangeError} If dr is outside 0–7.
104
+ */
105
+ async setDataRate(dr) {
106
+ await this._setDataRate(dr);
107
+ }
108
+
109
+ /** @returns {number} The configured DR code (0–7). */
110
+ getDataRate() { return this._dr; }
111
+
112
+ /** @returns {number} The configured data rate in samples per second. */
113
+ dataRateSps() { return RATES[this._dr]; }
114
+
115
+ /**
116
+ * Read the most recent completed result without touching Config.
117
+ * @returns {Promise<number>} Signed 16-bit code.
118
+ */
119
+ async readContinuousRaw() { return this._readContinuousRaw(); }
120
+
121
+ /**
122
+ * Read the most recent continuous result in volts.
123
+ * @returns {Promise<number>} Voltage in V.
124
+ */
125
+ async readContinuous() { return (await this._readContinuousRaw()) * this._lsb(); }
126
+
127
+ /**
128
+ * Return to single-shot / power-down mode (MODE ← 1).
129
+ * @returns {Promise<void>}
130
+ */
131
+ async stopContinuous() { await this._stopContinuous(); }
132
+
133
+ /** @returns {Promise<boolean>} True while CONFIG.OS reads 0 (single-shot mode only). */
134
+ async isConverting() { return this._isConverting(); }
135
+
136
+ /** @returns {Promise<number>} The raw 16-bit CONFIG register. */
137
+ async readConfig() { return this._readReg(REG_CONFIG); }
138
+
139
+ /**
140
+ * Write the reset values back and clear cached settings. Not an I²C general-call reset.
141
+ * @returns {Promise<void>}
142
+ */
143
+ async reset() { await this._reset(true); }
144
+
145
+ /**
146
+ * Configure the comparator and route it to ALERT/RDY.
147
+ * @param {number} [mode=COMP_TRADITIONAL] - COMP_TRADITIONAL or COMP_WINDOW.
148
+ * @param {number} [polarity=ACTIVE_LOW] - ACTIVE_LOW or ACTIVE_HIGH.
149
+ * @param {boolean} [latch=false] - True to latch until clearAlert().
150
+ * @param {number} [queue=QUEUE_1] - QUEUE_1, QUEUE_2 or QUEUE_4 consecutive out-of-range samples.
151
+ * @returns {Promise<void>}
152
+ * @throws {RangeError} On an invalid argument or when the last thresholds have high <= low.
153
+ */
154
+ async configureComparator(mode = 0, polarity = 0, latch = false, queue = 0) {
155
+ await this._configureComparator(mode, polarity, latch, queue);
156
+ }
157
+
158
+ /** Set COMP_QUE to 11; ALERT/RDY becomes high-impedance. @returns {Promise<void>} */
159
+ async disableComparator() { await this._disableComparator(); }
160
+
161
+ /** Write LO_THRESH (signed code, same scale as CONVERSION). @param {number} raw @returns {Promise<void>} */
162
+ async setLowThresholdRaw(raw) { await this._setLowThresholdRaw(raw); }
163
+
164
+ /** Write HI_THRESH (signed code, same scale as CONVERSION). @param {number} raw @returns {Promise<void>} */
165
+ async setHighThresholdRaw(raw) { await this._setHighThresholdRaw(raw); }
166
+
167
+ /**
168
+ * Write both thresholds from volts at the current gain.
169
+ * @param {number} low - Lower threshold in volts.
170
+ * @param {number} high - Upper threshold in volts.
171
+ * @returns {Promise<void>}
172
+ * @throws {RangeError} If high <= low.
173
+ */
174
+ async setThresholds(low, high) { await this._setThresholds(low, high); }
175
+
176
+ /** @returns {Promise<number[]>} [low, high] read back, sign-extended. */
177
+ async getThresholdsRaw() { return this._getThresholdsRaw(); }
178
+
179
+ /** Read CONVERSION to release a latched comparator output. @returns {Promise<void>} */
180
+ async clearAlert() { await this._clearAlert(); }
181
+
182
+ /**
183
+ * Route one source to ALERT/RDY (the other is disabled).
184
+ * @param {number} source - SOURCE_CONVERSION_READY or SOURCE_COMPARATOR.
185
+ * @returns {Promise<void>}
186
+ */
187
+ async enableInterrupt(source) { await this._enableInterrupt(source); }
188
+
189
+ /** Release ALERT/RDY (COMP_QUE ← 11). @param {number} source @returns {Promise<void>} */
190
+ async disableInterrupt(source) { await this._disableComparator(); }
191
+
192
+ /**
193
+ * Return the enabled source constant if ALERT/RDY is asserted, else 0.
194
+ * Samples `connection.intPin` when present; without a pin
195
+ * SOURCE_CONVERSION_READY falls back to CONFIG.OS (single-shot only). A
196
+ * latched comparator alert is cleared by reading CONVERSION.
197
+ * @returns {Promise<number>}
198
+ */
199
+ async pollInterrupt() { return this._pollInterrupt(); }
200
+
201
+ /**
202
+ * Subscribe to ALERT/RDY events: `connection.intPin` edges when wired,
203
+ * otherwise a 5 ms polling loop that calls back when the status changes.
204
+ * @param {function(number): void} callback - Receives the pollInterrupt() value.
205
+ * @returns {Promise<void>}
206
+ */
207
+ async onInterrupt(callback) { await this._onInterrupt(callback); }
208
+
209
+ /** Unsubscribe and stop delivery. @returns {Promise<void>} */
210
+ async offInterrupt() { await this._offInterrupt(); }
211
+ }
212
+
213
+ /** Default 7-bit I²C address (ADDR = GND). Valid range 0x48–0x4B. */
214
+ ADS1115Minimal.I2C_ADDRESS = 0x48;
215
+
216
+ /** Data-rate codes (DR[2:0]). */
217
+ Object.assign(ADS1115Full, { DR_8: 0, DR_16: 1, DR_32: 2, DR_64: 3, DR_128: 4, DR_250: 5, DR_475: 6, DR_860: 7 });
218
+
219
+ /** Full-scale range codes (PGA[2:0]). */
220
+ Object.assign(ADS1115Full, { PGA_6_144: 0, PGA_4_096: 1, PGA_2_048: 2, PGA_1_024: 3, PGA_0_512: 4, PGA_0_256: 5 });
221
+
222
+ /** Differential pairs and MUX codes. */
223
+ Object.assign(ADS1115Full, { DIFF_0_1: 0, DIFF_0_3: 1, DIFF_1_3: 2, DIFF_2_3: 3,
224
+ MUX_AIN0_AIN1: 0, MUX_AIN0_AIN3: 1, MUX_AIN1_AIN3: 2, MUX_AIN2_AIN3: 3,
225
+ MUX_AIN0_GND: 4, MUX_AIN1_GND: 5, MUX_AIN2_GND: 6, MUX_AIN3_GND: 7 });
226
+
227
+ /** Comparator mode, polarity, queue and interrupt-source values. */
228
+ Object.assign(ADS1115Full, { COMP_TRADITIONAL: 0, COMP_WINDOW: 1, ACTIVE_LOW: 0, ACTIVE_HIGH: 1,
229
+ QUEUE_1: 0, QUEUE_2: 1, QUEUE_4: 2,
230
+ SOURCE_CONVERSION_READY, SOURCE_COMPARATOR });
231
+
232
+ module.exports = { ADS1115Minimal, ADS1115Full };