From 621d515eff9b27ad5675db0db9af1c50388d2dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20M=C3=BChl?= <31169771+Blueforcer@users.noreply.github.com> Date: Tue, 29 Aug 2023 21:37:01 +0200 Subject: [PATCH] v0.82 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 🔋 Allows to set the battery messurement scale via dev.json - 🪞 Allows to mirror the screen for streaming etc. - Better handling of disabled transistion after Notifications. --- docs/dev.md | 1 + src/Apps.h | 16 ++++++++-------- src/DisplayManager.cpp | 18 +++++++++++++----- src/Globals.cpp | 7 ++++++- src/Globals.h | 2 +- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/docs/dev.md b/docs/dev.md index 1e7119eb..81b413b8 100644 --- a/docs/dev.md +++ b/docs/dev.md @@ -18,6 +18,7 @@ The JSON object has the following properties: | `color_correction` | array of int | Sets the colorcorrection of the matrix | `[255,255,255]` | | `color_temperature` | array of int | Sets the colortemperature of the matrix | `[255,255,255]` | | `rotate_screen` | boolean | Rotates the screen upside down | `false` | +| `mirror_screen` | boolean | Mirrors the screen | `false` | | `temp_dec_places` | integer | Number of decimal places for temperature measurements | `0` | | `sensor_reading` | boolean | Enables or disables the reading of the Temp&Hum sensor | `true` | | `temp_offset` | float | Sets the offset for the internal temperature messurement | `-9` | diff --git a/src/Apps.h b/src/Apps.h index 31217820..a62c8344 100644 --- a/src/Apps.h +++ b/src/Apps.h @@ -473,7 +473,6 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState callEffect(matrix, x, y, ca->effect); } - CURRENT_APP = ca->name; currentCustomApp = name; @@ -600,7 +599,8 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState { DisplayManager.setAutoTransition(true); ca->currentRepeat = 0; - DisplayManager.nextApp(); + if (AUTO_TRANSITION) + DisplayManager.nextApp(); ca->scrollDelay = 0; ca->scrollposition = 9 + ca->textOffset; return; @@ -745,8 +745,6 @@ void NotifyOverlay(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPl notifyFlag = true; } - - if (notifications[0].wakeup && MATRIX_OFF) { DisplayManager.setBrightness(BRIGHTNESS); @@ -764,7 +762,7 @@ void NotifyOverlay(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPl } notifications[0].icon.close(); notifications.erase(notifications.begin()); - + if (notifications[0].wakeup && MATRIX_OFF) { DisplayManager.setBrightness(0); @@ -773,12 +771,14 @@ void NotifyOverlay(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPl if (notifications.empty()) { notifyFlag = false; + if (AUTO_TRANSITION) + DisplayManager.nextApp(); } - DisplayManager.nextApp(); + return; } - // Set current app name + // Set current app name CURRENT_APP = F("Notification"); // Check if notification has an icon @@ -983,7 +983,7 @@ void NotifyOverlay(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPl else { matrix->setTextColor(TextEffect(notifications[0].color, notifications[0].fade, notifications[0].blink)); - + DisplayManager.printText(textX + notifications[0].textOffset, 6, notifications[0].text.c_str(), false, notifications[0].textCase); } } diff --git a/src/DisplayManager.cpp b/src/DisplayManager.cpp index 680cde3a..fe8396be 100644 --- a/src/DisplayManager.cpp +++ b/src/DisplayManager.cpp @@ -1487,20 +1487,16 @@ String DisplayManager_::getStats() #else doc[F("type")] = 1; #endif - doc[LuxKey] = static_cast(CURRENT_LUX); doc[LDRRawKey] = LDR_RAW; - uint32_t freeHeap = ESP.getFreeHeap(); doc[RamKey] = freeHeap; doc[BrightnessKey] = BRIGHTNESS; - if (SENSOR_READING) { doc[TempKey] = static_cast(CURRENT_TEMP); doc[HumKey] = static_cast(CURRENT_HUM); } - doc[UpTimeKey] = PeripheryManager.readUptime(); doc[SignalStrengthKey] = WiFi.RSSI(); doc[MessagesKey] = RECEIVED_MESSAGES; @@ -1509,7 +1505,6 @@ String DisplayManager_::getStats() doc[F("indicator2")] = ui->indicator2State; doc[F("indicator3")] = ui->indicator3State; doc[F("app")] = CURRENT_APP; - // doc[F("freeFlash")] = LittleFS.totalBytes() - LittleFS.usedBytes(); String jsonString; serializeJson(doc, jsonString); return jsonString; @@ -1808,6 +1803,19 @@ void DisplayManager_::gammaCorrection() { leds[i] = applyGamma_video(leds[i], gamma); } + + if (MIRROR_DISPLAY) + { + for (int y = 0; y < MATRIX_HEIGHT; y++) + { + for (int x = 0; x < MATRIX_WIDTH / 2; x++) + { + int index1 = y * MATRIX_WIDTH + x; + int index2 = y * MATRIX_WIDTH + (MATRIX_WIDTH - x - 1); + std::swap(leds[index1], leds[index2]); + } + } + } } void DisplayManager_::sendAppLoop() diff --git a/src/Globals.cpp b/src/Globals.cpp index a2dec021..8bed3de8 100644 --- a/src/Globals.cpp +++ b/src/Globals.cpp @@ -77,6 +77,11 @@ void loadDevSettings() MATRIX_LAYOUT = doc["matrix"]; } + if (doc.containsKey("mirror_screen")) + { + MIRROR_DISPLAY = doc["mirror_screen"].as(); + } + if (doc.containsKey("temp_offset")) { TEMP_OFFSET = doc["temp_offset"]; @@ -351,7 +356,7 @@ bool AUTO_BRIGHTNESS = true; bool UPPERCASE_LETTERS = true; bool AP_MODE; bool MATRIX_OFF; - +bool MIRROR_DISPLAY=false; uint16_t TEXTCOLOR_565; bool SOUND_ACTIVE; String BOOT_SOUND = ""; diff --git a/src/Globals.h b/src/Globals.h index c30efc3b..be11ca75 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -81,7 +81,7 @@ extern bool AUTO_BRIGHTNESS; extern bool AP_MODE; extern bool MATRIX_OFF; extern uint16_t TEXTCOLOR_565; - +extern bool MIRROR_DISPLAY; extern bool AUTO_TRANSITION; extern String TIME_FORMAT; extern String DATE_FORMAT;