This is a Node.JS for the SSD1306 OLED display which will be placed inside the R nineT navigation tower to provide some basic system status information.
Unlike other OLED display drivers, this one doesn't use an in-memory buffer. All data is written directly to the screen. In case an application needs double buffering for drawing to the screen, it will have to implement it.
Running an event driven service will soon show you that the OLED display will crash and start showing an odd behaviour if some kind of thread synchronisation isn't used. This module uses a mutex from async-lock internally, making it thread safe.
The module exposes the following methods:
init(width, height)
- initialises a new device with the given dimensionsreset()
- resets the device, this is part of the initialisation scheduledisplay(buffer, x, y, width, pages)
- writes the data in the given buffer on a section of the screen, if no buffer is specified the entire in-memory buffer is written to the displayclear(page)
- clears a single page on the in-memory buffer or all pages if no page is specifiedwidth()
- the actual width of the device in pixelsheight()
- the actual height on the device in pixelspages()
- the number of pages available in the device (height / 8) - each page is one byte (8 bits) tall
The module exposes the following constants:
SPLASH
- used for testing purposes and some funSPI_BUS
- the default SPI bus is 0DEVICE_NUMBER
- the default device number is 0WIDTH
- the default width of the screenHEIGHT
- the default height of the screen
The script test.js provides some sample code which may be used to test connectivity to the device.
The script crash.js was used to crash the OLED display before adding the mutex. It now confirms it is thread safe.
This module isn't published to the NPM registry and needs to be installed from GitHub with the command:
npm install https://github.com/sailingscally/ssd1306