Display Interface APIs

Generic Display Interface

group display_interface

Display Interface.

Typedefs

typedef display_blanking_on_api

Callback API to turn on display blanking See display_blanking_on() for argument description.

typedef display_blanking_off_api

Callback API to turn off display blanking See display_blanking_off() for argument description.

typedef display_write_api

Callback API for writing data to the display See display_write() for argument description.

typedef display_read_api

Callback API for reading data from the display See display_read() for argument description.

typedef display_get_framebuffer_api

Callback API to get framebuffer pointer See display_get_framebuffer() for argument description.

typedef display_set_brightness_api

Callback API to set display brightness See display_set_brightness() for argument description.

typedef display_set_contrast_api

Callback API to set display contrast See display_set_contrast() for argument description.

typedef display_get_capabilities_api

Callback API to get display capabilities See display_get_capabilities() for argument description.

typedef display_set_pixel_format_api

Callback API to set pixel format used by the display See display_set_pixel_format() for argument description.

typedef display_set_orientation_api

Callback API to set orientation used by the display See display_set_orientation() for argument description.

Enums

enum display_pixel_format

Values:

PIXEL_FORMAT_RGB_888 = BIT(0)
PIXEL_FORMAT_MONO01 = BIT(1)
PIXEL_FORMAT_MONO10 = BIT(2)
PIXEL_FORMAT_ARGB_8888 = BIT(3)
enum display_screen_info

Values:

SCREEN_INFO_MONO_VTILED = BIT(0)

If selected, one octet represents 8 pixels ordered vertically, otherwise ordered horizontally.

SCREEN_INFO_MONO_MSB_FIRST = BIT(1)

If selected, the MSB represents the first pixel, otherwise MSB represents the last pixel.

SCREEN_INFO_EPD = BIT(2)

Electrophoretic Display.

SCREEN_INFO_DOUBLE_BUFFER = BIT(3)

Screen has two alternating ram buffers

enum display_orientation

Enumeration with possible display orientation.

Values:

DISPLAY_ORIENTATION_NORMAL
DISPLAY_ORIENTATION_ROTATED_90
DISPLAY_ORIENTATION_ROTATED_180
DISPLAY_ORIENTATION_ROTATED_270

Functions

static int display_write(const struct device *dev, const u16_t x, const u16_t y, const struct display_buffer_descriptor *desc, const void *buf)

Write data to display.

Parameters
  • dev: Pointer to device structure
  • x: x Coordinate of the upper left corner where to write the buffer
  • y: y Coordinate of the upper left corner where to write the buffer
  • desc: Pointer to a structure describing the buffer layout
  • buf: Pointer to buffer array
Return Value
  • 0: on success else negative errno code.

static int display_read(const struct device *dev, const u16_t x, const u16_t y, const struct display_buffer_descriptor *desc, void *buf)

Read data from display.

Parameters
  • dev: Pointer to device structure
  • x: x Coordinate of the upper left corner where to read from
  • y: y Coordinate of the upper left corner where to read from
  • desc: Pointer to a structure describing the buffer layout
  • buf: Pointer to buffer array
Return Value
  • 0: on success else negative errno code.

static void *display_get_framebuffer(const struct device *dev)

Get pointer to framebuffer for direct access.

Parameters
  • dev: Pointer to device structure
Return Value
  • Pointer: to frame buffer or NULL if direct framebuffer access is not supported

static int display_blanking_on(const struct device *dev)

Turn display blanking on.

Parameters
  • dev: Pointer to device structure
Return Value
  • 0: on success else negative errno code.

static int display_blanking_off(const struct device *dev)

Turn display blanking off.

Parameters
  • dev: Pointer to device structure
Return Value
  • 0: on success else negative errno code.

static int display_set_brightness(const struct device *dev, u8_t brightness)

Set the brightness of the display.

Set the brightness of the display in steps of 1/256, where 255 is full brightness and 0 is minimal.

