From 539b7088d666033f0ebdf13f69b60bedf02a5bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Metrich?= <45318189+FredM67@users.noreply.github.com> Date: Fri, 31 May 2024 16:39:14 +0200 Subject: [PATCH] Font --- Mk2_3phase_RFdatalog_temp/config.h | 2 +- Mk2_3phase_RFdatalog_temp/main.cpp | 3 +++ Mk2_3phase_RFdatalog_temp/utils.h | 26 ++++++++++++-------------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Mk2_3phase_RFdatalog_temp/config.h b/Mk2_3phase_RFdatalog_temp/config.h index a248ce6..deddfeb 100644 --- a/Mk2_3phase_RFdatalog_temp/config.h +++ b/Mk2_3phase_RFdatalog_temp/config.h @@ -88,7 +88,7 @@ inline constexpr pairForceLoad rg_ForceLoad[NO_OF_DUMPLOADS]{ { -3, 2 } }; /**< inline constexpr int16_t iTemperatureThreshold{ 100 }; /**< the temperature threshold to stop overriding in °C */ -inline constexpr TemperatureSensing temperatureSensing{ 12, +inline constexpr TemperatureSensing temperatureSensing{ 4, { { 0x28, 0xAA, 0x16, 0xA7, 0x16, 0x13, 0x02, 0xDC } } }; /**< list of temperature sensor Addresses */ inline constexpr uint32_t ROTATION_AFTER_CYCLES{ 8UL * 3600UL * SUPPLY_FREQUENCY }; /**< rotates load priorities after this period of inactivity */ diff --git a/Mk2_3phase_RFdatalog_temp/main.cpp b/Mk2_3phase_RFdatalog_temp/main.cpp index 8390a4a..4b4746f 100644 --- a/Mk2_3phase_RFdatalog_temp/main.cpp +++ b/Mk2_3phase_RFdatalog_temp/main.cpp @@ -342,6 +342,9 @@ void setup() tft.initR(INITR_MINI160x80_PLUGIN); // Init ST7735S mini display tft.fillScreen(ST77XX_BLACK); tft.setRotation(3); + tft.setTextWrap(false); + tft.setFont(&FreeSansBold24pt7b); + tft.setTextSize(1); DBUG(F(">>free RAM = ")); DBUGLN(freeRam()); // a useful value to keep an eye on diff --git a/Mk2_3phase_RFdatalog_temp/utils.h b/Mk2_3phase_RFdatalog_temp/utils.h index 5d5c29b..81c8e68 100644 --- a/Mk2_3phase_RFdatalog_temp/utils.h +++ b/Mk2_3phase_RFdatalog_temp/utils.h @@ -24,6 +24,7 @@ #include // Hardware-specific library for ST7735 #include // Hardware-specific library for ST7789 #include +#include #define TFT_CS 10 #define TFT_RST 8 @@ -261,26 +262,12 @@ inline void printForSerialJson() Serial.println(F(")")); } -void testdrawtext(char *text, uint16_t color) -{ - tft.setCursor(0, 0); - tft.setTextColor(color); - tft.setTextWrap(true); - tft.print(text); -} - /** * @brief Prints data logs to the Serial output in text format * */ inline void printForSerialText() { - tft.fillScreen(ST77XX_BLACK); - tft.setCursor(0, 0); - tft.setTextSize(3); - tft.print(tx_data.Vrms_L_x100[0] * 0.01F); - //testdrawtext("35\xF8\x43", ST77XX_WHITE); - uint8_t phase{ 0 }; Serial.print(copyOf_energyInBucket_main * invSUPPLY_FREQUENCY); @@ -318,6 +305,17 @@ inline void printForSerialText() continue; } + tft.fillScreen(ST77XX_BLACK); + + tft.setTextColor(tx_data.temperature_x100[0] > 4500 ? ST77XX_GREEN : ST7735_RED); + tft.setCursor(10, 52); + tft.print(tx_data.temperature_x100[0] * 0.01F, 1); + const auto curr_x = tft.getCursorX(); + const auto curr_y = tft.getCursorY(); + tft.drawCircle(curr_x + 6, curr_y - 28, 4, ST7735_WHITE); + tft.setTextColor(ST7735_WHITE); + tft.print(F(" C")); + Serial.print(F(", T")); Serial.print(idx + 1); Serial.print(F(":"));