Final push to unify all menu states

All states are now handled by the new menu system, although some are flagged to have a custom handler that does everything by itself.

I replaced most reference parameters to pointers to be able to typecast in a nicer way.

Key input is not passed as a parameter to the menu functions instead of having global variables they all access. I think I broke one thing by doing this, since there is no way to propagate key input changes to the next frame.
This commit is contained in:
Mikael Degerfält 2019-06-23 16:55:25 +02:00
parent 9a595c0ffc
commit 5b59b4cd0f
4 changed files with 364 additions and 314 deletions

View file

@ -1,6 +1,15 @@
#ifndef __NUMENU_H
#define __NUMENU_H
#include <stdint.h>
//***********************************************************
struct KeyState {
uint8_t current;
uint8_t changed;
};
//***********************************************************
enum MenuType {
@ -18,6 +27,7 @@ enum MenuEntryFlags {
enum MenuPageFlags {
EMenuPageCustom = (1u<<0),
EMenuPageRoot = (1u<<1),
EMenuCustomTitle = (1u << 2),
};
@ -45,22 +55,22 @@ struct MenuEntrySub {
struct MenuEntryStateCh {
enum MenuType type;
const char* title;
byte state;
uint8_t state;
};
struct MenuPage {
const char* title;
uint16_t flags;
byte cursor;
byte parentPage;
byte numEntries;
uint8_t cursor;
uint8_t parentPage;
uint8_t numEntries;
const MenuEntry** entries;
};
struct MenuPageCustom {
const char* title;
uint16_t flags;
bool (*menuUpdateFunc)(void);
bool (*menuUpdateFunc)(KeyState &input, uint32_t timeNow);
};
//***********************************************************
@ -77,5 +87,4 @@ struct AdjustMenuEntry {
void (*saveFunc)(const AdjustMenuEntry&);
};
#endif