#ifndef SHIELD_RICHSHIELD1_H
#define SHIELD_RICHSHIELD1_H

#include <Arduino.h>
#include "KK_ButtonHandler.h"
#include <TM1637Display.h>
#include "KK_dht11.h"

class Shield_RichShield1 {
  public:
    Shield_RichShield1();
    
    void begin();
    void update(); // Muss in den loop()

    // --- Taster (K1 & K2) ---
    KK_ButtonHandler btnK1;
    KK_ButtonHandler btnK2;

    // --- Ausgaben ---
    void setLED(uint8_t ledNum, bool state);
    void setLEDPWM(uint8_t ledNum, uint8_t value); // Nur für LED 2 (Blau) & 3 (Grün)
    void playTone(uint16_t freq, uint32_t ms);
    
    // --- Eingaben / Sensoren ---
    uint16_t readPoti();
    uint8_t readLDR(); // Gibt direkt 0 - 100% zurück
    float readNTC(); // Gibt direkt °C zurück
    float readVoltage(); // Spannungs-Klemme
    
    float readTemperature(); // DHT11
    float readHumidity();    // DHT11

    // --- IR Empfänger ---
    void printIRCode();
    bool checkIRCode(uint32_t hexCode);

    // --- Display ---
    void showNumber(int num);
    void showWord(char c1, char c2, char c3, char c4);
    void clearDisplay();

  private:
    TM1637Display _display;
    KK_dht11 _dht;
    
    // Pin Definitionen 
    const int _pinLed1_Yellow = 7;
    const int _pinLed2_Blue   = 6;
    const int _pinLed3_Green  = 5;
    const int _pinLed4_Red    = 4;
    
    const int _pinBuzzer      = 3;
    const int _pinPoti        = A0;
    const int _pinNTC         = A1;
    const int _pinLDR         = A2;
    const int _pinVoltage     = A3; 
    
    const int _pinDHT         = 12;
    const int _pinCLK         = 10;
    const int _pinDIO         = 11;
    const int _pinIR          = 2;
    
    // Interne IR Variablen
    uint32_t _currentIRCode;
    bool _newIRCodeAvailable;

    uint8_t _charToSegment(char c);
};

#endif