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.
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
asset_tracker_v2/src/events/ui_module_event.h
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.
-
enumerator UI_EVT_BUTTON_DATA_READY
-
struct ui_module_data
- #include <ui_module_event.h>
Structure used to provide button data.
-
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.
-
struct app_event_header header
-
enum ui_module_event_type