MenuFunctions.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef MenuFunctions_h
  2. #define MenuFunctions_h
  3. #include "WiFiScan.h"
  4. #include "Display.h"
  5. extern Display display_obj;
  6. extern WiFiScan wifi_scan_obj;
  7. // Keypad start position, key sizes and spacing
  8. #define KEY_X 120 // Centre of key
  9. #define KEY_Y 50
  10. #define KEY_W 240 // Width and height
  11. #define KEY_H 18
  12. #define KEY_SPACING_X 0 // X and Y gap
  13. #define KEY_SPACING_Y 1
  14. #define KEY_TEXTSIZE 1 // Font size multiplier
  15. #define BUTTON_ARRAY_LEN 5
  16. #define FLASH_BUTTON 0
  17. struct Menu;
  18. // Individual Nodes of a menu
  19. struct MenuNode {
  20. String name;
  21. uint16_t color;
  22. Menu *childMenu;
  23. TFT_eSPI_Button* button;
  24. std::function<void()> callable; // Make a function that changes menu to a child menu
  25. };
  26. // Full Menus
  27. struct Menu {
  28. SimpleList<MenuNode>* list;
  29. Menu * parentMenu;
  30. uint8_t selected;
  31. };
  32. class MenuFunctions
  33. {
  34. private:
  35. Menu* current_menu;
  36. Menu mainMenu;
  37. Menu wifiMenu;
  38. Menu bluetoothMenu;
  39. TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
  40. //SimpleList<TFT_eSPI_Button>* key;
  41. void addNodes(Menu* menu, String name, uint16_t color, Menu* child, int place, std::function<void()> callable);
  42. void showMenuList(Menu* menu, int layer);
  43. public:
  44. MenuFunctions();
  45. uint16_t x = -1, y = -1;
  46. boolean pressed = false;
  47. void buildButtons(Menu* menu);
  48. void changeMenu(Menu* menu);
  49. void displayCurrentMenu();
  50. void handlePress(boolean pressed, uint16_t t_x, uint16_t t_y);
  51. void main();
  52. void RunSetup();
  53. };
  54. #endif