#pragma once

#include <AceButton.h>
#include <Arduino.h>

#include "display_task.h"
#include "motor_task.h"
#include "commu_task.h"
#include "task.h"

#define ALSCHECKINTERVAL 4000

class InterfaceTask : public Task<InterfaceTask>, public ace_button::IEventHandler {
    friend class Task<InterfaceTask>; // Allow base Task to invoke protected run()

    public:
        InterfaceTask(const uint8_t task_core, MotorTask& motor_task, DisplayTask* display_task, CommuTask& commu_task);
        ~InterfaceTask();

        void handleEvent(ace_button::AceButton* button, uint8_t event_type, uint8_t button_state) override;

    protected:
        void run();

    private:
        MotorTask& motor_task_;
        DisplayTask* display_task_;
        CommuTask& commu_task_;

        int current_config_ = 0;

        uint16_t brightness = UINT16_MAX;

        void changeConfig(bool next);
};
