Merge branch 'main' into daniel/persistent-positions

custom
ailurux 7 months ago
commit 79dccc2685
  1. 1
      lua/browser.lua
  2. 1
      lua/file_browser.lua
  3. 9
      src/tangara/system_fsm/running.cpp
  4. 2
      src/tangara/system_fsm/system_events.hpp
  5. 6
      src/tangara/system_fsm/system_fsm.hpp

@ -42,7 +42,6 @@ return screen:new{
pad_left = 4, pad_left = 4,
pad_right = 4, pad_right = 4,
pad_bottom = 2, pad_bottom = 2,
bg_opa = lvgl.OPA(100),
scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF
} }
theme.set_subject(header, "header") theme.set_subject(header, "header")

@ -43,7 +43,6 @@ return screen:new {
pad_left = 4, pad_left = 4,
pad_right = 4, pad_right = 4,
pad_bottom = 2, pad_bottom = 2,
bg_opa = lvgl.OPA(100),
scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF
} }
theme.set_subject(header, "header") theme.set_subject(header, "header")

@ -40,7 +40,7 @@ void Running::entry() {
sUnmountTimer = xTimerCreate("unmount_timeout", kTicksBeforeUnmount, false, sUnmountTimer = xTimerCreate("unmount_timeout", kTicksBeforeUnmount, false,
NULL, timer_callback); NULL, timer_callback);
} }
mountStorage(); events::System().Dispatch(internal::Mount{});
} }
void Running::exit() { void Running::exit() {
@ -72,7 +72,8 @@ void Running::react(const SdDetectChanged& ev) {
} }
if (ev.has_sd_card && !sStorage) { if (ev.has_sd_card && !sStorage) {
mountStorage(); events::System().Dispatch(internal::Mount{});
return;
} }
// Don't automatically unmount, since this event seems to occasionally happen // 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); gpios.WriteSync(drivers::IGpios::Pin::kSdPowerEnable, 0);
// Now it's ready for us. // 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{}); 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. // Only mount our storage if we know it's not currently in use by the SAMD.
if (sServices->samd().UsbMassStorage()) { if (sServices->samd().UsbMassStorage()) {
updateSdState(drivers::SdState::kNotMounted); updateSdState(drivers::SdState::kNotMounted);

@ -82,6 +82,8 @@ struct SamdInterrupt : tinyfsm::Event {};
struct IdleTimeout : tinyfsm::Event {}; struct IdleTimeout : tinyfsm::Event {};
struct UnmountTimeout : tinyfsm::Event {}; struct UnmountTimeout : tinyfsm::Event {};
struct Mount : tinyfsm::Event {};
} // namespace internal } // namespace internal
} // namespace system_fsm } // namespace system_fsm

@ -63,6 +63,7 @@ class SystemState : public tinyfsm::Fsm<SystemState> {
virtual void react(const audio::PlaybackUpdate&) {} virtual void react(const audio::PlaybackUpdate&) {}
virtual void react(const internal::IdleTimeout&) {} virtual void react(const internal::IdleTimeout&) {}
virtual void react(const internal::UnmountTimeout&) {} virtual void react(const internal::UnmountTimeout&) {}
virtual void react(const internal::Mount&) {}
protected: protected:
auto IdleCondition() -> bool; auto IdleCondition() -> bool;
@ -101,16 +102,17 @@ class Running : public SystemState {
void react(const audio::PlaybackUpdate&) override; void react(const audio::PlaybackUpdate&) override;
void react(const database::event::UpdateFinished&) override; void react(const database::event::UpdateFinished&) override;
void react(const SamdUsbMscChanged&) override; void react(const SamdUsbMscChanged&) override;
void react(const internal::UnmountTimeout&) override;
void react(const StorageError&) override; void react(const StorageError&) override;
void react(const internal::UnmountTimeout&) override;
void react(const internal::Mount&) override;
using SystemState::react; using SystemState::react;
private: private:
auto checkIdle() -> void; auto checkIdle() -> void;
auto updateSdState(drivers::SdState) -> void; auto updateSdState(drivers::SdState) -> void;
auto mountStorage() -> void;
auto unmountStorage() -> void; auto unmountStorage() -> void;
bool storage_mounted_; bool storage_mounted_;

Loading…
Cancel
Save