#include <BaseRenderers.h>
Public Types | |
enum | DisplayTakeoverMode { NOT_TAKEN_OVER , TAKEN_OVER_FN , START_CUSTOM_DRAW , RUNNING_CUSTOM_DRAW } |
Public Member Functions | |
BaseMenuRenderer (int bufferSize, RendererType rType=RENDER_TYPE_BASE, uint8_t displayNum=0) | |
~BaseMenuRenderer () override | |
void | initialise () override |
void | setUpdatesPerSecond (int updatesSec) |
void | turnOffDisplayUpdates (bool) |
void | setResetIntervalTimeSeconds (uint16_t interval) |
void | turnOffResetLogic () |
void | resetNotifiesOnly (uint16_t ticks) |
void | setResetCallback (ResetCallbackFn resetFn) |
void | setCustomDrawingHandler (CustomDrawing *customDrawingParam) |
CustomDrawing * | getCurrentCustomDrawing () |
void | exec () override |
virtual void | render ()=0 |
bool | tryTakeSelectIfNeeded (int currentReading, RenderPressMode pressMode) override |
virtual MenuItem * | getMenuItemAtIndex (MenuItem *pItem, uint8_t idx) |
virtual int | findItemIndex (MenuItem *root, MenuItem *toFind) |
virtual uint8_t | itemCount (MenuItem *item, bool includeNonVisible) |
virtual uint8_t | setActiveItem (MenuItem *item) |
MenuItem * | getActiveItem () |
int | findActiveItem (MenuItem *root) |
void | setFirstWidget (TitleWidget *widget) |
TitleWidget * | getFirstWidget () |
void | menuAltered () |
void | takeOverDisplay (RendererCallbackFn displayFn=nullptr) |
void | giveBackDisplay () |
void | resetToDefault () |
void | redrawRequirement (MenuRedrawState state) |
void | invalidateAll () |
Public Member Functions inherited from MenuRenderer | |
MenuRenderer (RendererType rendererType, int bufferSize) | |
virtual BaseDialog * | getDialog ()=0 |
virtual | ~MenuRenderer () |
char * | getBuffer () |
uint8_t | getBufferSize () |
RendererType | getRendererType () |
Static Public Member Functions | |
static BaseMenuRenderer * | getInstance () |
Static Public Member Functions inherited from MenuRenderer | |
static MenuRenderer * | getInstance () |
Protected Member Functions | |
void | countdownToDefaulting () |
Protected Attributes | |
uint8_t | lastOffset |
uint8_t | updatesPerSecond |
uint8_t | displayNumber = 0 |
MenuRedrawState | redrawMode |
uint16_t | ticksToReset |
uint16_t | resetValInTicks |
TitleWidget * | firstWidget |
CustomDrawing * | customDrawing |
BaseDialog * | dialog |
DisplayTakeoverMode | displayTakenMode |
RenderPressMode | renderFnPressType |
RendererCallbackFn | renderCallback |
MenuItem * | activeItem = nullptr |
Protected Attributes inherited from MenuRenderer | |
char * | buffer |
uint8_t | bufferSize |
RendererType | rendererType |
Additional Inherited Members | |
Static Protected Attributes inherited from MenuRenderer | |
static MenuRenderer * | theInstance = nullptr |
This class provides the base functionality that will be required by most implementations of renderer, you can extend this class to add new renderers, it proivides much of the core functionality that's needed by a renderer.
Renderers work in a similar way to a game loop, the render method is repeatedly called and in this loop any rendering or event callbacks should be handled.
BaseMenuRenderer::BaseMenuRenderer | ( | int | bufferSize, |
RendererType | rType = RENDER_TYPE_BASE , |
||
uint8_t | displayNum = 0 |
||
) |
constructs the renderer with a given buffer size
bufferSize | size of text buffer to create |
|
inlineoverride |
Destructs the class removing the allocated buffer
|
overridevirtual |
Initialise the render setting up the refresh task at the update frequency provided (or leave blank for default).
updatesPerSecond | the number of times to update the display per second, set to 0 or leave blank for default |
Implements MenuRenderer.
Reimplemented in tcgfx::BaseGraphicalRenderer.
void BaseMenuRenderer::setUpdatesPerSecond | ( | int | updatesSec | ) |
Set the number of updates per second for the display, use caution not to set too high, and never set to 0. Important note: This re-initialises the reset interval to 30 seconds
updatesSec | the number of updates. |
|
inline |
Turn off the display updates to allow for low power state transition, to re-enable call setUpdatesPerSecond
|
inline |
Adjust the default reset interval of 30 seconds. Maximum value is 60 seconds. At this point the reset callback is called and the menu is reset to root with no present editor. Values range from 1..4096
resetTime | the number of seconds before calling the reset handler. |
|
inline |
Completely turn off the reset interval so there will never be a reset event on the renderer.
|
inline |
Indicates to the renderer that you want reset notification, but you do not want any changes to be made to the position in the menu, instead of the default behaviour to reset to the root menu.
ticks | the number of seconds before calling the reset handler |
|
inline |
Sets the callback that will receive reset events when the menu has not been edited for some time. You can optionally use an instance of CustomDrawing instead of this, and that will be notified of both reset events and take over display events.
|
inline |
Sets the CustomDrawing implementation that will handle both the reset event and also any custom drawing that needs to be done. The reset method will be called whenever the display times out back to it's defaults, the started will be called when the display is first taken over, followed by renderLoop until it's given back.
|
inline |
|
override |
Called by taskManager when we are scheduled
|
pure virtual |
This is the rendering call that must be implemented by subclasses. Generally it is called a few times a second, and should render the menu, if changes are detected
Implemented in tcgfx::BaseGraphicalRenderer.
|
overridevirtual |
If this renderer has been taken over, displaying a dialog or needs to do something special with a button press, then this function can take action BEFORE anything else
editor | the current editor |
Implements MenuRenderer.
Gets the menu item at a specific position
root | the root item |
idx | the index to find |
Reimplemented in tcgfx::BaseGraphicalRenderer.
Find an item's offset in a given root, safely returns 0.
root | the root item |
toFind | the item within that root |
Reimplemented in tcgfx::BaseGraphicalRenderer.
|
virtual |
Get the count of items in the current root
item | the root item |
includeNonVisible | if non visible should be included |
Reimplemented in tcgfx::BaseGraphicalRenderer.
|
virtual |
Set the active index to a new menu item, the active item is the one that is selected for editing and other display purposes. You must never pass null to this method, and you are returned the index in the array that is now selected.
Reimplemented in tcgfx::BaseGraphicalRenderer.
int BaseMenuRenderer::findActiveItem | ( | MenuItem * | root | ) |
Find the active item offset in the list
root | the root item |
void BaseMenuRenderer::setFirstWidget | ( | TitleWidget * | widget | ) |
For menu systems that support title widgets, this will allow the first widget.
the | first widget in a chain of widgets linked by next pointer. |
|
inline |
Called when the menu has been altered, to reset the countdown to reset behaviour
void BaseMenuRenderer::takeOverDisplay | ( | RendererCallbackFn | displayFn = nullptr | ) |
In order to take over the display, provide a callback function that will receive the regular render call backs instead of this renderer. If you have already registered a custom drawing class that implements CustomDrawing by calling setCustomDrawing(..) then you can omit the display function parameter, and your custom drawing class will be called instead. Unlike standard drawing you callback must include api calls that would reset the display to a known state for example when using U8G2 library you must call setDrawColor method prior to any other calls
displayFn | the callback to render the display |
void BaseMenuRenderer::giveBackDisplay | ( | ) |
Call this method to clear custom display rendering after a call to takeOverDisplay. It will cause a complete repaint of the display.
void BaseMenuRenderer::resetToDefault | ( | ) |
Used to reset the display to it's default state, root menu, nothing being edited
|
inline |
Sets the type of redraw that is needed
state | the required redraw |
|
inline |
Completely invalidate all drawing and instigate a complete redraw of all elements.
|
protected |
set up a countdown to default back to the submenu