#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK); // Display which does not send AC
char s[50];
int n;
String S;
void setup(void) {
u8g.begin();
u8g.setFont(u8g_font_6x13);
//u8g.setFont(u8g_font_unifont);
u8g.setFontPosTop();
}
void loop(void) {
strcpy(s, "Wed, 24 Nov 2024");
sendToScreen();
delay(2000);
for (n = 0; n < 5; n++) {
sprintf(s, "%d", n);
sendToScreen();
delay(2000);
}
strcpy(s, "The End");
sendToScreen();
while (1);
//delay(50);
}
void draw(void) {
// graphic commands to redraw the complete screen should be placed here
//u8g.drawFrame(0, 0, 128, 64);
//strcpy(s, S.c_str());
//sprintf(s, "%s", a);
u8g.drawStr((128 - u8g.getStrWidth(s)) / 2, 4, s);
}
void clearDisplay(void) {
u8g.firstPage();
do {
u8g.setColorIndex(0);
u8g.drawBox(0, 0, 128, 64);
u8g.setColorIndex(1);
} while ( u8g.nextPage() );
}
void sendToScreen(void) {
clearDisplay();
u8g.firstPage();
do {
draw();
} while ( u8g.nextPage() );
}