main/co2meter.c

changeset 38
46e2c385e9de
parent 37
358bbd5b608e
child 47
1ab1f4a8c328
--- 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;
     }
 }

mercurial