#ifndef UI_GRAPHICS_H_
#define UI_GRAPHICS_H_

#include <U8g2lib.h>

#include "CarCharger.h"
#include "PwrSupply_Laptop.h"

class C_UI_Graphics {
   public:
    C_UI_Graphics() : u8g2(U8G2_R0, /* clock=*/7, /* data=*/13, /* cs=*/11, /* dc=*/4, /* reset=*/10) { ; }

    static const char *PowerSupplies_ShortNames[N_SUPPLIES];
    static const char *PowerSupplies_MenuNames[N_SUPPLIES];

    void Init();
    void DrawWelcomeScreen();

    void Render();
    void Navigation();

   private:
    U8G2_ST7565_EA_DOGM128_1_4W_SW_SPI u8g2;

    void DrawMenu_Totals();
    void DrawMenu_Normal(int supplyId);
    void DrawMenu_About();
    void DrawMenu_Laptop();
    void DrawMenu_LaptopVotageNotification();
    void DrawMenu_FuseTriggeredNotification(const char *out_name);
    void DrawMenu_FuseNotifications();

    static const int logo_width = 57;
    static const int logo_height = 40;

    static const uint8_t logo_bits[];

    int menuPos = 0;

    char buff[64];  //temp print buffer

    enum class laptopMenuState_t {
        MAIN_MENU,
        LAPTOP_BRANDS,
        LAPTOP_VOLTAGE
    } laptopMenuState;
    int selectedLaptopID = 0;
    float selectedLaptopVoltage = 0;

    bool notificationRendered = false;
    int notificationStep = 0;
    static const int NUM_STEPS = 5;

    static const int MENU_N_ITEMS = 6;  //total, 4x PSU, about
    static const int LAPTOP_DB_LEN = 9;

    const float laptopVoltagesDB[LAPTOP_DB_LEN] = {C_PwrSupply_Laptop::LAPTOP_MIN_V, 19, 19, 19, 19, 19.5, 20, 19, 19.5};
    const char *laptopNamesDB[LAPTOP_DB_LEN] = {"Custom", "Acer", "Asus", "Dell", "Fujitsu", "HP", "Lenovo", "Samsung", "Sony"};

    static const char labelFuseLowered1[] PROGMEM;
    static const char labelFuseLowered2[] PROGMEM;

    static const char STR_DEVICE_NAME[] PROGMEM;
    static const char STR_VERSION_YEAR[] PROGMEM;
    static const char STR_SYSTEMP_LINE[] PROGMEM;
    static const char STR_FANSPEED_LINE[] PROGMEM;
    static const char STR_FANPWM_LINE[] PROGMEM;
    static const char STR_TOTAL_ARROW[] PROGMEM;
    static const char STR_POUT[] PROGMEM;
    static const char STR_ACTIVE[] PROGMEM;
    static const char STR_UOUT[] PROGMEM;
    static const char STR_IOUT[] PROGMEM;
    static const char STR_SELECTED_V[] PROGMEM;
    static const char STR_ABOUT[] PROGMEM;
    static const char STR_ABOUT_YEAR_VERSION[] PROGMEM;
    static const char STR_SELECT_HEADING[] PROGMEM;
    static const char STR_LAPTOP_BRAND[] PROGMEM;
    static const char STR_LAPTOP_SELECTION[] PROGMEM;
    static const char STR_CONFIRM[] PROGMEM;
    static const char STR_SET_VOLTAGE_HEADING[] PROGMEM;
    static const char STR_SET_VOLTAGE[] PROGMEM;
    static const char STR_SELECTED_LAPTOP_V[] PROGMEM;
    static const char STR_FUSE_TRIGGERED_HEADING[] PROGMEM;
    static const char STR_CURRENT_LIMIT1[] PROGMEM;
    static const char STR_CURRENT_LIMIT2[] PROGMEM;
    static const char STR_CURRENT_LIMIT3[] PROGMEM;

    const uint8_t *FONT_WELCOME_HEADING = u8g2_font_t0_12b_tr;
    const uint8_t *FONT_NORMAL_HEADING = u8g2_font_t0_12b_tr;
    const uint8_t *FONT_WELCOME_TEXT = u8g2_font_t0_12_tr;
    const uint8_t *FONT_NORMAL_TEXT = u8g2_font_chikita_tr;
};

#endif
