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);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
[[deprecated("Use margin")]]
|
||||
lv_obj_t* spacer_create(lv_obj_t* parent, int32_t width, int32_t height);
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
|
||||
|
||||
#include "lvgl.h"
|
||||
#include "Assets.h"
|
||||
#include "CoreDefines.h"
|
||||
#include "Log.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
static void tt_spinner_constructor(const lv_obj_class_t* object_class, lv_obj_t* object);
|
||||
namespace tt::lvgl {
|
||||
|
||||
static void spinner_constructor(const lv_obj_class_t* object_class, lv_obj_t* object);
|
||||
|
||||
const lv_obj_class_t tt_spinner_class = {
|
||||
.base_class = &lv_image_class,
|
||||
.constructor_cb = tt_spinner_constructor,
|
||||
.constructor_cb = spinner_constructor,
|
||||
.destructor_cb = nullptr,
|
||||
.event_cb = nullptr,
|
||||
.user_data = nullptr,
|
||||
@@ -21,11 +24,11 @@ const lv_obj_class_t tt_spinner_class = {
|
||||
.theme_inheritable = 0
|
||||
};
|
||||
|
||||
lv_obj_t* tt_spinner_create(lv_obj_t* parent) {
|
||||
lv_obj_t* spinner_create(lv_obj_t* parent) {
|
||||
lv_obj_t* obj = lv_obj_class_create_obj(&tt_spinner_class, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
|
||||
lv_image_set_src(obj, "A:/assets/spinner.png");
|
||||
lv_image_set_src(obj, TT_ASSETS_UI_SPINNER);
|
||||
|
||||
return obj;
|
||||
}
|
||||
@@ -39,7 +42,7 @@ static void anim_rotation_callback(void* var, int32_t v) {
|
||||
lv_obj_set_style_transform_rotation(object, v, 0);
|
||||
}
|
||||
|
||||
static void tt_spinner_constructor(TT_UNUSED const lv_obj_class_t* object_class, lv_obj_t* object) {
|
||||
static void spinner_constructor(TT_UNUSED const lv_obj_class_t* object_class, lv_obj_t* object) {
|
||||
lv_obj_remove_flag(object, LV_OBJ_FLAG_CLICKABLE);
|
||||
|
||||
lv_anim_t a;
|
||||
@@ -51,3 +54,5 @@ static void tt_spinner_constructor(TT_UNUSED const lv_obj_class_t* object_class,
|
||||
lv_anim_set_exec_cb(&a, anim_rotation_callback);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#include "lvgl.h"
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
/**
|
||||
* Create the Tactility spinner widget
|
||||
* @param parent pointer to an object, it will be the parent of the new spinner.
|
||||
* @return the created spinner
|
||||
*/
|
||||
lv_obj_t* tt_spinner_create(lv_obj_t* parent);
|
||||
lv_obj_t* spinner_create(lv_obj_t* parent);
|
||||
|
||||
}
|
||||
|
||||
@@ -90,8 +90,6 @@ static void statusbar_destructor(TT_UNUSED const lv_obj_class_t* class_p, lv_obj
|
||||
|
||||
static void update_icon(lv_obj_t* image, const StatusbarIcon* icon) {
|
||||
if (icon->image != nullptr && icon->visible && icon->claimed) {
|
||||
lv_obj_set_style_image_recolor(image, lv_color_white(), 0);
|
||||
lv_obj_set_style_image_recolor_opa(image, 255, 0);
|
||||
lv_image_set_src(image, icon->image);
|
||||
lv_obj_remove_flag(image, LV_OBJ_FLAG_HIDDEN);
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,6 @@ typedef struct {
|
||||
lv_obj_t* close_button;
|
||||
lv_obj_t* close_button_image;
|
||||
lv_obj_t* action_container;
|
||||
ToolbarAction* action_array[TOOLBAR_ACTION_LIMIT];
|
||||
uint8_t action_count;
|
||||
} Toolbar;
|
||||
|
||||
@@ -60,30 +59,23 @@ lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title) {
|
||||
lv_obj_center(obj);
|
||||
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW);
|
||||
|
||||
int32_t title_offset_x = (TOOLBAR_HEIGHT - TOOLBAR_TITLE_FONT_HEIGHT - 8) / 4 * 3;
|
||||
int32_t title_offset_y = (TOOLBAR_HEIGHT - TOOLBAR_TITLE_FONT_HEIGHT - 8) / 2;
|
||||
|
||||
toolbar->close_button = lv_button_create(obj);
|
||||
lv_obj_set_size(toolbar->close_button, TOOLBAR_HEIGHT - 4, TOOLBAR_HEIGHT - 4);
|
||||
obj_set_style_no_padding(toolbar->close_button);
|
||||
toolbar->close_button_image = lv_image_create(toolbar->close_button);
|
||||
lv_obj_align(toolbar->close_button_image, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
// Need spacer to avoid button press glitch animation
|
||||
spacer_create(obj, title_offset_x, 1);
|
||||
|
||||
lv_obj_t* label_container = lv_obj_create(obj);
|
||||
obj_set_style_no_padding(label_container);
|
||||
lv_obj_set_style_border_width(label_container, 0, 0);
|
||||
lv_obj_set_height(label_container, LV_PCT(100)); // 2% less due to 4px translate (it's not great, but it works)
|
||||
lv_obj_set_flex_grow(label_container, 1);
|
||||
|
||||
toolbar->title_label = lv_label_create(label_container);
|
||||
toolbar->title_label = lv_label_create(obj);
|
||||
lv_obj_set_style_text_font(toolbar->title_label, &lv_font_montserrat_18, 0); // TODO replace with size 18
|
||||
lv_obj_set_height(toolbar->title_label, TOOLBAR_TITLE_FONT_HEIGHT);
|
||||
lv_label_set_text(toolbar->title_label, title.c_str());
|
||||
lv_obj_set_pos(toolbar->title_label, 0, title_offset_y);
|
||||
lv_obj_set_style_text_align(toolbar->title_label, LV_TEXT_ALIGN_LEFT, 0);
|
||||
lv_obj_set_flex_grow(toolbar->title_label, 1);
|
||||
int32_t title_offset_x = (TOOLBAR_HEIGHT - TOOLBAR_TITLE_FONT_HEIGHT - 8) / 4 * 3;
|
||||
// Margin top doesn't work
|
||||
lv_obj_set_style_pad_top(toolbar->title_label, title_offset_x, 0);
|
||||
lv_obj_set_style_margin_left(toolbar->title_label, 8, 0);
|
||||
// Hack for margin bug where buttons in flex get rendered more narrowly
|
||||
lv_obj_set_style_margin_right(toolbar->title_label, -8, 0);
|
||||
|
||||
toolbar->action_container = lv_obj_create(obj);
|
||||
lv_obj_set_width(toolbar->action_container, LV_SIZE_CONTENT);
|
||||
@@ -112,7 +104,7 @@ void toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callb
|
||||
lv_image_set_src(toolbar->close_button_image, icon); // e.g. LV_SYMBOL_CLOSE
|
||||
}
|
||||
|
||||
uint8_t toolbar_add_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* user_data) {
|
||||
lv_obj_t* toolbar_add_button_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* user_data) {
|
||||
auto* toolbar = (Toolbar*)obj;
|
||||
uint8_t id = toolbar->action_count;
|
||||
tt_check(toolbar->action_count < TOOLBAR_ACTION_LIMIT, "max actions reached");
|
||||
@@ -126,7 +118,7 @@ uint8_t toolbar_add_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callba
|
||||
lv_image_set_src(action_button_image, icon);
|
||||
lv_obj_align(action_button_image, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
return id;
|
||||
return action_button;
|
||||
}
|
||||
|
||||
lv_obj_t* toolbar_add_switch_action(lv_obj_t* obj) {
|
||||
@@ -138,7 +130,7 @@ lv_obj_t* toolbar_add_switch_action(lv_obj_t* obj) {
|
||||
|
||||
lv_obj_t* toolbar_add_spinner_action(lv_obj_t* obj) {
|
||||
auto* toolbar = (Toolbar*)obj;
|
||||
return tt_spinner_create(toolbar->action_container);
|
||||
return tt::lvgl::spinner_create(toolbar->action_container);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -6,23 +6,14 @@
|
||||
namespace tt::lvgl {
|
||||
|
||||
#define TOOLBAR_HEIGHT 40
|
||||
#define TOOLBAR_ACTION_LIMIT 8
|
||||
#define TOOLBAR_TITLE_FONT_HEIGHT 18
|
||||
|
||||
typedef void(*ToolbarActionCallback)(void* _Nullable context);
|
||||
|
||||
typedef struct {
|
||||
const char* icon;
|
||||
const char* text;
|
||||
ToolbarActionCallback callback;
|
||||
void* _Nullable callback_context;
|
||||
} ToolbarAction;
|
||||
#define TOOLBAR_ACTION_LIMIT 4
|
||||
|
||||
lv_obj_t* toolbar_create(lv_obj_t* parent, const std::string& title);
|
||||
lv_obj_t* toolbar_create(lv_obj_t* parent, const app::AppContext& app);
|
||||
void toolbar_set_title(lv_obj_t* obj, const std::string& title);
|
||||
void toolbar_set_nav_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* user_data);
|
||||
uint8_t toolbar_add_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* user_data);
|
||||
lv_obj_t* toolbar_add_button_action(lv_obj_t* obj, const char* icon, lv_event_cb_t callback, void* user_data);
|
||||
lv_obj_t* toolbar_add_switch_action(lv_obj_t* obj);
|
||||
lv_obj_t* toolbar_add_spinner_action(lv_obj_t* obj);
|
||||
} // namespace
|
||||
|
||||
@@ -43,35 +43,29 @@ struct ServiceData {
|
||||
|
||||
// region wifi
|
||||
|
||||
const char* getWifiStatusIconForRssi(int rssi, bool secured) {
|
||||
if (rssi > 0) {
|
||||
return TT_ASSETS_ICON_WIFI_CONNECTION_ISSUE;
|
||||
} else if (rssi >= -30) {
|
||||
return secured ? TT_ASSETS_ICON_WIFI_SIGNAL_4_LOCKED : TT_ASSETS_ICON_WIFI_SIGNAL_4;
|
||||
} else if (rssi >= -67) {
|
||||
return secured ? TT_ASSETS_ICON_WIFI_SIGNAL_3_LOCKED : TT_ASSETS_ICON_WIFI_SIGNAL_3;
|
||||
const char* getWifiStatusIconForRssi(int rssi) {
|
||||
if (rssi >= -60) {
|
||||
return TT_ASSETS_ICON_WIFI_SIGNAL_STRONG_WHITE;
|
||||
} else if (rssi >= -70) {
|
||||
return secured ? TT_ASSETS_ICON_WIFI_SIGNAL_2_LOCKED : TT_ASSETS_ICON_WIFI_SIGNAL_2;
|
||||
} else if (rssi >= -80) {
|
||||
return secured ? TT_ASSETS_ICON_WIFI_SIGNAL_1_LOCKED : TT_ASSETS_ICON_WIFI_SIGNAL_1;
|
||||
return TT_ASSETS_ICON_WIFI_SIGNAL_MEDIUM_WHITE;
|
||||
} else {
|
||||
return secured ? TT_ASSETS_ICON_WIFI_SIGNAL_0_LOCKED : TT_ASSETS_ICON_WIFI_SIGNAL_0;
|
||||
return TT_ASSETS_ICON_WIFI_SIGNAL_WEAK_WHITE;
|
||||
}
|
||||
}
|
||||
|
||||
static const char* wifi_get_status_icon(wifi::WifiRadioState state, bool secure) {
|
||||
int rssi;
|
||||
switch (state) {
|
||||
case wifi::WIFI_RADIO_ON_PENDING:
|
||||
case wifi::WIFI_RADIO_ON:
|
||||
case wifi::WIFI_RADIO_ON_PENDING:
|
||||
case wifi::WIFI_RADIO_CONNECTION_PENDING:
|
||||
return TT_ASSETS_ICON_WIFI_SCAN_WHITE;
|
||||
case wifi::WIFI_RADIO_OFF_PENDING:
|
||||
case wifi::WIFI_RADIO_OFF:
|
||||
return TT_ASSETS_ICON_WIFI_OFF;
|
||||
case wifi::WIFI_RADIO_CONNECTION_PENDING:
|
||||
return TT_ASSETS_ICON_WIFI_FIND;
|
||||
return TT_ASSETS_ICON_WIFI_OFF_WHITE;
|
||||
case wifi::WIFI_RADIO_CONNECTION_ACTIVE:
|
||||
rssi = wifi::getRssi();
|
||||
return getWifiStatusIconForRssi(rssi, secure);
|
||||
return getWifiStatusIconForRssi(rssi);
|
||||
default:
|
||||
tt_crash("not implemented");
|
||||
}
|
||||
@@ -132,16 +126,28 @@ static _Nullable const char* power_get_status_icon() {
|
||||
|
||||
uint8_t charge = charge_level.valueAsUint8;
|
||||
|
||||
if (charge >= 90) {
|
||||
if (charge >= 95) {
|
||||
return TT_ASSETS_ICON_POWER_100;
|
||||
} else if (charge >= 70) {
|
||||
return TT_ASSETS_ICON_POWER_080;
|
||||
} else if (charge >= 50) {
|
||||
return TT_ASSETS_ICON_POWER_060;
|
||||
} else if (charge >= 30) {
|
||||
return TT_ASSETS_ICON_POWER_040;
|
||||
} else {
|
||||
return TT_ASSETS_ICON_POWER_020;
|
||||
} else if (charge >= 85) {
|
||||
return TT_ASSETS_ICON_POWER_90;
|
||||
} else if (charge >= 75) {
|
||||
return TT_ASSETS_ICON_POWER_80;
|
||||
} else if (charge >= 65) {
|
||||
return TT_ASSETS_ICON_POWER_70;
|
||||
} else if (charge >= 55) {
|
||||
return TT_ASSETS_ICON_POWER_60;
|
||||
} else if (charge >= 45) {
|
||||
return TT_ASSETS_ICON_POWER_50;
|
||||
} else if (charge >= 35) {
|
||||
return TT_ASSETS_ICON_POWER_40;
|
||||
} else if (charge >= 25) {
|
||||
return TT_ASSETS_ICON_POWER_30;
|
||||
} else if (charge >= 15) {
|
||||
return TT_ASSETS_ICON_POWER_20;
|
||||
} else if (charge >= 5) {
|
||||
return TT_ASSETS_ICON_POWER_10;
|
||||
} else {
|
||||
return TT_ASSETS_ICON_POWER_0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace tt::service::statusbar {
|
||||
|
||||
/**
|
||||
* Return the relevant icon asset from assets.h for the given inputs
|
||||
* @param rssi the rssi value
|
||||
* @param secured whether the access point is a secured one (as in: not an open one)
|
||||
* @return
|
||||
*/
|
||||
const char* getWifiStatusIconForRssi(int rssi, bool secured);
|
||||
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user