diff --git a/firmware/application/main.cpp b/firmware/application/main.cpp index 0cffc0b6a..9cd811be4 100755 --- a/firmware/application/main.cpp +++ b/firmware/application/main.cpp @@ -618,6 +618,7 @@ int main(void) { } init_message_queues(); + shared_memory.correction_ppm = 0; portapack::io.init(); ui::Context context; diff --git a/firmware/application/radio.cpp b/firmware/application/radio.cpp index d85cab2d2..b493f2178 100644 --- a/firmware/application/radio.cpp +++ b/firmware/application/radio.cpp @@ -26,6 +26,7 @@ #include "max5864.hpp" #include "baseband_cpld.hpp" #include "baseband_sgpio.hpp" +#include "portapack_shared_memory.hpp" #include "tuning.hpp" @@ -117,7 +118,7 @@ void set_direction(const rf::Direction new_direction) { } bool set_tuning_frequency(const rf::Frequency frequency) { - rf::Frequency corrected_frequency = frequency * (1000000 - 10) / 1000000; + rf::Frequency corrected_frequency = frequency * (1000000 + shared_memory.correction_ppm) / 1000000; const auto tuning_config = tuning::config::create(corrected_frequency); if( tuning_config.is_valid() ) { first_if.disable(); diff --git a/firmware/application/ui_setup.cpp b/firmware/application/ui_setup.cpp index f9757822e..d4be6bb6c 100644 --- a/firmware/application/ui_setup.cpp +++ b/firmware/application/ui_setup.cpp @@ -21,6 +21,7 @@ #include "ui_setup.hpp" +#include "portapack_shared_memory.hpp" #include "lpc43xx_cpp.hpp" using namespace lpc43xx; @@ -103,6 +104,7 @@ SetFrequencyCorrectionView::SetFrequencyCorrectionView( ) { button_ok.on_select = [&nav, this](Button&){ const auto model = this->form_collect(); + shared_memory.correction_ppm = model.ppm; nav.pop(); }, @@ -119,7 +121,7 @@ SetFrequencyCorrectionView::SetFrequencyCorrectionView( } }); SetFrequencyCorrectionModel model { - 0 + shared_memory.correction_ppm }; form_init(model); diff --git a/firmware/common/portapack_shared_memory.hpp b/firmware/common/portapack_shared_memory.hpp index c4ae6aabb..53097f826 100644 --- a/firmware/common/portapack_shared_memory.hpp +++ b/firmware/common/portapack_shared_memory.hpp @@ -38,6 +38,7 @@ struct SharedMemory { // TODO: M0 should directly configure and control DMA channel that is // acquiring ADC samples. TouchADCFrame touch_adc_frame; + int8_t correction_ppm; }; extern SharedMemory& shared_memory;