UI_Lib  a1366e08a59cc549a65fa26081e6409aa12f26d5
This is a user interface library for graphical LCDs. It offers many different controls and indicators that can be nested depending on the element types.
Loading...
Searching...
No Matches
3 - Simple Example
#include "Core/UI_Elements.h"
bool boolVal1;
Label labelBool("Boolean");
BoolIndicator boolInd1(&boolVal1);
BoolControl boolCtrl1(&boolVal1, &boolVal1);
ContainerStack stack_boolean;
// Call this method to build a simple Visual Tree and attach it to the UI_Manager
void UI_Test_BuildTree()
{
stack_boolean.AddItem(&labelBool);
stack_boolean.AddItem(&boolInd1);
stack_boolean.AddItem(&boolCtrl1);
stack_boolean.InitItems();
UiManager.ChangeVisualTreeRoot(&stack_boolean);
}
// Call this method from outside to initialize the UI_Lib
void UI_Test_Init(Adafruit_GFX* gfx)
{
UiManager.SetColors(RGB565(0x00, 0x00, 0x00), RGB565(0x00, 0xF7, 0x00), RGB565(0x00, 0x00, 0x00));
UiManager.Init(gfx);
}
// Call this method to redraw the screen
void UI_Test_Draw()
{
UiManager.Draw();
}
// Call this method to send user inputs (keys, encoder actions) to the UI_Manager
void UI_Test_KeyInput(Keys_t key)
{
UiManager.KeyInput(key);
}
// Call this method to send touch inputs to the UI_Manager
void UI_Test_TouchInput(uint16_t x, uint16_t y, TouchTypes touchType)
{
UiManager.TouchInput(x, y, touchType);
}
enum Keys Keys_t
Available input keys.
TouchTypes
Available touch types.
Definition TouchTypes.h:13
Containing a class that is used to handle the drawing and key handling of all UI_Elements.
UI_Manager UiManager
Access object for the singleton instance of the UI_Manager.
Definition UI_Manager.cpp:7
#define RGB565(r, g, b)
Macro that can be used to convert a RGB888 color to the RGB565 format.
Definition UIElement.h:18
Class for a boolean control that is showing a boolean variable value and offers the possibility to to...
Definition BoolControl.h:32
Class for a boolean indicator that is only showing a boolean variable value.
Definition BoolIndicator.h:27
bool AddItem(UIElement *item)
Add a new element to the container and activate it as active child.
Definition Container.cpp:19
class for a container that is showing all items at a time stacked one after another.
Definition ContainerStack.h:28
Class for an Label indicator that is drawing a string to the screen.
Definition Label.h:19

A more detailed example can be found in

https://github.com/M1S2/UI_Lib/blob/master/examples/full_graphics_demo/UI_Lib_Test.cpp

or

https://github.com/M1S2/UI_Lib/blob/master/examples/touch_demo/UI_Lib_Test_Touch_Demo.cpp