|
LCDGFX LCD display driver
1.2.0
Lightweight graphics library for SSD1306, SSD1325, SSD1327, SSD1331, SSD1351, SH1106, SH1107, IL9163, ST7735, ST7789, ILI9341, PCD8544 displays over I2C/SPI
|
Class implements menu objects for lcdgfx library. More...
#include <menu.h>
Public Member Functions | |
| LcdGfxMenu (const char **items, uint8_t count, const NanoRect &rect={}) | |
| Creates menu object with the provided list of menu items. More... | |
| template<typename D > | |
| void | update (D &d) |
| Equivalent to show(). More... | |
| void | invalidate () |
| Forces the next show() to perform a full redraw (border + all visible items + scroll indicators). More... | |
| void | down () |
| Moves selection pointer down by 1 item. More... | |
| void | up () |
| Moves selection pointer up by 1 item. More... | |
| uint8_t | selection () |
| Returns currently selected menu item. More... | |
| void | setSelection (uint8_t s) |
| void | setRect (const NanoRect &rect={}) |
| Sets rect area for the menu. More... | |
| uint8_t | size () |
| Returns total count of menu items in menu. | |
| template<typename D > | |
| void | updateSize (D &d) |
| Updates size of the object, if it was not set previously. | |
| template<typename D > | |
| uint8_t | itemAtPoint (D &d, lcdint_t x, lcdint_t y) |
| Returns the menu item index at the given screen coordinate, or 0xFF if the point lies outside any item row (e.g. More... | |
| template<typename D > | |
| bool | onTouch (D &d, lcdint_t x, lcdint_t y) |
| Handles a touch event at the given screen coordinates. More... | |
| template<typename D > | |
| void | show (D &d) |
| Shows menu items on the display. More... | |
| LcdGfxMenu::LcdGfxMenu | ( | const char ** | items, |
| uint8_t | count, | ||
| const NanoRect & | rect = {} |
||
| ) |
Creates menu object with the provided list of menu items.
List of menu items (strings) must exist all until menu object is no longer needed. Selection is set to the first item by default.
| items | array of null-termintated strings (located in SRAM) |
| count | count of menu items in the array |
| rect | screen area to use for menu |
| void LcdGfxMenu::down | ( | ) |
Moves selection pointer down by 1 item.
If there are no items below, it will set selection pointer to the first item. Use show() to refresh menu state on the display.
|
inline |
Handles a touch event at the given screen coordinates.
Touches in the empty band between the border and the first/last item scroll the menu by one item (when more items are available in that direction). Touches on an item row select that item. Returns true if the touch was handled.
Call show() afterwards to refresh the display.
| d | display object |
| x | screen x coordinate of the touch |
| y | screen y coordinate of the touch |
| uint8_t LcdGfxMenu::selection | ( | ) |
Returns currently selected menu item.
First item has zero-index.
| void LcdGfxMenu::setRect | ( | const NanoRect & | rect = {} | ) |
Sets rect area for the menu.
| rect | rect area to use for menu |
| void LcdGfxMenu::show | ( | D & | d | ) |
Shows menu items on the display.
If menu items cannot fit the display, the function provides scrolling.
The first call after construction (or after invalidate() / setRect()) performs a full redraw (border, every visible item, scroll indicators). Subsequent calls are flicker-free: when the selection moved within the already-visible window only the previously- and newly-selected item rows are redrawn; the border and untouched items are left alone. When the visible window changes (selection scrolls off-screen) a full redraw is performed automatically.
| d | display object |
| void LcdGfxMenu::up | ( | ) |
Moves selection pointer up by 1 item.
If selected item is the first one, then selection pointer will set to the last item in menu list. Use show() to refresh menu state on the display.
|
inline |