Battery, EPD, and SD support for m5paper
Also hide button hints
This commit is contained in:
@@ -18,6 +18,13 @@
|
||||
#include "settings/SettingsActivity.h"
|
||||
#include "util/FullScreenMessageActivity.h"
|
||||
|
||||
// taskENTER_CRITICAL needs a real spinlock on dual-core targets (classic ESP32,
|
||||
// e.g. M5Paper). On the single-core ESP32-C3 a nullptr mux was tolerated, but
|
||||
// the dual-core port acquires an inter-core spinlock and asserts on a null
|
||||
// pointer (spinlock_acquire, spinlock.h:84). One shared spinlock guards the
|
||||
// short waitingTaskHandle critical sections below.
|
||||
static portMUX_TYPE activityMux = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
void ActivityManager::begin() {
|
||||
xTaskCreate(&renderTaskTrampoline, "ActivityManagerRender",
|
||||
8192, // Stack size
|
||||
@@ -45,10 +52,10 @@ void ActivityManager::renderTaskLoop() {
|
||||
}
|
||||
// Notify any task blocked in requestUpdateAndWait() that the render is done.
|
||||
TaskHandle_t waiter = nullptr;
|
||||
taskENTER_CRITICAL(nullptr);
|
||||
taskENTER_CRITICAL(&activityMux);
|
||||
waiter = waitingTaskHandle;
|
||||
waitingTaskHandle = nullptr;
|
||||
taskEXIT_CRITICAL(nullptr);
|
||||
taskEXIT_CRITICAL(&activityMux);
|
||||
if (waiter) {
|
||||
xTaskNotify(waiter, 1, eIncrement);
|
||||
}
|
||||
@@ -279,7 +286,7 @@ void ActivityManager::requestUpdateAndWait() {
|
||||
}
|
||||
|
||||
// Atomic section to perform checks
|
||||
taskENTER_CRITICAL(nullptr);
|
||||
taskENTER_CRITICAL(&activityMux);
|
||||
auto currTaskHandler = xTaskGetCurrentTaskHandle();
|
||||
auto mutexHolder = xSemaphoreGetMutexHolder(renderingMutex);
|
||||
bool isRenderTask = (currTaskHandler == renderTaskHandle);
|
||||
@@ -288,7 +295,7 @@ void ActivityManager::requestUpdateAndWait() {
|
||||
if (!alreadyWaiting && !isRenderTask && !holdingRenderLock) {
|
||||
waitingTaskHandle = currTaskHandler;
|
||||
}
|
||||
taskEXIT_CRITICAL(nullptr);
|
||||
taskEXIT_CRITICAL(&activityMux);
|
||||
|
||||
// Render task cannot call requestUpdateAndWait() or it will cause a deadlock
|
||||
assert(!isRenderTask && "Render task cannot call requestUpdateAndWait()");
|
||||
|
||||
Reference in New Issue
Block a user