dogfood-timer updated to remove the chance (1/350) of the arduino skipping a second while the display is supposed to turn off or change the day. Side effect is that the arduino is actually more accurate at keeping time.

This commit is contained in:
Cole Deck 2018-06-05 23:46:47 +00:00
parent e0eb0be69b
commit 69013515ed

View File

@ -192,7 +192,7 @@ void setuptime() {
}
delay(250);
unsigned long oldtime = 0;
unsigned long secper5 = now();
unsigned long secper20 = now();
check = false;
while(1 == 1) {
time_t t = now();
@ -212,7 +212,7 @@ void setuptime() {
//Serial.println(distance);
if(distance < 30 || analogRead(3) >= 150 || digitalRead(7) == 1 || digitalRead(6) == 1) {
if(distance < 30 || analogRead(3) >= 125 || digitalRead(7) == 1 || digitalRead(6) == 1) {
digitalWrite(10, HIGH);
wait = now();
}
@ -232,11 +232,17 @@ void setuptime() {
if(now() != oldtime) {
//if(check == false) {
//Serial.println(analogRead(3));
if(now()-350 >= secper5) {
t = t + 1;
secper5 = now();
if(now()-1200 >= secper20) {
if(now()-15 >= wait && analogRead(3) < 100) {
digitalWrite(10, LOW); // just in case the arduino skips a second at the wrong time
}
if(day(t) != oldday) {
today = 0;
}
setTime(now() + 1);
secper20 = now();
}
if(now()-15 >= wait && analogRead(3) < 150) {
if(now()-15 >= wait && analogRead(3) < 100) {
digitalWrite(10, LOW);
}
if(day(t) != oldday) {
@ -258,7 +264,7 @@ void setuptime() {
lcd.print("PM");
} */
if (analogRead(3) < 150 && prevphoto >=150) {
if (analogRead(3) < 100 && prevphoto >=100) {
last = now();
lastlong = now();
today ++;