//
// Created by robtor on 05.01.23.
//

#ifndef FLOATPUMP_MENU_CONTROLLER_H
#define FLOATPUMP_MENU_CONTROLLER_H

#include "Menu.h"
#include "LCD_I2C_Driver.h"

namespace floatpump::menu {

    class Menu_Controller {
    public:
        Menu_Controller(Menu *menu, LCD_I2C_Driver &driver) : m_menu(menu), m_driver(driver) {};

        //Possible User-Events that could be pushed to the controller
        enum Event {
            Increase, Decrease, Push
        };

        //Execute Menu (call this in a single loop to update the screen)
        void execute();

        //Push an Event to the Menu_Controller
        void pushEvent(Event ev);

    private:
        //Used to interact with the screen
        void displayMenu(Menu *m);

        void keypress(Menu *m);

        void increase(Menu *m);

        void decrease(Menu *m);

    private:
        LCD_I2C_Driver &m_driver;
        int m_current_index = 0;
        Menu *m_menu;
    };

} // menu

#endif //FLOATPUMP_MENU_CONTROLLER_H
