Re implement display

This commit is contained in:
GW_MC
2026-01-26 18:17:39 +08:00
parent abe840b65d
commit 30dfdd630a
12 changed files with 1780 additions and 849 deletions

View File

@@ -1,14 +1,18 @@
#pragma once
#include "freertos/semphr.h"
#include "freertos/portmacro.h"
#include "esp_log.h"
struct SemaphoreGuard {
public:
const SemaphoreHandle_t semaphore;
SemaphoreGuard(SemaphoreHandle_t semaphore) : semaphore(semaphore) { }
portBASE_TYPE take(TickType_t ticks_to_wait = portMAX_DELAY) {
if (this->semaphore == nullptr) {
ESP_LOGE("SemaphoreGuard", "Attempted to take a null semaphore");
return pdFALSE;
}
portBASE_TYPE result = xSemaphoreTake(this->semaphore, ticks_to_wait);
taken = (result == pdTRUE);
return result;
@@ -20,9 +24,26 @@ public:
}
}
// allow move semantics
SemaphoreGuard(SemaphoreGuard&& other) noexcept
: semaphore(other.semaphore), taken(other.taken) {
other.taken = false;
}
SemaphoreGuard& operator=(SemaphoreGuard&& other) noexcept {
if (this != &other) {
// move from other
taken = other.taken;
other.taken = false;
semaphore = other.semaphore;
other.semaphore = nullptr;
}
return *this;
}
private:
// prevent copying
SemaphoreGuard(const SemaphoreGuard&) = delete;
SemaphoreGuard& operator=(const SemaphoreGuard&) = delete;
SemaphoreHandle_t semaphore = nullptr;
bool taken = false;
};