#include <Arduino.h>
#include <DHT.h>
#include <TM1637Display.h>

#define DIO 1
#define CLK 2
#define DHT_PIN 3
#define LIT_F (SEG_A | SEG_F | SEG_G | SEG_E)
#define LIT_O_LOW (SEG_E | SEG_G | SEG_C | SEG_D)
#define LIT_C (SEG_A | SEG_F | SEG_E | SEG_D)
#define LIT_O_UP (SEG_A | SEG_B | SEG_G | SEG_F)
#define LIT_SPACE 0

DHT dht(DHT_PIN, DHT22);
TM1637Display display(CLK, DIO);

void setup()
{
  display.setBrightness(7);
  dht.begin();
}

void loop()
{
  print_temperature(true);
  delay(2000);

  print_humidity();
  delay(2000);
}

void print_temperature(bool fahrenheit)
{
  display.clear();

  if(fahrenheit){
    const uint8_t FGrade[] = {LIT_O_UP  , LIT_F};
    display.showNumberDec(dht.readTemperature(true), false, 2, 0);
    display.setSegments(FGrade, 2, 2);
  }
  else{
    const uint8_t CGrade[] = {LIT_O_UP  , LIT_C};
    display.showNumberDec(dht.readTemperature(), false, 2, 0);
    display.setSegments(CGrade, 2, 2);
  }
    
}

void print_humidity()
{
  const uint8_t P[] = {LIT_O_UP, LIT_O_LOW};
  display.clear();

  display.showNumberDec(dht.readHumidity(), false, 2, 0);
  display.setSegments(P, 2, 2);
}
4-Digit Display