Display
Overview
This sample uses the display API to draw some basic shapes onto the display.
For most display controllers, the shapes will be rectangles whose colors and positions are chosen so that the orientation of the LCD and correct RGB bit order can be checked. The rectangles are drawn in clockwise order, from top left corner: red, green, blue, grey. The shade of grey changes from black to white.
Tip
If the grey looks too green or red at any point or the order of the corners is not as described above then the LCD may be endian swapped!
Typical RGB output at 320x240: red, green, and blue corners (clockwise from top left); bottom left animates from black to white. Corner sizes scale with resolution on real hardware.
On displays where it is only possible to draw full lines at a time (see
SCREEN_INFO_X_ALIGNMENT_WIDTH), such as those using the
sharp,ls0xx driver, the rectangles described in the RGB tab will be replaced
with bars that take up the entire width of the display.
Only the green and grey bars will be visible (each corner draw uses the full width, so the top-left and top-right draws overlap at the top, and the bottom-right and bottom-left draws overlap at the bottom).
Full-width bands: green at the top, animated grey at the bottom.
On displays using an 8-bit luminance format (for example PIXEL_FORMAT_L_8),
each corner is a different grey level; the bottom-left patch still animates from black to
white. Other multi-bit monochrome formats behave similarly (different greys per corner).
Grayscale-style corners; bottom left animates through grey levels toward white.
On displays with 1 bit per pixel, the greyscale animation of the bottom rectangle (or bar) will appear as flickering between black and white. Other corners stay at a fixed color that matches the display background for the active pixel format.
1 bpp: three corners stay at the background color (black for MONO01,
white for MONO10 on a black screen); bottom-left toggles.
By querying the display controller’s capabilities, it is possible to determine if the display
is an e-paper display by checking if the SCREEN_INFO_EPD bit is set in the
display_capabilities.screen_info.
For such displays, the color of the bottom-left corner will change at a much slower rate than on a typical LCD, to align with the typical refresh rate of e-ink technologies.
Building and Running
As this is a generic sample it should work with any display supported by Zephyr.
Below is an example on how to build for a nRF52840 DK board with a Adafruit 2.8” TFT Touch Shield v2.
west build -b nrf52840dk/nrf52840 --shield adafruit_2_8_tft_touch_v2 samples/drivers/display
For testing purpose without the need of any hardware, the native_sim board is also supported and can be built as follows;
west build -b native_sim samples/drivers/display