From 138e4d668ad36561274f63768558d0451df94a85 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Mon, 18 Jun 2018 10:38:13 +0200 Subject: [PATCH] add lightsleep functions --- src/main.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index b7ead25..496dc59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -118,6 +118,28 @@ unsigned long rtcMillis() { return ((uint64_t)(rtc_t*(uint64_t)cal) >> 12)/1000; } +void fpm_wakup_cb_func1(void) { + //gpio_pin_wakeup_disable(); + //ESP.wdtFeed(); + //wifi_fpm_do_wakeup(); + wifi_fpm_close(); + //geiger_counts++; +} + +void lightsleep() { + ESP.wdtFeed(); + wifi_station_disconnect(); + wifi_set_opmode(NULL_MODE); + wifi_fpm_set_sleep_type(LIGHT_SLEEP_T); + wifi_fpm_open(); // Enables force sleep + GPIO_DIS_OUTPUT(GPIO_ID_PIN(GEIGER_PIN)); + 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); + wifi_fpm_do_sleep(0xFFFFFFF); // Sleep for longest possible time + //delay(1); +} + void ICACHE_FLASH_ATTR sendValues() { sd.temperature = dht.readTemperature(); sd.humidity = dht.readHumidity();