From c2cdbc00e07e68a29da9dfd15002f285af3deb03 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Thu, 4 Jul 2019 12:19:50 +0200 Subject: [PATCH] move sleep commands around --- src/main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fdf5c39..eeb7089 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -133,8 +133,6 @@ unsigned long rtcMillis() { void ICACHE_RAM_ATTR fpm_wakup_cb_func1(void) { //gpio_pin_wakeup_disable(); //ESP.wdtFeed(); - //wifi_fpm_do_wakeup(); - wifi_fpm_close(); geiger_counts++; } @@ -148,8 +146,12 @@ void inline lightsleep() { PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U,FUNC_GPIO13); // PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U,FUNC_GPIO13); gpio_pin_wakeup_enable(GPIO_ID_PIN(GEIGER_PIN), GPIO_PIN_INTR_LOLEVEL); wifi_fpm_set_wakeup_cb(fpm_wakup_cb_func1); + Serial.flush(); wifi_fpm_do_sleep(0xFFFFFFF); // Sleep for longest possible time // this does not work: (uint32_t)postingInterval*1000 - //delay(500); + delay(1); // go to sleep now + DEBUG_MSG("woken\n"); + //wifi_fpm_do_wakeup(); + wifi_fpm_close(); } void ICACHE_FLASH_ATTR getValuesJSON(char* buffer, const size_t buf_len, int format) { @@ -462,8 +464,8 @@ void loop() { geiger_previousMillis = rtcMillis(); geiger_counts = 0; } - DEBUG_MSG("sleeping now... (%u)\n", currentMillis); DEBUG_MSG("heap: %d\n", ESP.getFreeHeap()); + DEBUG_MSG("sleeping now... (%u)\n", currentMillis); delay(10); detachInterrupt(digitalPinToInterrupt(GEIGER_PIN));