#include <U8glib.h>
#define FONT u8g_font_6x10
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST); //fast i2c
int progress = 0;
int frame=0;
// 'fan55', 32x32px
const unsigned char epd_bitmap_fan55 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00,
0x00, 0x0c, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
0x00, 0x03, 0x00, 0x1e, 0x00, 0x03, 0x81, 0xfe, 0x00, 0x01, 0x9f, 0xee, 0x00, 0x01, 0xfe, 0x04,
0x00, 0x1f, 0xe0, 0x00, 0x31, 0xff, 0xc0, 0x00, 0x7f, 0xe0, 0xc0, 0x00, 0x3e, 0x00, 0xc0, 0x00,
0x20, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x00,
0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00,
0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'fan45', 32x32px
const unsigned char epd_bitmap_fan45 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x03, 0x80, 0x00, 0x00, 0x07, 0x80, 0x00, 0x20, 0x03, 0x80, 0x00, 0x70, 0x01, 0x80, 0x00, 0xf0,
0x00, 0xc0, 0x03, 0xf0, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x70, 0x0e, 0x00, 0x00, 0x38, 0x1c, 0x00,
0x00, 0x1c, 0x38, 0x00, 0x00, 0x0e, 0x70, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x03, 0xc0, 0x00,
0x00, 0x03, 0xc0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x0e, 0x70, 0x00, 0x00, 0x1c, 0x38, 0x00,
0x00, 0x38, 0x1c, 0x00, 0x00, 0x70, 0x0e, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x0f, 0xc0, 0x03, 0x00,
0x0f, 0x00, 0x01, 0x80, 0x0e, 0x00, 0x01, 0xc0, 0x04, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x01, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'fan25', 32x32px
const unsigned char epd_bitmap_fan25 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00,
0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x00, 0x18, 0x00,
0x1c, 0x00, 0x18, 0x00, 0x3c, 0x00, 0x30, 0x00, 0x1e, 0x00, 0x30, 0x00, 0x07, 0x80, 0x60, 0x00,
0x01, 0xe0, 0x60, 0x00, 0x00, 0x78, 0xc0, 0x00, 0x00, 0x1f, 0xc0, 0x00, 0x00, 0x07, 0xc0, 0x00,
0x00, 0x03, 0xe0, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x03, 0x1e, 0x00, 0x00, 0x06, 0x07, 0x80,
0x00, 0x06, 0x01, 0xe0, 0x00, 0x0c, 0x00, 0x78, 0x00, 0x0c, 0x00, 0x3c, 0x00, 0x18, 0x00, 0x38,
0x00, 0x18, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00,
0x00, 0xe0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'fan15', 32x32px
const unsigned char epd_bitmap_fan15 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3c, 0x00,
0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x00,
0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x10, 0x00, 0xc0, 0x00, 0x30, 0x00, 0xc0, 0x00,
0x78, 0x00, 0xc0, 0x00, 0x7f, 0xc0, 0xc0, 0x00, 0x07, 0xfd, 0x80, 0x00, 0x00, 0x7f, 0xc0, 0x00,
0x00, 0x03, 0xfe, 0x00, 0x00, 0x01, 0xbf, 0xe0, 0x00, 0x03, 0x03, 0xfe, 0x00, 0x03, 0x00, 0x1e,
0x00, 0x03, 0x00, 0x0c, 0x00, 0x03, 0x00, 0x08, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
0x00, 0x3c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'fan0 (1)', 32x32px
const unsigned char epd_bitmap_fan0 [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x01, 0xc0, 0x00,
0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
0x00, 0x01, 0x80, 0x00, 0x20, 0x01, 0x80, 0x00, 0x70, 0x01, 0x80, 0x00, 0x7f, 0xff, 0xff, 0xfe,
0x7f, 0xff, 0xff, 0xfe, 0x00, 0x01, 0x80, 0x0e, 0x00, 0x01, 0x80, 0x04, 0x00, 0x01, 0x80, 0x00,
0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00,
0x00, 0x03, 0x80, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Array of all bitmaps for convenience. (Total bytes used to store images in PROGMEM = 720)
const int epd_bitmap_allArray_LEN = 5;
const unsigned char* epd_bitmap_allArray[5] = {
epd_bitmap_fan0,
epd_bitmap_fan15,
epd_bitmap_fan25,
epd_bitmap_fan45,
epd_bitmap_fan55
};
bool firstIteration = true;
// Your bitmap data here...
void setup() {
u8g.setColorIndex(1);
u8g.setFont(FONT);
}
void loop() {
if (firstIteration) {
// Draw the progress bar during the first iteration
loading();
} else {
// Display the welcome screen after the progress bar completes
displayWelcomeScreen();
//delay(1000); // You can adjust the delay as needed
firstIteration = false; // Set the flag to false for the next iteration
}
// Your other code here...
}
void loading() {
u8g.firstPage();
do {
u8g.setColorIndex(1);
u8g.drawStr(5,5,"Loading");
u8g.drawBox(0, 55, progress, 10);
} while (u8g.nextPage());
// Update the progress
if (progress < 128) {
progress++;
} else {
progress = 0;
firstIteration = false; // Set the flag to false to indicate progress completion
}
}
void displayWelcomeScreen() {
battery();
}
void battery(){
u8g.firstPage();
do {
// Display welcome message or any other content
//u8g.setColorIndex(1);
u8g.setColorIndex(1); // Black color
u8g.drawFrame(26,2,58,30); // Battery shape
u8g.setColorIndex(1); //white color
u8g.drawFrame(84,11,4,10);//Battery Head
u8g.drawBox(28,4,map(progress,0,100,0,54),26);
u8g.setFont(u8g_font_profont22);
u8g.drawStr(0, 64-22, "H");
u8g.drawStr(0, 64-2, "L");
u8g.setFont(u8g_font_fub25);
u8g.drawStr(16,64-2,"0000");
u8g.setFont(u8g_font_fub11);
u8g.drawStr(124-16,64-6,"g");
u8g.drawStr(124-16,64-15,"Oz");
u8g.setColorIndex(1);
u8g.drawFrame(92,0,36,36);
//display the fan
u8g.drawBitmapP(94,2,32/8,32,epd_bitmap_allArray[frame]);
} while (u8g.nextPage());
if(progress<100){
progress++;
}else{
progress = 0;
}
frame= frame +1;
if(frame>4){frame=0;}
}