// Minimalis kode OLED utk centering text
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 
#define SCREEN_HEIGHT 64 
#define SCREEN_ADDRESS 0x3C

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

int countLetters(String str) {
  int count = 0;

  for (int i = 0; i < str.length(); i++) {
    if (isAlpha(str[i])) {
      count++;
    }
  }

  return count;
}

void ShowTitikDua()
{
  display.drawCircle(SCREEN_WIDTH/2-2, 24, 2, SSD1306_WHITE);
  display.drawCircle(SCREEN_WIDTH/2-2, 40, 2, SSD1306_WHITE);
}

void Show0(int posisi){
  /*
  display.drawLine(posisi+1, 2, posisi+24, 2, SSD1306_WHITE);
  display.drawLine(posisi+24, 2, posisi+24, 58, SSD1306_WHITE);
  display.drawLine(posisi+24,58, posisi+1, 58, SSD1306_WHITE);
  display.drawLine(posisi+1, 58, posisi+1, 2, SSD1306_WHITE);
  */
  display.drawRoundRect(posisi+1, 2, 24, 56, 8, SSD1306_WHITE);
}
void Show1(int posisi){
  display.drawLine(posisi+14, 2, posisi+14, 58, SSD1306_WHITE);
}
void Show2(int posisi){
  display.drawLine(posisi+1, 2, posisi+24, 2, SSD1306_WHITE);
  display.drawLine(posisi+24, 2, posisi+24, 29, SSD1306_WHITE);
  display.drawLine(posisi+24,29, posisi+1, 29, SSD1306_WHITE);
  display.drawLine(posisi+1, 29, posisi+1, 58, SSD1306_WHITE);
  display.drawLine(posisi+1, 58, posisi+24, 58, SSD1306_WHITE);
}
void Show3(int posisi){
  display.drawLine(posisi+1, 2, posisi+24, 2, SSD1306_WHITE);
  display.drawLine(posisi+24, 2, posisi+24, 58, SSD1306_WHITE);
  display.drawLine(posisi+24,29, posisi+12, 29, SSD1306_WHITE);
  display.drawLine(posisi+1, 58, posisi+24, 58, SSD1306_WHITE);
}
void Show4(int posisi){
  display.drawLine(posisi+1, 2, posisi+1, 29, SSD1306_WHITE);
  display.drawLine(posisi+24, 2, posisi+24, 58, SSD1306_WHITE);
  display.drawLine(posisi+24,29, posisi+1, 29, SSD1306_WHITE);
}
void Show5(int posisi){
  display.drawLine(posisi+1, 2, posisi+24, 2, SSD1306_WHITE);
  display.drawLine(posisi+1, 2, posisi+1, 29, SSD1306_WHITE);
  display.drawLine(posisi+24,29, posisi+1, 29, SSD1306_WHITE);
  display.drawLine(posisi+24, 29, posisi+24, 58, SSD1306_WHITE);
  display.drawLine(posisi+1, 58, posisi+24, 58, SSD1306_WHITE);
}
void Show6(int posisi){
  /*
  display.drawLine(posisi+1, 29, posisi+24, 2, SSD1306_WHITE);
  display.drawLine(posisi+1, 29, posisi+1, 58, SSD1306_WHITE);
  display.drawLine(posisi+24,29, posisi+1, 29, SSD1306_WHITE);
  display.drawLine(posisi+24, 29, posisi+24, 58, SSD1306_WHITE);  
  display.drawLine(posisi+1, 58, posisi+24, 58, SSD1306_WHITE);
  */
  display.drawLine(posisi+1, 29, posisi+24, 2, SSD1306_WHITE);
  display.drawRoundRect(posisi+1, 29, 24, 29, 4, SSD1306_WHITE);
}
void Show7(int posisi){
  display.drawLine(posisi+1, 2, posisi+24, 2, SSD1306_WHITE);
  display.drawLine(posisi+24, 2, posisi+2, 58, SSD1306_WHITE);
}
void Show8(int posisi){
  //Show0(posisi);
  //display.drawLine(posisi+24,29, posisi+1, 29, SSD1306_WHITE);
  display.drawRoundRect(posisi+1, 2, 24, 29, 8, SSD1306_WHITE);
  display.drawRoundRect(posisi+1, 29, 24, 30, 8, SSD1306_WHITE);
}
void Show9(int posisi){
  display.drawLine(posisi+1, 2, posisi+24, 2, SSD1306_WHITE);
  display.drawLine(posisi+1, 2, posisi+1, 29, SSD1306_WHITE);
  display.drawLine(posisi+24,29, posisi+1, 29, SSD1306_WHITE);
  display.drawLine(posisi+24, 2, posisi+24, 58, SSD1306_WHITE);
  display.drawLine(posisi+1, 58, posisi+24, 58, SSD1306_WHITE);
}

void setup() {
  // put your setup code here, to run once:
  
  Serial.begin(115200);

  display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
  display.clearDisplay();
  Show8(0);
  Show3(30);
  Show0(69);
  Show6(99);
  ShowTitikDua();
  display.display();


  
}

void loop() {
  // put your main code here, to run repeatedly:

}