mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-02-04 08:55:21 -05:00
Improved SoundBoard app:
* No device freeze when you try to close app while it's transmitting * Bypassed 100 .wav files limit by implementing paging functionality * Removed useless progressbar and implemented page info line instead
This commit is contained in:
parent
3425ca8d54
commit
e466c14c88
@ -48,7 +48,7 @@ void SoundBoardView::stop() {
|
|||||||
|
|
||||||
void SoundBoardView::handle_replay_thread_done(const uint32_t return_code) {
|
void SoundBoardView::handle_replay_thread_done(const uint32_t return_code) {
|
||||||
stop();
|
stop();
|
||||||
progressbar.set_value(0);
|
//progressbar.set_value(0);
|
||||||
|
|
||||||
if (return_code == ReplayThread::END_OF_FILE) {
|
if (return_code == ReplayThread::END_OF_FILE) {
|
||||||
if (check_random.value()) {
|
if (check_random.value()) {
|
||||||
@ -90,7 +90,7 @@ void SoundBoardView::start_tx(const uint32_t id) {
|
|||||||
|
|
||||||
playing_id = id;
|
playing_id = id;
|
||||||
|
|
||||||
progressbar.set_max(reader->sample_count());
|
//progressbar.set_max(reader->sample_count());
|
||||||
|
|
||||||
//button_play.set_bitmap(&bitmap_stop);
|
//button_play.set_bitmap(&bitmap_stop);
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ void SoundBoardView::start_tx(const uint32_t id) {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
void SoundBoardView::on_tx_progress(const uint32_t progress) {
|
void SoundBoardView::on_tx_progress(const uint32_t progress) {
|
||||||
progressbar.set_value(progress);
|
//progressbar.set_value(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundBoardView::on_select_entry() {
|
void SoundBoardView::on_select_entry() {
|
||||||
@ -141,8 +141,10 @@ void SoundBoardView::refresh_list() {
|
|||||||
auto reader = std::make_unique<WAVFileReader>();
|
auto reader = std::make_unique<WAVFileReader>();
|
||||||
|
|
||||||
file_list.clear();
|
file_list.clear();
|
||||||
|
uint32_t c_page = page;
|
||||||
|
|
||||||
// List directories and files, put directories up top
|
// List directories and files, put directories up top
|
||||||
|
uint32_t count = 0;
|
||||||
for (const auto& entry : std::filesystem::directory_iterator(u"WAV", u"*")) {
|
for (const auto& entry : std::filesystem::directory_iterator(u"WAV", u"*")) {
|
||||||
if (std::filesystem::is_regular_file(entry.status())) {
|
if (std::filesystem::is_regular_file(entry.status())) {
|
||||||
if (entry.path().string().length()) {
|
if (entry.path().string().length()) {
|
||||||
@ -158,11 +160,16 @@ void SoundBoardView::refresh_list() {
|
|||||||
if ((reader->channels() == 1) && (reader->bits_per_sample() == 8)) {
|
if ((reader->channels() == 1) && (reader->bits_per_sample() == 8)) {
|
||||||
//sounds[c].ms_duration = reader->ms_duration();
|
//sounds[c].ms_duration = reader->ms_duration();
|
||||||
//sounds[c].path = u"WAV/" + entry.path().native();
|
//sounds[c].path = u"WAV/" + entry.path().native();
|
||||||
|
if (count >= (page - 1) * 100 && count < page * 100){
|
||||||
file_list.push_back(entry.path());
|
file_list.push_back(entry.path());
|
||||||
if (file_list.size() == 100)
|
if (file_list.size() == 100){
|
||||||
|
page++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,9 +177,15 @@ void SoundBoardView::refresh_list() {
|
|||||||
|
|
||||||
if (!file_list.size()) {
|
if (!file_list.size()) {
|
||||||
// Hide widgets, show warning
|
// Hide widgets, show warning
|
||||||
|
if (page == 1){
|
||||||
menu_view.hidden(true);
|
menu_view.hidden(true);
|
||||||
text_empty.hidden(false);
|
text_empty.hidden(false);
|
||||||
set_dirty();
|
set_dirty();
|
||||||
|
}else{
|
||||||
|
page = 1;
|
||||||
|
refresh_list();
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Hide warning, show widgets
|
// Hide warning, show widgets
|
||||||
menu_view.hidden(false);
|
menu_view.hidden(false);
|
||||||
@ -192,8 +205,13 @@ void SoundBoardView::refresh_list() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
page_info.set("Page: " + to_string_dec_uint(c_page) + " Songs: " + to_string_dec_uint(file_list.size()));
|
||||||
menu_view.set_highlighted(0); // Refresh
|
menu_view.set_highlighted(0); // Refresh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file_list.size() < 100){
|
||||||
|
page = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundBoardView::SoundBoardView(
|
SoundBoardView::SoundBoardView(
|
||||||
@ -209,14 +227,20 @@ SoundBoardView::SoundBoardView(
|
|||||||
&options_tone_key,
|
&options_tone_key,
|
||||||
//&text_title,
|
//&text_title,
|
||||||
//&text_duration,
|
//&text_duration,
|
||||||
&progressbar,
|
//&progressbar,
|
||||||
|
&page_info,
|
||||||
&check_loop,
|
&check_loop,
|
||||||
&check_random,
|
&check_random,
|
||||||
|
&button_next_page,
|
||||||
&tx_view
|
&tx_view
|
||||||
});
|
});
|
||||||
|
|
||||||
refresh_list();
|
refresh_list();
|
||||||
|
|
||||||
|
button_next_page.on_select = [this](Button&) {
|
||||||
|
this->refresh_list();
|
||||||
|
};
|
||||||
|
|
||||||
//text_title.set(to_string_dec_uint(file_list.size()));
|
//text_title.set(to_string_dec_uint(file_list.size()));
|
||||||
|
|
||||||
tone_keys_populate(options_tone_key);
|
tone_keys_populate(options_tone_key);
|
||||||
@ -243,6 +267,7 @@ SoundBoardView::SoundBoardView(
|
|||||||
}
|
}
|
||||||
|
|
||||||
SoundBoardView::~SoundBoardView() {
|
SoundBoardView::~SoundBoardView() {
|
||||||
|
stop();
|
||||||
transmitter_model.disable();
|
transmitter_model.disable();
|
||||||
baseband::shutdown();
|
baseband::shutdown();
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ private:
|
|||||||
tx_modes tx_mode = NORMAL;
|
tx_modes tx_mode = NORMAL;
|
||||||
|
|
||||||
uint32_t playing_id { };
|
uint32_t playing_id { };
|
||||||
|
uint32_t page = 1;
|
||||||
|
|
||||||
std::vector<std::filesystem::path> file_list { };
|
std::vector<std::filesystem::path> file_list { };
|
||||||
|
|
||||||
@ -84,6 +85,15 @@ private:
|
|||||||
{ { 0, 180 }, "Key:", Color::light_grey() }
|
{ { 0, 180 }, "Key:", Color::light_grey() }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Button button_next_page {
|
||||||
|
{ 18 * 10, 25 * 8, 10 * 4, 2 * 16 },
|
||||||
|
"=>"
|
||||||
|
};
|
||||||
|
|
||||||
|
Text page_info {
|
||||||
|
{ 0, 30 * 8 - 4, 30 * 8, 16 }
|
||||||
|
};
|
||||||
|
|
||||||
MenuView menu_view {
|
MenuView menu_view {
|
||||||
{ 0, 0, 240, 175 },
|
{ 0, 0, 240, 175 },
|
||||||
true
|
true
|
||||||
@ -119,9 +129,9 @@ private:
|
|||||||
"Random"
|
"Random"
|
||||||
};
|
};
|
||||||
|
|
||||||
ProgressBar progressbar {
|
//ProgressBar progressbar {
|
||||||
{ 0 * 8, 30 * 8 - 4, 30 * 8, 16 }
|
// { 0 * 8, 30 * 8 - 4, 30 * 8, 16 }
|
||||||
};
|
//};
|
||||||
|
|
||||||
TransmitterView tx_view {
|
TransmitterView tx_view {
|
||||||
16 * 16,
|
16 * 16,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user