Merge develop into main branch (#137)

* SdCard HAL refactored (#135)

- Refactor SdCard HAL
- introduce Lockable

* Screenshot and FatFS improvements (#136)

- Fix screenshots on ESP32
- Improve Screenshot service
- Convert Screenshot app to class-based instead of structs
- Screenshot app now automatically updates when task is finished
- Enable FatFS long filename support

* Re-use common log messages (#138)

For consistency and binary size reduction

* Toolbar spinner should get margin to the right

* More TactilityC features (#139)

* Rewrote Loader

- Simplified Loader by removing custom threa
- Created DispatcherThread
- Move auto-starting apps to Boot app
- Fixed Dispatcher bug where it could get stuck not processing new
messages

* Hide AP settings if the AP is not saved

* Missing from previous commit

* Replace LV_EVENT_CLICKED with LV_EVENT_SHORT_CLICKED

* Refactored files app and created InputDialog (#140)

- Changed Files app so that it has a View and State
- Files app now allows for long-pressing on files to perform actions
- Files app now has rename and delete actions
- Created InputDialog app
- Improved AlertDialog app layout
This commit is contained in:
Ken Van Hoeylandt
2024-12-27 22:12:39 +00:00
committed by GitHub
parent 9033daa6dd
commit 50bd6e8bf6
144 changed files with 3244 additions and 2038 deletions
+17 -67
View File
@@ -2,6 +2,7 @@
#include "app/AppManifest.h"
#include "app/AppInstance.h"
#include "EventFlag.h"
#include "MessageQueue.h"
#include "Pubsub.h"
#include "Thread.h"
@@ -10,6 +11,7 @@
#include "RtosCompatSemaphore.h"
#include <stack>
#include <utility>
#include <DispatcherThread.h>
namespace tt::service::loader {
@@ -53,98 +55,46 @@ typedef struct {
// region LoaderMessage
typedef enum {
LoaderMessageTypeNone,
LoaderMessageTypeAppStart,
LoaderMessageTypeAppStop,
LoaderMessageTypeServiceStop,
} LoaderMessageType;
class LoaderMessageAppStart {
public:
// This lock blocks anyone from starting an app as long
// as an app is already running via loader_start()
// This lock's lifecycle is not owned by this class.
std::shared_ptr<EventFlag> api_lock = std::make_shared<EventFlag>();
std::string id;
std::shared_ptr<const Bundle> _Nullable parameters;
LoaderMessageAppStart() = default;
LoaderMessageAppStart(LoaderMessageAppStart& other) :
api_lock(other.api_lock),
id(other.id),
parameters(other.parameters) {}
LoaderMessageAppStart(const std::string& id, std::shared_ptr<const Bundle> parameters) :
id(id),
parameters(std::move(parameters))
{}
};
typedef struct {
LoaderStatus value;
} LoaderMessageLoaderStatusResult;
~LoaderMessageAppStart() = default;
typedef struct {
bool value;
} LoaderMessageBoolResult;
std::shared_ptr<EventFlag> getApiLockEventFlag() { return api_lock; }
class LoaderMessage {
public:
// This lock blocks anyone from starting an app as long
// as an app is already running via loader_start()
// This lock's lifecycle is not owned by this class.
EventFlag* _Nullable api_lock;
LoaderMessageType type;
uint32_t getApiLockEventFlagValue() { return 1; }
struct {
union {
// TODO: Convert to smart pointer
const LoaderMessageAppStart* start;
};
} payload;
struct {
union {
LoaderMessageLoaderStatusResult status_value;
LoaderMessageBoolResult bool_value;
void* raw_value;
};
} result;
LoaderMessage() {
api_lock = nullptr;
type = LoaderMessageTypeNone;
payload = { .start = nullptr };
result = { .raw_value = nullptr };
}
LoaderMessage(const LoaderMessageAppStart* start, const LoaderMessageLoaderStatusResult& statusResult) {
api_lock = nullptr;
type = LoaderMessageTypeAppStart;
payload.start = start;
result.status_value = statusResult;
}
LoaderMessage(LoaderMessageType messageType) {
api_lock = nullptr;
type = messageType;
payload = { .start = nullptr };
result = { .raw_value = nullptr };
}
void setApiLock(EventFlag* eventFlag) {
api_lock = eventFlag;
}
void cleanup() {
if (type == LoaderMessageTypeAppStart) {
delete payload.start;
}
void onProcessed() {
api_lock->set(1);
}
};
// endregion LoaderMessage
struct Loader {
Thread* thread;
std::shared_ptr<PubSub> pubsub_internal = std::make_shared<PubSub>();
std::shared_ptr<PubSub> pubsub_external = std::make_shared<PubSub>();
MessageQueue queue = MessageQueue(2, sizeof(LoaderMessage)); // 2 entries, so you can stop the current app while starting a new one without blocking
Mutex mutex = Mutex(Mutex::TypeRecursive);
std::stack<app::AppInstance*> app_stack;
std::unique_ptr<DispatcherThread> dispatcherThread = std::make_unique<DispatcherThread>("loader_dispatcher", 6144); // Files app requires ~5k
};
} // namespace