periph 1.2.0 → 1.3.0

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 (153) hide show
  1. package/README.md +18 -0
  2. package/examples/accelerometer/bma150/complete.js +62 -0
  3. package/examples/accelerometer/bma150/demo.js +65 -0
  4. package/examples/accelerometer/bma150/minimal.js +18 -0
  5. package/examples/adc_dac/hy3131/complete.js +66 -0
  6. package/examples/adc_dac/hy3131/demo.js +37 -0
  7. package/examples/adc_dac/hy3131/minimal.js +18 -0
  8. package/examples/discovery/complete.js +25 -0
  9. package/examples/discovery/demo.js +30 -0
  10. package/examples/discovery/minimal.js +12 -0
  11. package/examples/display/il0373/complete.js +71 -0
  12. package/examples/display/il0373/demo.js +49 -0
  13. package/examples/display/il0373/minimal.js +26 -0
  14. package/examples/display/ssd1331/complete.js +83 -0
  15. package/examples/display/ssd1331/demo.js +49 -0
  16. package/examples/display/ssd1331/minimal.js +27 -0
  17. package/examples/display/st7036/complete.js +71 -0
  18. package/examples/display/st7036/demo.js +56 -0
  19. package/examples/display/st7036/minimal.js +21 -0
  20. package/examples/display/uc1611s/complete.js +135 -0
  21. package/examples/display/uc1611s/complete_spi.js +128 -0
  22. package/examples/display/uc1611s/demo.js +90 -0
  23. package/examples/display/uc1611s/demo_spi.js +91 -0
  24. package/examples/display/uc1611s/minimal.js +28 -0
  25. package/examples/display/uc1611s/minimal_spi.js +30 -0
  26. package/examples/display/uc8159/complete.js +64 -0
  27. package/examples/display/uc8159/demo.js +41 -0
  28. package/examples/display/uc8159/minimal.js +28 -0
  29. package/examples/display/uc8276c/complete.js +73 -0
  30. package/examples/display/uc8276c/demo.js +49 -0
  31. package/examples/display/uc8276c/minimal.js +26 -0
  32. package/examples/environmental/bme280/complete.js +1 -1
  33. package/examples/environmental/bme280/demo.js +1 -1
  34. package/examples/environmental/bme280/minimal.js +1 -1
  35. package/examples/gyroscope/l3g4200d/complete.js +1 -1
  36. package/examples/gyroscope/l3g4200d/demo.js +1 -1
  37. package/examples/gyroscope/l3g4200d/minimal.js +1 -1
  38. package/examples/memory/23x1024/complete.js +54 -0
  39. package/examples/memory/23x1024/demo.js +51 -0
  40. package/examples/memory/23x1024/minimal.js +22 -0
  41. package/examples/memory/mx25l12845e/complete.js +66 -0
  42. package/examples/memory/mx25l12845e/demo.js +66 -0
  43. package/examples/memory/mx25l12845e/minimal.js +27 -0
  44. package/examples/memory/sd_spi/complete.js +55 -0
  45. package/examples/memory/sd_spi/demo.js +67 -0
  46. package/examples/memory/sd_spi/minimal.js +32 -0
  47. package/examples/motor/drv8830/complete.js +50 -0
  48. package/examples/motor/drv8830/demo.js +57 -0
  49. package/examples/motor/drv8830/minimal.js +23 -0
  50. package/examples/pressure/bmp280/complete.js +1 -1
  51. package/examples/pressure/bmp280/demo.js +1 -1
  52. package/examples/pressure/bmp280/minimal.js +1 -1
  53. package/examples/pressure/bmp581/complete.js +1 -1
  54. package/examples/pressure/bmp581/demo.js +1 -1
  55. package/examples/pressure/bmp581/minimal.js +1 -1
  56. package/examples/pressure/lps22df/complete.js +1 -1
  57. package/examples/pressure/lps22df/demo.js +1 -1
  58. package/examples/pressure/lps22df/minimal.js +1 -1
  59. package/examples/rtc/ds3231/complete.js +77 -0
  60. package/examples/rtc/ds3231/demo.js +60 -0
  61. package/examples/rtc/ds3231/minimal.js +23 -0
  62. package/examples/rtc/pcf8523/complete.js +66 -0
  63. package/examples/rtc/pcf8523/demo.js +65 -0
  64. package/examples/rtc/pcf8523/minimal.js +20 -0
  65. package/examples/temperature/mcp9808/complete.js +89 -0
  66. package/examples/temperature/mcp9808/demo.js +62 -0
  67. package/examples/temperature/mcp9808/minimal.js +21 -0
  68. package/examples/temperature/tmp117/complete.js +90 -0
  69. package/examples/temperature/tmp117/demo.js +73 -0
  70. package/examples/temperature/tmp117/minimal.js +21 -0
  71. package/examples/tof/vl53l0x/complete.js +118 -0
  72. package/examples/tof/vl53l0x/demo.js +83 -0
  73. package/examples/tof/vl53l0x/minimal.js +25 -0
  74. package/examples/tof/vl53l1x/complete.js +151 -0
  75. package/examples/tof/vl53l1x/demo.js +100 -0
  76. package/examples/tof/vl53l1x/minimal.js +25 -0
  77. package/package.json +1 -1
  78. package/src/chips/accelerometer/adxl345.js +10 -31
  79. package/src/chips/accelerometer/adxl362.js +7 -7
  80. package/src/chips/accelerometer/bma150.js +419 -0
  81. package/src/chips/adc_dac/ad7705.js +36 -9
  82. package/src/chips/adc_dac/ad7706.js +39 -9
  83. package/src/chips/adc_dac/hy3131.js +311 -0
  84. package/src/chips/display/il0373.js +607 -0
  85. package/src/chips/display/ssd1331.js +412 -0
  86. package/src/chips/display/st7036.js +401 -0
  87. package/src/chips/display/uc1611s.js +648 -0
  88. package/src/chips/display/uc8159.js +394 -0
  89. package/src/chips/display/uc8276c.js +658 -0
  90. package/src/chips/environmental/bme280.js +31 -46
  91. package/src/chips/environmental/bme680.js +38 -43
  92. package/src/chips/gas/ens160.js +18 -26
  93. package/src/chips/gyroscope/l3g4200d.js +34 -50
  94. package/src/chips/gyroscope/l3gd20h.js +24 -40
  95. package/src/chips/imu/mpu6050.js +29 -41
  96. package/src/chips/imu/mpu9250.js +45 -69
  97. package/src/chips/imu/mpu9255.js +54 -78
  98. package/src/chips/io_expander/mcp23017.js +24 -33
  99. package/src/chips/light/apds-9930.js +52 -60
  100. package/src/chips/light/apds9960.js +69 -77
  101. package/src/chips/magnetometer/as5600.js +13 -27
  102. package/src/chips/magnetometer/hmc5883l.js +32 -29
  103. package/src/chips/memory/_23x1024.js +228 -0
  104. package/src/chips/memory/_24aa02uid.js +8 -11
  105. package/src/chips/memory/mx25l12845e.js +467 -0
  106. package/src/chips/memory/sd_spi.js +486 -0
  107. package/src/chips/motor/drv8830.js +239 -0
  108. package/src/chips/other/mpr121.js +7 -7
  109. package/src/chips/power/ina219.js +5 -8
  110. package/src/chips/power/ina226.js +5 -8
  111. package/src/chips/power/ina3221.js +5 -8
  112. package/src/chips/pressure/bmp085.js +17 -11
  113. package/src/chips/pressure/bmp180.js +7 -7
  114. package/src/chips/pressure/bmp280.js +21 -33
  115. package/src/chips/pressure/bmp384.js +28 -39
  116. package/src/chips/pressure/bmp581.js +59 -70
  117. package/src/chips/pressure/lps22df.js +50 -52
  118. package/src/chips/pressure/lps28dfw.js +15 -13
  119. package/src/chips/pressure/lps33hw.js +7 -5
  120. package/src/chips/rtc/ds3231.js +504 -0
  121. package/src/chips/rtc/pcf8523.js +533 -0
  122. package/src/chips/temperature/mcp9808.js +490 -0
  123. package/src/chips/temperature/tmp117.js +471 -0
  124. package/src/chips/tof/_vl53_base.js +160 -0
  125. package/src/chips/tof/vl53l0x.js +816 -0
  126. package/src/chips/tof/vl53l1x.js +816 -0
  127. package/src/connection/connection.js +6 -4
  128. package/src/connection/dhtxx.js +5 -3
  129. package/src/connection/display.js +278 -0
  130. package/src/connection/display_mock.js +77 -0
  131. package/src/connection/hx711.js +5 -3
  132. package/src/connection/i2c.js +6 -4
  133. package/src/connection/i2c_mock.js +47 -0
  134. package/src/connection/input_pin.js +36 -5
  135. package/src/connection/register.js +14 -0
  136. package/src/connection/register_connection.js +65 -0
  137. package/src/connection/sipo.js +4 -2
  138. package/src/connection/sipo_mock.js +49 -0
  139. package/src/connection/smbus.js +6 -4
  140. package/src/connection/softspi.js +73 -0
  141. package/src/connection/spi.js +110 -23
  142. package/src/connection/spi_mock.js +50 -0
  143. package/src/connection/uart.js +2 -1
  144. package/src/discovery/discovery.js +218 -0
  145. package/src/discovery/registry.js +85 -0
  146. package/src/storage/block_device.js +95 -0
  147. package/src/storage/ram_block_device.js +72 -0
  148. package/examples/motor/.gitkeep +0 -0
  149. package/examples/temperature/.gitkeep +0 -0
  150. package/examples/tof/.gitkeep +0 -0
  151. package/src/chips/motor/.gitkeep +0 -0
  152. package/src/chips/temperature/.gitkeep +0 -0
  153. package/src/chips/tof/.gitkeep +0 -0
