IF482 bugfix
This commit is contained in:
parent
56ab5a24a5
commit
8d01b651bb
@ -88,9 +88,12 @@ TaskHandle_t IF482Task;
|
|||||||
|
|
||||||
HardwareSerial IF482(2); // use UART #2 (note: #1 may be in use for serial GPS)
|
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) {
|
int if482_init(void) {
|
||||||
|
|
||||||
|
// setup external interupt for active low RTC INT pin
|
||||||
|
pinMode(RTC_INT, INPUT_PULLUP);
|
||||||
|
|
||||||
// open serial interface
|
// open serial interface
|
||||||
IF482.begin(HAS_IF482);
|
IF482.begin(HAS_IF482);
|
||||||
|
|
||||||
@ -113,8 +116,6 @@ int if482_init(void) {
|
|||||||
0); // CPU core
|
0); // CPU core
|
||||||
|
|
||||||
assert(IF482Task); // has if482loop task started?
|
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);
|
attachInterrupt(digitalPinToInterrupt(RTC_INT), IF482IRQ, FALLING);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -124,10 +125,7 @@ int if482_init(void) {
|
|||||||
String if482Telegram(time_t tt) {
|
String if482Telegram(time_t tt) {
|
||||||
|
|
||||||
time_t t = myTZ.toLocal(tt);
|
time_t t = myTZ.toLocal(tt);
|
||||||
|
char mon, buf[14], out[17];
|
||||||
char mon;
|
|
||||||
char buf[14] = "000000F000000";
|
|
||||||
char out[17];
|
|
||||||
|
|
||||||
switch (timeStatus()) { // indicates if time has been set and recently synced
|
switch (timeStatus()) { // indicates if time has been set and recently synced
|
||||||
case timeSet: // time is set and is synced
|
case timeSet: // time is set and is synced
|
||||||
@ -141,14 +139,16 @@ String if482Telegram(time_t tt) {
|
|||||||
break;
|
break;
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
if ((timeStatus() == timeSet) ||
|
// do we have confident time/date?
|
||||||
(timeStatus() == timeNeedsSync)) // do we have valid time?
|
if ((timeStatus() == timeSet) || (timeStatus() == timeNeedsSync))
|
||||||
snprintf(buf, sizeof buf, "%02u%02u%02u%1u%02u%02u%02u", year(t) - 2000,
|
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));
|
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);
|
ESP_LOGD(TAG, "IF482 = %s", out);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,9 +337,8 @@ void setup() {
|
|||||||
strcat_P(features, " DCF77");
|
strcat_P(features, " DCF77");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined HAS_IF482 && defined RTC_INT
|
#if (defined HAS_IF482) && (defined RTC_INT)
|
||||||
strcat_P(features, " IF482");
|
strcat_P(features, " IF482");
|
||||||
assert(if482_init());
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// show compiled features
|
// show compiled features
|
||||||
@ -417,9 +416,9 @@ void setup() {
|
|||||||
setSyncInterval(TIME_SYNC_INTERVAL_GPS * 60);
|
setSyncInterval(TIME_SYNC_INTERVAL_GPS * 60);
|
||||||
#endif
|
#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"
|
#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...");
|
ESP_LOGI(TAG, "Starting IF482 Generator...");
|
||||||
assert(if482_init());
|
assert(if482_init());
|
||||||
#elif defined HAS_DCF77
|
#elif defined HAS_DCF77
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
#define TIME_SYNC_INTERVAL_RTC 60 // sync time each .. minutes from RTC [default = 60], comment out means off
|
#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_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 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
|
// 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
|
#define DAYLIGHT_TIME {"CEST", Last, Sun, Mar, 2, 120} // Central European Summer Time
|
||||||
|
Loading…
Reference in New Issue
Block a user