#include "U8glib.h"
// Use the SH1106 driver as it seems SH1107 is not available
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0); // I2C / TWI
const int SCREEN_WIDTH = 128;
const int SCREEN_HEIGHT = 64;
float radius = min(SCREEN_HEIGHT, SCREEN_WIDTH) / 2 - 1;
const int X_CENTER = SCREEN_WIDTH / 2;
const int Y_CENTER = SCREEN_HEIGHT / 2;
void draw(void) {
// Increase OLED brightness
u8g.setContrast(255); // Set the OLED brightness to maximum
// Clear the screen
u8g.firstPage();
do {
// Draw 4 concentric circles with a common center
for (int i = 0; i < 4; i++) {
u8g.drawCircle(X_CENTER, Y_CENTER, radius - (i * 10));
}
} while (u8g.nextPage());
// Print "Hello, World!" for 3 seconds
u8g.setFont(u8g_font_chikita);
u8g.firstPage();
do {
u8g.drawStr(0, 30, " by ARVIND");
} while (u8g.nextPage());
delay(2000);
// Rebuild the concentric circles after some delay
u8g.firstPage();
do {
// Draw 4 concentric circles with a common center again
for (int i = 0; i < 4; i++) {
u8g.drawCircle(X_CENTER, Y_CENTER, radius - (i * 10));
}
} while (u8g.nextPage());
// Rebuild the picture after another delay
delay(1500);
}
void setup(void) {
// flip screen, if required
// u8g.setRot180();
}
void loop(void) {
draw();
}
Loading
grove-oled-sh1107
grove-oled-sh1107