mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
fix: remove glitch on interpolation
This commit is contained in:
parent
94659a22ba
commit
3a6de231c6
9
main.c
9
main.c
|
|
@ -43,8 +43,8 @@ bool sweep(bool break_on_operation);
|
|||
static MUTEX_DECL(mutex);
|
||||
|
||||
#define DRIVE_STRENGTH_AUTO (-1)
|
||||
//#define FREQ_HARMONICS 300000000
|
||||
#define FREQ_HARMONICS (config.harmonic_freq_threshold)
|
||||
#define IS_HARMONIC_MODE(f) ((f) > FREQ_HARMONICS)
|
||||
|
||||
int32_t frequency_offset = 5000;
|
||||
int32_t frequency = 10000000;
|
||||
|
|
@ -1292,6 +1292,13 @@ cal_interpolate(int s)
|
|||
// found f between freqs at j and j+1
|
||||
float k1 = (float)(f - src->_frequencies[j])
|
||||
/ (src->_frequencies[j+1] - src->_frequencies[j]);
|
||||
|
||||
// avoid glitch between freqs in different harmonics mode
|
||||
if (IS_HARMONIC_MODE(src->_frequencies[j]) != IS_HARMONIC_MODE(src->_frequencies[j+1])) {
|
||||
// assume f[j] < f[j+1]
|
||||
k1 = IS_HARMONIC_MODE(f) ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
float k0 = 1.0 - k1;
|
||||
for (eterm = 0; eterm < 5; eterm++) {
|
||||
cal_data[eterm][i][0] = src->_cal_data[eterm][j][0] * k0 + src->_cal_data[eterm][j+1][0] * k1;
|
||||
|
|
|
|||
4
si5351.c
4
si5351.c
|
|
@ -310,10 +310,10 @@ si5351_set_frequency_with_offset(int freq, int offset, uint8_t drive_strength)
|
|||
int delay = 3;
|
||||
uint32_t ofreq = freq + offset;
|
||||
uint32_t rdiv = SI5351_R_DIV_1;
|
||||
if (freq > config.harmonic_freq_threshold * 3) {
|
||||
if (freq >= config.harmonic_freq_threshold * 3) {
|
||||
freq /= 5;
|
||||
ofreq /= 7;
|
||||
} else if (freq > config.harmonic_freq_threshold) {
|
||||
} else if (freq >= config.harmonic_freq_threshold) {
|
||||
freq /= 3;
|
||||
ofreq /= 5;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue