Added dev Setting to change decimal places for temperature measurements

This commit is contained in:
Elfish
2023-04-03 16:23:25 +02:00
parent 9f8b8b9a6c
commit acdb78cd76
4 changed files with 24 additions and 7 deletions

View File

@@ -11,5 +11,6 @@ The JSON object has the following properties:
| Key | Type | Description | Default | | 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 | | `uppercase` | boolean | Print every character in uppercase | true |
| `temp_dec_places` | int | Number of decimal places for temperature measurements | 0 |

View File

@@ -188,16 +188,21 @@ void TempApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x,
CURRENT_APP = "Temperature"; CURRENT_APP = "Temperature";
DisplayManager.getInstance().resetTextColor(); DisplayManager.getInstance().resetTextColor();
matrix->drawRGBBitmap(x, y, get_icon(234), 8, 8); 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) if (IS_CELSIUS)
{ {
matrix->print((int)CURRENT_TEMP); matrix->print(CURRENT_TEMP, TEMP_DECIMAL_PLACES);
matrix->print(utf8ascii("°C")); matrix->print(utf8ascii("°C"));
} }
else else
{ {
int tempF = (CURRENT_TEMP * 9 / 5) + 32; double tempF = (CURRENT_TEMP * 9 / 5) + 32;
matrix->print(tempF); matrix->print(tempF, TEMP_DECIMAL_PLACES);
matrix->print(utf8ascii("°F")); matrix->print(utf8ascii("°F"));
} }
} }
@@ -210,8 +215,8 @@ void HumApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x, i
DisplayManager.getInstance().resetTextColor(); DisplayManager.getInstance().resetTextColor();
matrix->drawRGBBitmap(x, y + 1, get_icon(2075), 8, 8); matrix->drawRGBBitmap(x, y + 1, get_icon(2075), 8, 8);
matrix->setCursor(14 + x, 6 + y); matrix->setCursor(14 + x, 6 + y);
int humidity = CURRENT_HUM; // Temperatur ohne Nachkommastellen int humidity = CURRENT_HUM; // Humidity without decimal places
matrix->print(humidity); // Ausgabe der Temperatur matrix->print(humidity); // Output humidity
matrix->print("%"); matrix->print("%");
} }

View File

@@ -61,6 +61,11 @@ void loadDevSettings()
UPPERCASE_LETTERS = doc["uppercase"].as<bool>(); UPPERCASE_LETTERS = doc["uppercase"].as<bool>();
} }
if (doc.containsKey("temp_dec_places"))
{
TEMP_DECIMAL_PLACES = doc["temp_dec_places"].as<int>();
}
file.close(); file.close();
} }
} }
@@ -198,7 +203,10 @@ bool ALARM_ACTIVE;
uint16_t TEXTCOLOR_565 = 0xFFFF; uint16_t TEXTCOLOR_565 = 0xFFFF;
bool SOUND_ACTIVE; bool SOUND_ACTIVE;
String BOOT_SOUND = ""; String BOOT_SOUND = "";
int TEMP_DECIMAL_PLACES = 0;
#ifndef ULANZI
uint8_t VOLUME_PERCENT; uint8_t VOLUME_PERCENT;
uint8_t VOLUME; uint8_t VOLUME;
#endif
int MATRIX_LAYOUT; int MATRIX_LAYOUT;
bool UPDATE_AVAILABLE = false; bool UPDATE_AVAILABLE = false;

View File

@@ -68,8 +68,11 @@ extern bool START_ON_MONDAY;
extern bool IS_CELSIUS; extern bool IS_CELSIUS;
extern bool SOUND_ACTIVE; extern bool SOUND_ACTIVE;
extern String BOOT_SOUND; extern String BOOT_SOUND;
extern int TEMP_DECIMAL_PLACES;
#ifndef ULANZI
extern uint8_t VOLUME_PERCENT; extern uint8_t VOLUME_PERCENT;
extern uint8_t VOLUME; extern uint8_t VOLUME;
#endif
extern int MATRIX_LAYOUT; extern int MATRIX_LAYOUT;
extern bool UPDATE_AVAILABLE; extern bool UPDATE_AVAILABLE;
void loadSettings(); void loadSettings();