Merge develop into main (#339)
- Update ILI9341 driver to v2.0.1 - Lots of code cleanup for apps - Refactor app "type" into "category" and added flags to the manifest (for show/hide statusbar and for hidden apps) - Rename some ElfApp-related functionality and improved the way the static data was managed - Rename "filebrowser" to "files" - Added cstring functions to tt_init.cpp - Minor fix in Boot app - Updated external apps for SDK changes
This commit is contained in:
committed by
GitHub
parent
a2af95b92d
commit
faab6d825f
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/app/AppContext.h"
|
||||
#include "Tactility/app/AppManifest.h"
|
||||
#include "Tactility/app/ElfApp.h"
|
||||
#include <Tactility/app/AppContext.h>
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/app/ElfApp.h>
|
||||
|
||||
#include <Tactility/Bundle.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
@@ -29,7 +29,7 @@ class AppInstance : public AppContext {
|
||||
const std::shared_ptr<AppManifest> manifest;
|
||||
State state = State::Initial;
|
||||
LaunchId launchId;
|
||||
Flags flags = { .showStatusbar = true };
|
||||
Flags flags = { .hideStatusbar = true };
|
||||
/** @brief Optional parameters to start the app with
|
||||
* When these are stored in the app struct, the struct takes ownership.
|
||||
* Do not mutate after app creation.
|
||||
|
||||
+5
-9
@@ -6,9 +6,9 @@
|
||||
#include <vector>
|
||||
#include <dirent.h>
|
||||
|
||||
namespace tt::app::filebrowser {
|
||||
namespace tt::app::files {
|
||||
|
||||
class State {
|
||||
class State final {
|
||||
|
||||
public:
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
|
||||
template <std::invocable<const std::vector<dirent> &> Func>
|
||||
void withEntries(Func&& onEntries) const {
|
||||
mutex.withLock([&]() {
|
||||
mutex.withLock([&] {
|
||||
std::invoke(std::forward<Func>(onEntries), dir_entries);
|
||||
});
|
||||
}
|
||||
@@ -61,13 +61,9 @@ public:
|
||||
|
||||
std::string getSelectedChildPath() const;
|
||||
|
||||
PendingAction getPendingAction() const {
|
||||
return action;
|
||||
}
|
||||
PendingAction getPendingAction() const { return action; }
|
||||
|
||||
void setPendingAction(PendingAction newAction) {
|
||||
action = newAction;
|
||||
}
|
||||
void setPendingAction(PendingAction newAction) { action = newAction; }
|
||||
};
|
||||
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace tt::app::filebrowser {
|
||||
namespace tt::app::files {
|
||||
|
||||
bool isSupportedAppFile(const std::string& filename);
|
||||
bool isSupportedImageFile(const std::string& filename);
|
||||
+3
-3
@@ -2,14 +2,14 @@
|
||||
|
||||
#include "./State.h"
|
||||
|
||||
#include "Tactility/app/AppManifest.h"
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <memory>
|
||||
|
||||
namespace tt::app::filebrowser {
|
||||
namespace tt::app::files {
|
||||
|
||||
class View {
|
||||
class View final {
|
||||
std::shared_ptr<State> state;
|
||||
|
||||
lv_obj_t* dir_entry_list = nullptr;
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace tt::app::fileselection {
|
||||
|
||||
class State {
|
||||
class State final {
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
std::vector<dirent> dir_entries;
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
#include "./State.h"
|
||||
#include "./FileSelectionPrivate.h"
|
||||
|
||||
#include "Tactility/app/AppManifest.h"
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <memory>
|
||||
|
||||
namespace tt::app::fileselection {
|
||||
|
||||
class View {
|
||||
class View final {
|
||||
std::shared_ptr<State> state;
|
||||
|
||||
lv_obj_t* dir_entry_list = nullptr;
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/hal/i2c/I2c.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <Tactility/Thread.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <memory>
|
||||
|
||||
namespace tt::app::i2cscanner {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/i18n/TextResources.h"
|
||||
#include <Tactility/i18n/TextResources.h>
|
||||
|
||||
// WARNING: This file is auto-generated. Do not edit manually.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/i18n/TextResources.h"
|
||||
#include <Tactility/i18n/TextResources.h>
|
||||
|
||||
// WARNING: This file is auto-generated. Do not edit manually.
|
||||
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
#pragma once
|
||||
|
||||
#include "View.h"
|
||||
|
||||
#include <Tactility/Preferences.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/app/alertdialog/AlertDialog.h>
|
||||
#include <Tactility/hal/uart/Uart.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/lvgl/Style.h>
|
||||
|
||||
#include <Tactility/StringUtils.h>
|
||||
#include <string>
|
||||
|
||||
namespace tt::app::serialconsole {
|
||||
|
||||
class ConnectView final : public View {
|
||||
|
||||
public:
|
||||
|
||||
typedef std::function<void(std::unique_ptr<hal::uart::Uart>)> OnConnectedFunction;
|
||||
std::vector<std::string> uartNames;
|
||||
Preferences preferences = Preferences("SerialConsole");
|
||||
|
||||
private:
|
||||
|
||||
OnConnectedFunction onConnected;
|
||||
lv_obj_t* busDropdown = nullptr;
|
||||
lv_obj_t* speedTextarea = nullptr;
|
||||
|
||||
int32_t getSpeedInput() const {
|
||||
auto* speed_text = lv_textarea_get_text(speedTextarea);
|
||||
return std::stoi(speed_text);
|
||||
}
|
||||
|
||||
void onConnect() {
|
||||
auto lock = lvgl::getSyncLock()->asScopedLock();
|
||||
if (!lock.lock(lvgl::defaultLockTime)) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto selected_uart_index = lv_dropdown_get_selected(busDropdown);
|
||||
if (selected_uart_index >= uartNames.size()) {
|
||||
alertdialog::start("Error", "No UART selected");
|
||||
return;
|
||||
}
|
||||
|
||||
auto uart_name = uartNames[selected_uart_index];
|
||||
auto uart = hal::uart::open(uart_name);
|
||||
if (uart == nullptr) {
|
||||
alertdialog::start("Error", "Failed to connect to UART");
|
||||
return;
|
||||
}
|
||||
|
||||
int speed = getSpeedInput();
|
||||
if (speed <= 0) {
|
||||
alertdialog::start("Error", "Invalid speed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!uart->start()) {
|
||||
alertdialog::start("Error", "Failed to initialize");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!uart->setBaudRate(speed)) {
|
||||
uart->stop();
|
||||
alertdialog::start("Error", "Failed to set baud rate");
|
||||
return;
|
||||
}
|
||||
|
||||
onConnected(std::move(uart));
|
||||
}
|
||||
|
||||
static void onConnectCallback(lv_event_t* event) {
|
||||
auto* view = (ConnectView*)lv_event_get_user_data(event);
|
||||
view->onConnect();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
explicit ConnectView(OnConnectedFunction onConnected) : onConnected(std::move(onConnected)) {}
|
||||
|
||||
void onStart(lv_obj_t* parent) {
|
||||
uartNames = hal::uart::getNames();
|
||||
|
||||
auto* wrapper = lv_obj_create(parent);
|
||||
lv_obj_set_size(wrapper, LV_PCT(100), LV_PCT(100));
|
||||
lv_obj_set_style_pad_ver(wrapper, 0, 0);
|
||||
lv_obj_set_style_border_width(wrapper, 0, 0);
|
||||
lvgl::obj_set_style_bg_invisible(wrapper);
|
||||
|
||||
busDropdown = lv_dropdown_create(wrapper);
|
||||
|
||||
auto bus_options = string::join(uartNames, "\n");
|
||||
lv_dropdown_set_options(busDropdown, bus_options.c_str());
|
||||
lv_obj_align(busDropdown, LV_ALIGN_TOP_RIGHT, 0, 0);
|
||||
lv_obj_set_width(busDropdown, LV_PCT(50));
|
||||
lv_obj_set_style_border_color(busDropdown, lv_color_hex(0xFAFAFA), LV_PART_MAIN);
|
||||
lv_obj_set_style_border_width(busDropdown, 1, LV_PART_MAIN);
|
||||
int32_t bus_index = 0;
|
||||
preferences.optInt32("bus", bus_index);
|
||||
if (bus_index < uartNames.size()) {
|
||||
lv_dropdown_set_selected(busDropdown, bus_index);
|
||||
}
|
||||
|
||||
auto* bus_label = lv_label_create(wrapper);
|
||||
lv_obj_align(bus_label, LV_ALIGN_TOP_LEFT, 0, 10);
|
||||
lv_label_set_text(bus_label, "Bus");
|
||||
|
||||
int32_t speed = 115200;
|
||||
preferences.optInt32("speed", speed);
|
||||
speedTextarea = lv_textarea_create(wrapper);
|
||||
lv_textarea_set_text(speedTextarea, std::to_string(speed).c_str());
|
||||
lv_textarea_set_one_line(speedTextarea, true);
|
||||
lv_obj_set_width(speedTextarea, LV_PCT(50));
|
||||
lv_obj_align(speedTextarea, LV_ALIGN_TOP_RIGHT, 0, 40);
|
||||
|
||||
auto* baud_rate_label = lv_label_create(wrapper);
|
||||
lv_obj_align(baud_rate_label, LV_ALIGN_TOP_LEFT, 0, 50);
|
||||
lv_label_set_text(baud_rate_label, "Baud");
|
||||
|
||||
auto* connect_button = lv_button_create(wrapper);
|
||||
auto* connect_label = lv_label_create(connect_button);
|
||||
lv_label_set_text(connect_label, "Connect");
|
||||
lv_obj_align(connect_button, LV_ALIGN_TOP_MID, 0, 90);
|
||||
lv_obj_add_event_cb(connect_button, onConnectCallback, LV_EVENT_SHORT_CLICKED, this);
|
||||
}
|
||||
|
||||
void onStop() override {
|
||||
int speed = getSpeedInput();
|
||||
if (speed > 0) {
|
||||
preferences.putInt32("speed", speed);
|
||||
}
|
||||
|
||||
auto bus_index = (int32_t)lv_dropdown_get_selected(busDropdown);
|
||||
preferences.putInt32("bus", bus_index);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace tt::app::serialconsole
|
||||
@@ -0,0 +1,283 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/app/serialconsole/View.h>
|
||||
#include <Tactility/Timer.h>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
namespace tt::app::serialconsole {
|
||||
|
||||
constexpr auto* TAG = "SerialConsole";
|
||||
constexpr size_t receiveBufferSize = 512;
|
||||
constexpr size_t renderBufferSize = receiveBufferSize + 2; // Leave space for newline at split and null terminator at the end
|
||||
|
||||
class ConsoleView final : public View {
|
||||
|
||||
lv_obj_t* _Nullable parent = nullptr;
|
||||
lv_obj_t* _Nullable logTextarea = nullptr;
|
||||
lv_obj_t* _Nullable inputTextarea = nullptr;
|
||||
std::unique_ptr<hal::uart::Uart> _Nullable uart = nullptr;
|
||||
std::shared_ptr<Thread> uartThread _Nullable = nullptr;
|
||||
bool uartThreadInterrupted = false;
|
||||
std::shared_ptr<Thread> viewThread _Nullable = nullptr;
|
||||
bool viewThreadInterrupted = false;
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
uint8_t receiveBuffer[receiveBufferSize];
|
||||
uint8_t renderBuffer[renderBufferSize];
|
||||
size_t receiveBufferPosition = 0;
|
||||
std::string terminatorString = "\n";
|
||||
|
||||
bool isUartThreadInterrupted() const {
|
||||
auto lock = mutex.asScopedLock();
|
||||
lock.lock();
|
||||
return uartThreadInterrupted;
|
||||
}
|
||||
|
||||
bool isViewThreadInterrupted() const {
|
||||
auto lock = mutex.asScopedLock();
|
||||
lock.lock();
|
||||
return viewThreadInterrupted;
|
||||
}
|
||||
|
||||
void updateViews() {
|
||||
auto lvgl_lock = lvgl::getSyncLock()->asScopedLock();
|
||||
if (!lvgl_lock.lock(lvgl::defaultLockTime)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Updating the view is expensive, so we only want to set the text once:
|
||||
// Gather all the lines in a single buffer
|
||||
if (mutex.lock()) {
|
||||
size_t first_part_size = receiveBufferSize - receiveBufferPosition;
|
||||
memcpy(renderBuffer, receiveBuffer + receiveBufferPosition, first_part_size);
|
||||
renderBuffer[receiveBufferPosition] = '\n';
|
||||
if (receiveBufferPosition > 0) {
|
||||
memcpy(renderBuffer + first_part_size + 1, receiveBuffer, (receiveBufferSize - first_part_size));
|
||||
renderBuffer[receiveBufferSize - 1] = 0x00;
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
if (lvgl::lock(lvgl::defaultLockTime)) {
|
||||
lv_textarea_set_text(logTextarea, (const char*)renderBuffer);
|
||||
lvgl::unlock();
|
||||
}
|
||||
}
|
||||
|
||||
int32_t viewThreadMain() {
|
||||
while (!isViewThreadInterrupted()) {
|
||||
auto start_time = kernel::getTicks();
|
||||
|
||||
updateViews();
|
||||
|
||||
auto end_time = kernel::getTicks();
|
||||
auto time_diff = end_time - start_time;
|
||||
if (time_diff < 500U) {
|
||||
kernel::delayTicks((500U - time_diff) / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t uartThreadMain() {
|
||||
uint8_t byte;
|
||||
|
||||
while (!isUartThreadInterrupted()) {
|
||||
assert(uart != nullptr);
|
||||
bool success = uart->readByte(&byte, 50 / portTICK_PERIOD_MS);
|
||||
|
||||
// Thread might've been interrupted in the meanwhile
|
||||
if (isUartThreadInterrupted()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (success) {
|
||||
mutex.lock();
|
||||
receiveBuffer[receiveBufferPosition++] = byte;
|
||||
if (receiveBufferPosition == receiveBufferSize) {
|
||||
receiveBufferPosition = 0;
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void onSendClickedCallback(lv_event_t* event) {
|
||||
auto* view = (ConsoleView*)lv_event_get_user_data(event);
|
||||
view->onSendClicked();
|
||||
}
|
||||
|
||||
static void onTerminatorDropdownValueChangedCallback(lv_event_t* event) {
|
||||
auto* view = (ConsoleView*)lv_event_get_user_data(event);
|
||||
view->onTerminatorDropDownValueChanged(event);
|
||||
}
|
||||
|
||||
void onTerminatorDropDownValueChanged(lv_event_t* event) {
|
||||
auto* dropdown = static_cast<lv_obj_t*>(lv_event_get_target(event));
|
||||
mutex.lock();
|
||||
switch (lv_dropdown_get_selected(dropdown)) {
|
||||
case 0:
|
||||
terminatorString = "\n";
|
||||
break;
|
||||
case 1:
|
||||
terminatorString = "\r\n";
|
||||
break;
|
||||
}
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void onSendClicked() {
|
||||
mutex.lock();
|
||||
std::string input_text = lv_textarea_get_text(inputTextarea);
|
||||
std::string to_send = input_text + terminatorString;
|
||||
mutex.unlock();
|
||||
|
||||
auto* safe_uart = uart.get();
|
||||
if (safe_uart != nullptr) {
|
||||
if (!safe_uart->writeString(to_send.c_str(), 100 / portTICK_PERIOD_MS)) {
|
||||
TT_LOG_E(TAG, "Failed to send \"%s\"", input_text.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
lv_textarea_set_text(inputTextarea, "");
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void startLogic(std::unique_ptr<hal::uart::Uart> newUart) {
|
||||
memset(receiveBuffer, 0, receiveBufferSize);
|
||||
|
||||
assert(uartThread == nullptr);
|
||||
assert(uart == nullptr);
|
||||
|
||||
uart = std::move(newUart);
|
||||
|
||||
uartThreadInterrupted = false;
|
||||
uartThread = std::make_unique<Thread>(
|
||||
"SerConsUart",
|
||||
4096,
|
||||
[this]() {
|
||||
return this->uartThreadMain();
|
||||
}
|
||||
);
|
||||
uartThread->setPriority(tt::Thread::Priority::High);
|
||||
uartThread->start();
|
||||
}
|
||||
|
||||
void startViews(lv_obj_t* parent) {
|
||||
this->parent = parent;
|
||||
|
||||
lv_obj_set_style_pad_gap(parent, 2, 0);
|
||||
|
||||
logTextarea = lv_textarea_create(parent);
|
||||
lv_textarea_set_placeholder_text(logTextarea, "Waiting for data...");
|
||||
lv_obj_set_flex_grow(logTextarea, 1);
|
||||
lv_obj_set_width(logTextarea, LV_PCT(100));
|
||||
lv_obj_add_state(logTextarea, LV_STATE_DISABLED);
|
||||
lv_obj_set_style_margin_ver(logTextarea, 0, 0);
|
||||
|
||||
auto* input_wrapper = lv_obj_create(parent);
|
||||
lv_obj_set_size(input_wrapper, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
lv_obj_set_style_pad_all(input_wrapper, 0, 0);
|
||||
lv_obj_set_style_border_width(input_wrapper, 0, 0);
|
||||
lv_obj_set_width(input_wrapper, LV_PCT(100));
|
||||
lv_obj_set_flex_flow(input_wrapper, LV_FLEX_FLOW_ROW);
|
||||
|
||||
inputTextarea = lv_textarea_create(input_wrapper);
|
||||
lv_textarea_set_one_line(inputTextarea, true);
|
||||
lv_textarea_set_placeholder_text(inputTextarea, "Text to send");
|
||||
lv_obj_set_width(inputTextarea, LV_PCT(100));
|
||||
lv_obj_set_flex_grow(inputTextarea, 1);
|
||||
|
||||
auto* terminator_dropdown = lv_dropdown_create(input_wrapper);
|
||||
lv_dropdown_set_options(terminator_dropdown, "\\n\n\\r\\n");
|
||||
lv_obj_set_width(terminator_dropdown, 70);
|
||||
lv_obj_add_event_cb(terminator_dropdown, onTerminatorDropdownValueChangedCallback, LV_EVENT_VALUE_CHANGED, this);
|
||||
|
||||
|
||||
auto* button = lv_button_create(input_wrapper);
|
||||
auto* button_label = lv_label_create(button);
|
||||
lv_label_set_text(button_label, "Send");
|
||||
lv_obj_add_event_cb(button, onSendClickedCallback, LV_EVENT_SHORT_CLICKED, this);
|
||||
|
||||
viewThreadInterrupted = false;
|
||||
viewThread = std::make_unique<Thread>(
|
||||
"SerConsView",
|
||||
4096,
|
||||
[this] {
|
||||
return this->viewThreadMain();
|
||||
}
|
||||
);
|
||||
viewThread->setPriority(THREAD_PRIORITY_RENDER);
|
||||
viewThread->start();
|
||||
}
|
||||
|
||||
void stopLogic() {
|
||||
auto lock = mutex.asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
uartThreadInterrupted = true;
|
||||
|
||||
// Detach thread, it will auto-delete when leaving the current scope
|
||||
auto old_uart_thread = std::move(uartThread);
|
||||
// Unlock so thread can lock
|
||||
lock.unlock();
|
||||
|
||||
if (old_uart_thread->getState() != Thread::State::Stopped) {
|
||||
// Wait for thread to finish
|
||||
old_uart_thread->join();
|
||||
}
|
||||
}
|
||||
|
||||
void stopViews() {
|
||||
auto lock = mutex.asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
viewThreadInterrupted = true;
|
||||
|
||||
// Detach thread, it will auto-delete when leaving the current scope
|
||||
auto old_view_thread = std::move(viewThread);
|
||||
|
||||
// Unlock so thread can lock
|
||||
lock.unlock();
|
||||
|
||||
if (old_view_thread->getState() != Thread::State::Stopped) {
|
||||
// Wait for thread to finish
|
||||
old_view_thread->join();
|
||||
}
|
||||
}
|
||||
|
||||
void stopUart() {
|
||||
auto lock = mutex.asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
if (uart != nullptr && uart->isStarted()) {
|
||||
uart->stop();
|
||||
uart = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void onStart(lv_obj_t* parent, std::unique_ptr<hal::uart::Uart> newUart) {
|
||||
auto lock = mutex.asScopedLock();
|
||||
lock.lock();
|
||||
|
||||
startLogic(std::move(newUart));
|
||||
startViews(parent);
|
||||
}
|
||||
|
||||
void onStop() override {
|
||||
stopViews();
|
||||
stopLogic();
|
||||
stopUart();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace tt::app::serialconsole
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace tt::app::serialconsole {
|
||||
|
||||
class View {
|
||||
public:
|
||||
virtual void onStop() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/Bundle.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
#include <string>
|
||||
|
||||
namespace tt::app::wifiapsettings {
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace tt::app::wificonnect {
|
||||
|
||||
class State {
|
||||
class State final {
|
||||
Mutex lock;
|
||||
service::wifi::settings::WifiApSettings apSettings;
|
||||
bool connectionError = false;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "./Bindings.h"
|
||||
#include "./State.h"
|
||||
|
||||
#include "Tactility/app/AppContext.h"
|
||||
#include <Tactility/app/AppContext.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace tt::app::wificonnect {
|
||||
|
||||
class WifiConnect;
|
||||
|
||||
class View {
|
||||
class View final {
|
||||
|
||||
Bindings* bindings;
|
||||
State* state;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/app/App.h"
|
||||
#include "Tactility/app/wificonnect/Bindings.h"
|
||||
#include "Tactility/app/wificonnect/State.h"
|
||||
#include "Tactility/app/wificonnect/View.h"
|
||||
#include <Tactility/app/App.h>
|
||||
#include <Tactility/app/wificonnect/Bindings.h>
|
||||
#include <Tactility/app/wificonnect/State.h>
|
||||
#include <Tactility/app/wificonnect/View.h>
|
||||
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
|
||||
namespace tt::app::wificonnect {
|
||||
|
||||
class WifiConnect : public App {
|
||||
class WifiConnect final : public App {
|
||||
|
||||
Mutex mutex;
|
||||
State state;
|
||||
@@ -27,7 +27,7 @@ class WifiConnect : public App {
|
||||
public:
|
||||
|
||||
WifiConnect();
|
||||
~WifiConnect();
|
||||
~WifiConnect() override;
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
@@ -39,7 +39,6 @@ public:
|
||||
Bindings& getBindings() { return bindings; }
|
||||
View& getView() { return view; }
|
||||
|
||||
|
||||
void requestViewUpdate();
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace tt::app::wifimanage {
|
||||
/**
|
||||
* View's state
|
||||
*/
|
||||
class State {
|
||||
class State final {
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
bool scanning = false;
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
|
||||
template <std::invocable<const std::vector<service::wifi::ApRecord>&> Func>
|
||||
void withApRecords(Func&& onApRecords) const {
|
||||
mutex.withLock([&]() {
|
||||
mutex.withLock([&] {
|
||||
std::invoke(std::forward<Func>(onApRecords), apRecords);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,19 +3,17 @@
|
||||
#include "./Bindings.h"
|
||||
#include "./State.h"
|
||||
|
||||
#include "Tactility/app/AppContext.h"
|
||||
#include <Tactility/app/AppContext.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
|
||||
namespace tt::app::wifimanage {
|
||||
|
||||
class View {
|
||||
|
||||
private:
|
||||
class View final {
|
||||
|
||||
Bindings* bindings;
|
||||
State* state;
|
||||
std::unique_ptr<app::Paths> paths;
|
||||
std::unique_ptr<Paths> paths;
|
||||
lv_obj_t* root = nullptr;
|
||||
lv_obj_t* enable_switch = nullptr;
|
||||
lv_obj_t* enable_on_boot_switch = nullptr;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "./View.h"
|
||||
#include "./State.h"
|
||||
|
||||
#include "Tactility/app/App.h"
|
||||
#include <Tactility/app/App.h>
|
||||
|
||||
#include <Tactility/PubSub.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace tt::app::wifimanage {
|
||||
|
||||
class WifiManage : public App {
|
||||
class WifiManage final : public App {
|
||||
|
||||
PubSub<service::wifi::WifiEvent>::SubscriptionHandle wifiSubscription = nullptr;
|
||||
Mutex mutex;
|
||||
|
||||
Reference in New Issue
Block a user