#include <U8g2lib.h>
// #include <Adafruit_BMP280.h>
#include <Wire.h>
static const unsigned char image_Dominar_bits[] U8X8_PROGMEM = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0xff,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x8f,0xff,0x7f,0xfc,0x01,0x9e,0xcf,0x1f,0x60,0xfe,0xf9,0xff,0x07,0x00,0x80,0xff,0xe7,0x03,0x70,0xfe,0x07,0x9f,0xe7,0x73,0x30,0xc7,0xf3,0xff,0x0f,0x00,0xc0,0xff,0xf3,0x01,0x70,0x7e,0x87,0xcd,0xe7,0xe1,0x98,0x87,0x07,0xf0,0x07,0x00,0xe0,0xff,0xf8,0x80,0xbf,0x3f,0xfe,0xcc,0xf3,0xc0,0xcd,0x07,0x0f,0xff,0x01,0x00,0xf0,0x7f,0xf8,0xfc,0xbf,0x3f,0x7c,0xe6,0xfb,0x80,0xef,0xe3,0x1f,0xff,0x00,0x00,0xff,0x1f,0xf0,0xff,0xcf,0x0f,0x18,0xf3,0x79,0x00,0xe3,0x01,0x3e,0x7c,0x00,0xf0,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0x00,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x03};
static const unsigned char image_D400_bits[] U8X8_PROGMEM = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x9f,0x87,0xcf,0xff,0x9f,0xff,0x3f,0x00,0x00,0xff,0xef,0xc3,0xef,0x03,0xdc,0x0f,0x38,0x00,0x80,0xff,0xf7,0xc0,0xf7,0x01,0xee,0x03,0x1c,0x00,0xc0,0xff,0xf9,0xff,0xfb,0xc0,0xff,0x81,0x1f,0x00,0xe0,0xff,0xfe,0xff,0xfb,0xff,0xf7,0xff,0x0f,0x00,0xfe,0x3f,0x00,0xf0,0xf1,0xff,0xe3,0xff,0x07,0xe0,0xff,0x1f,0x00,0xf8,0xc0,0xff,0x80,0xff,0x01,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static const unsigned char image_New_Project__1___1__bits[] U8X8_PROGMEM = {0xc0,0x01,0x00,0x07,0xc0,0x01,0x80,0x08,0xc0,0x41,0x40,0x10,0xc0,0xa1,0x40,0x10,0xc0,0x81,0x80,0x10,0xf9,0x6f,0x00,0x18,0xf0,0x07,0x00,0x0c,0xe7,0xf3,0xff,0x07,0xc0,0x01,0x00,0x00,0x9f,0xfc,0x3f,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x20,0x00};
static const unsigned char image_frame1_1_bits[] U8X8_PROGMEM = {0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x0e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static const unsigned char image_frame2_bits[] U8X8_PROGMEM = {0x00,0x00,0x1e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static const unsigned char image_frame3_bits[] U8X8_PROGMEM = {0x03,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
static const unsigned char image_arrowDown_bits[] U8X8_PROGMEM = {0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x49,0x2a,0x1c,0x08,0x00,0x00};
static const unsigned char image_arrowUp_bits[] U8X8_PROGMEM = {0x00,0x00,0x08,0x1c,0x2a,0x49,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00};
static const unsigned char image_dash_bits[] U8X8_PROGMEM = {0x00,0x00,0x3e,0x00,0x00};
// Adafruit_BMP280 bmp; // I2C
// U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ 22, /* data=*/ 21, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE, /* clock=*/ 22, /* data=*/ 21); // ESP32 Thing, HW I2C with pin remapping
int width = 0;
char buffer[20];
char buff_tmp[7];
float prevPress;
int currframe = 1;
void setup()
{
// bmp.begin(0x76);
Serial.begin(9600);
u8g2.begin();
//Welcome Sreen
u8g2.clearBuffer();
u8g2.setFontMode(1);
u8g2.setBitmapMode(1);
// u8g2.drawFrame(4, 22, 120, 19);
u8g2.drawXBMP(2, 17, 124, 13, image_Dominar_bits);
u8g2.drawXBMP(46, 29, 78, 13, image_D400_bits);
for (width = 1; width <= 127; width*=2){
// u8g2.drawBox(6, 24, width, 15);
u8g2.drawLine(0, 63, width, 63);
u8g2.sendBuffer();
delay(200);
}
delay(500);
/* Default settings from datasheet. */
// bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */
// Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */
// Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */
// Adafruit_BMP280::FILTER_X16, /* Filtering. */
// Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
}
void loop()
{
// float tmp = 28.3;
float tmp = random(27.5, 35.5);
// float pres = 999999.99;
float pres = random(101355.00, 109000.00);
u8g2.clearBuffer();
u8g2.drawLine (0, 0, 127, 0); //top
u8g2.drawLine (0, 0, 0, 64); //left
u8g2.drawLine (0, 63, 127, 63);// bottom
u8g2.drawLine (0, 46, 127, 46); // line above alti
u8g2.drawLine (127, 0, 127, 63); //right
// u8g2.drawLine (64, 0, 64, 46); // center
// u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font
// u8g2.drawStr(20,11,"Temperature (C)");
// u8g2.drawStr(70,11,"Humidity");
// u8g2.setFont(u8g2_font_crox2cb_tf);
u8g2.setFont(u8g2_font_4x6_mr);
u8g2.drawXBMP(2, 49, 29, 13, image_New_Project__1___1__bits);
u8g2.drawStr(105,60,"hPa");
u8g2.setFont(u8g2_font_crox2cb_tf);
u8g2.setCursor(32,60);
u8g2.print(pres/100,2);
Serial.println(pres);
if (prevPress != 0 && pres < prevPress){
u8g2.drawXBMP(119, 49, 7, 14, image_arrowDown_bits);
}
else if (prevPress != 0 && pres > prevPress){
u8g2.drawXBMP(119, 49, 7, 14, image_arrowUp_bits);
}
else{
u8g2.drawXBMP(119, 54, 7, 5, image_dash_bits);
}
u8g2.setFont(u8g2_font_helvR24_te);
u8g2.setCursor(15,36);
strcpy(buffer, dtostrf(tmp, 1,1,buff_tmp));
strcat(buffer, "\xB0""C");
u8g2.print(buffer);
Serial.println(tmp,1);
if (currframe == 1){
u8g2.drawXBMP(1, 50, 29, 6, image_frame1_1_bits);
currframe++;
}
else if(currframe == 2){
u8g2.drawXBMP(1, 50, 29, 6, image_frame2_bits);
currframe++;
}
else if(currframe == 3){
u8g2.drawXBMP(1, 50, 29, 6, image_frame3_bits);
currframe = 1;
}
u8g2.sendBuffer();
prevPress = pres;
delay(2000);
}