Skip to content

Commit

Permalink
New playlist (#1185)
Browse files Browse the repository at this point in the history
* updated playlist file format
* fix trim and delay part of item
* playlist add/remove tracks
* UI Tweak
  • Loading branch information
kallanreed authored Jun 25, 2023
1 parent 960ecf6 commit e14fa5e
Show file tree
Hide file tree
Showing 8 changed files with 352 additions and 112 deletions.
285 changes: 205 additions & 80 deletions firmware/application/apps/ui_playlist.cpp

Large diffs are not rendered by default.

95 changes: 66 additions & 29 deletions firmware/application/apps/ui_playlist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
#define NORMAL_UI false

#include "app_settings.hpp"
#include "bitmap.hpp"
#include "file.hpp"
#include "metadata_file.hpp"
#include "radio_state.hpp"
#include "ui_widget.hpp"
#include "replay_thread.hpp"
#include "ui_navigation.hpp"
#include "ui_receiver.hpp"
#include "replay_thread.hpp"
#include "ui_spectrum.hpp"
#include "ui_transmitter.hpp"
#include "ui_widget.hpp"

#include <string>
#include <memory>
Expand All @@ -44,10 +47,6 @@ class PlaylistView : public View {
PlaylistView(NavigationView& nav);
~PlaylistView();

// Disable copy to make -Weffc++ happy.
PlaylistView(const PlaylistView&) = delete;
PlaylistView& operator=(const PlaylistView&) = delete;

void set_parent_rect(Rect new_parent_rect) override;
void on_hide() override;
void focus() override;
Expand All @@ -61,35 +60,40 @@ class PlaylistView : public View {
"tx_playlist", app_settings::Mode::TX};

// More header == less spectrum view.
static constexpr ui::Dim header_height = 4 * 16;
static constexpr ui::Dim header_height = 6 * 16;
static constexpr uint32_t baseband_bandwidth = 2500000;

struct playlist_entry {
rf::Frequency replay_frequency{0};
std::filesystem::path replay_file{};
uint32_t sample_rate{};
uint32_t initial_delay{};
std::filesystem::path path{};
capture_metadata metadata{};
File::Size file_size{};
uint32_t ms_delay{};
};

std::unique_ptr<ReplayThread> replay_thread_{};
bool ready_signal_{}; // Used to signal the ReplayThread.

size_t current_track_{0};
const playlist_entry* current_entry_{};
size_t current_entry_size_{0};
size_t current_index_{0};
bool playlist_dirty_{};
std::vector<playlist_entry> playlist_db_{};
std::filesystem::path playlist_path_{};

void load_file(const std::filesystem::path& path);
Optional<playlist_entry> load_entry(std::filesystem::path&& path);
void on_file_changed(const std::filesystem::path& path);
void open_file(bool prompt_save = true);
void save_file(bool show_dialogs = true);
void add_entry(std::filesystem::path&& path);
void delete_entry();
void reset();
void show_file_error(
const std::filesystem::path& path,
const std::string& message);

const playlist_entry* current() const;

bool is_active() const;
bool loop() const;
bool is_done() const;
bool at_end() const;

void toggle();
void start();
Expand All @@ -103,31 +107,28 @@ class PlaylistView : public View {
void on_tx_progress(uint32_t progress);
void handle_replay_thread_done(uint32_t return_code);

Button button_open{
{0 * 8, 0 * 16, 10 * 8, 2 * 16},
"Open PPL"};

Text text_filename{
{11 * 8, 0 * 16, 12 * 8, 16}};
{0 * 8, 0 * 16, 30 * 8, 16}};

Text text_sample_rate{
{24 * 8, 0 * 16, 6 * 8, 16}};
// TODO: delay duration field.
// TODO: TxFrequencyField to edit entry frequency.
Text text_frequency{
{0 * 8, 1 * 16, 9 * 8, 16}};

Text text_duration{
{11 * 8, 1 * 16, 6 * 8, 16}};
Text text_sample_rate{
{10 * 8, 1 * 16, 7 * 8, 16}};

ProgressBar progressbar_track{
{18 * 8, 1 * 16, 12 * 8, 8}};

ProgressBar progressbar_transmit{
{18 * 8, 3 * 8, 12 * 8, 8}};

Text text_frequency{
{0 * 8, 2 * 16, 9 * 8, 16}};
Text text_duration{
{0 * 8, 2 * 16, 5 * 8, 16}};

TransmitterView2 tx_view{
74, 1 * 8, SHORT_UI // x(columns), y (line) position.
};
9 * 8, 1 * 8, SHORT_UI};

Checkbox check_loop{
{21 * 8, 2 * 16},
Expand All @@ -144,6 +145,42 @@ class PlaylistView : public View {
Text text_track{
{0 * 8, 3 * 16, 30 * 8, 16}};

NewButton button_prev{
{0 * 8, 4 * 16, 4 * 8, 2 * 16},
"",
&bitmap_arrow_left,
Color::dark_grey()};

NewButton button_add{
{6 * 8, 4 * 16, 4 * 8, 2 * 16},
"",
&bitmap_icon_new_file,
Color::orange()};

NewButton button_delete{
{10 * 8, 4 * 16, 4 * 8, 2 * 16},
"",
&bitmap_icon_delete,
Color::orange()};

NewButton button_open{
{16 * 8, 4 * 16, 4 * 8, 2 * 16},
"",
&bitmap_icon_load,
Color::dark_blue()};

NewButton button_save{
{20 * 8, 4 * 16, 4 * 8, 2 * 16},
"",
&bitmap_icon_save,
Color::dark_blue()};

NewButton button_next{
{26 * 8, 4 * 16, 4 * 8, 2 * 16},
"",
&bitmap_arrow_right,
Color::dark_grey()};

spectrum::WaterfallWidget waterfall{};

MessageHandlerRegistration message_handler_replay_thread_error{
Expand Down
76 changes: 76 additions & 0 deletions firmware/application/bitmap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5417,6 +5417,82 @@ static constexpr Bitmap bitmap_icon_touchtunes{
{16, 16},
bitmap_icon_touchtunes_data};

static constexpr uint8_t bitmap_arrow_left_data[] = {
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x20,
0x00,
0x30,
0x00,
0x38,
0x00,
0xFC,
0x7F,
0xFE,
0x7F,
0xFC,
0x7F,
0x38,
0x00,
0x30,
0x00,
0x20,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
};
static constexpr Bitmap bitmap_arrow_left{
{16, 16},
bitmap_arrow_left_data};

static constexpr uint8_t bitmap_arrow_right_data[] = {
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x04,
0x00,
0x0C,
0x00,
0x1C,
0xFE,
0x3F,
0xFE,
0x7F,
0xFE,
0x3F,
0x00,
0x1C,
0x00,
0x0C,
0x00,
0x04,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
};
static constexpr Bitmap bitmap_arrow_right{
{16, 16},
bitmap_arrow_right_data};

} /* namespace ui */

#endif /*__BITMAP_HPP__*/
2 changes: 1 addition & 1 deletion firmware/common/ui_widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ class ButtonWithEncoder : public Widget {
class NewButton : public Widget {
public:
std::function<void(void)> on_select{};
// std::function<void(NewButton&)> on_select { };
// std::function<void(NewButton&)> on_select{};
std::function<bool(NewButton&, KeyEvent)> on_dir{};
std::function<void(NewButton&)> on_highlight{};

Expand Down
Binary file added firmware/graphics/arrow_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added firmware/graphics/arrow_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions sdcard/PLAYLIST/PLAYLIST.PPL

This file was deleted.

4 changes: 4 additions & 0 deletions sdcard/PLAYLIST/TESLAS.PPL
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Playlist file example
# capture path, pre-delay milliseconds (optional)
/SAMPLES/TeslaChargePort_US.C16
/SAMPLES/TeslaChargePort_EU_AU.C16,100

0 comments on commit e14fa5e

Please sign in to comment.