From 82e8c180824800189b4ca8f35f20cb95e1c9d349 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 5 Mar 2022 16:57:29 +0100 Subject: [PATCH 1/5] cleanup heltec hal files --- src/hal/heltec.h | 4 ---- src/hal/heltecv2.h | 6 ------ src/hal/heltecv21.h | 6 ------ 3 files changed, 16 deletions(-) diff --git a/src/hal/heltec.h b/src/hal/heltec.h index 55f7332a..3546089e 100644 --- a/src/hal/heltec.h +++ b/src/hal/heltec.h @@ -10,10 +10,6 @@ // Hardware related definitions for Heltec V1 LoRa-32 Board // see https://heltec-automation-docs.readthedocs.io/en/latest/esp32/wifi_lora_32/hardware_update_log.html#v1 -//#define HAS_BME 1 // Enable BME sensors in general -//#define HAS_BME680 GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL -//#define BME680_ADDR BME680_I2C_ADDR_PRIMARY // connect SDIO of BME680 to GND - #define HAS_LORA 1 // comment out if device shall not send data via LoRa #define CFG_sx1276_radio 1 diff --git a/src/hal/heltecv2.h b/src/hal/heltecv2.h index b6aab088..b047bdd8 100644 --- a/src/hal/heltecv2.h +++ b/src/hal/heltecv2.h @@ -10,12 +10,6 @@ // Hardware related definitions for Heltec V2 LoRa-32 Board // see https://heltec-automation-docs.readthedocs.io/en/latest/esp32/wifi_lora_32/hardware_update_log.html#v2 -//#define HAS_BME 1 // Enable BME sensors in general -//#define HAS_BME680 GPIO_NUM_4, GPIO_NUM_15 // SDA, SCL -//#define BME680_ADDR BME680_I2C_ADDR_PRIMARY // connect SDIO of BME680 to GND -//#define HAS_BMP180 -//#define BMP180_ADDR 0x77 - #define HAS_LORA 1 // comment out if device shall not send data via LoRa #define CFG_sx1276_radio 1 diff --git a/src/hal/heltecv21.h b/src/hal/heltecv21.h index a24d875a..9372325d 100644 --- a/src/hal/heltecv21.h +++ b/src/hal/heltecv21.h @@ -10,12 +10,6 @@ // Hardware related definitions for Heltec V2.1 LoRa-32 Board // see https://heltec-automation-docs.readthedocs.io/en/latest/esp32/wifi_lora_32/hardware_update_log.html#v2-1 -//#define HAS_BME 1 // Enable BME sensors in general -//#define HAS_BME680 GPIO_NUM_4, GPIO_NUM_15 // SDA, SCL -//#define BME680_ADDR BME680_I2C_ADDR_PRIMARY // connect SDIO of BME680 to GND -//#define HAS_BMP180 -//#define BMP180_ADDR 0x77 - #define HAS_LORA 1 // comment out if device shall not send data via LoRa #define CFG_sx1276_radio 1 From b393dae769bc833fb9330a42695f5c72a8cfacaa Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 5 Mar 2022 17:33:23 +0100 Subject: [PATCH 2/5] use Wire.end() --- src/i2c.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/i2c.cpp b/src/i2c.cpp index 9731e09d..0080dd5d 100644 --- a/src/i2c.cpp +++ b/src/i2c.cpp @@ -12,8 +12,7 @@ void i2c_init(void) { Wire.begin(); } -// void i2c_deinit(void) { Wire.end(); } -void i2c_deinit(void) { Wire.~TwoWire(); } +void i2c_deinit(void) { Wire.end(); } void i2c_scan(void) { From 8394f3be709b02f0cc9e4012b15e96b2ccff33c5 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 5 Mar 2022 17:33:50 +0100 Subject: [PATCH 3/5] new time_init() --- src/main.cpp | 6 +++--- src/timekeeper.cpp | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b9176b0c..e84c376a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -471,15 +471,15 @@ void setup() { button_init(HAS_BUTTON); #endif // HAS_BUTTON - // cyclic function interrupts - cyclicTimer.attach(HOMECYCLE, setCyclicIRQ); - // only if we have a timesource we do timesync #if ((HAS_LORA_TIME) || (HAS_GPS) || (HAS_RTC)) time_init(); strcat_P(features, " TIME"); #endif // timesync + // cyclic function interrupts + cyclicTimer.attach(HOMECYCLE, setCyclicIRQ); + // show compiled features ESP_LOGI(TAG, "Features:%s", features); diff --git a/src/timekeeper.cpp b/src/timekeeper.cpp index 3545d915..896f49ec 100644 --- a/src/timekeeper.cpp +++ b/src/timekeeper.cpp @@ -381,13 +381,16 @@ time_t mkgmtime(const struct tm *ptm) { } void time_init(void) { -#if (HAS_LORA_TIME) - timesync_init(); // create loraserver time sync task -#endif - ESP_LOGI(TAG, "Starting time pulse..."); - timepulse_init(); // starts pps and cyclic time sync + #if (defined HAS_IF482 || defined HAS_DCF77) ESP_LOGI(TAG, "Starting clock controller..."); clock_init(); #endif + +#if (HAS_LORA_TIME) + timesync_init(); // create loraserver time sync task +#endif + + ESP_LOGI(TAG, "Starting time pulse..."); + timepulse_init(); // starts pps and cyclic time sync } \ No newline at end of file From 790e18614162ecad2a7c3e0c0240f414034b7990 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 5 Mar 2022 18:09:58 +0100 Subject: [PATCH 4/5] timekeeper.h cleanup --- include/timekeeper.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/timekeeper.h b/include/timekeeper.h index 88d3c8e8..fe4dfb9e 100644 --- a/include/timekeeper.h +++ b/include/timekeeper.h @@ -27,9 +27,6 @@ extern DRAM_ATTR bool TimePulseTick; // 1sec pps flag set by GPS or RTC extern DRAM_ATTR unsigned long lastPPS; extern hw_timer_t *ppsIRQ; -//void IRAM_ATTR CLOCKIRQ(void); -//void IRAM_ATTR GPSIRQ(void); -//void clock_loop(void *pvParameters); void setTimeSyncIRQ(void); void time_init(void); bool timeIsValid(time_t const t); From 01989320e0fa2c523d7eba937f2b679c2af7aeb7 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 5 Mar 2022 18:10:35 +0100 Subject: [PATCH 5/5] rtctime.cpp: fix crash until repair --- src/rtctime.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rtctime.cpp b/src/rtctime.cpp index e0142d45..50280d3b 100644 --- a/src/rtctime.cpp +++ b/src/rtctime.cpp @@ -65,6 +65,7 @@ time_t get_rtctime(uint16_t *msec) { RtcDateTime tt = Rtc.GetDateTime(); t = tt.Epoch32Time(); // sec2000 -> epoch } + /* #ifdef RTC_INT // adjust time to top of next second by waiting TimePulseTick to flip bool lastTick = TimePulseTick; @@ -72,6 +73,7 @@ time_t get_rtctime(uint16_t *msec) { }; t++; #endif +*/ return t; } // get_rtctime()