Merge develop into main (#167)
- WiFi Connect app is now hidden by default, but accessible at the bottom of the WiFi Manage app when WiFi is turned on. - WiFi service now turns on WiFi when calling connect() and WiFi is not on. - Removed `blocking` option for `service::loader::startApp()`. This feature was unused and complex. - Various apps: Moved private headers into Private/ folder. - Various apps: created start() function for easy starting. - Added documentation to all TactilityC APIs - Refactored various `enum` into `class enum` - Refactor M5Stack `initBoot()` (but VBus is still 0V for some reason)
This commit is contained in:
committed by
GitHub
parent
3ca0f8cf97
commit
3ea02d912f
@@ -37,7 +37,7 @@ class AppInstance : public AppContext {
|
||||
|
||||
private:
|
||||
|
||||
Mutex mutex = Mutex(Mutex::TypeNormal);
|
||||
Mutex mutex = Mutex(Mutex::Type::Normal);
|
||||
const AppManifest& manifest;
|
||||
State state = StateInitial;
|
||||
Flags flags = { .showStatusbar = true };
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "./View.h"
|
||||
#include "./State.h"
|
||||
|
||||
#include "app/AppManifest.h"
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <dirent.h>
|
||||
#include <memory>
|
||||
|
||||
namespace tt::app::files {
|
||||
|
||||
class Files {
|
||||
std::unique_ptr<View> view;
|
||||
std::shared_ptr<State> state;
|
||||
|
||||
public:
|
||||
Files() {
|
||||
state = std::make_shared<State>();
|
||||
view = std::make_unique<View>(state);
|
||||
}
|
||||
|
||||
void onShow(lv_obj_t* parent) {
|
||||
view->init(parent);
|
||||
}
|
||||
|
||||
void onResult(Result result, const Bundle& bundle) {
|
||||
view->onResult(result, bundle);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
Mutex mutex = Mutex(Mutex::TypeRecursive);
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
std::vector<dirent> dir_entries;
|
||||
std::string current_path;
|
||||
std::string selected_child_entry;
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "State.h"
|
||||
#include "./State.h"
|
||||
|
||||
#include "app/AppManifest.h"
|
||||
#include <lvgl.h>
|
||||
#include <memory>
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <TactilityCore.h>
|
||||
#include <Mutex.h>
|
||||
#include <Thread.h>
|
||||
#include "lvgl.h"
|
||||
#include "hal/i2c/I2c.h"
|
||||
#include "Timer.h"
|
||||
#include <memory>
|
||||
|
||||
namespace tt::app::i2cscanner {
|
||||
|
||||
#define TAG "i2cscanner"
|
||||
|
||||
enum ScanState {
|
||||
ScanStateInitial,
|
||||
ScanStateScanning,
|
||||
ScanStateStopped
|
||||
};
|
||||
|
||||
struct Data {
|
||||
// Core
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
std::unique_ptr<Timer> scanTimer = nullptr;
|
||||
// State
|
||||
ScanState scanState;
|
||||
i2c_port_t port = I2C_NUM_0;
|
||||
std::vector<uint8_t> scannedAddresses;
|
||||
// Widgets
|
||||
lv_obj_t* scanButtonLabelWidget = nullptr;
|
||||
lv_obj_t* portDropdownWidget = nullptr;
|
||||
lv_obj_t* scanListWidget = nullptr;
|
||||
};
|
||||
|
||||
void onScanTimerFinished(std::shared_ptr<Data> data);
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "I2cScanner.h"
|
||||
#include "./I2cScannerPrivate.h"
|
||||
#include <memory>
|
||||
|
||||
namespace tt::app::i2cscanner {
|
||||
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/wificonnect/Bindings.h"
|
||||
#include "app/wificonnect/State.h"
|
||||
#include "app/wificonnect/View.h"
|
||||
|
||||
#include "Mutex.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
|
||||
namespace tt::app::wificonnect {
|
||||
|
||||
class WifiConnect {
|
||||
Mutex mutex;
|
||||
State state;
|
||||
Bindings bindings = {
|
||||
.onConnectSsid = nullptr,
|
||||
.onConnectSsidContext = nullptr
|
||||
};
|
||||
View view = View(&bindings, &state);
|
||||
PubSubSubscription* wifiSubscription;
|
||||
bool view_enabled = false;
|
||||
|
||||
public:
|
||||
|
||||
WifiConnect();
|
||||
~WifiConnect();
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
void onShow(AppContext& app, lv_obj_t* parent);
|
||||
void onHide(AppContext& app);
|
||||
|
||||
State& getState() { return state; }
|
||||
Bindings& getBindings() { return bindings; }
|
||||
View& getView() { return view; }
|
||||
|
||||
|
||||
void requestViewUpdate();
|
||||
};
|
||||
|
||||
bool optSsidParameter(const std::shared_ptr<const Bundle>& bundle, std::string& ssid);
|
||||
bool optPasswordParameter(const std::shared_ptr<const Bundle>& bundle, std::string& password);
|
||||
|
||||
} // namespace
|
||||
+2
@@ -6,12 +6,14 @@ typedef void (*OnWifiToggled)(bool enable);
|
||||
typedef void (*OnConnectSsid)(const char* ssid);
|
||||
typedef void (*OnDisconnect)();
|
||||
typedef void (*OnShowApSettings)(const char* ssid);
|
||||
typedef void (*OnConnectToHidden)();
|
||||
|
||||
struct Bindings{
|
||||
OnWifiToggled onWifiToggled;
|
||||
OnConnectSsid onConnectSsid;
|
||||
OnDisconnect onDisconnect;
|
||||
OnShowApSettings onShowApSettings;
|
||||
OnConnectToHidden onConnectToHidden;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -10,30 +10,30 @@ namespace tt::app::wifimanage {
|
||||
*/
|
||||
class State {
|
||||
|
||||
Mutex mutex = Mutex(Mutex::TypeRecursive);
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
bool scanning = false;
|
||||
bool scannedAfterRadioOn = false;
|
||||
service::wifi::WifiRadioState radioState;
|
||||
std::vector<service::wifi::WifiApRecord> apRecords;
|
||||
service::wifi::RadioState radioState;
|
||||
std::vector<service::wifi::ApRecord> apRecords;
|
||||
std::string connectSsid;
|
||||
|
||||
public:
|
||||
State() {}
|
||||
State() = default;
|
||||
|
||||
void setScanning(bool isScanning);
|
||||
bool isScanning() const;
|
||||
|
||||
bool hasScannedAfterRadioOn() const { return scannedAfterRadioOn; }
|
||||
|
||||
void setRadioState(service::wifi::WifiRadioState state);
|
||||
service::wifi::WifiRadioState getRadioState() const;
|
||||
void setRadioState(service::wifi::RadioState state);
|
||||
service::wifi::RadioState getRadioState() const;
|
||||
|
||||
void updateApRecords();
|
||||
|
||||
const std::vector<service::wifi::WifiApRecord>& lockApRecords() const;
|
||||
const std::vector<service::wifi::ApRecord>& lockApRecords() const;
|
||||
void unlockApRecords() const;
|
||||
|
||||
void setConnectSsid(std::string ssid);
|
||||
void setConnectSsid(const std::string& ssid);
|
||||
std::string getConnectSsid() const;
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/AppContext.h"
|
||||
#include "Bindings.h"
|
||||
#include "State.h"
|
||||
#include "./Bindings.h"
|
||||
#include "./State.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
namespace tt::app::wifimanage {
|
||||
@@ -19,12 +19,14 @@ private:
|
||||
lv_obj_t* enable_on_boot_switch = nullptr;
|
||||
lv_obj_t* scanning_spinner = nullptr;
|
||||
lv_obj_t* networks_list = nullptr;
|
||||
lv_obj_t* connect_to_hidden = nullptr;
|
||||
|
||||
void updateWifiToggle();
|
||||
void updateEnableOnBootToggle();
|
||||
void updateScanning();
|
||||
void updateNetworkList();
|
||||
void createSsidListItem(const service::wifi::WifiApRecord& record, bool isConnecting);
|
||||
void updateConnectToHidden();
|
||||
void createSsidListItem(const service::wifi::ApRecord& record, bool isConnecting);
|
||||
|
||||
public:
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
#include "Mutex.h"
|
||||
#include "./View.h"
|
||||
#include "./State.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
|
||||
namespace tt::app::wifimanage {
|
||||
|
||||
class WifiManage {
|
||||
|
||||
PubSubSubscription* wifiSubscription = nullptr;
|
||||
Mutex mutex;
|
||||
Bindings bindings = { };
|
||||
State state;
|
||||
View view = View(&bindings, &state);
|
||||
bool isViewEnabled = false;
|
||||
|
||||
public:
|
||||
|
||||
WifiManage();
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
void onShow(AppContext& app, lv_obj_t* parent);
|
||||
void onHide(AppContext& app);
|
||||
|
||||
Bindings& getBindings() { return bindings; }
|
||||
State& getState() { return state; }
|
||||
|
||||
void requestViewUpdate();
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -19,7 +19,7 @@ namespace tt::service::gui {
|
||||
struct Gui {
|
||||
// Thread and lock
|
||||
Thread* thread = nullptr;
|
||||
Mutex mutex = Mutex(Mutex::TypeRecursive);
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
PubSubSubscription* loader_pubsub_subscription = nullptr;
|
||||
|
||||
// Layers and Canvas
|
||||
|
||||
@@ -57,17 +57,12 @@ typedef struct {
|
||||
|
||||
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) {}
|
||||
|
||||
@@ -77,14 +72,6 @@ public:
|
||||
{}
|
||||
|
||||
~LoaderMessageAppStart() = default;
|
||||
|
||||
std::shared_ptr<EventFlag> getApiLockEventFlag() { return api_lock; }
|
||||
|
||||
uint32_t getApiLockEventFlagValue() { return 1; }
|
||||
|
||||
void onProcessed() {
|
||||
api_lock->set(1);
|
||||
}
|
||||
};
|
||||
|
||||
// endregion LoaderMessage
|
||||
@@ -92,7 +79,7 @@ public:
|
||||
struct Loader {
|
||||
std::shared_ptr<PubSub> pubsubInternal = std::make_shared<PubSub>();
|
||||
std::shared_ptr<PubSub> pubsubExternal = std::make_shared<PubSub>();
|
||||
Mutex mutex = Mutex(Mutex::TypeRecursive);
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
std::stack<app::AppInstance*> appStack;
|
||||
/** The dispatcher thread needs a callstack large enough to accommodate all the dispatched methods.
|
||||
* This includes full LVGL redraw via Gui::redraw()
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace tt::app {
|
||||
typedef std::unordered_map<std::string, const AppManifest*> AppManifestMap;
|
||||
|
||||
static AppManifestMap app_manifest_map;
|
||||
static Mutex hash_mutex(Mutex::TypeNormal);
|
||||
static Mutex hash_mutex(Mutex::Type::Normal);
|
||||
|
||||
void addApp(const AppManifest* manifest) {
|
||||
TT_LOG_I(TAG, "Registering manifest %s", manifest->id.c_str());
|
||||
|
||||
@@ -19,13 +19,13 @@ namespace tt::app::alertdialog {
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
void start(std::string title, std::string message, const std::vector<std::string>& buttonLabels) {
|
||||
void start(const std::string& title, const std::string& message, const std::vector<std::string>& buttonLabels) {
|
||||
std::string items_joined = string::join(buttonLabels, PARAMETER_ITEM_CONCATENATION_TOKEN);
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_TITLE, title);
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_MESSAGE, message);
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_BUTTON_LABELS, items_joined);
|
||||
service::loader::startApp(manifest.id, false, bundle);
|
||||
service::loader::startApp(manifest.id, bundle);
|
||||
}
|
||||
|
||||
int32_t getResultIndex(const Bundle& bundle) {
|
||||
|
||||
@@ -12,7 +12,13 @@
|
||||
*/
|
||||
namespace tt::app::alertdialog {
|
||||
|
||||
void start(std::string title, std::string message, const std::vector<std::string>& buttonLabels);
|
||||
/**
|
||||
* Show a dialog with the provided title, message and 0, 1 or more buttons.
|
||||
* @param[in] title the title to show in the toolbar
|
||||
* @param[in] message the message to display
|
||||
* @param[in] buttonLabels the buttons to show
|
||||
*/
|
||||
void start(const std::string& title, const std::string& message, const std::vector<std::string>& buttonLabels);
|
||||
|
||||
/**
|
||||
* Get the index of the button that the user selected.
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace tt::app::applist {
|
||||
|
||||
static void onAppPressed(lv_event_t* e) {
|
||||
const auto* manifest = static_cast<const AppManifest*>(lv_event_get_user_data(e));
|
||||
service::loader::startApp(manifest->id, false);
|
||||
service::loader::startApp(manifest->id);
|
||||
}
|
||||
|
||||
static void createAppWidget(const AppManifest* manifest, void* parent) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifdef ESP_TARGET
|
||||
|
||||
#include "app/crashdiagnostics/QrHelpers.h"
|
||||
#include "app/crashdiagnostics/QrUrl.h"
|
||||
#include "app/launcher/Launcher.h"
|
||||
#include "lvgl.h"
|
||||
#include "lvgl/Statusbar.h"
|
||||
#include "app/launcher/Launcher.h"
|
||||
#include "qrcode.h"
|
||||
#include "QrHelpers.h"
|
||||
#include "QrUrl.h"
|
||||
#include "service/loader/Loader.h"
|
||||
|
||||
#define TAG "crash_diagnostics"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "app/crashdiagnostics/QrHelpers.h"
|
||||
#include <cstdint>
|
||||
#include <cassert>
|
||||
#include "QrHelpers.h"
|
||||
|
||||
/**
|
||||
* Maps QR version (starting at a fictitious 0) to the usable byte size for L(ow) CRC checking QR.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#ifdef ESP_TARGET
|
||||
|
||||
#include "QrUrl.h"
|
||||
#include "app/crashdiagnostics/QrUrl.h"
|
||||
|
||||
#include "kernel/PanicHandler.h"
|
||||
#include "Log.h"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "FileUtils.h"
|
||||
#include "app/files/FileUtils.h"
|
||||
|
||||
#include "TactilityCore.h"
|
||||
#include <cstring>
|
||||
#include <StringUtils.h>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "Files.h"
|
||||
#include "app/files/FilesPrivate.h"
|
||||
|
||||
#include "app/AppContext.h"
|
||||
#include "Assets.h"
|
||||
#include "service/loader/Loader.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -37,4 +39,8 @@ extern const AppManifest manifest = {
|
||||
.onResult = onResult
|
||||
};
|
||||
|
||||
void start() {
|
||||
service::loader::startApp(manifest.id);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -10,24 +10,6 @@
|
||||
|
||||
namespace tt::app::files {
|
||||
|
||||
class Files {
|
||||
std::unique_ptr<View> view;
|
||||
std::shared_ptr<State> state;
|
||||
|
||||
public:
|
||||
Files() {
|
||||
state = std::make_shared<State>();
|
||||
view = std::make_unique<View>(state);
|
||||
}
|
||||
|
||||
void onShow(lv_obj_t* parent) {
|
||||
view->init(parent);
|
||||
}
|
||||
|
||||
void onResult(Result result, const Bundle& bundle) {
|
||||
view->onResult(result, bundle);
|
||||
}
|
||||
};
|
||||
|
||||
void start();
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "State.h"
|
||||
#include "app/files/State.h"
|
||||
#include "app/files/FileUtils.h"
|
||||
|
||||
#include "kernel/Kernel.h"
|
||||
#include "Log.h"
|
||||
#include "FileUtils.h"
|
||||
#include "Partitions.h"
|
||||
#include "hal/SdCard.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#include "app/files/FileUtils.h"
|
||||
#include "app/files/View.h"
|
||||
|
||||
#include "app/alertdialog/AlertDialog.h"
|
||||
#include "app/imageviewer/ImageViewer.h"
|
||||
#include "app/inputdialog/InputDialog.h"
|
||||
@@ -6,9 +9,7 @@
|
||||
#include "lvgl/Toolbar.h"
|
||||
#include "lvgl/LvglSync.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "FileUtils.h"
|
||||
#include "Tactility.h"
|
||||
#include "View.h"
|
||||
#include "StringUtils.h"
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
@@ -83,18 +84,14 @@ void View::viewFile(const std::string& path, const std::string& filename) {
|
||||
app::startElfApp(processed_filepath);
|
||||
#endif
|
||||
} else if (isSupportedImageFile(filename)) {
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
bundle->putString(IMAGE_VIEWER_FILE_ARGUMENT, processed_filepath);
|
||||
service::loader::startApp("ImageViewer", false, bundle);
|
||||
app::imageviewer::start(processed_filepath);
|
||||
} else if (isSupportedTextFile(filename)) {
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
if (kernel::getPlatform() == kernel::PlatformEsp) {
|
||||
bundle->putString(TEXT_VIEWER_FILE_ARGUMENT, processed_filepath);
|
||||
app::textviewer::start(processed_filepath);
|
||||
} else {
|
||||
// Remove forward slash, because we need a relative path
|
||||
bundle->putString(TEXT_VIEWER_FILE_ARGUMENT, processed_filepath.substr(1));
|
||||
app::textviewer::start(processed_filepath.substr(1));
|
||||
}
|
||||
service::loader::startApp("TextViewer", false, bundle);
|
||||
} else {
|
||||
TT_LOG_W(TAG, "opening files of this type is not supported");
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ void Gpio::startTask(std::shared_ptr<Gpio> ptr) {
|
||||
lock();
|
||||
tt_assert(timer == nullptr);
|
||||
timer = std::make_unique<Timer>(
|
||||
Timer::TypePeriodic,
|
||||
Timer::Type::Periodic,
|
||||
&onTimer,
|
||||
ptr
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "I2cHelpers.h"
|
||||
#include "app/i2cscanner/I2cHelpers.h"
|
||||
#include "Tactility.h"
|
||||
#include "StringUtils.h"
|
||||
#include <iomanip>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "I2cScanner.h"
|
||||
#include "I2cScannerThread.h"
|
||||
#include "I2cHelpers.h"
|
||||
#include "app/i2cscanner/I2cScannerPrivate.h"
|
||||
#include "app/i2cscanner/I2cScannerThread.h"
|
||||
#include "app/i2cscanner/I2cHelpers.h"
|
||||
|
||||
#include "Assets.h"
|
||||
#include "Tactility.h"
|
||||
@@ -50,7 +50,7 @@ static void onSelectBus(lv_event_t* event) {
|
||||
TT_LOG_I(TAG, "Selected %ld", selected);
|
||||
}
|
||||
|
||||
static void onPressScan(lv_event_t* event) {
|
||||
static void onPressScan(TT_UNUSED lv_event_t* event) {
|
||||
auto data = optData();
|
||||
if (data != nullptr) {
|
||||
if (data->scanState == ScanStateScanning) {
|
||||
@@ -191,4 +191,8 @@ extern const AppManifest manifest = {
|
||||
.onHide = onHide
|
||||
};
|
||||
|
||||
void start() {
|
||||
service::loader::startApp(manifest.id);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -10,28 +10,6 @@
|
||||
|
||||
namespace tt::app::i2cscanner {
|
||||
|
||||
#define TAG "i2cscanner"
|
||||
|
||||
enum ScanState {
|
||||
ScanStateInitial,
|
||||
ScanStateScanning,
|
||||
ScanStateStopped
|
||||
};
|
||||
|
||||
struct Data {
|
||||
// Core
|
||||
Mutex mutex = Mutex(Mutex::TypeRecursive);
|
||||
std::unique_ptr<Timer> scanTimer = nullptr;
|
||||
// State
|
||||
ScanState scanState;
|
||||
i2c_port_t port = I2C_NUM_0;
|
||||
std::vector<uint8_t> scannedAddresses;
|
||||
// Widgets
|
||||
lv_obj_t* scanButtonLabelWidget = nullptr;
|
||||
lv_obj_t* portDropdownWidget = nullptr;
|
||||
lv_obj_t* scanListWidget = nullptr;
|
||||
};
|
||||
|
||||
void onScanTimerFinished(std::shared_ptr<Data> data);
|
||||
void start();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "I2cScannerThread.h"
|
||||
#include "app/i2cscanner/I2cScannerThread.h"
|
||||
#include "lvgl.h"
|
||||
#include "service/loader/Loader.h"
|
||||
|
||||
@@ -100,7 +100,7 @@ void startScanning(std::shared_ptr<Data> data) {
|
||||
|
||||
data->scanState = ScanStateScanning;
|
||||
data->scanTimer = std::make_unique<Timer>(
|
||||
Timer::TypeOnce,
|
||||
Timer::Type::Once,
|
||||
onScanTimer,
|
||||
data
|
||||
);
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#include <TactilityCore.h>
|
||||
#include "ImageViewer.h"
|
||||
#include "lvgl.h"
|
||||
#include "lvgl/Style.h"
|
||||
#include "lvgl/Toolbar.h"
|
||||
#include "StringUtils.h"
|
||||
#include "service/loader/Loader.h"
|
||||
|
||||
namespace tt::app::imageviewer {
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
#define TAG "image_viewer"
|
||||
#define IMAGE_VIEWER_FILE_ARGUMENT "file"
|
||||
|
||||
static void onShow(AppContext& app, lv_obj_t* parent) {
|
||||
auto wrapper = lv_obj_create(parent);
|
||||
@@ -57,4 +58,10 @@ extern const AppManifest manifest = {
|
||||
.onShow = onShow
|
||||
};
|
||||
|
||||
void start(const std::string& file) {
|
||||
auto parameters = std::make_shared<Bundle>();
|
||||
parameters->putString(IMAGE_VIEWER_FILE_ARGUMENT, file);
|
||||
service::loader::startApp(manifest.id, parameters);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#define IMAGE_VIEWER_FILE_ARGUMENT "file"
|
||||
namespace tt::app::imageviewer {
|
||||
|
||||
void start(const std::string& file);
|
||||
|
||||
};
|
||||
@@ -24,7 +24,7 @@ void start(const std::string& title, const std::string& message, const std::stri
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_TITLE, title);
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_MESSAGE, message);
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_PREFILLED, prefilled);
|
||||
service::loader::startApp(manifest.id, false, bundle);
|
||||
service::loader::startApp(manifest.id, bundle);
|
||||
}
|
||||
|
||||
std::string getResult(const Bundle& bundle) {
|
||||
|
||||
@@ -3,13 +3,12 @@
|
||||
#include "Check.h"
|
||||
#include "lvgl.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "Assets.h"
|
||||
|
||||
namespace tt::app::launcher {
|
||||
|
||||
static void onAppPressed(TT_UNUSED lv_event_t* e) {
|
||||
auto* appId = (const char*)lv_event_get_user_data(e);
|
||||
service::loader::startApp(appId, false);
|
||||
service::loader::startApp(appId);
|
||||
}
|
||||
|
||||
static lv_obj_t* createAppButton(lv_obj_t* parent, const char* title, const char* imageFile, const char* appId, int32_t buttonPaddingLeft) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include <TactilityCore.h>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include "lvgl.h"
|
||||
@@ -13,12 +12,12 @@
|
||||
namespace tt::app::log {
|
||||
|
||||
struct LogAppData {
|
||||
LogLevel filterLevel = LogLevelInfo;
|
||||
LogLevel filterLevel = LogLevel::Info;
|
||||
lv_obj_t* labelWidget = nullptr;
|
||||
};
|
||||
|
||||
static bool shouldShowLog(LogLevel filterLevel, LogLevel logLevel) {
|
||||
if (filterLevel == LogLevelNone || logLevel == LogLevelNone) {
|
||||
if (filterLevel == LogLevel::None || logLevel == LogLevel::None) {
|
||||
return false;
|
||||
} else {
|
||||
return filterLevel >= logLevel;
|
||||
@@ -115,19 +114,19 @@ static void onResult(AppContext& app, Result result, const Bundle& bundle) {
|
||||
if (result == ResultOk) {
|
||||
switch (resultIndex) {
|
||||
case 0:
|
||||
data->filterLevel = LogLevelVerbose;
|
||||
data->filterLevel = LogLevel::Verbose;
|
||||
break;
|
||||
case 1:
|
||||
data->filterLevel = LogLevelDebug;
|
||||
data->filterLevel = LogLevel::Debug;
|
||||
break;
|
||||
case 2:
|
||||
data->filterLevel = LogLevelInfo;
|
||||
data->filterLevel = LogLevel::Info;
|
||||
break;
|
||||
case 3:
|
||||
data->filterLevel = LogLevelWarning;
|
||||
data->filterLevel = LogLevel::Warning;
|
||||
break;
|
||||
case 4:
|
||||
data->filterLevel = LogLevelError;
|
||||
data->filterLevel = LogLevel::Error;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -16,7 +16,7 @@ extern const AppManifest manifest;
|
||||
static void onTimer(TT_UNUSED std::shared_ptr<void> context);
|
||||
|
||||
struct Data {
|
||||
Timer update_timer = Timer(Timer::TypePeriodic, &onTimer, nullptr);
|
||||
Timer update_timer = Timer(Timer::Type::Periodic, &onTimer, nullptr);
|
||||
std::shared_ptr<tt::hal::Power> power = getConfiguration()->hardware->power();
|
||||
lv_obj_t* enable_label = nullptr;
|
||||
lv_obj_t* enable_switch = nullptr;
|
||||
@@ -39,7 +39,7 @@ std::shared_ptr<Data> _Nullable optData() {
|
||||
static void updateUi(std::shared_ptr<Data> data) {
|
||||
const char* charge_state;
|
||||
hal::Power::MetricData metric_data;
|
||||
if (data->power->getMetric(hal::Power::MetricType::IS_CHARGING, metric_data)) {
|
||||
if (data->power->getMetric(hal::Power::MetricType::IsCharging, metric_data)) {
|
||||
charge_state = metric_data.valueAsBool ? "yes" : "no";
|
||||
} else {
|
||||
charge_state = "N/A";
|
||||
@@ -47,7 +47,7 @@ static void updateUi(std::shared_ptr<Data> data) {
|
||||
|
||||
uint8_t charge_level;
|
||||
bool charge_level_scaled_set = false;
|
||||
if (data->power->getMetric(hal::Power::MetricType::CHARGE_LEVEL, metric_data)) {
|
||||
if (data->power->getMetric(hal::Power::MetricType::ChargeLevel, metric_data)) {
|
||||
charge_level = metric_data.valueAsUint8;
|
||||
charge_level_scaled_set = true;
|
||||
}
|
||||
@@ -57,14 +57,14 @@ static void updateUi(std::shared_ptr<Data> data) {
|
||||
|
||||
int32_t current;
|
||||
bool current_set = false;
|
||||
if (data->power->getMetric(hal::Power::MetricType::CURRENT, metric_data)) {
|
||||
if (data->power->getMetric(hal::Power::MetricType::Current, metric_data)) {
|
||||
current = metric_data.valueAsInt32;
|
||||
current_set = true;
|
||||
}
|
||||
|
||||
uint32_t battery_voltage;
|
||||
bool battery_voltage_set = false;
|
||||
if (data->power->getMetric(hal::Power::MetricType::BATTERY_VOLTAGE, metric_data)) {
|
||||
if (data->power->getMetric(hal::Power::MetricType::BatteryVoltage, metric_data)) {
|
||||
battery_voltage = metric_data.valueAsUint32;
|
||||
battery_voltage_set = true;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#if TT_FEATURE_SCREENSHOT_ENABLED
|
||||
|
||||
#include "ScreenshotUi.h"
|
||||
#include "app/screenshot/ScreenshotUi.h"
|
||||
#include <memory>
|
||||
|
||||
namespace tt::app::screenshot {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#if TT_FEATURE_SCREENSHOT_ENABLED
|
||||
|
||||
#include "ScreenshotUi.h"
|
||||
#include "app/screenshot/ScreenshotUi.h"
|
||||
|
||||
#include "TactilityCore.h"
|
||||
#include "hal/SdCard.h"
|
||||
@@ -51,7 +51,7 @@ static void onTimerCallback(TT_UNUSED std::shared_ptr<void> context) {
|
||||
}
|
||||
|
||||
ScreenshotUi::ScreenshotUi() {
|
||||
updateTimer = std::make_unique<Timer>(Timer::TypePeriodic, onTimerCallback, nullptr);
|
||||
updateTimer = std::make_unique<Timer>(Timer::Type::Periodic, onTimerCallback, nullptr);
|
||||
}
|
||||
|
||||
ScreenshotUi::~ScreenshotUi() {
|
||||
@@ -146,7 +146,7 @@ void ScreenshotUi::createModeSettingWidgets(lv_obj_t* parent) {
|
||||
lv_obj_align_to(modeDropdown, mode_label, LV_ALIGN_OUT_RIGHT_MID, 8, 0);
|
||||
lv_obj_add_event_cb(modeDropdown, onModeSetCallback, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||
service::screenshot::Mode mode = service->getMode();
|
||||
if (mode == service::screenshot::ScreenshotModeApps) {
|
||||
if (mode == service::screenshot::Mode::Apps) {
|
||||
lv_dropdown_set_selected(modeDropdown, 1);
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ void ScreenshotUi::createFilePathWidgets(lv_obj_t* parent) {
|
||||
lv_obj_set_flex_grow(pathTextArea, 1);
|
||||
if (kernel::getPlatform() == kernel::PlatformEsp) {
|
||||
auto sdcard = tt::hal::getConfiguration()->sdcard;
|
||||
if (sdcard != nullptr && sdcard->getState() == hal::SdCard::StateMounted) {
|
||||
if (sdcard != nullptr && sdcard->getState() == hal::SdCard::State::Mounted) {
|
||||
lv_textarea_set_text(pathTextArea, "A:/sdcard");
|
||||
} else {
|
||||
lv_textarea_set_text(pathTextArea, "Error: no SD card");
|
||||
|
||||
@@ -18,12 +18,12 @@ namespace tt::app::selectiondialog {
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
void start(std::string title, const std::vector<std::string>& items) {
|
||||
void start(const std::string& title, const std::vector<std::string>& items) {
|
||||
std::string items_joined = string::join(items, PARAMETER_ITEM_CONCATENATION_TOKEN);
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_TITLE, title);
|
||||
bundle->putString(PARAMETER_BUNDLE_KEY_ITEMS, items_joined);
|
||||
service::loader::startApp(manifest.id, false, bundle);
|
||||
service::loader::startApp(manifest.id, bundle);
|
||||
}
|
||||
|
||||
int32_t getResultIndex(const Bundle& bundle) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
namespace tt::app::selectiondialog {
|
||||
|
||||
void start(std::string title, const std::vector<std::string>& items);
|
||||
void start(const std::string& title, const std::vector<std::string>& items);
|
||||
|
||||
/**
|
||||
* Get the index of the item that the user selected.
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
#include "lvgl/LabelUtils.h"
|
||||
#include "lvgl/Style.h"
|
||||
#include "lvgl/Toolbar.h"
|
||||
#include "service/loader/Loader.h"
|
||||
|
||||
#define TAG "text_viewer"
|
||||
#define TEXT_VIEWER_FILE_ARGUMENT "file"
|
||||
|
||||
namespace tt::app::textviewer {
|
||||
|
||||
@@ -45,4 +47,11 @@ extern const AppManifest manifest = {
|
||||
.onShow = onShow
|
||||
};
|
||||
|
||||
void start(const std::string& file) {
|
||||
auto parameters = std::make_shared<Bundle>();
|
||||
parameters->putString(TEXT_VIEWER_FILE_ARGUMENT, file);
|
||||
service::loader::startApp(manifest.id, parameters);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#define TEXT_VIEWER_FILE_ARGUMENT "file"
|
||||
namespace tt::app::textviewer {
|
||||
|
||||
void start(const std::string&file);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "service/loader/Loader.h"
|
||||
#include "app/timezone/TimeZone.h"
|
||||
#include "Assets.h"
|
||||
#include "Tactility.h"
|
||||
#include "time/Time.h"
|
||||
#include "lvgl/LvglSync.h"
|
||||
|
||||
@@ -15,7 +14,7 @@ namespace tt::app::timedatesettings {
|
||||
extern const AppManifest manifest;
|
||||
|
||||
struct Data {
|
||||
Mutex mutex = Mutex(Mutex::TypeRecursive);
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
lv_obj_t* regionLabelWidget = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ static void onShow(AppContext& app, lv_obj_t* parent) {
|
||||
|
||||
static void onStart(AppContext& app) {
|
||||
auto data = std::make_shared<Data>();
|
||||
data->updateTimer = std::make_unique<Timer>(Timer::TypeOnce, onUpdateTimer, data);
|
||||
data->updateTimer = std::make_unique<Timer>(Timer::Type::Once, onUpdateTimer, data);
|
||||
app.setData(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const AppContext* _Nullable optWifiApSettingsApp() {
|
||||
void start(const std::string& ssid) {
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
bundle->putString("ssid", ssid);
|
||||
service::loader::startApp(manifest.id, false, bundle);
|
||||
service::loader::startApp(manifest.id, bundle);
|
||||
}
|
||||
|
||||
static void onPressForget(TT_UNUSED lv_event_t* event) {
|
||||
@@ -135,7 +135,7 @@ void onResult(TT_UNUSED AppContext& app, TT_UNUSED Result result, const Bundle&
|
||||
TT_LOG_I(TAG, "Removed SSID");
|
||||
|
||||
if (
|
||||
service::wifi::getRadioState() == service::wifi::WIFI_RADIO_CONNECTION_ACTIVE &&
|
||||
service::wifi::getRadioState() == service::wifi::RadioState::ConnectionActive &&
|
||||
service::wifi::getConnectionTarget() == ssid
|
||||
) {
|
||||
service::wifi::disconnect();
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define WIFI_CONNECT_PARAM_SSID "ssid" // String
|
||||
#define WIFI_CONNECT_PARAM_PASSWORD "password" // String
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "State.h"
|
||||
#include "app/wificonnect/State.h"
|
||||
#include "Check.h"
|
||||
#include <cstring>
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "View.h"
|
||||
#include "State.h"
|
||||
#include "Parameters.h"
|
||||
#include "app/wificonnect/View.h"
|
||||
#include "app/wificonnect/WifiConnectPrivate.h"
|
||||
#include "WifiConnect.h"
|
||||
|
||||
#include "lvgl.h"
|
||||
@@ -186,19 +185,19 @@ void View::init(AppContext& app, lv_obj_t* parent) {
|
||||
createBottomButtons(wrapper);
|
||||
|
||||
// Keyboard bindings
|
||||
service::gui::keyboardAddTextArea(ssid_textarea);
|
||||
service::gui::keyboardAddTextArea(password_textarea);
|
||||
service::gui::keyboardAddTextArea(ssid_textarea);
|
||||
service::gui::keyboardAddTextArea(password_textarea);
|
||||
|
||||
// Init from app parameters
|
||||
auto bundle = app.getParameters();
|
||||
if (bundle != nullptr) {
|
||||
std::string ssid;
|
||||
if (bundle->optString(WIFI_CONNECT_PARAM_SSID, ssid)) {
|
||||
if (optSsidParameter(bundle, ssid)) {
|
||||
lv_textarea_set_text(ssid_textarea, ssid.c_str());
|
||||
}
|
||||
|
||||
std::string password;
|
||||
if (bundle->optString(WIFI_CONNECT_PARAM_PASSWORD, password)) {
|
||||
if (optPasswordParameter(bundle, ssid)) {
|
||||
lv_textarea_set_text(password_textarea, password.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "WifiConnect.h"
|
||||
#include "app/wificonnect/WifiConnectPrivate.h"
|
||||
|
||||
#include "app/AppContext.h"
|
||||
#include "TactilityCore.h"
|
||||
@@ -9,6 +9,8 @@
|
||||
namespace tt::app::wificonnect {
|
||||
|
||||
#define TAG "wifi_connect"
|
||||
#define WIFI_CONNECT_PARAM_SSID "ssid" // String
|
||||
#define WIFI_CONNECT_PARAM_PASSWORD "password" // String
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
@@ -23,18 +25,18 @@ std::shared_ptr<WifiConnect> _Nullable optWifiConnect() {
|
||||
}
|
||||
|
||||
static void eventCallback(const void* message, void* context) {
|
||||
auto* event = static_cast<const service::wifi::WifiEvent*>(message);
|
||||
auto* event = static_cast<const service::wifi::Event*>(message);
|
||||
auto* wifi = static_cast<WifiConnect*>(context);
|
||||
State& state = wifi->getState();
|
||||
switch (event->type) {
|
||||
case service::wifi::WifiEventTypeConnectionFailed:
|
||||
case service::wifi::EventType::ConnectionFailed:
|
||||
if (state.isConnecting()) {
|
||||
state.setConnecting(false);
|
||||
state.setConnectionError(true);
|
||||
wifi->requestViewUpdate();
|
||||
}
|
||||
break;
|
||||
case service::wifi::WifiEventTypeConnectionSuccess:
|
||||
case service::wifi::EventType::ConnectionSuccess:
|
||||
if (wifi->getState().isConnecting()) {
|
||||
state.setConnecting(false);
|
||||
service::loader::stopApp();
|
||||
@@ -123,10 +125,25 @@ extern const AppManifest manifest = {
|
||||
.id = "WifiConnect",
|
||||
.name = "Wi-Fi Connect",
|
||||
.icon = LV_SYMBOL_WIFI,
|
||||
.type = TypeSettings,
|
||||
.type = TypeHidden,
|
||||
.onStart = &onStart,
|
||||
.onShow = &onShow,
|
||||
.onHide = &onHide
|
||||
};
|
||||
|
||||
void start(const std::string& ssid, const std::string& password) {
|
||||
auto parameters = std::make_shared<Bundle>();
|
||||
parameters->putString(WIFI_CONNECT_PARAM_SSID, ssid);
|
||||
parameters->putString(WIFI_CONNECT_PARAM_PASSWORD, password);
|
||||
service::loader::startApp(manifest.id, parameters);
|
||||
}
|
||||
|
||||
bool optSsidParameter(const std::shared_ptr<const Bundle>& bundle, std::string& ssid) {
|
||||
return bundle->optString(WIFI_CONNECT_PARAM_SSID, ssid);
|
||||
}
|
||||
|
||||
bool optPasswordParameter(const std::shared_ptr<const Bundle>& bundle, std::string& password) {
|
||||
return bundle->optString(WIFI_CONNECT_PARAM_PASSWORD, password);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,48 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "Bindings.h"
|
||||
#include "State.h"
|
||||
#include "View.h"
|
||||
|
||||
#include "Mutex.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
#include <string>
|
||||
|
||||
namespace tt::app::wificonnect {
|
||||
|
||||
class WifiConnect {
|
||||
Mutex mutex;
|
||||
State state;
|
||||
Bindings bindings = {
|
||||
.onConnectSsid = nullptr,
|
||||
.onConnectSsidContext = nullptr
|
||||
};
|
||||
View view = View(&bindings, &state);
|
||||
PubSubSubscription* wifiSubscription;
|
||||
bool view_enabled = false;
|
||||
|
||||
public:
|
||||
|
||||
WifiConnect();
|
||||
~WifiConnect();
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
void onShow(AppContext& app, lv_obj_t* parent);
|
||||
void onHide(AppContext& app);
|
||||
|
||||
State& getState() { return state; }
|
||||
Bindings& getBindings() { return bindings; }
|
||||
View& getView() { return view; }
|
||||
|
||||
|
||||
void requestViewUpdate();
|
||||
};
|
||||
|
||||
void lock(WifiConnect* wifi);
|
||||
|
||||
void unlock(WifiConnect* wifi);
|
||||
|
||||
void view_update(WifiConnect* wifi);
|
||||
/**
|
||||
* Start the app with optional pre-filled fields.
|
||||
*/
|
||||
void start(const std::string& ssid = "", const std::string& password = "");
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <Check.h>
|
||||
#include "WifiManage.h"
|
||||
#include "app/wifimanage/WifiManagePrivate.h"
|
||||
|
||||
namespace tt::app::wifimanage {
|
||||
|
||||
@@ -10,16 +10,16 @@ void State::setScanning(bool isScanning) {
|
||||
tt_check(mutex.release() == TtStatusOk);
|
||||
}
|
||||
|
||||
void State::setRadioState(service::wifi::WifiRadioState state) {
|
||||
void State::setRadioState(service::wifi::RadioState state) {
|
||||
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
|
||||
radioState = state;
|
||||
if (radioState == service::wifi::WIFI_RADIO_OFF) {
|
||||
if (radioState == service::wifi::RadioState::Off) {
|
||||
scannedAfterRadioOn = false;
|
||||
}
|
||||
tt_check(mutex.release() == TtStatusOk);
|
||||
}
|
||||
|
||||
service::wifi::WifiRadioState State::getRadioState() const {
|
||||
service::wifi::RadioState State::getRadioState() const {
|
||||
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
|
||||
auto result = radioState;
|
||||
tt_check(mutex.release() == TtStatusOk);
|
||||
@@ -33,7 +33,7 @@ bool State::isScanning() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
const std::vector<service::wifi::WifiApRecord>& State::lockApRecords() const {
|
||||
const std::vector<service::wifi::ApRecord>& State::lockApRecords() const {
|
||||
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
|
||||
return apRecords;
|
||||
}
|
||||
@@ -48,7 +48,7 @@ void State::updateApRecords() {
|
||||
tt_check(mutex.release() == TtStatusOk);
|
||||
}
|
||||
|
||||
void State::setConnectSsid(std::string ssid) {
|
||||
void State::setConnectSsid(const std::string& ssid) {
|
||||
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
|
||||
connectSsid = ssid;
|
||||
tt_check(mutex.release() == TtStatusOk);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "View.h"
|
||||
#include "WifiManage.h"
|
||||
#include "app/wifimanage/View.h"
|
||||
#include "app/wifimanage/WifiManagePrivate.h"
|
||||
|
||||
#include "Log.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
@@ -48,6 +48,11 @@ static void on_enable_on_boot_switch_changed(lv_event_t* event) {
|
||||
}
|
||||
}
|
||||
|
||||
static void onConnectToHiddenClicked(lv_event_t* event) {
|
||||
auto* bindings = (Bindings*)lv_event_get_user_data(event);
|
||||
bindings->onConnectToHidden();
|
||||
}
|
||||
|
||||
// region Secondary updates
|
||||
|
||||
static void connect(lv_event_t* event) {
|
||||
@@ -73,7 +78,7 @@ static void showDetails(lv_event_t* event) {
|
||||
bindings->onShowApSettings(ssid);
|
||||
}
|
||||
|
||||
void View::createSsidListItem(const service::wifi::WifiApRecord& record, bool isConnecting) {
|
||||
void View::createSsidListItem(const service::wifi::ApRecord& record, bool isConnecting) {
|
||||
lv_obj_t* wrapper = lv_obj_create(networks_list);
|
||||
lv_obj_add_event_cb(wrapper, &connect, LV_EVENT_SHORT_CLICKED, bindings);
|
||||
lv_obj_set_user_data(wrapper, bindings);
|
||||
@@ -124,20 +129,36 @@ void View::createSsidListItem(const service::wifi::WifiApRecord& record, bool is
|
||||
}
|
||||
}
|
||||
|
||||
void View::updateConnectToHidden() {
|
||||
switch (state->getRadioState()) {
|
||||
case service::wifi::RadioState::On:
|
||||
case service::wifi::RadioState::ConnectionPending:
|
||||
case service::wifi::RadioState::ConnectionActive:
|
||||
lv_obj_remove_flag(connect_to_hidden, LV_OBJ_FLAG_HIDDEN);
|
||||
break;
|
||||
|
||||
case service::wifi::RadioState::OnPending:
|
||||
case service::wifi::RadioState::OffPending:
|
||||
case service::wifi::RadioState::Off:
|
||||
lv_obj_add_flag(connect_to_hidden, LV_OBJ_FLAG_HIDDEN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void View::updateNetworkList() {
|
||||
lv_obj_clean(networks_list);
|
||||
|
||||
switch (state->getRadioState()) {
|
||||
case service::wifi::WIFI_RADIO_ON_PENDING:
|
||||
case service::wifi::WIFI_RADIO_ON:
|
||||
case service::wifi::WIFI_RADIO_CONNECTION_PENDING:
|
||||
case service::wifi::WIFI_RADIO_CONNECTION_ACTIVE: {
|
||||
case service::wifi::RadioState::OnPending:
|
||||
case service::wifi::RadioState::On:
|
||||
case service::wifi::RadioState::ConnectionPending:
|
||||
case service::wifi::RadioState::ConnectionActive: {
|
||||
|
||||
std::string connection_target = service::wifi::getConnectionTarget();
|
||||
auto& ap_records = state->lockApRecords();
|
||||
|
||||
bool is_connected = !connection_target.empty() &&
|
||||
state->getRadioState() == service::wifi::WIFI_RADIO_CONNECTION_ACTIVE;
|
||||
state->getRadioState() == service::wifi::RadioState::ConnectionActive;
|
||||
bool added_connected = false;
|
||||
if (is_connected) {
|
||||
if (!ap_records.empty()) {
|
||||
@@ -159,8 +180,8 @@ void View::updateNetworkList() {
|
||||
if (used_ssids.find(record.ssid) == used_ssids.end()) {
|
||||
bool connection_target_match = (record.ssid == connection_target);
|
||||
bool is_connecting = connection_target_match
|
||||
&& state->getRadioState() == service::wifi::WIFI_RADIO_CONNECTION_PENDING &&
|
||||
!connection_target.empty();
|
||||
&& state->getRadioState() == service::wifi::RadioState::ConnectionPending &&
|
||||
!connection_target.empty();
|
||||
bool skip = connection_target_match && added_connected;
|
||||
if (!skip) {
|
||||
createSsidListItem(record, is_connecting);
|
||||
@@ -180,8 +201,8 @@ void View::updateNetworkList() {
|
||||
state->unlockApRecords();
|
||||
break;
|
||||
}
|
||||
case service::wifi::WIFI_RADIO_OFF_PENDING:
|
||||
case service::wifi::WIFI_RADIO_OFF: {
|
||||
case service::wifi::RadioState::OffPending:
|
||||
case service::wifi::RadioState::Off: {
|
||||
lv_obj_add_flag(networks_list, LV_OBJ_FLAG_HIDDEN);
|
||||
break;
|
||||
}
|
||||
@@ -189,7 +210,7 @@ void View::updateNetworkList() {
|
||||
}
|
||||
|
||||
void View::updateScanning() {
|
||||
if (state->getRadioState() == service::wifi::WIFI_RADIO_ON && state->isScanning()) {
|
||||
if (state->getRadioState() == service::wifi::RadioState::On && state->isScanning()) {
|
||||
lv_obj_clear_flag(scanning_spinner, LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_add_flag(scanning_spinner, LV_OBJ_FLAG_HIDDEN);
|
||||
@@ -199,18 +220,18 @@ void View::updateScanning() {
|
||||
void View::updateWifiToggle() {
|
||||
lv_obj_clear_state(enable_switch, LV_STATE_ANY);
|
||||
switch (state->getRadioState()) {
|
||||
case service::wifi::WIFI_RADIO_ON:
|
||||
case service::wifi::WIFI_RADIO_CONNECTION_PENDING:
|
||||
case service::wifi::WIFI_RADIO_CONNECTION_ACTIVE:
|
||||
case service::wifi::RadioState::On:
|
||||
case service::wifi::RadioState::ConnectionPending:
|
||||
case service::wifi::RadioState::ConnectionActive:
|
||||
lv_obj_add_state(enable_switch, LV_STATE_CHECKED);
|
||||
break;
|
||||
case service::wifi::WIFI_RADIO_ON_PENDING:
|
||||
case service::wifi::RadioState::OnPending:
|
||||
lv_obj_add_state(enable_switch, LV_STATE_CHECKED | LV_STATE_DISABLED);
|
||||
break;
|
||||
case service::wifi::WIFI_RADIO_OFF:
|
||||
case service::wifi::RadioState::Off:
|
||||
lv_obj_remove_state(enable_switch, LV_STATE_CHECKED | LV_STATE_DISABLED);
|
||||
break;
|
||||
case service::wifi::WIFI_RADIO_OFF_PENDING:
|
||||
case service::wifi::RadioState::OffPending:
|
||||
lv_obj_remove_state(enable_switch, LV_STATE_CHECKED);
|
||||
lv_obj_add_state(enable_switch, LV_STATE_DISABLED);
|
||||
break;
|
||||
@@ -233,7 +254,7 @@ void View::updateEnableOnBootToggle() {
|
||||
void View::init(const AppContext& app, lv_obj_t* parent) {
|
||||
root = parent;
|
||||
|
||||
paths = std::move(app.getPaths());
|
||||
paths = app.getPaths();
|
||||
|
||||
// Toolbar
|
||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
||||
@@ -279,6 +300,14 @@ void View::init(const AppContext& app, lv_obj_t* parent) {
|
||||
lv_obj_set_style_pad_top(networks_list, 0, 0);
|
||||
lv_obj_set_style_pad_bottom(networks_list, 0, 0);
|
||||
lv_obj_align(networks_list, LV_ALIGN_TOP_LEFT, 0, 44);
|
||||
|
||||
connect_to_hidden = lv_button_create(secondary_flex);
|
||||
lv_obj_set_width(connect_to_hidden, LV_PCT(100));
|
||||
lv_obj_set_style_margin_bottom(connect_to_hidden, 8, 0);
|
||||
lv_obj_set_style_margin_hor(connect_to_hidden, 12, 0);
|
||||
lv_obj_add_event_cb(connect_to_hidden, onConnectToHiddenClicked, LV_EVENT_SHORT_CLICKED, bindings);
|
||||
auto* connect_to_hidden_label = lv_label_create(connect_to_hidden);
|
||||
lv_label_set_text(connect_to_hidden_label, "Connect to hidden SSID");
|
||||
}
|
||||
|
||||
void View::update() {
|
||||
@@ -286,6 +315,7 @@ void View::update() {
|
||||
updateEnableOnBootToggle();
|
||||
updateScanning();
|
||||
updateNetworkList();
|
||||
updateConnectToHidden();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "WifiManage.h"
|
||||
#include "View.h"
|
||||
#include "State.h"
|
||||
#include "app/wifimanage/WifiManagePrivate.h"
|
||||
#include "app/wifimanage/View.h"
|
||||
#include "app/wifimanage/State.h"
|
||||
|
||||
#include "app/AppContext.h"
|
||||
#include "app/wificonnect/Parameters.h"
|
||||
#include "app/wifiapsettings/WifiApSettings.h"
|
||||
#include "TactilityCore.h"
|
||||
#include "service/loader/Loader.h"
|
||||
#include "service/wifi/WifiSettings.h"
|
||||
#include "lvgl/LvglSync.h"
|
||||
#include "app/wificonnect/WifiConnect.h"
|
||||
|
||||
namespace tt::app::wifimanage {
|
||||
|
||||
@@ -33,10 +33,7 @@ static void onConnect(const char* ssid) {
|
||||
service::wifi::connect(&settings, false);
|
||||
} else {
|
||||
TT_LOG_I(TAG, "Starting connection dialog");
|
||||
auto bundle = std::make_shared<Bundle>();
|
||||
bundle->putString(WIFI_CONNECT_PARAM_SSID, ssid);
|
||||
bundle->putString(WIFI_CONNECT_PARAM_PASSWORD, "");
|
||||
service::loader::startApp("WifiConnect", false, bundle);
|
||||
wificonnect::start(ssid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,12 +49,17 @@ static void onWifiToggled(bool enabled) {
|
||||
service::wifi::setEnabled(enabled);
|
||||
}
|
||||
|
||||
static void onConnectToHidden() {
|
||||
wificonnect::start();
|
||||
}
|
||||
|
||||
WifiManage::WifiManage() {
|
||||
bindings = (Bindings) {
|
||||
.onWifiToggled = onWifiToggled,
|
||||
.onConnectSsid = onConnect,
|
||||
.onDisconnect = onDisconnect,
|
||||
.onShowApSettings = onShowApSettings
|
||||
.onShowApSettings = onShowApSettings,
|
||||
.onConnectToHidden = onConnectToHidden
|
||||
};
|
||||
}
|
||||
|
||||
@@ -83,19 +85,20 @@ void WifiManage::requestViewUpdate() {
|
||||
}
|
||||
|
||||
static void wifiManageEventCallback(const void* message, void* context) {
|
||||
auto* event = (service::wifi::WifiEvent*)message;
|
||||
auto* event = (service::wifi::Event*)message;
|
||||
auto* wifi = (WifiManage*)context;
|
||||
TT_LOG_I(TAG, "Update with state %d", service::wifi::getRadioState());
|
||||
wifi->getState().setRadioState(service::wifi::getRadioState());
|
||||
auto radio_state = service::wifi::getRadioState();
|
||||
TT_LOG_I(TAG, "Update with state %s", service::wifi::radioStateToString(radio_state));
|
||||
wifi->getState().setRadioState(radio_state);
|
||||
switch (event->type) {
|
||||
case tt::service::wifi::WifiEventTypeScanStarted:
|
||||
case tt::service::wifi::EventType::ScanStarted:
|
||||
wifi->getState().setScanning(true);
|
||||
break;
|
||||
case tt::service::wifi::WifiEventTypeScanFinished:
|
||||
case tt::service::wifi::EventType::ScanFinished:
|
||||
wifi->getState().setScanning(false);
|
||||
wifi->getState().updateApRecords();
|
||||
break;
|
||||
case tt::service::wifi::WifiEventTypeRadioStateOn:
|
||||
case tt::service::wifi::EventType::RadioStateOn:
|
||||
if (!service::wifi::isScanning()) {
|
||||
service::wifi::scan();
|
||||
}
|
||||
@@ -124,11 +127,11 @@ void WifiManage::onShow(AppContext& app, lv_obj_t* parent) {
|
||||
view.update();
|
||||
unlock();
|
||||
|
||||
service::wifi::WifiRadioState radio_state = service::wifi::getRadioState();
|
||||
bool can_scan = radio_state == service::wifi::WIFI_RADIO_ON ||
|
||||
radio_state == service::wifi::WIFI_RADIO_CONNECTION_PENDING ||
|
||||
radio_state == service::wifi::WIFI_RADIO_CONNECTION_ACTIVE;
|
||||
TT_LOG_I(TAG, "%d %d", radio_state, service::wifi::isScanning());
|
||||
service::wifi::RadioState radio_state = service::wifi::getRadioState();
|
||||
bool can_scan = radio_state == service::wifi::RadioState::On ||
|
||||
radio_state == service::wifi::RadioState::ConnectionPending ||
|
||||
radio_state == service::wifi::RadioState::ConnectionActive;
|
||||
TT_LOG_I(TAG, "%s %d", service::wifi::radioStateToString(radio_state), (int)service::wifi::isScanning());
|
||||
if (can_scan && !service::wifi::isScanning()) {
|
||||
service::wifi::scan();
|
||||
}
|
||||
@@ -172,4 +175,8 @@ extern const AppManifest manifest = {
|
||||
.onHide = onHide
|
||||
};
|
||||
|
||||
void start() {
|
||||
service::loader::startApp(manifest.id);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,35 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "Mutex.h"
|
||||
#include "View.h"
|
||||
#include "State.h"
|
||||
#include "app/wifimanage/View.h"
|
||||
#include "app/wifimanage/State.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
|
||||
namespace tt::app::wifimanage {
|
||||
|
||||
class WifiManage {
|
||||
|
||||
PubSubSubscription* wifiSubscription = nullptr;
|
||||
Mutex mutex;
|
||||
Bindings bindings = { };
|
||||
State state;
|
||||
View view = View(&bindings, &state);
|
||||
bool isViewEnabled = false;
|
||||
|
||||
public:
|
||||
|
||||
WifiManage();
|
||||
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
void onShow(AppContext& app, lv_obj_t* parent);
|
||||
void onHide(AppContext& app);
|
||||
|
||||
Bindings& getBindings() { return bindings; }
|
||||
State& getState() { return state; }
|
||||
|
||||
void requestViewUpdate();
|
||||
};
|
||||
void start();
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -26,10 +26,10 @@ struct StatusbarIcon {
|
||||
};
|
||||
|
||||
struct StatusbarData {
|
||||
Mutex mutex = Mutex(Mutex::TypeRecursive);
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
std::shared_ptr<PubSub> pubsub = std::make_shared<PubSub>();
|
||||
StatusbarIcon icons[STATUSBAR_ICON_LIMIT] = {};
|
||||
Timer* time_update_timer = new Timer(Timer::TypeOnce, onUpdateTime, nullptr);
|
||||
Timer* time_update_timer = new Timer(Timer::Type::Once, onUpdateTime, nullptr);
|
||||
uint8_t time_hours = 0;
|
||||
uint8_t time_minutes = 0;
|
||||
bool time_set = false;
|
||||
|
||||
@@ -17,6 +17,13 @@ namespace tt::service::loader {
|
||||
|
||||
#define TAG "loader"
|
||||
|
||||
enum class LoaderStatus {
|
||||
Ok,
|
||||
ErrorAppStarted,
|
||||
ErrorUnknownApp,
|
||||
ErrorInternal,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
LoaderEventType type;
|
||||
} LoaderEventInternal;
|
||||
@@ -41,20 +48,11 @@ static void loader_free() {
|
||||
loader_singleton = nullptr;
|
||||
}
|
||||
|
||||
void startApp(const std::string& id, bool blocking, const std::shared_ptr<const Bundle>& parameters) {
|
||||
void startApp(const std::string& id, const std::shared_ptr<const Bundle>& parameters) {
|
||||
TT_LOG_I(TAG, "Start app %s", id.c_str());
|
||||
tt_assert(loader_singleton);
|
||||
|
||||
auto message = std::make_shared<LoaderMessageAppStart>(id, parameters);
|
||||
loader_singleton->dispatcherThread->dispatch(onStartAppMessage, message);
|
||||
|
||||
auto event_flag = message->getApiLockEventFlag();
|
||||
if (blocking) {
|
||||
/* TODO: Check if task id is not the LVGL one,
|
||||
because otherwise this fails as the apps starting logic will try to lock lvgl
|
||||
to update the UI and fail. */
|
||||
event_flag->wait(message->getApiLockEventFlagValue());
|
||||
}
|
||||
}
|
||||
|
||||
void stopApp() {
|
||||
@@ -163,7 +161,7 @@ static LoaderStatus startAppWithManifestInternal(
|
||||
|
||||
auto scoped_lock = loader_singleton->mutex.scoped();
|
||||
if (!scoped_lock->lock(50 / portTICK_PERIOD_MS)) {
|
||||
return LoaderStatusErrorInternal;
|
||||
return LoaderStatus::ErrorInternal;
|
||||
}
|
||||
|
||||
auto previous_app = !loader_singleton->appStack.empty() ? loader_singleton->appStack.top() : nullptr;
|
||||
@@ -192,7 +190,7 @@ static LoaderStatus startAppWithManifestInternal(
|
||||
};
|
||||
tt_pubsub_publish(loader_singleton->pubsubExternal, &event_external);
|
||||
|
||||
return LoaderStatusOk;
|
||||
return LoaderStatus::Ok;
|
||||
}
|
||||
|
||||
static void onStartAppMessage(std::shared_ptr<void> message) {
|
||||
@@ -213,7 +211,7 @@ static LoaderStatus startAppInternal(
|
||||
const app::AppManifest* manifest = app::findAppById(id);
|
||||
if (manifest == nullptr) {
|
||||
TT_LOG_E(TAG, "App not found: %s", id.c_str());
|
||||
return LoaderStatusErrorUnknownApp;
|
||||
return LoaderStatus::ErrorUnknownApp;
|
||||
} else {
|
||||
return startAppWithManifestInternal(manifest, parameters);
|
||||
}
|
||||
|
||||
@@ -10,21 +10,13 @@ namespace tt::service::loader {
|
||||
|
||||
typedef struct Loader Loader;
|
||||
|
||||
typedef enum {
|
||||
LoaderStatusOk,
|
||||
LoaderStatusErrorAppStarted,
|
||||
LoaderStatusErrorUnknownApp,
|
||||
LoaderStatusErrorInternal,
|
||||
} LoaderStatus;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Start an app
|
||||
* @param[in] id application name or id
|
||||
* @param[in] blocking whether this call is blocking or not. You cannot call this from an LVGL thread.
|
||||
* @param[in] parameters optional parameters to pass onto the application
|
||||
*/
|
||||
void startApp(const std::string& id, bool blocking = false, const std::shared_ptr<const Bundle>& _Nullable parameters = nullptr);
|
||||
void startApp(const std::string& id, const std::shared_ptr<const Bundle>& _Nullable parameters = nullptr);
|
||||
|
||||
/** @brief Stop the currently showing app. Show the previous app if any app was still running. */
|
||||
void stopApp();
|
||||
|
||||
@@ -32,7 +32,7 @@ void ScreenshotService::startApps(const char* path) {
|
||||
|
||||
if (task == nullptr || task->isFinished()) {
|
||||
task = std::make_unique<ScreenshotTask>();
|
||||
mode = ScreenshotModeApps;
|
||||
mode = Mode::Apps;
|
||||
task->startApps(path);
|
||||
} else {
|
||||
TT_LOG_W(TAG, "Screenshot task already running");
|
||||
@@ -48,7 +48,7 @@ void ScreenshotService::startTimed(const char* path, uint8_t delayInSeconds, uin
|
||||
|
||||
if (task == nullptr || task->isFinished()) {
|
||||
task = std::make_unique<ScreenshotTask>();
|
||||
mode = ScreenshotModeTimed;
|
||||
mode = Mode::Timed;
|
||||
task->startTimed(path, delayInSeconds, amount);
|
||||
} else {
|
||||
TT_LOG_W(TAG, "Screenshot task already running");
|
||||
@@ -64,17 +64,17 @@ void ScreenshotService::stop() {
|
||||
|
||||
if (task != nullptr) {
|
||||
task = nullptr;
|
||||
mode = ScreenshotModeNone;
|
||||
mode = Mode::None;
|
||||
} else {
|
||||
TT_LOG_W(TAG, "Screenshot task not running");
|
||||
}
|
||||
}
|
||||
|
||||
Mode ScreenshotService::getMode() {
|
||||
Mode ScreenshotService::getMode() const {
|
||||
auto scoped_lockable = mutex.scoped();
|
||||
if (!scoped_lockable->lock(50 / portTICK_PERIOD_MS)) {
|
||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
|
||||
return ScreenshotModeNone;
|
||||
return Mode::None;
|
||||
}
|
||||
|
||||
return mode;
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
|
||||
namespace tt::service::screenshot {
|
||||
|
||||
typedef enum {
|
||||
ScreenshotModeNone,
|
||||
ScreenshotModeTimed,
|
||||
ScreenshotModeApps
|
||||
} Mode;
|
||||
enum class Mode {
|
||||
None,
|
||||
Timed,
|
||||
Apps
|
||||
};
|
||||
|
||||
class ScreenshotService {
|
||||
|
||||
@@ -22,14 +22,14 @@ private:
|
||||
|
||||
Mutex mutex;
|
||||
std::unique_ptr<ScreenshotTask> task;
|
||||
Mode mode = ScreenshotModeNone;
|
||||
Mode mode = Mode::None;
|
||||
|
||||
public:
|
||||
|
||||
bool isTaskStarted();
|
||||
|
||||
/** The state of the service. */
|
||||
Mode getMode();
|
||||
Mode getMode() const;
|
||||
|
||||
/** @brief Start taking screenshot whenever an app is started
|
||||
* @param[in] path the path to store the screenshots at
|
||||
|
||||
@@ -25,7 +25,7 @@ class ScreenshotTask {
|
||||
};
|
||||
|
||||
Thread* thread = nullptr;
|
||||
Mutex mutex = Mutex(Mutex::TypeRecursive);
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
bool interrupted = false;
|
||||
bool finished = false;
|
||||
ScreenshotTaskWork work;
|
||||
|
||||
@@ -80,17 +80,17 @@ const char* getWifiStatusIconForRssi(int rssi) {
|
||||
}
|
||||
}
|
||||
|
||||
static const char* getWifiStatusIcon(wifi::WifiRadioState state, bool secure) {
|
||||
static const char* getWifiStatusIcon(wifi::RadioState state, bool secure) {
|
||||
int rssi;
|
||||
switch (state) {
|
||||
case wifi::WIFI_RADIO_ON:
|
||||
case wifi::WIFI_RADIO_ON_PENDING:
|
||||
case wifi::WIFI_RADIO_CONNECTION_PENDING:
|
||||
case wifi::RadioState::On:
|
||||
case wifi::RadioState::OnPending:
|
||||
case wifi::RadioState::ConnectionPending:
|
||||
return STATUSBAR_ICON_WIFI_SCAN_WHITE;
|
||||
case wifi::WIFI_RADIO_OFF_PENDING:
|
||||
case wifi::WIFI_RADIO_OFF:
|
||||
case wifi::RadioState::OffPending:
|
||||
case wifi::RadioState::Off:
|
||||
return STATUSBAR_ICON_WIFI_OFF_WHITE;
|
||||
case wifi::WIFI_RADIO_CONNECTION_ACTIVE:
|
||||
case wifi::RadioState::ConnectionActive:
|
||||
rssi = wifi::getRssi();
|
||||
return getWifiStatusIconForRssi(rssi);
|
||||
default:
|
||||
@@ -99,7 +99,7 @@ static const char* getWifiStatusIcon(wifi::WifiRadioState state, bool secure) {
|
||||
}
|
||||
|
||||
static void updateWifiIcon(const service::Paths* paths, const std::shared_ptr<ServiceData>& data) {
|
||||
wifi::WifiRadioState radio_state = wifi::getRadioState();
|
||||
wifi::RadioState radio_state = wifi::getRadioState();
|
||||
bool is_secure = wifi::isConnectionSecure();
|
||||
const char* desired_icon = getWifiStatusIcon(radio_state, is_secure);
|
||||
if (data->wifi_last_icon != desired_icon) {
|
||||
@@ -120,11 +120,11 @@ static void updateWifiIcon(const service::Paths* paths, const std::shared_ptr<Se
|
||||
|
||||
static const char* getSdCardStatusIcon(hal::SdCard::State state) {
|
||||
switch (state) {
|
||||
case hal::SdCard::StateMounted:
|
||||
case hal::SdCard::State::Mounted:
|
||||
return STATUSBAR_ICON_SDCARD;
|
||||
case hal::SdCard::StateError:
|
||||
case hal::SdCard::StateUnmounted:
|
||||
case hal::SdCard::StateUnknown:
|
||||
case hal::SdCard::State::Error:
|
||||
case hal::SdCard::State::Unmounted:
|
||||
case hal::SdCard::State::Unknown:
|
||||
return STATUSBAR_ICON_SDCARD_ALERT;
|
||||
default:
|
||||
tt_crash("Unhandled SdCard state");
|
||||
@@ -135,7 +135,7 @@ static void updateSdCardIcon(const service::Paths* paths, const std::shared_ptr<
|
||||
auto sdcard = tt::hal::getConfiguration()->sdcard;
|
||||
if (sdcard != nullptr) {
|
||||
auto state = sdcard->getState();
|
||||
if (state != hal::SdCard::StateUnknown) {
|
||||
if (state != hal::SdCard::State::Unknown) {
|
||||
auto* desired_icon = getSdCardStatusIcon(state);
|
||||
if (data->sdcard_last_icon != desired_icon) {
|
||||
auto icon_path = paths->getSystemPathLvgl(desired_icon);
|
||||
@@ -161,7 +161,7 @@ static _Nullable const char* getPowerStatusIcon() {
|
||||
auto power = get_power();
|
||||
|
||||
hal::Power::MetricData charge_level;
|
||||
if (!power->getMetric(hal::Power::MetricType::CHARGE_LEVEL, charge_level)) {
|
||||
if (!power->getMetric(hal::Power::MetricType::ChargeLevel, charge_level)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ static void onStart(ServiceContext& service) {
|
||||
auto data = std::make_shared<ServiceData>();
|
||||
lvgl::unlock();
|
||||
|
||||
data->paths = std::move(service.getPaths());
|
||||
data->paths = service.getPaths();
|
||||
|
||||
service.setData(data);
|
||||
|
||||
@@ -238,7 +238,7 @@ static void onStart(ServiceContext& service) {
|
||||
updateSdCardIcon(data->paths.get(), data); // also updates visibility
|
||||
updatePowerStatusIcon(data->paths.get(), data);
|
||||
|
||||
data->updateTimer = std::make_unique<Timer>(Timer::TypePeriodic, onUpdate, data);
|
||||
data->updateTimer = std::make_unique<Timer>(Timer::Type::Periodic, onUpdate, data);
|
||||
// We want to try and scan more often in case of startup or scan lock failure
|
||||
data->updateTimer->start(1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user