Merge develop into main (#353)

## TactilityC
- Add `tt_lvgl_lock()` and `tt_lvgl_unlock()`
- Add `tt_thread_set_affinity()`
- Add support for STL symbols

## Other
- Add `Thread::setAffinity()`
- `GuiService`: replace `#define` with `constexpr`
- Remove log storage and log app for now
- Split up ELF symbols into more groups
This commit is contained in:
Ken Van Hoeylandt
2025-10-01 23:07:47 +02:00
committed by GitHub
parent c7621b5e4c
commit b214a3358e
27 changed files with 198 additions and 344 deletions
+1 -27
View File
@@ -1,36 +1,10 @@
#pragma once
#include "LogMessages.h"
#include <array>
#include <memory>
#if not defined(ESP_PLATFORM) or (defined(CONFIG_SPIRAM_USE_MALLOC) && CONFIG_SPIRAM_USE_MALLOC == 1)
#define TT_LOG_ENTRY_COUNT 200
#define TT_LOG_MESSAGE_SIZE 128
#else
#define TT_LOG_ENTRY_COUNT 50
#define TT_LOG_MESSAGE_SIZE 50
#endif
#ifdef ESP_PLATFORM
#include "LogEsp.h"
#else
#include "LogSimulator.h"
#endif
#include "LogMessages.h"
#include "LogCommon.h"
namespace tt {
struct LogEntry {
LogLevel level = LogLevel::Verbose;
char message[TT_LOG_MESSAGE_SIZE] = { 0 };
};
/** Make a copy of the currently stored entries.
* The array size is TT_LOG_ENTRY_COUNT
* @param[out] outIndex the write index for the next log entry.
*/
std::unique_ptr<std::array<LogEntry, TT_LOG_ENTRY_COUNT>> copyLogEntries(std::size_t& outIndex);
} // namespace tt
+1
View File
@@ -3,6 +3,7 @@
#ifdef ESP_PLATFORM
#include <esp_log.h>
#include "Tactility/LogCommon.h"
#define TT_LOG_E(tag, format, ...) \
ESP_LOGE(tag, format, ##__VA_ARGS__)
+5
View File
@@ -97,6 +97,11 @@ public:
*/
void setStackSize(size_t stackSize);
/** Set CPU core pinning for this thread.
* @param[in] affinity -1 means not pinned, otherwise it's the core id (e.g. 0 or 1 on ESP32)
*/
void setAffinity(portBASE_TYPE affinity);
/** Set Thread callback
* @param[in] callback ThreadCallback, called upon thread run
* @param[in] callbackContext what to pass to the callback
-50
View File
@@ -1,50 +0,0 @@
#include "Tactility/Mutex.h"
#include <cstring>
#include <sstream>
namespace tt {
static std::array<LogEntry, TT_LOG_ENTRY_COUNT> logEntries;
static size_t nextLogEntryIndex;
/**
* This used to be a simple static value, but that crashes on device boot where early logging happens.
* For some unknown reason, the static Mutex instance wouldn't have their constructor called before
* the mutex is used.
*/
Mutex& getLogMutex() {
static Mutex* logMutex = nullptr;
if (logMutex == nullptr) {
logMutex = new Mutex();
}
return *logMutex;
}
void storeLog(LogLevel level, const char* format, va_list args) {
if (getLogMutex().lock(5 / portTICK_PERIOD_MS)) {
logEntries[nextLogEntryIndex].level = level;
vsnprintf(logEntries[nextLogEntryIndex].message, TT_LOG_MESSAGE_SIZE, format, args);
nextLogEntryIndex++;
if (nextLogEntryIndex == TT_LOG_ENTRY_COUNT) {
nextLogEntryIndex = 0;
}
getLogMutex().unlock();
}
}
std::unique_ptr<std::array<LogEntry, TT_LOG_ENTRY_COUNT>> copyLogEntries(std::size_t& outIndex) {
if (getLogMutex().lock(5 / portTICK_PERIOD_MS)) {
auto copy = std::make_unique<std::array<LogEntry, TT_LOG_ENTRY_COUNT>>(logEntries);
getLogMutex().unlock();
outIndex = nextLogEntryIndex;
return copy;
} else {
return nullptr;
}
}
} // namespace tt
-24
View File
@@ -1,24 +0,0 @@
#ifdef ESP_PLATFORM
#include "Tactility/LogCommon.h"
#include <esp_log.h>
namespace tt {
void storeLog(LogLevel level, const char* format, va_list args);
}
extern "C" {
extern void __real_esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...);
void __wrap_esp_log_write(esp_log_level_t level, const char* tag, const char* format, ...) {
va_list args;
va_start(args, format);
tt::storeLog((tt::LogLevel)level, format, args);
esp_log_writev(level, tag, format, args);
va_end(args);
}
}
#endif
-6
View File
@@ -9,8 +9,6 @@
namespace tt {
void storeLog(LogLevel level, const char* format, va_list args);
static char toPrefix(LogLevel level) {
using enum LogLevel;
switch (level) {
@@ -81,10 +79,6 @@ void log(LogLevel level, const char* tag, const char* format, ...) {
va_start(args, format);
vprintf(buffer.str().c_str(), args);
va_end(args);
va_start(args, format);
tt::storeLog(level, buffer.str().c_str(), args);
va_end(args);
}
} // namespace tt
+6 -1
View File
@@ -95,9 +95,14 @@ void Thread::setStackSize(size_t newStackSize) {
stackSize = newStackSize;
}
void Thread::setAffinity(portBASE_TYPE newAffinity) {
assert(state == State::Stopped);
affinity = newAffinity;
}
void Thread::setCallback(Callback callback, _Nullable void* callbackContext) {
assert(state == State::Stopped);
mainFunction = [callback, callbackContext]() {
mainFunction = [callback, callbackContext] {
return callback(callbackContext);
};
}