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.
- package/README.md +18 -0
- package/examples/accelerometer/bma180/complete.js +83 -0
- package/examples/accelerometer/bma180/demo.js +47 -0
- package/examples/accelerometer/bma180/minimal.js +21 -0
- package/examples/accelerometer/fxos8700/complete.js +111 -0
- package/examples/accelerometer/fxos8700/demo.js +80 -0
- package/examples/accelerometer/fxos8700/minimal.js +20 -0
- package/examples/accelerometer/lis3dh/complete.js +123 -0
- package/examples/accelerometer/lis3dh/demo.js +99 -0
- package/examples/accelerometer/lis3dh/minimal.js +19 -0
- package/examples/accelerometer/lsm303/complete.js +82 -0
- package/examples/accelerometer/lsm303/demo.js +96 -0
- package/examples/accelerometer/lsm303/minimal.js +23 -0
- package/examples/accelerometer/mma8451q/complete.js +96 -0
- package/examples/accelerometer/mma8451q/demo.js +120 -0
- package/examples/accelerometer/mma8451q/minimal.js +20 -0
- package/examples/adc_dac/ad5243/complete.js +52 -0
- package/examples/adc_dac/ad5243/demo.js +50 -0
- package/examples/adc_dac/ad5243/minimal.js +23 -0
- package/examples/adc_dac/ad5248/complete.js +49 -0
- package/examples/adc_dac/ad5248/demo.js +42 -0
- package/examples/adc_dac/ad5248/minimal.js +21 -0
- package/examples/adc_dac/ads1013/complete.js +51 -0
- package/examples/adc_dac/ads1013/demo.js +51 -0
- package/examples/adc_dac/ads1013/minimal.js +21 -0
- package/examples/adc_dac/ads1014/complete.js +88 -0
- package/examples/adc_dac/ads1014/demo.js +52 -0
- package/examples/adc_dac/ads1014/minimal.js +21 -0
- package/examples/adc_dac/ads1113/complete.js +47 -0
- package/examples/adc_dac/ads1113/demo.js +39 -0
- package/examples/adc_dac/ads1113/minimal.js +20 -0
- package/examples/adc_dac/ads1114/complete.js +77 -0
- package/examples/adc_dac/ads1114/demo.js +47 -0
- package/examples/adc_dac/ads1114/minimal.js +20 -0
- package/examples/adc_dac/ads1115/complete.js +82 -0
- package/examples/adc_dac/ads1115/demo.js +55 -0
- package/examples/adc_dac/ads1115/minimal.js +20 -0
- package/examples/display/pcf8578/complete.js +58 -0
- package/examples/display/pcf8578/demo.js +62 -0
- package/examples/display/pcf8578/minimal.js +19 -0
- package/examples/display/pcf8579/complete.js +58 -0
- package/examples/display/pcf8579/demo.js +61 -0
- package/examples/display/pcf8579/minimal.js +19 -0
- package/examples/imu/icm20948/complete.js +114 -0
- package/examples/imu/icm20948/demo.js +79 -0
- package/examples/imu/icm20948/minimal.js +22 -0
- package/examples/io_expander/mcp23008/complete.js +70 -0
- package/examples/io_expander/mcp23008/demo.js +58 -0
- package/examples/io_expander/mcp23008/minimal.js +20 -0
- package/examples/memory/mb85rc/complete.js +40 -0
- package/examples/memory/mb85rc/demo.js +58 -0
- package/examples/memory/mb85rc/minimal.js +15 -0
- package/examples/motor/drv2605/complete.js +100 -0
- package/examples/motor/drv2605/demo.js +55 -0
- package/examples/motor/drv2605/minimal.js +24 -0
- package/package.json +1 -1
- package/src/chips/accelerometer/bma180.js +573 -0
- package/src/chips/accelerometer/fxos8700.js +1600 -0
- package/src/chips/accelerometer/lis3dh.js +1341 -0
- package/src/chips/accelerometer/lsm303.js +1471 -0
- package/src/chips/accelerometer/mma8451q.js +1406 -0
- package/src/chips/adc_dac/_ads111x_base.js +272 -0
- package/src/chips/adc_dac/ad5243.js +231 -0
- package/src/chips/adc_dac/ad5248.js +194 -0
- package/src/chips/adc_dac/ads1013.js +219 -0
- package/src/chips/adc_dac/ads1014.js +509 -0
- package/src/chips/adc_dac/ads1113.js +112 -0
- package/src/chips/adc_dac/ads1114.js +201 -0
- package/src/chips/adc_dac/ads1115.js +232 -0
- package/src/chips/display/pcf8578.js +452 -0
- package/src/chips/display/pcf8579.js +451 -0
- package/src/chips/imu/icm20948.js +849 -0
- package/src/chips/io_expander/mcp23008.js +558 -0
- package/src/chips/memory/mb85rc.js +166 -0
- package/src/chips/motor/drv2605.js +592 -0
- package/src/discovery/registry.js +20 -19
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
4
|
+
const { ADS1114Full } = require('periph/src/chips/adc_dac/ads1114');
|
|
5
|
+
|
|
6
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
7
|
+
|
|
8
|
+
(async () => {
|
|
9
|
+
const bus = parseInt(process.env.I2C_BUS || '1', 10);
|
|
10
|
+
const connection = new I2CConnection(bus, ADS1114Full.I2C_ADDRESS);
|
|
11
|
+
const adc = new ADS1114Full(connection); // Create ADS1114 Full driver, (connection)
|
|
12
|
+
// no I²C traffic; Config word is rebuilt per conversion
|
|
13
|
+
const raw = await adc.readRaw(); // Read raw code, () → number
|
|
14
|
+
// single-shot conversion, signed 16-bit
|
|
15
|
+
const v = await adc.readVoltage(); // Read voltage, () → number V
|
|
16
|
+
// raw × lsb()
|
|
17
|
+
console.log(`raw ${raw} voltage ${v.toFixed(5)} V`);
|
|
18
|
+
await adc.setGain(ADS1114Full.PGA_4_096); // Set gain, (pga 0–5) → None
|
|
19
|
+
// ±4.096 V full scale
|
|
20
|
+
console.log(`gain ${adc.getGain()}`);
|
|
21
|
+
const fs = adc.fullScale(); // Full scale, () → number V
|
|
22
|
+
// ±FSR of the current gain
|
|
23
|
+
const lsb = adc.lsb(); // LSB, () → number V
|
|
24
|
+
// fullScale() / 32768
|
|
25
|
+
console.log(`full scale ${fs} V, lsb ${lsb} V`);
|
|
26
|
+
await adc.setDataRate(ADS1114Full.DR_250); // Set data rate, (dr 0–7) → None
|
|
27
|
+
// DR field of the Config word
|
|
28
|
+
const sps = adc.dataRateSps(); // Data rate, () → number SPS
|
|
29
|
+
// samples per second of the current setting
|
|
30
|
+
console.log(`rate ${adc.getDataRate()} = ${sps} SPS`);
|
|
31
|
+
await adc.startContinuous(); // Start continuous, () → None
|
|
32
|
+
// MODE ← 0
|
|
33
|
+
await sleep(50);
|
|
34
|
+
const craw = await adc.readContinuousRaw(); // Read continuous raw, () → number
|
|
35
|
+
// CONVERSION without touching Config
|
|
36
|
+
const cv = await adc.readContinuous(); // Read continuous, () → number V
|
|
37
|
+
// readContinuousRaw() × lsb()
|
|
38
|
+
console.log(`continuous ${craw} ${cv.toFixed(5)} V`);
|
|
39
|
+
await adc.stopContinuous(); // Stop continuous, () → None
|
|
40
|
+
// MODE ← 1
|
|
41
|
+
const busy = await adc.isConverting(); // Check conversion, () → boolean
|
|
42
|
+
// CONFIG.OS == 0
|
|
43
|
+
const cfg = await adc.readConfig(); // Read CONFIG, () → number
|
|
44
|
+
// raw 16-bit register
|
|
45
|
+
console.log(`converting ${busy}, config 0x${cfg.toString(16)}`);
|
|
46
|
+
await adc.setThresholds(0.5, 3.0); // Set thresholds, (low V, high V) → None
|
|
47
|
+
// converted with the current lsb(), clamped
|
|
48
|
+
await adc.setLowThresholdRaw(4000); // Set low threshold, (raw) → None
|
|
49
|
+
// LO_THRESH ← raw & 0xFFFF
|
|
50
|
+
await adc.setHighThresholdRaw(20000); // Set high threshold, (raw) → None
|
|
51
|
+
// HI_THRESH ← raw & 0xFFFF
|
|
52
|
+
const [lo, hi] = await adc.getThresholdsRaw(); // Get thresholds, () → [number, number]
|
|
53
|
+
// read back, sign-extended
|
|
54
|
+
console.log(`thresholds ${lo} ${hi}`);
|
|
55
|
+
await adc.configureComparator(ADS1114Full.COMP_WINDOW, ADS1114Full.ACTIVE_LOW, true, ADS1114Full.QUEUE_2);// Configure comparator, (mode, polarity, latch=false, queue=QUEUE_1) → None
|
|
56
|
+
// window mode, latching, 2-sample queue
|
|
57
|
+
await adc.clearAlert(); // Clear alert, () → None
|
|
58
|
+
// reads CONVERSION to release the latch
|
|
59
|
+
await adc.disableComparator(); // Disable comparator, () → None
|
|
60
|
+
// COMP_QUE ← 11
|
|
61
|
+
await adc.enableInterrupt(ADS1114Full.SOURCE_CONVERSION_READY); // Enable interrupt, (source) → None
|
|
62
|
+
// ALERT/RDY signals conversion-ready
|
|
63
|
+
const status = await adc.pollInterrupt(); // Poll interrupt, () → number source
|
|
64
|
+
// enabled source if ALERT/RDY is asserted
|
|
65
|
+
console.log(`poll ${status}`);
|
|
66
|
+
await adc.onInterrupt((s) => console.log(`alert ${s}`)); // Subscribe, (callback) → None
|
|
67
|
+
// pin edge, or a polling loop without an InputPin
|
|
68
|
+
await sleep(1000);
|
|
69
|
+
await adc.offInterrupt(); // Unsubscribe, () → None
|
|
70
|
+
// stops delivery
|
|
71
|
+
await adc.disableInterrupt(ADS1114Full.SOURCE_CONVERSION_READY); // Disable interrupt, (source) → None
|
|
72
|
+
// releases ALERT/RDY
|
|
73
|
+
await adc.reset(); // Reset, () → None
|
|
74
|
+
// writes the reset values back
|
|
75
|
+
|
|
76
|
+
await connection.close();
|
|
77
|
+
})();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
4
|
+
const { ADS1114Full } = require('periph/src/chips/adc_dac/ads1114');
|
|
5
|
+
|
|
6
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
7
|
+
|
|
8
|
+
(async () => {
|
|
9
|
+
const bus = parseInt(process.env.I2C_BUS || '1', 10);
|
|
10
|
+
const connection = new I2CConnection(bus, ADS1114Full.I2C_ADDRESS);
|
|
11
|
+
const adc = new ADS1114Full(connection); // Create ADS1114 Full driver, (connection)
|
|
12
|
+
|
|
13
|
+
// --- Configure the converter ---
|
|
14
|
+
// ±4.096 V covers a 3.3 V rail with headroom; 250 SPS keeps single-shot
|
|
15
|
+
// reads short while still averaging out most noise.
|
|
16
|
+
await adc.setGain(ADS1114Full.PGA_4_096); // Set gain, (pga 0–5) → None
|
|
17
|
+
await adc.setDataRate(ADS1114Full.DR_250); // Set data rate, (dr 0–7) → None
|
|
18
|
+
|
|
19
|
+
// --- Read the inputs ---
|
|
20
|
+
// Single-shot mode powers the chip down between conversions.
|
|
21
|
+
for (let i = 0; i < 3; i++) {
|
|
22
|
+
const raw = await adc.readRaw(); // Read raw code, () → number
|
|
23
|
+
console.log(`raw ${raw} ${(raw * adc.lsb()).toFixed(5)} V`);
|
|
24
|
+
await sleep(1000);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// --- Arm a window comparator ---
|
|
28
|
+
// ALERT/RDY asserts when the input leaves 0.5 V ... 3.0 V for two
|
|
29
|
+
// consecutive conversions; the latch holds it until clearAlert().
|
|
30
|
+
await adc.setThresholds(0.5, 3.0); // Set thresholds, (low V, high V) → None
|
|
31
|
+
await adc.configureComparator(ADS1114Full.COMP_WINDOW, ADS1114Full.ACTIVE_LOW, true, ADS1114Full.QUEUE_2);// Configure comparator, (mode, polarity, latch=false, queue=QUEUE_1) → None
|
|
32
|
+
await adc.startContinuous(); // Start continuous, () → None
|
|
33
|
+
|
|
34
|
+
// --- Report out-of-range events ---
|
|
35
|
+
// With an InputPin on ALERT/RDY the callback fires on the edge; without
|
|
36
|
+
// one the driver polls the register every 5 ms.
|
|
37
|
+
await adc.onInterrupt(async () => { // Subscribe, (callback) → None
|
|
38
|
+
console.log('OUT OF RANGE');
|
|
39
|
+
await adc.clearAlert(); // Clear alert, () → None
|
|
40
|
+
});
|
|
41
|
+
await sleep(10000);
|
|
42
|
+
await adc.offInterrupt(); // Unsubscribe, () → None
|
|
43
|
+
await adc.disableComparator(); // Disable comparator, () → None
|
|
44
|
+
await adc.stopContinuous(); // Stop continuous, () → None
|
|
45
|
+
|
|
46
|
+
await connection.close();
|
|
47
|
+
})();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
4
|
+
const { ADS1114Minimal } = require('periph/src/chips/adc_dac/ads1114');
|
|
5
|
+
|
|
6
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
7
|
+
|
|
8
|
+
(async () => {
|
|
9
|
+
const bus = parseInt(process.env.I2C_BUS || '1', 10);
|
|
10
|
+
const connection = new I2CConnection(bus, ADS1114Minimal.I2C_ADDRESS);
|
|
11
|
+
const adc = new ADS1114Minimal(connection); // Create ADS1114 driver, (connection)
|
|
12
|
+
|
|
13
|
+
for (let i = 0; i < 10; i++) {
|
|
14
|
+
const v = await adc.readVoltage(); // Read voltage, () → number V
|
|
15
|
+
console.log(`${v.toFixed(5)} V`);
|
|
16
|
+
await sleep(1000);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
await connection.close();
|
|
20
|
+
})();
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
4
|
+
const { ADS1115Full } = require('periph/src/chips/adc_dac/ads1115');
|
|
5
|
+
|
|
6
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
7
|
+
|
|
8
|
+
(async () => {
|
|
9
|
+
const bus = parseInt(process.env.I2C_BUS || '1', 10);
|
|
10
|
+
const connection = new I2CConnection(bus, ADS1115Full.I2C_ADDRESS);
|
|
11
|
+
const adc = new ADS1115Full(connection); // Create ADS1115 Full driver, (connection)
|
|
12
|
+
// no I²C traffic; Config word is rebuilt per conversion
|
|
13
|
+
const raw = await adc.readRaw(2); // Read raw code, (channel=0) → number
|
|
14
|
+
// single-shot conversion, signed 16-bit
|
|
15
|
+
const v = await adc.readVoltage(2); // Read voltage, (channel=0) → number V
|
|
16
|
+
// raw × lsb()
|
|
17
|
+
console.log(`raw ${raw} voltage ${v.toFixed(5)} V`);
|
|
18
|
+
await adc.setGain(ADS1115Full.PGA_4_096); // Set gain, (pga 0–5) → None
|
|
19
|
+
// ±4.096 V full scale
|
|
20
|
+
console.log(`gain ${adc.getGain()}`);
|
|
21
|
+
const fs = adc.fullScale(); // Full scale, () → number V
|
|
22
|
+
// ±FSR of the current gain
|
|
23
|
+
const lsb = adc.lsb(); // LSB, () → number V
|
|
24
|
+
// fullScale() / 32768
|
|
25
|
+
console.log(`full scale ${fs} V, lsb ${lsb} V`);
|
|
26
|
+
await adc.setDataRate(ADS1115Full.DR_250); // Set data rate, (dr 0–7) → None
|
|
27
|
+
// DR field of the Config word
|
|
28
|
+
const sps = adc.dataRateSps(); // Data rate, () → number SPS
|
|
29
|
+
// samples per second of the current setting
|
|
30
|
+
console.log(`rate ${adc.getDataRate()} = ${sps} SPS`);
|
|
31
|
+
const d = await adc.readDifferential(ADS1115Full.DIFF_2_3); // Read differential, (pair 0–3) → number V
|
|
32
|
+
// single-shot MUX = pair
|
|
33
|
+
const draw = await adc.readDifferentialRaw(ADS1115Full.DIFF_0_1); // Read differential raw, (pair 0–3) → number
|
|
34
|
+
// signed 16-bit code
|
|
35
|
+
console.log(`differential ${d.toFixed(6)} V, raw ${draw}`);
|
|
36
|
+
await adc.startContinuous(ADS1115Full.MUX_AIN0_GND); // Start continuous, (mux=MUX_AIN0_GND 0–7) → None
|
|
37
|
+
// MODE ← 0
|
|
38
|
+
await sleep(50);
|
|
39
|
+
const craw = await adc.readContinuousRaw(); // Read continuous raw, () → number
|
|
40
|
+
// CONVERSION without touching Config
|
|
41
|
+
const cv = await adc.readContinuous(); // Read continuous, () → number V
|
|
42
|
+
// readContinuousRaw() × lsb()
|
|
43
|
+
console.log(`continuous ${craw} ${cv.toFixed(5)} V`);
|
|
44
|
+
await adc.stopContinuous(); // Stop continuous, () → None
|
|
45
|
+
// MODE ← 1
|
|
46
|
+
const busy = await adc.isConverting(); // Check conversion, () → boolean
|
|
47
|
+
// CONFIG.OS == 0
|
|
48
|
+
const cfg = await adc.readConfig(); // Read CONFIG, () → number
|
|
49
|
+
// raw 16-bit register
|
|
50
|
+
console.log(`converting ${busy}, config 0x${cfg.toString(16)}`);
|
|
51
|
+
await adc.setThresholds(0.5, 3.0); // Set thresholds, (low V, high V) → None
|
|
52
|
+
// converted with the current lsb(), clamped
|
|
53
|
+
await adc.setLowThresholdRaw(4000); // Set low threshold, (raw) → None
|
|
54
|
+
// LO_THRESH ← raw & 0xFFFF
|
|
55
|
+
await adc.setHighThresholdRaw(20000); // Set high threshold, (raw) → None
|
|
56
|
+
// HI_THRESH ← raw & 0xFFFF
|
|
57
|
+
const [lo, hi] = await adc.getThresholdsRaw(); // Get thresholds, () → [number, number]
|
|
58
|
+
// read back, sign-extended
|
|
59
|
+
console.log(`thresholds ${lo} ${hi}`);
|
|
60
|
+
await adc.configureComparator(ADS1115Full.COMP_WINDOW, ADS1115Full.ACTIVE_LOW, true, ADS1115Full.QUEUE_2);// Configure comparator, (mode, polarity, latch=false, queue=QUEUE_1) → None
|
|
61
|
+
// window mode, latching, 2-sample queue
|
|
62
|
+
await adc.clearAlert(); // Clear alert, () → None
|
|
63
|
+
// reads CONVERSION to release the latch
|
|
64
|
+
await adc.disableComparator(); // Disable comparator, () → None
|
|
65
|
+
// COMP_QUE ← 11
|
|
66
|
+
await adc.enableInterrupt(ADS1115Full.SOURCE_CONVERSION_READY); // Enable interrupt, (source) → None
|
|
67
|
+
// ALERT/RDY signals conversion-ready
|
|
68
|
+
const status = await adc.pollInterrupt(); // Poll interrupt, () → number source
|
|
69
|
+
// enabled source if ALERT/RDY is asserted
|
|
70
|
+
console.log(`poll ${status}`);
|
|
71
|
+
await adc.onInterrupt((s) => console.log(`alert ${s}`)); // Subscribe, (callback) → None
|
|
72
|
+
// pin edge, or a polling loop without an InputPin
|
|
73
|
+
await sleep(1000);
|
|
74
|
+
await adc.offInterrupt(); // Unsubscribe, () → None
|
|
75
|
+
// stops delivery
|
|
76
|
+
await adc.disableInterrupt(ADS1115Full.SOURCE_CONVERSION_READY); // Disable interrupt, (source) → None
|
|
77
|
+
// releases ALERT/RDY
|
|
78
|
+
await adc.reset(); // Reset, () → None
|
|
79
|
+
// writes the reset values back
|
|
80
|
+
|
|
81
|
+
await connection.close();
|
|
82
|
+
})();
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
4
|
+
const { ADS1115Full } = require('periph/src/chips/adc_dac/ads1115');
|
|
5
|
+
|
|
6
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
7
|
+
|
|
8
|
+
(async () => {
|
|
9
|
+
const bus = parseInt(process.env.I2C_BUS || '1', 10);
|
|
10
|
+
const connection = new I2CConnection(bus, ADS1115Full.I2C_ADDRESS);
|
|
11
|
+
const adc = new ADS1115Full(connection); // Create ADS1115 Full driver, (connection)
|
|
12
|
+
|
|
13
|
+
// --- Configure the converter ---
|
|
14
|
+
// ±4.096 V covers a 3.3 V rail with headroom; 250 SPS keeps single-shot
|
|
15
|
+
// reads short while still averaging out most noise.
|
|
16
|
+
await adc.setGain(ADS1115Full.PGA_4_096); // Set gain, (pga 0–5) → None
|
|
17
|
+
await adc.setDataRate(ADS1115Full.DR_250); // Set data rate, (dr 0–7) → None
|
|
18
|
+
|
|
19
|
+
// --- Read the inputs ---
|
|
20
|
+
// Single-shot mode powers the chip down between conversions.
|
|
21
|
+
for (let i = 0; i < 3; i++) {
|
|
22
|
+
for (let ch = 0; ch < 4; ch++) {
|
|
23
|
+
const raw = await adc.readRaw(ch); // Read raw code, (channel=0) → number
|
|
24
|
+
console.log(`AIN${ch} raw ${raw} ${(raw * adc.lsb()).toFixed(5)} V`);
|
|
25
|
+
}
|
|
26
|
+
await sleep(1000);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// --- Arm a window comparator ---
|
|
30
|
+
// ALERT/RDY asserts when the input leaves 0.5 V ... 3.0 V for two
|
|
31
|
+
// consecutive conversions; the latch holds it until clearAlert().
|
|
32
|
+
await adc.setThresholds(0.5, 3.0); // Set thresholds, (low V, high V) → None
|
|
33
|
+
await adc.configureComparator(ADS1115Full.COMP_WINDOW, ADS1115Full.ACTIVE_LOW, true, ADS1115Full.QUEUE_2);// Configure comparator, (mode, polarity, latch=false, queue=QUEUE_1) → None
|
|
34
|
+
await adc.startContinuous(ADS1115Full.MUX_AIN0_GND); // Start continuous, (mux=MUX_AIN0_GND 0–7) → None
|
|
35
|
+
|
|
36
|
+
// --- Report out-of-range events ---
|
|
37
|
+
// With an InputPin on ALERT/RDY the callback fires on the edge; without
|
|
38
|
+
// one the driver polls the register every 5 ms.
|
|
39
|
+
await adc.onInterrupt(async () => { // Subscribe, (callback) → None
|
|
40
|
+
console.log('OUT OF RANGE');
|
|
41
|
+
await adc.clearAlert(); // Clear alert, () → None
|
|
42
|
+
});
|
|
43
|
+
await sleep(10000);
|
|
44
|
+
await adc.offInterrupt(); // Unsubscribe, () → None
|
|
45
|
+
await adc.disableComparator(); // Disable comparator, () → None
|
|
46
|
+
await adc.stopContinuous(); // Stop continuous, () → None
|
|
47
|
+
|
|
48
|
+
// --- Bridge-sensor style differential read ---
|
|
49
|
+
// The smallest range gives 7.8 uV per code for millivolt-level signals.
|
|
50
|
+
await adc.setGain(ADS1115Full.PGA_0_256); // Set gain, (pga 0–5) → None
|
|
51
|
+
const d = await adc.readDifferential(ADS1115Full.DIFF_2_3); // Read differential, (pair 0–3) → number V
|
|
52
|
+
console.log(`differential ${d.toFixed(6)} V`);
|
|
53
|
+
|
|
54
|
+
await connection.close();
|
|
55
|
+
})();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
4
|
+
const { ADS1115Minimal } = require('periph/src/chips/adc_dac/ads1115');
|
|
5
|
+
|
|
6
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
7
|
+
|
|
8
|
+
(async () => {
|
|
9
|
+
const bus = parseInt(process.env.I2C_BUS || '1', 10);
|
|
10
|
+
const connection = new I2CConnection(bus, ADS1115Minimal.I2C_ADDRESS);
|
|
11
|
+
const adc = new ADS1115Minimal(connection); // Create ADS1115 driver, (connection)
|
|
12
|
+
|
|
13
|
+
for (let i = 0; i < 10; i++) {
|
|
14
|
+
const v = await adc.readVoltage(0); // Read voltage, (channel=0) → number V
|
|
15
|
+
console.log(`${v.toFixed(5)} V`);
|
|
16
|
+
await sleep(1000);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
await connection.close();
|
|
20
|
+
})();
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { I2CConnection } = require('../../../src/connection/i2c');
|
|
3
|
+
const { PCF8578Full } = require('../../../src/chips/display/pcf8578');
|
|
4
|
+
|
|
5
|
+
const I2C_BUS = parseInt(process.env.I2C_BUS || '1', 10);
|
|
6
|
+
const I2C_ADDR = parseInt(process.env.I2C_ADDR || '0x3C', 16);
|
|
7
|
+
|
|
8
|
+
const connection = new I2CConnection(I2C_BUS, I2C_ADDR);
|
|
9
|
+
const lcd = new PCF8578Full(connection, 16); // Create PCF8578 driver, (connection, rows=16 8/16/24/32)
|
|
10
|
+
// clears RAM and switches the display on in mixed mode
|
|
11
|
+
|
|
12
|
+
(async () => {
|
|
13
|
+
await lcd.ready(); // Wait for initialisation, () → void
|
|
14
|
+
// resolves once the RAM is cleared and the display is on
|
|
15
|
+
await lcd.clear(); // Clear display RAM, () → void
|
|
16
|
+
// zeroes all 4 banks x 40 columns and the shadow
|
|
17
|
+
await lcd.setPixel(1, 1); // Set one pixel, (x 0–23, y 0–15, on=true) → void
|
|
18
|
+
// writes a single RAM byte from the shadow
|
|
19
|
+
await lcd.writeColumns(4, 0, [0xFF, 0x81, 0xFF]); // Write column bytes, (x 0–23, bank 0–1, data bytes) → void
|
|
20
|
+
// character access mode, bit 0 = top row of the bank
|
|
21
|
+
const on = await lcd.getPixel(1, 1); // Read pixel from shadow, (x, y) → boolean
|
|
22
|
+
// no bus traffic
|
|
23
|
+
await lcd.fill(true); // Fill display, (on=true) → void
|
|
24
|
+
// every displayed pixel on
|
|
25
|
+
await lcd.fill(false); // Fill display, (on=true) → void
|
|
26
|
+
// every displayed pixel off
|
|
27
|
+
await lcd.drawLine(0, 0, 23, 15); // Draw line, (x0, y0, x1, y1, on=true) → void
|
|
28
|
+
// Bresenham, written as one batch of changed bytes
|
|
29
|
+
await lcd.drawRect(0, 0, 24, 16); // Draw rectangle outline, (x, y, w, h, on=true, fill=false) → void
|
|
30
|
+
// border around the whole panel
|
|
31
|
+
await lcd.drawRect(8, 4, 8, 8, true, true); // Draw filled rectangle, (x, y, w, h, on=true, fill=false) → void
|
|
32
|
+
// solid 8x8 block in the middle
|
|
33
|
+
await lcd.showBitmap(2, 8, [[0x18, 0x24, 0x42, 0x81]]); // Blit bitmap, (x, y multiple of 8, bands array of column bytes) → void
|
|
34
|
+
// one 8-pixel-high band at the lower bank
|
|
35
|
+
await lcd.setDisplay(PCF8578Full.DISPLAY_INVERSE); // Set display status, (status 0 blank/1 normal/2 all on/3 inverse) → void
|
|
36
|
+
// inverse video; RAM is preserved
|
|
37
|
+
await lcd.setDisplay(PCF8578Full.DISPLAY_NORMAL); // Set display status, (status 0–3) → void
|
|
38
|
+
// back to normal video
|
|
39
|
+
await lcd.setMode(24, true); // Set multiplex rate, (rows 8/16/24/32, mixed=true) → void
|
|
40
|
+
// 1:24 drive; mixed mode keeps RAM accessible
|
|
41
|
+
await lcd.setMode(16, true); // Set multiplex rate, (rows 8/16/24/32, mixed=true) → void
|
|
42
|
+
// back to 1:16
|
|
43
|
+
await lcd.setStartBank(1); // Set start bank, (bank 0–3) → void
|
|
44
|
+
// shows RAM bank 1 at the top (hardware scroll)
|
|
45
|
+
await lcd.scroll(-1); // Scroll by banks, (banks number) → void
|
|
46
|
+
// adds -1 to the start bank modulo banks in use
|
|
47
|
+
await lcd.writeRam(16, 0, [0xAA, 0x55]); // Write raw RAM, (x 0–39, bank 0–3, data bytes, mode=0) → void
|
|
48
|
+
// character order at RAM column 16
|
|
49
|
+
const data = await lcd.readRam(16, 0, 2); // Read raw RAM, (x 0–39, bank 0–3, n, mode=0) → Buffer
|
|
50
|
+
// address-set commands, repeated start, then a read
|
|
51
|
+
await lcd.deviceSelect(0); // Select device subaddress, (subaddress 0–15) → void
|
|
52
|
+
// 0 addresses this PCF8578; others target cascaded PCF8579s
|
|
53
|
+
await lcd.reset(); // Re-initialise, () → void
|
|
54
|
+
// clears RAM and restores normal video
|
|
55
|
+
|
|
56
|
+
await connection.close();
|
|
57
|
+
console.log('===DONE: 0 passed, 0 failed===');
|
|
58
|
+
})();
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { I2CConnection } = require('../../../src/connection/i2c');
|
|
3
|
+
const { PCF8578Full } = require('../../../src/chips/display/pcf8578');
|
|
4
|
+
|
|
5
|
+
const I2C_BUS = parseInt(process.env.I2C_BUS || '1', 10);
|
|
6
|
+
const I2C_ADDR = parseInt(process.env.I2C_ADDR || '0x3C', 16);
|
|
7
|
+
|
|
8
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
9
|
+
|
|
10
|
+
const connection = new I2CConnection(I2C_BUS, I2C_ADDR);
|
|
11
|
+
|
|
12
|
+
// --- Initialise a 16 x 24 dot-matrix panel ---
|
|
13
|
+
// 1:16 multiplex gives 16 rows and 24 columns; the constructor clears the RAM
|
|
14
|
+
// before switching the display on so no random start-up pattern is shown.
|
|
15
|
+
const lcd = new PCF8578Full(connection, 16); // Create PCF8578 driver, (connection, rows=16 8/16/24/32)
|
|
16
|
+
|
|
17
|
+
(async () => {
|
|
18
|
+
await lcd.ready();
|
|
19
|
+
|
|
20
|
+
// --- Draw a border and both diagonals ---
|
|
21
|
+
// Lines and rectangles are rendered in the shadow buffer and sent as one
|
|
22
|
+
// batch of changed bytes per run of columns.
|
|
23
|
+
await lcd.drawRect(0, 0, 24, 16); // Draw rectangle outline, (x, y, w, h, on=true, fill=false) → void
|
|
24
|
+
await lcd.drawLine(0, 0, 23, 15); // Draw line, (x0, y0, x1, y1, on=true) → void
|
|
25
|
+
await lcd.drawLine(0, 15, 23, 0); // Draw line, (x0, y0, x1, y1, on=true) → void
|
|
26
|
+
|
|
27
|
+
// --- Flash the display twice with inverse video ---
|
|
28
|
+
// Inverse video only changes how the RAM is shown, so the picture is kept.
|
|
29
|
+
for (let i = 0; i < 2; i++) {
|
|
30
|
+
await lcd.setDisplay(PCF8578Full.DISPLAY_INVERSE); // Set display status, (status 0–3) → void
|
|
31
|
+
await sleep(400);
|
|
32
|
+
await lcd.setDisplay(PCF8578Full.DISPLAY_NORMAL); // Set display status, (status 0–3) → void
|
|
33
|
+
await sleep(400);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// --- Fill all four RAM banks with distinct patterns ---
|
|
37
|
+
// At 1:16 only banks 0 and 1 are visible; banks 2 and 3 act as off-screen
|
|
38
|
+
// buffers that the start bank can scroll into view.
|
|
39
|
+
const patterns = [0x55, 0x33, 0x0F, 0xFF];
|
|
40
|
+
for (let bank = 0; bank < 4; bank++) {
|
|
41
|
+
await lcd.writeRam(16, bank, new Array(24).fill(patterns[bank])); // Write raw RAM, (x 0–39, bank 0–3, data bytes, mode=0) → void
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// --- Scroll through the banks with the hardware start bank ---
|
|
45
|
+
// Stepping the start bank scrolls the display by 8 rows without rewriting RAM.
|
|
46
|
+
for (let bank = 0; bank < 4; bank++) {
|
|
47
|
+
await lcd.setStartBank(bank); // Set start bank, (bank 0–3) → void
|
|
48
|
+
const first = await lcd.readRam(16, bank, 1); // Read raw RAM, (x 0–39, bank 0–3, n, mode=0) → Buffer
|
|
49
|
+
console.log('start bank', bank, 'first column byte', '0x' + first[0].toString(16));
|
|
50
|
+
await sleep(1000);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// --- Read back the first 8 RAM columns of bank 0 ---
|
|
54
|
+
// RAM columns 0-7 are never displayed at 1:16, so they serve as scratch
|
|
55
|
+
// storage; the chip supports reads in mixed mode, so the bytes can be verified.
|
|
56
|
+
await lcd.setStartBank(0); // Set start bank, (bank 0–3) → void
|
|
57
|
+
await lcd.writeRam(0, 0, [1, 2, 3, 4, 5, 6, 7, 8]); // Write raw RAM, (x 0–39, bank 0–3, data bytes, mode=0) → void
|
|
58
|
+
console.log(Array.from(await lcd.readRam(0, 0, 8))); // Read raw RAM, (x 0–39, bank 0–3, n, mode=0) → Buffer
|
|
59
|
+
|
|
60
|
+
await connection.close();
|
|
61
|
+
console.log('===DONE: 0 passed, 0 failed===');
|
|
62
|
+
})();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { I2CConnection } = require('../../../src/connection/i2c');
|
|
3
|
+
const { PCF8578Minimal } = require('../../../src/chips/display/pcf8578');
|
|
4
|
+
|
|
5
|
+
const I2C_BUS = parseInt(process.env.I2C_BUS || '1', 10);
|
|
6
|
+
const I2C_ADDR = parseInt(process.env.I2C_ADDR || '0x3C', 16);
|
|
7
|
+
|
|
8
|
+
const connection = new I2CConnection(I2C_BUS, I2C_ADDR);
|
|
9
|
+
const lcd = new PCF8578Minimal(connection, 16); // Create PCF8578 driver, (connection, rows=16 8/16/24/32)
|
|
10
|
+
|
|
11
|
+
(async () => {
|
|
12
|
+
await lcd.clear(); // Clear display RAM, () → void
|
|
13
|
+
await lcd.setPixel(0, 0); // Set one pixel, (x 0–23, y 0–15, on=true) → void
|
|
14
|
+
await lcd.setPixel(23, 15); // Set opposite corner, (x 0–23, y 0–15, on=true) → void
|
|
15
|
+
await lcd.writeColumns(4, 0, [0xFF, 0x81, 0x81, 0xFF]); // Write column bytes, (x 0–23, bank 0–1, data bytes) → void
|
|
16
|
+
|
|
17
|
+
await connection.close();
|
|
18
|
+
console.log('===DONE: 0 passed, 0 failed===');
|
|
19
|
+
})();
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { I2CConnection } = require('../../../src/connection/i2c');
|
|
3
|
+
const { PCF8579Full } = require('../../../src/chips/display/pcf8579');
|
|
4
|
+
|
|
5
|
+
const I2C_BUS = parseInt(process.env.I2C_BUS || '1', 10);
|
|
6
|
+
const I2C_ADDR = parseInt(process.env.I2C_ADDR || '0x3C', 16);
|
|
7
|
+
|
|
8
|
+
const connection = new I2CConnection(I2C_BUS, I2C_ADDR);
|
|
9
|
+
const lcd = new PCF8579Full(connection, 0, 16); // Create PCF8579 driver, (connection, subaddress=0 0–15, rows=16 8/16/24/32, mixed=false)
|
|
10
|
+
// clears this device's RAM and switches the display on
|
|
11
|
+
|
|
12
|
+
(async () => {
|
|
13
|
+
await lcd.ready(); // Wait for initialisation, () → void
|
|
14
|
+
// resolves once the RAM is cleared and the display is on
|
|
15
|
+
await lcd.clear(); // Clear display RAM, () → void
|
|
16
|
+
// zeroes all 4 banks x 40 columns and the shadow
|
|
17
|
+
await lcd.setPixel(1, 1); // Set one pixel, (x 0–39, y 0–15, on=true) → void
|
|
18
|
+
// writes a single RAM byte from the shadow
|
|
19
|
+
await lcd.writeColumns(4, 0, [0xFF, 0x81, 0xFF]); // Write column bytes, (x 0–39, bank 0–1, data bytes) → void
|
|
20
|
+
// character access mode, bit 0 = top row of the bank
|
|
21
|
+
const on = await lcd.getPixel(1, 1); // Read pixel from shadow, (x, y) → boolean
|
|
22
|
+
// no bus traffic
|
|
23
|
+
await lcd.fill(true); // Fill display, (on=true) → void
|
|
24
|
+
// every displayed pixel on
|
|
25
|
+
await lcd.fill(false); // Fill display, (on=true) → void
|
|
26
|
+
// every displayed pixel off
|
|
27
|
+
await lcd.drawLine(0, 0, 39, 15); // Draw line, (x0, y0, x1, y1, on=true) → void
|
|
28
|
+
// Bresenham, written as one batch of changed bytes
|
|
29
|
+
await lcd.drawRect(0, 0, 40, 16); // Draw rectangle outline, (x, y, w, h, on=true, fill=false) → void
|
|
30
|
+
// border around the whole panel
|
|
31
|
+
await lcd.drawRect(8, 4, 8, 8, true, true); // Draw filled rectangle, (x, y, w, h, on=true, fill=false) → void
|
|
32
|
+
// solid 8x8 block in the middle
|
|
33
|
+
await lcd.showBitmap(2, 8, [0x18, 0x24, 0x42, 0x81]); // Blit bitmap, (x, y multiple of 8, columns array of bytes) → void
|
|
34
|
+
// one 8-pixel-high band at the lower bank
|
|
35
|
+
await lcd.setDisplay(PCF8579Full.DISPLAY_INVERSE); // Set display status, (status 0 blank/1 normal/2 all on/3 inverse) → void
|
|
36
|
+
// inverse video; RAM is preserved
|
|
37
|
+
await lcd.setDisplay(PCF8579Full.DISPLAY_NORMAL); // Set display status, (status 0–3) → void
|
|
38
|
+
// back to normal video
|
|
39
|
+
await lcd.setMode(24, false); // Set multiplex rate, (rows 8/16/24/32, mixed=false) → void
|
|
40
|
+
// 1:24 drive; mixed is the PCF8578 mode bit T
|
|
41
|
+
await lcd.setMode(16, false); // Set multiplex rate, (rows 8/16/24/32, mixed=false) → void
|
|
42
|
+
// back to 1:16
|
|
43
|
+
await lcd.setStartBank(1); // Set start bank, (bank 0–3) → void
|
|
44
|
+
// shows RAM bank 1 at the top (hardware scroll)
|
|
45
|
+
await lcd.scroll(-1); // Scroll by banks, (banks number) → void
|
|
46
|
+
// adds -1 to the start bank modulo banks in use
|
|
47
|
+
await lcd.writeRam(16, 0, [0xAA, 0x55]); // Write raw RAM, (x 0–39, bank 0–3, data bytes, mode=0) → void
|
|
48
|
+
// character order at RAM column 16
|
|
49
|
+
const data = await lcd.readRam(16, 0, 2); // Read raw RAM, (x 0–39, bank 0–3, n, mode=0) → Buffer
|
|
50
|
+
// address-set commands, repeated start, then a read
|
|
51
|
+
await lcd.writeRamCascade(new Array(160).fill(0)); // Write across devices, (data bytes, mode=2) → void
|
|
52
|
+
// runs on into the following subaddresses after column 39
|
|
53
|
+
await lcd.reset(); // Re-initialise, () → void
|
|
54
|
+
// clears RAM and restores normal video
|
|
55
|
+
|
|
56
|
+
await connection.close();
|
|
57
|
+
console.log('===DONE: 0 passed, 0 failed===');
|
|
58
|
+
})();
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { I2CConnection } = require('../../../src/connection/i2c');
|
|
3
|
+
const { PCF8579Full } = require('../../../src/chips/display/pcf8579');
|
|
4
|
+
|
|
5
|
+
const I2C_BUS = parseInt(process.env.I2C_BUS || '1', 10);
|
|
6
|
+
const I2C_ADDR = parseInt(process.env.I2C_ADDR || '0x3C', 16);
|
|
7
|
+
|
|
8
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
9
|
+
|
|
10
|
+
const connection = new I2CConnection(I2C_BUS, I2C_ADDR);
|
|
11
|
+
|
|
12
|
+
// --- Initialise a 16 x 40 column driver ---
|
|
13
|
+
// 1:16 multiplex gives 16 rows and 40 columns; the constructor clears the RAM
|
|
14
|
+
// before switching the display on so no random start-up pattern is shown.
|
|
15
|
+
const lcd = new PCF8579Full(connection, 0, 16); // Create PCF8579 driver, (connection, subaddress=0 0–15, rows=16 8/16/24/32, mixed=false)
|
|
16
|
+
|
|
17
|
+
(async () => {
|
|
18
|
+
await lcd.ready();
|
|
19
|
+
|
|
20
|
+
// --- Draw a border and both diagonals ---
|
|
21
|
+
// Lines and rectangles are rendered in the shadow buffer and sent as one
|
|
22
|
+
// batch of changed bytes per run of columns.
|
|
23
|
+
await lcd.drawRect(0, 0, 40, 16); // Draw rectangle outline, (x, y, w, h, on=true, fill=false) → void
|
|
24
|
+
await lcd.drawLine(0, 0, 39, 15); // Draw line, (x0, y0, x1, y1, on=true) → void
|
|
25
|
+
await lcd.drawLine(0, 15, 39, 0); // Draw line, (x0, y0, x1, y1, on=true) → void
|
|
26
|
+
|
|
27
|
+
// --- Flash the display twice with inverse video ---
|
|
28
|
+
// Inverse video only changes how the RAM is shown, so the picture is kept.
|
|
29
|
+
for (let i = 0; i < 2; i++) {
|
|
30
|
+
await lcd.setDisplay(PCF8579Full.DISPLAY_INVERSE); // Set display status, (status 0–3) → void
|
|
31
|
+
await sleep(400);
|
|
32
|
+
await lcd.setDisplay(PCF8579Full.DISPLAY_NORMAL); // Set display status, (status 0–3) → void
|
|
33
|
+
await sleep(400);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// --- Fill all four RAM banks with distinct patterns ---
|
|
37
|
+
// At 1:16 only banks 0 and 1 are visible; banks 2 and 3 act as off-screen
|
|
38
|
+
// buffers that the start bank can scroll into view.
|
|
39
|
+
const patterns = [0x55, 0x33, 0x0F, 0xFF];
|
|
40
|
+
for (let bank = 0; bank < 4; bank++) {
|
|
41
|
+
await lcd.writeRam(0, bank, new Array(40).fill(patterns[bank])); // Write raw RAM, (x 0–39, bank 0–3, data bytes, mode=0) → void
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// --- Scroll through the banks with the hardware start bank ---
|
|
45
|
+
// Stepping the start bank scrolls the display by 8 rows without rewriting RAM.
|
|
46
|
+
for (let bank = 0; bank < 4; bank++) {
|
|
47
|
+
await lcd.setStartBank(bank); // Set start bank, (bank 0–3) → void
|
|
48
|
+
const first = await lcd.readRam(0, bank, 1); // Read raw RAM, (x 0–39, bank 0–3, n, mode=0) → Buffer
|
|
49
|
+
console.log('start bank', bank, 'first column byte', '0x' + first[0].toString(16));
|
|
50
|
+
await sleep(1000);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// --- Read back the first 8 RAM columns of bank 0 ---
|
|
54
|
+
// Writing a counting pattern and reading it back verifies the bus path.
|
|
55
|
+
await lcd.setStartBank(0); // Set start bank, (bank 0–3) → void
|
|
56
|
+
await lcd.writeRam(0, 0, [1, 2, 3, 4, 5, 6, 7, 8]); // Write raw RAM, (x 0–39, bank 0–3, data bytes, mode=0) → void
|
|
57
|
+
console.log(Array.from(await lcd.readRam(0, 0, 8))); // Read raw RAM, (x 0–39, bank 0–3, n, mode=0) → Buffer
|
|
58
|
+
|
|
59
|
+
await connection.close();
|
|
60
|
+
console.log('===DONE: 0 passed, 0 failed===');
|
|
61
|
+
})();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const { I2CConnection } = require('../../../src/connection/i2c');
|
|
3
|
+
const { PCF8579Minimal } = require('../../../src/chips/display/pcf8579');
|
|
4
|
+
|
|
5
|
+
const I2C_BUS = parseInt(process.env.I2C_BUS || '1', 10);
|
|
6
|
+
const I2C_ADDR = parseInt(process.env.I2C_ADDR || '0x3C', 16);
|
|
7
|
+
|
|
8
|
+
const connection = new I2CConnection(I2C_BUS, I2C_ADDR);
|
|
9
|
+
const lcd = new PCF8579Minimal(connection, 0, 16); // Create PCF8579 driver, (connection, subaddress=0 0–15, rows=16 8/16/24/32, mixed=false)
|
|
10
|
+
|
|
11
|
+
(async () => {
|
|
12
|
+
await lcd.clear(); // Clear display RAM, () → void
|
|
13
|
+
await lcd.setPixel(0, 0); // Set one pixel, (x 0–39, y 0–15, on=true) → void
|
|
14
|
+
await lcd.setPixel(39, 15); // Set opposite corner, (x 0–39, y 0–15, on=true) → void
|
|
15
|
+
await lcd.writeColumns(4, 0, [0xFF, 0x81, 0x81, 0xFF]); // Write column bytes, (x 0–39, bank 0–1, data bytes) → void
|
|
16
|
+
|
|
17
|
+
await connection.close();
|
|
18
|
+
console.log('===DONE: 0 passed, 0 failed===');
|
|
19
|
+
})();
|