Merge develop into main branch (#137)
* SdCard HAL refactored (#135) - Refactor SdCard HAL - introduce Lockable * Screenshot and FatFS improvements (#136) - Fix screenshots on ESP32 - Improve Screenshot service - Convert Screenshot app to class-based instead of structs - Screenshot app now automatically updates when task is finished - Enable FatFS long filename support * Re-use common log messages (#138) For consistency and binary size reduction * Toolbar spinner should get margin to the right * More TactilityC features (#139) * Rewrote Loader - Simplified Loader by removing custom threa - Created DispatcherThread - Move auto-starting apps to Boot app - Fixed Dispatcher bug where it could get stuck not processing new messages * Hide AP settings if the AP is not saved * Missing from previous commit * Replace LV_EVENT_CLICKED with LV_EVENT_SHORT_CLICKED * Refactored files app and created InputDialog (#140) - Changed Files app so that it has a View and State - Files app now allows for long-pressing on files to perform actions - Files app now has rename and delete actions - Created InputDialog app - Improved AlertDialog app layout
This commit is contained in:
committed by
GitHub
parent
9033daa6dd
commit
50bd6e8bf6
@@ -4,11 +4,12 @@
|
||||
#include "Tactility.h"
|
||||
|
||||
#include "hal/Power.h"
|
||||
#include "hal/sdcard/Sdcard.h"
|
||||
#include "hal/SdCard.h"
|
||||
#include "lvgl/Statusbar.h"
|
||||
#include "service/ServiceContext.h"
|
||||
#include "service/wifi/Wifi.h"
|
||||
#include "service/ServiceRegistry.h"
|
||||
#include "TactilityHeadless.h"
|
||||
|
||||
namespace tt::service::statusbar {
|
||||
|
||||
@@ -85,25 +86,29 @@ static void update_wifi_icon(std::shared_ptr<ServiceData> data) {
|
||||
|
||||
// region sdcard
|
||||
|
||||
static _Nullable const char* sdcard_get_status_icon(hal::sdcard::State state) {
|
||||
static const char* sdcard_get_status_icon(hal::SdCard::State state) {
|
||||
switch (state) {
|
||||
case hal::sdcard::StateMounted:
|
||||
case hal::SdCard::StateMounted:
|
||||
return TT_ASSETS_ICON_SDCARD;
|
||||
case hal::sdcard::StateError:
|
||||
case hal::sdcard::StateUnmounted:
|
||||
case hal::SdCard::StateError:
|
||||
case hal::SdCard::StateUnmounted:
|
||||
case hal::SdCard::StateUnknown:
|
||||
return TT_ASSETS_ICON_SDCARD_ALERT;
|
||||
default:
|
||||
return nullptr;
|
||||
tt_crash("Unhandled SdCard state");
|
||||
}
|
||||
}
|
||||
|
||||
static void update_sdcard_icon(std::shared_ptr<ServiceData> data) {
|
||||
hal::sdcard::State state = hal::sdcard::getState();
|
||||
const char* desired_icon = sdcard_get_status_icon(state);
|
||||
if (data->sdcard_last_icon != desired_icon) {
|
||||
lvgl::statusbar_icon_set_image(data->sdcard_icon_id, desired_icon);
|
||||
lvgl::statusbar_icon_set_visibility(data->sdcard_icon_id, desired_icon != nullptr);
|
||||
data->sdcard_last_icon = desired_icon;
|
||||
auto sdcard = tt::hal::getConfiguration().sdcard;
|
||||
if (sdcard != nullptr) {
|
||||
auto state = sdcard->getState();
|
||||
const char* desired_icon = sdcard_get_status_icon(state);
|
||||
if (data->sdcard_last_icon != desired_icon) {
|
||||
lvgl::statusbar_icon_set_image(data->sdcard_icon_id, desired_icon);
|
||||
lvgl::statusbar_icon_set_visibility(data->sdcard_icon_id, desired_icon != nullptr);
|
||||
data->sdcard_last_icon = desired_icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user