User Interface module

The User Interface module controls and monitors the UI elements on nRF91 Series development kits, Thingy:91, and Thingy:91 X.

Features

This section documents the various features implemented by the module.

Button presses

When a button is pressed on a supported board, the UI module notifies the rest of the application with the UI_EVT_BUTTON_DATA_READY event that contains information about the button press. The buttons used by the module and their functionality are listed in the following table:

Button

Thingy:91 and Thingy:91 X

nRF91 Series DK

1

Send a message to the cloud service

Send message to the cloud service.

2

Send message to the cloud service.

LED indication

The module supports multiple LED patterns to visualize the operating state of the application. The following table describes the supported LED states:

State

Thingy:91 and Thingy:91 X RGB LEDs

nRF91 Series DK solid LEDs

LTE connection search

Yellow, blinking

LED1 blinking

Location search

Purple, blinking

LED2 blinking

Cloud association

White, double pulse blinking

LED3 double pulse blinking

Connecting to cloud

Green, triple pulse blinking

LED3 triple pulse blinking

Publishing data

Green, blinking

LED3 blinking

Active mode

Light blue, blinking

LED4 blinking

Passive mode

Dark blue, blinking

LED3 and LED4 blinking

Error

Red, static

All 4 LEDs blinking

FOTA update

Orange, rapid blinking

LED1 and LED2 blinking

Completion of FOTA update

Orange, static

LED1 and LED2 static

Note

The LED pattern that indicates the device mode is visible for a few seconds after an update has been sent to cloud.

Configuration options

CONFIG_UI_THREAD_STACK_SIZE - UI module thread stack size

This option configures the UI module’s internal thread stack size.

Module states

The UI module continuously updates its internal state based on the mode and operating state of the application. This ensures that the correct LED pattern is displayed when the application changes its state of operation. The UI module has an internal state machine with the following states:

  • STATE_INIT - The initial state of the module.

  • STATE_RUNNING - The module has performed all the required initializations and can initiate the display of LED patterns based on incoming events from other modules.

    • SUB_STATE_ACTIVE - The application is in the active mode. The module reverts to the active mode LED pattern after cloud publication.

    • SUB_STATE_PASSIVE - The application is in the passive mode. The module reverts to the passive mode LED pattern after cloud publication.

      • SUB_SUB_STATE_LOCATION_ACTIVE - The application is performing a location search. The module reverts to the location search LED pattern.

      • SUB_SUB_STATE_LOCATION_INACTIVE - A location search is not being performed.

  • STATE_LTE_CONNECTING - The modem module is performing an LTE connection search. The UI module triggers the LTE connection search LED pattern.

  • STATE_CLOUD_CONNECTING - The cloud module is connecting to cloud. The UI module triggers the cloud connection LED pattern.

  • STATE_CLOUD_ASSOCIATING - The cloud module is performing user association. The UI module triggers the cloud association LED pattern.

  • STATE_FOTA_UPDATING - The cloud module is performing a FOTA update. The UI module triggers the FOTA update LED pattern.

  • STATE_SHUTDOWN - The module has been shut down after receiving a request from the utility module. It triggers the appropriate LED pattern that corresponds to the shutdown reason.

Module events

The asset_tracker_v2/src/events/ui_module_event.h header file contains a list of various events sent by the module.

Dependencies

This module uses the following nRF Connect SDK libraries and drivers:

API documentation

Header file: asset_tracker_v2/src/events/ui_module_event.h
Source files: asset_tracker_v2/src/events/ui_module_event.c, asset_tracker_v2/src/modules/ui_module.c
group ui_module_event

UI module event.

Enums

enum ui_module_event_type

UI event types submitted by the UI module.

Values:

enumerator UI_EVT_BUTTON_DATA_READY

Button has been pressed. Payload is of type ui_module_data (ui).

enumerator UI_EVT_SHUTDOWN_READY

The UI module has performed all procedures to prepare for a shutdown of the system. The event carries the ID (id) of the module.

enumerator UI_EVT_ERROR

An irrecoverable error has occurred in the cloud module. Error details are attached in the event structure.

struct ui_module_data
#include <ui_module_event.h>

Structure used to provide button data.

Public Members

int button_number

Button number of the board that was pressed.

int64_t timestamp

Uptime when the button was pressed.

struct ui_module_event
#include <ui_module_event.h>

UI module event.

Public Members

struct app_event_header header

UI module application event header.

enum ui_module_event_type type

UI module event type.

struct ui_module_data ui

Variable that carries button press information.

uint32_t id

Module ID, used when acknowledging shutdown requests.

int err

Code signifying the cause of error.