From 162808cea73812009c33d1d52af1128746d3795e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Metrich?= <45318189+FredM67@users.noreply.github.com> Date: Sun, 1 Dec 2024 22:05:46 +0100 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 918becfaad3558d07dc034fb94a2b3450a170c25 Author: Frédéric Metrich <45318189+FredM67@users.noreply.github.com> Date: Sun Dec 1 22:03:43 2024 +0100 Fix for old PCBs commit 51a68bb5aaca5b45046675cf011b634a3cca9666 Author: Frédéric Metrich Date: Fri Nov 29 17:58:34 2024 +0100 Refactor code formatting in processing.cpp and utils_display.h for improved readability commit a043d62e3e4be1182f6501d63be9d5c7afb35f13 Author: Frédéric Metrich Date: Fri Nov 29 17:33:37 2024 +0100 Update configuration and pin assignments for improved functionality and clarity --- Mk2_fasterControl_Full/calibration.h | 2 +- Mk2_fasterControl_Full/utils_display.h | 1 - Mk2_fasterControl_Full/utils_oled.h | 43 ++++++++++++++++++++++++-- PVRouter-1-phase.code-workspace | 3 +- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/Mk2_fasterControl_Full/calibration.h b/Mk2_fasterControl_Full/calibration.h index 4e9e52e..7920283 100644 --- a/Mk2_fasterControl_Full/calibration.h +++ b/Mk2_fasterControl_Full/calibration.h @@ -36,7 +36,7 @@ inline constexpr float powerCal_diverted{ 0.0435F }; // for CT2 inline constexpr float f_voltageCal{ 0.8151F }; /**< compared with Sentron PAC 4200 */ -inline constexpr float lpf_gain{ 8 }; /**< setting this to 0 disables this extra processing */ +inline constexpr float lpf_gain{ 0 }; /**< setting this to 0 disables this extra processing */ inline constexpr float alpha{ 0.002 }; //-------------------------------------------------------------------------------------------------- diff --git a/Mk2_fasterControl_Full/utils_display.h b/Mk2_fasterControl_Full/utils_display.h index e9c0087..ffbc35d 100644 --- a/Mk2_fasterControl_Full/utils_display.h +++ b/Mk2_fasterControl_Full/utils_display.h @@ -295,7 +295,6 @@ void configureValueForDisplay(const bool _EDD_isActive, const uint16_t _ValueToD } } - /** * @brief Refreshes the display by updating the active digit and its segments. * diff --git a/Mk2_fasterControl_Full/utils_oled.h b/Mk2_fasterControl_Full/utils_oled.h index 60e7598..080ecf8 100644 --- a/Mk2_fasterControl_Full/utils_oled.h +++ b/Mk2_fasterControl_Full/utils_oled.h @@ -15,6 +15,7 @@ #include #include +#include "type_traits.hpp" #include "FastDivision.h" #include "types.h" @@ -24,9 +25,47 @@ #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) #define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 -U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* reset=*/U8X8_PIN_NONE); /**< The OLED display object */ +/** + * @brief This is a fake class in case there's no OLED display + * + * When declaring a variable with the real OLED class, even it's not used, it is + * loaded and partially initialized. + * This leads to "break" the ADC measurement on old boards and + * consumes memory on any board. + * This is to avoid the use of "#ifdef" in the code to activate/deactivate + * portions of code. + * + */ +class u8x8_fake +{ +public: + u8x8_fake(uint8_t) {} + + bool begin() + { + return true; + } + void clearDisplay() {} + void noInverse() {} + uint8_t getCols() + { + return 0; + } + uint8_t getRows() + { + return 0; + } + + void setFont(const uint8_t *) {} + void drawString(uint8_t, uint8_t, const char *) {} + void drawGlyph(uint8_t, uint8_t, uint8_t) {} + + void drawTile(uint8_t, uint8_t, uint8_t, uint8_t *) {} +}; + +conditional< TYPE_OF_DISPLAY == DisplayType::OLED, U8X8_SSD1306_128X64_NONAME_HW_I2C, u8x8_fake >::type u8x8(/* reset=*/U8X8_PIN_NONE); /**< The OLED display object */ -inline constexpr uint8_t LOGO_WIDTH{ 72 }; /**< The widthof the object, in pixel */ +inline constexpr uint8_t LOGO_WIDTH{ 72 }; /**< The width of the object, in pixel */ inline constexpr uint8_t LOGO_HEIGHT{ 64 }; /**< The Height of the object, in pixel */ const unsigned char logo_xbm[] U8X8_PROGMEM = { diff --git a/PVRouter-1-phase.code-workspace b/PVRouter-1-phase.code-workspace index 8d5b8b5..3518e07 100644 --- a/PVRouter-1-phase.code-workspace +++ b/PVRouter-1-phase.code-workspace @@ -19,7 +19,8 @@ "settings": { "files.associations": { "xtr1common": "cpp", - "new": "cpp" + "new": "cpp", + "initializer_list": "cpp" } } } \ No newline at end of file