#include "U8g2lib.h"
#include <Wire.h>
#include <uRTCLib.h>

U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0);
uRTCLib rtc(0x68);

// 'batt-logo-pixel', 12x9px
const unsigned char epd_bitmap_batt_logo_pixel [] PROGMEM = {
	0x0c, 0x03, 0xff, 0x0f, 0x01, 0x08, 0x09, 0x08, 0x1d, 0x0b, 0x09, 0x08, 0x01, 0x08, 0x01, 0x08, 
	0xff, 0x0f
};

// 'temp-logo-pixel', 11x9px
const unsigned char epd_bitmap_temp_logo_pixel [] PROGMEM = {
	0x04, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x00, 0x0a, 0x01, 0x91, 0x03, 0xd5, 0x06, 0x91, 0x03, 
	0x0e, 0x01
};

char hari[7][4] = {"MIN", "SEN", "SEL", "RAB", "KAM", "JUM", "SAB"};
char bulan[12][4] = {"JAN", "FEB", "MAR", "APR", "MEI", "JUN", "JUL", "AGU", "SEP", "OKT", "NOV", "DES"};

void setup() {
   u8g2.setColorIndex(1);
   u8g2.begin();
   URTCLIB_WIRE.begin();
}

 void loop() {
  char bufferClock[60], bufferDate[30],  bufferVoltage[10], bufferTemp[10];
  sprintf(bufferDate, "%s - %02d / %s / %02d",hari[rtc.dayOfWeek()-1], rtc.day(), bulan[rtc.month()-1], rtc.year());
  sprintf(bufferClock, "%02d : %02d", rtc.hour(), rtc.minute());

  u8g2.clearBuffer();
  rtc.refresh();

  u8g2.drawLine(5, 28, 123, 28);
  u8g2.drawLine(64, 28, 64, 3);

  u8g2.setFont(u8g2_font_lastapprenticebold_tr);
  u8g2.drawStr(5, 24, "12.55");
  u8g2.drawStr(70, 24, "30.55");

  u8g2.drawStr(48, 61, bufferClock);

  u8g2.setFont(u8g2_font_6x13_tf);
  u8g2.drawStr(54, 24, "v");
  u8g2.drawStr(118, 24, "c");

  u8g2.drawStr(8, 43, bufferDate);

  u8g2.drawXBMP(5, 0, 12, 9, epd_bitmap_batt_logo_pixel);
  u8g2.drawXBMP(70, 0, 11, 9, epd_bitmap_temp_logo_pixel);
  
  u8g2.sendBuffer();
  delay(3000);
 }
GND5VSDASCLSQWRTCDS1307+