2023-01-05 15:32:42 +00:00
|
|
|
//
|
|
|
|
// Created by robtor on 05.01.23.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef FLOATPUMP_MENU_CONTROLLER_H
|
|
|
|
#define FLOATPUMP_MENU_CONTROLLER_H
|
|
|
|
|
2023-01-26 12:22:43 +00:00
|
|
|
#include "Menu.h"
|
2023-01-26 11:25:09 +00:00
|
|
|
#include "LCD_I2C_Driver.h"
|
2023-01-05 15:32:42 +00:00
|
|
|
|
2023-01-26 11:31:13 +00:00
|
|
|
namespace floatpump::menu {
|
2023-01-05 15:32:42 +00:00
|
|
|
|
2023-01-06 12:51:07 +00:00
|
|
|
class Menu_Controller {
|
|
|
|
public:
|
|
|
|
Menu_Controller(Menu *menu, LCD_I2C_Driver &driver) : m_menu(menu), m_driver(driver) {};
|
2023-01-05 15:32:42 +00:00
|
|
|
|
2023-01-06 12:51:07 +00:00
|
|
|
//Possible User-Events that could be pushed to the controller
|
|
|
|
enum Event {
|
|
|
|
Increase, Decrease, Push
|
|
|
|
};
|
2023-01-05 15:32:42 +00:00
|
|
|
|
2023-01-06 12:51:07 +00:00
|
|
|
//Execute Menu (call this in a single loop to update the screen)
|
|
|
|
void execute();
|
2023-01-06 11:12:37 +00:00
|
|
|
|
2023-01-06 12:51:07 +00:00
|
|
|
//Push an Event to the Menu_Controller
|
|
|
|
void pushEvent(Event ev);
|
2023-01-06 11:12:37 +00:00
|
|
|
|
2023-01-06 12:51:07 +00:00
|
|
|
private:
|
|
|
|
//Used to interact with the screen
|
|
|
|
void displayMenu(Menu *m);
|
2023-01-05 16:42:39 +00:00
|
|
|
|
2023-01-06 12:51:07 +00:00
|
|
|
void keypress(Menu *m);
|
2023-01-05 16:42:39 +00:00
|
|
|
|
2023-01-06 12:51:07 +00:00
|
|
|
void increase(Menu *m);
|
2023-01-05 16:42:39 +00:00
|
|
|
|
2023-01-06 12:51:07 +00:00
|
|
|
void decrease(Menu *m);
|
2023-01-05 16:42:39 +00:00
|
|
|
|
2023-01-06 12:51:07 +00:00
|
|
|
private:
|
|
|
|
LCD_I2C_Driver &m_driver;
|
|
|
|
int m_current_index = 0;
|
|
|
|
Menu *m_menu;
|
|
|
|
};
|
2023-01-05 15:32:42 +00:00
|
|
|
|
|
|
|
} // menu
|
|
|
|
|
|
|
|
#endif //FLOATPUMP_MENU_CONTROLLER_H
|