it8951
Version:
Raspberry Pi node.js module for e-papers controlled by IT8951
308 lines (306 loc) • 9.8 kB
TypeScript
/// <reference types="node" />
/**
* Return object for system information call.
*
* @export
*/
export interface SystemInfo {
/**
* Width of screen in pixels.
*/
width: number;
/**
* Height of screen in pixels.
*/
height: number;
/**
* Internal image buffer address.
*/
imbufferadr: number;
/**
* Firmware version.
*/
firmware: string;
/**
* LUT loaded.
*/
lut: string;
}
/**
* System register addresses
*
* @enum {number}
*/
declare enum SYS_REG {
/** Address of System Registers */
I80CPCR
}
/**
* Image rotation. All rotations are clockwise from the base of the screen.
*
* @export
* @enum {number}
*/
export declare enum IMAGE_ROTATION {
/**
* Rotate zero degrees. Default rotation in methods supporting rotation.
*/
ROTATE_0 = 0,
/**
* Rotate 90 degrees.
*/
ROTATE_90 = 1,
/**
* Rotate 180 degress.
*/
ROTATE_180 = 2,
/**
* Rotate 270 degrees.
*/
ROTATE_270 = 3
}
/**
* Pixel packaging mode.
*
* @export
* @enum {number}
*/
export declare enum PIXEL_PACKING {
/**
* Two bits per pixel
*/
BPP2 = 0,
/**
* Three bits per pixel
*/
BPP3 = 1,
/**
* Four bits per pixel
*/
BPP4 = 2,
/**
* Eight bits per pixel
*/
BPP8 = 3
}
/**
* Endianness of the image data. Only relevant when sending data less than 8BPP.
*
* @export
* @enum {number}
*/
export declare enum ENDIANNESS {
/**
* Data is packed with little endian order.
*/
LITTLE = 0,
/**
* Data is packed with big endian order.
*/
BIG = 1
}
/**
* Waveform mode used when updating the display. Further information is available in the [mode declaration]{@link https://www.waveshare.com/w/upload/c/c4/E-paper-mode-declaration.pdf}.
*
* @export
*/
export declare enum WAVEFORM {
/**
* The initialization (INIT) mode is used to completely erase the display and leave it in the white state. It is
* useful for situations where the display information in memory is not a faithful representation of the optical
* state of the display, for example, after the device receives power after it has been fully powered down. This
* waveform switches the display several times and leaves it in the white state.
*
* **Usage:** Display initialization
*
* **Ghosting:** N/A
*
* **Typical update time:** 2000ms
*/
INIT = 0,
/**
* The direct update (DU) is a very fast, non-flashy update. This mode supports transitions from any graytone
* to black or white only. It cannot be used to update to any graytone other than black or white. The fast
* update time for this mode makes it useful for response to touch sensor or pen input or menu selection
* indictors.
*
* **Usage:** Monochrome menu, text input, and touch screen/pen input
*
* **Ghosting:** Low
*
* **Typical update time:** 260ms
*/
DU = 1,
/**
* The grayscale clearing (GC16) mode is used to update the full display and provide a high image quality.
* When GC16 is used with Full Display Update the entire display will update as the new image is written. If a
* Partial Update command is used the only pixels with changing graytone values will update. The GC16 mode
* has 16 unique gray levels.
*
* **Usage:** High quality images
*
* **Ghosting:** Very low
*
* **Typical update time:** 450ms
*/
GC16 = 2,
/**
* The GL16 waveform is primarily used to update sparse content on a white background, such as a page of
* anti-aliased text, with reduced flash. The GL16 waveform has 16 unique gray levels.
*
* **Usage:** Text with white background
*
* **Ghosting:** Medium
*
* **Typical update time:** 450ms
*/
GL16 = 3,
/**
* The GLR16 mode is used in conjunction with an image preprocessing algorithm to update sparse content on
* a white background with reduced flash and reduced image artifacts. The GLR16 mode supports 16
* graytones. If only the even pixel states are used (0, 2, 4, … 30), the mode will behave exactly as a traditional
* GL16 waveform mode. If a separately-supplied image preprocessing algorithm is used, the transitions
* invoked by the pixel states 29 and 31 are used to improve display quality. For the AF waveform, it is
* assured that the GLR16 waveform data will point to the same voltage lists as the GL16 data and does not
* need to be stored in a separate memory.
*
* **Usage:** Text with white background
*
* **Ghosting:** Low
*
* **Typical update time:** 450ms
*/
GLR16 = 4,
/**
* The GLD16 mode is used in conjunction with an image preprocessing algorithm to update sparse content
* on a white background with reduced flash and reduced image artifacts. It is recommended to be used only
* with the full display update. The GLD16 mode supports 16 graytones. If only the even pixel states are used
* (0, 2, 4, … 30), the mode will behave exactly as a traditional GL16 waveform mode. If a separately-supplied
* image preprocessing algorithm is used, the transitions invoked by the pixel states 29 and 31 are used to
* refresh the background with a lighter flash compared to GC16 mode following a predetermined pixel map
* as encoded in the waveform file, and reduce image artifacts even more compared to the GLR16 mode. For
* the AF waveform, it is assured that the GLD16 waveform data will point to the same voltage lists as the
* GL16 data and does not need to be stored in a separate memory.
*
* **Usage:** Text and graphics with white background
*
* **Ghosting:** Low
*
* **Typical update time:** 450ms
*/
GLD16 = 5,
/**
* The A2 mode is a fast, non-flash update mode designed for fast paging turning or simple black/white
* animation. This mode supports transitions from and to black or white only. It cannot be used to update to
* any graytone other than black or white. The recommended update sequence to transition into repeated A2
* updates is shown in Figure 1. The use of a white image in the transition from 4-bit to 1-bit images will
* reduce ghosting and improve image quality for A2 updates.
*
* **Usage:** Fast page flipping at reduced contrast
*
* **Ghosting:** Medium
*
* **Typical update time:** 120ms
*/
A2 = 6,
/**
* The DU4 is a fast update time (similar to DU), non-flashy waveform. This mode supports transitions from
* any gray tone to gray tones 1,6,11,16 represented by pixel states [0 10 20 30]. The combination of fast
* update time and four gray tones make it useful for anti-aliased text in menus. There is a moderate increase
* in ghosting compared with GC16.
*
* **Usage:** Anti-aliased text in menus / touch and screen/pen input
*
* **Ghosting:** Medium
*
* **Typical update time:** 290ms
*/
DU4 = 7
}
export declare class IT8951 {
private info;
private spi;
/**
* Creates an instance of IT8951. If the voltage is omitted then the controller default of -1.5v is used.
* @param vcom Set the voltage of the display.
*/
constructor(vcom?: number);
/**
* Queries the controller for the dev info.
*/
systemInfo(): SystemInfo;
/**
* Return the voltage
*/
get vcom(): number;
/**
* Sets the voltage
*/
set vcom(vcom: number);
/**
* Sets register `address` to `value`.
*
* @param address Address value to set
* @param value Value to set
*/
setRegister(address: number | SYS_REG, value: number): void;
/**
* Reads register value at `address`
*
* @param address Address value to read
*/
readRegister(address: number | SYS_REG): number;
/**
* Loads an image to memory without updating display.
*
* @param x vertical start of area to load
* @param y horizontal start of area to load
* @param width width of data to load
* @param height height of data to load
* @param image image data to transfer
* @param bpp byte packing of image data
* @param [rotate=IMAGE_ROTATION.ROTATE_0] rotate data for storage
* @param [endianism=ENDIANNESS.LITTLE] image data endianness
*/
writePixels(x: number, y: number, width: number, height: number, image: Buffer, bpp: PIXEL_PACKING, rotate?: IMAGE_ROTATION, endianism?: ENDIANNESS): void;
/**
* Updates a region of the screen with a previously loaded image.
*
* @param x vertical start of area to dsiplay
* @param y horizontal start of area to dsiplay
* @param width width of data to dsiplay
* @param height height of data to dsiplay
* @param mode waveform mode to update display
*/
displayArea(x: number, y: number, width: number, height: number, mode: WAVEFORM): void;
/**
* Issues the display running command.
*
* Enables all clocks and goes to active state.
*
*/
run(): void;
/**
* Issues the display standby command.
*
* Gate off clocks and go to standby state.
*/
standby(): void;
/**
* Issues the display sleep command.
*
* Disables all clocks and goes to sleep state.
*/
sleep(): void;
/**
* Returns a promise that resolves when all the lut engines are ready.
*
* @return {*}
*/
waitForDisplayReady(): Promise<unknown>;
/**
* Resets the controller.
*/
reset(): any;
}
export {};