Files
ESP32Marauder/esp32_marauder/MenuFunctions.h
Just Call Me Koko 7b4b589205 Added Marauder source
2019-10-15 19:02:17 -04:00

75 lines
1.5 KiB
C++

#ifndef MenuFunctions_h
#define MenuFunctions_h
#include "WiFiScan.h"
#include "Display.h"
extern Display display_obj;
extern WiFiScan wifi_scan_obj;
// Keypad start position, key sizes and spacing
#define KEY_X 120 // Centre of key
#define KEY_Y 50
#define KEY_W 240 // Width and height
#define KEY_H 18
#define KEY_SPACING_X 0 // X and Y gap
#define KEY_SPACING_Y 1
#define KEY_TEXTSIZE 1 // Font size multiplier
#define BUTTON_ARRAY_LEN 5
#define FLASH_BUTTON 0
struct Menu;
// Individual Nodes of a menu
struct MenuNode {
String name;
uint16_t color;
Menu *childMenu;
TFT_eSPI_Button* button;
std::function<void()> callable; // Make a function that changes menu to a child menu
};
// Full Menus
struct Menu {
SimpleList<MenuNode>* list;
Menu * parentMenu;
uint8_t selected;
};
class MenuFunctions
{
private:
Menu* current_menu;
Menu mainMenu;
Menu wifiMenu;
Menu bluetoothMenu;
TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
//SimpleList<TFT_eSPI_Button>* key;
void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable);
void showMenuList(Menu* menu, int layer);
public:
MenuFunctions();
uint16_t x = -1, y = -1;
boolean pressed = false;
void buildButtons(Menu* menu);
void changeMenu(Menu* menu);
void displayCurrentMenu();
void handlePress(boolean pressed, uint16_t t_x, uint16_t t_y);
void main();
void RunSetup();
};
#endif