Parameters
  • dev: Pointer to device structure
  • brightness: Brightness in steps of 1/256
Return Value
  • 0: on success else negative errno code.

static int display_set_contrast(const struct device *dev, u8_t contrast)

Set the contrast of the display.

Set the contrast of the display in steps of 1/256, where 255 is maximum difference and 0 is minimal.

Parameters
  • dev: Pointer to device structure
  • contrast: Contrast in steps of 1/256
Return Value
  • 0: on success else negative errno code.

static void display_get_capabilities(const struct device *dev, struct display_capabilities *capabilities)

Get display capabilities.

Parameters
  • dev: Pointer to device structure
  • capabilities: Pointer to capabilities structure to populate

static int display_set_pixel_format(const struct device *dev, const enum display_pixel_format pixel_format)

Set pixel format used by the display.

Parameters
  • dev: Pointer to device structure
  • pixel_format: Pixel format to be used by display
Return Value
  • 0: on success else negative errno code.

static int display_set_orientation(const struct device *dev, const enum display_orientation orientation)

Set display orientation.

Parameters
  • dev: Pointer to device structure
  • orientation: Orientation to be used by display
Return Value
  • 0: on success else negative errno code.

Variables

u16_t x_resolution

Display resolution in the X direction

u16_t y_resolution

Display resolution in the Y direction

u32_t supported_pixel_formats

Bitwise or of pixel formats supported by the display

u32_t screen_info

Information about display panel

display_pixel_format current_pixel_format

Currently active pixel format for the display

display_orientation current_orientation

Current display orientation

u32_t buf_size

Data buffer size in bytes

u16_t width

Data buffer row width in pixels

u16_t height

Data buffer column height in pixels

u16_t pitch

Number of pixels between consecutive rows in the data buffer

struct display_capabilities
#include <display.h>

Structure holding display capabilities.

struct display_buffer_descriptor
#include <display.h>

Structure to describe display data buffer layout.

struct display_driver_api
#include <display.h>

Display driver API API which a display driver should expose.

Grove LCD Display

group grove_display

Grove display APIs.

Defines

GROVE_LCD_NAME
GLCD_DS_DISPLAY_ON
GLCD_DS_DISPLAY_OFF
GLCD_DS_CURSOR_ON
GLCD_DS_CURSOR_OFF
GLCD_IS_SHIFT_INCREMENT
GLCD_IS_SHIFT_DECREMENT
GLCD_IS_ENTRY_LEFT
GLCD_IS_ENTRY_RIGHT
GLCD_FS_8BIT_MODE
GLCD_FS_ROWS_2
GLCD_FS_ROWS_1
GLCD_FS_DOT_SIZE_BIG
GLCD_FS_DOT_SIZE_LITTLE
GROVE_RGB_WHITE
GROVE_RGB_RED
GROVE_RGB_GREEN
GROVE_RGB_BLUE

Functions

void glcd_print(struct device *port, char *data, u32_t size)

Send text to the screen.

Parameters
  • port: Pointer to device structure for driver instance.
  • data: the ASCII text to display
  • size: the length of the text in bytes

void glcd_cursor_pos_set(struct device *port, u8_t col, u8_t row)

Set text cursor position for next additions.

Parameters
  • port: Pointer to device structure for driver instance.
  • col: the column for the cursor to be moved to (0-15)
  • row: the row it should be moved to (0 or 1)

void glcd_clear(struct device *port)

Clear the current display.

Parameters
  • port: Pointer to device structure for driver instance.

void glcd_display_state_set(struct device *port, u8_t opt)

Function to change the display state.

This function provides the user the ability to change the state of the display as per needed. Controlling things like powering on or off the screen, the option to display the cursor or not, and the ability to blink the cursor.

Parameters
  • port: Pointer to device structure for driver instance.
  • opt: An 8bit bitmask of GLCD_DS_* options.

