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:
committed by
GitHub
parent
c7621b5e4c
commit
b214a3358e
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user