#include <U8g2lib.h>
//U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 12, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ 8);
U8G2_SSD1306_128X64_NONAME_1_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display
byte a = 0;
#define smallFont u8g2_font_battery19_tn
#define bigFont u8g2_font_osr26_tn
char s[25];
void setup() {
// put your setup code here, to run once:
u8g2.begin();
}
void loop() {
// put your main code here, to run repeatedly:
a = a % 7;
u8g2.firstPage();
do {
u8g2.setFontPosTop();
u8g2.setDrawColor(0);
u8g2.drawBox(0, 0, 128, 64);
u8g2.setDrawColor(1);
// u8g2.setFont(bigFont);
// sprintf(s, "%d", a);
// centerPrintIt(0, 128, 0, s);
u8g2.setFont(smallFont);
sprintf(s, "%c", a + 48);
centerPrintIt(0, 128, 40, s);
} while ( u8g2.nextPage() );
a++;
delay(1000);
}
void centerPrintIt( int x1, int x2, int y, char L[]) {
u8g2.drawStr(x1 + (x2 - x1 - u8g2.getStrWidth(L)) / 2, y, L);
return;
}
Loading
ssd1306
ssd1306