Changes in the main timing loop and corrected the loop time.

Tue, 03 Oct 2023 19:43:22 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 03 Oct 2023 19:43:22 +0200
changeset 78
e03d729aecb8
parent 77
15dc572a7fcb
child 79
332e85569339

Changes in the main timing loop and corrected the loop time.

main/co2meter.c file | annotate | diff | comparison | revisions
main/task_user.c file | annotate | diff | comparison | revisions
main/updates.c file | annotate | diff | comparison | revisions
--- a/main/co2meter.c	Tue Oct 03 17:24:06 2023 +0200
+++ b/main/co2meter.c	Tue Oct 03 19:43:22 2023 +0200
@@ -29,7 +29,7 @@
 extern bool				_wifi_ScanDone;
 extern int8_t				_wifi_RSSI;
 extern int				count_pub;			///< Published MQTT messages in transit
-extern uint32_t				AlarmTimer;			///< Alarm timer
+extern uint32_t				LoopTimer;			///< Loop timer
 extern uint32_t				err_connect;			///< Connect error counter
 
 char					hostname[32];
@@ -171,7 +171,7 @@
 		    Main_Loop1 = ML1_CONNECT;
 		    request_ds18b20();
 		    request_adc();
-		    AlarmTimer = 30 * 100;
+		    LoopTimer = MAINLOOP_TIMER;
 		    if (! ready_WiFi()) { /* If WiFi was lost, try a new connection */
 			ESP_LOGI(TAG, "Try WiFi restore");
 			request_WiFi();
@@ -315,15 +315,9 @@
 
 		case ML1_DONE:
 		    /* Wait here until the timer resets the loop */
-		    if (AlarmTimer == 0) {
-                        Main_Loop1 = ML1_INIT;
-                        ESP_LOGI(TAG, "Loop => ML1_INIT");
-                    }
 		    break;
 	    }
 	    vTaskDelay(10 / portTICK_PERIOD_MS);
-	    if (AlarmTimer > 0)
-                AlarmTimer--;
 	}
 
 	Main_Loop1 = ML1_INIT;
--- a/main/task_user.c	Tue Oct 03 17:24:06 2023 +0200
+++ b/main/task_user.c	Tue Oct 03 19:43:22 2023 +0200
@@ -12,7 +12,7 @@
 esp_timer_handle_t			timerHandle;			///< Seconds timer
 uint32_t				SecsCount = 0;			///< Seconds counter
 uint32_t				UserTimer = 0;                  ///< User inactive timeout
-uint32_t				AlarmTimer = 0;			///< Alarm timer
+uint32_t				LoopTimer = 0;			///< Alarm timer
 int					Main_Loop2 = -1;		///< Effective menu
 int					New_Loop2 = ML2_INIT;		///< New menu
 int					SubMenu = 0;			///< Submenu number
@@ -83,14 +83,13 @@
 	UserTimer--;
     }
 
-    if (AlarmTimer == 1) {
+    if (LoopTimer == 1) {
 	ESP_LOGI(TAG, "Alarm Timer timeout");
 	Main_Loop1 = ML1_INIT;
-	err_alarm++;
     }
 
-    if (AlarmTimer) {
-	AlarmTimer--;
+    if (LoopTimer) {
+	LoopTimer--;
     }
 }
 
--- a/main/updates.c	Tue Oct 03 17:24:06 2023 +0200
+++ b/main/updates.c	Tue Oct 03 19:43:22 2023 +0200
@@ -14,7 +14,7 @@
 
 extern u8g2_t			u8g2;			///< Structure for the display.
 extern int			Main_Loop1;
-extern uint32_t			AlarmTimer;
+extern uint32_t			LoopTimer;
 
 
 static void http_cleanup(esp_http_client_handle_t client)
@@ -37,7 +37,7 @@
 
     ESP_LOGI(TAG, "Update begin");
     update_running = 1;
-    AlarmTimer = 0;
+    LoopTimer = 0;
     screen_updating("Stop meten", NULL);
 
     for (;;) {

mercurial