I'm a beginner and I'm doing a project for school!
I'm not able to change screens in the u8g2 library using a button, could someone help me!!
I have this code that works perfectly in the loop
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_7Segments_26x42_mn);
char buf[4];
sprintf(buf, "%d", average);
u8g2.drawFrame(0, 45, 128, 19);
u8g2.drawBox(2, 45, TankValue0, 19);
u8g2.drawStr(3,42, buf);
} while ( u8g2.nextPage() );
and I also have this one that works, but I added the function to change the screen to show the time in an RTC DS1307. however when I press the button the ESP32 crashes
if (digitalRead(BUTTON1) == LOW){
digitalWrite(LedBoard, !digitalRead(LedBoard));
delay(100);
DateTime now = RTC.now();
u8g2.setFont(u8g2_font_7Segments_26x42_mn);
u8g2.setCursor(30, 40);
u8g2.print(now.year());
u8g2.print("-");
u8g2.print(now.month());
u8g2.print("-");
u8g2.print(now.day());
u8g2.print(" ");
u8g2.setCursor(35, 64);
u8g2.print(now.hour());
u8g2.print(":");
u8g2.print(now.minute());
u8g2.print(":");
u8g2.print(now.second());
}