IF482 bugfix

This commit is contained in:
Klaus K Wilting 2019-02-04 21:42:44 +01:00
parent 56ab5a24a5
commit 8d01b651bb
3 changed files with 18 additions and 19 deletions

View File

@ -88,9 +88,12 @@ TaskHandle_t IF482Task;
HardwareSerial IF482(2); // use UART #2 (note: #1 may be in use for serial GPS)
// initialize and configure GPS
// initialize and configure IF482 Generator
int if482_init(void) {
// setup external interupt for active low RTC INT pin
pinMode(RTC_INT, INPUT_PULLUP);
// open serial interface
IF482.begin(HAS_IF482);
@ -113,8 +116,6 @@ int if482_init(void) {
0); // CPU core
assert(IF482Task); // has if482loop task started?
// setup external interupt for active low RTC INT pin
pinMode(RTC_INT, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(RTC_INT), IF482IRQ, FALLING);
return 1;
@ -124,10 +125,7 @@ int if482_init(void) {
String if482Telegram(time_t tt) {
time_t t = myTZ.toLocal(tt);
char mon;
char buf[14] = "000000F000000";
char out[17];
char mon, buf[14], out[17];
switch (timeStatus()) { // indicates if time has been set and recently synced
case timeSet: // time is set and is synced
@ -141,14 +139,16 @@ String if482Telegram(time_t tt) {
break;
} // switch
if ((timeStatus() == timeSet) ||
(timeStatus() == timeNeedsSync)) // do we have valid time?
snprintf(buf, sizeof buf, "%02u%02u%02u%1u%02u%02u%02u", year(t) - 2000,
// do we have confident time/date?
if ((timeStatus() == timeSet) || (timeStatus() == timeNeedsSync))
snprintf(buf, sizeof(buf), "%02u%02u%02u%1u%02u%02u%02u", year(t) - 2000,
month(t), day(t), weekday(t), hour(t), minute(t), second(t));
else
snprintf(buf, sizeof(buf), "000000F000000"); // no confident time/date
snprintf(out, sizeof out, "O%cL%s\r", mon, buf);
// output IF482 telegram
snprintf(out, sizeof(out), "O%cL%s\r", mon, buf);
ESP_LOGD(TAG, "IF482 = %s", out);
return out;
}
@ -167,7 +167,7 @@ void if482_loop(void *pvParameters) {
do {
tt = now();
} while (t == tt);
BitsPending = true; // start blink in display
// take timestamp at moment of start of new second
@ -186,7 +186,7 @@ void if482_loop(void *pvParameters) {
vTaskDelayUntil(&wakeTime, shotTime); // sets waketime to moment of shot
IF482.print(if482Telegram(now() + 1));
}
BitsPending = false; // stop blink in display
BitsPending = false; // stop blink in display
vTaskDelete(IF482Task); // shoud never be reached
} // if482_loop()

View File

@ -337,9 +337,8 @@ void setup() {
strcat_P(features, " DCF77");
#endif
#if defined HAS_IF482 && defined RTC_INT
#if (defined HAS_IF482) && (defined RTC_INT)
strcat_P(features, " IF482");
assert(if482_init());
#endif
// show compiled features
@ -417,9 +416,9 @@ void setup() {
setSyncInterval(TIME_SYNC_INTERVAL_GPS * 60);
#endif
#if defined HAS_IF482 && defined DCF_77
#if (defined HAS_IF482) && (defined DCF_77)
#error "You may define at most one of HAS_IF482 or DCF_77"
#elif defined HAS_IF482 && defined RTC_INT
#elif (defined HAS_IF482) && (defined RTC_INT)
ESP_LOGI(TAG, "Starting IF482 Generator...");
assert(if482_init());
#elif defined HAS_DCF77

View File

@ -86,7 +86,7 @@
#define TIME_SYNC_INTERVAL_RTC 60 // sync time each .. minutes from RTC [default = 60], comment out means off
#define TIME_WRITE_INTERVAL_RTC 60 // write time each .. minutes from GPS/LORA to RTC [default = 60], comment out means off
//#define TIME_SYNC_INTERVAL_LORA 60 // sync time each .. minutes from LORA network [default = 60], comment out means off
#define IF482_OFFSET 984 // 1sec minus IF482 serial transmit time [ms]: e.g. 9 bits * 17 bytes * 1/9600 bps = 16ms
#define IF482_OFFSET 16 // IF482 serial transmit time [ms]: e.g. 9 bits * 17 bytes * 1/9600 bps = 16ms
// time zone, see https://github.com/JChristensen/Timezone/blob/master/examples/WorldClock/WorldClock.ino
#define DAYLIGHT_TIME {"CEST", Last, Sun, Mar, 2, 120} // Central European Summer Time