From 50d6efada5bfa2b23a3e1830051475e95d33eb53 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 10 Sep 2024 14:42:40 +1000 Subject: Use '/sd' instead of '/sdcard' for accessing the sd card it's cleaner --- src/drivers/storage.cpp | 2 +- src/tangara/ui/screenshot.cpp | 2 +- src/tangara/ui/ui_fsm.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/drivers/storage.cpp b/src/drivers/storage.cpp index f4be5864..09702a8c 100644 --- a/src/drivers/storage.cpp +++ b/src/drivers/storage.cpp @@ -31,7 +31,7 @@ static const uint8_t kMaxOpenFiles = 8; namespace drivers { -const char* kStoragePath = "/sdcard"; +const char* kStoragePath = "/sd"; auto SdStorage::Create(IGpios& gpio) -> cpp::result { gpio.WriteSync(IGpios::Pin::kSdPowerEnable, 1); diff --git a/src/tangara/ui/screenshot.cpp b/src/tangara/ui/screenshot.cpp index e4f9cc3f..b6ee4e2f 100644 --- a/src/tangara/ui/screenshot.cpp +++ b/src/tangara/ui/screenshot.cpp @@ -34,7 +34,7 @@ auto SaveScreenshot(lv_obj_t* obj, const std::string& path) -> void { } // The LVGL lodepng fork uses LVGL's file API, so an extra '/' is needed. - std::string fullpath = "//sdcard/" + path; + std::string fullpath = "//sd/" + path; auto res = lodepng_encode_file(fullpath.c_str(), buf->data, buf->header.w, buf->header.h, LCT_RGB, 8); diff --git a/src/tangara/ui/ui_fsm.cpp b/src/tangara/ui/ui_fsm.cpp index 2009a888..3f59d4ad 100644 --- a/src/tangara/ui/ui_fsm.cpp +++ b/src/tangara/ui/ui_fsm.cpp @@ -730,7 +730,7 @@ void Lua::entry() { sPowerFastChargeEnabled.setDirect(sServices->nvs().FastCharge()); if (sServices->sd() == drivers::SdState::kMounted) { - sLua->RunScript("/sdcard/config.lua"); + sLua->RunScript("/sd/config.lua"); } sLua->RunScript("/lua/main.lua"); } -- cgit v1.2.3 From 1f5ce2438982860529e43f8ddf093164b920724a Mon Sep 17 00:00:00 2001 From: ailurux Date: Tue, 10 Sep 2024 15:58:03 +1000 Subject: Rename set_style to set_subject --- src/tangara/lua/lua_theme.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/tangara/lua/lua_theme.cpp b/src/tangara/lua/lua_theme.cpp index 03578778..372712b3 100644 --- a/src/tangara/lua/lua_theme.cpp +++ b/src/tangara/lua/lua_theme.cpp @@ -22,12 +22,12 @@ namespace lua { -static auto set_style(lua_State* L) -> int { - // Get the object and class name from the stack - std::string class_name = luaL_checkstring(L, -1); +static auto set_subject(lua_State* L) -> int { + // Get the object and subject name from the stack + std::string subject_name = luaL_checkstring(L, -1); lv_obj_t* obj = luavgl_to_obj(L, -2); if (obj != NULL) { - ui::themes::Theme::instance()->ApplyStyle(obj, class_name); + ui::themes::Theme::instance()->ApplyStyle(obj, subject_name); } return 0; } @@ -107,7 +107,7 @@ static auto theme_filename(lua_State* L) -> int { } static const struct luaL_Reg kThemeFuncs[] = {{"set", set_theme}, - {"set_style", set_style}, + {"set_subject", set_subject}, {"load_theme", load_theme}, {"theme_filename", theme_filename}, {NULL, NULL}}; -- cgit v1.2.3 From a174d76aa16e09ddfc2ce67393c92ed947a817a5 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 13 Sep 2024 10:12:40 +1000 Subject: Mount the SD card asynchronously when it becomes available Previously we were doing it synchronously, which led to some odd looking livelock stacktraces... we still don't have a consistent repro, but this at least makes the stack when we mount a lot more predictable --- src/tangara/system_fsm/running.cpp | 9 +++++---- src/tangara/system_fsm/system_events.hpp | 2 ++ src/tangara/system_fsm/system_fsm.hpp | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/tangara/system_fsm/running.cpp b/src/tangara/system_fsm/running.cpp index 07166e2f..33c6c7dc 100644 --- a/src/tangara/system_fsm/running.cpp +++ b/src/tangara/system_fsm/running.cpp @@ -40,7 +40,7 @@ void Running::entry() { sUnmountTimer = xTimerCreate("unmount_timeout", kTicksBeforeUnmount, false, NULL, timer_callback); } - mountStorage(); + events::System().Dispatch(internal::Mount{}); } void Running::exit() { @@ -72,7 +72,8 @@ void Running::react(const SdDetectChanged& ev) { } if (ev.has_sd_card && !sStorage) { - mountStorage(); + events::System().Dispatch(internal::Mount{}); + return; } // Don't automatically unmount, since this event seems to occasionally happen @@ -120,7 +121,7 @@ void Running::react(const SamdUsbMscChanged& ev) { gpios.WriteSync(drivers::IGpios::Pin::kSdPowerEnable, 0); // Now it's ready for us. - mountStorage(); + events::System().Dispatch(internal::Mount{}); } } @@ -145,7 +146,7 @@ auto Running::updateSdState(drivers::SdState state) -> void { events::System().Dispatch(SdStateChanged{}); } -auto Running::mountStorage() -> void { +void Running::react(const internal::Mount&) { // Only mount our storage if we know it's not currently in use by the SAMD. if (sServices->samd().UsbMassStorage()) { updateSdState(drivers::SdState::kNotMounted); diff --git a/src/tangara/system_fsm/system_events.hpp b/src/tangara/system_fsm/system_events.hpp index 3452e58e..c93c14d5 100644 --- a/src/tangara/system_fsm/system_events.hpp +++ b/src/tangara/system_fsm/system_events.hpp @@ -82,6 +82,8 @@ struct SamdInterrupt : tinyfsm::Event {}; struct IdleTimeout : tinyfsm::Event {}; struct UnmountTimeout : tinyfsm::Event {}; +struct Mount : tinyfsm::Event {}; + } // namespace internal } // namespace system_fsm diff --git a/src/tangara/system_fsm/system_fsm.hpp b/src/tangara/system_fsm/system_fsm.hpp index 5c4157cd..40009781 100644 --- a/src/tangara/system_fsm/system_fsm.hpp +++ b/src/tangara/system_fsm/system_fsm.hpp @@ -63,6 +63,7 @@ class SystemState : public tinyfsm::Fsm { virtual void react(const audio::PlaybackUpdate&) {} virtual void react(const internal::IdleTimeout&) {} virtual void react(const internal::UnmountTimeout&) {} + virtual void react(const internal::Mount&) {} protected: auto IdleCondition() -> bool; @@ -101,16 +102,17 @@ class Running : public SystemState { void react(const audio::PlaybackUpdate&) override; void react(const database::event::UpdateFinished&) override; void react(const SamdUsbMscChanged&) override; - void react(const internal::UnmountTimeout&) override; void react(const StorageError&) override; + void react(const internal::UnmountTimeout&) override; + void react(const internal::Mount&) override; + using SystemState::react; private: auto checkIdle() -> void; auto updateSdState(drivers::SdState) -> void; - auto mountStorage() -> void; auto unmountStorage() -> void; bool storage_mounted_; -- cgit v1.2.3