CSV file save on SPIFF filesystem, 10MB on internal flash

This commit is contained in:
Emanuele Trabattoni
2026-04-07 13:21:27 +02:00
parent f36cb96f21
commit 668b590d7c
11 changed files with 1032 additions and 27 deletions
+30
View File
@@ -0,0 +1,30 @@
#pragma once
#include <vector>
#include "esp_heap_caps.h"
// Allocator custom per PSRAM
template <typename T>
struct PSRAMAllocator {
using value_type = T;
PSRAMAllocator() noexcept {}
template <typename U>
PSRAMAllocator(const PSRAMAllocator<U>&) noexcept {}
T* allocate(std::size_t n) {
void* ptr = heap_caps_malloc(n * sizeof(T), MALLOC_CAP_SPIRAM);
if (!ptr) {
throw std::bad_alloc();
}
return static_cast<T*>(ptr);
}
void deallocate(T* p, std::size_t) noexcept {
heap_caps_free(p);
}
};
template <typename T>
using PSRAMVector = std::vector<T, PSRAMAllocator<T>>;