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 16e2fcf..0d457cf 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/BeaconScanner.cpp b/src/BeaconScanner.cpp index 9a10b73..be18710 100644 --- a/src/BeaconScanner.cpp +++ b/src/BeaconScanner.cpp @@ -225,53 +225,56 @@ void printAllowedIds() bool loadBeaconSettings() { - Serial.println("laodSettings"); - File file = LittleFS.open("/beacons.json", "r"); - if (!file) + Serial.println("loadSettings"); + if (LittleFS.exists("/beacons.json")) { - return false; - } - DynamicJsonDocument doc(128); - DeserializationError error = deserializeJson(doc, file); - if (error) - { - Serial.println(F("Failed to read beacon settings")); - return false; - } - - if (doc.containsKey("room")) - { - room = doc["room"].as(); - Serial.println(room); - } - else - { - return false; - } - - if (doc.containsKey("trigger_distance")) - { - triggerDistance = doc["trigger_distance"].as(); - Serial.println(triggerDistance); - } - else - { - return false; - } - - if (doc.containsKey("allowed_ids")) - { - JsonArray allowedIdsJsonArray = doc["allowed_ids"]; - for (const char *id : allowedIdsJsonArray) + File file = LittleFS.open("/beacons.json", "r"); + DynamicJsonDocument doc(128); + DeserializationError error = deserializeJson(doc, file); + if (error) { - allowedIds.push_back(String(id)); + Serial.println(F("Failed to read beacon settings")); + return false; } - printAllowedIds(); - } - return true; - file.close(); -} + if (doc.containsKey("room")) + { + room = doc["room"].as(); + Serial.println(room); + } + else + { + return false; + } + + if (doc.containsKey("trigger_distance")) + { + triggerDistance = doc["trigger_distance"].as(); + Serial.println(triggerDistance); + } + else + { + return false; + } + + if (doc.containsKey("allowed_ids")) + { + JsonArray allowedIdsJsonArray = doc["allowed_ids"]; + for (const char *id : allowedIdsJsonArray) + { + allowedIds.push_back(String(id)); + } + printAllowedIds(); + } + + return true; + file.close(); + } + else + { + return false; + } + } void BeaconScanner_::setup() { diff --git a/src/DisplayManager.cpp b/src/DisplayManager.cpp index fd6d5a6..56ec7c2 100644 --- a/src/DisplayManager.cpp +++ b/src/DisplayManager.cpp @@ -31,7 +31,6 @@ GifPlayer gif; uint16_t gifX, gifY; CRGB leds[MATRIX_WIDTH * MATRIX_HEIGHT]; -// Awtrix Big / Ulanzi FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(leds, 8, 8, 4, 1, NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_ROWS + NEO_MATRIX_PROGRESSIVE); MatrixDisplayUi *ui = new MatrixDisplayUi(matrix); diff --git a/src/Globals.cpp b/src/Globals.cpp index b5f3ed5..938a373 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(); } } @@ -90,7 +95,6 @@ void loadSettings() #endif SOUND_ACTIVE = Settings.getBool("SOUND", true); #ifndef ULANZI - // Settings.putUInt("VOL", VOLUME_PERCENT); VOLUME_PERCENT = Settings.getUInt("VOL", 50); VOLUME = map(VOLUME_PERCENT, 0, 100, 0, 30); #endif @@ -199,8 +203,11 @@ 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; long RECEIVED_MESSAGES; \ No newline at end of file diff --git a/src/Globals.h b/src/Globals.h index b811f1b..5a4985c 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; extern long RECEIVED_MESSAGES; diff --git a/src/PeripheryManager.cpp b/src/PeripheryManager.cpp index 1e73d43..7cc2572 100644 --- a/src/PeripheryManager.cpp +++ b/src/PeripheryManager.cpp @@ -93,13 +93,12 @@ PeripheryManager_ &PeripheryManager = PeripheryManager.getInstance(); void left_button_pressed() { -#ifdef AWTRIX_UPGRADE +#ifndef ULANZI PeripheryManager.playFromFile(DFMINI_MP3_CLICK); #endif - if (AP_MODE) { -#ifdef AWTRIX_UPGRADE +#ifndef ULANZI --MATRIX_LAYOUT; if (MATRIX_LAYOUT < 0) MATRIX_LAYOUT = 2; @@ -116,12 +115,12 @@ void left_button_pressed() void right_button_pressed() { -#ifdef AWTRIX_UPGRADE +#ifndef ULANZI PeripheryManager.playFromFile(DFMINI_MP3_CLICK); #endif if (AP_MODE) { -#ifdef AWTRIX_UPGRADE +#ifndef ULANZI ++MATRIX_LAYOUT; if (MATRIX_LAYOUT > 2) MATRIX_LAYOUT = 0; @@ -138,7 +137,7 @@ void right_button_pressed() void select_button_pressed() { -#ifdef AWTRIX_UPGRADE +#ifndef ULANZI PeripheryManager.playFromFile(DFMINI_MP3_CLICK); #endif DisplayManager.selectButton();