# HG changeset patch # User Michiel Broek # Date 1574765746 -3600 # Node ID 70c99c2084dc536c6c979f1f5c59e4cc88abfe88 # Parent 22a0f9810561f0a6365e53c7802e9868ebccb909 Version 0.2.1. When wakeup by user push, select the active unit screen if only one unit is active. diff -r 22a0f9810561 -r 70c99c2084dc CMakeLists.txt --- 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) diff -r 22a0f9810561 -r 70c99c2084dc main/task_user.c --- 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;