u8_t glcd_display_state_get(struct device *port)

return the display feature set associated with the device

Return
the display feature set associated with the device.
Parameters
  • port: the Grove LCD to get the display features set

void glcd_input_state_set(struct device *port, u8_t opt)

Function to change the input state.

This function provides the user the ability to change the state of the text input. Controlling things like text entry from the left or right side, and how far to increment on new text

Parameters
  • port: Pointer to device structure for driver instance.
  • opt: A bitmask of GLCD_IS_* options

u8_t glcd_input_state_get(struct device *port)

return the input set associated with the device

Return
the input set associated with the device.
Parameters
  • port: the Grove LCD to get the input features set

void glcd_function_set(struct device *port, u8_t opt)

Function to set the functional state of the display.

This function provides the user the ability to change the state of the display as per needed. Controlling things like the number of rows, dot size, and text display quality.

Parameters
  • port: Pointer to device structure for driver instance.
  • opt: A bitmask of GLCD_FS_* options

u8_t glcd_function_get(struct device *port)

return the function set associated with the device

Return
the function features set associated with the device.
Parameters
  • port: the Grove LCD to get the functions set

void glcd_color_select(struct device *port, u8_t color)

Set LCD background to a predefined color.

Parameters
  • port: Pointer to device structure for driver instance.
  • color: One of the predefined color options

void glcd_color_set(struct device *port, u8_t r, u8_t g, u8_t b)

Set LCD background to custom RGB color value.

Parameters
  • port: Pointer to device structure for driver instance.
  • r: A numeric value for the red color (max is 255)
  • g: A numeric value for the green color (max is 255)
  • b: A numeric value for the blue color (max is 255)

int glcd_initialize(struct device *port)

Initialize the Grove LCD panel.

Return
Returns 0 if all passes
Parameters
  • port: Pointer to device structure for driver instance.

BBC micro:bit Display

group mb_display

BBC micro:bit display APIs.

Defines

MB_IMAGE(_rows...)

Generate an image object from a given array rows/columns.

This helper takes an array of 5 rows, each consisting of 5 0/1 values which correspond to the columns of that row. The value 0 means the pixel is disabled whereas a 1 means the pixel is enabled.

The pixels go from left to right and top to bottom, i.e. top-left corner is the first row’s first value, top-right is the first rows last value, and bottom-right corner is the last value of the last (5th) row. As an example, the following would create a smiley face image:

Return
Image bitmap that can be passed e.g. to mb_display_image().
Parameters
  • _rows: Each of the 5 rows represented as a 5-value column array.

Enums

enum mb_display_mode

Display mode.

First 16 bits are reserved for modes, last 16 for flags.

Values:

MB_DISPLAY_MODE_DEFAULT

Default mode (“single” for images, “scroll” for text).

MB_DISPLAY_MODE_SINGLE

Display images sequentially, one at a time.

MB_DISPLAY_MODE_SCROLL

Display images by scrolling.

MB_DISPLAY_FLAG_LOOP = BIT(16)

Loop back to the beginning when reaching the last image.

Functions

struct mb_display *mb_display_get(void)

Get a pointer to the BBC micro:bit display object.

Return
Pointer to display object.

void mb_display_image(struct mb_display *disp, u32_t mode, s32_t duration, const struct mb_image *img, u8_t img_count)

Display one or more images on the BBC micro:bit LED display.

This function takes an array of one or more images and renders them sequentially on the micro:bit display. The call is asynchronous, i.e. the processing of the display happens in the background. If there is another image being displayed it will be canceled and the new one takes over.

Parameters
  • disp: Display object.
  • mode: One of the MB_DISPLAY_MODE_* options.
  • duration: Duration how long to show each image (in milliseconds).
  • img: Array of image bitmaps (struct mb_image objects).
  • img_count: Number of images in ‘img’ array.

void mb_display_print(struct mb_display *disp, u32_t mode, s32_t duration, const char *fmt, ...)

