#include "segmentos.h"
#include <Wire.h>
#include "RTClib.h"
SieteSegmentos seg(2, 3, 4, 5, 6, 7, 8);
unsigned long t = 0;
byte hodnoty[] = {1,0,0,0};
RTC_DS1307 rtc;
bool stav = false;
void setup() {
seg.init();
if (! rtc.begin())
{
while (true);
}
DateTime val = DateTime(__DATE__, __TIME__);
rtc.adjust(DateTime(val.year(), val.month(), val.day(), val.hour()+1, val.minute(), val.second()));
}
void loop() {
displaytime(rtc.now());
}
void updateDigits(){
for(int i = 0;i<4;i++){
seg.ShowNum(hodnoty[i],i);
}
}
void displaytime(DateTime cas) {
if (millis() - t > 5000) {
t = millis();
stav = !stav;
}
if (stav) {
int teplota = 1 / (log(1 / (1023. / analogRead(A3) - 1)) / 3950 + 1.0 / 298.15) - 273.15;
seg.ShowNum(teplota%10,2);
seg.ShowNum(teplota/10,3);
seg.ShowDegrees();
} else {
seg.ShowNum(cas.minute()%10,0);
seg.ShowNum(cas.minute()/10,1);
seg.ShowNum(cas.hour()%10,2);
seg.ShowNum(cas.hour()/10,3);
}
}