projet crepp_git/crepp-projects/station-meteo/firmware/receiver/v1.0 · branche main
TabManager.h Voir sur GitLab
#pragma once
//TabManager.h - Gestion des onglets de l'interface
#include <Arduino.h>
#include <TFT_eSPI.h>
#include "Theme.h"


// Types d'onglets disponibles
enum TabType {
    TAB_WEATHER = 0,
    TAB_DEBUG,
    TAB_INDOOR_TEMP,
    TAB_STATS,
    TAB_COUNT  // 4
};

// Structure d'un onglet
struct Tab {
    TabType type;
    const char* name;
    void (*drawFunction)(TFT_eSPI& tft);
    void (*updateFunction)();
};

// Gestionnaire d'onglets
class TabManager {
private:
    static Tab tabs[TAB_COUNT];
    static int currentTab;
    static int lastTab;
    static bool needsRedraw;
    static unsigned long lastButtonTime;
    static const unsigned long BUTTON_DEBOUNCE = 200;

public:
    static void init();
    static void nextTab();
    static void previousTab();
    static void handleButton(int buttonId, bool longPress = false);
    static void draw(TFT_eSPI& tft);
    static void update();
    static void forceRedraw() { needsRedraw = true; }
    static int getCurrentTab() { return currentTab; }
};