#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <RTClib.h>
#include <Wire.h>
#define TFT_DC 14
#define TFT_CS 5
#define TFT_RST 13
#define bUP 35 //tombol atas
#define bDN 34 //tombol bawah
#define bOK 26 //tombol OK
#define bL 3 //tombol kiri
#define bR 1 //tombol kanan
char jam[100]; //tempat nampung data waktu
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"};
char hari[100];
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
RTC_DS1307 rtc;
const unsigned char icon [] PROGMEM = {
// 'clock-five (1), 32x32px
0x00, 0x0f, 0xf0, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x01, 0xff, 0xff, 0x80, 0x03, 0xff, 0xff, 0xc0,
0x07, 0xf8, 0x1f, 0xe0, 0x0f, 0xc0, 0x03, 0xf0, 0x1f, 0x80, 0x01, 0xf8, 0x3f, 0x00, 0x00, 0xfc,
0x3e, 0x07, 0x80, 0x7c, 0x7c, 0x07, 0x80, 0x3e, 0x78, 0x07, 0x80, 0x1e, 0x78, 0x07, 0x80, 0x1e,
0xf8, 0x07, 0x80, 0x1f, 0xf0, 0x07, 0x80, 0x0f, 0xf0, 0x07, 0x80, 0x0f, 0xf0, 0x07, 0x80, 0x0f,
0xf0, 0x07, 0xc0, 0x0f, 0xf0, 0x03, 0xe0, 0x0f, 0xf0, 0x03, 0xe0, 0x0f, 0xf8, 0x01, 0xf0, 0x1f,
0x78, 0x00, 0xf0, 0x1e, 0x78, 0x00, 0xc0, 0x1e, 0x7c, 0x00, 0x00, 0x3e, 0x3e, 0x00, 0x00, 0x7c,
0x3f, 0x00, 0x00, 0xfc, 0x1f, 0x80, 0x01, 0xf8, 0x0f, 0xc0, 0x03, 0xf0, 0x07, 0xf8, 0x1f, 0xe0,
0x03, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0x80, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x0f, 0xf0, 0x00
};
const unsigned char iconMenu [] PROGMEM = {
// 'menu, 32x32px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x7f, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xfe,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void setup() {
pinMode(bUP, INPUT_PULLUP);
pinMode(bDN, INPUT_PULLUP);
pinMode(bOK, INPUT_PULLUP);
pinMode(bL, INPUT_PULLUP);
pinMode(bR, INPUT_PULLUP);
Serial.begin(115200);
tft.begin();
rtc.begin();
tft.setRotation(1);
menuAwal();
}
void loop() {
waktu();
if(digitalRead(bOK) == LOW){
tft.fillRoundRect(185,190,130,40,8,ILI9341_GREEN);
delay(200);
tft.fillScreen(ILI9341_BLACK);
admin();
}
}
void tampil(uint16_t x, uint16_t y, uint16_t size, uint16_t warna, const char*pesan){
tft.setCursor(x,y);
tft.setTextSize(size);
tft.setTextColor(warna);
tft.print(pesan);
}
void waktu(){
DateTime now = rtc.now();
tft.drawBitmap(0,1,icon,32,32,ILI9341_BLUE);
sprintf(jam, "%02i : %02i", now.hour(), now.minute());
sprintf(hari, "%2i-%2i-%4i", now.day(), now.month(), now.year());
tampil(40,5,3,ILI9341_BLUE,jam);
tampil(190,9,2,ILI9341_BLUE,hari);
delay(1000);
tft.fillRect(0,0,320,40,ILI9341_BLACK);
}
void menuAwal(){
tampil(22, 70, 3, ILI9341_RED, "SMART WORKSPACE");
tampil(14, 110, 3, ILI9341_RED, "ATTEDANCE SYSTEM");
//tft.drawRoundRect(150,180,120,35,8,ILI9341_GREEN);
tampil(230,200,3,ILI9341_WHITE,"Menu");
tft.drawBitmap(185,195,iconMenu,32,32,ILI9341_BLUE);
//waktu();
}
void admin(){
tft.drawRoundRect(85,120,120,40,8,ILI9341_GREEN);
tampil(115,130,2,ILI9341_WHITE,"Admin");
}