Hi,
also habe grade nachgesehen, die Lib ist von Thijs Elenbaas und er selbst schreibt
Hi Robert,
No, the DCF77 library doesn’t, but the time library with which the DCF library interacts does, see: Arduino Playground - HomePage.
In order to have good separation of concerns, I want the DCF library just to receive and output the time, and do time-displaying, -conversion and -manipulation outside of it
also wird das gar nicht erst vom DCF77 ausgelesen. Somit ist klar warum nur Käse beim "Weekday" rauskommt.
Was ich machen wollte ist folgendes.....
Ich habe einen DS1307 und einen DCF77. Ich zeige die Uhrzeit mittels diesem Code hier an:
RTC.getTime();
if (RTC.hour < 10){
lcd.setCursor(5,0); // Cursorbeginn auf Zeichen 7, Zeile 2
} else {
lcd.setCursor(4,0); // Cursorbeginn auf Zeichen 6, Zeile 2
}
lcd.print(RTC.hour); // Stunden
printDigits(RTC.minute); // : Minuten
printDigits(RTC.second); // : Sekunden
lcd.setCursor(1,1); // Cursorbeginn auf Zeichen 1, Zeile 2
switch (RTC.dow) {
case 1: // your hand is on the sensor
lcd.print("Mo"); // Wochentag
break;
case 2: // your hand is close to the sensor
lcd.print("Di"); // Wochentag
break;
case 3: // your hand is a few inches from the sensor
lcd.print("Mi"); // Wochentag
break;
case 4: // your hand is nowhere near the sensor
lcd.print("Do"); // Wochentag
break;
case 5: // your hand is nowhere near the sensor
lcd.print("Fr"); // Wochentag
break;
case 6: // your hand is nowhere near the sensor
lcd.print("Sa"); // Wochentag
break;
case 7: // your hand is nowhere near the sensor
lcd.print("So"); // Wochentag
break;
}
if (day() < 10 && month() < 10){ // Wenn Tag < 10 und Monat < 10
lcd.setCursor(5,1); // Cursorbeginn auf Zeichen 7, Zeile 3
} else if (RTC.day > 10 && RTC.month < 10 || RTC.day < 10 && RTC.month > 10 ){ // Wenn Tag > 10 und Monat < 10 oder Tag < 10 und Monat > 10
lcd.setCursor(4,1); // Cursorbeginn auf Zeichen 6, Zeile 3
} else { // alles andere
lcd.setCursor(3,1); // Cursorbeginn auf Zeichen 5, Zeile 3
}
lcd.print(RTC.day); // Tag
lcd.print("."); // Text "."
lcd.print(RTC.month); // Monat
lcd.print("."); // Text "."
lcd.print(RTC.year); // Jahr "
}
was auch ganz gut klappt.
Die Uhrzeit wird mittels DCF77 gesetzt mit diesem Code hier:
void DCFtoRTCsync()
{
if((millis() - prev) > interval) { // Delay mit Millis damit der µC nach andere Dinge paralell abarbeiten kann
time_t DCFtime = DCF.getTime(); // Zeit holen
if (DCFtime!=0) { // Prüfen ob neue Zeit vorhanden ist (Wenn Return 0 dann wurde noch keine neue Zeit empfangen)
prev = millis(); // Aktuelle millis Zeit in "prev_update" speichern
RTC.stopClock();
RTC.second = (second(DCFtime)); // DON'T USE '00' IF YOU MEAN '0' SECONDS!!!
RTC.minute = (minute(DCFtime));
RTC.hour = (hour(DCFtime));
RTC.dow = (weekday(DCFtime)); // SUN=7,MON=1...
RTC.day = (day(DCFtime));
RTC.month = (month(DCFtime));
RTC.year = (year(DCFtime));
RTC.setTime();
RTC.startClock();
}
}
}
das klappt auch alles wunderbar. Nur RTC.dow = (weekday(DCFtime)); // SUN=7,MON=1... nciht......
Ich wollte einfach nur zusätzlich den Wochentag ausgeben. Oder wie soll ich das sonst machen?