/*
Simple "Hello World" for ILI9341 LCD
https://wokwi.com/arduino/projects/308024602434470466
*/
#include <dht.h> // Подключение библиотеки
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
// '02', 21x42px
const unsigned char epd_bitmap_02 [] PROGMEM = {
0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0, 0x1f, 0xff, 0xc0, 0xcf, 0xff, 0x98, 0xe0, 0x00, 0x38, 0xf0,
0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00,
0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78,
0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xe0, 0x00, 0x38, 0xc0, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xc0, 0x00, 0x18, 0xe0, 0x00, 0x38, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00,
0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78,
0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xe0,
0x00, 0x38, 0xcf, 0xff, 0x98, 0x1f, 0xff, 0xc0, 0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0
};
// '12', 21x42px
const unsigned char epd_bitmap_12 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x38, 0x00,
0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00,
0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78,
0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x38, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x38, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00,
0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78,
0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00,
0x00, 0x38, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// '22', 21x42px
const unsigned char epd_bitmap_22 [] PROGMEM = {
0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0, 0x1f, 0xff, 0xc0, 0x0f, 0xff, 0x98, 0x00, 0x00, 0x38, 0x00,
0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00,
0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78,
0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x38, 0x0f, 0xff, 0x98, 0x1f, 0xff, 0xc0, 0x1f,
0xff, 0xc0, 0xcf, 0xff, 0x80, 0xe0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00,
0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00,
0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xe0,
0x00, 0x00, 0xcf, 0xff, 0x80, 0x1f, 0xff, 0xc0, 0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0
};
// '32', 21x42px
const unsigned char epd_bitmap_32 [] PROGMEM = {
0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0, 0x1f, 0xff, 0xc0, 0x0f, 0xff, 0x98, 0x00, 0x00, 0x38, 0x00,
0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00,
0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78,
0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x38, 0x0f, 0xff, 0x98, 0x1f, 0xff, 0xc0, 0x1f,
0xff, 0xc0, 0x0f, 0xff, 0x98, 0x00, 0x00, 0x38, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00,
0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78,
0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00,
0x00, 0x38, 0x0f, 0xff, 0x98, 0x1f, 0xff, 0xc0, 0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0
};
// '42', 21x42px
const unsigned char epd_bitmap_42 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x18, 0xe0, 0x00, 0x38, 0xf0,
0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00,
0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78,
0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xe0, 0x00, 0x38, 0xcf, 0xff, 0x98, 0x1f, 0xff, 0xc0, 0x1f,
0xff, 0xc0, 0x0f, 0xff, 0x98, 0x00, 0x00, 0x38, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00,
0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78,
0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00,
0x00, 0x38, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// '52', 21x42px
const unsigned char epd_bitmap_52 [] PROGMEM = {
0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0, 0x1f, 0xff, 0xc0, 0xcf, 0xff, 0x80, 0xe0, 0x00, 0x00, 0xf0,
0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00,
0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00,
0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0xcf, 0xff, 0x80, 0x1f, 0xff, 0xc0, 0x1f,
0xff, 0xc0, 0x0f, 0xff, 0x98, 0x00, 0x00, 0x38, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00,
0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78,
0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00,
0x00, 0x38, 0x0f, 0xff, 0x98, 0x1f, 0xff, 0xc0, 0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0
};
// '62', 21x42px
const unsigned char epd_bitmap_62 [] PROGMEM = {
0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0, 0x1f, 0xff, 0xc0, 0xcf, 0xff, 0x80, 0xe0, 0x00, 0x00, 0xf0,
0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00,
0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00,
0xf0, 0x00, 0x00, 0xf0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0xcf, 0xff, 0x80, 0x1f, 0xff, 0xc0, 0x1f,
0xff, 0xc0, 0xcf, 0xff, 0x98, 0xe0, 0x00, 0x38, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00,
0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78,
0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xe0,
0x00, 0x38, 0xcf, 0xff, 0x98, 0x1f, 0xff, 0xc0, 0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0
};
// '72', 21x42px
const unsigned char epd_bitmap_72 [] PROGMEM = {
0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0, 0x1f, 0xff, 0xc0, 0x0f, 0xff, 0x98, 0x00, 0x00, 0x38, 0x00,
0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00,
0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78,
0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x38, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x38, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00,
0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78,
0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00,
0x00, 0x38, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// '82', 21x42px
const unsigned char epd_bitmap_82 [] PROGMEM = {
0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0, 0x1f, 0xff, 0xc0, 0xcf, 0xff, 0x98, 0xe0, 0x00, 0x38, 0xf0,
0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00,
0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78,
0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xe0, 0x00, 0x38, 0xcf, 0xff, 0x98, 0x1f, 0xff, 0xc0, 0x1f,
0xff, 0xc0, 0xcf, 0xff, 0x98, 0xe0, 0x00, 0x38, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00,
0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78,
0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xe0,
0x00, 0x38, 0xcf, 0xff, 0x98, 0x1f, 0xff, 0xc0, 0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0
};
// '92', 21x42px
const unsigned char epd_bitmap_92 [] PROGMEM = {
0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0, 0x1f, 0xff, 0xc0, 0xcf, 0xff, 0x98, 0xe0, 0x00, 0x38, 0xf0,
0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00,
0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78,
0xf0, 0x00, 0x78, 0xf0, 0x00, 0x78, 0xe0, 0x00, 0x38, 0xcf, 0xff, 0x98, 0x1f, 0xff, 0xc0, 0x1f,
0xff, 0xc0, 0x0f, 0xff, 0x98, 0x00, 0x00, 0x38, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00,
0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78,
0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00, 0x00, 0x78, 0x00,
0x00, 0x38, 0x0f, 0xff, 0x98, 0x1f, 0xff, 0xc0, 0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0
};
// '93', 42x84px
const unsigned char epd_bitmap_93 [] PROGMEM = {
0x0f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x0f, 0xff, 0xff, 0xff,
0xfc, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x03, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x03, 0xff,
0xff, 0xff, 0xf0, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xc3, 0xc0, 0xf0, 0xff, 0xff, 0xff, 0xc3, 0xc0,
0xfc, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0xfc, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0xff, 0x00, 0x00, 0x00,
0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00,
0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0,
0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00,
0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00,
0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0,
0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00,
0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00,
0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0,
0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00,
0x3f, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0xfc, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0xfc, 0x00,
0x00, 0x00, 0x0f, 0xc0, 0xf0, 0xff, 0xff, 0xff, 0xc3, 0xc0, 0xf0, 0xff, 0xff, 0xff, 0xc3, 0xc0,
0x03, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x03, 0xff, 0xff, 0xff,
0xf0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xc3, 0xc0, 0x00, 0xff,
0xff, 0xff, 0xc3, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0xff, 0xff, 0xff, 0xc3, 0xc0, 0x00, 0xff,
0xff, 0xff, 0xc3, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x03, 0xff, 0xff, 0xff, 0xf0, 0x00,
0x0f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x0f, 0xff, 0xff, 0xff,
0xfc, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xfc, 0x00
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 1440)
const int epd_bitmap_allArray_LEN = 11;
const unsigned char* epd_bitmap_allArray[11] = {
epd_bitmap_02,
epd_bitmap_12,
epd_bitmap_22,
epd_bitmap_32,
epd_bitmap_42,
epd_bitmap_52,
epd_bitmap_62,
epd_bitmap_72,
epd_bitmap_82,
epd_bitmap_92,
epd_bitmap_93
};
dht DHT;
#define DHT22_PIN 5
struct
{
uint32_t total;
uint32_t ok;
uint32_t crc_error;
uint32_t time_out;
uint32_t connect;
uint32_t ack_l;
uint32_t ack_h;
uint32_t unknown;
} stat = { 0,0,0,0,0,0,0,0};
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
void drawRoomTemp (int16_t posX, int16_t posY){
tft.drawLine(32 + posX ,41 + posY,43 + posX, 30 + posY, ILI9341_WHITE);
tft.drawLine(43 + posX ,30 + posY,45 + posX, 30 + posY, ILI9341_WHITE);
tft.drawLine(45 + posX ,30 + posY,56 + posX, 41 + posY, ILI9341_WHITE);
tft.drawPixel(35 + posX ,37 + posY, ILI9341_WHITE);
tft.drawRect(35 + posX, 35+ posY, 3, 2, ILI9341_WHITE);
tft.fillRect(35 + posX, 29+ posY, 4, 7, ILI9341_WHITE);
tft.drawLine(35 + posX ,41 + posY,44 + posX, 32 + posY, ILI9341_WHITE);
tft.drawLine(44 + posX ,32 + posY,53 + posX, 41 + posY, ILI9341_WHITE);
tft.drawLine(53 + posX ,41 + posY,53 + posX, 50 + posY, ILI9341_WHITE);
tft.drawLine(53 + posX ,50 + posY,51 + posX, 52 + posY, ILI9341_WHITE);
tft.drawLine(51 + posX ,52 + posY,37 + posX, 52 + posY, ILI9341_WHITE);
tft.drawLine(37 + posX ,52 + posY,35 + posX, 50 + posY, ILI9341_WHITE);
tft.drawLine(35 + posX ,50 + posY,35 + posX, 41 + posY, ILI9341_WHITE);
tft.fillCircle(44 + posX ,46 + posY, 3, ILI9341_WHITE);
tft.drawRoundRect(43 + posX, 35 + posY, 3, 12, 2, ILI9341_WHITE);
tft.drawLine(44 + posX ,40 + posY,44 + posX, 42 + posY, ILI9341_WHITE);
}
void drawOnButton (int16_t posX, int16_t posY) {
tft.fillCircle(50 + posX ,50 + posY, 12, ILI9341_LIGHTGREY );
tft.fillCircle(50 + posX ,50 + posY, 8, ILI9341_BLACK);
tft.fillRect(49 + posX, 38+ posY, 3, 10, ILI9341_LIGHTGREY );
}
void drawButtons(int16_t posX, int16_t posY) {
tft.drawLine(35 + posX ,55 + posY,50 + posX, 40 + posY, ILI9341_WHITE);
tft.drawLine(36 + posX ,55 + posY,50 + posX, 41 + posY, ILI9341_WHITE);
tft.drawLine(36 + posX ,56 + posY,50 + posX, 42 + posY, ILI9341_WHITE);
tft.drawLine(37 + posX ,56 + posY,50 + posX, 43 + posY, ILI9341_WHITE);
tft.drawLine(37 + posX ,57 + posY,50 + posX, 44 + posY, ILI9341_WHITE);
tft.drawLine(50 + posX ,40 + posY,65 + posX, 55 + posY, ILI9341_WHITE);
tft.drawLine(50 + posX ,41 + posY,64 + posX, 55 + posY, ILI9341_WHITE);
tft.drawLine(50 + posX ,42 + posY,64 + posX, 56 + posY, ILI9341_WHITE);
tft.drawLine(50 + posX ,43 + posY,63 + posX, 56 + posY, ILI9341_WHITE);
tft.drawLine(50 + posX ,44 + posY,63 + posX, 57 + posY, ILI9341_WHITE);
posX += 50;
tft.drawLine(35 + posX ,42 + posY,50 + posX, 57 + posY, ILI9341_WHITE);
tft.drawLine(36 + posX ,42 + posY,50 + posX, 56 + posY, ILI9341_WHITE);
tft.drawLine(36 + posX ,41 + posY,50 + posX, 55 + posY, ILI9341_WHITE);
tft.drawLine(37 + posX ,41 + posY,50 + posX, 54 + posY, ILI9341_WHITE);
tft.drawLine(37 + posX ,40 + posY,50 + posX, 53 + posY, ILI9341_WHITE);
tft.drawLine(50 + posX ,57 + posY,65 + posX, 42 + posY, ILI9341_WHITE);
tft.drawLine(50 + posX ,56 + posY,64 + posX, 42 + posY, ILI9341_WHITE);
tft.drawLine(50 + posX ,55 + posY,64 + posX, 41 + posY, ILI9341_WHITE);
tft.drawLine(50 + posX ,54 + posY,63 + posX, 41 + posY, ILI9341_WHITE);
tft.drawLine(50 + posX ,53 + posY,63 + posX, 40 + posY, ILI9341_WHITE);
}
void drawTexts (int16_t posX, int16_t posY) {
tft.setTextSize(1); // Normal 1:1 pixel scale
tft.setTextColor(ILI9341_WHITE); // Draw white text
tft.setCursor(posX,posY); // Start at top-left corner
tft.println(F("ROOM"));
tft.setCursor(posX,posY + 10); // Start at top-left corner
tft.println(F("TEMP"));
tft.setCursor(160 + posX,posY + 5); // Start at top-left corner
tft.println(F("SET"));
tft.drawCircle(158+ posX, posY - 75, 2, ILI9341_WHITE);
tft.setTextSize(3);
tft.setCursor(140 + posX,posY - 75); // Start at top-left corner
tft.println(F("C"));
tft.drawCircle(318+ posX, posY - 75, 2, ILI9341_WHITE);
tft.setTextSize(3);
tft.setCursor(300 + posX, posY - 75); // Start at top-left corner
tft.println(F("C"));
}
void drawIndicator(int16_t posX, int16_t posY) {
tft.fillRect(posX + 5, posY + 5, 5, 55, ILI9341_WHITE);
tft.fillRect(posX + 5, posY + 55, 115, 5, ILI9341_WHITE);
tft.fillRect(posX + 115, posY + 5, 5, 55, ILI9341_WHITE);
tft.fillRect(posX + 15, posY + 45, 15, 5, ILI9341_WHITE);
tft.fillRect(posX + 35, posY + 35, 15, 15, ILI9341_WHITE);
tft.fillRect(posX + 55, posY + 25, 15, 25, ILI9341_WHITE);
tft.fillRect(posX + 75, posY + 15, 15, 35, ILI9341_WHITE);
tft.fillRect(posX + 95, posY + 5, 15, 45, ILI9341_WHITE);
}
void setup() {
Serial.begin(9600);
tft.begin();
tft.setRotation(1);
/*tft.setCursor(26, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println("Hello, TFT!");
tft.setCursor(20, 160);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("I can has colors?");
*/
drawRoomTemp (-30, -20);
drawOnButton(240, 50);
drawButtons(-20, 140);
drawTexts(0, 80);
drawIndicator(160, 160);
// Meme reference: https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
}
void loop() {
// READ DATA
Serial.print("DHT22, \t");
uint32_t start = micros();
int chk = DHT.read22(DHT22_PIN);
uint32_t stop = micros();
stat.total++;
switch (chk)
{
case DHTLIB_OK:
stat.ok++;
Serial.print("OK,\t");
break;
case DHTLIB_ERROR_CHECKSUM:
stat.crc_error++;
Serial.print("Checksum error,\t");
break;
case DHTLIB_ERROR_TIMEOUT:
stat.time_out++;
Serial.print("Time out error,\t");
break;
case DHTLIB_ERROR_CONNECT:
stat.connect++;
Serial.print("Connect error,\t");
break;
case DHTLIB_ERROR_ACK_L:
stat.ack_l++;
Serial.print("Ack Low error,\t");
break;
case DHTLIB_ERROR_ACK_H:
stat.ack_h++;
Serial.print("Ack High error,\t");
break;
default:
stat.unknown++;
Serial.print("Unknown error,\t");
break;
}
// DISPLAY DATA
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.print(DHT.temperature, 1);
Serial.print(",\t");
Serial.print(stop - start);
Serial.println();
if (stat.total % 20 == 0)
{
Serial.println("\nTOT\tOK\tCRC\tTO\tCON\tACK_L\tACK_H\tUNK");
Serial.print(stat.total);
Serial.print("\t");
Serial.print(stat.ok);
Serial.print("\t");
Serial.print(stat.crc_error);
Serial.print("\t");
Serial.print(stat.time_out);
Serial.print("\t");
Serial.print(stat.connect);
Serial.print("\t");
Serial.print(stat.ack_l);
Serial.print("\t");
Serial.print(stat.ack_h);
Serial.print("\t");
Serial.print(stat.unknown);
Serial.println("\n");
}
int16_t tens, eds, des;
tens = DHT.temperature / 10;
eds = int(DHT.temperature) % 10;
if (int(DHT.temperature * 10) % 10 <= 5) {
des = 5;
} else {
des = 0;
eds++;
}
Serial.print(tens);
//Serial.print("\t");
Serial.print(eds);
//Serial.print("\t");
Serial.print(des);
Serial.println();
tft.fillRect(50, 50, 75, 50, ILI9341_BLACK);
tft.drawBitmap(50, 50, epd_bitmap_allArray[tens], 21, 42, ILI9341_WHITE);
tft.drawBitmap(75, 50, epd_bitmap_allArray[eds], 21, 42, ILI9341_WHITE);
tft.fillCircle(98, 92, 2, ILI9341_WHITE);
tft.drawBitmap(100, 50, epd_bitmap_allArray[des], 21, 42, ILI9341_WHITE);
//tft.fillRect(200, 50, 210, 50, ILI9341_BLACK);
tft.drawBitmap(200, 50, epd_bitmap_allArray[2], 21, 42, ILI9341_WHITE);
tft.drawBitmap(225, 50, epd_bitmap_allArray[7], 21, 42, ILI9341_WHITE);
delay(2000);
}