Made the sensor adjust menu driven by data
* Moved menu titles and option names into data structures. * Unified select menu option code * Also unified handling of menu selection, although main and rotator menus are still handled the old way. * Moved struct definitions to numenu.h * Grouped functions and variables together based on usage.
This commit is contained in:
parent
9a0bb369ac
commit
0d0ea5051d
6 changed files with 663 additions and 1033 deletions
|
@ -1,31 +1,66 @@
|
|||
#ifndef __NUMENU_H
|
||||
#define __NUMENU_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
//***********************************************************
|
||||
|
||||
#define MAX_DEPTH 16
|
||||
|
||||
class Adafruit_SSD1306;
|
||||
|
||||
class NuMenu
|
||||
{
|
||||
public:
|
||||
NuMenu(Adafruit_SSD1306 &gfx);
|
||||
|
||||
bool init();
|
||||
void update(uint16_t buttonState);
|
||||
|
||||
void setEnabled(bool state) { _enabled = state; }
|
||||
|
||||
static void drawMenuItems(const char* title, const char* entries[], int count, int selection, int offset = 0);
|
||||
|
||||
private:
|
||||
bool _enabled;
|
||||
// MenuPageState _rootMenu;
|
||||
// MenuPageState _pageStack[MAX_DEPTH];
|
||||
|
||||
Adafruit_SSD1306 &_display;
|
||||
enum MenuType {
|
||||
ESub,
|
||||
ESubRotator,
|
||||
EStateChange,
|
||||
};
|
||||
|
||||
struct MenuEntry {
|
||||
enum MenuType type;
|
||||
const char* title;
|
||||
};
|
||||
|
||||
struct MenuEntrySub {
|
||||
enum MenuType type;
|
||||
const char* title;
|
||||
const char* subTitle;
|
||||
byte* flag;
|
||||
void (*subMenuFunc)(int color);
|
||||
};
|
||||
|
||||
struct MenuEntrySubRotator {
|
||||
enum MenuType type;
|
||||
const char* title;
|
||||
const char* subTitle;
|
||||
byte flagValue;
|
||||
byte* flag;
|
||||
void (*subMenuFunc)(int color);
|
||||
};
|
||||
|
||||
struct MenuEntryStateCh {
|
||||
enum MenuType type;
|
||||
const char* title;
|
||||
byte state;
|
||||
};
|
||||
|
||||
struct MenuPage {
|
||||
const char* title;
|
||||
byte cursor;
|
||||
byte parentPage;
|
||||
byte numEntries;
|
||||
const MenuEntry** entries;
|
||||
};
|
||||
|
||||
|
||||
//***********************************************************
|
||||
|
||||
|
||||
|
||||
struct AdjustValue {
|
||||
uint16_t *value;
|
||||
uint16_t limitLow;
|
||||
uint16_t limitHigh;
|
||||
};
|
||||
|
||||
struct AdjustMenuEntry {
|
||||
const char* title;
|
||||
AdjustValue entries[2];
|
||||
void (*saveFunc)(const AdjustMenuEntry&);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue