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:
Ken Van Hoeylandt
2025-01-17 19:37:42 +01:00
committed by GitHub
parent 3ca0f8cf97
commit 3ea02d912f
147 changed files with 1538 additions and 739 deletions
+50 -20
View File
@@ -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