//include <Wire.h>
#include "ssd1306.h"
//#include "DHT.h"
const int relayPin = 2; // Change this to match your setup
#define DHTPIN 6
#define DHTTYPE DHT22
//DHT dht(DHTPIN, DHTTYPE);
float c = 0;
void setup() {
//pinMode(relayPin, OUTPUT);
//dht.begin();
/* Select the font to use with menu and all font functions */
ssd1306_setFixedFont(free_calibri11x12);
ssd1306_128x64_i2c_init();
// ssd1306_128x64_spi_init(-1, 0, 1); // Use this line for nano pi (RST not used, 0=CE, gpio1=D/C)
// ssd1306_128x64_spi_init(3,4,5); // Use this line for Atmega328p (3=RST, 4=CE, 5=D/C)
// ssd1306_128x64_spi_init(24, 0, 23); // Use this line for Raspberry (gpio24=RST, 0=CE, gpio23=D/C)
// ssd1306_128x64_spi_init(22, 5, 21); // Use this line for ESP32 (VSPI) (gpio22=RST, gpio5=CE for VSPI, gpio21=D/C)
// composite_video_128x64_mono_init(); // Use this line for ESP32 with Composite video support
//ssd1306_clearScreen();
//ssd1306_createMenu( &menu, menuItems, sizeof(menuItems) / sizeof(char *) );
//ssd1306_showMenu( &menu );
//ssd1306_setFixedFont(ssd1306xled_font6x8); free_calibri11x12_latin
ssd1306_setFixedFont(ssd1306xled_font8x16);
ssd1306_clearScreen();
ssd1306_printFixed(0, 0, "Normal text", STYLE_NORMAL);
ssd1306_printFixed(0, 16, "Bold text", STYLE_BOLD);
ssd1306_printFixed(0, 32, "Italic text", STYLE_ITALIC);
ssd1306_negativeMode();
ssd1306_printFixed(0, 48, "Inverted bold", STYLE_BOLD);
ssd1306_positiveMode();
delay(4000);
ssd1306_clearScreen();
ssd1306_printFixed(0, 0, "Temp.: ", STYLE_NORMAL);
ssd1306_printFixed(0, 16, "Umid.: ", STYLE_NORMAL);
ssd1306_printFixed(0, 32, "Cont.+: ", STYLE_NORMAL);
ssd1306_printFixed(0, 48, "Cont.-: ", STYLE_NORMAL);
}
void loop() {
float temperature = 0;
float humidity = 0;
char result;
char s [10];
dtostrf(temperature,7,2, s);
//digitalWrite(relayPin, HIGH);
//delay(1000); // Wait for 1 second
ssd1306_printFixed(70, 0, s , STYLE_BOLD);
dtostrf(humidity,7,2, s);
ssd1306_printFixed(70, 16, s , STYLE_BOLD);
dtostrf(c * -1,7,0, s);
ssd1306_printFixed(70, 32, s , STYLE_BOLD);
dtostrf(c,7,0, s);
ssd1306_printFixed(70, 48, s , STYLE_BOLD);
c-=1 ;
//delay(1000); // Wait for 1 second
// digitalWrite(relayPin, LOW);
}