11 #ifndef _BASE_RENDERERS_H_
12 #define _BASE_RENDERERS_H_
17 #include <TaskManager.h>
32 #ifndef TC_DISPLAY_UPDATES_PER_SECOND
33 #define TC_DISPLAY_UPDATES_PER_SECOND 4
37 #define UPDATES_SEC_DISPLAY_OFF 0xFFU
39 #define RENDERER_MAXIMUM_TICK_MASK 0x1FFF
40 #define RENDERER_RESET_OFF 0x8000
41 #define RENDERER_RESET_NOTIFY_ONLY 0x4000
128 const uint8_t*
const* iconData;
129 volatile uint8_t currentState;
130 volatile bool changed;
133 uint8_t maxStateIcons;
137 TitleWidget(
const uint8_t*
const* icons, uint8_t maxStateIcons, uint8_t width, uint8_t height,
TitleWidget* next = NULL);
144 return (
const uint8_t *)pgm_read_ptr(&iconData[currentState]);
146 const uint8_t* getIcon(
int num) {
147 if(num >= maxStateIcons) num = 0;
148 return (
const uint8_t *)pgm_read_ptr(&iconData[num]);
153 return iconData[currentState];
155 const uint8_t* getIcon(
int num) {
156 if(num >= maxStateIcons) num = 0;
157 return iconData[num];
164 if (state >= maxStateIcons || currentState == state)
return;
166 this->currentState = state;
167 this->changed =
true;
192 enum RendererType: uint8_t { RENDER_TYPE_NOLOCAL, RENDER_TYPE_BASE, RENDER_TYPE_CONFIGURABLE };
203 RendererType rendererType;
205 MenuRenderer(RendererType rendererType,
int bufferSize) {
206 buffer =
new char[bufferSize+1];
207 this->bufferSize = bufferSize;
208 this->rendererType = rendererType;
234 static MenuRenderer* getInstance() {
return theInstance; }
255 MENUDRAW_NO_CHANGE = 0, MENUDRAW_EDITOR_CHANGE, MENUDRAW_COMPLETE_REDRAW
265 NoRenderer() :
MenuRenderer(RENDER_TYPE_NOLOCAL, 20) { MenuRenderer::theInstance =
this; dialog =
nullptr;}
284 enum DisplayTakeoverMode { NOT_TAKEN_OVER, TAKEN_OVER_FN, START_CUSTOM_DRAW, RUNNING_CUSTOM_DRAW };
288 uint8_t updatesPerSecond;
289 uint8_t displayNumber = 0;
291 uint16_t ticksToReset;
292 uint16_t resetValInTicks;
296 DisplayTakeoverMode displayTakenMode;
305 BaseMenuRenderer(
int bufferSize, RendererType rType = RENDER_TYPE_BASE, uint8_t displayNum = 0);
330 updatesPerSecond = UPDATES_SEC_DISPLAY_OFF;
340 resetValInTicks = (interval * updatesPerSecond) & RENDERER_MAXIMUM_TICK_MASK;
347 resetValInTicks = RENDERER_RESET_OFF;
356 resetValInTicks = (ticks & RENDERER_MAXIMUM_TICK_MASK) | RENDERER_RESET_NOTIFY_ONLY;
375 customDrawing = customDrawingParam;
382 return customDrawing;
388 void exec()
override;
438 MenuItem* getActiveItem() {
return activeItem; }
453 TitleWidget* getFirstWidget() {
return this->firstWidget; }
504 bool isCardLayoutActive(
MenuItem* root);
RenderPressMode
Definition: BaseRenderers.h:50
@ RPRESS_NONE
Definition: BaseRenderers.h:52
@ RPRESS_PRESSED
Definition: BaseRenderers.h:54
@ RPRESS_HELD
Definition: BaseRenderers.h:56
bool isItemActionable(MenuItem *item)
Definition: BaseRenderers.cpp:249
void(* RendererCallbackFn)(unsigned int currentValue, RenderPressMode userClicked)
Definition: BaseRenderers.h:67
MenuRedrawState
Definition: BaseRenderers.h:254
void(* ResetCallbackFn)()
Definition: BaseRenderers.h:101
Definition: BaseDialog.h:102
Definition: BaseRenderers.h:76
virtual void renderLoop(unsigned int currentValue, RenderPressMode userClick)=0
virtual void started(BaseMenuRenderer *currentRenderer)=0
Definition: BaseRenderers.h:261
BaseDialog * getDialog() override
Definition: BaseRenderers.cpp:242
bool tryTakeSelectIfNeeded(int, RenderPressMode) override
Definition: BaseRenderers.h:267
void initialise() override
Definition: BaseRenderers.h:268
Definition: BaseRenderers.h:107
void reset() override
Definition: BaseRenderers.h:112
void renderLoop(unsigned int, RenderPressMode) override
Definition: BaseRenderers.h:113
void started(BaseMenuRenderer *) override
Definition: BaseRenderers.h:111