Removed all the deepsleep code since there will be no battery operation.

Sat, 23 Nov 2019 22:31:49 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 23 Nov 2019 22:31:49 +0100
changeset 38
46e2c385e9de
parent 37
358bbd5b608e
child 39
c3fcc599a119

Removed all the deepsleep code since there will be no battery operation.

main/co2meter.c file | annotate | diff | comparison | revisions
main/config.h file | annotate | diff | comparison | revisions
main/task_user.c file | annotate | diff | comparison | revisions
main/task_user.h file | annotate | diff | comparison | revisions
--- a/main/co2meter.c	Sat Nov 23 21:43:14 2019 +0100
+++ b/main/co2meter.c	Sat Nov 23 22:31:49 2019 +0100
@@ -10,12 +10,7 @@
 
 const esp_app_desc_t                    *app_desc = NULL;               ///< Application description
 int					Main_Loop1 = ML1_INIT;		///< Loop 1 init
-bool                            	System_TimeOk = false;          ///< System time status
-time_t                          	now;                            ///< Current time
-struct tm                       	timeinfo;                       ///< Current time structure
-char                            	strftime_buf[64];               ///< Time buffer
 int					num_sensors = 0;		///< Detected DS18B20 sensors
-static RTC_DATA_ATTR struct timeval	sleep_enter_time;
 static TaskHandle_t			xTaskDS18B20 = NULL;
 static TaskHandle_t			xTaskADC = NULL;
 static TaskHandle_t			xTaskWifi = NULL;
@@ -37,39 +32,15 @@
 
 void app_main()
 {
-    struct timeval	now;
-    gettimeofday(&now, NULL);
-    int			sleep_time_ms = (now.tv_sec - sleep_enter_time.tv_sec) * 1000 + (now.tv_usec - sleep_enter_time.tv_usec) / 1000;
     esp_err_t           ret;
 
     Main_Loop1 = ML1_INIT;
     app_desc = esp_ota_get_app_description();
-    /* event handler and event group for the user interface */
+    /*
+     * event handler and event group for the user interface
+     */
     xEventGroupUser = xEventGroupCreate();
-
-    switch (esp_sleep_get_wakeup_cause()) {
-        case ESP_SLEEP_WAKEUP_EXT1: {
-	    ESP_LOGI(TAG, "Starting from deep sleep, Rotary switch pressed");
-	    user_wakeup();
-            break;
-        }
-        case ESP_SLEEP_WAKEUP_TIMER: {
-	    ESP_LOGI(TAG, "Starting from deep sleep, timer wakeup after %dms", sleep_time_ms);
-            break;
-        }
-        case ESP_SLEEP_WAKEUP_UNDEFINED:
-        default:
-            ESP_LOGI(TAG, "Starting from hard reset");
-	    user_cold();
-    }
-
-    const int wakeup_time_sec = 55;
-    ESP_LOGI(TAG, "Enabling timer wakeup, %ds", wakeup_time_sec);
-    esp_sleep_enable_timer_wakeup(wakeup_time_sec * 1000000);
-    const uint64_t ext_wakeup_pin_1_mask = 1ULL << ROT_ENC_SW_GPIO;
-
-    ESP_LOGI(TAG, "Enabling EXT1 wakeup on pin GPIO%d", ROT_ENC_SW_GPIO);
-    esp_sleep_enable_ext1_wakeup(ext_wakeup_pin_1_mask, ESP_EXT1_WAKEUP_ALL_LOW);
+    user_cold();
 
     /*
      * Initialize NVS
@@ -296,22 +267,12 @@
 		    break;
 
 		case ML1_DONE:
+		    /* Wait here until the timer resets the loop */
 		    break;
 	    }
-
-	    if (Main_Loop1 == ML1_DONE && ! user_busy())
-	    	break;
-
 	    vTaskDelay(10 / portTICK_PERIOD_MS);
 	}
 
-	ESP_LOGI(TAG, "Entering deep sleep");
-    	gettimeofday(&sleep_enter_time, NULL);
-	esp_deep_sleep_start();
-
-//	ESP_LOGI(TAG, "Do nothing loop");
-//	vTaskDelay(55000 / portTICK_PERIOD_MS);
-
 	Main_Loop1 = ML1_INIT;
     }
 }
--- a/main/config.h	Sat Nov 23 21:43:14 2019 +0100
+++ b/main/config.h	Sat Nov 23 22:31:49 2019 +0100
@@ -30,7 +30,6 @@
 #include "soc/sens_periph.h"
 #include "soc/rtc.h"
 #include "esp_adc_cal.h"
-#include "esp_sleep.h"
 #include "esp_log.h"
 #include "esp_spiffs.h"
 #include "esp_vfs.h"
@@ -43,7 +42,6 @@
 #include "esp_http_client.h"
 #include "nvs.h"
 #include "nvs_flash.h"
-#include "lwip/apps/sntp.h"
 #include "lwip/sockets.h"
 #include "lwip/dns.h"
 #include "lwip/netdb.h"
--- a/main/task_user.c	Sat Nov 23 21:43:14 2019 +0100
+++ b/main/task_user.c	Sat Nov 23 22:31:49 2019 +0100
@@ -85,13 +85,6 @@
 
 
 
-void user_wakeup()
-{
-    xEventGroupSetBits(xEventGroupUser, TASK_USER_WAKEUP);
-}
-
-
-
 bool user_busy(void)
 {
     if (xEventGroupGetBits(xEventGroupUser) & TASK_USER_BUSY)
@@ -101,7 +94,6 @@
 
 
 
-
 /**
  * @brief Get a keyboard character from the rotary encoder.
  * @param curkey The referenced value if the key being edited.
@@ -681,6 +673,9 @@
 		} else if (gpio_get_level(io_num) == 1) {
 		    PushDuration = (esp_timer_get_time() - pushed) / 1000;
 		    ESP_LOGI(TAG, "GPIO rotary button intr, val: %d time: %d", gpio_get_level(io_num), PushDuration);
+		    if (! user_busy()) {
+			xEventGroupSetBits(xEventGroupUser, TASK_USER_WAKEUP);
+		    }
 		}
 	    } else {
             	ESP_LOGE(TAG, "GPIO[%d] unknown intr, val: %d", io_num, gpio_get_level(io_num));
--- a/main/task_user.h	Sat Nov 23 21:43:14 2019 +0100
+++ b/main/task_user.h	Sat Nov 23 22:31:49 2019 +0100
@@ -28,12 +28,6 @@
 
 
 /**
- * @brief Called after wakeup by the user.
- */
-void user_wakeup(void);
-
-
-/**
  * @brief Refresh screens that are in focus.
  */
 void user_refresh(void);

mercurial