[epaper_spi] Refactoring (#11540)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2025-11-04 10:45:32 +13:00
1 parent 9c7cb30ae5
commit 8aa8bb8f98
14 files changed
+619 -344

No files matched your search

@@ -4,7 +4,13 @@
#include <cstdlib>
namespace esphome::split_buffer {
/**
* A SplitBuffer allocates a large memory buffer potentially as multiple smaller buffers
* to facilitate allocation of large buffers on devices with fragmented memory spaces.
* Each sub-buffer is the same size, except for the last one which may be smaller.
* Standard array indexing using `[]` is possible on the buffer, but, since the buffer may not be contiguous in memory,
* there is no easy way to access the buffer as a single array, i.e. no `.data()` access like a vector.
*/
class SplitBuffer {
public:
SplitBuffer() = default;
@@ -19,13 +25,13 @@ class SplitBuffer {
// Access operators
uint8_t &operator[](size_t index);
const uint8_t &operator[](size_t index) const;
void fill(uint8_t value) const;
// Get the total length
size_t size() const { return this->total_length_; }
// Get buffer information
size_t get_buffer_count() const { return this->buffer_count_; }
size_t get_buffer_size() const { return this->buffer_size_; }
// Check if successfully initialized
bool is_valid() const { return this->buffers_ != nullptr && this->buffer_count_ > 0; }