Fixes and improvements (#132)
- Fix glitch when turning on WiFi: It would temporarily show "No networks found" right before starting the first scan. - Fix spinner to use Assets.h - Replace statusbar battery icons - Better statusbar icon for when WiFi is on but not connected - Replace statusbar WiFi icons and Wifi Manage RSSI/lock icons - Fix for crash when timer is null in I2cScanner - Deprecate Spacer - Fixes for toolbar layout (simplified) - Improved ImageViewer app: center image and add filename text on the bottom - Add LV debug params to sdkconfig.developer - Disabled LV spinner, msgbox and window widgets. These have equivalents in Tactility.
This commit is contained in:
committed by
GitHub
parent
b4592dd7d1
commit
f34440eb6f
@@ -219,7 +219,7 @@ static void onShow(AppContext& app, lv_obj_t* parent) {
|
||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
||||
|
||||
lv_obj_t* toolbar = lvgl::toolbar_create(parent, "Files");
|
||||
lvgl::toolbar_add_action(toolbar, LV_SYMBOL_UP, &onNavigateUpPressed, nullptr);
|
||||
lvgl::toolbar_add_button_action(toolbar, LV_SYMBOL_UP, &onNavigateUpPressed, nullptr);
|
||||
|
||||
data->list = lv_list_create(parent);
|
||||
lv_obj_set_width(data->list, LV_PCT(100));
|
||||
|
||||
@@ -162,7 +162,10 @@ static void onHide(AppContext& app) {
|
||||
|
||||
bool isRunning = false;
|
||||
if (data->mutex.acquire(250 / portTICK_PERIOD_MS) == TtStatusOk) {
|
||||
isRunning = data->scanTimer->isRunning();
|
||||
auto* timer = data->scanTimer.get();
|
||||
if (timer != nullptr) {
|
||||
isRunning = timer->isRunning();
|
||||
}
|
||||
data->mutex.release();
|
||||
} else {
|
||||
return;
|
||||
|
||||
@@ -3,25 +3,39 @@
|
||||
#include "lvgl.h"
|
||||
#include "lvgl/Style.h"
|
||||
#include "lvgl/Toolbar.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
namespace tt::app::imageviewer {
|
||||
|
||||
extern const AppManifest manifest;
|
||||
|
||||
#define TAG "image_viewer"
|
||||
|
||||
static void onShow(AppContext& app, lv_obj_t* parent) {
|
||||
lv_obj_set_flex_flow(parent, LV_FLEX_FLOW_COLUMN);
|
||||
lvgl::toolbar_create(parent, app);
|
||||
|
||||
lv_obj_t* wrapper = lv_obj_create(parent);
|
||||
lv_obj_set_width(wrapper, LV_PCT(100));
|
||||
lv_obj_set_flex_grow(wrapper, 1);
|
||||
lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN);
|
||||
auto wrapper = lv_obj_create(parent);
|
||||
lv_obj_set_size(wrapper, LV_PCT(100), LV_PCT(100));
|
||||
lv_obj_set_style_border_width(wrapper, 0, 0);
|
||||
lvgl::obj_set_style_no_padding(wrapper);
|
||||
lvgl::obj_set_style_bg_invisible(wrapper);
|
||||
|
||||
lv_obj_t* image = lv_img_create(wrapper);
|
||||
auto toolbar = lvgl::toolbar_create(wrapper, app);
|
||||
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
auto* image_wrapper = lv_obj_create(wrapper);
|
||||
lv_obj_align_to(image_wrapper, toolbar, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
|
||||
lv_obj_set_width(image_wrapper, LV_PCT(100));
|
||||
auto parent_height = lv_obj_get_height(wrapper);
|
||||
lv_obj_set_height(image_wrapper, parent_height - TOOLBAR_HEIGHT);
|
||||
lv_obj_set_flex_flow(image_wrapper, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_align(image_wrapper, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
|
||||
lvgl::obj_set_style_no_padding(image_wrapper);
|
||||
lvgl::obj_set_style_bg_invisible(image_wrapper);
|
||||
|
||||
auto* image = lv_image_create(image_wrapper);
|
||||
lv_obj_align(image, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
auto* file_label = lv_label_create(wrapper);
|
||||
lv_obj_align_to(file_label, wrapper, LV_ALIGN_BOTTOM_LEFT, 0, 0);
|
||||
|
||||
std::shared_ptr<const Bundle> bundle = app.getParameters();
|
||||
tt_check(bundle != nullptr, "Parameters not set");
|
||||
std::string file_argument;
|
||||
@@ -29,6 +43,10 @@ static void onShow(AppContext& app, lv_obj_t* parent) {
|
||||
std::string prefixed_path = "A:" + file_argument;
|
||||
TT_LOG_I(TAG, "Opening %s", prefixed_path.c_str());
|
||||
lv_img_set_src(image, prefixed_path.c_str());
|
||||
auto path = string::getLastPathSegment(file_argument);
|
||||
lv_label_set_text(file_label, path.c_str());
|
||||
} else {
|
||||
lv_label_set_text(file_label, "File not found");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "service/wifi/WifiSettings.h"
|
||||
#include "lvgl/Style.h"
|
||||
#include "lvgl/Toolbar.h"
|
||||
#include "lvgl/Spinner.h"
|
||||
#include <TactilityCore.h>
|
||||
#include <cstring>
|
||||
|
||||
@@ -97,8 +98,7 @@ void View::createBottomButtons(lv_obj_t* parent) {
|
||||
lv_obj_align(remember_label, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_obj_align_to(remember_label, remember_switch, LV_ALIGN_OUT_RIGHT_MID, 4, 0);
|
||||
|
||||
connecting_spinner = lv_spinner_create(button_container);
|
||||
lv_obj_set_size(connecting_spinner, 32, 32);
|
||||
connecting_spinner = tt::lvgl::spinner_create(button_container);
|
||||
lv_obj_align(connecting_spinner, LV_ALIGN_RIGHT_MID, 0, 0);
|
||||
lv_obj_add_flag(connecting_spinner, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
|
||||
@@ -6,12 +6,16 @@ namespace tt::app::wifimanage {
|
||||
void State::setScanning(bool isScanning) {
|
||||
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
|
||||
scanning = isScanning;
|
||||
scannedAfterRadioOn |= isScanning;
|
||||
tt_check(mutex.release() == TtStatusOk);
|
||||
}
|
||||
|
||||
void State::setRadioState(service::wifi::WifiRadioState state) {
|
||||
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
|
||||
radioState = state;
|
||||
if (radioState == service::wifi::WIFI_RADIO_OFF) {
|
||||
scannedAfterRadioOn = false;
|
||||
}
|
||||
tt_check(mutex.release() == TtStatusOk);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ namespace tt::app::wifimanage {
|
||||
class State {
|
||||
|
||||
Mutex mutex = Mutex(Mutex::TypeRecursive);
|
||||
bool scanning;
|
||||
bool scanning = false;
|
||||
bool scannedAfterRadioOn = false;
|
||||
service::wifi::WifiRadioState radioState;
|
||||
std::vector<service::wifi::WifiApRecord> apRecords;
|
||||
std::string connectSsid;
|
||||
@@ -22,6 +23,8 @@ public:
|
||||
void setScanning(bool isScanning);
|
||||
bool isScanning() const;
|
||||
|
||||
bool hasScannedAfterRadioOn() const { return scannedAfterRadioOn; }
|
||||
|
||||
void setRadioState(service::wifi::WifiRadioState state);
|
||||
service::wifi::WifiRadioState getRadioState() const;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "WifiManage.h"
|
||||
|
||||
#include "Log.h"
|
||||
#include "service/statusbar/Statusbar.h"
|
||||
#include "Assets.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
#include "lvgl/Style.h"
|
||||
#include "lvgl/Toolbar.h"
|
||||
@@ -17,6 +17,16 @@ namespace tt::app::wifimanage {
|
||||
|
||||
std::shared_ptr<WifiManage> _Nullable optWifiManage();
|
||||
|
||||
const char* getWifiStatusIconForRssi(int rssi) {
|
||||
if (rssi >= -60) {
|
||||
return TT_ASSETS_ICON_WIFI_SIGNAL_STRONG_BLACK;
|
||||
} else if (rssi >= -70) {
|
||||
return TT_ASSETS_ICON_WIFI_SIGNAL_MEDIUM_BLACK;
|
||||
} else {
|
||||
return TT_ASSETS_ICON_WIFI_SIGNAL_WEAK_BLACK;
|
||||
}
|
||||
}
|
||||
|
||||
static void on_enable_switch_changed(lv_event_t* event) {
|
||||
lv_event_code_t code = lv_event_get_code(event);
|
||||
auto* enable_switch = static_cast<lv_obj_t*>(lv_event_get_target(event));
|
||||
@@ -97,13 +107,19 @@ void View::createSsidListItem(const service::wifi::WifiApRecord& record, bool is
|
||||
lv_obj_align(info_label, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
if (isConnecting) {
|
||||
lv_obj_t* connecting_spinner = tt_spinner_create(wrapper);
|
||||
lv_obj_t* connecting_spinner = tt::lvgl::spinner_create(wrapper);
|
||||
lv_obj_align_to(connecting_spinner, info_wrapper, LV_ALIGN_OUT_LEFT_MID, -8, 0);
|
||||
} else {
|
||||
const char* icon = service::statusbar::getWifiStatusIconForRssi(record.rssi, record.auth_mode != WIFI_AUTH_OPEN);
|
||||
lv_obj_t* image = lv_image_create(wrapper);
|
||||
lv_image_set_src(image, icon);
|
||||
lv_obj_align(image, LV_ALIGN_RIGHT_MID, -50, 0);
|
||||
const char* icon = getWifiStatusIconForRssi(record.rssi);
|
||||
lv_obj_t* rssi_image = lv_image_create(wrapper);
|
||||
lv_image_set_src(rssi_image, icon);
|
||||
lv_obj_align(rssi_image, LV_ALIGN_RIGHT_MID, -42, 0);
|
||||
|
||||
if (record.auth_mode != WIFI_AUTH_OPEN) {
|
||||
lv_obj_t* lock_image = lv_image_create(wrapper);
|
||||
lv_image_set_src(lock_image, TT_ASSETS_ICON_WIFI_LOCK_BLACK);
|
||||
lv_obj_align(lock_image, LV_ALIGN_RIGHT_MID, -62, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +168,8 @@ void View::updateNetworkList() {
|
||||
}
|
||||
}
|
||||
lv_obj_clear_flag(networks_list, LV_OBJ_FLAG_HIDDEN);
|
||||
} else if (state->isScanning()) {
|
||||
} else if (!state->hasScannedAfterRadioOn() || state->isScanning()) {
|
||||
// hasScannedAfterRadioOn() prevents briefly showing "No networks found" when turning radio on.
|
||||
lv_obj_add_flag(networks_list, LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
lv_obj_clear_flag(networks_list, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
Reference in New Issue
Block a user