// U8g2 library is used for monochrome GLCD
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(
U8G2_R0,
U8X8_PIN_NONE, // reset
22, // clock (SCL)
21 // data (SDA)
);
void setup() {
// Init UART
Serial.begin(115200);
Serial.println("Hello, ESP32!");
// Init LCD
u8g2.begin();
u8g2.enableUTF8Print();
}
void loop() {
// clear the internal memory
u8g2.clearBuffer();
// choose a suitable font
u8g2.setFont(u8g2_font_ncenB08_tr);
// write something to the internal memory
u8g2.drawStr(0, 10, "Hello!");
// choose a farsi font
u8g2.setFont(u8g2_font_samim_10_t_all);
u8g2.drawUTF8(0, 30, "!ﻡﻼﺳ");
// transfer internal memory to the display
u8g2.sendBuffer();
delay(1000);
}