bolar_2 backup

This commit is contained in:
2026-11-27 16:38:11 +08:00
commit e96d6d19df
305 changed files with 43350 additions and 0 deletions

33
main/core/psram_object.h Normal file
View File

@@ -0,0 +1,33 @@
#pragma once
#include <memory>
#include <new>
#include <esp_heap_caps.h>
namespace borla {
template <typename T>
struct PsramObjectDeleter {
void operator()(T* object) const
{
if (object != nullptr) {
object->~T();
heap_caps_free(object);
}
}
};
template <typename T>
std::unique_ptr<T, PsramObjectDeleter<T>> MakePsramObject()
{
void* memory = heap_caps_malloc(
sizeof(T), MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
if (memory == nullptr) {
return {};
}
return std::unique_ptr<T, PsramObjectDeleter<T>>(
new (memory) T());
}
} // namespace borla