mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-11 15:29:28 -05:00
Persist tuned frequency.
w00t!
This commit is contained in:
parent
4870f0015b
commit
d855336985
@ -27,11 +27,11 @@
|
||||
using namespace portapack;
|
||||
|
||||
rf::Frequency ReceiverModel::tuning_frequency() const {
|
||||
return tuning_frequency_;
|
||||
return persistent_memory::tuned_frequency();
|
||||
}
|
||||
|
||||
void ReceiverModel::set_tuning_frequency(rf::Frequency f) {
|
||||
tuning_frequency_ = f;
|
||||
persistent_memory::set_tuned_frequency(f);
|
||||
update_tuning_frequency();
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ int32_t ReceiverModel::tuning_offset() {
|
||||
}
|
||||
|
||||
void ReceiverModel::update_tuning_frequency() {
|
||||
radio::set_tuning_frequency(tuning_frequency_ + tuning_offset());
|
||||
radio::set_tuning_frequency(persistent_memory::tuned_frequency() + tuning_offset());
|
||||
}
|
||||
|
||||
void ReceiverModel::update_rf_amp() {
|
||||
|
@ -76,7 +76,6 @@ public:
|
||||
void disable();
|
||||
|
||||
private:
|
||||
rf::Frequency tuning_frequency_ { 858750000 };
|
||||
rf::Frequency frequency_step_ { 25000 };
|
||||
bool rf_amp_ { false };
|
||||
int32_t lna_gain_db_ { 32 };
|
||||
|
@ -47,12 +47,17 @@ struct range_t {
|
||||
}
|
||||
};
|
||||
|
||||
using tuned_frequency_range_t = range_t<rf::Frequency>;
|
||||
constexpr tuned_frequency_range_t tuned_frequency_range { rf::tuning_range.min, rf::tuning_range.max };
|
||||
constexpr rf::Frequency tuned_frequency_reset_value { 858750000 };
|
||||
|
||||
using ppb_range_t = range_t<ppb_t>;
|
||||
constexpr ppb_range_t ppb_range { -99000, 99000 };
|
||||
constexpr ppb_t ppb_reset_value { 0 };
|
||||
|
||||
/* struct must pack the same way on M4 and M0 cores. */
|
||||
struct data_t {
|
||||
int64_t tuned_frequency;
|
||||
int32_t correction_ppb;
|
||||
};
|
||||
|
||||
@ -60,6 +65,15 @@ static_assert(sizeof(data_t) <= 0x100, "Persistent memory structure too large fo
|
||||
|
||||
static data_t* const data = reinterpret_cast<data_t*>(LPC_BACKUP_REG_BASE);
|
||||
|
||||
rf::Frequency tuned_frequency() {
|
||||
tuned_frequency_range.reset_if_outside(data->tuned_frequency, tuned_frequency_reset_value);
|
||||
return data->tuned_frequency;
|
||||
}
|
||||
|
||||
void set_tuned_frequency(const rf::Frequency new_value) {
|
||||
data->tuned_frequency = tuned_frequency_range.clip(new_value);
|
||||
}
|
||||
|
||||
ppb_t correction_ppb() {
|
||||
ppb_range.reset_if_outside(data->correction_ppb, ppb_reset_value);
|
||||
return data->correction_ppb;
|
||||
|
@ -24,11 +24,16 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "rf_path.hpp"
|
||||
|
||||
namespace portapack {
|
||||
namespace persistent_memory {
|
||||
|
||||
using ppb_t = int32_t;
|
||||
|
||||
rf::Frequency tuned_frequency();
|
||||
void set_tuned_frequency(const rf::Frequency new_value);
|
||||
|
||||
ppb_t correction_ppb();
|
||||
void set_correction_ppb(const ppb_t new_value);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user