#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define CURSOR_SIZE 5
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
int cursorX = SCREEN_WIDTH / 2; // Initial X position of the cursor
int cursorY = SCREEN_HEIGHT / 2;
const unsigned char PROGMEM alarmIcon [] = {0x66, 0x81, 0x99, 0x3c, 0x3c, 0x3c, 0x7e, 0x18};
const unsigned char PROGMEM clockIcon [] = {0x18, 0x7e, 0x6e, 0xef, 0xe3, 0x7e, 0x7e, 0x18};
const unsigned char PROGMEM am [] = {0x7f, 0xf0, 0xc6, 0xe8, 0x92, 0x48, 0x92, 0x08, 0x82, 0x08, 0x92, 0x48, 0x92, 0x48, 0x7f, 0xf0};
const unsigned char PROGMEM pm [] = {0x7f, 0xf0, 0x86, 0xe8, 0x92, 0x48, 0x92, 0x08, 0x86, 0x08, 0x9e, 0x48, 0x9e, 0x48, 0x7f, 0xf0};
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Initialize with the I2C address of your display
display.clearDisplay();
display.setTextColor(WHITE);
//display.setTextSize(1);
display.setTextWrap(false);
}
void loop() {
display.clearDisplay();
int batteryWidth = 11;
int batteryHeight = 6;
int batteryX = 115;
int batteryY = 2;
display.drawRoundRect(batteryX, batteryY, batteryWidth, batteryHeight, 1, WHITE);
// display.drawRoundRect(0, 0, 11, 6, 2, WHITE);
display.drawRect(batteryX + 11, batteryY + 2, 1, 2, WHITE);
int batteryLevel = 49; // Change this value to set battery level
if (batteryLevel >= 75) {
display.fillRect(batteryX + 2, batteryY + 2, 1, batteryHeight - 4, WHITE);
display.fillRect(batteryX + 4, batteryY + 2, 1, batteryHeight - 4, WHITE);
display.fillRect(batteryX + 6, batteryY + 2, 1, batteryHeight - 4, WHITE);
display.fillRect(batteryX + 8, batteryY + 2, 1, batteryHeight - 4, WHITE);
} else if (batteryLevel >= 50) {
display.fillRect(batteryX + 2, batteryY + 2, 1, batteryHeight - 4, WHITE);
display.fillRect(batteryX + 4, batteryY + 2, 1, batteryHeight - 4, WHITE);
display.fillRect(batteryX + 6, batteryY + 2, 1, batteryHeight - 4, WHITE);
} else if (batteryLevel > 25) {
display.fillRect(batteryX + 2, batteryY + 2, 1, batteryHeight - 4, WHITE);
display.fillRect(batteryX + 4, batteryY + 2, 1, batteryHeight - 4, WHITE);
} else {
display.fillRect(batteryX + 2, batteryY + 2, 2, batteryHeight - 4, WHITE);
}
display.drawCircle(64, 54, 45, WHITE);
display.drawLine(64, 64, 64, 0, WHITE);
display.drawLine(0, 54, 128, 54, WHITE);
display.drawLine(42, 54, 42, 0, WHITE);
display.drawLine(86, 54, 86, 0, WHITE);
display.drawBitmap(80, 38, am, 13, 8, WHITE) ;
display.drawBitmap(38, 50, alarmIcon, 8, 8, WHITE);
display.drawBitmap(82, 50, clockIcon, 8, 8, WHITE);
display.drawRect(36, 48, 12, 12, WHITE); //alarm
display.drawRect(80, 48, 12, 12, WHITE); //clock
display.display();
}