freq correct unit fix (#1029)

* fix units for frequency offset. It was planned to be a uint32_t since a uint16_t is obviously too short
* took the uint32_t limitation for frequency offset in account
This commit is contained in:
gullradriel 2023-05-21 23:47:02 +02:00 committed by GitHub
parent 34d46a9d5d
commit be1b2716d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 14 deletions

View File

@ -398,8 +398,8 @@ SetFrequencyCorrectionView::SetFrequencyCorrectionView(NavigationView& nav) {
button_freq_rx_correction.on_select = [this, &nav](Button& button) { button_freq_rx_correction.on_select = [this, &nav](Button& button) {
auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::config_converter_freq()); auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::config_converter_freq());
new_view->on_changed = [this, &button](rf::Frequency f) { new_view->on_changed = [this, &button](rf::Frequency f) {
if (f > 4000000) if (f >= MAX_FREQ_CORRECTION)
f = 4000000; f = MAX_FREQ_CORRECTION;
portapack::persistent_memory::set_config_freq_rx_correction(f); portapack::persistent_memory::set_config_freq_rx_correction(f);
// Retune to take converter change in account // Retune to take converter change in account
receiver_model.set_tuning_frequency(portapack::persistent_memory::tuned_frequency()); receiver_model.set_tuning_frequency(portapack::persistent_memory::tuned_frequency());
@ -411,8 +411,8 @@ SetFrequencyCorrectionView::SetFrequencyCorrectionView(NavigationView& nav) {
button_freq_tx_correction.on_select = [this, &nav](Button& button) { button_freq_tx_correction.on_select = [this, &nav](Button& button) {
auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::config_converter_freq()); auto new_view = nav.push<FrequencyKeypadView>(portapack::persistent_memory::config_converter_freq());
new_view->on_changed = [this, &button](rf::Frequency f) { new_view->on_changed = [this, &button](rf::Frequency f) {
if (f > 4000000) if (f >= MAX_FREQ_CORRECTION)
f = 4000000; f = MAX_FREQ_CORRECTION;
portapack::persistent_memory::set_config_freq_tx_correction(f); portapack::persistent_memory::set_config_freq_tx_correction(f);
// Retune to take converter change in account // Retune to take converter change in account
receiver_model.set_tuning_frequency(portapack::persistent_memory::tuned_frequency()); receiver_model.set_tuning_frequency(portapack::persistent_memory::tuned_frequency());

View File

@ -33,6 +33,8 @@
namespace ui { namespace ui {
#define MAX_FREQ_CORRECTION 4294967295 // maximum possible for an uint32_t
struct SetDateTimeModel { struct SetDateTimeModel {
uint16_t year; uint16_t year;
uint8_t month; uint8_t month;

View File

@ -297,9 +297,9 @@ struct data_t {
int64_t converter_frequency_offset; int64_t converter_frequency_offset;
// frequency correction // frequency correction
int16_t frequency_rx_correction; uint32_t frequency_rx_correction;
bool updown_frequency_rx_correction; bool updown_frequency_rx_correction;
int16_t frequency_tx_correction; uint32_t frequency_tx_correction;
bool updown_frequency_tx_correction; bool updown_frequency_tx_correction;
constexpr data_t() constexpr data_t()
@ -795,16 +795,16 @@ bool config_freq_rx_correction_updown() {
void set_freq_rx_correction_updown(bool v) { void set_freq_rx_correction_updown(bool v) {
data->updown_frequency_rx_correction = v; data->updown_frequency_rx_correction = v;
} }
int16_t config_freq_tx_correction() { uint32_t config_freq_tx_correction() {
return data->frequency_tx_correction; return data->frequency_tx_correction;
} }
int16_t config_freq_rx_correction() { uint32_t config_freq_rx_correction() {
return data->frequency_rx_correction; return data->frequency_rx_correction;
} }
void set_config_freq_tx_correction(uint16_t v) { void set_config_freq_tx_correction(uint32_t v) {
data->frequency_tx_correction = v; data->frequency_tx_correction = v;
} }
void set_config_freq_rx_correction(uint16_t v) { void set_config_freq_rx_correction(uint32_t v) {
data->frequency_rx_correction = v; data->frequency_rx_correction = v;
} }

View File

@ -189,10 +189,10 @@ bool config_freq_tx_correction_updown();
void set_freq_tx_correction_updown(bool v); void set_freq_tx_correction_updown(bool v);
bool config_freq_rx_correction_updown(); bool config_freq_rx_correction_updown();
void set_freq_rx_correction_updown(bool v); void set_freq_rx_correction_updown(bool v);
int16_t config_freq_tx_correction(); uint32_t config_freq_tx_correction();
int16_t config_freq_rx_correction(); uint32_t config_freq_rx_correction();
void set_config_freq_tx_correction(uint16_t v); void set_config_freq_tx_correction(uint32_t v);
void set_config_freq_rx_correction(uint16_t v); void set_config_freq_rx_correction(uint32_t v);
void set_clock_hidden(bool v); void set_clock_hidden(bool v);
void set_clock_with_date(bool v); void set_clock_with_date(bool v);
void set_config_login(bool v); void set_config_login(bool v);