|
|
|
|
@ -444,6 +444,10 @@ void setFreq(int V, unsigned long freq)
|
|
|
|
|
{
|
|
|
|
|
SI4432_Sel = V;
|
|
|
|
|
if (old_freq[V] != freq) {
|
|
|
|
|
if (V == 0) {
|
|
|
|
|
V = -V;
|
|
|
|
|
V = -V;
|
|
|
|
|
}
|
|
|
|
|
SI4432_Set_Frequency(freq);
|
|
|
|
|
old_freq[V] = freq;
|
|
|
|
|
}
|
|
|
|
|
@ -685,7 +689,7 @@ float perform(bool break_on_operation, int i, int32_t f, int tracking)
|
|
|
|
|
long local_IF;
|
|
|
|
|
if (MODE_HIGH(setting_mode))
|
|
|
|
|
local_IF = 0;
|
|
|
|
|
else if (avoid_spur(f))
|
|
|
|
|
else if (setting_mode == M_LOW && avoid_spur(f))
|
|
|
|
|
local_IF = spur_alternate_IF;
|
|
|
|
|
else
|
|
|
|
|
local_IF = frequency_IF;
|
|
|
|
|
@ -698,7 +702,7 @@ float perform(bool break_on_operation, int i, int32_t f, int tracking)
|
|
|
|
|
if (local_IF) {
|
|
|
|
|
setFreq (0, local_IF);
|
|
|
|
|
}
|
|
|
|
|
if (setting_modulation == MO_AM) {
|
|
|
|
|
if (MODE_OUTPUT(setting_mode) && setting_modulation == MO_AM) {
|
|
|
|
|
int p = setting_attenuate * 2 + modulation_counter;
|
|
|
|
|
PE4302_Write_Byte(p);
|
|
|
|
|
if (modulation_counter == 3)
|
|
|
|
|
@ -706,7 +710,7 @@ float perform(bool break_on_operation, int i, int32_t f, int tracking)
|
|
|
|
|
else
|
|
|
|
|
modulation_counter++;
|
|
|
|
|
chThdSleepMicroseconds(250);
|
|
|
|
|
} else if (setting_modulation == MO_NFM || setting_modulation == MO_WFM ) {
|
|
|
|
|
} else if (MODE_OUTPUT(setting_mode) && (setting_modulation == MO_NFM || setting_modulation == MO_WFM )) {
|
|
|
|
|
SI4432_Sel = 1;
|
|
|
|
|
SI4432_Write_Byte(0x79, modulation_counter); // Use frequency hopping channel for FM modulation
|
|
|
|
|
if (modulation_counter == 3)
|
|
|
|
|
@ -719,16 +723,22 @@ float perform(bool break_on_operation, int i, int32_t f, int tracking)
|
|
|
|
|
int t = 0;
|
|
|
|
|
do {
|
|
|
|
|
int lf = (uint32_t)(f + (int)(t * 500 * actual_rbw));
|
|
|
|
|
if (tracking)
|
|
|
|
|
if (MODE_INPUT(setting_mode) && tracking)
|
|
|
|
|
setFreq (0, local_IF + lf - reffer_freq[setting_refer]); // Offset so fundamental of reffer is visible
|
|
|
|
|
#if 0
|
|
|
|
|
if (lf >11000000 || lf < 9000000) {
|
|
|
|
|
lf = lf;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
setFreq (1, local_IF + lf);
|
|
|
|
|
if (MODE_OUTPUT(setting_mode))
|
|
|
|
|
if (MODE_OUTPUT(setting_mode)) // No substepping in output mode
|
|
|
|
|
return(0);
|
|
|
|
|
float subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting_mode))+settingLevelOffset()+setting_attenuate;
|
|
|
|
|
if (RSSI < subRSSI)
|
|
|
|
|
RSSI = subRSSI;
|
|
|
|
|
t++;
|
|
|
|
|
if ((operation_requested && break_on_operation ) || (MODE_OUTPUT(setting_mode))) // output modes do not step.
|
|
|
|
|
if (operation_requested && break_on_operation) // output modes do not step.
|
|
|
|
|
break; // abort
|
|
|
|
|
} while (t < vbwSteps);
|
|
|
|
|
return(RSSI);
|
|
|
|
|
@ -747,20 +757,20 @@ static bool sweep(bool break_on_operation)
|
|
|
|
|
temppeakLevel = -150;
|
|
|
|
|
float temp_min_level = 100;
|
|
|
|
|
// spur_old_stepdelay = 0;
|
|
|
|
|
//again:
|
|
|
|
|
//again:
|
|
|
|
|
for (int i = 0; i < sweep_points; i++) {
|
|
|
|
|
RSSI = perform(break_on_operation, i, frequencies[i], setting_tracking);
|
|
|
|
|
|
|
|
|
|
// back to toplevel to handle ui operation
|
|
|
|
|
if (operation_requested && break_on_operation)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// if (setting_spur == 1) { // First pass
|
|
|
|
|
// temp_t[i] = RSSI;
|
|
|
|
|
// continue; // Skip all other processing
|
|
|
|
|
// }
|
|
|
|
|
// if (setting_spur == -1) // Second pass
|
|
|
|
|
// RSSI = ( RSSI < temp_t[i] ? RSSI : temp_t[i]); // Minimum of two passes
|
|
|
|
|
if (MODE_INPUT(setting_mode)) {
|
|
|
|
|
// if (setting_spur == 1) { // First pass
|
|
|
|
|
// temp_t[i] = RSSI;
|
|
|
|
|
// continue; // Skip all other processing
|
|
|
|
|
// }
|
|
|
|
|
// if (setting_spur == -1) // Second pass
|
|
|
|
|
// RSSI = ( RSSI < temp_t[i] ? RSSI : temp_t[i]); // Minimum of two passes
|
|
|
|
|
temp_t[i] = RSSI;
|
|
|
|
|
if (setting_subtract_stored) {
|
|
|
|
|
RSSI = RSSI - stored_t[i] ;
|
|
|
|
|
@ -789,7 +799,7 @@ static bool sweep(bool break_on_operation)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
// START_PROFILE
|
|
|
|
|
// START_PROFILE
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
cur_max = 0; // Always at least one maximum
|
|
|
|
|
temppeakIndex = 0;
|
|
|
|
|
@ -819,15 +829,15 @@ static bool sweep(bool break_on_operation)
|
|
|
|
|
int k = MAX_MAX-1;
|
|
|
|
|
while (k > j) { // Shift to make room for max
|
|
|
|
|
max_index[k] = max_index[k-1];
|
|
|
|
|
// maxlevel_index[k] = maxlevel_index[k-1]; // Only for debugging
|
|
|
|
|
// maxlevel_index[k] = maxlevel_index[k-1]; // Only for debugging
|
|
|
|
|
k--;
|
|
|
|
|
}
|
|
|
|
|
max_index[j] = temppeakIndex;
|
|
|
|
|
// maxlevel_index[j] = actual_t[temppeakIndex]; // Only for debugging
|
|
|
|
|
// maxlevel_index[j] = actual_t[temppeakIndex]; // Only for debugging
|
|
|
|
|
if (cur_max < MAX_MAX) {
|
|
|
|
|
cur_max++;
|
|
|
|
|
}
|
|
|
|
|
//STOP_PROFILE
|
|
|
|
|
//STOP_PROFILE
|
|
|
|
|
}
|
|
|
|
|
temppeakIndex = i; // Latest minimum
|
|
|
|
|
temppeakLevel = actual_t[i];
|
|
|
|
|
@ -835,6 +845,7 @@ static bool sweep(bool break_on_operation)
|
|
|
|
|
downslope = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
if (frequencies[i] > 1000000) {
|
|
|
|
|
if (temppeakLevel < actual_t[i]) {
|
|
|
|
|
@ -846,17 +857,18 @@ static bool sweep(bool break_on_operation)
|
|
|
|
|
temp_min_level = actual_t[i];
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
// if (setting_spur == 1) {
|
|
|
|
|
// setting_spur = -1;
|
|
|
|
|
// goto again;
|
|
|
|
|
// } else if (setting_spur == -1)
|
|
|
|
|
// setting_spur = 1;
|
|
|
|
|
// if (setting_spur == 1) {
|
|
|
|
|
// setting_spur = -1;
|
|
|
|
|
// goto again;
|
|
|
|
|
// } else if (setting_spur == -1)
|
|
|
|
|
// setting_spur = 1;
|
|
|
|
|
|
|
|
|
|
if (scandirty) {
|
|
|
|
|
scandirty = false;
|
|
|
|
|
draw_cal_status();
|
|
|
|
|
}
|
|
|
|
|
#if 1
|
|
|
|
|
if (MODE_INPUT(setting_mode)) {
|
|
|
|
|
int i = 0;
|
|
|
|
|
int m = 0;
|
|
|
|
|
while (i < cur_max) { // For all maxima found
|
|
|
|
|
@ -915,6 +927,7 @@ static bool sweep(bool break_on_operation)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
// redraw_marker(peak_marker, FALSE);
|
|
|
|
|
palSetPad(GPIOC, GPIOC_LED);
|
|
|
|
|
return true;
|
|
|
|
|
|