3#include "bytestreammemory.h"
5#include "math_macros.h"
9ByteStreamMemory::ByteStreamMemory(uint32_t size_buffer)
10 : mBuffer(size_buffer) {}
12ByteStreamMemory::~ByteStreamMemory() =
default;
14bool ByteStreamMemory::available(
size_t n)
const {
15 return mBuffer.size() >= n;
18size_t ByteStreamMemory::read(uint8_t *dst,
size_t bytesToRead) {
19 if (!available(bytesToRead) || dst ==
nullptr) {
23 size_t actualBytesToRead = MIN(bytesToRead, mBuffer.size());
26 while (bytesRead < actualBytesToRead) {
27 mBuffer.pop_front(&dst[bytesRead]);
34size_t ByteStreamMemory::write(
const uint8_t* src,
size_t n) {
35 if (src ==
nullptr || mBuffer.capacity() == 0) {
40 for (
size_t i = 0; i < n; ++i) {
44 mBuffer.push_back(src[i]);
50size_t ByteStreamMemory::write(
const CRGB* src,
size_t n) {
51 return write(
reinterpret_cast<const uint8_t*
>(src), n * 3);
Representation of an RGB pixel (Red, Green, Blue)