ux fixes
This commit is contained in:
@@ -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;
|
||||
|
||||
+2
-14
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user