@@ -0,0 +1,83 @@
1
+ // SSD1331 complete example: every Full method on a Waveshare 0.95inch RGB OLED, Raspberry Pi (Node.js).
2
+ // Wiring: DIN=GPIO10 (SPI0 MOSI), CLK=GPIO11, CS=GPIO8 (CE0), DC=GPIO25, RST=GPIO17 (no BUSY line).
3
+ 'use strict';
4
+ const { Default } = require('opengpio');
5
+ const { DisplayConnection } = require('../../../src/connection/display');
6
+ const { GpioOutputPin } = require('../../../src/connection/output_pin');
7
+ const { SSD1331Full, MODE_NORMAL, MODE_ALL_ON, MODE_ALL_OFF, MODE_INVERSE, BLACK, WHITE, RED, GREEN, BLUE, YELLOW, CYAN, MAGENTA } = require('../../../src/chips/display/ssd1331');
8
+
9
+ const dc = new GpioOutputPin(Default.output({ chip: 0, line: 25 })); // Create D/C# pin, (chip, line=25) → OutputPin
10
+ const res = new GpioOutputPin(Default.output({ chip: 0, line: 17 })); // Create RES# pin, (chip, line=17) → OutputPin
11
+ const connection = new DisplayConnection({ busNumber: 0, deviceNumber: 0, dc, res }); // Create display connection, (busNumber, deviceNumber, dc, res, busy=none)
12
+ const oled = new SSD1331Full(connection); // Create SSD1331 driver, (connection)
13
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
14
+
15
+ (async () => {
16
+ await oled.ready();
17
+ oled.clear(BLACK); // Fill framebuffer, (color=BLACK)
18
+ // sets every pixel; the display is unchanged until show()
19
+ oled.drawRect(0, 0, 96, 64, WHITE); // Rectangle outline, (x, y, w, h, color=WHITE, fill=false)
20
+ oled.drawRect(4, 4, 30, 20, RED, true); // Filled rectangle, (x, y, w, h, color=WHITE, fill=false)
21
+ oled.drawLine(0, 0, 95, 63, GREEN); // Software line, (x0, y0, x1, y1, color=WHITE)
22
+ // Bresenham diagonal
23
+ oled.drawLine(0, 63, 95, 0, CYAN); // Software line, (x0, y0, x1, y1, color=WHITE)
24
+ const sprite = Array.from({ length: 64 }, (_, i) => ((((i >> 3) + (i & 7)) & 1) ? YELLOW : MAGENTA));
25
+ oled.blit(60, 8, sprite, 8, 8); // Copy RGB565 bitmap, (x, y, pixels, w, h)
26
+ // checkerboard into the framebuffer
27
+ oled.setPixel(48, 32, WHITE); // Set one pixel, (x, y, color=WHITE)
28
+ console.log(oled.getPixel(48, 32).toString(16)); // Read framebuffer pixel, (x, y) → number RGB565
29
+ await oled.show(); // Send framebuffer, () → Promise<void>
30
+ // window 0..95 x 0..63 then 12288 bytes
31
+ await sleep(2000);
32
+
33
+ oled.clear(BLUE); // Fill framebuffer, (color=BLACK)
34
+ oled.drawRect(20, 16, 56, 32, WHITE, true); // Filled rectangle, (x, y, w, h, color=WHITE, fill=false)
35
+ await oled.showRegion(16, 12, 64, 40); // Send region, (x, y, w, h) → Promise<void>
36
+ // only the rows of the window are transferred
37
+ await sleep(2000);
38
+
39
+ await oled.hwClear(0, 0, 95, 63); // Clear window in display RAM, (x0, y0, x1, y1) → Promise<void>
40
+ // chip clears its own RAM, framebuffer untouched
41
+ await oled.hwRect(10, 10, 76, 44, YELLOW, RED, true); // Hardware rectangle, (x, y, w, h, lineColor, fillColor=0, fill=false)
42
+ // outline and fill drawn by the chip
43
+ await oled.hwLine(0, 0, 95, 63, WHITE); // Hardware line, (x0, y0, x1, y1, color)
44
+ await sleep(2000);
45
+ await oled.hwCopy(10, 10, 40, 40, 50, 20); // Hardware copy, (x0, y0, x1, y1, x, y)
46
+ await sleep(2000);
47
+ await oled.hwDim(0, 0, 47, 63); // Hardware dim window, (x0, y0, x1, y1)
48
+ await sleep(2000);
49
+
50
+ await oled.setDisplayMode(MODE_INVERSE); // Display mode, (mode)
51
+ await sleep(1500);
52
+ await oled.setDisplayMode(MODE_ALL_ON); // Display mode, (mode)
53
+ await sleep(1000);
54
+ await oled.setDisplayMode(MODE_ALL_OFF); // Display mode, (mode)
55
+ await sleep(1000);
56
+ await oled.setDisplayMode(MODE_NORMAL); // Display mode, (mode)
57
+
58
+ await oled.setContrast(0x30, 0x30, 0x30); // Channel contrast, (a, b, c) 0..255
59
+ await sleep(1000);
60
+ await oled.setContrast(0xFF, 0xFF, 0xFF); // Channel contrast, (a, b, c) 0..255
61
+ await oled.setMasterCurrent(4); // Master current, (n 1..16) n/16
62
+ await sleep(1000);
63
+ await oled.setMasterCurrent(7); // Master current, (n 1..16) n/16
64
+
65
+ await oled.setFlip(false, true); // Mirror, (horizontal, vertical)
66
+ await oled.show(); // Send framebuffer, () → Promise<void>
67
+ await sleep(1500);
68
+ await oled.setFlip(true, true); // Mirror, (horizontal, vertical)
69
+ await oled.show(); // Send framebuffer, () → Promise<void>
70
+ await sleep(1500);
71
+
72
+ await oled.scroll(1, 0, 64, 0, 0); // Scroll, (horizontal, startRow, rows, vertical, interval 0..3)
73
+ // continuous scroll one column per 6 frames
74
+ await sleep(4000);
75
+ await oled.scrollStop(); // Stop scrolling, ()
76
+
77
+ await oled.dimMode(0x10, 0x10, 0x10, 0x10); // Dim mode, (a, b, c, precharge 0..31)
78
+ await sleep(1500);
79
+ await oled.setPowerSave(true); // Power save, (on)
80
+ await oled.displayOff(); // Display off, ()
81
+ connection.close();
82
+ process.exit(0);
83
+ })().catch((e) => { console.error(e); process.exit(1); });
@@ -0,0 +1,49 @@
1
+ // SSD1331 demo example: a colour test card on a Waveshare 0.95inch RGB OLED, Raspberry Pi (Node.js).
2
+ // Wiring: DIN=GPIO10 (SPI0 MOSI), CLK=GPIO11, CS=GPIO8 (CE0), DC=GPIO25, RST=GPIO17 (no BUSY line).
3
+ 'use strict';
4
+ const { Default } = require('opengpio');
5
+ const { DisplayConnection } = require('../../../src/connection/display');
6
+ const { GpioOutputPin } = require('../../../src/connection/output_pin');
7
+ const { SSD1331Full, rgb, BLACK, WHITE, RED, GREEN, BLUE, YELLOW, CYAN, MAGENTA } = require('../../../src/chips/display/ssd1331');
8
+
9
+ const dc = new GpioOutputPin(Default.output({ chip: 0, line: 25 })); // Create D/C# pin, (chip, line=25) → OutputPin
10
+ const res = new GpioOutputPin(Default.output({ chip: 0, line: 17 })); // Create RES# pin, (chip, line=17) → OutputPin
11
+ const connection = new DisplayConnection({ busNumber: 0, deviceNumber: 0, dc, res }); // Create display connection, (busNumber, deviceNumber, dc, res, busy=none)
12
+ const oled = new SSD1331Full(connection); // Create SSD1331 driver, (connection)
13
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
14
+
15
+ (async () => {
16
+ await oled.ready();
17
+
18
+ // --- Draw the test card into the framebuffer ---
19
+ // Eight 12-pixel colour bars over a 26-row gray ramp show that all channels and the
20
+ // 5-6-5 depth work; the one-pixel frame shows that the whole 96 x 64 area is addressed.
21
+ const bars = [WHITE, YELLOW, CYAN, GREEN, MAGENTA, RED, BLUE, BLACK];
22
+ oled.clear(BLACK); // Fill framebuffer, (color=BLACK)
23
+ for (let x = 0; x < 96; x++) {
24
+ oled.drawRect(x, 2, 1, 30, bars[Math.floor(x / 12)], true); // Filled rectangle, (x, y, w, h, color=WHITE, fill=false)
25
+ const g = Math.round(x * 255 / 95);
26
+ oled.drawRect(x, 34, 1, 26, rgb(g, g, g), true); // Filled rectangle, (x, y, w, h, color=WHITE, fill=false)
27
+ }
28
+ oled.drawRect(0, 0, 96, 64, WHITE); // Rectangle outline, (x, y, w, h, color=WHITE, fill=false)
29
+
30
+ // --- Send it once ---
31
+ await oled.show(); // Send framebuffer, () → Promise<void>
32
+ await sleep(3000);
33
+
34
+ // --- Animate with hardware drawing ---
35
+ // The chip draws the marker straight into its RAM: no framebuffer transfer per step.
36
+ for (let step = 0; step < 60; step++) {
37
+ const x = 4 + (step * 3) % 80;
38
+ await oled.show(); // Send framebuffer, () → Promise<void>
39
+ await oled.hwRect(x, 36, 10, 10, WHITE, RED, true); // Hardware rectangle, (x, y, w, h, lineColor, fillColor=0, fill=false)
40
+ await sleep(50);
41
+ }
42
+
43
+ // --- Scroll the test card ---
44
+ // The chip scrolls its own RAM, one column every 6 frames.
45
+ await oled.show(); // Send framebuffer, () → Promise<void>
46
+ await oled.scroll(1, 0, 64, 0, 0); // Scroll, (horizontal, startRow, rows, vertical, interval 0..3)
47
+ connection.close();
48
+ process.exit(0);
49
+ })().catch((e) => { console.error(e); process.exit(1); });
@@ -0,0 +1,27 @@
1
+ // SSD1331 minimal example: Waveshare 0.95inch RGB OLED on a Raspberry Pi (Node.js).
2
+ // Wiring: DIN=GPIO10 (SPI0 MOSI), CLK=GPIO11, CS=GPIO8 (CE0), DC=GPIO25, RST=GPIO17 (no BUSY line).
3
+ 'use strict';
4
+ const { Default } = require('opengpio');
5
+ const { DisplayConnection } = require('../../../src/connection/display');
6
+ const { GpioOutputPin } = require('../../../src/connection/output_pin');
7
+ const { SSD1331Minimal, BLACK, WHITE, RED, GREEN, BLUE, YELLOW, CYAN, MAGENTA } = require('../../../src/chips/display/ssd1331');
8
+
9
+ const dc = new GpioOutputPin(Default.output({ chip: 0, line: 25 })); // Create D/C# pin, (chip, line=25) → OutputPin
10
+ const res = new GpioOutputPin(Default.output({ chip: 0, line: 17 })); // Create RES# pin, (chip, line=17) → OutputPin
11
+ const connection = new DisplayConnection({ busNumber: 0, deviceNumber: 0, dc, res }); // Create display connection, (busNumber, deviceNumber, dc, res, busy=none)
12
+ const oled = new SSD1331Minimal(connection); // Create SSD1331 driver, (connection)
13
+
14
+ (async () => {
15
+ await oled.ready();
16
+ const bars = [WHITE, YELLOW, CYAN, GREEN, MAGENTA, RED, BLUE, BLACK];
17
+ for (let y = 0; y < oled.height; y++) {
18
+ for (let x = 0; x < oled.width; x++) oled.setPixel(x, y, bars[Math.floor(x / 12)]); // Set one pixel, (x, y, color=WHITE)
19
+ }
20
+ for (let x = 0; x < oled.width; x++) {
21
+ oled.setPixel(x, 0, WHITE); // Set one pixel, (x, y, color=WHITE)
22
+ oled.setPixel(x, oled.height - 1, WHITE); // Set one pixel, (x, y, color=WHITE)
23
+ }
24
+ await oled.show(); // Send framebuffer, () → Promise<void>
25
+ connection.close();
26
+ process.exit(0);
27
+ })().catch((e) => { console.error(e); process.exit(1); });
@@ -0,0 +1,71 @@
1
+ // ST7036 complete example: every Full method on an EA DOGM162W-A (2 x 16, 3.3 V) on a Raspberry Pi (Node.js).
2
+ // Wiring: SI=GPIO10 (SPI0 MOSI), SCL=GPIO11, CSB=GPIO8 (CE0), RS=GPIO25 (C/D), RESET=GPIO17; PSB=GND, E=3V3 (no BUSY line).
3
+ // Module capacitors: 0.1-1 uF between CAP1N and CAP1P, 0.47-2.2 uF from VOUT to GND, VIN = VDD.
4
+ 'use strict';
5
+ const { Default } = require('opengpio');
6
+ const { DisplayConnection } = require('../../../src/connection/display');
7
+ const { GpioOutputPin } = require('../../../src/connection/output_pin');
8
+ const { ST7036Full } = require('../../../src/chips/display/st7036');
9
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
10
+
11
+ const dc = new GpioOutputPin(Default.output({ chip: 0, line: 25 })); // Create RS (C/D) pin, (chip, line=25) → OutputPin
12
+ const res = new GpioOutputPin(Default.output({ chip: 0, line: 17 })); // Create RESET pin, (chip, line=17) → OutputPin
13
+ const connection = new DisplayConnection({ busNumber: 0, deviceNumber: 0, dc, res, maxSpeedHz: 1000000 }); // Create display connection, (busNumber, deviceNumber, dc, res, busy=none, maxSpeedHz=1 MHz)
14
+ const lcd = new ST7036Full(connection); // Create ST7036 driver, (connection, lines=2, columns=null, supply=SUPPLY_3V3, contrast=null)
15
+
16
+ (async () => {
17
+ await lcd.ready();
18
+ await lcd.clear(); // Clear display, () → Promise<void>
19
+ // writes spaces to all of DDRAM, cursor to home (2 ms)
20
+ await lcd.printAt(0, 0, 'Complete example'); // Write text, (col, row, text) → Promise<void>
21
+ await lcd.setCursor(0, 1); // Move cursor, (col, row) → Promise<void>
22
+ await lcd.write('Cursor + blink'); // Write text at the cursor, (text) → Promise<void>
23
+ await lcd.cursor(true, true); // Cursor, (on, blink=false) → Promise<void>
24
+ await sleep(2000);
25
+ await lcd.cursor(false, false); // Cursor, (on, blink=false) → Promise<void>
26
+
27
+ const heart = [0x00, 0x0A, 0x1F, 0x1F, 0x0E, 0x04, 0x00, 0x00];
28
+ const arrow = [0x04, 0x02, 0x1F, 0x02, 0x04, 0x00, 0x00, 0x00];
29
+ await lcd.createChar(0, heart); // Define user character, (index 0..7, rows[8]) → Promise<void>
30
+ // 8 rows of 5 bits into CGRAM, DDRAM address restored
31
+ await lcd.createChar(1, arrow); // Define user character, (index 0..7, rows[8]) → Promise<void>
32
+ await lcd.clear(); // Clear display, () → Promise<void>
33
+ await lcd.setCursor(0, 0); // Move cursor, (col, row) → Promise<void>
34
+ await lcd.write('I '); // Write text at the cursor, (text) → Promise<void>
35
+ await lcd.writeChar(0); // Write raw character code, (code) → Promise<void>
36
+ await lcd.write(' custom '); // Write text at the cursor, (text) → Promise<void>
37
+ await lcd.writeChar(1); // Write raw character code, (code) → Promise<void>
38
+ await sleep(2000);
39
+
40
+ await lcd.setContrast(0x08); // Set contrast, (value 0..63) → Promise<void>
41
+ await lcd.printAt(0, 1, 'low contrast'); // Write text, (col, row, text) → Promise<void>
42
+ await sleep(1500);
43
+ await lcd.setContrast(0x30); // Set contrast, (value 0..63) → Promise<void>
44
+ await lcd.printAt(0, 1, 'high contrast'); // Write text, (col, row, text) → Promise<void>
45
+ await sleep(1500);
46
+ await lcd.setContrast(0x18); // Set contrast, (value 0..63) → Promise<void>
47
+ // 0x18 is the DOGM162 3.3 V preset
48
+ await lcd.setBias(false); // LCD bias, (quarter=false) → Promise<void>, 1/5 bias
49
+ await lcd.setFollower(true, 5); // Voltage follower, (on, ratio 0..7) → Promise<void>, 1 + Rb/Ra = 2.5
50
+ await lcd.setBooster(true); // Voltage booster, (on) → Promise<void>
51
+
52
+ await lcd.clear(); // Clear display, () → Promise<void>
53
+ await lcd.setEntryMode(true, false); // Entry mode, (increment, shift=false) → Promise<void>
54
+ await lcd.printAt(0, 0, 'Shift display ->'); // Write text, (col, row, text) → Promise<void>
55
+ await lcd.printAt(0, 1, '0123456789ABCDEF'); // Write text, (col, row, text) → Promise<void>
56
+ await sleep(1000);
57
+ for (let i = 0; i < 6; i++) {
58
+ await lcd.shiftDisplay(true); // Shift display, (right) → Promise<void>
59
+ await sleep(300);
60
+ }
61
+ await lcd.returnHome(); // Return home, () → Promise<void>, undoes the display shift
62
+ await lcd.shiftCursor(true); // Shift cursor, (right) → Promise<void>
63
+ await lcd.setDdramAddress(0x40); // Set DDRAM address, (address) → Promise<void>
64
+ await sleep(1000);
65
+
66
+ await lcd.display(false); // Display on/off, (on) → Promise<void>
67
+ await sleep(800);
68
+ await lcd.display(true); // Display on/off, (on) → Promise<void>
69
+ connection.close();
70
+ process.exit(0);
71
+ })().catch((e) => { console.error(e); process.exit(1); });
@@ -0,0 +1,56 @@
1
+ // ST7036 demo example: a two-line status display with a bar graph on an EA DOGM162W-A (2 x 16, 3.3 V) on a Raspberry Pi (Node.js).
2
+ // Wiring: SI=GPIO10 (SPI0 MOSI), SCL=GPIO11, CSB=GPIO8 (CE0), RS=GPIO25 (C/D), RESET=GPIO17; PSB=GND, E=3V3 (no BUSY line).
3
+ // Module capacitors: 0.1-1 uF between CAP1N and CAP1P, 0.47-2.2 uF from VOUT to GND, VIN = VDD.
4
+ 'use strict';
5
+ const { Default } = require('opengpio');
6
+ const { DisplayConnection } = require('../../../src/connection/display');
7
+ const { GpioOutputPin } = require('../../../src/connection/output_pin');
8
+ const { ST7036Full } = require('../../../src/chips/display/st7036');
9
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
10
+
11
+ const dc = new GpioOutputPin(Default.output({ chip: 0, line: 25 })); // Create RS (C/D) pin, (chip, line=25) → OutputPin
12
+ const res = new GpioOutputPin(Default.output({ chip: 0, line: 17 })); // Create RESET pin, (chip, line=17) → OutputPin
13
+ const connection = new DisplayConnection({ busNumber: 0, deviceNumber: 0, dc, res, maxSpeedHz: 1000000 }); // Create display connection, (busNumber, deviceNumber, dc, res, busy=none, maxSpeedHz=1 MHz)
14
+ const lcd = new ST7036Full(connection); // Create ST7036 driver, (connection, lines=2, columns=null, supply=SUPPLY_3V3, contrast=null)
15
+
16
+ (async () => {
17
+ await lcd.ready();
18
+ // --- Define the bar-graph glyphs ---
19
+ // Custom characters 0..4 are columns of 1..5 filled pixel columns, so a 16-character bar
20
+ // can show 80 steps with the eight CGRAM slots.
21
+ for (let g = 0; g < 5; g++) {
22
+ const pattern = (0x1F << (4 - g)) & 0x1F;
23
+ const rows = [0, 1, 2, 3, 4, 5, 6, 7].map((r) => (r === 0 || r === 7 ? 0 : pattern));
24
+ await lcd.createChar(g, rows); // Define user character, (index 0..7, rows[8]) → Promise<void>
25
+ }
26
+
27
+ // --- Static title line ---
28
+ await lcd.clear(); // Clear display, () → Promise<void>
29
+ await lcd.printAt(0, 0, 'Periph ST7036'); // Write text, (col, row, text) → Promise<void>
30
+
31
+ // --- Animate a progress bar on line 2 ---
32
+ // Each step fills 1/5 of a character cell; a full bar is 16 x 5 = 80 steps.
33
+ for (let step = 0; step <= 80; step++) {
34
+ await lcd.setCursor(0, 1); // Move cursor, (col, row) → Promise<void>
35
+ for (let col = 0; col < 16; col++) {
36
+ const fill = step - col * 5; // pixel columns of this cell that are filled
37
+ if (fill >= 5) await lcd.writeChar(4); // Write raw character code, (code) → Promise<void>
38
+ else if (fill > 0) await lcd.writeChar(fill - 1); // Write raw character code, (code) → Promise<void>
39
+ else await lcd.writeChar(0x20); // Write raw character code, (code) → Promise<void>
40
+ }
41
+ await sleep(40);
42
+ }
43
+ await sleep(1000);
44
+
45
+ // --- Contrast sweep ---
46
+ // The contrast is set once in normal use; sweeping it shows the usable range of the module.
47
+ await lcd.printAt(0, 0, 'Contrast sweep '); // Write text, (col, row, text) → Promise<void>
48
+ for (let c = 0x10; c <= 0x30; c++) {
49
+ await lcd.setContrast(c); // Set contrast, (value 0..63) → Promise<void>
50
+ await sleep(80);
51
+ }
52
+ await lcd.setContrast(0x18); // Set contrast, (value 0..63) → Promise<void>
53
+ await lcd.printAt(0, 0, 'Periph ST7036 '); // Write text, (col, row, text) → Promise<void>
54
+ connection.close();
55
+ process.exit(0);
56
+ })().catch((e) => { console.error(e); process.exit(1); });
@@ -0,0 +1,21 @@
1
+ // ST7036 minimal example: two lines of text on an EA DOGM162W-A (2 x 16, 3.3 V) on a Raspberry Pi (Node.js).
2
+ // Wiring: SI=GPIO10 (SPI0 MOSI), SCL=GPIO11, CSB=GPIO8 (CE0), RS=GPIO25 (C/D), RESET=GPIO17; PSB=GND, E=3V3 (no BUSY line).
3
+ // Module capacitors: 0.1-1 uF between CAP1N and CAP1P, 0.47-2.2 uF from VOUT to GND, VIN = VDD.
4
+ 'use strict';
5
+ const { Default } = require('opengpio');
6
+ const { DisplayConnection } = require('../../../src/connection/display');
7
+ const { GpioOutputPin } = require('../../../src/connection/output_pin');
8
+ const { ST7036Minimal } = require('../../../src/chips/display/st7036');
9
+
10
+ const dc = new GpioOutputPin(Default.output({ chip: 0, line: 25 })); // Create RS (C/D) pin, (chip, line=25) → OutputPin
11
+ const res = new GpioOutputPin(Default.output({ chip: 0, line: 17 })); // Create RESET pin, (chip, line=17) → OutputPin
12
+ const connection = new DisplayConnection({ busNumber: 0, deviceNumber: 0, dc, res, maxSpeedHz: 1000000 }); // Create display connection, (busNumber, deviceNumber, dc, res, busy=none, maxSpeedHz=1 MHz)
13
+ const lcd = new ST7036Minimal(connection); // Create ST7036 driver, (connection)
14
+
15
+ (async () => {
16
+ await lcd.ready();
17
+ await lcd.printAt(0, 0, 'Hello, Periph!'); // Write text, (col, row, text) → Promise<void>
18
+ await lcd.printAt(0, 1, 'ST7036 DOGM162'); // Write text, (col, row, text) → Promise<void>
19
+ connection.close();
20
+ process.exit(0);
21
+ })().catch((e) => { console.error(e); process.exit(1); });
@@ -0,0 +1,135 @@
1
+ // UC1611s complete example: EA DOGXL240-7 (240 x 128, 3.3 V only) over I2C on a Raspberry Pi (Node.js).
2
+ // Wiring: SDA=GPIO2, SCL=GPIO3 (/dev/i2c-1), VDD = 3V3; module pins BM0 = D13 = VDD, CD = A2 = A3 = VSS -> command 0x38 / data 0x39.
3
+ // Capacitors: 4 x 4.7 uF/5 V (VA0, VA1, VB0, VB1 pairs), 470 nF/25 V on VLCD; pull-ups 2-4.7 k to 3.3 V. Complete: every Full method - drawing, contrast, invert, flip, scroll, drive tuning, partial display, RAM screens, reads, sleep, reset.
4
+ 'use strict';
5
+ const { I2CConnection } = require('../../../src/connection/i2c');
6
+ const { UC1611sFull } = require('../../../src/chips/display/uc1611s');
7
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
8
+
9
+ const command = new I2CConnection(1, 0x38); // Create command connection, (busNumber=1, addr=0x38)
10
+ const data = new I2CConnection(1, 0x39); // Create data connection, (busNumber=1, addr=0x39)
11
+ const lcd = new UC1611sFull(command, data); // Create UC1611s driver, (command, data, width=240, height=128)
12
+
13
+ (async () => {
14
+ await lcd.ready();
15
+ // Framebuffer drawing: everything is composed in RAM and sent with show().
16
+ lcd.clear(); // Clear framebuffer, ()
17
+ // zeroes every pixel of the framebuffer; the panel is unchanged until show()
18
+ lcd.fill(true); // Fill framebuffer, (on=true)
19
+ // sets (or clears) every pixel
20
+ lcd.fill(false); // Fill framebuffer, (on=true)
21
+ lcd.drawRect(0, 0, 240, 128); // Draw rectangle, (x, y, w, h, on=true, fill=false)
22
+ // one-pixel outline around the whole panel
23
+ lcd.drawLine(0, 0, 239, 127); // Draw line, (x0, y0, x1, y1, on=true)
24
+ // Bresenham line into the framebuffer
25
+ lcd.drawLine(0, 127, 239, 0); // Draw line, (x0, y0, x1, y1, on=true)
26
+ lcd.drawRect(20, 20, 40, 30, true, true); // Draw rectangle, (x, y, w, h, on=true, fill=false)
27
+ // filled rectangle
28
+ lcd.drawRect(30, 28, 20, 14, false, true); // Draw rectangle, (x, y, w, h, on=true, fill=false)
29
+ // on=false clears pixels: a hole in the filled rectangle
30
+ lcd.setPixel(120, 64, true); // Set pixel, (x, y, on=true)
31
+ const lit = lcd.getPixel(120, 64); // Read framebuffer pixel, (x, y) → boolean
32
+ // reads the framebuffer, not the panel
33
+ const icon = [0x3C, 0x42, 0x81, 0xA5, 0x81, 0xA5, 0x99, 0x42, 0x3C, 0x00, 0x7E, 0x81, 0x81, 0x81, 0x7E, 0x00];
34
+ lcd.blit(180, 16, icon, 2); // Copy bitmap, (x, y multiple of 8, columns, heightPages=1)
35
+ // two page rows of 8 columns, bit 0 = top pixel
36
+ await lcd.show(); // Send framebuffer to the display, () → Promise<void>
37
+ // per page: page + column address, then 240 data bytes in 32-byte chunks
38
+ await sleep(2000);
39
+ await lcd.showPage(2); // Send one framebuffer page, (page 0..15) → Promise<void>
40
+ // cheaper partial update of 8 rows
41
+
42
+ // Contrast and display modes.
43
+ await lcd.setContrast(0x70); // Set contrast, (value 0..255) → Promise<void>
44
+ // writes the potentiometer PM; lower = lighter
45
+ await sleep(800);
46
+ await lcd.setContrast(0x8F); // Set contrast, (value 0..255) → Promise<void>
47
+ // 0x8F is the DOG example value
48
+ await lcd.setInvert(true); // Invert display, (on) → Promise<void>
49
+ // bit-wise inversion of what is displayed; RAM unchanged
50
+ await sleep(800);
51
+ await lcd.setInvert(false); // Invert display, (on) → Promise<void>
52
+ await lcd.setAllOn(true); // Light all pixels, (on) → Promise<void>
53
+ // test mode, RAM unchanged
54
+ await sleep(800);
55
+ await lcd.setAllOn(false); // Light all pixels, (on) → Promise<void>
56
+ await lcd.setFlip(false, true); // Mirror display, (mirrorX, mirrorY) → Promise<void>
57
+ // MY = 1: rows mirrored at once; MX is applied to RAM writes
58
+ await sleep(800);
59
+ await lcd.setFlip(true, false); // Mirror display, (mirrorX, mirrorY) → Promise<void>
60
+ // back to the bottom-view default
61
+ await lcd.show(); // Send framebuffer to the display, () → Promise<void>
62
+
63
+ // Hardware scroll with a fixed header.
64
+ await lcd.setFixedLines(2); // Set fixed lines, (lines 0..15) → Promise<void>
65
+ // the top 2 x 2 = 4 rows stay put
66
+ for (let line = 0; line <= 32; line += 4) {
67
+ await lcd.setScrollLine(line); // Scroll the image up, (line 0..159 - 2 * fixed) → Promise<void>
68
+ // rows enter from the bottom as the image moves up
69
+ await sleep(120);
70
+ }
71
+ await lcd.setScrollLine(0); // Scroll the image up, (line 0..159 - 2 * fixed) → Promise<void>
72
+ await lcd.setFixedLines(0); // Set fixed lines, (lines 0..15) → Promise<void>
73
+
74
+ // LCD drive tuning (the DOG defaults are already sent at init).
75
+ await lcd.setBiasRatio(2); // Set bias ratio, (ratio 0..3) → Promise<void>
76
+ // 0 = 1/5, 1 = 1/10, 2 = 1/11 (reset), 3 = 1/12
77
+ await lcd.setTemperatureCompensation(1); // Set temperature compensation, (curve 0..3) → Promise<void>
78
+ // 1 = -0.10 %/degC, the DOG example value
79
+ await lcd.setLineRate(3); // Set line rate, (rate 0..3) → Promise<void>
80
+ // 3 = 9.4 kilo-lines per second in On/Off mode
81
+ await lcd.setPump(true); // Select VLCD source, (internal) → Promise<void>
82
+ // internal 11x charge pump
83
+ await lcd.setPanelLoading(true); // Set panel loading, (high) → Promise<void>
84
+ // 33..55 nF panel capacitance
85
+ await lcd.setNLineInversion(0, false); // Set N-line inversion, (lines 0..63, xor=false) → Promise<void>
86
+ // 0 = off
87
+ await lcd.setIsolationClock(1, 0); // Set isolation clock, (front 0..15, back 0..15) → Promise<void>
88
+ // the reset values
89
+
90
+ // Partial display: scan only the middle 64 rows.
91
+ await lcd.setPartialDisplay(true, 32, 95); // Set partial display, (on, start=0, end=height-1) → Promise<void>
92
+ // rows outside 32..95 are not scanned and save power
93
+ await sleep(1500);
94
+ await lcd.setPartialDisplay(false); // Set partial display, (on, start=0, end=height-1) → Promise<void>
95
+ // back to the full panel
96
+
97
+ // Four RAM screens: draw into screen 1, then switch to it.
98
+ lcd.setWritePattern(1); // Select RAM screen to write, (pattern 0..3)
99
+ // show() now writes RAM screen 1
100
+ lcd.fill(false); // Fill framebuffer, (on=true)
101
+ lcd.drawRect(40, 30, 160, 68, true, true); // Draw rectangle, (x, y, w, h, on=true, fill=false)
102
+ await lcd.show(); // Send framebuffer to the display, () → Promise<void>
103
+ // screen 0 is still displayed
104
+ await lcd.setDisplayPattern(1); // Select displayed RAM screen, (pattern 0..3) → Promise<void>
105
+ // the display now shows RAM screen 1
106
+ await sleep(1500);
107
+ await lcd.setDisplayPattern(0); // Select displayed RAM screen, (pattern 0..3) → Promise<void>
108
+ lcd.setWritePattern(0); // Select RAM screen to write, (pattern 0..3)
109
+
110
+ // Read back over I2C.
111
+ const status = await lcd.readStatus(); // Read status bytes, () → Promise<Buffer>
112
+ // NOP first, then Status1 = Ver MX MY WA DE WS MD MS, Status3 high nibble = product code 1
113
+ console.log('status', [...status].map((b) => b.toString(16).padStart(2, '0')).join(' '));
114
+ const ram = await lcd.readRam(0, 0, 8); // Read display RAM, (page, column, n) → Promise<Buffer>
115
+ // the dummy byte after the address change is discarded
116
+ console.log('ram', ram.toString('hex'));
117
+
118
+ // Sleep, raw access, reset.
119
+ await lcd.sleep(); // Enter sleep, () → Promise<void>
120
+ // drivers, pump and clock stop; registers and RAM are kept
121
+ await sleep(1000);
122
+ await lcd.wake(); // Leave sleep, () → Promise<void>
123
+ // polls Status1.DE while the chip restores VLCD
124
+ await lcd.sendCommand(0xE3); // Send raw command bytes, (...bytes) → Promise<void>
125
+ // 0xE3 = NOP
126
+ await lcd.sendData(Buffer.alloc(8)); // Send raw RAM data, (bytes) → Promise<void>
127
+ // written at the current RAM address
128
+ await lcd.reset(); // System Reset and reconfigure, () → Promise<void>
129
+ // registers back to the DOG settings with the cached contrast and mapping; RAM is kept
130
+ void lit;
131
+ console.log(`done (I2C retries ${lcd.retryCount()}, unrecovered ${lcd.errorCount()})`);
132
+ command.close();
133
+ data.close();
134
+ process.exit(0);
135
+ })().catch((e) => { console.error(e); process.exit(1); });
@@ -0,0 +1,128 @@
1
+ // UC1611s complete example (4-wire SPI): EA DOGXL240-7 (240 x 128, 3.3 V only) on a Raspberry Pi (Node.js).
2
+ // Wiring: SI=GPIO10 (SPI0 MOSI), SCK=GPIO11, CS0=GPIO8 (CE0), CD=GPIO25, RST=GPIO17; VDD=3V3; module pins BM0 = D13 = VSS (4-wire SPI).
3
+ // Capacitors: 4 x 4.7 uF/5 V (VA0, VA1, VB0, VB1 pairs), 470 nF/25 V on VLCD. Complete: every Full method - drawing, contrast, invert, flip, scroll, drive tuning, partial display, RAM screens, sleep, raw access, reset (SPI has no read-back).
4
+ 'use strict';
5
+ const { Default } = require('opengpio');
6
+ const { DisplayConnection } = require('../../../src/connection/display');
7
+ const { GpioOutputPin } = require('../../../src/connection/output_pin');
8
+ const { UC1611sSpiFull } = require('../../../src/chips/display/uc1611s');
9
+
10
+ const dc = new GpioOutputPin(Default.output({ chip: 0, line: 25 })); // Create CD (D/C) pin, (chip, line=25) → OutputPin
11
+ const res = new GpioOutputPin(Default.output({ chip: 0, line: 17 })); // Create RST pin, (chip, line=17) → OutputPin
12
+ const connection = new DisplayConnection({ busNumber: 0, deviceNumber: 0, dc, res, maxSpeedHz: 4000000 }); // Create display connection, (busNumber, deviceNumber, dc, res, busy=none, maxSpeedHz=4 MHz)
13
+ const lcd = new UC1611sSpiFull(connection); // Create UC1611s driver, (connection, width=240, height=128, topView=false, contrast=0x8F)
14
+
15
+ (async () => {
16
+ await lcd.ready();
17
+ // Framebuffer drawing: everything is composed in RAM and sent with show().
18
+ lcd.clear(); // Clear framebuffer, ()
19
+ // zeroes every pixel of the framebuffer; the panel is unchanged until show()
20
+ lcd.fill(true); // Fill framebuffer, (on=true)
21
+ // sets (or clears) every pixel
22
+ lcd.fill(false); // Fill framebuffer, (on=true)
23
+ lcd.drawRect(0, 0, 240, 128); // Draw rectangle, (x, y, w, h, on=true, fill=false)
24
+ // one-pixel outline around the whole panel
25
+ lcd.drawLine(0, 0, 239, 127); // Draw line, (x0, y0, x1, y1, on=true)
26
+ // Bresenham line into the framebuffer
27
+ lcd.drawLine(0, 127, 239, 0); // Draw line, (x0, y0, x1, y1, on=true)
28
+ lcd.drawRect(20, 20, 40, 30, true, true); // Draw rectangle, (x, y, w, h, on=true, fill=false)
29
+ // filled rectangle
30
+ lcd.drawRect(30, 28, 20, 14, false, true); // Draw rectangle, (x, y, w, h, on=true, fill=false)
31
+ // on=false clears pixels: a hole in the filled rectangle
32
+ lcd.setPixel(120, 64, true); // Set pixel, (x, y, on=true)
33
+ const lit = lcd.getPixel(120, 64); // Read framebuffer pixel, (x, y) → boolean
34
+ // reads the framebuffer, not the panel
35
+ const icon = [0x3C, 0x42, 0x81, 0xA5, 0x81, 0xA5, 0x99, 0x42, 0x3C, 0x00, 0x7E, 0x81, 0x81, 0x81, 0x7E, 0x00];
36
+ lcd.blit(180, 16, icon, 2); // Copy bitmap, (x, y multiple of 8, columns, heightPages=1)
37
+ // two page rows of 8 columns, bit 0 = top pixel
38
+ await lcd.show(); // Send framebuffer to the display, () → Promise<void>
39
+ // per page: page + column address, then 240 data bytes in one transfer
40
+ await sleep(2000);
41
+ await lcd.showPage(2); // Send one framebuffer page, (page 0..15) → Promise<void>
42
+ // cheaper partial update of 8 rows
43
+
44
+ // Contrast and display modes.
45
+ await lcd.setContrast(0x70); // Set contrast, (value 0..255) → Promise<void>
46
+ // writes the potentiometer PM; lower = lighter
47
+ await sleep(800);
48
+ await lcd.setContrast(0x8F); // Set contrast, (value 0..255) → Promise<void>
49
+ // 0x8F is the DOG example value
50
+ await lcd.setInvert(true); // Invert display, (on) → Promise<void>
51
+ // bit-wise inversion of what is displayed; RAM unchanged
52
+ await sleep(800);
53
+ await lcd.setInvert(false); // Invert display, (on) → Promise<void>
54
+ await lcd.setAllOn(true); // Light all pixels, (on) → Promise<void>
55
+ // test mode, RAM unchanged
56
+ await sleep(800);
57
+ await lcd.setAllOn(false); // Light all pixels, (on) → Promise<void>
58
+ await lcd.setFlip(false, true); // Mirror display, (mirrorX, mirrorY) → Promise<void>
59
+ // MY = 1: rows mirrored at once; MX is applied to RAM writes
60
+ await sleep(800);
61
+ await lcd.setFlip(true, false); // Mirror display, (mirrorX, mirrorY) → Promise<void>
62
+ // back to the bottom-view default
63
+ await lcd.show(); // Send framebuffer to the display, () → Promise<void>
64
+
65
+ // Hardware scroll with a fixed header.
66
+ await lcd.setFixedLines(2); // Set fixed lines, (lines 0..15) → Promise<void>
67
+ // the top 2 x 2 = 4 rows stay put
68
+ for (let line = 0; line <= 32; line += 4) {
69
+ await lcd.setScrollLine(line); // Scroll the image up, (line 0..159 - 2 * fixed) → Promise<void>
70
+ // rows enter from the bottom as the image moves up
71
+ await sleep(120);
72
+ }
73
+ await lcd.setScrollLine(0); // Scroll the image up, (line 0..159 - 2 * fixed) → Promise<void>
74
+ await lcd.setFixedLines(0); // Set fixed lines, (lines 0..15) → Promise<void>
75
+
76
+ // LCD drive tuning (the DOG defaults are already sent at init).
77
+ await lcd.setBiasRatio(2); // Set bias ratio, (ratio 0..3) → Promise<void>
78
+ // 0 = 1/5, 1 = 1/10, 2 = 1/11 (reset), 3 = 1/12
79
+ await lcd.setTemperatureCompensation(1); // Set temperature compensation, (curve 0..3) → Promise<void>
80
+ // 1 = -0.10 %/degC, the DOG example value
81
+ await lcd.setLineRate(3); // Set line rate, (rate 0..3) → Promise<void>
82
+ // 3 = 9.4 kilo-lines per second in On/Off mode
83
+ await lcd.setPump(true); // Select VLCD source, (internal) → Promise<void>
84
+ // internal 11x charge pump
85
+ await lcd.setPanelLoading(true); // Set panel loading, (high) → Promise<void>
86
+ // 33..55 nF panel capacitance
87
+ await lcd.setNLineInversion(0, false); // Set N-line inversion, (lines 0..63, xor=false) → Promise<void>
88
+ // 0 = off
89
+ await lcd.setIsolationClock(1, 0); // Set isolation clock, (front 0..15, back 0..15) → Promise<void>
90
+ // the reset values
91
+
92
+ // Partial display: scan only the middle 64 rows.
93
+ await lcd.setPartialDisplay(true, 32, 95); // Set partial display, (on, start=0, end=height-1) → Promise<void>
94
+ // rows outside 32..95 are not scanned and save power
95
+ await sleep(1500);
96
+ await lcd.setPartialDisplay(false); // Set partial display, (on, start=0, end=height-1) → Promise<void>
97
+ // back to the full panel
98
+
99
+ // Four RAM screens: draw into screen 1, then switch to it.
100
+ lcd.setWritePattern(1); // Select RAM screen to write, (pattern 0..3)
101
+ // show() now writes RAM screen 1
102
+ lcd.fill(false); // Fill framebuffer, (on=true)
103
+ lcd.drawRect(40, 30, 160, 68, true, true); // Draw rectangle, (x, y, w, h, on=true, fill=false)
104
+ await lcd.show(); // Send framebuffer to the display, () → Promise<void>
105
+ // screen 0 is still displayed
106
+ await lcd.setDisplayPattern(1); // Select displayed RAM screen, (pattern 0..3) → Promise<void>
107
+ // the display now shows RAM screen 1
108
+ await sleep(1500);
109
+ await lcd.setDisplayPattern(0); // Select displayed RAM screen, (pattern 0..3) → Promise<void>
110
+ lcd.setWritePattern(0); // Select RAM screen to write, (pattern 0..3)
111
+
112
+ // Sleep, raw access, reset.
113
+ await lcd.sleep(); // Enter sleep, () → Promise<void>
114
+ // drivers, pump and clock stop; registers and RAM are kept
115
+ await sleep(1000);
116
+ await lcd.wake(); // Leave sleep, () → Promise<void>
117
+ // polls Status1.DE while the chip restores VLCD
118
+ await lcd.sendCommand(0xE3); // Send raw command bytes, (...bytes) → Promise<void>
119
+ // 0xE3 = NOP
120
+ await lcd.sendData(Buffer.alloc(8)); // Send raw RAM data, (bytes) → Promise<void>
121
+ // written at the current RAM address
122
+ await lcd.reset(); // System Reset and reconfigure, () → Promise<void>
123
+ // registers back to the DOG settings with the cached contrast and mapping; RAM is kept
124
+ void lit;
125
+ console.log('done');
126
+ connection.close();
127
+ process.exit(0);
128
+ })().catch((e) => { console.error(e); process.exit(1); });