#include "PrayerTimes.h"
#include <Wire.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 8
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
/*
#include <SystemFont5x7.h>
#include "fonts/Arial_Black_16.h"
#include "fonts/myNumber6x16.h"
//#include "fonts/SystemFont5x7.h"
#include <fonts/ElektronMart6x16.h>
#include <fonts/ElektronMart6x8.h>
#include <fonts/ElektronMartArabic6x16.h>
*/
#include "RTClib.h"
//#include "Notes.h"
RTC_DS1307 rtc;
char daysOfTheWeek[7][6] = {"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"};
static const char* NamaSholat[] =
{
"Subuh",
"Syuruq",
"Dzuhur",
"Ashar",
"Maghrib",
"Isya'"
};
/*
* JADWAL WAKTU SHOLAT MENGGUNAKAN NODEMCU ESP8266, LED P10, RTC DS3241, BUZZER
* FITUR : JADWAL SHOLAT 5 WAKTU DAN TANBIH IMSAK, JAM BESAR, TANGGAL, SUHU, ALARAM ADZAN DAN TANBIH IMSAK,
* DAN HITUNG MUNDUR IQOMAH DAN UBAH WAKTU LEWAT WIFI DENGAN BROWSER.
*
Pin on DMD P10 GPIO NODEMCU Pin on DS3231 NODEMCU Pin on Buzzer NODEMCU
2 A GPIO16 D0 SCL D1 (GPIO 5) + RX (GPIO 3)
4 B GPIO12 D6 SDA D2 (GPIO 4) - GND
8 CLK GPIO14 D5 VCC 3V
10 SCK GPIO0 D3 GND GND
12 R GPIO13 D7
1 NOE GPIO15 D8
3 GND GND GND
Catatan :
o Perlu Power Eksternal 5V ke LED P10.
o Saat Flashing (upload program) cabut sementara pin untuk buzzer.
Eksternal Library
- HJS589(DMD3 porting for ESP8266 by Ahmad Herman) < DMD3 by Wardi Utari @ MFH Robotic (info https://www.facebook.com/MFH.Robotic/)) < DMD : https://github.com/freetronics/DMD
- PrayerTime : https://github.com/asmaklad/Arduino-Prayer-Times
- RTC DS3231 : https://github.com/Makuna/Rtc
- ArduinoJson V6 : https://github.com/bblanchon/ArduinoJson
*/
// JADWAL SHOLAT
double waktuJWS[sizeof(TimeName)/sizeof(char*)];
/*
// Durasi waktu iqomah
struct ConfigJws {
int adzns;
int adznd;
int adzna;
int adznm;
int adzni;
int iqmhs;
int iqmhd;
int iqmha;
int iqmhm;
int iqmhi;
int stbys;
int stbyd;
int stbya;
int stbym;
int stbyi;
int stbyj;
int ihti; // Koreksi Waktu Menit Jadwal Sholat
float latitude;
float longitude;
int zonawaktu;
};
struct ConfigInfo {
char nama[64];
char infosholat[512];
int blnmasehi1;
int hari1;
int tglmasehiawal1;
int tglmasehiakhir1;
int blnhijriyah1;
int tglhijriyahawal1;
int tglhijriyahakhir1;
int jamawal1;
int jamakhir1;
char huruf1[10];
char info1[512];
int blnmasehi2;
int hari2;
int tglmasehiawal2;
int tglmasehiakhir2;
int blnhijriyah2;
int tglhijriyahawal2;
int tglhijriyahakhir2;
int jamawal2;
int jamakhir2;
char huruf2[10];
char info2[512];
int blnmasehi3;
int hari3;
int tglmasehiawal3;
int tglmasehiakhir3;
int blnhijriyah3;
int tglhijriyahawal3;
int tglhijriyahakhir3;
int jamawal3;
int jamakhir3;
char huruf3[10];
char info3[512];
int blnmasehi4;
int hari4;
int tglmasehiawal4;
int tglmasehiakhir4;
int blnhijriyah4;
int tglhijriyahawal4;
int tglhijriyahakhir4;
int jamawal4;
int jamakhir4;
char huruf4[10];
char info4[512];
int blnmasehi5;
int hari5;
int tglmasehiawal5;
int tglmasehiakhir5;
int blnhijriyah5;
int tglhijriyahawal5;
int tglhijriyahakhir5;
int jamawal5;
int jamakhir5;
char huruf5[10];
char info5[512];
};
struct ConfigWifi {
char wifissid[64];
char wifipassword[64];
};
struct ConfigDisp {
int cerah;
int cepat;
int onjam;
int onmenit;
int offjam;
int offmenit;
};
int iqmh, menitiqmh;
int detikiqmh = 60;
int minStanby, secStanby;
int cJam, cMenit;
// BUZZER
const int buzzer = 3; // Pin GPIO Buzzer - RX
// LED Internal
uint8_t pin_led = 2;
//SETUP RTC
//year, month, date, hour, min, sec and week-day(Senin 0 sampai Ahad 6)
//DateTime dt(2018, 12, 20, 16, 30, 0, 3);
RtcDateTime rtcNow;
/////////////////start1/////////////////////////////
#define epochHijriah 1948439.5f //math.harvard.edu
#define tambahKurangHijriah 0
struct TanggalMasehi {
uint8_t detik;
uint8_t menit;
uint8_t jam;
uint8_t hari;
uint8_t tanggal;
uint8_t bulan;
uint16_t tahun;
};
struct TanggalHijriah {
uint8_t tanggal;
uint8_t bulan;
uint16_t tahun;
};
struct TanggalJawa {
uint8_t pasaran;
uint8_t wuku;
uint8_t tanggal;
uint8_t bulan;
uint16_t tahun;
};
struct JamDanMenit {
int jam;
int menit;
};
uint8_t jumlahHariPerBulan[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
char wulanInMasehi[][10] = {"Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember" };
char wulanInHijriah[][17] = {"Muharram", "Shafar", "Rabiul Awal", "Rabiul Akhir", "Jumadil Ula", "Jumadil Tsaniyah", "Rajab", "Sya'ban", "Ramadhan", "Syawal", "Dzulqa'dah", "Dzulhijjah" };
char dinoInWulan[][7] = {"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jum'at", "Sabtu",};
char namaBulanJawa[][13] = { "Sura", "Sapar", "Mulud", "Bakda Mulud", "Jumadil Awal", "Jumadil Akir", "Rejeb", "Ruwah", "Pasa", "Sawal", "Sela", "Besar" };
char namaWukuJawa[][13] = {"Shinta", "Landhep", "Wukit", "Kurantil", "Tala", "Gumbreg", "Warigalit", "Warigagung", "Julungwangi",
"Sungsang", "Galungan", "Kuningan", "Langkir", "Mandasia", "Julungpujut", "Pahang", "Kuruwelut", "Mrakeh", "Tambir",
"Madangkungan", "Maktal", "Wuye", "Manahil", "Prangbakat", "Bala", "Wungu", "Wayang", "Kulawu", "Dhukut", "Watugunung"
};
char namaHariPasaran[][7] = {"Legi", "Pahing", "Pon", "Wage", "Kliwon"};
TanggalMasehi tglMasehi;
TanggalHijriah tglHijriah;
TanggalJawa tglJawa;
JamDanMenit waktuMagrib;
/////////////////end1/////////////////////////////
//SETUP DMD
#define DISPLAYS_WIDE 2
#define DISPLAYS_HIGH 1
HJS589 dispDMD(DISPLAYS_WIDE, DISPLAYS_HIGH); // Jumlah Panel P10 yang digunakan (KOLOM,BARIS)
//WEB Server
ESP8266WebServer server(80);
const char* password = "123456";
const char* mySsid = "A2T TnT"; //kalau gagal konek
IPAddress local_ip(192, 168, 10, 1);
IPAddress gateway(192, 168, 10, 1);
IPAddress netmask(255, 255, 255, 0);
boolean turu = false;
int offSholat;
const char *fileconfigdisp = "/configdisp.json";
ConfigDisp configdisp;
const char *fileconfigjws = "/configjws.json";
ConfigJws configjws;
const char *fileconfiginfo = "/configinfo.json";
ConfigInfo configinfo;
const char *fileconfigwifi = "/configwifi.json";
ConfigWifi configwifi;
//----------------------------------------------------------------------
// XML UNTUK JEMBATAN DATA MESIN DENGAN WEB
void buildXML() {
RtcDateTime rtcNow = Rtc.GetDateTime();
RtcTemperature rtcTemp = Rtc.GetTemperature();
XML="<?xml version='1.0'?>";
XML+="<t>";
XML+="<rWifissid>";
XML+= configwifi.wifissid;
XML+="</rWifissid>";
XML+="<rYear>";
XML+=rtcNow.Year();
XML+="</rYear>";
XML+="<rMonth>";
XML+=rtcNow.Month();
XML+="</rMonth>";
XML+="<rDay>";
XML+=rtcNow.Day();
XML+="</rDay>";
XML+="<rHour>";
if(rtcNow.Hour()<10){
XML+="0";
XML+=rtcNow.Hour();
}else{ XML+=rtcNow.Hour();}
XML+="</rHour>";
XML+="<rMinute>";
if(rtcNow.Minute()<10){
XML+="0";
XML+=rtcNow.Minute();
}else{ XML+=rtcNow.Minute();}
XML+="</rMinute>";
XML+="<rSecond>";
if(rtcNow.Second()<10){
XML+="0";
XML+=rtcNow.Second();
}else{ XML+=rtcNow.Second();}
XML+="</rSecond>";
XML+="<rTemp>";
XML+= rtcTemp.AsFloatDegC();
XML+="</rTemp>";
XML+="<rAdzns>";
XML+= configjws.adzns;
XML+="</rAdzns>";
XML+="<rAdznd>";
XML+= configjws.adznd;
XML+="</rAdznd>";
XML+="<rAdzna>";
XML+= configjws.adzna;
XML+="</rAdzna>";
XML+="<rAdznm>";
XML+= configjws.adznm;
XML+="</rAdznm>";
XML+="<rAdzni>";
XML+= configjws.adzni;
XML+="</rAdzni>";
XML+="<rIqmhs>";
XML+= configjws.iqmhs;
XML+="</rIqmhs>";
XML+="<rIqmhd>";
XML+= configjws.iqmhd;
XML+="</rIqmhd>";
XML+="<rIqmha>";
XML+= configjws.iqmha;
XML+="</rIqmha>";
XML+="<rIqmhm>";
XML+= configjws.iqmhm;
XML+="</rIqmhm>";
XML+="<rIqmhi>";
XML+= configjws.iqmhi;
XML+="</rIqmhi>";
XML+="<rStbys>";
XML+= configjws.stbys;
XML+="</rStbys>";
XML+="<rStbyd>";
XML+= configjws.stbyd;
XML+="</rStbyd>";
XML+="<rStbya>";
XML+= configjws.stbya;
XML+="</rStbya>";
XML+="<rStbym>";
XML+= configjws.stbym;
XML+="</rStbym>";
XML+="<rStbyi>";
XML+= configjws.stbyi;
XML+="</rStbyi>";
XML+="<rStbyj>";
XML+= configjws.stbyj;
XML+="</rStbyj>";
XML+="<rIhti>";
XML+= configjws.ihti;
XML+="</rIhti>";
XML+="<rLatitude>";
XML+= configjws.latitude;
XML+="</rLatitude>";
XML+="<rLongitude>";
XML+= configjws.longitude;
XML+="</rLongitude>";
XML+="<rZonaWaktu>";
XML+= configjws.zonawaktu;
XML+="</rZonaWaktu>";
XML+="<rNama>";
XML+= configinfo.nama;
XML+="</rNama>";
XML+="<rInfoSholat>";
XML+= configinfo.infosholat;
XML+="</rInfoSholat>";
XML+="<rBlnMasehi1>";
XML+= configinfo.blnmasehi1;
XML+="</rBlnMasehi1>";
XML+="<rHari1>";
XML+= configinfo.hari1;
XML+="</rHari1>";
XML+="<rTglMasehiAwal1>";
XML+= configinfo.tglmasehiawal1;
XML+="</rTglMasehiAwal1>";
XML+="<rTglMasehiAkhir1>";
XML+= configinfo.tglmasehiakhir1;
XML+="</rTglMasehiAkhir1>";
XML+="<rBlnHijriyah1>";
XML+= configinfo.blnhijriyah1;
XML+="</rBlnHijriyah1>";
XML+="<rTglHijriyahAwal1>";
XML+= configinfo.tglhijriyahawal1;
XML+="</rTglHijriyahAwal1>";
XML+="<rTglHijriyahAkhir1>";
XML+= configinfo.tglhijriyahakhir1;
XML+="</rTglHijriyahAkhir1>";
XML+="<rJamAwal1>";
XML+= configinfo.jamawal1;
XML+="</rJamAwal1>";
XML+="<rJamAkhir1>";
XML+= configinfo.jamakhir1;
XML+="</rJamAkhir1>";
XML+="<rHuruf1>";
XML+= configinfo.huruf1;
XML+="</rHuruf1>";
XML+="<rInfo1>";
XML+= configinfo.info1;
XML+="</rInfo1>";
XML+="<rBlnMasehi2>";
XML+= configinfo.blnmasehi2;
XML+="</rBlnMasehi2>";
XML+="<rHari2>";
XML+= configinfo.hari2;
XML+="</rHari2>";
XML+="<rTglMasehiAwal2>";
XML+= configinfo.tglmasehiawal2;
XML+="</rTglMasehiAwal2>";
XML+="<rTglMasehiAkhir2>";
XML+= configinfo.tglmasehiakhir2;
XML+="</rTglMasehiAkhir2>";
XML+="<rBlnHijriyah2>";
XML+= configinfo.blnhijriyah2;
XML+="</rBlnHijriyah2>";
XML+="<rTglHijriyahAwal2>";
XML+= configinfo.tglhijriyahawal2;
XML+="</rTglHijriyahAwal2>";
XML+="<rTglHijriyahAkhir2>";
XML+= configinfo.tglhijriyahakhir2;
XML+="</rTglHijriyahAkhir2>";
XML+="<rJamAwal2>";
XML+= configinfo.jamawal2;
XML+="</rJamAwal2>";
XML+="<rJamAkhir2>";
XML+= configinfo.jamakhir2;
XML+="</rJamAkhir2>";
XML+="<rHuruf2>";
XML+= configinfo.huruf2;
XML+="</rHuruf2>";
XML+="<rInfo2>";
XML+= configinfo.info2;
XML+="</rInfo2>";
XML+="<rBlnMasehi3>";
XML+= configinfo.blnmasehi3;
XML+="</rBlnMasehi3>";
XML+="<rHari3>";
XML+= configinfo.hari3;
XML+="</rHari3>";
XML+="<rTglMasehiAwal3>";
XML+= configinfo.tglmasehiawal3;
XML+="</rTglMasehiAwal3>";
XML+="<rTglMasehiAkhir3>";
XML+= configinfo.tglmasehiakhir3;
XML+="</rTglMasehiAkhir3>";
XML+="<rBlnHijriyah3>";
XML+= configinfo.blnhijriyah3;
XML+="</rBlnHijriyah3>";
XML+="<rTglHijriyahAwal3>";
XML+= configinfo.tglhijriyahawal3;
XML+="</rTglHijriyahAwal3>";
XML+="<rTglHijriyahAkhir3>";
XML+= configinfo.tglhijriyahakhir3;
XML+="</rTglHijriyahAkhir3>";
XML+="<rJamAwal3>";
XML+= configinfo.jamawal3;
XML+="</rJamAwal3>";
XML+="<rJamAkhir3>";
XML+= configinfo.jamakhir3;
XML+="</rJamAkhir3>";
XML+="<rHuruf3>";
XML+= configinfo.huruf3;
XML+="</rHuruf3>";
XML+="<rInfo3>";
XML+= configinfo.info3;
XML+="</rInfo3>";
XML+="<rBlnMasehi4>";
XML+= configinfo.blnmasehi4;
XML+="</rBlnMasehi4>";
XML+="<rHari4>";
XML+= configinfo.hari4;
XML+="</rHari4>";
XML+="<rTglMasehiAwal4>";
XML+= configinfo.tglmasehiawal4;
XML+="</rTglMasehiAwal4>";
XML+="<rTglMasehiAkhir4>";
XML+= configinfo.tglmasehiakhir4;
XML+="</rTglMasehiAkhir4>";
XML+="<rBlnHijriyah4>";
XML+= configinfo.blnhijriyah4;
XML+="</rBlnHijriyah4>";
XML+="<rTglHijriyahAwal4>";
XML+= configinfo.tglhijriyahawal4;
XML+="</rTglHijriyahAwal4>";
XML+="<rTglHijriyahAkhir4>";
XML+= configinfo.tglhijriyahakhir4;
XML+="</rTglHijriyahAkhir4>";
XML+="<rJamAwal4>";
XML+= configinfo.jamawal4;
XML+="</rJamAwal4>";
XML+="<rJamAkhir4>";
XML+= configinfo.jamakhir4;
XML+="</rJamAkhir4>";
XML+="<rHuruf4>";
XML+= configinfo.huruf4;
XML+="</rHuruf4>";
XML+="<rInfo4>";
XML+= configinfo.info4;
XML+="</rInfo4>";
XML+="<rBlnMasehi5>";
XML+= configinfo.blnmasehi5;
XML+="</rBlnMasehi5>";
XML+="<rHari5>";
XML+= configinfo.hari5;
XML+="</rHari5>";
XML+="<rTglMasehiAwal5>";
XML+= configinfo.tglmasehiawal5;
XML+="</rTglMasehiAwal5>";
XML+="<rTglMasehiAkhir5>";
XML+= configinfo.tglmasehiakhir5;
XML+="</rTglMasehiAkhir5>";
XML+="<rBlnHijriyah5>";
XML+= configinfo.blnhijriyah5;
XML+="</rBlnHijriyah5>";
XML+="<rTglHijriyahAwal5>";
XML+= configinfo.tglhijriyahawal5;
XML+="</rTglHijriyahAwal5>";
XML+="<rTglHijriyahAkhir5>";
XML+= configinfo.tglhijriyahakhir5;
XML+="</rTglHijriyahAkhir5>";
XML+="<rJamAwal5>";
XML+= configinfo.jamawal5;
XML+="</rJamAwal5>";
XML+="<rJamAkhir5>";
XML+= configinfo.jamakhir5;
XML+="</rJamAkhir5>";
XML+="<rHuruf5>";
XML+= configinfo.huruf5;
XML+="</rHuruf5>";
XML+="<rInfo5>";
XML+= configinfo.info5;
XML+="</rInfo5>";
XML+="<rCerah>";
XML+= configdisp.cerah;
XML+="</rCerah>";
XML+="<rCepat>";
XML+= configdisp.cepat;
XML+="</rCepat>";
XML+="<rOnJam>";
XML+= configdisp.onjam;
XML+="</rOnJam>";
XML+="<rOnMenit>";
XML+= configdisp.onmenit;
XML+="</rOnMenit>";
XML+="<rOffJam>";
XML+= configdisp.offjam;
XML+="</rOffJam>";
XML+="<rOffMenit>";
XML+= configdisp.offmenit;
XML+="</rOffMenit>";
XML+="</t>";
}
void handleXML(){
buildXML();
server.send(200,"text/xml",XML);
}
//----------------------------------------------------------------------
// PENGATURAN WIFI AUTO MODE STATION ATAU ACCESS POINT
void wifiConnect() {
WiFi.softAPdisconnect(true);
WiFi.disconnect();
delay(1000);
Serial.println("Wifi Sation Mode");
WiFi.mode(WIFI_STA);
WiFi.begin(configwifi.wifissid,configwifi.wifipassword);
unsigned long startTime = millis();
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
digitalWrite(pin_led, !digitalRead(pin_led));
if (millis() - startTime > 10000) break;
}
if (WiFi.status() == WL_CONNECTED) {
digitalWrite(pin_led, HIGH);
} else {
Serial.println("Wifi AP Mode");
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(local_ip, gateway, netmask);
WiFi.softAP(mySsid, password);
digitalWrite(pin_led, LOW);
}
//Serial.println("");
WiFi.printDiag(Serial);
Serial.print("MAC: ");
Serial.println(WiFi.macAddress());
Serial.print("IP: ");
Serial.println(WiFi.localIP());
}
//----------------------------------------------------------------------
// HJS589 P10 FUNGSI TAMBAHAN UNTUK NODEMCU ESP8266
void ICACHE_RAM_ATTR refresh() {
dispDMD.refresh();
timer0_write(ESP.getCycleCount() + 80000);
}
void Disp_init() {
dispDMD.start();
noInterrupts();
timer0_isr_init();
timer0_attachInterrupt(refresh);
timer0_write(ESP.getCycleCount() + 80000);
interrupts();
dispDMD.clear();
}
//----------------------------------------------------------------------
// HJS589 P10 FUNGSI TAMBAHAN UNTUK NODEMCU ESP8266
void LoadDataAwal() {
////////// configjws
if (configjws.adzns == 0) {
configjws.adzns = 2;
}
if (configjws.adznd == 0) {
configjws.adznd = 2;
}
if (configjws.adzna == 0) {
configjws.adzna = 2;
}
if (configjws.adznm == 0) {
configjws.adznm = 2;
}
if (configjws.adzni == 0) {
configjws.adzni = 2;
}
if (configjws.iqmhs == 0) {
configjws.iqmhs = 3;
}
if (configjws.iqmhd == 0) {
configjws.iqmhd = 3;
}
if (configjws.iqmha == 0) {
configjws.iqmha = 3;
}
if (configjws.iqmhm == 0) {
configjws.iqmhm = 3;
}
if (configjws.iqmhi == 0) {
configjws.iqmhi = 3;
}
if (configjws.stbys == 0) {
configjws.stbys = 10;
}
if (configjws.stbyd == 0) {
configjws.stbyd = 15;
}
if (configjws.stbya == 0) {
configjws.stbya = 15;
}
if (configjws.stbym == 0) {
configjws.stbym = 10;
}
if (configjws.stbyi == 0) {
configjws.stbyi = 15;
}
if (configjws.stbyj == 0) {
configjws.stbyj = 30;
}
if (configjws.ihti == 0) {
configjws.ihti = 2;
}
if (configjws.latitude == 0) {
configjws.latitude = -7.2793;
}
if (configjws.longitude == 0) {
configjws.longitude = 112.7217;
}
if (configjws.zonawaktu == 0) {
configjws.zonawaktu = 7;
}
////////// configinfo
if (strlen(configinfo.nama) == 0) {
strlcpy(configinfo.nama, "Selamat datang di MASJID A2T AL-HIDAYAH", sizeof(configinfo.nama));
}
if (strlen(configinfo.infosholat) == 0) {
strlcpy(configinfo.infosholat, "TIBA WAKTU SHOLAT, DEMI KESEMPURNAAN SHOLAT SHAF LURUS DAN RAPATKAN, MATIKAN HP", sizeof(configinfo.infosholat));
}
if (configinfo.blnmasehi1 == 0) {
configinfo.blnmasehi1 = 0;
}
if (configinfo.hari1 == 0) {
configinfo.hari1 = 0;
}
if (configinfo.tglmasehiawal1 == 0) {
configinfo.tglmasehiawal1 = 0;
}
if (configinfo.tglmasehiakhir1 == 0) {
configinfo.tglmasehiakhir1 = 0;
}
if (configinfo.blnhijriyah1 == 0) {
configinfo.blnhijriyah1 = 0;
}
if (configinfo.tglhijriyahawal1 == 0) {
configinfo.tglhijriyahawal1 = 0;
}
if (configinfo.tglhijriyahakhir1 == 0) {
configinfo.tglhijriyahakhir1 = 0;
}
if (configinfo.jamawal1 == 0) {
configinfo.jamawal1 = 0;
}
if (configinfo.jamakhir1 == 0) {
configinfo.jamakhir1 = 0;
}
if (strlen(configinfo.huruf1) == 0) {
strlcpy(configinfo.huruf1, "Kecil", sizeof(configinfo.huruf1));
}
if (strlen(configinfo.info1) == 0) {
strlcpy(configinfo.info1, "http://a2ttravel.biz", sizeof(configinfo.info1));
}
if (configinfo.blnmasehi2 == 0) {
configinfo.blnmasehi2 = 0;
}
if (configinfo.hari2 == 0) {
configinfo.hari2 = 0;
}
if (configinfo.tglmasehiawal2 == 0) {
configinfo.tglmasehiawal2 = 0;
}
if (configinfo.tglmasehiakhir2 == 0) {
configinfo.tglmasehiakhir2 = 0;
}
if (configinfo.blnhijriyah2 == 0) {
configinfo.blnhijriyah2 = 0;
}
if (configinfo.tglhijriyahawal2 == 0) {
configinfo.tglhijriyahawal2 = 0;
}
if (configinfo.tglhijriyahakhir2 == 0) {
configinfo.tglhijriyahakhir2 = 0;
}
if (configinfo.jamawal2 == 0) {
configinfo.jamawal2 = 0;
}
if (configinfo.jamakhir2 == 0) {
configinfo.jamakhir2 = 0;
}
if (strlen(configinfo.huruf2) == 0) {
strlcpy(configinfo.huruf2, "Kecil", sizeof(configinfo.huruf2));
}
if (strlen(configinfo.info2) == 0) {
strlcpy(configinfo.info2, "http://tiketmurah.com", sizeof(configinfo.info2));
}
if (configinfo.blnmasehi3 == 0) {
configinfo.blnmasehi3 = 0;
}
if (configinfo.hari3 == 0) {
configinfo.hari3 = 0;
}
if (configinfo.tglmasehiawal3 == 0) {
configinfo.tglmasehiawal3 = 0;
}
if (configinfo.tglmasehiakhir3 == 0) {
configinfo.tglmasehiakhir3 = 0;
}
if (configinfo.blnhijriyah3 == 0) {
configinfo.blnhijriyah3 = 0;
}
if (configinfo.tglhijriyahawal3 == 0) {
configinfo.tglhijriyahawal3 = 0;
}
if (configinfo.tglhijriyahakhir3 == 0) {
configinfo.tglhijriyahakhir3 = 0;
}
if (configinfo.jamawal3 == 0) {
configinfo.jamawal3 = 0;
}
if (configinfo.jamakhir3 == 0) {
configinfo.jamakhir3 = 0;
}
if (strlen(configinfo.huruf3) == 0) {
strlcpy(configinfo.huruf3, "Kecil", sizeof(configinfo.huruf3));
}
if (strlen(configinfo.info3) == 0) {
strlcpy(configinfo.info3, "", sizeof(configinfo.info3));
}
if (configinfo.blnmasehi4 == 0) {
configinfo.blnmasehi4 = 0;
}
if (configinfo.hari4 == 0) {
configinfo.hari4 = 0;
}
if (configinfo.tglmasehiawal4 == 0) {
configinfo.tglmasehiawal4 = 0;
}
if (configinfo.tglmasehiakhir4 == 0) {
configinfo.tglmasehiakhir4 = 0;
}
if (configinfo.blnhijriyah4 == 0) {
configinfo.blnhijriyah4 = 0;
}
if (configinfo.tglhijriyahawal4 == 0) {
configinfo.tglhijriyahawal4 = 0;
}
if (configinfo.tglhijriyahakhir4 == 0) {
configinfo.tglhijriyahakhir4 = 0;
}
if (configinfo.jamawal4 == 0) {
configinfo.jamawal4 = 0;
}
if (configinfo.jamakhir4 == 0) {
configinfo.jamakhir4 = 0;
}
if (strlen(configinfo.huruf4) == 0) {
strlcpy(configinfo.huruf4, "Kecil", sizeof(configinfo.huruf4));
}
if (strlen(configinfo.info4) == 0) {
strlcpy(configinfo.info4, "", sizeof(configinfo.info4));
}
if (configinfo.blnmasehi5 == 0) {
configinfo.blnmasehi5 = 0;
}
if (configinfo.hari5 == 0) {
configinfo.hari5 = 0;
}
if (configinfo.tglmasehiawal5 == 0) {
configinfo.tglmasehiawal5 = 0;
}
if (configinfo.tglmasehiakhir5 == 0) {
configinfo.tglmasehiakhir5 = 0;
}
if (configinfo.blnhijriyah5 == 0) {
configinfo.blnhijriyah5 = 0;
}
if (configinfo.tglhijriyahawal5 == 0) {
configinfo.tglhijriyahawal5 = 0;
}
if (configinfo.tglhijriyahakhir5 == 0) {
configinfo.tglhijriyahakhir5 = 0;
}
if (configinfo.jamawal5 == 0) {
configinfo.jamawal5 = 0;
}
if (configinfo.jamakhir5 == 0) {
configinfo.jamakhir5 = 0;
}
if (strlen(configinfo.huruf5) == 0) {
strlcpy(configinfo.huruf5, "Kecil", sizeof(configinfo.huruf5));
}
if (strlen(configinfo.info5) == 0) {
strlcpy(configinfo.info5, "", sizeof(configinfo.info5));
}
////////// configwifi
if (strlen(configwifi.wifissid) == 0) {
strlcpy(configwifi.wifissid, "A2T CELL", sizeof(configwifi.wifissid));
}
if (strlen(configwifi.wifipassword) == 0) {
strlcpy(configwifi.wifipassword, "5980wxyz", sizeof(configwifi.wifipassword));
}
////////// configdisp
if (configdisp.cerah == 0) {
configdisp.cerah = 100;
}
if (configdisp.cepat == 0) {
configdisp.cepat = 91;
}
if (configdisp.onjam == 0) {
configdisp.onjam = 3;
}
if (configdisp.onmenit == 0) {
configdisp.onmenit = 30;
}
if (configdisp.offjam == 0) {
configdisp.offjam = 21;
}
if (configdisp.offmenit == 0) {
configdisp.offmenit = 0;
}
}
//----------------------------------------------------------------------
// SETUP
void setup() {
Serial.begin(9600);
//Buzzer
pinMode(buzzer, OUTPUT);
digitalWrite(buzzer, LOW);
delay(50);
//RTC D3231
int rtn = I2C_ClearBus(); // clear the I2C bus first before calling Wire.begin()
if (rtn != 0) {
Serial.println(F("I2C bus error. Could not clear"));
if (rtn == 1) {
Serial.println(F("SCL clock line held low"));
} else if (rtn == 2) {
Serial.println(F("SCL clock line held low by slave clock stretch"));
} else if (rtn == 3) {
Serial.println(F("SDA data line held low"));
}
} else { // bus clear, re-enable Wire, now can start Wire Arduino master
Wire.begin();
}
Rtc.Begin();
if (!Rtc.GetIsRunning()) {
Rtc.SetIsRunning(true);
}
Rtc.Enable32kHzPin(false);
Rtc.SetSquareWavePin(DS3231SquareWavePin_ModeNone);
Serial.println("Setup RTC selesai");
//WIFI
pinMode(pin_led, OUTPUT);
SPIFFS.begin();
loadWifiConfig(fileconfigwifi, configwifi);
loadJwsConfig(fileconfigjws, configjws);
loadInfoConfig(fileconfiginfo, configinfo);
loadDispConfig(fileconfigdisp, configdisp);
LoadDataAwal();
WiFi.hostname("A2T TnT");
WiFi.begin(configwifi.wifissid, configwifi.wifipassword);
wifiConnect();
server.on("/", []() {
server.send_P(200, "text/html", setwaktu);
// Kalau ada perubahan tanggal
if (server.hasArg("date")) {
uint16_t jam;
uint8_t menit;
uint8_t detik;
String sd=server.arg("date");
String lastSd;
jam = ((sd[0]-'0')*1000)+((sd[1]-'0')*100)+((sd[2]-'0')*10)+(sd[3]-'0');
menit = ((sd[5]-'0')*10)+(sd[6]-'0');
detik = ((sd[8]-'0')*10)+(sd[9]-'0');
if (sd != lastSd){
RtcDateTime rtcNow = Rtc.GetDateTime();
uint8_t hour = rtcNow.Hour();
uint8_t minute = rtcNow.Minute();
Rtc.SetDateTime(RtcDateTime(jam, menit, detik, hour, minute, 0));
lastSd=sd;
}
server.send ( 404 ,"text", message );
}
// Kalau ada perubahaan jam
if (server.hasArg("time")) {
String st=server.arg("time");
String lastSt;
uint8_t jam = ((st[0]-'0')*10)+(st[1]-'0');
uint8_t menit = ((st[3]-'0')*10)+(st[4]-'0');
if (st != lastSt){
RtcDateTime rtcNow = Rtc.GetDateTime();
uint16_t year = rtcNow.Year();
uint8_t month = rtcNow.Month();
uint8_t day = rtcNow.Day();
Rtc.SetDateTime(RtcDateTime(year, month, day, jam, menit, 0));
lastSt=st;}
server.send ( 404 ,"text", message );
}
});
server.on("/toggle", toggleLED);
server.on("/setwifi", []() {server.send_P(200, "text/html", setwifi);});
server.on("/settingwifi", HTTP_POST, handleSettingWifiUpdate);
server.on("/setjws", []() {server.send_P(200, "text/html", setjws);});
server.on("/settingjws", HTTP_POST, handleSettingJwsUpdate);
server.on("/setinfo", []() {server.send_P(200, "text/html", setinfo);});
server.on("/settinginfo", HTTP_POST, handleSettingInfoUpdate);
server.on("/setdisplay", []() {server.send_P(200, "text/html", setdisplay);});
server.on("/settingdisp", HTTP_POST, handleSettingDispUpdate);
server.on ( "/xml", handleXML) ;
server.begin();
Serial.println("HTTP server started");
//Buzzer
BuzzerPendek();
//DMD
Disp_init();
dispDMD.setBrightness(configdisp.cerah);
//SHOW IP
IpLocalShow();
// BRANDING
branding();
}
void loadDispConfig(const char *fileconfigdisp, ConfigDisp &configdisp) {
File configFileDisp = SPIFFS.open(fileconfigdisp, "r");
if (!configFileDisp) {
Serial.println("Gagal membuka file configdisp untuk dibaca");
return;
}
size_t size = configFileDisp.size();
std::unique_ptr<char[]> buf(new char[size]);
configFileDisp.readBytes(buf.get(), size);
DynamicJsonDocument doc(1024);
DeserializationError error = deserializeJson(doc, buf.get());
if (error) {
Serial.println("Gagal parse file configdisp");
return;
}
configdisp.cerah = doc["cerah"];
configdisp.cepat = doc["cepat"];
configdisp.onjam = doc["onjam"];
configdisp.onmenit = doc["onmenit"];
configdisp.offjam = doc["offjam"];
configdisp.offmenit = doc["offmenit"];
configFileDisp.close();
}
void handleSettingDispUpdate() {
timer0_detachInterrupt();
String datadisp = server.arg("plain");
DynamicJsonDocument doc(1024);
DeserializationError error = deserializeJson(doc, datadisp);
File configFileDisp = SPIFFS.open(fileconfigdisp, "w");
if (!configFileDisp) {
Serial.println("Gagal membuka Display configFile untuk ditulis");
return;
}
serializeJson(doc, configFileDisp);
if (error) {
Serial.print(F("deserializeJson() gagal kode sebagai berikut: "));
Serial.println(error.c_str());
return;
} else {
configFileDisp.close();
Serial.println("Berhasil mengubah configFileDisp");
server.send(200, "application/json", "{\"status\":\"ok\"}");
loadDispConfig(fileconfigdisp, configdisp);
delay(500);
Disp_init();
dispDMD.setBrightness(configdisp.cerah);
}
}
void loadJwsConfig(const char *fileconfigjws, ConfigJws &configjws) {
File configFileJws = SPIFFS.open(fileconfigjws, "r");
if (!configFileJws) {
Serial.println("Gagal membuka file configjws untuk dibaca");
return;
}
size_t size = configFileJws.size();
std::unique_ptr<char[]> buf(new char[size]);
configFileJws.readBytes(buf.get(), size);
DynamicJsonDocument doc(1024);
DeserializationError error = deserializeJson(doc, buf.get());
if (error) {
Serial.println("Gagal parse fileconfigjws");
return;
}
configjws.adzns = doc["adzns"];
configjws.adznd = doc["adznd"];
configjws.adzna = doc["adzna"];
configjws.adznm = doc["adznm"];
configjws.adzni = doc["adzni"];
configjws.iqmhs = doc["iqmhs"];
configjws.iqmhd = doc["iqmhd"];
configjws.iqmha = doc["iqmha"];
configjws.iqmhm = doc["iqmhm"];
configjws.iqmhi = doc["iqmhi"];
configjws.stbys = doc["stbys"];
configjws.stbyd = doc["stbyd"];
configjws.stbya = doc["stbya"];
configjws.stbym = doc["stbym"];
configjws.stbyi = doc["stbyi"];
configjws.stbyj = doc["stbyj"];
configjws.ihti = doc["ihti"];
configjws.latitude = doc["latitude"];
configjws.longitude = doc["longitude"];
configjws.zonawaktu = doc["zonawaktu"];
configFileJws.close();
}
void handleSettingJwsUpdate() {
timer0_detachInterrupt();
String datajws = server.arg("plain");
DynamicJsonDocument doc(1024);
DeserializationError error = deserializeJson(doc, datajws);
File configFileJws = SPIFFS.open(fileconfigjws, "w");
if (!configFileJws) {
Serial.println("Gagal membuka JWS configFile untuk ditulis");
return;
}
serializeJson(doc, configFileJws);
if (error) {
Serial.print(F("deserializeJson() gagal kode sebagai berikut: "));
Serial.println(error.c_str());
return;
} else {
configFileJws.close();
Serial.println("Berhasil mengubah configFileJws");
server.send(200, "application/json", "{\"status\":\"ok\"}");
loadJwsConfig(fileconfigjws, configjws);
delay(500);
Disp_init();
}
}
void loadInfoConfig(const char *fileconfiginfo, ConfigInfo &configinfo) {
File configFileInfo = SPIFFS.open(fileconfiginfo, "r");
if (!configFileInfo) {
Serial.println("Gagal membuka fileconfiginfo untuk dibaca");
return;
}
size_t size = configFileInfo.size();
std::unique_ptr<char[]> buf(new char[size]);
configFileInfo.readBytes(buf.get(), size);
DynamicJsonDocument doc(4096);
DeserializationError error = deserializeJson(doc, buf.get());
if (error) {
Serial.println("Gagal parse fileconfiginfo");
return;
}
strlcpy(configinfo.nama, doc["nama"] | "Selamat datang di MASJID A2T AL-HIDAYAH", sizeof(configinfo.nama)); // Set awal Nama
strlcpy(configinfo.infosholat, doc["infosholat"] | "TIBA WAKTU SHOLAT, DEMI KESEMPURNAAN SHOLAT SHAF LURUS DAN RAPATKAN, MATIKAN HP", sizeof(configinfo.infosholat)); // Set awal InfoSholat
configinfo.blnmasehi1 = doc["blnmasehi1"];
configinfo.hari1 = doc["hari1"];
configinfo.tglmasehiawal1 = doc["tglmasehiawal1"];
configinfo.tglmasehiakhir1 = doc["tglmasehiakhir1"];
configinfo.blnhijriyah1 = doc["blnhijriyah1"];
configinfo.tglhijriyahawal1 = doc["tglhijriyahawal1"];
configinfo.tglhijriyahakhir1 = doc["tglhijriyahakhir1"];
configinfo.jamawal1 = doc["jamawal1"];
configinfo.jamakhir1 = doc["jamakhir1"];
strlcpy(configinfo.huruf1, doc["huruf1"] | "Kecil", sizeof(configinfo.huruf1));
strlcpy(configinfo.info1, doc["info1"] | "http://a2ttravel.biz", sizeof(configinfo.info1)); // Set awal Info1
configinfo.blnmasehi2 = doc["blnmasehi2"];
configinfo.hari2 = doc["hari2"];
configinfo.tglmasehiawal2 = doc["tglmasehiawal2"];
configinfo.tglmasehiakhir2 = doc["tglmasehiakhir2"];
configinfo.blnhijriyah2 = doc["blnhijriyah2"];
configinfo.tglhijriyahawal2 = doc["tglhijriyahawal2"];
configinfo.tglhijriyahakhir2 = doc["tglhijriyahakhir2"];
configinfo.jamawal2 = doc["jamawal2"];
configinfo.jamakhir2 = doc["jamakhir2"];
strlcpy(configinfo.huruf2, doc["huruf2"] | "Kecil", sizeof(configinfo.huruf2));
strlcpy(configinfo.info2, doc["info2"] | "http://tiketmurah.com", sizeof(configinfo.info2)); // Set awal Info2
configinfo.blnmasehi3 = doc["blnmasehi3"];
configinfo.hari3 = doc["hari3"];
configinfo.tglmasehiawal3 = doc["tglmasehiawal3"];
configinfo.tglmasehiakhir3 = doc["tglmasehiakhir3"];
configinfo.blnhijriyah3 = doc["blnhijriyah3"];
configinfo.tglhijriyahawal3 = doc["tglhijriyahawal3"];
configinfo.tglhijriyahakhir3 = doc["tglhijriyahakhir3"];
configinfo.jamawal3 = doc["jamawal3"];
configinfo.jamakhir3 = doc["jamakhir3"];
strlcpy(configinfo.huruf3, doc["huruf3"] | "Kecil", sizeof(configinfo.huruf3));
strlcpy(configinfo.info3, doc["info3"] | "", sizeof(configinfo.info3)); // Set awal Info3
configinfo.blnmasehi4 = doc["blnmasehi4"];
configinfo.hari4 = doc["hari4"];
configinfo.tglmasehiawal4 = doc["tglmasehiawal4"];
configinfo.tglmasehiakhir4 = doc["tglmasehiakhir4"];
configinfo.blnhijriyah4 = doc["blnhijriyah4"];
configinfo.tglhijriyahawal4 = doc["tglhijriyahawal4"];
configinfo.tglhijriyahakhir4 = doc["tglhijriyahakhir4"];
configinfo.jamawal4 = doc["jamawal4"];
configinfo.jamakhir4 = doc["jamakhir4"];
strlcpy(configinfo.huruf4, doc["huruf4"] | "Kecil", sizeof(configinfo.huruf4));
strlcpy(configinfo.info4, doc["info4"] | "", sizeof(configinfo.info4)); // Set awal Info4
configinfo.blnmasehi5 = doc["blnmasehi5"];
configinfo.hari5 = doc["hari5"];
configinfo.tglmasehiawal5 = doc["tglmasehiawal5"];
configinfo.tglmasehiakhir5 = doc["tglmasehiakhir5"];
configinfo.blnhijriyah5 = doc["blnhijriyah5"];
configinfo.tglhijriyahawal5 = doc["tglhijriyahawal5"];
configinfo.tglhijriyahakhir5 = doc["tglhijriyahakhir5"];
configinfo.jamawal5 = doc["jamawal5"];
configinfo.jamakhir5 = doc["jamakhir5"];
strlcpy(configinfo.huruf5, doc["huruf5"] | "Kecil", sizeof(configinfo.huruf5));
strlcpy(configinfo.info5, doc["info5"] | "", sizeof(configinfo.info5)); // Set awal Info5
configFileInfo.close();
}
void handleSettingInfoUpdate() {
timer0_detachInterrupt();
String datainfo = server.arg("plain");
DynamicJsonDocument doc(4096);
DeserializationError error = deserializeJson(doc, datainfo);
File configFileInfo = SPIFFS.open(fileconfiginfo, "w");
if (!configFileInfo) {
Serial.println("Gagal membuka Info config File untuk ditulis");
return;
}
serializeJson(doc, configFileInfo);
if (error) {
Serial.print(F("deserializeJson() gagal kode sebagai berikut: "));
Serial.println(error.c_str());
return;
} else {
configFileInfo.close();
Serial.println("Berhasil mengubah configFileInfo");
server.send(200, "application/json", "{\"status\":\"ok\"}");
loadInfoConfig(fileconfiginfo, configinfo);
delay(500);
Disp_init();
}
}
void loadWifiConfig(const char *fileconfigwifi, ConfigWifi &configwifi) {
File configFileWifi = SPIFFS.open(fileconfigwifi, "r");
if (!configFileWifi) {
Serial.println("Gagal membuka file configwifi untuk dibaca");
return;
}
size_t size = configFileWifi.size();
std::unique_ptr<char[]> buf(new char[size]);
configFileWifi.readBytes(buf.get(), size);
DynamicJsonDocument doc(1024);
DeserializationError error = deserializeJson(doc, buf.get());
if (error) {
Serial.println("Gagal untuk parse config file");
return;
}
strlcpy(configwifi.wifissid, doc["wifissid"] | "A2T CELL", sizeof(configwifi.wifissid));
strlcpy(configwifi.wifipassword, doc["wifipassword"] | "5980wxyz", sizeof(configwifi.wifipassword));
configFileWifi.close();
}
void handleSettingWifiUpdate() {
timer0_detachInterrupt();
String data = server.arg("plain");
DynamicJsonDocument doc(1024);
DeserializationError error = deserializeJson(doc, data);
File configFile = SPIFFS.open("/configwifi.json", "w");
if (!configFile) {
Serial.println("Error opening Wifi configFile for writing");
return;
}
serializeJson(doc, configFile);
if (error) {
Serial.print(F("deserializeJson() gagal kode sebagai berikut: "));
Serial.println(error.c_str());
return;
} else {
configFile.close();
Serial.println("Berhasil mengubah configFileWifi");
server.send(200, "application/json", "{\"status\":\"ok\"}");
loadWifiConfig(fileconfigwifi, configwifi);
delay(500);
Disp_init();
}
}
//----------------------------------------------------------------------
// LOOP
void loop() {
server.handleClient();
tampilan();
}
//----------------------------------------------------------------------
//MODE TAMPILAN JAM
uint8_t tampilanjam;
void tampilan() {
if (tampilanjam > 4) {
tampilanjam = 0;
}
switch(tampilanjam) {
case 0 :
Istirahat();
TeksJalanNama();
AlarmSholat();
break;
case 1 :
Istirahat();
TampilTanggal();
AlarmSholat();
break;
case 2 :
Istirahat();
JamJatuhPulse(0);
TampilJadwal();
AlarmSholat();
break;
case 3 :
Istirahat();
InfoShow();
//TeksJalanInfo1();
AlarmSholat();
break;
case 4:
Istirahat();
break;
}
}
//----------------------------------------------------------------------
//MODE TAMPILAN JAM
void JamJatuhPulse(int x) {
RtcDateTime rtcNow = Rtc.GetDateTime();
char jam[3];
char menit[3];
char detik[3];
sprintf(jam,"%02d", rtcNow.Hour());
sprintf(menit,"%02d", rtcNow.Minute());
sprintf(detik,"%02d", rtcNow.Second());
static boolean huruf;
static uint8_t y,i;
static uint8_t d,d2;
static uint32_t pM, pMAnimasi;
uint32_t cM = millis();
static uint32_t pMDetik;
static uint8_t pulse;
String dt;
if (turu == false) {
if(cM - pM > 35) {
if(d == 0 and y < 20) {
pM=cM;
y++;
}
if(d == 1 and y > 0) {
pM=cM;
y--;
}
}
if(cM - pM > 25800 and y == 20) {
d=1;
}
if(y == 0 and d == 1) {
d=0;
}
//JAM
dispDMD.setFont(myNumber6x16);
dispDMD.drawText(0, y - 20, jam);
dispDMD.setFont(SystemFont5x7);
dispDMD.drawText(18,0 + y - 20,menit);
dispDMD.drawText(18,8 + y - 20,detik);
int h = detik[1] % 2;
if (h == 0) {
dispDMD.drawCircle( 15, y - 20 + 4, 1, 1 );
dispDMD.drawCircle( 15, y - 20 + 10, 1, 1 );
} else {
dispDMD.drawCircle( 15, y - 20 + 4, 1, 0 );
dispDMD.drawCircle( 15, y - 20 + 10, 1, 0 );
}
if (y < 20){
dispDMD.drawCircle( 15, y - 20 + 4, 1, 0 );
dispDMD.drawCircle( 15, y - 20 + 10, 1, 0 );
}
dispDMD.drawRect(0, y - 5 , 31, 16, 0, 0);
}
}
void JamJatuhPulse2(int x) {
RtcDateTime rtcNow = Rtc.GetDateTime();
char jam[3];
char menit[3];
char detik[3];
sprintf(jam,"%02d", rtcNow.Hour());
sprintf(menit,"%02d", rtcNow.Minute());
sprintf(detik,"%02d", rtcNow.Second());
static boolean huruf;
static uint8_t y,i;
static uint8_t d;
static uint32_t pM;
uint32_t cM = millis();
static uint32_t pMPulse, dM;
static uint8_t pulse;
String dt;
if (cM - pMPulse >= 100) {
pMPulse = cM;
pulse++;
}
if (pulse > 8) {
pulse=0;
}
if(cM - pM > 35) {
if(d == 0 and y < 20) {
pM=cM;
y++;
}
if(d == 1 and y > 0) {
pM=cM;
y--;
}
}
if(cM - pM > 10000 and y == 20) {
d=1;
}
if(y == 20) {
dispDMD.drawRect(x+14,3+pulse,x+17,11-pulse,0,1);
}
if(y < 20) {
dispDMD.drawRect(x+14,3,x+18,17,0,0);
}
if(y == 0 and d == 1) {
d=0;
huruf = !huruf;
}
//JAM
if (huruf) {
dispDMD.setFont(ElektronMart6x16);
} else {
dispDMD.setFont(ElektronMartArabic6x16);
}
dispDMD.drawText(x+1, y - 20, jam);
//MENIT
if (huruf) {
dispDMD.setFont(ElektronMart6x16);
} else {
dispDMD.setFont(ElektronMartArabic6x16);
}
dispDMD.drawText(x+18, y - 20, menit);
}
/////// Jam Kecil/////////
void TampilJamKecil(uint32_t hbs) {
char jam[3];
char menit[3];
char detik[3];
static uint32_t pM;
static uint32_t pMJam, pMAnimasi, pMDetik;
uint32_t cM = millis();
static uint8_t y,s,s1,i;
char detikx[3];
RtcDateTime rtcNow = Rtc.GetDateTime();
if ((cM - pM) > 50) {
if (s == 0 and y < 12) {
pM = cM; y++;
}
if (s == 1 and y > 0) {
pM = cM; y--;
}
}
if ((cM - pMJam) > hbs and y == 12 ){
pMJam = cM; s = 1;
}
if (y == 0 and s == 1) {
s = 0;
}
//JAM
//sprintf(jam,"%02d:%02d:%02d", rtcNow.Hour(), rtcNow.Minute(), rtcNow.Second());
sprintf(jam,"%02d", rtcNow.Hour());
sprintf(menit,"%02d", rtcNow.Minute());
sprintf(detik,"%02d", rtcNow.Second());
dispDMD.setFont(SystemFont5x7);
//textCenter(y - 12, jam);
dispDMD.drawText(11, y - 12, jam);
dispDMD.drawText(26, y - 12, menit);
dispDMD.drawText(41, y - 12, detik);
dispDMD.drawRect(23, 0 + y - 12, 24, 0 + y - 12, 0, 0);
dispDMD.drawRect(23, 1 + y - 12, 24, 2 + y - 12, 1, 1);
dispDMD.drawRect(23, 3 + y - 12, 24, 3 + y - 12, 0, 0);
dispDMD.drawRect(23, 4 + y - 12, 24, 5 + y - 12, 1, 1);
dispDMD.drawRect(23, 6 + y - 12, 24, 6 + y - 12, 0, 0);
dispDMD.drawRect(38, 0 + y - 12, 39, 0 + y - 12, 0, 0);
dispDMD.drawRect(38, 1 + y - 12, 39, 2 + y - 12, 1, 1);
dispDMD.drawRect(38, 3 + y - 12, 39, 3 + y - 12, 0, 0);
dispDMD.drawRect(38, 4 + y - 12, 39, 5 + y - 12, 1, 1);
dispDMD.drawRect(38, 6 + y - 12, 39, 6 + y - 12, 0, 0);
dispDMD.drawRect(0, y - 5, 64, 7, 0, 0);
/*
if ((cM - pMAnimasi) > 50) {
if (s1 == 0 and i < 8) {
pMAnimasi = cM; i++;
}
if (s1 == 1 and i > 0) {
pMAnimasi = cM; i=0;
}
}
if ((cM - pMDetik) > 1000 and i == 8 ){
pMDetik = cM; s1 = 1;
}
if (i == 0 and s1 == 1) {
s1 = 0;
}
dispDMD.drawChar(56,-8 + i + y - 12, detik[1]);
*/ /*
}
uint8_t tampilanjadwal;
void TampilJadwal() {
if (tampilanjadwal > 1) {
tampilanjadwal = 0;
}
switch(tampilanjadwal) {
case 0 :
Istirahat();
TampilSuhu();
AlarmSholat();
break;
case 1 :
Istirahat();
TampilJadwalSholat();
AlarmSholat();
break;
}
}
//-------------------------------------------------------
// Tampilkan Tanggal
void TampilTanggal() {
static uint32_t pM;
static uint32_t x;
static uint32_t Speed;
int width = dispDMD.width();
dispDMD.setFont(SystemFont5x7);
char Kalender[60];
RtcDateTime rtcNow = Rtc.GetDateTime();
if (turu == false) {
Speed = 505 - (configdisp.cepat * 5);
////////////////////
///ambil waktu magrib
int hours, minutes;
get_float_time_parts(waktuJWS[5], hours, minutes);
minutes = minutes + configjws.ihti;
if (minutes >= 60) {
minutes = minutes - 60;
hours ++;
}
waktuMagrib = {hours, minutes};
uint32_t jumlahHari;
double jumlahHariMatahari;
tglMasehi.jam = rtcNow.Hour();
tglMasehi.menit = rtcNow.Minute();
tglMasehi.detik = rtcNow.Second();
tglMasehi.tanggal = rtcNow.Day();
tglMasehi.bulan = rtcNow.Month();
if (rtcNow.Year() > 2000) {
tglMasehi.tahun = rtcNow.Year()-2000;
} else {
tglMasehi.tahun = rtcNow.Year()-1900;
}
// tglMasehi.hari = hariDariTanggal(tglMasehi);
MasehiToHijriah(tglMasehi, waktuMagrib, tambahKurangHijriah, tglHijriah, tglJawa);
// printKonversi(tglMasehi, tglHijriah, tglJawa);
char KalenderMasehi[30];
char KalenderHijriah[30];
sprintf(KalenderMasehi,"%s %s, %02d %s %04d", dinoInWulan[rtcNow.DayOfWeek()], namaHariPasaran[tglJawa.pasaran], rtcNow.Day(), wulanInMasehi[rtcNow.Month()-1], rtcNow.Year());
sprintf(KalenderHijriah,"%02d %s %04d H", tglHijriah.tanggal, wulanInHijriah[tglHijriah.bulan-1], tglHijriah.tahun);
///////////////////
sprintf(Kalender,"%s, %s", KalenderMasehi, KalenderHijriah);
//int fullScroll = dispDMD.textWidth(Kalender) + width;
uint32_t fullScroll = dispDMD.textWidth(Kalender) + width;
if((millis() - pM) > Speed) {
pM = millis();
if (x < fullScroll) {
++x;
} else {
dispDMD.clear();
x = 0;
++tampilanjam;
return;
}
dispDMD.drawText(width - x, 9, Kalender);
}
TampilJamKecil(fullScroll * Speed);
}
}
/////////////////////////////start2//////////////////////////////
double get_julian_date(TanggalHijriah tanggal) {
if (tanggal.bulan <= 2)
{
tanggal.tahun -= 1;
tanggal.bulan += 12;
}
double a = floor(tanggal.tahun / 100.0);
double b = 2 - a + floor(a / 4.0);
if (tanggal.tahun < 1583)
b = 0;
if (tanggal.tahun == 1582) {
if (tanggal.bulan > 10)
b = -10;
if (tanggal.bulan == 10) {
b = 0;
if (tanggal.tanggal > 4)
b = -10;
}
}
return floor(365.25 * (tanggal.tahun + 4716)) + floor(30.6001 * (tanggal.bulan + 1)) + tanggal.tanggal + b - 1524.5;
}
double HijriahToJulian(uint16_t tahun, uint8_t bulan, uint8_t tanggal) {
return (epochHijriah + tanggal + ceil(29.5 * (bulan - 1)) + (354L * (tahun - 1)) + floor((3 + (11 * tahun)) / 30)) - 1;
}
void MasehiToHijriah(TanggalMasehi masehi, JamDanMenit waktuSholatMagrib, int8_t koreksiHijriah, TanggalHijriah &hijriah, TanggalJawa &jawa) {
uint16_t sisaHari;
double julianDate = get_julian_date({masehi.tanggal, masehi.bulan, masehi.tahun + 2000});
uint16_t menitMagrib = waktuSholatMagrib.jam * 60 + waktuSholatMagrib.menit;
uint16_t menitSekarang = masehi.jam * 60 + masehi.menit;
if (menitSekarang >= menitMagrib)
{
julianDate++;//Pergantian hari hijrah pada magrib
}
julianDate = floor(julianDate) + 0.5;
TanggalHijriah tglHijriah;
hijriah.tahun = floor(((30 * (julianDate - epochHijriah)) + 10646) / 10631);
hijriah.bulan = min(12.0, ceil((julianDate - (29 + HijriahToJulian(hijriah.tahun, 1, 1))) / 29.5) + 1);
hijriah.tanggal = (julianDate - HijriahToJulian(hijriah.tahun, hijriah.bulan, 1)) + 1;
long julianLong = (long)julianDate;
jawa.pasaran = ((julianLong + 1) % 5); //0 = legi
jawa.wuku = (((julianLong + 65) % 210) / 7); //0 = Shinta
jawa.tanggal = hijriah.tanggal;
jawa.bulan = hijriah.bulan;
jawa.tahun = hijriah.tahun + 512;
}
uint8_t hariDariTanggal(TanggalMasehi tanggalDanWaktu) {
uint16_t jumlahHari = tanggalDanWaktu.tanggal;
for (uint8_t i = 1; i < tanggalDanWaktu.bulan; ++i)
jumlahHari += jumlahHariPerBulan[i-1];
if (tanggalDanWaktu.bulan > 2 && tanggalDanWaktu.tahun % 4 == 0)
++jumlahHari;
jumlahHari += (365 * tanggalDanWaktu.tahun) + ((tanggalDanWaktu.tahun + 3) / 4) - 1;
return ((jumlahHari + 6) % 7) + 1; // 1 Januari 2000 hari sabtu = 7
}
//----------------------------------------------------------------------
// TAMPILKAN SUHU
void TampilSuhu() {
RtcTemperature temp = Rtc.GetTemperature();
int celsius = temp.AsFloatDegC();
char suhu[2];
int koreksisuhu = 2; // Perkiraan selisih suhu ruangan dan luar ruangan
static uint8_t d,s,y;
static uint32_t pM;
uint32_t cM = millis();
if (turu == false) {
if ((cM - pM) > 50) {
if (s == 0 and y < 8) {
pM = cM;
y++;
}
if (s == 1 and y > 0) {
pM = cM;
y--;
}
}
if ((cM - pM) > 3000 and y == 8) {
s = 1;
}
if (y == 0 and s == 1) {
s = 0; d++;
}
dispDMD.setFont(SystemFont5x7);
textCenter1PKanan(y - 8, "SUHU");
sprintf(suhu,"%d*C",celsius - koreksisuhu);
textCenter1PKanan(16 - y, suhu);
dispDMD.drawRect(32, y - 1, 64, 15 - y, 0, 0);
if (d >= 1) {
d = 0; y = 0;
++tampilanjadwal;
}
}
}
/////////// Ketentuan Jadwal Sholat //////////
void KetentuanJWS(const RtcDateTime& now) {
set_calc_method(ISNA);
set_asr_method(Shafii);
set_high_lats_adjust_method(AngleBased);
set_fajr_angle(20);
set_isha_angle(18);
get_prayer_times(now.Year(), now.Month(), now.Day(), configjws.latitude, configjws.longitude, configjws.zonawaktu, waktuJWS);
}
//----------------------------------------------------------------------
// TAMPILAN JADWAL SHOLAT
void TampilJadwalSholat() {
static uint8_t i,s,y;
static uint32_t pM;
uint32_t cM = millis();
char sholat[8];
String namaSholat;
char jam[5];
char TimeName[][6] = {"SUBUH","TRBIT","DUHUR","ASHAR","TRBNM","MGRIB","ISYA'"};
int hours, minutes;
RtcDateTime rtcNow = Rtc.GetDateTime();
if (turu == false) {
KetentuanJWS(rtcNow);
if ((cM - pM) > 50) {
if (s == 0 and y < 8) {
pM = cM;
y++;
}
if (s == 1 and y > 0) {
pM = cM;
y--;
}
}
if ((cM - pM) > 3000 and y == 8) {
s = 1;
}
if (y == 0 and s == 1) {
s = 0; i++;
}
//if (i == 2) { i = 3; }
if (i == 5) { i = 6; }
if (i == 0) {
get_float_time_parts(waktuJWS[0], hours, minutes);
minutes = minutes + configjws.ihti;
minutes = minutes - 10 ;
if (minutes < 0) {
minutes = minutes + 60;
hours --;
}
namaSholat = "IMSAK";
}
if (i >= 1 and i <= 7) {
get_float_time_parts(waktuJWS[i-1], hours, minutes);
namaSholat = TimeName[i-1];
minutes = minutes + configjws.ihti;
if (minutes >= 60) {
minutes = minutes - 60;
hours ++;
}
}
if (i >= 0 and i <=7) {
sprintf(jam,"%02d:%02d", hours, minutes);
dispDMD.setFont(SystemFont5x7);
textCenter1PKanan(y - 8, namaSholat);
textCenter1PKanan(16 - y, jam);
dispDMD.drawRect(32, y - 1, 64, 15 - y, 0, 0);
}
if (i > 7) {
dispDMD.clear();
i = 0; y = 0;
++tampilanjadwal;
dispDMD.clear();
++tampilanjam;
}
}
}
//----------------------------------------------------------------------
// ALARM SHOLAT BERJALAN SAAT MASUK WAKTU SHOLAT
void AlarmSholat() {
RtcDateTime rtcNow = Rtc.GetDateTime();
int Hari = rtcNow.DayOfWeek();
int Hor = rtcNow.Hour();
int Min = rtcNow.Minute();
int Sec = rtcNow.Second();
int adzans = configjws.adzns * 60;
int adzand = configjws.adznd * 60;
int adzana = configjws.adzna * 60;
int adzanm = configjws.adznm * 60;
int adzani = configjws.adzni * 60;
int adzanimsak = 120;
int tadzan;
if (turu == false) {
KetentuanJWS(rtcNow);
int hours, minutes, seconds;
// Tanbih Imsak
get_float_time_parts(waktuJWS[0], hours, minutes);
minutes = minutes + configjws.ihti;
if (minutes < 10) {
minutes = 60 - minutes;
hours --;
} else {
minutes = minutes - 10 ;
}
if (Hor == hours && Min == minutes) {
BuzzerPendek();
dispDMD.clear();
for ( tadzan = 0; tadzan < adzanimsak; tadzan++ )
{
delay(1000);
dispDMD.setFont(SystemFont5x7);
textCenter(0, "TANBIH");
textCenter(8, "IMSAK");
delay(1000);
dispDMD.clear();
}
}
// Subuh
get_float_time_parts(waktuJWS[0], hours, minutes);
minutes = minutes + configjws.ihti;
if (minutes >= 60) {
minutes = minutes - 60;
hours ++;
}
if (Hor == hours && Min == minutes) {
BuzzerPendek();
dispDMD.clear();
for ( tadzan = 0; tadzan < adzans; tadzan++ )
{
delay(1000);
dispDMD.setFont(SystemFont5x7);
textCenter(0, "ADZAN");
textCenter(8, "SUBUH");
delay(1000);
dispDMD.clear();
}
iqmh = configjws.iqmhs;
menitiqmh = iqmh - 1;
minStanby = configjws.stbys;
Iqomah(menitiqmh);
return;
}
// Dzuhur
get_float_time_parts(waktuJWS[2], hours, minutes);
minutes = minutes + configjws.ihti;
if (minutes >= 60) {
minutes = minutes - 60;
hours ++;
}
if (Hor == hours && Min == minutes && Hari != 5) {
BuzzerPendek();
dispDMD.clear();
for ( tadzan = 0; tadzan < adzand; tadzan++ )
{
delay(1000);
dispDMD.setFont(SystemFont5x7);
textCenter(0, "ADZAN");
textCenter(8, "DHUHUR");
delay(1000);
dispDMD.clear();
}
iqmh = configjws.iqmhd;
menitiqmh = iqmh - 1;
minStanby = configjws.stbyd;
Iqomah(menitiqmh);
return;
} else if (Hor == hours && Min == minutes && Hari == 5) {
BuzzerPendek();
dispDMD.clear();
for ( tadzan = 0; tadzan < adzand; tadzan++ )
{
delay(1000);
dispDMD.setFont(SystemFont5x7);
textCenter(0, "ADZAN");
textCenter(8, "JUM'AT");
delay(1000);
dispDMD.clear();
}
minStanby = configjws.stbyj;
Iqomah(0);
return;
}
// Ashar
get_float_time_parts(waktuJWS[3], hours, minutes);
minutes = minutes + configjws.ihti;
if (minutes >= 60) {
minutes = minutes - 60;
hours ++;
}
if (Hor == hours && Min == minutes) {
BuzzerPendek();
dispDMD.clear();
for ( tadzan = 0; tadzan < adzana; tadzan++ )
{
delay(1000);
dispDMD.setFont(SystemFont5x7);
textCenter(0, "ADZAN");
textCenter(8, "ASHAR");
delay(1000);
dispDMD.clear();
}
iqmh = configjws.iqmha;
menitiqmh = iqmh - 1;
minStanby = configjws.stbya;
Iqomah(menitiqmh);
return;
}
// Maghrib
get_float_time_parts(waktuJWS[5], hours, minutes);
minutes = minutes + configjws.ihti;
if (minutes >= 60) {
minutes = minutes - 60;
hours ++;
}
if (Hor == hours && Min == minutes) {
BuzzerPendek();
dispDMD.clear();
for ( tadzan = 0; tadzan < adzanm; tadzan++ )
{
delay(1000);
dispDMD.setFont(SystemFont5x7);
textCenter(0, "ADZAN");
textCenter(8, "MAGHRIB");
delay(1000);
dispDMD.clear();
}
iqmh = configjws.iqmhm;
menitiqmh = iqmh - 1;
minStanby = configjws.stbym;
Iqomah(menitiqmh);
return;
}
// Isya'
get_float_time_parts(waktuJWS[6], hours, minutes);
minutes = minutes + configjws.ihti;
if (minutes >= 60) {
minutes = minutes - 60;
hours ++;
}
if (Hor == hours && Min == minutes) {
BuzzerPendek();
dispDMD.clear();
for ( tadzan = 0; tadzan < adzani; tadzan++ )
{
delay(1000);
dispDMD.setFont(SystemFont5x7);
textCenter(0, "ADZAN");
textCenter(8, "ISYA'");
delay(1000);
dispDMD.clear();
}
iqmh = configjws.iqmhi;
menitiqmh = iqmh - 1;
minStanby = configjws.stbyi;
Iqomah(menitiqmh);
return;
}
}
}
void Iqomah(int menitIqmh) {
static uint32_t pMIqmh;
uint32_t cM = millis();
static char hitungmundur[6];
dispDMD.clear();
dispDMD.setFont(SystemFont5x7);
textCenter(0, "IQOMAH");
for (detikiqmh == 60; detikiqmh >=0; detikiqmh--) {
sprintf(hitungmundur, "%02d:%02d", menitIqmh, detikiqmh);
dispDMD.setFont(SystemFont5x7);
textCenter(8, hitungmundur);
if ( menitIqmh > 0 && detikiqmh <= 0 ) {
detikiqmh = 60;
menitIqmh = menitIqmh - 1;
}
delay(1000);
/////buzer sholat////
if (menitIqmh <= 0) {
if (detikiqmh == 7 || detikiqmh == 5 || detikiqmh == 3 ) { digitalWrite(2, HIGH); }
if (detikiqmh == 6 || detikiqmh == 4 || detikiqmh == 2 ) { digitalWrite(2, LOW); }
if (detikiqmh <=0) {
SiapSholat();
dispDMD.clear();
offSholat = true;
Istirahat();
tampilanjam = 0;
return;
}
}
}
}
static char *infosholat[] = {configinfo.infosholat};
void SiapSholat() {
static uint32_t x, t;
static uint32_t Speed;
int width = dispDMD.width();
dispDMD.setFont(Arial_Black_16);
Speed = 505 - (configdisp.cepat * 5);
int fullScroll = dispDMD.textWidth(infosholat[0]) + width;
dispDMD.clear();
for (t = 0; t < 2; t++) {
for (x = 0; x < fullScroll; ++x) {
dispDMD.drawText(width - x, 1, infosholat[0]);
delay(Speed);
}
}
}
//----------------------------------------------------------------------
// BUNYIKAN BEEP BUZZER
void BuzzerPanjang() {
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(buzzer, LOW);
delay(1000);
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(buzzer, LOW);
delay(50);
}
void BuzzerPendek() {
digitalWrite(buzzer, HIGH);
delay(200);
digitalWrite(buzzer, LOW);
delay(100);
digitalWrite(buzzer, HIGH);
delay(200);
digitalWrite(buzzer, LOW);
delay(50);
}
//-------------------------------------------------------
// TAMPILKAN SCROLLING TEKS NAMA
static char *nama[] = {configinfo.nama};
void TeksJalanNama() {
static uint32_t pM;
static uint32_t x;
static uint32_t Speed;
int width = dispDMD.width();
int y;
if (turu == false) {
Speed = 505 - (configdisp.cepat * 5);
//dispDMD.setFont(ElektronMart6x8);
//textCenter(0,"#");
//dispDMD.setFont(SystemFont5x7);
dispDMD.setFont(Arial_Black_16);
// logoMasjid((dispDMD.width()/2)-16);
// dispDMD.drawRect(0,7,dispDMD.width(),15,0,0);
// dispDMD.drawRect(0,6,dispDMD.width(),6,1,1);
int fullScroll = dispDMD.textWidth(nama[0]) + width;
if((millis() - pM) > Speed) {
pM = millis();
if (x < fullScroll) {
++x;
} else {
dispDMD.clear();
x = 0; y = 0;
++tampilanjam;
return;
}
dispDMD.drawText(width - x, 1, nama[0]);
}
}
}
int bM, Hr, tMAw, tMAk;
int bH, tHAw, tHAk;
int jAw, jAk;
String Hf, iShow;
//-------------------------------------------------------
// TAMPILKAN SCROLLING TEKS INFO1
uint8_t jadwalShow;
void InfoShow() {
char inShow[255];
static uint32_t pM;
static uint32_t x;
static uint32_t Speed;
int posX;
int width = dispDMD.width();
if (turu == false) {
Speed = 505 - (configdisp.cepat * 5);
if (jadwalShow > 4) {
dispDMD.clear();
jadwalShow = 0;
++tampilanjam;
return;
}
switch(jadwalShow) {
case 0 :
bM = configinfo.blnmasehi1;
Hr = configinfo.hari1;
tMAw = configinfo.tglmasehiawal1;
tMAk = configinfo.tglmasehiakhir1;
bH = configinfo.blnhijriyah1;
tHAw = configinfo.tglhijriyahawal1;
tHAk = configinfo.tglhijriyahakhir1;
jAw = configinfo.jamawal1;
jAk = configinfo.jamakhir1;
Hf = configinfo.huruf1;
sprintf(inShow,"%s", configinfo.info1);
break;
case 1 :
bM = configinfo.blnmasehi2;
Hr = configinfo.hari2;
tMAw = configinfo.tglmasehiawal2;
tMAk = configinfo.tglmasehiakhir2;
bH = configinfo.blnhijriyah2;
tHAw = configinfo.tglhijriyahawal2;
tHAk = configinfo.tglhijriyahakhir2;
jAw = configinfo.jamawal2;
jAk = configinfo.jamakhir2;
Hf = configinfo.huruf2;
sprintf(inShow,"%s", configinfo.info2);
break;
case 2 :
bM = configinfo.blnmasehi3;
Hr = configinfo.hari3;
tMAw = configinfo.tglmasehiawal3;
tMAk = configinfo.tglmasehiakhir3;
bH = configinfo.blnhijriyah3;
tHAw = configinfo.tglhijriyahawal3;
tHAk = configinfo.tglhijriyahakhir3;
jAw = configinfo.jamawal3;
jAk = configinfo.jamakhir3;
Hf = configinfo.huruf3;
sprintf(inShow,"%s", configinfo.info3);
break;
case 3 :
bM = configinfo.blnmasehi4;
Hr = configinfo.hari4;
tMAw = configinfo.tglmasehiawal4;
tMAk = configinfo.tglmasehiakhir4;
bH = configinfo.blnhijriyah4;
tHAw = configinfo.tglhijriyahawal4;
tHAk = configinfo.tglhijriyahakhir4;
jAw = configinfo.jamawal4;
jAk = configinfo.jamakhir4;
Hf = configinfo.huruf4;
sprintf(inShow,"%s", configinfo.info4);
break;
case 4 :
bM = configinfo.blnmasehi5;
Hr = configinfo.hari5;
tMAw = configinfo.tglmasehiawal5;
tMAk = configinfo.tglmasehiakhir5;
bH = configinfo.blnhijriyah5;
tHAw = configinfo.tglhijriyahawal5;
tHAk = configinfo.tglhijriyahakhir5;
jAw = configinfo.jamawal5;
jAk = configinfo.jamakhir5;
Hf = configinfo.huruf5;
sprintf(inShow,"%s", configinfo.info5);
break;
}
//uji kondisi
UjiKondisi(inShow);
//===========
if (Hf == "Besar1"){
dispDMD.setFont(Droid_Sans_12);
posX = (16 - dispDMD.textHeight()) / 2;
} else
if (Hf == "Besar2"){
dispDMD.setFont(Arial_Black_16);
posX = (16 - dispDMD.textHeight()) / 2;
} else {
//dispDMD.setFont(SystemFont5x7);
dispDMD.setFont(angka_2);
posX = 8;
}
int pj = dispDMD.textWidth(iShow);
if (pj <= 5) {
++jadwalShow;
} else {
uint32_t fullScroll = dispDMD.textWidth(iShow) + width;
if((millis() - pM) > Speed) {
pM = millis();
if (x < fullScroll) {
++x;
} else {
x = 0;
++jadwalShow;
return;
}
dispDMD.drawText(width - x, posX, iShow);
}
if (Hf == "Kecil"){
TampilJamKecil(fullScroll * Speed);
}
}
}
}
//void UjiKondisi(char ishow[255]){
void UjiKondisi(char ishow[]){
int jAwal, mAwal, jAkhir, mAkhir;
RtcDateTime rtcNow = Rtc.GetDateTime();
int Hari = rtcNow.DayOfWeek();
int Tgl = rtcNow.Day();
int Bln = rtcNow.Month();
int Thn = rtcNow.Year();
int Hor = rtcNow.Hour();
int Min = rtcNow.Minute();
String ishw = String(ishow);
int TglOld, TglNew;
int HBln = tglHijriah.bulan;
int HTgl = tglHijriah.tanggal;
CekWaktu(jAw);
jAwal = cJam;
mAwal = cMenit;
CekWaktu(jAk);
jAkhir = cJam;
mAkhir = cMenit;
if (jAwal<=23 or jAkhir<=23) {
//cek masehi
if (bM==0 && Hr==0 && tMAw==0 && tMAk==0 && bH==0 && tHAw==0 && tHAk==0 and jAwal==0 && jAkhir==0 && ishw.length()>5) iShow = ishw;
else if (bM==Bln && Hr==0 && tMAw==0 && tMAk==0 && bH==0 && tHAw==0 && tHAk==0 and jAwal==0 && jAkhir==0 && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==Hari+1 && tMAw==0 && tMAk==0 && bH==0 && tHAw==0 && tHAk==0 and jAwal==0 && jAkhir==0 && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==0 && tMAw>=Tgl && tMAk<=Tgl && bH==0 && tHAw==0 && tHAk==0 and jAwal==0 && jAkhir==0 && ishw.length()>5) iShow = ishw;
else if (bM==Bln && Hr==Hari+1 && tMAw==0 && tMAk==0 && bH==0 && tHAw==0 && tHAk==0 and jAwal==0 && jAkhir==0 && ishw.length()>5) iShow = ishw;
else if (bM==Bln && Hr==0 && tMAw>=Tgl && tMAk<=Tgl && bH==0 && tHAw==0 && tHAk==0 and jAwal==0 && jAkhir==0 && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==Hari+1 && tMAw>=Tgl && tMAk<=Tgl && bH==0 && tHAw==0 && tHAk==0 and jAwal==0 && jAkhir==0 && ishw.length()>5) iShow = ishw;
else if (bM==Bln && Hr==Hari+1 && tMAw>=Tgl && tMAk<=Tgl && bH==0 && tHAw==0 && tHAk==0 and jAwal==0 && jAkhir==0 && ishw.length()>5) iShow = ishw;
else if (bM==Bln && Hr==0 && tMAw==0 && tMAk==0 && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && jAkhir<=Hor && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==Hari+1 && tMAw==0 && tMAk==0 && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && jAkhir<=Hor && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==0 && tMAw>=Tgl && tMAk<=Tgl && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && jAkhir<=Hor && ishw.length()>5) iShow = ishw;
else if (bM==Bln && Hr==Hari+1 && tMAw==0 && tMAk==0 && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && jAkhir<=Hor && ishw.length()>5) iShow = ishw;
else if (bM==Bln && Hr==0 && tMAw>=Tgl && tMAk<=Tgl && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && jAkhir<=Hor && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==Hari+1 && tMAw>=Tgl && tMAk<=Tgl && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && jAkhir<=Hor && ishw.length()>5) iShow = ishw;
else if (bM==Bln && Hr==Hari+1 && tMAw>=Tgl && tMAk<=Tgl && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && jAkhir<=Hor && ishw.length()>5) iShow = ishw;
else //cek hijriyah
if (bM==0 && Hr==0 && tMAw==0 && tMAk==0 && bH==HBln && tHAw==0 && tHAk==0 and jAwal==0 && jAkhir==0 && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==0 && tMAw==0 && tMAk==0 && bH==0 && tHAw>=HTgl && tHAk<=HTgl and jAwal==0 && jAkhir==0 && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==0 && tMAw==0 && tMAk==0 && bH==HBln && tHAw>=HTgl && tHAk<=HTgl and jAwal==0 && jAkhir==0 && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==0 && tMAw==0 && tMAk==0 && bH==HBln && tHAw==0 && tHAk==0 and jAwal>=Hor && jAkhir<=Hor && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==0 && tMAw==0 && tMAk==0 && bH==0 && tHAw>=HTgl && tHAk<=HTgl and jAwal>=Hor && jAkhir<=Hor && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==0 && tMAw==0 && tMAk==0 && bH==HBln && tHAw>=HTgl && tHAk<=HTgl and jAwal>=Hor && jAkhir<=Hor && ishw.length()>5) iShow = ishw;
else if (bH > 12 && HBln != 9) iShow = ishw;
else iShow="";
} else {
if (bM==Bln && Hr==0 && tMAw==0 && tMAk==0 && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && mAwal>=Min && jAkhir<=Hor && mAwal<=Min && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==Hari+1 && tMAw==0 && tMAk==0 && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && mAwal>=Min && jAkhir<=Hor && mAwal<=Min && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==0 && tMAw>=Tgl && tMAk<=Tgl && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && mAwal>=Min && jAkhir<=Hor && mAwal<=Min && ishw.length()>5) iShow = ishw;
else if (bM==Bln && Hr==Hari+1 && tMAw==0 && tMAk==0 && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && mAwal>=Min && jAkhir<=Hor && mAwal<=Min && ishw.length()>5) iShow = ishw;
else if (bM==Bln && Hr==0 && tMAw>=Tgl && tMAk<=Tgl && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && mAwal>=Min && jAkhir<=Hor && mAwal<=Min && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==Hari+1 && tMAw>=Tgl && tMAk<=Tgl && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && mAwal>=Min && jAkhir<=Hor && mAwal<=Min && ishw.length()>5) iShow = ishw;
else if (bM==Bln && Hr==Hari+1 && tMAw>=Tgl && tMAk<=Tgl && bH==0 && tHAw==0 && tHAk==0 and jAwal>=Hor && mAwal>=Min && jAkhir<=Hor && mAwal<=Min && ishw.length()>5) iShow = ishw;
else //cek hijriyah
if (bM==0 && Hr==0 && tMAw==0 && tMAk==0 && bH==HBln && tHAw==0 && tHAk==0 and jAwal>=Hor && mAwal>=Min && jAkhir<=Hor && mAwal<=Min && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==0 && tMAw==0 && tMAk==0 && bH==0 && tHAw>=HTgl && tHAk<=HTgl and jAwal>=Hor && mAwal>=Min && jAkhir<=Hor && mAwal<=Min && ishw.length()>5) iShow = ishw;
else if (bM==0 && Hr==0 && tMAw==0 && tMAk==0 && bH==HBln && tHAw>=HTgl && tHAk<=HTgl and jAwal>=Hor && mAwal>=Min && jAkhir<=Hor && mAwal<=Min && ishw.length()>5) iShow = ishw;
else iShow="";
}
iShow = iShow + " ";
}
//----------------------------------------------------------------------
void CekWaktu(int waktu) {
int jam, menit;
RtcDateTime rtcNow = Rtc.GetDateTime();
KetentuanJWS(rtcNow);
if (waktu > 23){
if (waktu >= 24 && waktu <= 26){ // ==== sebelum subuh, subuh & sesudah subuh ====
get_float_time_parts(waktuJWS[0], jam, menit);
} else
if (waktu >= 27 && waktu <= 29){ // ==== sebelum duhur, duhur & sesudah duhur ====
get_float_time_parts(waktuJWS[2], jam, menit);
} else
if (waktu >= 30 && waktu <= 32){ // ==== sebelum ashar, ashar & sesudah ashar ====
get_float_time_parts(waktuJWS[3], jam, menit);
} else
if (waktu >= 33 && waktu <= 35){ // ==== sebelum magrib, magrib & sesudah magrib ====
get_float_time_parts(waktuJWS[5], jam, menit);
} else
if (waktu >= 36 && waktu <= 38){ // ==== sebelum isya', isya' & sesudah isya' ====
get_float_time_parts(waktuJWS[6], jam, menit);
}
if (waktu == 24 or waktu == 27 or waktu == 30 or waktu == 33 or waktu == 36){
if (menit - 20 < 0){
cJam = jam - 1;
cMenit = 60 - menit;
} else {
cJam = jam;
cMenit = menit - 20;
}
} else
if (waktu == 25 or waktu == 28 or waktu == 31 or waktu == 34 or waktu == 37){
cJam = jam;
cMenit = menit;
} else
if (waktu == 26 or waktu == 29 or waktu == 32 or waktu == 35 or waktu == 38){
if (menit + 20 > 60){
cJam = jam + 1;
cMenit = menit + 20 - 60;
} else {
cJam = jam;
cMenit = menit + 20;
}
}
} else {
cJam = waktu;
cMenit = 0;
}
}
//----------------------------------------------------------------------
// FORMAT TEKS
void textCenter(int y,String Msg) {
int center = int((dispDMD.width()-dispDMD.textWidth(Msg)) / 2);
dispDMD.drawText(center,y,Msg);
}
void textCenter1PKanan(int y,String Msg) {
int center = ((dispDMD.width()-dispDMD.textWidth(Msg)) / 2) + (dispDMD.width() / 4);
dispDMD.drawText(center,y,Msg);
}
//----------------------------------------------------------------------
// ANIMASI LOGO
void animLogoX() {
static uint8_t x;
static uint8_t s; // 0=in, 1=out
static uint32_t pM;
uint32_t cM = millis();
JamJatuhPulse2(16);
if ((cM - pM) > 35) {
if (s == 0 and x < 16) {
pM = cM;
x++;
}
if (s == 1 and x > 0) {
pM = cM;
x--;
}
}
if ((cM - pM) > 10000 and x == 16) {
s = 1;
}
if (x == 0 and s == 1) {
dispDMD.clear();
s = 0;
++tampilanjam;
}
logoax(x - 16);
logobx(dispDMD.width() - x);
}
void logoax(uint32_t x) {
static const uint8_t logoax[] PROGMEM = {
16, 16,
B00000000,B00000000,
B01111110,B01111110,
B01111110,B01111110,
B00000110,B01100110,
B00000110,B01100110,
B01111110,B01111110,
B01111110,B01111110,
B00000110,B01100000,
B00000110,B01100000,
B01111110,B01111110,
B01111110,B01111110,
B01100110,B00000110,
B01100110,B00000110,
B01111111,B11111110,
B01111111,B11111110,
B00000000,B00000000
};
dispDMD.drawBitmap(x, 0, logoax);
}
void logobx(uint32_t x) {
static const uint8_t logobx[] PROGMEM = {
16, 16,
B00000000,B00000000,
B01111111,B11111110,
B01111111,B11111110,
B00000000,B00000000,
B00000000,B00000000,
B01111110,B01100110,
B01111110,B01100110,
B00000110,B01100110,
B00000110,B01100110,
B01111110,B01100110,
B01111110,B01100110,
B01100110,B01100110,
B01100110,B01100110,
B01111111,B11111110,
B01111111,B11111110,
B00000000,B00000000
};
dispDMD.drawBitmap(x, 0, logobx);
}
void logoa2t(uint32_t x) {
static const uint8_t logoa2t[] PROGMEM = {
16, 16,
B00000000,B00000000,
B00000111,B11100000,
B00001111,B11110000,
B00011100,B00111000,
B00111001,B10011100,
B01110011,B11001110,
B01110110,B01101110,
B01110111,B01101110,
B01110110,B01101110,
B01110000,B00001110,
B01110111,B11101110,
B01110001,B10001110,
B01110001,B10001110,
B01110001,B10001110,
B01110001,B10001110,
B00000000,B00000000
};
dispDMD.drawBitmap(6, x, logoa2t);
}
void logoMasjid(uint32_t x) {
static const uint8_t logoMasjid[] PROGMEM = {
32, 16,
0x00, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x18,
0x7c, 0x07, 0xc0, 0x3c, 0x38, 0x1f, 0xf0, 0x7e,
0x00, 0x3f, 0xf8, 0x7e, 0x7c, 0x3f, 0xf8, 0x3c,
0x00, 0x1f, 0xf0, 0x00, 0x3b, 0xff, 0xff, 0xbc,
0x28, 0x00, 0x00, 0x2c, 0x3b, 0xff, 0xff, 0xac,
0x3b, 0xbe, 0xfb, 0xac, 0x3b, 0x1c, 0x71, 0xac,
0x3b, 0x1c, 0x71, 0xac, 0x3b, 0x1c, 0x71, 0xac,
0x7f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00
};
dispDMD.drawBitmap(x, 0, logoMasjid);
}
//----------------------------------------------------------------------
// TOGGLE LED INTERNAL UNTUK STATUS MODE WIFI
void toggleLED() {
digitalWrite(pin_led, !digitalRead(pin_led));
server.send_P(200, "text/html", setwaktu);
}
//----------------------------------------------------------------------
// HJS589 P10 utility Function
void branding() {
static uint8_t x;
dispDMD.clear();
dispDMD.setFont(SystemFont5x7);
for (x=0; x < 41; ++x){
if (x < 16) {
logoa2t(x - 15);
}
dispDMD.drawText(64 - x, 0, "TRAVEL");
dispDMD.drawText(64 - x, 8, ".BIZ");
delay(10);
}
delay(3000);
for (x=0; x < 32; ++x) {
dispDMD.drawRect(32 - x, 0, x + 32, 16, 0, 0);
delay(25);
}
dispDMD.clear();
dispDMD.setFont(ElektronMart6x8);
//textCenter(0, "#");
textCenter(4, "JWS v.1");
delay(2000);
for (x=0; x < 32; ++x) {
dispDMD.drawRect(0 + x, 0, 64 - x, 16, 0, 0);
delay(25);
}
dispDMD.clear();
}
//tampilkan ip
void IpLocalShow() {
static uint32_t pM;
static uint32_t x, t;
static uint32_t Speed = 50;
int width = dispDMD.width();
dispDMD.setFont(SystemFont5x7);
//String IpLocal;
char IpLocal[16];
dispDMD.clear();
if (WiFi.status() == WL_CONNECTED) {
//IpLocal = (WiFi.localIP().toString()).c_str();
sprintf(IpLocal, "%03d:%03d:%03d:%03d ", WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], WiFi.localIP()[3]);
} else {
//IpLocal = (local_ip.toString()).c_str();
sprintf(IpLocal, "%03d:%03d:%03d:%03d ", local_ip[0], local_ip[1], local_ip[2], local_ip[3]);
}
//IpLocal = IpLocal + " ";
int fullScroll = dispDMD.textWidth(IpLocal) + width;
for (t=0; t < 2; ++t){
for (x=0; x < fullScroll; ++x){
dispDMD.drawText(width - x, 1, IpLocal);
delay(Speed);
}
}
dispDMD.clear();
}
void Istirahat() {
RtcDateTime rtcNow = Rtc.GetDateTime();
/*
int Hari = rtcNow.DayOfWeek();
int Tgl = rtcNow.Day();
int Bln = rtcNow.Month();
int Thn = rtcNow.Year();
*/ /*
int Hor = rtcNow.Hour();
int Min = rtcNow.Minute();
int Sec = rtcNow.Second();
int OnJam, OnMenit, OffJam, OffMenit;
char strOn[10];
char strOff[10];
dispDMD.setFont(SystemFont5x7);
if (offSholat == true and turu == false){
turu = true;
minStanby = minStanby - 1; secStanby = 60;
}
if (minStanby > 0 && secStanby <= 0) {
minStanby--; secStanby = 60;
}
if (minStanby == 0 and secStanby <= 0 and offSholat == true) {
OnJam = Hor;
OnMenit = Min;
Sec = 0;
} else {
OffJam = configdisp.offjam;
OffMenit = configdisp.offmenit;
OnJam = configdisp.onjam;
OnMenit = configdisp.onmenit;
}
sprintf(strOff,"%02d.%02d", OffJam, OffMenit);
sprintf(strOn,"%02d.%02d", OnJam, OnMenit);
if (Hor == OffJam && Min == OffMenit - 1 && Sec == 50){
dispDMD.clear();
dispDMD.drawText(5, 0, "OFF");
dispDMD.drawText(5, 8, "ON");
dispDMD.drawRect(24, 2, 25, 3, 1, 1);
dispDMD.drawRect(24, 5, 25, 6, 1, 1);
dispDMD.drawRect(24, 10, 25, 11, 1, 1);
dispDMD.drawRect(24, 13, 25, 14, 1, 1);
dispDMD.drawText(28, 0, strOff);
dispDMD.drawText(28, 8, strOn);
delay((60 - Sec) * 1000);
}
if (Hor == OffJam && Min == OffMenit && Sec == 0 && turu == false){
dispDMD.clear();
turu = true;
}
if (Hor == OnJam && Min == OnMenit && Sec == 0 && turu == true){
dispDMD.clear();
turu = false;
offSholat = false;
++tampilanjam;
return;
}
if (turu == true){
dispDMD.clear();
dispDMD.drawCircle(15, 4, 1, 1, 1);
dispDMD.drawCircle(15, 10, 1, 1, 1);
delay(500);
dispDMD.clear();
dispDMD.drawCircle(15, 4, 1, 0, 0);
dispDMD.drawCircle(15, 10, 1, 0, 0);
delay(500);
if (offSholat == true){
secStanby = secStanby -1;
}
// tampilanjam = 4;
++tampilanjam;
return;
}
if (tampilanjam > 3){
++tampilanjam;
}
}
//----------------------------------------------------------------------
// I2C_ClearBus menghindari gagal baca RTC (nilai 00 atau 165)
int I2C_ClearBus() {
#if defined(TWCR) && defined(TWEN)
TWCR &= ~(_BV(TWEN)); //Disable the Atmel 2-Wire interface so we can control the SDA and SCL pins directly
#endif
pinMode(SDA, INPUT_PULLUP); // Make SDA (data) and SCL (clock) pins Inputs with pullup.
pinMode(SCL, INPUT_PULLUP);
delay(2500); // Wait 2.5 secs. This is strictly only necessary on the first power
// up of the DS3231 module to allow it to initialize properly,
// but is also assists in reliable programming of FioV3 boards as it gives the
// IDE a chance to start uploaded the program
// before existing sketch confuses the IDE by sending Serial data.
boolean SCL_LOW = (digitalRead(SCL) == LOW); // Check is SCL is Low.
if (SCL_LOW) { //If it is held low Arduno cannot become the I2C master.
return 1; //I2C bus error. Could not clear SCL clock line held low
}
boolean SDA_LOW = (digitalRead(SDA) == LOW); // vi. Check SDA input.
int clockCount = 20; // > 2x9 clock
while (SDA_LOW && (clockCount > 0)) { // vii. If SDA is Low,
clockCount--;
// Note: I2C bus is open collector so do NOT drive SCL or SDA high.
pinMode(SCL, INPUT); // release SCL pullup so that when made output it will be LOW
pinMode(SCL, OUTPUT); // then clock SCL Low
delayMicroseconds(10); // for >5uS
pinMode(SCL, INPUT); // release SCL LOW
pinMode(SCL, INPUT_PULLUP); // turn on pullup resistors again
// do not force high as slave may be holding it low for clock stretching.
delayMicroseconds(10); // for >5uS
// The >5uS is so that even the slowest I2C devices are handled.
SCL_LOW = (digitalRead(SCL) == LOW); // Check if SCL is Low.
int counter = 20;
while (SCL_LOW && (counter > 0)) { // loop waiting for SCL to become High only wait 2sec.
counter--;
delay(100);
SCL_LOW = (digitalRead(SCL) == LOW);
}
if (SCL_LOW) { // still low after 2 sec error
return 2; // I2C bus error. Could not clear. SCL clock line held low by slave clock stretch for >2sec
}
SDA_LOW = (digitalRead(SDA) == LOW); // and check SDA input again and loop
}
if (SDA_LOW) { // still low
return 3; // I2C bus error. Could not clear. SDA data line held low
}
// else pull SDA line low for Start or Repeated Start
pinMode(SDA, INPUT); // remove pullup.
pinMode(SDA, OUTPUT); // and then make it LOW i.e. send an I2C Start or Repeated start control.
// When there is only one I2C master a Start or Repeat Start has the same function as a Stop and clears the bus.
/// A Repeat Start is a Start occurring after a Start with no intervening Stop.
delayMicroseconds(10); // wait >5uS
pinMode(SDA, INPUT); // remove output low
pinMode(SDA, INPUT_PULLUP); // and make SDA high i.e. send I2C STOP control.
delayMicroseconds(10); // x. wait >5uS
pinMode(SDA, INPUT); // and reset pins as tri-state inputs which is the default state on reset
pinMode(SCL, INPUT);
return 0; // all ok
*/
int scrollSpeed = 25; // default frame delay value
textEffect_t scrollEffect = PA_SCROLL_LEFT;
textPosition_t scrollAlign = PA_LEFT;
int scrollPause = 2000; // in milliseconds
char szMesg[MAX_DEVICES + 1] = "";
char teks = "";
void setup () {
Serial.begin(115200);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
P.begin();
P.setFont(0);
P.setIntensity(200);
//P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
//delay(5000);
//P.displayClear();
}
int jam, menit;
uint8_t years,months,days,hours, minutes, seconds;
boolean imsk;
// Code for reading clock time
void getTime(char *psz, bool f = true)
{
sprintf(psz, "%02d%c%02d", hours, (f ? ':' : ' '), minutes);
}
void loop () {
static uint32_t lastTime = 0;
static uint8_t tampil = 0;
static bool flasher = false;
DateTime now = rtc.now();
years=now.year(), DEC;
months=now.month(), DEC;
days=now.day(), DEC;
hours=now.hour(), DEC;
minutes=now.minute(), DEC;
seconds=now.second(), DEC;
float latitude = -7.2770144;
float longitude = 112.4556897;
byte zonawaktu = 7;
set_calc_method(ISNA);
set_asr_method(Shafii);
set_high_lats_adjust_method(AngleBased);
set_fajr_angle(20);
set_isha_angle(18);
get_prayer_times(years, months, days, latitude, longitude, zonawaktu, waktuJWS);
/*
long randNumber;
randNumber = random(0,54); //untuk mengambil quote random, karena quote yang saya buat total nya ada 55, maka dibuat random 0 - 54
Serial.println(randNumber);
Serial.println(notes[randNumber]);
*/
//P.displayAnimate();
if (P.displayAnimate())
{
switch(tampil){
case 1: //imsyak
//P.setPause(0, 1000);
//P.setTextEffect(0, PA_SCROLL_UP, PA_SCROLL_DOWN);
tampil++; imsk=true;
getWaktuSholat(0, szMesg);
P.displayText(szMesg, PA_CENTER, 0, 2000, PA_SCROLL_UP, PA_SCROLL_DOWN);
break;
case 2: //subuh
tampil++; imsk=false;
getWaktuSholat(0, szMesg);
P.displayText(szMesg, PA_CENTER, 0, 2000, PA_SCROLL_UP, PA_SCROLL_DOWN);
break;
case 3: //syuruq
tampil++; imsk=false;
getWaktuSholat(1, szMesg);
P.displayText(szMesg, PA_CENTER, 0, 2000, PA_SCROLL_UP, PA_SCROLL_DOWN);
break;
case 4: //dhuhur
tampil++; imsk=false;
getWaktuSholat(2, szMesg);
P.displayText(szMesg, PA_CENTER, 0, 2000, PA_SCROLL_UP, PA_SCROLL_DOWN);
break;
case 5: //ashar
tampil++; imsk=false;
getWaktuSholat(3, szMesg);
P.displayText(szMesg, PA_CENTER, 0, 2000, PA_SCROLL_UP, PA_SCROLL_DOWN);
break;
case 6: //magrib
tampil++; imsk=false;
getWaktuSholat(4, szMesg);
P.displayText(szMesg, PA_CENTER, 0, 2000, PA_SCROLL_UP, PA_SCROLL_DOWN);
break;
case 7: //isya'
tampil++; imsk=false;
getWaktuSholat(6, szMesg);
P.displayText(szMesg, PA_CENTER, 0, 2000, PA_SCROLL_UP, PA_SCROLL_DOWN);
break;
case 0:
// imsk = true;
//P.setFont(0, numeric7Seg);
//P.setTextEffect(0, PA_PRINT, PA_NO_EFFECT);
//P.setPause(0, 0);
/*
if ((millis() - lastTime) >= 1000)
{
lastTime = millis();
getTime(szMesg, flasher);
flasher = !flasher;
}
*/
sprintf(szMesg, "%02d:%02d:%02d", hours, minutes, seconds);
P.displayText(szMesg, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
if ((now.second() == 00) && (now.second() <= 30)) {
tampil++;
//P.setTextEffect(0, PA_PRINT, PA_WIPE_CURSOR);
P.displayText(szMesg, PA_CENTER, 0, 0, PA_PRINT, PA_WIPE_CURSOR);
}
break;
default:
tampil=0;
String str = "Jangan lupa SHOLAT";
int str_len = str.length() + 1;
char char_array[str_len];
//str.toCharArray(char_array, str_len);
strncpy_P(teks, char_array,str_len);
//strcpy(teks,char_array);
sprintf(teks,"%s", char_array);
P.displayText(teks, PA_LEFT, 20, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
break;
}
P.displayReset();
//Serial.println(szMesg);
}
}
void getWaktuSholat(int i, char *psz)
{
get_float_time_parts(waktuJWS[i], jam, menit);
if (imsk==true){ sprintf(psz, "%s %02d:%02d", "Imsak", jam, menit-10); }
else if (i>5) { sprintf(psz, "%s %02d:%02d", NamaSholat[i-1], jam, menit); }
else { sprintf(psz, "%s %02d:%02d", NamaSholat[i], jam, menit); }
String namasholat = psz;
int len = namasholat.length()+1;
//Serial.println(len);
}