replace delete in EInkDynamicDisplay.{cpp,h} with std::unique_ptr (#9643)
Is part of the unique_ptr modernization effort.
This commit is contained in:
@@ -10,7 +10,7 @@ EInkDynamicDisplay::EInkDynamicDisplay(uint8_t address, int sda, int scl, OLEDDI
|
|||||||
{
|
{
|
||||||
// If tracking ghost pixels, grab memory
|
// If tracking ghost pixels, grab memory
|
||||||
#ifdef EINK_LIMIT_GHOSTING_PX
|
#ifdef EINK_LIMIT_GHOSTING_PX
|
||||||
dirtyPixels = new uint8_t[EInkDisplay::displayBufferSize](); // Init with zeros
|
dirtyPixels = std::unique_ptr<uint8_t[]>(new uint8_t[EInkDisplay::displayBufferSize]()); // Init with zeros
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ EInkDynamicDisplay::~EInkDynamicDisplay()
|
|||||||
{
|
{
|
||||||
// If we were tracking ghost pixels, free the memory
|
// If we were tracking ghost pixels, free the memory
|
||||||
#ifdef EINK_LIMIT_GHOSTING_PX
|
#ifdef EINK_LIMIT_GHOSTING_PX
|
||||||
delete[] dirtyPixels;
|
dirtyPixels = nullptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,7 +454,7 @@ void EInkDynamicDisplay::checkExcessiveGhosting()
|
|||||||
void EInkDynamicDisplay::resetGhostPixelTracking()
|
void EInkDynamicDisplay::resetGhostPixelTracking()
|
||||||
{
|
{
|
||||||
// Copy the current frame into dirtyPixels[] from the display buffer
|
// Copy the current frame into dirtyPixels[] from the display buffer
|
||||||
memcpy(dirtyPixels, EInkDisplay::buffer, EInkDisplay::displayBufferSize);
|
memcpy(dirtyPixels.get(), EInkDisplay::buffer, EInkDisplay::displayBufferSize);
|
||||||
}
|
}
|
||||||
#endif // EINK_LIMIT_GHOSTING_PX
|
#endif // EINK_LIMIT_GHOSTING_PX
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#if defined(USE_EINK) && defined(USE_EINK_DYNAMICDISPLAY)
|
#if defined(USE_EINK) && defined(USE_EINK_DYNAMICDISPLAY)
|
||||||
|
|
||||||
@@ -116,11 +117,11 @@ class EInkDynamicDisplay : public EInkDisplay, protected concurrency::NotifiedWo
|
|||||||
// Optional - track ghosting, pixel by pixel
|
// Optional - track ghosting, pixel by pixel
|
||||||
// May 2024: no longer used by any display. Kept for possible future use.
|
// May 2024: no longer used by any display. Kept for possible future use.
|
||||||
#ifdef EINK_LIMIT_GHOSTING_PX
|
#ifdef EINK_LIMIT_GHOSTING_PX
|
||||||
void countGhostPixels(); // Count any pixels which have moved from black to white since last full-refresh
|
void countGhostPixels(); // Count any pixels which have moved from black to white since last full-refresh
|
||||||
void checkExcessiveGhosting(); // Check if ghosting exceeds defined limit
|
void checkExcessiveGhosting(); // Check if ghosting exceeds defined limit
|
||||||
void resetGhostPixelTracking(); // Clear the dirty pixels array. Call when full-refresh cleans the display.
|
void resetGhostPixelTracking(); // Clear the dirty pixels array. Call when full-refresh cleans the display.
|
||||||
uint8_t *dirtyPixels; // Any pixels that have been black since last full-refresh (dynamically allocated mem)
|
std::unique_ptr<uint8_t[]> dirtyPixels; // Any pixels that have been black since last full-refresh (dynamically allocated mem)
|
||||||
uint32_t ghostPixelCount = 0; // Number of pixels with problematic ghosting. Retained here for LOG_DEBUG use
|
uint32_t ghostPixelCount = 0; // Number of pixels with problematic ghosting. Retained here for LOG_DEBUG use
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Conditional - async full refresh - only with modified meshtastic/GxEPD2
|
// Conditional - async full refresh - only with modified meshtastic/GxEPD2
|
||||||
|
|||||||
Reference in New Issue
Block a user