Zephyr API Documentation  3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
BBC micro:bit display APIs

BBC micro:bit display APIs. More...

Data Structures

struct  mb_image
 Representation of a BBC micro:bit display image. More...
 

Macros

#define MB_IMAGE(_rows...)   { .r = { _rows } }
 Generate an image object from a given array rows/columns.
 

Enumerations

enum  mb_display_mode { MB_DISPLAY_MODE_DEFAULT , MB_DISPLAY_MODE_SINGLE , MB_DISPLAY_MODE_SCROLL , MB_DISPLAY_FLAG_LOOP = BIT(16) }
 Display mode. More...
 

Functions

struct mb_display * mb_display_get (void)
 Get a pointer to the BBC micro:bit display object.
 
void mb_display_image (struct mb_display *disp, uint32_t mode, int32_t duration, const struct mb_image *img, uint8_t img_count)
 Display one or more images on the BBC micro:bit LED display.
 
void mb_display_print (struct mb_display *disp, uint32_t mode, int32_t duration, const char *fmt,...)
 Print a string of characters on the BBC micro:bit LED display.
 
void mb_display_stop (struct mb_display *disp)
 Stop the ongoing display of an image.
 

Detailed Description

BBC micro:bit display APIs.

Macro Definition Documentation

◆ MB_IMAGE

#define MB_IMAGE (   _rows...)    { .r = { _rows } }

#include <zephyr/display/mb_display.h>

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:

static const struct mb_image smiley = MB_IMAGE({ 0, 1, 0, 1, 0 },
                                          { 0, 1, 0, 1, 0 },
                                          { 0, 0, 0, 0, 0 },
                                          { 1, 0, 0, 0, 1 },
                                          { 0, 1, 1, 1, 0 });
Parameters
_rowsEach of the 5 rows represented as a 5-value column array.
Returns
Image bitmap that can be passed e.g. to mb_display_image().

Enumeration Type Documentation

◆ mb_display_mode

#include <zephyr/display/mb_display.h>

Display mode.

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

Enumerator
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 

Loop back to the beginning when reaching the last image.

Function Documentation

◆ mb_display_get()

struct mb_display * mb_display_get ( void  )

#include <zephyr/display/mb_display.h>

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

Returns
Pointer to display object.

◆ mb_display_image()

void mb_display_image ( struct mb_display *  disp,
uint32_t  mode,
int32_t  duration,
const struct mb_image img,
uint8_t  img_count 
)

#include <zephyr/display/mb_display.h>

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
dispDisplay object.
modeOne of the MB_DISPLAY_MODE_* options.
durationDuration how long to show each image (in milliseconds), or SYS_FOREVER_MS.
imgArray of image bitmaps (struct mb_image objects).
img_countNumber of images in 'img' array.

◆ mb_display_print()

void mb_display_print ( struct mb_display *  disp,
uint32_t  mode,
int32_t  duration,
const char *  fmt,
  ... 
)

#include <zephyr/display/mb_display.h>

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
dispDisplay object.
modeOne of the MB_DISPLAY_MODE_* options.
durationDuration how long to show each character (in milliseconds), or SYS_FOREVER_MS.
fmtprintf-style format string
...Optional list of format arguments.

◆ mb_display_stop()

void mb_display_stop ( struct mb_display *  disp)

#include <zephyr/display/mb_display.h>

Stop the ongoing display of an image.

Parameters
dispDisplay object.