From 8a4e6492d91077752afcf9b8374cc37ecf06f7d5 Mon Sep 17 00:00:00 2001 From: ITAxReal Date: Fri, 28 Aug 2020 23:59:33 +0300 Subject: [PATCH] More Improvements on SoundBoard Optimizing and fixing --- firmware/application/apps/soundboard_app.cpp | 10 +++++++++- firmware/application/apps/soundboard_app.hpp | 10 ++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/firmware/application/apps/soundboard_app.cpp b/firmware/application/apps/soundboard_app.cpp index 882dc9ce..337c8935 100644 --- a/firmware/application/apps/soundboard_app.cpp +++ b/firmware/application/apps/soundboard_app.cpp @@ -141,7 +141,7 @@ void SoundBoardView::refresh_list() { auto reader = std::make_unique(); file_list.clear(); - uint32_t c_page = page; + c_page = page; // List directories and files, put directories up top uint32_t count = 0; @@ -231,6 +231,7 @@ SoundBoardView::SoundBoardView( &page_info, &check_loop, &check_random, + &button_prev_page, &button_next_page, &tx_view }); @@ -240,6 +241,13 @@ SoundBoardView::SoundBoardView( button_next_page.on_select = [this](Button&) { this->refresh_list(); }; + + button_prev_page.on_select = [this](Button&) { + if (c_page == 1) return; + if (c_page == 2) page = 1; + page = c_page - 1; + refresh_list(); + }; //text_title.set(to_string_dec_uint(file_list.size())); diff --git a/firmware/application/apps/soundboard_app.hpp b/firmware/application/apps/soundboard_app.hpp index 90d8cbca..91feaf96 100644 --- a/firmware/application/apps/soundboard_app.hpp +++ b/firmware/application/apps/soundboard_app.hpp @@ -59,6 +59,7 @@ private: uint32_t playing_id { }; uint32_t page = 1; + uint32_t c_page = 1; std::vector file_list { }; @@ -86,10 +87,15 @@ private: }; Button button_next_page { - { 18 * 10, 25 * 8, 10 * 4, 2 * 16 }, + { 30 * 7, 25 * 8, 10 * 3, 2 * 14 }, "=>" }; + Button button_prev_page { + { 17 * 10, 25 * 8, 10 * 3, 2 * 14 }, + "<=" + }; + Text page_info { { 0, 30 * 8 - 4, 30 * 8, 16 } }; @@ -124,7 +130,7 @@ private: }; Checkbox check_random { - { 10 * 8, 25 * 8 + 4 }, + { 10 * 7, 25 * 8 + 4 }, 6, "Random" };