summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-07-28 15:21:18 +1000
committerjacqueline <me@jacqueline.id.au>2023-07-28 15:21:18 +1000
commit10120f9a92aa84f8b5d17a7e84e767a7aa0b42e7 (patch)
tree8eec52e8533030ce34d9f827fd9d6a87809e9fb9 /src
parent3670859d1620ca0fe3492cffb591bf29e5af849c (diff)
downloadtangara-fw-10120f9a92aa84f8b5d17a7e84e767a7aa0b42e7.tar.gz
ux fixes
Diffstat (limited to 'src')
-rw-r--r--src/app_console/app_console.cpp6
-rw-r--r--src/audio/audio_fsm.cpp16
-rw-r--r--src/audio/audio_task.cpp8
-rw-r--r--src/drivers/display.cpp2
-rw-r--r--src/system_fsm/system_fsm.cpp6
-rw-r--r--src/ui/screen_playing.cpp1
6 files changed, 17 insertions, 22 deletions
diff --git a/src/app_console/app_console.cpp b/src/app_console/app_console.cpp
index 74e11de5..bef29834 100644
--- a/src/app_console/app_console.cpp
+++ b/src/app_console/app_console.cpp
@@ -233,7 +233,7 @@ int CmdDbIndex(int argc, char** argv) {
return -1;
}
- std::unique_ptr<database::Result<database::IndexRecord>> res(
+ std::shared_ptr<database::Result<database::IndexRecord>> res(
db->GetTracksByIndex(*index, 20).get());
int choice_index = 2;
@@ -248,6 +248,10 @@ int CmdDbIndex(int argc, char** argv) {
std::cout << "choice out of range" << std::endl;
return -1;
}
+ if (res->values().at(choice).track()) {
+ AppConsole::sTrackQueue->IncludeLast(std::make_shared<playlist::IndexRecordSource>(
+ AppConsole::sDatabase, res, 0, res, choice));
+ }
auto cont = res->values().at(choice).Expand(20);
if (!cont) {
std::cout << "more choices than levels" << std::endl;
diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp
index b8c20584..fc263351 100644
--- a/src/audio/audio_fsm.cpp
+++ b/src/audio/audio_fsm.cpp
@@ -99,7 +99,7 @@ void Standby::react(const internal::InputFileOpened& ev) {
void Standby::react(const QueueUpdate& ev) {
auto current_track = sTrackQueue->GetCurrent();
- if (!current_track) {
+ if (!current_track || (sCurrentTrack && *sCurrentTrack == *current_track)) {
return;
}
@@ -156,19 +156,7 @@ void Playback::react(const PlaybackUpdate& ev) {
void Playback::react(const internal::InputFileOpened& ev) {}
-void Playback::react(const internal::InputFileClosed& ev) {
- ESP_LOGI(kTag, "finished reading file");
- auto upcoming = sTrackQueue->GetUpcoming(1);
- if (upcoming.empty()) {
- return;
- }
- auto db = sDatabase.lock();
- if (!db) {
- return;
- }
- ESP_LOGI(kTag, "preemptively opening next file");
- sFileSource->SetPath(db->GetTrackPath(upcoming.front()));
-}
+void Playback::react(const internal::InputFileClosed& ev) {}
void Playback::react(const internal::InputFileFinished& ev) {
ESP_LOGI(kTag, "finished playing file");
diff --git a/src/audio/audio_task.cpp b/src/audio/audio_task.cpp
index b6eff550..751366c1 100644
--- a/src/audio/audio_task.cpp
+++ b/src/audio/audio_task.cpp
@@ -81,10 +81,12 @@ auto Timer::AddBytes(std::size_t bytes) -> void {
total_duration_seconds_ = current_seconds_;
}
- events::Audio().Dispatch(PlaybackUpdate{
+ PlaybackUpdate ev{
.seconds_elapsed = current_seconds_,
- .seconds_total = total_duration_seconds_,
- });
+ .seconds_total = total_duration_seconds_
+ };
+ events::Audio().Dispatch(ev);
+ events::Ui().Dispatch(ev);
}
}
diff --git a/src/drivers/display.cpp b/src/drivers/display.cpp
index d1ea367c..f828d33e 100644
--- a/src/drivers/display.cpp
+++ b/src/drivers/display.cpp
@@ -196,7 +196,7 @@ auto Display::SetDisplayOn(bool enabled) -> void {
display_on_ = enabled;
int new_duty = display_on_ ? brightness_ : 0;
- ledc_set_fade_with_time(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, new_duty, 250);
+ ledc_set_fade_with_time(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, new_duty, 100);
ledc_fade_start(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, LEDC_FADE_NO_WAIT);
}
diff --git a/src/system_fsm/system_fsm.cpp b/src/system_fsm/system_fsm.cpp
index 27e57b22..5f85d43c 100644
--- a/src/system_fsm/system_fsm.cpp
+++ b/src/system_fsm/system_fsm.cpp
@@ -61,17 +61,17 @@ void SystemState::react(const internal::GpioInterrupt&) {
events::Ui().Dispatch(ev);
}
if (key_down != prev_key_down) {
- KeyDownChanged ev{.falling = prev_key_up};
+ KeyDownChanged ev{.falling = prev_key_down};
events::Audio().Dispatch(ev);
events::Ui().Dispatch(ev);
}
if (key_lock != prev_key_lock) {
- KeyLockChanged ev{.falling = prev_key_up};
+ KeyLockChanged ev{.falling = key_lock};
events::System().Dispatch(ev);
events::Ui().Dispatch(ev);
}
if (has_headphones != prev_has_headphones) {
- HasPhonesChanged ev{.falling = prev_key_up};
+ HasPhonesChanged ev{.falling = prev_has_headphones};
events::Audio().Dispatch(ev);
}
}
diff --git a/src/ui/screen_playing.cpp b/src/ui/screen_playing.cpp
index 27f7654b..cb3d866e 100644
--- a/src/ui/screen_playing.cpp
+++ b/src/ui/screen_playing.cpp
@@ -221,6 +221,7 @@ auto Playing::OnPlaybackUpdate(uint32_t pos_seconds, uint32_t new_duration)
}
auto Playing::OnQueueUpdate() -> void {
+ OnTrackUpdate();
auto current = queue_->GetUpcoming(kMaxUpcoming);
auto db = db_.lock();
if (!db) {