Print a string of characters on the BBC micro:bit LED display.

This function takes a printf-style format string and outputs it in a scrolling fashion to the display.

The call is asynchronous, i.e. the processing of the display happens in the background. If there is another image or string being displayed it will be canceled and the new one takes over.

Parameters
  • disp: Display object.
  • mode: One of the MB_DISPLAY_MODE_* options.
  • duration: Duration how long to show each character (in milliseconds).
  • fmt: printf-style format string
  • ...: Optional list of format arguments.

void mb_display_stop(struct mb_display *disp)

Stop the ongoing display of an image.

Parameters
  • disp: Display object.

struct mb_image
#include <mb_display.h>

Representation of a BBC micro:bit display image.

This struct should normally not be used directly, rather created using the MB_IMAGE() macro.

Monochrome Character Framebuffer

group monochrome_character_framebuffer

Public Monochrome Character Framebuffer API.

Defines

FONT_ENTRY_DEFINE(_name, _width, _height, _caps, _data, _fc, _lc)

Macro for creating a font entry.

Parameters
  • _name: Name of the font entry.
  • _width: Width of the font in pixels
  • _height: Height of the font in pixels.
  • _caps: Font capabilities.
  • _data: Raw data of the font.
  • _fc: Character mapped to first font element.
  • _lc: Character mapped to last font element.

Enums

enum cfb_display_param

Values:

CFB_DISPLAY_HEIGH = 0
CFB_DISPLAY_WIDTH
CFB_DISPLAY_PPT
CFB_DISPLAY_ROWS
CFB_DISPLAY_COLS
enum cfb_font_caps

Values:

CFB_FONT_MONO_VPACKED = BIT(0)
CFB_FONT_MONO_HPACKED = BIT(1)

Functions

int cfb_print(struct device *dev, char *str, u16_t x, u16_t y)

Print a string into the framebuffer.

Return
0 on success, negative value otherwise
Parameters
  • dev: Pointer to device structure for driver instance
  • str: String to print
  • x: Position in X direction of the beginning of the string
  • y: Position in Y direction of the beginning of the string

int cfb_framebuffer_clear(struct device *dev, bool clear_display)

Clear framebuffer.

Return
0 on success, negative value otherwise
Parameters
  • dev: Pointer to device structure for driver instance
  • clear_display: Clear the display as well

int cfb_framebuffer_invert(struct device *dev)

Invert Pixels.

Return
0 on success, negative value otherwise
Parameters
  • dev: Pointer to device structure for driver instance

int cfb_framebuffer_finalize(struct device *dev)

Finalize framebuffer and write it to display RAM, invert or reorder pixels if necessary.

Return
0 on success, negative value otherwise
Parameters
  • dev: Pointer to device structure for driver instance

int cfb_get_display_parameter(struct device *dev, enum cfb_display_param)

Get display parameter.

Return
Display parameter value
Parameters
  • dev: Pointer to device structure for driver instance
  • cfb_display_param: One of the display parameters

int cfb_framebuffer_set_font(struct device *dev, u8_t idx)

Set font.

Return
0 on success, negative value otherwise
Parameters
  • dev: Pointer to device structure for driver instance
  • idx: Font index

int cfb_get_font_size(struct device *dev, u8_t idx, u8_t *width, u8_t *height)

Get font size.

Return
0 on success, negative value otherwise
Parameters
  • dev: Pointer to device structure for driver instance
  • idx: Font index
  • width: Pointers to the variable where the font width will be stored.
  • height: Pointers to the variable where the font height will be stored.

int cfb_get_numof_fonts(struct device *dev)

Get number of fonts.

Return
number of fonts
Parameters
  • dev: Pointer to device structure for driver instance

int cfb_framebuffer_init(struct device *dev)

Initialize Character Framebuffer.

Return
0 on success, negative value otherwise
Parameters
  • dev: Pointer to device structure for driver instance