#include "U8g2lib.h"
#include <Wire.h> // library required for IIC communication
#include "RTClib.h" // real time clock module library
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // initialization for the used OLED display
RTC_DS1307 rtc; // initialization for the real time clock module
// ultrasonic
#define trigger 13
#define echo 12
float TotalT= 0 ;
float Speed = 0.000343; // m/us
float Distance =0 ;
//buzzer
#define buzzer 7
//buttons
#define button_1 2
#define button_2 1
#define button_3 4
#define button_4 3
////////////////////////////////////////////////////////// clock //////////////////////////////////////////////////////////////////////////////////
// 'digit_0', 32x49px
const unsigned char epd_bitmap_digit_0 [] PROGMEM = {
0x00, 0xfc, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x0f, 0x80, 0xff, 0xff, 0x47, 0xc0, 0xff, 0xff, 0xe3,
0x00, 0xff, 0xff, 0xf1, 0x00, 0xfc, 0xff, 0xf8, 0x20, 0x00, 0x00, 0xfc, 0xe0, 0x00, 0x00, 0xfc,
0xe0, 0x07, 0x00, 0xfc, 0xf0, 0x07, 0x00, 0xfe, 0xf0, 0x07, 0x00, 0xfe, 0xf0, 0x03, 0x00, 0x7e,
0xf0, 0x03, 0x00, 0x7e, 0xf0, 0x03, 0x00, 0x7e, 0xf0, 0x03, 0x00, 0x7e, 0xf0, 0x03, 0x00, 0x7e,
0xf8, 0x03, 0x00, 0x7f, 0xf8, 0x03, 0x00, 0x7f, 0xf8, 0x11, 0x00, 0x3f, 0xf8, 0x01, 0x00, 0x3f,
0xf8, 0x01, 0x00, 0x38, 0xf8, 0x91, 0x04, 0x00, 0xc0, 0x01, 0x00, 0x01, 0x00, 0x00, 0x80, 0x0f,
0x1c, 0x90, 0x84, 0x3f, 0x7c, 0x00, 0x80, 0x3f, 0xfc, 0x00, 0x80, 0x1f, 0xfc, 0x00, 0x80, 0x1f,
0xfc, 0x00, 0x80, 0x1f, 0xfc, 0x00, 0x80, 0x1f, 0xfe, 0x00, 0xc0, 0x1f, 0xfe, 0x00, 0xc0, 0x1f,
0x7c, 0x00, 0xc0, 0x1f, 0x70, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f, 0x02, 0x00, 0xc0, 0x0f,
0x1e, 0x00, 0xc0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f,
0x3f, 0x00, 0xe0, 0x07, 0x3f, 0x00, 0xe0, 0x07, 0x3f, 0x00, 0xe0, 0x07, 0xff, 0xff, 0xe3, 0x07,
0xff, 0xff, 0xe3, 0x03, 0xff, 0xff, 0xf3, 0x03, 0xfe, 0xff, 0xf3, 0x01, 0xfc, 0xff, 0xf3, 0x00,
0xf8, 0xff, 0x31, 0x00
};
// 'digit_1', 32x49px
const unsigned char epd_bitmap_digit_1 [] PROGMEM = {
0x00, 0x24, 0x49, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x80, 0x24, 0x49, 0xe2,
0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc,
0x00, 0x00, 0x00, 0xfc, 0x90, 0x04, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x7e,
0x90, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x90, 0x00, 0x00, 0x7e,
0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f, 0x90, 0x20, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f,
0x00, 0x00, 0x00, 0x38, 0x90, 0x20, 0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x0f,
0x10, 0x20, 0x89, 0x3f, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0x1f, 0x90, 0x00, 0x80, 0x1f,
0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x80, 0x1f, 0x92, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0xc0, 0x1f,
0x00, 0x00, 0xc0, 0x1f, 0x10, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f,
0x12, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xe0, 0x0f, 0x12, 0x00, 0xe0, 0x0f,
0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x12, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07,
0x00, 0x00, 0xe0, 0x03, 0x92, 0x24, 0xf1, 0x03, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0xf0, 0x00,
0x90, 0x24, 0x31, 0x00
};
// 'digit_2', 32x49px
const unsigned char epd_bitmap_digit_2 [] PROGMEM = {
0x00, 0xfc, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x0f, 0x80, 0xff, 0xff, 0x47, 0xc0, 0xff, 0xff, 0xe3,
0x00, 0xff, 0xff, 0xf1, 0x00, 0xfc, 0xff, 0xf8, 0x20, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc,
0x00, 0x00, 0x00, 0xfc, 0x20, 0x01, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x7e,
0x20, 0x01, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x20, 0x01, 0x00, 0x7e,
0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f, 0x20, 0x31, 0x00, 0x3f, 0x00, 0xf0, 0x01, 0x3f,
0x00, 0xf0, 0x07, 0x38, 0x20, 0xf9, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00,
0x1c, 0xf0, 0x9f, 0x24, 0x7c, 0x80, 0x1f, 0x00, 0xfc, 0x00, 0x1e, 0x00, 0xfc, 0x00, 0x80, 0x04,
0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x80, 0x04, 0xfe, 0x00, 0x00, 0x00,
0x7c, 0x00, 0x00, 0x00, 0x70, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x1e, 0x00, 0x80, 0x04, 0x7f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x80, 0x04,
0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x80, 0x04, 0xff, 0xff, 0x03, 0x00,
0xff, 0xff, 0x03, 0x00, 0xff, 0xff, 0x93, 0x00, 0xfe, 0xff, 0x03, 0x00, 0xfc, 0xff, 0x03, 0x00,
0xf8, 0xff, 0x11, 0x00
};
// 'digit_3', 32x49px
const unsigned char epd_bitmap_digit_3 [] PROGMEM = {
0x00, 0xfc, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x0f, 0x80, 0xff, 0xff, 0x47, 0xc0, 0xff, 0xff, 0xe3,
0x00, 0xff, 0xff, 0xf1, 0x00, 0xfc, 0xff, 0xf8, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc,
0x00, 0x00, 0x00, 0xfc, 0x40, 0x02, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x7e,
0x40, 0x02, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x40, 0x02, 0x00, 0x7e,
0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f, 0x48, 0x30, 0x00, 0x3f, 0x00, 0xf0, 0x01, 0x3f,
0x00, 0xf0, 0x07, 0x38, 0x48, 0xf8, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x01, 0x00, 0xf8, 0x9f, 0x0f,
0x08, 0xf0, 0x9f, 0x3f, 0x00, 0x80, 0x9f, 0x3f, 0x00, 0x00, 0x9e, 0x1f, 0x48, 0x00, 0x80, 0x1f,
0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x80, 0x1f, 0x48, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0xc0, 0x1f,
0x00, 0x00, 0xc0, 0x1f, 0x40, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f, 0x02, 0x00, 0xc0, 0x0f,
0x1e, 0x00, 0xc0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f,
0x3f, 0x00, 0xe0, 0x07, 0x3f, 0x00, 0xe0, 0x07, 0x3f, 0x00, 0xe0, 0x07, 0xff, 0xff, 0xe3, 0x07,
0xff, 0xff, 0xe3, 0x03, 0xff, 0xff, 0xf3, 0x03, 0xfe, 0xff, 0xf3, 0x01, 0xfc, 0xff, 0xf3, 0x00,
0xf8, 0xff, 0x31, 0x00
};
// 'digit_5', 32x49px
const unsigned char epd_bitmap_digit_5 [] PROGMEM = {
0x00, 0xfc, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x0f, 0x80, 0xff, 0xff, 0x07, 0xc0, 0xff, 0xff, 0x23,
0x00, 0xff, 0xff, 0x01, 0x00, 0xfc, 0xff, 0x00, 0x20, 0x00, 0x00, 0x24, 0xe0, 0x00, 0x00, 0x00,
0xe0, 0x07, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x24, 0xf0, 0x07, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00,
0xf0, 0x03, 0x00, 0x24, 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x24,
0xf8, 0x03, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0xf8, 0x31, 0x00, 0x24, 0xf8, 0xf1, 0x01, 0x00,
0xf8, 0xf1, 0x07, 0x00, 0xf8, 0xf9, 0x1f, 0x00, 0xc0, 0xf9, 0x1f, 0x01, 0x00, 0xf8, 0x9f, 0x0f,
0x04, 0xf0, 0x9f, 0x3f, 0x00, 0x80, 0x9f, 0x3f, 0x00, 0x00, 0x9e, 0x1f, 0x24, 0x00, 0x80, 0x1f,
0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x80, 0x1f, 0x24, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0xc0, 0x1f,
0x00, 0x00, 0xc0, 0x1f, 0x20, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f, 0x02, 0x00, 0xc0, 0x0f,
0x1e, 0x00, 0xc0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f,
0x3f, 0x00, 0xe0, 0x07, 0x3f, 0x00, 0xe0, 0x07, 0x3f, 0x00, 0xe0, 0x07, 0xff, 0xff, 0xe3, 0x07,
0xff, 0xff, 0xe3, 0x03, 0xff, 0xff, 0xf3, 0x03, 0xfe, 0xff, 0xf3, 0x01, 0xfc, 0xff, 0xf3, 0x00,
0xf8, 0xff, 0x31, 0x00
};
// 'digit_4', 32x49px
const unsigned char epd_bitmap_digit_4 [] PROGMEM = {
0x00, 0x24, 0x49, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x80, 0x24, 0x49, 0xe2,
0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xf8, 0x20, 0x00, 0x00, 0xfc, 0xe0, 0x00, 0x00, 0xfc,
0xe0, 0x07, 0x00, 0xfc, 0xf0, 0x07, 0x00, 0xfe, 0xf0, 0x07, 0x00, 0xfe, 0xf0, 0x03, 0x00, 0x7e,
0xf0, 0x03, 0x00, 0x7e, 0xf0, 0x03, 0x00, 0x7e, 0xf0, 0x03, 0x00, 0x7e, 0xf0, 0x03, 0x00, 0x7e,
0xf8, 0x03, 0x00, 0x7f, 0xf8, 0x03, 0x00, 0x7f, 0xf8, 0x31, 0x00, 0x3f, 0xf8, 0xf1, 0x01, 0x3f,
0xf8, 0xf1, 0x07, 0x38, 0xf8, 0xf9, 0x1f, 0x00, 0xc0, 0xf9, 0x1f, 0x01, 0x00, 0xf8, 0x9f, 0x0f,
0x10, 0xf0, 0x9f, 0x3f, 0x00, 0x80, 0x9f, 0x3f, 0x00, 0x00, 0x9e, 0x1f, 0x90, 0x00, 0x80, 0x1f,
0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x80, 0x1f, 0x92, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0xc0, 0x1f,
0x00, 0x00, 0xc0, 0x1f, 0x10, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f,
0x12, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xe0, 0x0f, 0x12, 0x00, 0xe0, 0x0f,
0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x12, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07,
0x00, 0x00, 0xe0, 0x03, 0x92, 0x24, 0xf1, 0x03, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0xf0, 0x00,
0x90, 0x24, 0x31, 0x00
};
// 'digit_7', 32x49px
const unsigned char epd_bitmap_digit_7 [] PROGMEM = {
0x00, 0xfc, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x0f, 0x80, 0xff, 0xff, 0x47, 0xc0, 0xff, 0xff, 0xe3,
0x00, 0xff, 0xff, 0xf1, 0x00, 0xfc, 0xff, 0xf8, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc,
0x00, 0x00, 0x00, 0xfc, 0x90, 0x04, 0x00, 0xfe, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x7e,
0x90, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x7e, 0x90, 0x00, 0x00, 0x7e,
0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f, 0x90, 0x20, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x3f,
0x00, 0x00, 0x00, 0x38, 0x90, 0x20, 0x09, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x0f,
0x10, 0x20, 0x89, 0x3f, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0x1f, 0x90, 0x00, 0x80, 0x1f,
0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x80, 0x1f, 0x92, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0xc0, 0x1f,
0x00, 0x00, 0xc0, 0x1f, 0x10, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f,
0x12, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xe0, 0x0f, 0x12, 0x00, 0xe0, 0x0f,
0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x12, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07,
0x00, 0x00, 0xe0, 0x03, 0x92, 0x24, 0xf1, 0x03, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0xf0, 0x00,
0x90, 0x24, 0x31, 0x00
};
// 'digit_6', 32x49px
const unsigned char epd_bitmap_digit_6 [] PROGMEM = {
0x00, 0xfc, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x0f, 0x80, 0xff, 0xff, 0x07, 0xc0, 0xff, 0xff, 0x43,
0x00, 0xff, 0xff, 0x01, 0x00, 0xfc, 0xff, 0x00, 0x20, 0x00, 0x00, 0x48, 0xe0, 0x00, 0x00, 0x00,
0xe0, 0x07, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x48, 0xf0, 0x07, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00,
0xf0, 0x03, 0x00, 0x48, 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x48,
0xf8, 0x03, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, 0xf8, 0x31, 0x00, 0x09, 0xf8, 0xf1, 0x01, 0x00,
0xf8, 0xf1, 0x07, 0x00, 0xf8, 0xf9, 0x1f, 0x00, 0xc0, 0xf9, 0x1f, 0x01, 0x00, 0xf8, 0x9f, 0x0f,
0x1c, 0xf0, 0x9f, 0x3f, 0x7c, 0x80, 0x9f, 0x3f, 0xfc, 0x00, 0x9e, 0x1f, 0xfc, 0x00, 0x80, 0x1f,
0xfc, 0x00, 0x80, 0x1f, 0xfc, 0x00, 0x80, 0x1f, 0xfe, 0x00, 0xc0, 0x1f, 0xfe, 0x00, 0xc0, 0x1f,
0x7c, 0x00, 0xc0, 0x1f, 0x70, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f, 0x02, 0x00, 0xc0, 0x0f,
0x1e, 0x00, 0xc0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f,
0x3f, 0x00, 0xe0, 0x07, 0x3f, 0x00, 0xe0, 0x07, 0x3f, 0x00, 0xe0, 0x07, 0xff, 0xff, 0xe3, 0x07,
0xff, 0xff, 0xe3, 0x03, 0xff, 0xff, 0xf3, 0x03, 0xfe, 0xff, 0xf3, 0x01, 0xfc, 0xff, 0xf3, 0x00,
0xf8, 0xff, 0x31, 0x00
};
// 'digit_8', 32x49px
const unsigned char epd_bitmap_digit_8 [] PROGMEM = {
0x00, 0xfc, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x0f, 0x80, 0xff, 0xff, 0x47, 0xc0, 0xff, 0xff, 0xe3,
0x00, 0xff, 0xff, 0xf1, 0x00, 0xfc, 0xff, 0xf8, 0x20, 0x00, 0x00, 0xfc, 0xe0, 0x00, 0x00, 0xfc,
0xe0, 0x07, 0x00, 0xfc, 0xf0, 0x07, 0x00, 0xfe, 0xf0, 0x07, 0x00, 0xfe, 0xf0, 0x03, 0x00, 0x7e,
0xf0, 0x03, 0x00, 0x7e, 0xf0, 0x03, 0x00, 0x7e, 0xf0, 0x03, 0x00, 0x7e, 0xf0, 0x03, 0x00, 0x7e,
0xf8, 0x03, 0x00, 0x7f, 0xf8, 0x03, 0x00, 0x7f, 0xf8, 0x31, 0x00, 0x3f, 0xf8, 0xf1, 0x01, 0x3f,
0xf8, 0xf1, 0x07, 0x38, 0xf8, 0xf9, 0x1f, 0x00, 0xc0, 0xf9, 0x1f, 0x01, 0x00, 0xf8, 0x9f, 0x0f,
0x1c, 0xf0, 0x9f, 0x3f, 0x7c, 0x80, 0x9f, 0x3f, 0xfc, 0x00, 0x9e, 0x1f, 0xfc, 0x00, 0x80, 0x1f,
0xfc, 0x00, 0x80, 0x1f, 0xfc, 0x00, 0x80, 0x1f, 0xfe, 0x00, 0xc0, 0x1f, 0xfe, 0x00, 0xc0, 0x1f,
0x7c, 0x00, 0xc0, 0x1f, 0x70, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f, 0x02, 0x00, 0xc0, 0x0f,
0x1e, 0x00, 0xc0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f,
0x3f, 0x00, 0xe0, 0x07, 0x3f, 0x00, 0xe0, 0x07, 0x3f, 0x00, 0xe0, 0x07, 0xff, 0xff, 0xe3, 0x07,
0xff, 0xff, 0xe3, 0x03, 0xff, 0xff, 0xf3, 0x03, 0xfe, 0xff, 0xf3, 0x01, 0xfc, 0xff, 0xf3, 0x00,
0xf8, 0xff, 0x31, 0x00
};
// 'digit_9', 32x49px
const unsigned char epd_bitmap_digit_9 [] PROGMEM = {
0x00, 0xfc, 0xff, 0x1f, 0x00, 0xff, 0xff, 0x0f, 0x80, 0xff, 0xff, 0x47, 0xc0, 0xff, 0xff, 0xe3,
0x00, 0xff, 0xff, 0xf1, 0x00, 0xfc, 0xff, 0xf8, 0x20, 0x00, 0x00, 0xfc, 0xe0, 0x00, 0x00, 0xfc,
0xe0, 0x07, 0x00, 0xfc, 0xf0, 0x07, 0x00, 0xfe, 0xf0, 0x07, 0x00, 0xfe, 0xf0, 0x03, 0x00, 0x7e,
0xf0, 0x03, 0x00, 0x7e, 0xf0, 0x03, 0x00, 0x7e, 0xf0, 0x03, 0x00, 0x7e, 0xf0, 0x03, 0x00, 0x7e,
0xf8, 0x03, 0x00, 0x7f, 0xf8, 0x03, 0x00, 0x7f, 0xf8, 0x31, 0x00, 0x3f, 0xf8, 0xf1, 0x01, 0x3f,
0xf8, 0xf1, 0x07, 0x38, 0xf8, 0xf9, 0x1f, 0x00, 0xc0, 0xf9, 0x1f, 0x01, 0x00, 0xf8, 0x9f, 0x0f,
0x08, 0xf0, 0x9f, 0x3f, 0x00, 0x80, 0x9f, 0x3f, 0x00, 0x00, 0x9e, 0x1f, 0x48, 0x00, 0x80, 0x1f,
0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x80, 0x1f, 0x48, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0xc0, 0x1f,
0x00, 0x00, 0xc0, 0x1f, 0x40, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0xc0, 0x0f, 0x02, 0x00, 0xc0, 0x0f,
0x1e, 0x00, 0xc0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f, 0x7f, 0x00, 0xe0, 0x0f,
0x3f, 0x00, 0xe0, 0x07, 0x3f, 0x00, 0xe0, 0x07, 0x3f, 0x00, 0xe0, 0x07, 0xff, 0xff, 0xe3, 0x07,
0xff, 0xff, 0xe3, 0x03, 0xff, 0xff, 0xf3, 0x03, 0xfe, 0xff, 0xf3, 0x01, 0xfc, 0xff, 0xf3, 0x00,
0xf8, 0xff, 0x31, 0x00
};
// Array of all digits
const unsigned char* bitmaps_digits[10] = {
epd_bitmap_digit_0,
epd_bitmap_digit_1,
epd_bitmap_digit_2,
epd_bitmap_digit_3,
epd_bitmap_digit_4,
epd_bitmap_digit_5,
epd_bitmap_digit_6,
epd_bitmap_digit_7,
epd_bitmap_digit_8,
epd_bitmap_digit_9
};
int hours = 0;
int minutes = 0;
int seconds = 0;
/////////////////////////////////////////////////////////// first page //////////////////////////////////////////////////////////////////////////
// 'itc logo', 16x16px
const unsigned char epd_bitmap_teams_logo [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x3c, 0xdc, 0x7b, 0xee, 0x77, 0xee, 0x77,
0xee, 0x77, 0xec, 0x37, 0xd8, 0x1b, 0x9e, 0x79, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'BE logo', 16x16px
const unsigned char epd_bitmap_BE_logo [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x20, 0x04, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08,
0x20, 0x04, 0xc0, 0x03, 0x20, 0x04, 0x10, 0x08, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10, 0x00, 0x00
};
// 'teams logo', 16x16px
const unsigned char epd_bitmap_itc_logo [] PROGMEM = {
0x00, 0x00, 0x10, 0x00, 0x30, 0x00, 0x00, 0x00, 0xfe, 0x1f, 0xfe, 0x3f, 0x30, 0x00, 0xb6, 0x01,
0xb6, 0x01, 0xb6, 0x01, 0xb6, 0x01, 0xb6, 0x01, 0xb6, 0x01, 0xb6, 0x7f, 0xb6, 0x3f, 0x00, 0x00
};
// 'event logo', 16x16px
const unsigned char epd_bitmap_event_logo [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x05, 0x50, 0x05, 0xa8, 0x0a, 0x04, 0x10, 0x54, 0x15,
0x04, 0x10, 0x54, 0x15, 0x04, 0x10, 0x54, 0x15, 0x04, 0x10, 0x04, 0x10, 0xf8, 0x0f, 0x00, 0x00
};
// 'games logo', 16x16px
const unsigned char epd_bitmap_games_logo [] PROGMEM = {
0x00, 0x04, 0x00, 0x02, 0x00, 0x07, 0xf0, 0x0f, 0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x12, 0x48,
0x3a, 0x54, 0x12, 0x48, 0x02, 0x40, 0x82, 0x41, 0x44, 0x22, 0x44, 0x22, 0x38, 0x1c, 0x00, 0x00
};
// 'emergence logo', 16x16px
const unsigned char epd_bitmap_emergency_logo [] PROGMEM = {
0x00, 0x00, 0x7c, 0x00, 0x42, 0x00, 0x42, 0x00, 0x42, 0x7f, 0x62, 0x41, 0x22, 0x49, 0x12, 0x5d,
0x12, 0x49, 0x22, 0x41, 0x62, 0x7f, 0x42, 0x06, 0x42, 0x02, 0x42, 0x00, 0x7c, 0x00, 0x00, 0x00
};
const unsigned char* bitmap_icons [6] = {
epd_bitmap_itc_logo,
epd_bitmap_BE_logo,
epd_bitmap_teams_logo,
epd_bitmap_event_logo,
epd_bitmap_games_logo,
epd_bitmap_emergency_logo
};
// 'cursor points', 8x64px
const unsigned char epd_bitmap_cursor_points [] PROGMEM = {
0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00,
0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00,
0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00,
0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00
};
// 'selection', 128x21px
const unsigned char epd_bitmap_selection [] PROGMEM = {
0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01,
0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00
};
/////////////////////////////////////////////////////// expressions //////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////// teams ////////////////////////////////////////////////////////////////////////////
// 'article', 16x16px
const unsigned char epd_bitmap_article [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0xf8, 0x07, 0x14, 0x04, 0x12, 0x04, 0xde, 0x05, 0x02, 0x04, 0xfa, 0x05,
0x02, 0x04, 0x3a, 0x05, 0x02, 0x3c, 0xda, 0x25, 0x02, 0x24, 0x04, 0x28, 0xf8, 0x1f, 0x00, 0x00
};
// 'design', 16x16px
const unsigned char epd_bitmap_design [] PROGMEM = {
0x00, 0x00, 0x00, 0x60, 0x00, 0x50, 0x00, 0x48, 0x00, 0x24, 0x00, 0x12, 0x00, 0x09, 0x80, 0x04,
0x40, 0x02, 0x70, 0x01, 0x88, 0x00, 0x88, 0x00, 0x88, 0x00, 0x64, 0x00, 0x1e, 0x00, 0x00, 0x00
};
// 'security', 16x16px
const unsigned char epd_bitmap_security [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0xf8, 0x1f, 0x08, 0x10,
0x08, 0x10, 0x88, 0x11, 0x88, 0x11, 0x88, 0x11, 0x08, 0x10, 0xf8, 0x1f, 0x00, 0x00, 0x00, 0x00
};
// 'mobile ', 16x16px
const unsigned char epd_bitmap_mobile_ [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x08, 0x10, 0xe8, 0x17, 0xe8, 0x17, 0xe8, 0x17, 0xe8, 0x17,
0xe8, 0x17, 0xe8, 0x17, 0xe8, 0x17, 0x08, 0x10, 0x88, 0x11, 0x08, 0x10, 0xf0, 0x0f, 0x00, 0x00
};
// 'robotics', 16x16px
const unsigned char epd_bitmap_robotics [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x40, 0x01, 0xf8, 0x0f, 0x04, 0x10, 0x04, 0x10, 0x24, 0x12, 0x04, 0x10,
0xc4, 0x11, 0x04, 0x10, 0x04, 0x10, 0xf8, 0x0f, 0x20, 0x02, 0x30, 0x06, 0x00, 0x00, 0x00, 0x00
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 240)
const int epd_bitmap_allArray_LEN = 5;
const unsigned char* epd_bitmap_allArray[5] = {
epd_bitmap_article,
epd_bitmap_design,
epd_bitmap_mobile_,
epd_bitmap_robotics,
epd_bitmap_security
};
///////////////////////////////////////////////////////////// Games///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////// formation ///////////////////////////////////////////////////////////////////////
int b_up_clicked = 0; // only perform action when button is clicked, and wait until another press
int b_anter_clicked = 0;
int b_down_clicked = 0;
int current_screen = 0;
//screen 1
const int NUM_item = 6;
char menu_items[NUM_item][20]{
{"itc"},
{"BE members"},
{"Teams"},
{"Events"},
{"Games"},
{"Emergency"}
};
int selected =0;
int previous;
int next;
void setup() {
pinMode(button_1, INPUT_PULLUP);
pinMode(button_2, INPUT_PULLUP);
pinMode(button_3, INPUT_PULLUP);
pinMode(button_4, INPUT_PULLUP);
pinMode(buzzer, INPUT);
pinMode(trigger, OUTPUT);
pinMode(echo, INPUT);
u8g2.begin();
u8g2.setBitmapMode(1); // screen mode
rtc.begin(); // initialize the RTC module
}
void loop() {
// setting up time
rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // set the time and date to the time and date of uploading the sketch
DateTime now = rtc.now(); // get current time from the RTC module
hours = now.hour () ;
hours = hours +1; // utc +1
if (hours == 24){hours = 00;}
minutes = now.minute();
seconds = now.second();
digitalWrite(trigger, LOW);
delayMicroseconds(2);
digitalWrite(trigger, HIGH);
delayMicroseconds(10);
digitalWrite(trigger, LOW);
TotalT = pulseIn(echo, HIGH);
Distance = (TotalT * Speed) / 2;
if(Distance >= 1){
for(int t = 0; t < 50; t++){
u8g2.clearBuffer(); // clear the internal memory for drawing content
// draw digits for hours
u8g2.drawXBMP(0, 7, 32, 49, bitmaps_digits[hours / 10]); // first digit for hours
u8g2.drawXBMP(30, 7, 32, 49, bitmaps_digits[hours % 10]); // second digit for hours
// only show the colon in between every two seconds
if (seconds % 2 == 0) { // the result will be 0 or 1 depending if the value is even or odd
u8g2.drawBox(63, 21, 4, 4); // draw filled rectangle
u8g2.drawBox(61, 37, 4, 4); // draw filled rectangle
}
// draw digits for minutes
u8g2.drawXBMP(66, 7, 32, 49, bitmaps_digits[minutes / 10]); // first digit for minutes
u8g2.drawXBMP(96, 7, 32, 49, bitmaps_digits[minutes % 10]); // second digit for minutes
u8g2.sendBuffer(); // transfer internal memory to the display
}
}
else {
u8g2.setFont(u8g_font_7x14);
u8g2.setColorIndex(1);
if(current_screen == 0 || current_screen == 1){
if(digitalRead(button_3) == LOW && (b_up_clicked == 0)){
tone(buzzer, 660, 20);
selected = selected - 1;
b_up_clicked = 1;
if (selected < 0){
selected = NUM_item -1;
}
}
if(digitalRead(button_2) == LOW && (b_down_clicked == 0)){
tone(buzzer, 600, 20);
selected = selected + 1;
b_down_clicked = 1;
if (selected >= NUM_item){
selected = 0;
}
}
if ((digitalRead(button_3) == HIGH) && (b_up_clicked == 1)) { // unclick
b_up_clicked = 0;
}
if ((digitalRead(button_2) == HIGH) && (b_down_clicked == 1)) { // unclick
b_down_clicked = 0;
}
}
previous = selected - 1;
if (previous < 0){previous = NUM_item -1;} //turn to the last
next = selected + 1;
if (next >= NUM_item){next = 0;} //turn to the first
if ((digitalRead(button_1) == LOW) && (b_anter_clicked == 0)) { // select button clicked, jump between screens
tone(buzzer, 523, 60);
tone(buzzer, 659, 40);
tone(buzzer, 900, 40);
b_anter_clicked = 1; // set button to clicked to only perform the action once
if (current_screen == 0) {current_screen = 1;} // menu items screen --> screenshots screen
else if (current_screen == 1 && bitmap_icons[selected] == epd_bitmap_teams_logo) {current_screen = 2;} // screenshots screen --> home with it being formation
else {current_screen = 0 ;} // --> menu items screen
}
if ((digitalRead(button_1) == HIGH) && (b_anter_clicked == 1)) { // unclick
b_anter_clicked = 0;
}
u8g2.firstPage();
do {
if (current_screen == 0) {
u8g2.setFont(u8g_font_7x14);
u8g2.drawStr(25, 15, menu_items[previous]);
u8g2.drawXBMP( 4, 2, 16, 16, bitmap_icons[previous]);
//selected
u8g2.setFont(u8g_font_7x14B);
u8g2.drawStr(25, 37, menu_items[selected]);
u8g2.drawXBMP( 4, 24, 16, 16, bitmap_icons[selected]);
//next
u8g2.setFont(u8g_font_7x14);
u8g2.drawStr(25, 59, menu_items[next]);
u8g2.drawXBMP( 4, 46, 16, 16, bitmap_icons[next]);
u8g2.drawXBMP( 0, 22, 128, 21, epd_bitmap_selection);
u8g2.drawXBMP( 120, 0, 8, 64, epd_bitmap_cursor_points);
u8g2.drawBox(125, 64/6*selected , 8, 64/6); //6 is the number of total items and selected is the number of the selected item
}
else if (current_screen == 1) {
/*
if(bitmap_screenshots[selected] == epd_bitmap_ones_at_the_moment){
u8g2.setFont(u8g_font_7x14);
u8g2.drawStr(3, 21, menu_items_[previous_]);
//selected
u8g2.setFont(u8g_font_7x14B);
u8g2.drawStr(3, 40, menu_items_[selected_]);
//next
u8g2.setFont(u8g_font_7x14);
u8g2.drawStr(3, 58, menu_items_[next_]);
//u8g2.drawBitmapP( 0, 28, 128/8, 16, epd_bitmap_selection_2); //selection
//u8g2.drawBitmapP( 0, 0, 128/8, 9, epd_bitmap_ones_at_the_moment_1);
}
else{
//u8g2.drawBitmapP( 0, 0, 128/8, 64, bitmap_screenshots[selected]); // draw screenshot
u8g2.drawXBMP(0, 0, 128, 64, bitmap_screenshots[selected]);
}
*/
}
}while ( u8g2.nextPage() );
}
/*
else{u8g2.firstPage(); // Start clearing the first page
do {
u8g2.setColorIndex(0); // Set the color index to 0 (clear)
u8g2.drawBox(0, 0, u8g2.getWidth(), u8g2.getHeight()); // Draw a box covering the entire display to clear it
} while (u8g2.nextPage()); // Continue to the next page if available
}
*/
}