Skip to content

Commit

Permalink
Freqman improvements (#1276)
Browse files Browse the repository at this point in the history
* Show .1 MHz in pretty freqman string

* Refactor load to user FreqmanDB

* Recon file parsing cleanup

* use strtol for parse_int

* recon file cleanup

* Fix bugs in Recon changes

* PR feedback

---------

Co-authored-by: kallanreed <kallanreed@noreply.github.com>
  • Loading branch information
kallanreed and kallanreed committed Jul 17, 2023
1 parent f5c4aa2 commit 6574272
Show file tree
Hide file tree
Showing 22 changed files with 431 additions and 432 deletions.
2 changes: 1 addition & 1 deletion firmware/application/apps/analog_audio_app.cpp
Expand Up @@ -25,10 +25,10 @@
#include "audio.hpp"
#include "baseband_api.hpp"
#include "file.hpp"
#include "freqman.hpp"
#include "portapack.hpp"
#include "portapack_persistent_memory.hpp"
#include "string_format.hpp"
#include "ui_freqman.hpp"
#include "utility.hpp"

using namespace portapack;
Expand Down
1 change: 1 addition & 0 deletions firmware/application/apps/capture_app.cpp
Expand Up @@ -23,6 +23,7 @@
#include "capture_app.hpp"
#include "baseband_api.hpp"
#include "portapack.hpp"
#include "ui_freqman.hpp"

using namespace portapack;

Expand Down
1 change: 0 additions & 1 deletion firmware/application/apps/capture_app.hpp
Expand Up @@ -31,7 +31,6 @@
#include "ui_spectrum.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "freqman.hpp"

namespace ui {

Expand Down
38 changes: 30 additions & 8 deletions firmware/application/apps/ui_freqman.cpp
Expand Up @@ -24,7 +24,6 @@
#include "ui_freqman.hpp"

#include "event_m0.hpp"
#include "freqman.hpp"
#include "portapack.hpp"
#include "rtc_time.hpp"
#include "tone_key.hpp"
Expand All @@ -35,11 +34,33 @@
#include <memory>

using namespace portapack;
using namespace ui;
namespace fs = std::filesystem;

// TODO: Clean up after moving to better lookup tables.
extern ui::OptionsField::options_t freqman_bandwidths[4];
extern ui::OptionsField::options_t freqman_steps;
using options_t = OptionsField::options_t;
extern options_t freqman_modulations;
extern options_t freqman_bandwidths[4];
extern options_t freqman_steps;
extern options_t freqman_steps_short;

/* Set options. */
void freqman_set_modulation_option(OptionsField& option) {
option.set_options(freqman_modulations);
}

void freqman_set_bandwidth_option(freqman_index_t modulation, OptionsField& option) {
if (is_valid(modulation))
option.set_options(freqman_bandwidths[modulation]);
}

void freqman_set_step_option(OptionsField& option) {
option.set_options(freqman_steps);
}

void freqman_set_step_option_short(OptionsField& option) {
option.set_options(freqman_steps_short);
}

namespace ui {

Expand Down Expand Up @@ -155,7 +176,7 @@ FrequencySaveView::FrequencySaveView(
};

button_save.on_select = [this, &nav](Button&) {
db_.insert_entry(entry_, db_.entry_count());
db_.insert_entry(db_.entry_count(), entry_);
nav_.pop();
};
}
Expand Down Expand Up @@ -255,7 +276,7 @@ void FrequencyManagerView::on_add_entry() {
};

// Add will insert below the currently selected item.
db_.insert_entry(entry, current_index() + 1);
db_.insert_entry(current_index() + 1, entry);
refresh_list(1);
}

Expand Down Expand Up @@ -488,12 +509,13 @@ void FrequencyEditView::populate_step_options() {
}

void FrequencyEditView::populate_tone_options() {
using namespace tonekey;
OptionsField::options_t options;
options.push_back({"None", -1});

for (auto i = 1u; i < tonekey::tone_keys.size(); ++i) {
auto& item = tonekey::tone_keys[i];
options.push_back({item.first, (OptionsField::value_t)i});
for (auto i = 1u; i < tone_keys.size(); ++i) {
auto& item = tone_keys[i];
options.push_back({fx100_string(item.second), (OptionsField::value_t)i});
}

field_tone.set_options(std::move(options));
Expand Down
6 changes: 6 additions & 0 deletions firmware/application/apps/ui_freqman.hpp
Expand Up @@ -256,3 +256,9 @@ class FrequencyEditView : public View {
};

} /* namespace ui */

void freqman_set_bandwidth_option(freqman_index_t modulation, ui::OptionsField& option);
void freqman_set_modulation_option(ui::OptionsField& option);
void freqman_set_step_option(ui::OptionsField& option);
void freqman_set_step_option_short(ui::OptionsField& option);
void freqman_set_tone_option(ui::OptionsField& option);
1 change: 1 addition & 0 deletions firmware/application/apps/ui_level.cpp
Expand Up @@ -23,6 +23,7 @@

#include "ui_level.hpp"
#include "ui_fileman.hpp"
#include "ui_freqman.hpp"
#include "file.hpp"

using namespace portapack;
Expand Down
20 changes: 10 additions & 10 deletions firmware/application/apps/ui_level.hpp
Expand Up @@ -24,21 +24,21 @@
#ifndef _UI_LEVEL
#define _UI_LEVEL

#include "ui.hpp"
#include "receiver_model.hpp"
#include "ui_receiver.hpp"
#include "ui_styles.hpp"
#include "freqman.hpp"
#include "analog_audio_app.hpp"
#include "app_settings.hpp"
#include "audio.hpp"
#include "ui_mictx.hpp"
#include "portapack_persistent_memory.hpp"
#include "baseband_api.hpp"
#include "ui_spectrum.hpp"
#include "string_format.hpp"
#include "file.hpp"
#include "app_settings.hpp"
#include "freqman_db.hpp"
#include "portapack_persistent_memory.hpp"
#include "radio_state.hpp"
#include "receiver_model.hpp"
#include "string_format.hpp"
#include "ui.hpp"
#include "ui_mictx.hpp"
#include "ui_receiver.hpp"
#include "ui_spectrum.hpp"
#include "ui_styles.hpp"

namespace ui {

Expand Down

0 comments on commit 6574272

Please sign in to comment.