From 91067e9948dc20672269525b58b4a41618239786 Mon Sep 17 00:00:00 2001 From: estshorter <1430311+estshorter@users.noreply.github.com> Date: Wed, 3 Feb 2021 21:47:28 +0900 Subject: [PATCH 1/2] Add a destructor to M5EPD --- src/M5EPD.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/M5EPD.h b/src/M5EPD.h index 9fc8389..6ab9125 100644 --- a/src/M5EPD.h +++ b/src/M5EPD.h @@ -39,6 +39,11 @@ class M5EPD { public: M5EPD(); + ~M5EPD() + { + if (_adc_chars != nullptr) + free(_adc_chars); + } void begin(bool touchEnable = true, bool SDEnable = true, bool SerialEnable = true, bool BatteryADCEnable = true, bool I2CEnable = false); void update(); void enableEXTPower() { digitalWrite(M5EPD_EXT_PWR_EN_PIN, 1); } @@ -52,9 +57,9 @@ class M5EPD uint32_t getBatteryVoltage(); void shutdown(); - int shutdown( int seconds ); - int shutdown( const rtc_time_t &RTC_TimeStruct); - int shutdown( const rtc_date_t &RTC_DateStruct, const rtc_time_t &RTC_TimeStruct); + int shutdown(int seconds); + int shutdown(const rtc_time_t &RTC_TimeStruct); + int shutdown(const rtc_date_t &RTC_DateStruct, const rtc_time_t &RTC_TimeStruct); Button BtnL = Button(M5EPD_KEY_LEFT_PIN, true, 10); Button BtnP = Button(M5EPD_KEY_PUSH_PIN, true, 10); From 3c90e8993eff32711cdf654c0512a39f4cc3a7a7 Mon Sep 17 00:00:00 2001 From: estshorter <1430311+estshorter@users.noreply.github.com> Date: Wed, 3 Feb 2021 21:55:56 +0900 Subject: [PATCH 2/2] Initialize _adc_chars with nullptr --- src/M5EPD.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/M5EPD.cpp b/src/M5EPD.cpp index 23aca19..6e47718 100644 --- a/src/M5EPD.cpp +++ b/src/M5EPD.cpp @@ -7,11 +7,8 @@ #define SCALE 0.5//0.78571429 #define ADC_FILTER_SAMPLE 8 - -M5EPD::M5EPD() +M5EPD::M5EPD() : _is_adc_start(false), _isInited(false), _adc_chars(nullptr) { - _isInited = false; - _is_adc_start = false; } /** @brief Initialize the power supply, screen and other peripherals