From 4247c9fe7d25c921fbfc73fc50e849c8780e7ad6 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 29 Aug 2023 16:07:56 +1000 Subject: store the screen brightness in nvs --- src/tasks/tasks.cpp | 21 +++++++++++++++++++++ src/tasks/tasks.hpp | 1 + 2 files changed, 22 insertions(+) (limited to 'src/tasks') diff --git a/src/tasks/tasks.cpp b/src/tasks/tasks.cpp index 493d6ba9..f7dc0279 100644 --- a/src/tasks/tasks.cpp +++ b/src/tasks/tasks.cpp @@ -45,6 +45,10 @@ template <> auto Name() -> std::string { return "DB_BG"; } +template <> +auto Name() -> std::string { + return "NVS"; +} template auto AllocateStack() -> cpp::span; @@ -102,6 +106,13 @@ auto AllocateStack() -> cpp::span { return {static_cast(heap_caps_malloc(size, MALLOC_CAP_SPIRAM)), size}; } +template <> +auto AllocateStack() -> cpp::span { + std::size_t size = 2 * 1024; + return {static_cast( + heap_caps_malloc(size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)), + size}; +} // 2048 bytes in internal ram // 302 KiB in external ram. @@ -113,6 +124,12 @@ auto AllocateStack() -> cpp::span { template auto Priority() -> UBaseType_t; +// NVS writing requires suspending one of our cores, and disabling tasks with +// their stacks in PSRAM. Get it over and done with as soon as possible. +template <> +auto Priority() -> UBaseType_t { + return 13; +} // Realtime audio is the entire point of this device, so give this task the // highest priority. template <> @@ -171,6 +188,10 @@ template <> auto WorkerQueueSize() -> std::size_t { return 2; } +template <> +auto WorkerQueueSize() -> std::size_t { + return 2; +} auto PersistentMain(void* fn) -> void { auto* function = reinterpret_cast*>(fn); diff --git a/src/tasks/tasks.hpp b/src/tasks/tasks.hpp index a0c201d5..17836795 100644 --- a/src/tasks/tasks.hpp +++ b/src/tasks/tasks.hpp @@ -42,6 +42,7 @@ enum class Type { kDatabase, // Task for internal database operations kDatabaseBackground, + kNvsWriter, }; template -- cgit v1.2.3