Skip to content

Commit

Permalink
Gps default frequency (portapack-mayhem#1309)
Browse files Browse the repository at this point in the history
* Default frequency

* Default frequency

* Use sample rate from .ini file if present

* Eliminate unneeded sampling_rate variable

* Eliminate unneeded sampling_rate variable
  • Loading branch information
NotherNgineer authored Jul 26, 2023
1 parent 195a622 commit 37aa9c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 8 additions & 6 deletions firmware/application/apps/gps_sim_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,15 @@ void GpsSimAppView::on_file_changed(const fs::path& new_file_path) {

if (metadata) {
field_frequency.set_value(metadata->center_frequency);
sample_rate = metadata->sample_rate;
} else {
sample_rate = 2600000;
transmitter_model.set_sampling_rate(metadata->sample_rate);
}

// UI Fixup.
text_sample_rate.set(unit_auto_scale(sample_rate, 3, 1) + "Hz");
text_sample_rate.set(unit_auto_scale(transmitter_model.sampling_rate(), 3, 1) + "Hz");
progressbar.set_max(file_size);
text_filename.set(truncate(file_path.filename().string(), 12));

auto duration = ms_duration(file_size, sample_rate, 2);
auto duration = ms_duration(file_size, transmitter_model.sampling_rate(), 2);
text_duration.set(to_string_time_ms(duration));

button_play.focus();
Expand Down Expand Up @@ -129,7 +127,6 @@ void GpsSimAppView::start() {
});
}

transmitter_model.set_sampling_rate(sample_rate);
transmitter_model.enable();
}

Expand Down Expand Up @@ -176,6 +173,11 @@ GpsSimAppView::GpsSimAppView(
&waterfall,
});

if (!settings_.loaded()) {
field_frequency.set_value(initial_target_frequency);
transmitter_model.set_sampling_rate(2600000);
}

field_frequency.set_step(5000);

button_play.on_select = [this](ImageButton&) {
Expand Down
3 changes: 2 additions & 1 deletion firmware/application/apps/gps_sim_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class GpsSimAppView : public View {
std::string title() const override { return "GPS Sim TX"; };

private:
static constexpr uint32_t initial_target_frequency = 1575420000;

NavigationView& nav_;
RxRadioState radio_state_{
3000000 /* bandwidth */,
Expand All @@ -64,7 +66,6 @@ class GpsSimAppView : public View {

static constexpr ui::Dim header_height = 3 * 16;

uint32_t sample_rate = 0;
int32_t tx_gain{47};
bool rf_amp{true}; // aux private var to store temporal, same as Replay App rf_amp user selection.
static constexpr uint32_t baseband_bandwidth = 3000000; // filter bandwidth
Expand Down

0 comments on commit 37aa9c0

Please sign in to comment.