Class daisy::UI¶
#include <UI.h>
Classes¶
Type | Name |
---|---|
struct | SpecialControlIds |
Public Static Attributes¶
Type | Name |
---|---|
constexpr uint16_t | invalidCanvasId = [**uint16\_t**](classdaisy_1_1Apds9960.md)(-1) |
Public Functions¶
Type | Name |
---|---|
void | ClosePage (UiPage & page) |
uint16_t | GetPrimaryOneBitGraphicsDisplayId () const |
SpecialControlIds | GetSpecialControlIds () const |
void | Init (UiEventQueue & inputQueue, const SpecialControlIds & specialControlIds, std::initializer_list< UiCanvasDescriptor > canvases, uint16_t primaryOneBitGraphicsDisplayId=invalidCanvasId) |
void | Mute (bool shouldBeMuted, bool queueEvents=false) |
void | OpenPage (UiPage & page) |
void | Process () |
UI () |
|
~UI () |
Detailed Description¶
Author:
jelliesen
This system allows you to create complex and dynamic user interfaces with menus, pages and dialogs. It holds a stack of pages. Each page can react to user input on buttons, potentiometers, and encoders while drawing to one or multiple displays, leds or other output devices.
User input is consumed from a UiEventQueue and distributed to the pages from the top down. If a page doesn't handle an event, it will be forwarded to the next page below.
Pages are drawn from the bottom up. Multiple abstract canvases can be used for the drawing, where each canvas could be a graphics display, LEDs, alphanumeric displays, etc. The UI system makes sure that drawing is executed with a constant refresh rate that can be individually specified for each canvas.
Public Static Attributes Documentation¶
variable invalidCanvasId¶
Use this to denote a nonexistent / invalid canvas ID
Public Functions Documentation¶
function ClosePage¶
Called to close a page.
function GetPrimaryOneBitGraphicsDisplayId¶
If this UI has a canvas that uses a OneBitGraphicsDisplay AND this canvas should be used as the main display for menus, etc. then this function returns the canvas ID of this display. If no such canvas exists, this function returns UI::invalidCanvasId.
function GetSpecialControlIds¶
Returns the button IDs, encoder IDs and pot IDs used for special functions.
function Init¶
void daisy::UI::Init (
UiEventQueue & inputQueue,
const SpecialControlIds & specialControlIds,
std::initializer_list< UiCanvasDescriptor > canvases,
uint16_t primaryOneBitGraphicsDisplayId=invalidCanvasId
)
Initializes the UI.
Parameters:
inputQueue
The UiEventQueue to read user input events from.specialControlIds
Information about the control IDs used for special buttons/encoders/pots.canvases
A list of UiCanvasDescriptor that define which canvases to use.primaryOneBitGraphicsDisplayId
The ID of a OneBitGraphicsDisplay canvas that should be used as the main display. Menus will draw to this canvas. If no such dispaly is available, use Ui::invalidCanvasId.
function Mute¶
Call this to temporarily disable processing of user input, e.g. while a project is loading. If queueEvents==true, all user input that happens while muted will be queued up and processed when the mute state is removed. If queueEvents==false, all user input that happens while muted will be discarded.
function OpenPage¶
Adds a new UIPage on the top of the stack of UI pages without taking ownership of the object. The new page is set to be visible. The page must stay alive until it was removed from the UI. It's best to have each page statically allocated as a global variable.
function Process¶
Call this regularly to allow processing user input, redraw canvases and do other "housekeeping" work. This is best done from a low priority context, ideally from your main() idle loop.
function UI¶
function ~UI¶
The documentation for this class was generated from the following file external-docs/libDaisy/src/ui/UI.h