This library is a wrapper for the display-hat-mini-driver, that allows the use of the Pimoroni Display HAT Mini.
To install and build, please install the latest Rust language version. Which is required by Neon, the bindings library used to enable access to display-hat-mini-driver
from node.js.
This is a simple example on how to use this library:
const dhtm = require('display-hat-mini-node');
const width = dhtm.width();
const height = dhtm.height();
const data = new Uint8Array(width * height * 3);
dhtm.init(); //this is always needed
for (let i = 0; i < height; i++) {
for (let j = 0; j < width; j++) {
let offset = (i * width + j) * 3;
data[offset] = i; //red
data[offset + 1] = j; //green
data[offset + 2] = 0; //blue
}
}
const buffer = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
dhtm.display(buffer);
display(Buffer)
Call this function to draw a bitmap in the display. This bitmap should have 320x240 pixels where each pixel is 3 bytes, i.e. RGB24.
setVSync(Boolean)
Instructs the driver to wait for the tear effect pin to become high before writing the bitmap data. It does not totally eliminate image tearing while drawing.
readButtons()
The return value of this function is a flags byte indicating the state of the hardward buttons. For more information refer to this explanation.
setLED(red, green, blue)
Simply call this function to show the RGB in the integrated RGB LED.