Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.

Tue, 26 Nov 2019 11:55:46 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 26 Nov 2019 11:55:46 +0100
changeset 43
70c99c2084dc
parent 42
22a0f9810561
child 44
e52d11b8f252

Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active.

CMakeLists.txt file | annotate | diff | comparison | revisions
main/task_user.c file | annotate | diff | comparison | revisions
--- a/CMakeLists.txt	Tue Nov 26 11:20:41 2019 +0100
+++ b/CMakeLists.txt	Tue Nov 26 11:55:46 2019 +0100
@@ -2,7 +2,7 @@
 # in this exact order for cmake to work correctly
 cmake_minimum_required(VERSION 3.5)
 
-set(PROJECT_VER "0.2.0")
+set(PROJECT_VER "0.2.1")
 set(PROJECT_NAME "co2meter")
 
 include($ENV{IDF_PATH}/tools/cmake/project.cmake)
--- a/main/task_user.c	Tue Nov 26 11:20:41 2019 +0100
+++ b/main/task_user.c	Tue Nov 26 11:55:46 2019 +0100
@@ -407,6 +407,7 @@
     w = u8g2_GetUTF8Width(&u8g2, buf);
     u8g2_DrawUTF8(&u8g2, (128 - w) / 2,63, buf);
     u8g2_SendBuffer(&u8g2);
+    u8g2_SetPowerSave(&u8g2, 0); // wake up display
 }
 
 
@@ -815,7 +816,26 @@
         switch (Main_Loop2) {
 	    case ML2_INIT:
                 ESP_LOGI(TAG, "Loop user: Init");
-                New_Loop2 = ML2_USER;
+		New_Loop2 = -1;
+                if (xSemaphoreTake(xSemaphoreUnits, 25) == pdTRUE) {
+		    for (int i = 0; i < 3; i++) {
+                        if (units[i].mode) {
+			    if (New_Loop2 == -1) { // Not selected yet
+				New_Loop2 = i;
+			    } else if (New_Loop2 >= 0) { // One selected
+				New_Loop2 = -2;
+				break; // Multiple units are active
+			    }
+			}
+		    }
+                    xSemaphoreGive(xSemaphoreUnits);
+                } else {
+                    ESP_LOGE(TAG, "menu_change() ML2_INIT lock");
+                }
+		if (New_Loop2 < 0)
+                    New_Loop2 = ML2_USER;
+		else
+		    New_Loop2 += ML2_UNIT1;
                 break;
 
             case ML2_USER:
@@ -1267,7 +1287,6 @@
 	if (uxBits & TASK_USER_WAKEUP) {
 	    ESP_LOGI(TAG, "User task wakeup");
 	    xEventGroupSetBits(xEventGroupUser, TASK_USER_BUSY);
-	    screen_main();
 	    UserTimer = INACTIVITY;
 	    New_Loop2 = ML2_INIT;
 	    Main_Loop2 = -1;

mercurial