From acdb78cd7625bc8f40798331fbb7196a5eca8164 Mon Sep 17 00:00:00 2001 From: Elfish Date: Mon, 3 Apr 2023 16:23:25 +0200 Subject: [PATCH] Added dev Setting to change decimal places for temperature measurements --- docs/dev.md | 3 ++- src/Apps.h | 17 +++++++++++------ src/Globals.cpp | 8 ++++++++ src/Globals.h | 3 +++ 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/docs/dev.md b/docs/dev.md index 861c128..af99160 100644 --- a/docs/dev.md +++ b/docs/dev.md @@ -11,5 +11,6 @@ The JSON object has the following properties: | Key | Type | Description | Default | | --- | ---- | ----------- | ------- | -| `bootsound` | string | Uses a custom melodie from the MELODIES folder | | +| `bootsound` | string | Uses a custom melodie while booting | | | `uppercase` | boolean | Print every character in uppercase | true | +| `temp_dec_places` | int | Number of decimal places for temperature measurements | 0 | diff --git a/src/Apps.h b/src/Apps.h index 63fbe33..487612f 100644 --- a/src/Apps.h +++ b/src/Apps.h @@ -188,16 +188,21 @@ void TempApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x, CURRENT_APP = "Temperature"; DisplayManager.getInstance().resetTextColor(); matrix->drawRGBBitmap(x, y, get_icon(234), 8, 8); - matrix->setCursor(12 + x, 6 + y); + + if (TEMP_DECIMAL_PLACES > 0) + matrix->setCursor(8 + x, 6 + y); + else + matrix->setCursor(12 + x, 6 + y); + if (IS_CELSIUS) { - matrix->print((int)CURRENT_TEMP); + matrix->print(CURRENT_TEMP, TEMP_DECIMAL_PLACES); matrix->print(utf8ascii("°C")); } else { - int tempF = (CURRENT_TEMP * 9 / 5) + 32; - matrix->print(tempF); + double tempF = (CURRENT_TEMP * 9 / 5) + 32; + matrix->print(tempF, TEMP_DECIMAL_PLACES); matrix->print(utf8ascii("°F")); } } @@ -210,8 +215,8 @@ void HumApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x, i DisplayManager.getInstance().resetTextColor(); matrix->drawRGBBitmap(x, y + 1, get_icon(2075), 8, 8); matrix->setCursor(14 + x, 6 + y); - int humidity = CURRENT_HUM; // Temperatur ohne Nachkommastellen - matrix->print(humidity); // Ausgabe der Temperatur + int humidity = CURRENT_HUM; // Humidity without decimal places + matrix->print(humidity); // Output humidity matrix->print("%"); } diff --git a/src/Globals.cpp b/src/Globals.cpp index 22eabc7..625247d 100644 --- a/src/Globals.cpp +++ b/src/Globals.cpp @@ -61,6 +61,11 @@ void loadDevSettings() UPPERCASE_LETTERS = doc["uppercase"].as(); } + if (doc.containsKey("temp_dec_places")) + { + TEMP_DECIMAL_PLACES = doc["temp_dec_places"].as(); + } + file.close(); } } @@ -198,7 +203,10 @@ bool ALARM_ACTIVE; uint16_t TEXTCOLOR_565 = 0xFFFF; bool SOUND_ACTIVE; String BOOT_SOUND = ""; +int TEMP_DECIMAL_PLACES = 0; +#ifndef ULANZI uint8_t VOLUME_PERCENT; uint8_t VOLUME; +#endif int MATRIX_LAYOUT; bool UPDATE_AVAILABLE = false; \ No newline at end of file diff --git a/src/Globals.h b/src/Globals.h index 146baba..81697fd 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -68,8 +68,11 @@ extern bool START_ON_MONDAY; extern bool IS_CELSIUS; extern bool SOUND_ACTIVE; extern String BOOT_SOUND; +extern int TEMP_DECIMAL_PLACES; +#ifndef ULANZI extern uint8_t VOLUME_PERCENT; extern uint8_t VOLUME; +#endif extern int MATRIX_LAYOUT; extern bool UPDATE_AVAILABLE; void loadSettings();