Files
esphome/esphome/components/split_buffer/split_buffer.h
Jesse Hills 2fac813f18 [epaper_spi] New epaper component (#10462)
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Tudor Sandu <tm.sandu@gmail.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2025-10-08 21:11:06 +13:00

41 lines
944 B
C++

#pragma once
#include <cstdint>
#include <cstdlib>
namespace esphome::split_buffer {
class SplitBuffer {
public:
SplitBuffer() = default;
~SplitBuffer();
// Initialize the buffer with the desired total length
bool init(size_t total_length);
// Free all allocated buffers
void free();
// Access operators
uint8_t &operator[](size_t index);
const uint8_t &operator[](size_t index) 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; }
private:
uint8_t **buffers_{nullptr};
size_t buffer_count_{0};
size_t buffer_size_{0};
size_t total_length_{0};
};
} // namespace esphome::split_buffer