Cleanup and improvements (#194)
- Lots of changes for migrating C code to C++ - Improved `Lockable` in several ways like adding `withLock()` (+ tests) - Improved `Semaphore` a bit for improved readability, and also added some tests - Upgrade Linux machine in GitHub Actions so that we can compile with a newer GCC - Simplification of WiFi connection - Updated funding options - (and more)
This commit is contained in:
committed by
GitHub
parent
1bb1260ea0
commit
6c67845645
@@ -10,13 +10,13 @@
|
||||
|
||||
namespace tt::app {
|
||||
|
||||
typedef enum {
|
||||
StateInitial, // App is being activated in loader
|
||||
StateStarted, // App is in memory
|
||||
StateShowing, // App view is created
|
||||
StateHiding, // App view is destroyed
|
||||
StateStopped // App is not in memory
|
||||
} State;
|
||||
enum class State {
|
||||
Initial, // App is being activated in loader
|
||||
Started, // App is in memory
|
||||
Showing, // App view is created
|
||||
Hiding, // App view is destroyed
|
||||
Stopped // App is not in memory
|
||||
};
|
||||
|
||||
/**
|
||||
* Thread-safe app instance.
|
||||
@@ -27,7 +27,7 @@ private:
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Normal);
|
||||
const std::shared_ptr<AppManifest> manifest;
|
||||
State state = StateInitial;
|
||||
State state = State::Initial;
|
||||
Flags flags = { .showStatusbar = true };
|
||||
/** @brief Optional parameters to start the app with
|
||||
* When these are stored in the app struct, the struct takes ownership.
|
||||
|
||||
@@ -41,13 +41,11 @@ public:
|
||||
bool setEntriesForChildPath(const std::string& child_path);
|
||||
bool setEntriesForPath(const std::string& path);
|
||||
|
||||
const std::vector<dirent>& lockEntries() const {
|
||||
mutex.lock();
|
||||
return dir_entries;
|
||||
}
|
||||
|
||||
void unlockEntries() {
|
||||
mutex.unlock();
|
||||
template <std::invocable<const std::vector<dirent> &> Func>
|
||||
void withEntries(Func&& onEntries) const {
|
||||
mutex.withLock([&]() {
|
||||
std::invoke(std::forward<Func>(onEntries), dir_entries);
|
||||
});
|
||||
}
|
||||
|
||||
bool getDirent(uint32_t index, dirent& dirent);
|
||||
|
||||
@@ -20,9 +20,6 @@ public:
|
||||
void setConnectionError(bool error);
|
||||
bool hasConnectionError() const;
|
||||
|
||||
const service::wifi::settings::WifiApSettings& lockApSettings();
|
||||
void unlockApSettings();
|
||||
|
||||
void setApSettings(const service::wifi::settings::WifiApSettings* newSettings);
|
||||
|
||||
void setConnecting(bool isConnecting);
|
||||
|
||||
@@ -30,8 +30,12 @@ public:
|
||||
|
||||
void updateApRecords();
|
||||
|
||||
const std::vector<service::wifi::ApRecord>& lockApRecords() const;
|
||||
void unlockApRecords() const;
|
||||
template <std::invocable<const std::vector<service::wifi::ApRecord>&> Func>
|
||||
void withApRecords(Func&& onApRecords) const {
|
||||
mutex.withLock([&]() {
|
||||
std::invoke(std::forward<Func>(onApRecords), apRecords);
|
||||
});
|
||||
}
|
||||
|
||||
void setConnectSsid(const std::string& ssid);
|
||||
std::string getConnectSsid() const;
|
||||
|
||||
Reference in New Issue
Block a user