Double correction removed

Removed_REF_marker
erikkaashoek 5 years ago
parent 84e2e43ae3
commit 8888ca74cf

@ -18,7 +18,7 @@
*/ */
#include "ch.h" #include "ch.h"
#ifdef TINYSA_F303 //#ifdef TINYSA_F303
#include "adc_F303.h" #include "adc_F303.h"
#ifdef TINYSA_F072 #ifdef TINYSA_F072
#error "Remove comment for #ifdef TINYSA_F303" #error "Remove comment for #ifdef TINYSA_F303"
@ -27,7 +27,7 @@
#define TINYSA4 #define TINYSA4
#endif #endif
#define TINYSA4_PROTO #define TINYSA4_PROTO
#endif //#endif
#ifdef TINYSA_F072 #ifdef TINYSA_F072
#ifdef TINYSA_F303 #ifdef TINYSA_F303
@ -285,9 +285,9 @@ void set_extra_lna(int t);
// ------------------------------- sa_core.c ---------------------------------- // ------------------------------- sa_core.c ----------------------------------
extern float level_min; extern float level_min(void);
extern float level_max; extern float level_max(void);
extern float level_range; extern float level_range(void);
extern float channel_power[3]; extern float channel_power[3];
extern float channel_power_watt[3]; extern float channel_power_watt[3];
extern const char * const unit_string[]; extern const char * const unit_string[];

@ -236,7 +236,7 @@
// MODEM_RSSI_CONTROL2 - RSSI Jump Detection control. // MODEM_RSSI_CONTROL2 - RSSI Jump Detection control.
// MODEM_RSSI_COMP - RSSI compensation value. // MODEM_RSSI_COMP - RSSI compensation value.
*/ */
#define RF_MODEM_RSSI_JUMP_THRESH_4 0x11, 0x20, 0x04, 0x4B, 0x06, 0x09, 0x10, 0x40 #define RF_MODEM_RSSI_JUMP_THRESH_4 0x11, 0x20, 0x04, 0x4B, 0x06, 0x18, 0x10, 0x40
/* /*
// Set properties: RF_MODEM_RAW_SEARCH2_2 // Set properties: RF_MODEM_RAW_SEARCH2_2
@ -463,7 +463,7 @@
// FRR_CTL_C_MODE - Fast Response Register C Configuration. // FRR_CTL_C_MODE - Fast Response Register C Configuration.
// FRR_CTL_D_MODE - Fast Response Register D Configuration. // FRR_CTL_D_MODE - Fast Response Register D Configuration.
*/ */
#define RF_FRR_CTL_A_MODE_4 0x11, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 #define RF_FRR_CTL_A_MODE_4 0x11, 0x02, 0x04, 0x00, 0x0A, 0x00, 0x00, 0x00
/* /*
// Set properties: RF_PREAMBLE_CONFIG_STD_1_1 // Set properties: RF_PREAMBLE_CONFIG_STD_1_1
@ -628,7 +628,7 @@
// MODEM_RSSI_CONTROL2 - RSSI Jump Detection control. // MODEM_RSSI_CONTROL2 - RSSI Jump Detection control.
// MODEM_RSSI_COMP - RSSI compensation value. // MODEM_RSSI_COMP - RSSI compensation value.
*/ */
#define RF_MODEM_RAW_CONTROL_10 0x11, 0x20, 0x0A, 0x45, 0x8F, 0x02, 0x7F, 0x01, 0x00, 0xFF, 0x08, 0x08, 0x1A, 0x40 #define RF_MODEM_RAW_CONTROL_10 0x11, 0x20, 0x0A, 0x45, 0x8F, 0x02, 0x7F, 0x01, 0x00, 0xFF, 0x08, 0x18, 0x1A, 0x40
/* /*
// Set properties: RF_MODEM_RAW_SEARCH2_2_1 // Set properties: RF_MODEM_RAW_SEARCH2_2_1

@ -463,7 +463,7 @@
// FRR_CTL_C_MODE - Fast Response Register C Configuration. // FRR_CTL_C_MODE - Fast Response Register C Configuration.
// FRR_CTL_D_MODE - Fast Response Register D Configuration. // FRR_CTL_D_MODE - Fast Response Register D Configuration.
*/ */
#define RF_FRR_CTL_A_MODE_4 0x11, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 #define RF_FRR_CTL_A_MODE_4 0x11, 0x02, 0x04, 0x00, 0x0A, 0x00, 0x00, 0x00
/* /*
// Set properties: RF_PREAMBLE_CONFIG_STD_1_1 // Set properties: RF_PREAMBLE_CONFIG_STD_1_1
@ -628,7 +628,7 @@
// MODEM_RSSI_CONTROL2 - RSSI Jump Detection control. // MODEM_RSSI_CONTROL2 - RSSI Jump Detection control.
// MODEM_RSSI_COMP - RSSI compensation value. // MODEM_RSSI_COMP - RSSI compensation value.
*/ */
#define RF_MODEM_RAW_CONTROL_10 0x11, 0x20, 0x0A, 0x45, 0x8F, 0x02, 0x7F, 0x01, 0x00, 0xFF, 0x08, 0x08, 0x1A, 0x40 #define RF_MODEM_RAW_CONTROL_10 0x11, 0x20, 0x0A, 0x45, 0x8F, 0x02, 0x7F, 0x01, 0x00, 0xFF, 0x08, 0x18, 0x1A, 0x40
/* /*
// Set properties: RF_MODEM_RAW_SEARCH2_2_1 // Set properties: RF_MODEM_RAW_SEARCH2_2_1

@ -99,7 +99,7 @@
// FRR_CTL_C_MODE - Fast Response Register C Configuration. // FRR_CTL_C_MODE - Fast Response Register C Configuration.
// FRR_CTL_D_MODE - Fast Response Register D Configuration. // FRR_CTL_D_MODE - Fast Response Register D Configuration.
*/ */
#define RF_FRR_CTL_A_MODE_4 0x11, 0x02, 0x04, 0x00, 0x00, 0x01, 0x00, 0x00 #define RF_FRR_CTL_A_MODE_4 0x11, 0x02, 0x04, 0x00, 0x0A, 0x01, 0x00, 0x00
/* /*
// Set properties: RF_PREAMBLE_CONFIG_1 // Set properties: RF_PREAMBLE_CONFIG_1

@ -116,9 +116,9 @@ const int8_t drive_dBm [16] = {-38, -32, -30, -27, -24, -19, -15, -12, -5, -2, 0
#define RECEIVE_SWITCH_ATTENUATION 21 // TODO differentiate for tinySA3 and tinySA4 #define RECEIVE_SWITCH_ATTENUATION 21 // TODO differentiate for tinySA3 and tinySA4
float level_min; //float level_min;
float level_max; //float level_max;
float level_range; //float level_range;
float channel_power[3]; float channel_power[3];
float channel_power_watt[3]; float channel_power_watt[3];
@ -301,9 +301,9 @@ void reset_settings(int m)
setting.correction_frequency = config.correction_frequency[CORRECTION_LOW]; setting.correction_frequency = config.correction_frequency[CORRECTION_LOW];
setting.correction_value = config.correction_value[CORRECTION_LOW]; setting.correction_value = config.correction_value[CORRECTION_LOW];
#endif #endif
level_min = SL_GENLOW_LEVEL_MIN + LOW_OUT_OFFSET; // level_min = SL_GENLOW_LEVEL_MIN + LOW_OUT_OFFSET;
level_max = SL_GENLOW_LEVEL_MAX + LOW_OUT_OFFSET; // level_max = SL_GENLOW_LEVEL_MAX + LOW_OUT_OFFSET;
level_range = level_max - level_min; // level_range = level_max - level_min;
break; break;
case M_HIGH: case M_HIGH:
set_sweep_frequency(ST_START, minFreq); set_sweep_frequency(ST_START, minFreq);
@ -330,12 +330,12 @@ void reset_settings(int m)
setting.step_delay_mode = SD_FAST; setting.step_delay_mode = SD_FAST;
setting.correction_frequency = config.correction_frequency[CORRECTION_HIGH]; setting.correction_frequency = config.correction_frequency[CORRECTION_HIGH];
setting.correction_value = config.correction_value[CORRECTION_HIGH]; setting.correction_value = config.correction_value[CORRECTION_HIGH];
level_min = SL_GENHIGH_LEVEL_MIN + config.high_level_output_offset; // level_min = SL_GENHIGH_LEVEL_MIN + config.high_level_output_offset;
level_max = SL_GENHIGH_LEVEL_MAX + config.high_level_output_offset; // level_max = SL_GENHIGH_LEVEL_MAX + config.high_level_output_offset;
level_range = level_max - level_min; // level_range = level_max - level_min;
break; break;
} }
setting.level = level_max; // This is the level with above settings. setting.level = level_max(); // This is the level with above settings.
for (uint8_t i = 0; i< MARKERS_MAX; i++) { for (uint8_t i = 0; i< MARKERS_MAX; i++) {
markers[i].enabled = M_DISABLED; markers[i].enabled = M_DISABLED;
markers[i].mtype = M_NORMAL; markers[i].mtype = M_NORMAL;
@ -670,7 +670,7 @@ void set_auto_reflevel(bool v)
setting.auto_reflevel = v; setting.auto_reflevel = v;
} }
#if 0 #if 1
float level_min(void) float level_min(void)
{ {
int l; int l;
@ -786,7 +786,7 @@ float get_attenuation(void)
{ {
float actual_attenuation = setting.attenuate_x2 / 2.0; float actual_attenuation = setting.attenuate_x2 / 2.0;
if (setting.mode == M_GENLOW) { if (setting.mode == M_GENLOW) {
return (float)( level_max - actual_attenuation + BELOW_MAX_DRIVE(setting.rx_drive) - ( setting.atten_step ? SWITCH_ATTENUATION : 0) ); return (float)( level_max() - actual_attenuation + BELOW_MAX_DRIVE(setting.rx_drive) - ( setting.atten_step ? SWITCH_ATTENUATION : 0) );
} else if (setting.atten_step) { } else if (setting.atten_step) {
if (setting.mode == M_LOW) if (setting.mode == M_LOW)
return actual_attenuation + RECEIVE_SWITCH_ATTENUATION; return actual_attenuation + RECEIVE_SWITCH_ATTENUATION;
@ -800,7 +800,7 @@ void set_attenuation(float a) // Is used both only in high/low input mode
{ {
#if 0 #if 0
if (setting.mode == M_GENLOW) { if (setting.mode == M_GENLOW) {
a = a - level_max; // Move to zero for max power a = a - level_max(); // Move to zero for max power
if (a > 0) if (a > 0)
a = 0; a = 0;
if( a < - SWITCH_ATTENUATION) { if( a < - SWITCH_ATTENUATION) {
@ -1168,7 +1168,7 @@ void set_AGC_LNA(void) {
if (!S_STATE(setting.agc)) if (!S_STATE(setting.agc))
v |= 0x80 + 0x20; // Inverse!!!! v |= 0x80 + 0x20; // Inverse!!!!
if (S_STATE(setting.lna)) if (S_STATE(setting.lna))
v |= 0x08; // Inverse!!!! v |= 0x0F; // Inverse!!!!
SI446x_set_AGC_LNA(v); SI446x_set_AGC_LNA(v);
SI4432_old_v[0] = v; SI4432_old_v[0] = v;
} }
@ -1313,8 +1313,8 @@ void set_external_gain(float external_gain)
{ {
setting.external_gain = external_gain; setting.external_gain = external_gain;
int min,max; int min,max;
min = level_min; min = level_min();
max = min + level_range; max = min + level_range();
plot_printf(low_level_help_text, sizeof low_level_help_text, "%+d..%+d", min - (int)external_gain, max - (int)external_gain); plot_printf(low_level_help_text, sizeof low_level_help_text, "%+d..%+d", min - (int)external_gain, max - (int)external_gain);
redraw_request|=REDRAW_AREA; redraw_request|=REDRAW_AREA;
dirty = true; // No HW update required, only status panel refresh but need to ensure the cached value is updated in the calculation of the RSSI dirty = true; // No HW update required, only status panel refresh but need to ensure the cached value is updated in the calculation of the RSSI
@ -2459,7 +2459,7 @@ static void calculate_static_correction(void) // Calculate the
+ get_attenuation() + get_attenuation()
#ifdef TINYSA4 #ifdef TINYSA4
- (S_STATE(setting.agc)? 0 : 33) - (S_STATE(setting.agc)? 0 : 33)
- (S_STATE(setting.lna)? 0 : 0) - (S_STATE(setting.lna)? 12 : 0)
+ (setting.extra_lna ? -23.5 : 0) // TODO <------------------------- set correct value + (setting.extra_lna ? -23.5 : 0) // TODO <------------------------- set correct value
#endif #endif
- setting.external_gain); - setting.external_gain);
@ -2618,7 +2618,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
ls += 0.5; ls += 0.5;
else else
ls -= 0.5; ls -= 0.5;
float a = ((int)((setting.level + ((float)i / sweep_points) * ls)*2.0)) / 2.0 + get_level_offset(); float a = ((int)((setting.level + ((float)i / sweep_points) * ls)*2.0)) / 2.0 /* + get_level_offset() */ ;
correct_RSSI_freq = get_frequency_correction(f); correct_RSSI_freq = get_frequency_correction(f);
a += PURE_TO_float(correct_RSSI_freq) + 3.0; // Always 3dB in attenuator a += PURE_TO_float(correct_RSSI_freq) + 3.0; // Always 3dB in attenuator
if (a != old_a) { if (a != old_a) {
@ -2626,7 +2626,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
int very_low_flag = false; int very_low_flag = false;
#endif #endif
old_a = a; old_a = a;
a = a - level_max; // convert to all settings maximum power output equals a = zero a = a - level_max(); // convert to all settings maximum power output equals a = zero
if (a < -SWITCH_ATTENUATION) { if (a < -SWITCH_ATTENUATION) {
a = a + SWITCH_ATTENUATION; a = a + SWITCH_ATTENUATION;
#ifdef TINYSA3 #ifdef TINYSA3
@ -2680,7 +2680,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
} }
} }
else if (setting.mode == M_GENHIGH) { else if (setting.mode == M_GENHIGH) {
float a = setting.level - level_max; float a = setting.level - level_max();
if (a <= -SWITCH_ATTENUATION) { if (a <= -SWITCH_ATTENUATION) {
setting.atten_step = true; setting.atten_step = true;
a = a + SWITCH_ATTENUATION; a = a + SWITCH_ATTENUATION;
@ -2707,7 +2707,7 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
} }
unsigned int d = MIN_DRIVE; unsigned int d = MIN_DRIVE;
while (drive_dBm[d] - level_max < a && d < MAX_DRIVE) // Find level equal or above requested level while (drive_dBm[d] - level_max() < a && d < MAX_DRIVE) // Find level equal or above requested level
d++; d++;
// if (d == 8 && v < -12) // Round towards closest level // if (d == 8 && v < -12) // Round towards closest level
// d = 7; // d = 7;

@ -1467,14 +1467,14 @@ void SI4463_do_api(void* data, uint8_t len, void* out, uint8_t outLen)
{ {
// SPI_BR_SET(SI4432_SPI, SPI_BR_DIV8); // SPI_BR_SET(SI4432_SPI, SPI_BR_DIV8);
// __disable_irq(); __disable_irq();
SI_CS_LOW; SI_CS_LOW;
for(uint8_t i=0;i<len;i++) { for(uint8_t i=0;i<len;i++) {
shiftOut(((uint8_t*)data)[i]); // (pgm_read_byte(&((uint8_t*)data)[i])); shiftOut(((uint8_t*)data)[i]); // (pgm_read_byte(&((uint8_t*)data)[i]));
} }
// SPI_BR_SET(SI4432_SPI, SPI_BR_DIV8); // SPI_BR_SET(SI4432_SPI, SPI_BR_DIV8);
SI_CS_HIGH; SI_CS_HIGH;
// __enable_irq(); __enable_irq();
#if 0 #if 0
if(((uint8_t*)data)[0] == SI446X_CMD_IRCAL) // If we're doing an IRCAL then wait for its completion without a timeout since it can sometimes take a few seconds if(((uint8_t*)data)[0] == SI446X_CMD_IRCAL) // If we're doing an IRCAL then wait for its completion without a timeout since it can sometimes take a few seconds
#if 0 #if 0
@ -1943,13 +1943,25 @@ void SI446x_Fill(int s, int start)
uint8_t data[3]; uint8_t data[3];
do { do {
again: again:
#if 1
data[0] = SI446X_CMD_GET_MODEM_STATUS; data[0] = SI446X_CMD_GET_MODEM_STATUS;
data[1] = 0xFF; data[1] = 0xFF;
SI4463_do_api(data, 1, data, 3); // TODO no clear of interrups SI4463_do_api(data, 1, data, 3); // TODO no clear of interrups
if (data[2] == 0) goto again; if (data[2] == 0) {
if (i > 0)
data[2] = age[i-1];
else
goto again;
}
if (data[2] == 255) goto again; if (data[2] == 255) goto again;
if (i >= 0) if (i >= 0)
age[i]=(char)data[2]; // Skip first RSSI age[i]=(char)data[2]; // Skip first RSSI
#else
if (i>=0)
age[i] = getFRR(SI446X_CMD_READ_FRR_A);
// else
#endif
if (++i >= sweep_points) break; if (++i >= sweep_points) break;
if (t) if (t)
my_microsecond_delay(t); my_microsecond_delay(t);

@ -1902,7 +1902,7 @@ draw_menu_buttons(const menuitem_t *menu)
} }
goto draw_divider; goto draw_divider;
} else if (menu[i].data == KM_LOWOUTLEVEL) { } else if (menu[i].data == KM_LOWOUTLEVEL) {
local_slider_positions = ((get_level() - level_min) * (MENU_FORM_WIDTH-8)) / level_range + OFFSETX+4; local_slider_positions = ((get_level() - level_min()) * (MENU_FORM_WIDTH-8)) / level_range() + OFFSETX+4;
for (int i=0; i <= 4; i++) { for (int i=0; i <= 4; i++) {
ili9341_drawstring(step_text[i], button_start+12 + i * MENU_FORM_WIDTH/5, y+button_height-9); ili9341_drawstring(step_text[i], button_start+12 + i * MENU_FORM_WIDTH/5, y+button_height-9);
} }
@ -1915,7 +1915,7 @@ draw_menu_buttons(const menuitem_t *menu)
local_slider_positions = button_start; local_slider_positions = button_start;
ili9341_blitBitmap(local_slider_positions - 4, y, 7, 5, slider_bitmap); ili9341_blitBitmap(local_slider_positions - 4, y, 7, 5, slider_bitmap);
} else if (menu[i].data == KM_HIGHOUTLEVEL) { } else if (menu[i].data == KM_HIGHOUTLEVEL) {
local_slider_positions = ((get_level() - level_min ) * (MENU_FORM_WIDTH-8)) / level_range + OFFSETX+4; local_slider_positions = ((get_level() - level_min() ) * (MENU_FORM_WIDTH-8)) / level_range() + OFFSETX+4;
goto draw_slider; goto draw_slider;
} }
} }
@ -2080,7 +2080,7 @@ menu_select_touch(int i, int pos)
check_frequency_slider(slider_freq); check_frequency_slider(slider_freq);
} }
} else if (menu_is_form(menu) && MT_MASK(menu[i].type) == MT_KEYPAD && keypad == KM_LOWOUTLEVEL) { } else if (menu_is_form(menu) && MT_MASK(menu[i].type) == MT_KEYPAD && keypad == KM_LOWOUTLEVEL) {
uistat.value = setting.external_gain + ((touch_x - OFFSETX+4) * level_range ) / (MENU_FORM_WIDTH-8) + level_min ; uistat.value = setting.external_gain + ((touch_x - OFFSETX+4) * level_range() ) / (MENU_FORM_WIDTH-8) + level_min() ;
apply_step: apply_step:
set_keypad_value(keypad); set_keypad_value(keypad);
apply: apply:
@ -2089,7 +2089,7 @@ menu_select_touch(int i, int pos)
// } // }
// } else if (MT_MASK(menu[i].type) == MT_ADV_CALLBACK && menu[i].reference == menu_sdrive_acb) { // } else if (MT_MASK(menu[i].type) == MT_ADV_CALLBACK && menu[i].reference == menu_sdrive_acb) {
} else if (menu_is_form(menu) && MT_MASK(menu[i].type) == MT_KEYPAD && keypad == KM_HIGHOUTLEVEL) { } else if (menu_is_form(menu) && MT_MASK(menu[i].type) == MT_KEYPAD && keypad == KM_HIGHOUTLEVEL) {
set_level( (touch_x - OFFSETX+4) *(level_range) / (MENU_FORM_WIDTH-8) + level_min ); set_level( (touch_x - OFFSETX+4) *(level_range()) / (MENU_FORM_WIDTH-8) + level_min() );
goto apply; goto apply;
} }
keypad_mode = old_keypad_mode; keypad_mode = old_keypad_mode;

@ -425,6 +425,7 @@ enum {
KM_ATTACK, KM_ATTACK,
#ifdef TINYSA4 #ifdef TINYSA4
KM_LPF, KM_LPF,
KM_LEVEL,
#endif #endif
#ifdef __LIMITS__ #ifdef __LIMITS__
KM_LIMIT_FREQ, KM_LIMIT_LEVEL, KM_LIMIT_FREQ, KM_LIMIT_LEVEL,
@ -449,7 +450,7 @@ static const struct {
{keypads_plusmin_unit, "ACTUAL\nPOWER"}, // actual power {keypads_plusmin_unit, "ACTUAL\nPOWER"}, // actual power
{keypads_freq , "IF"}, // IF {keypads_freq , "IF"}, // IF
{keypads_positive , "SAMPLE\nDELAY"}, // sample delay #10 {keypads_positive , "SAMPLE\nDELAY"}, // sample delay #10
{keypads_plusmin , "LEVEL"}, // KM_LOWOUTLEVEL {keypads_plusmin , "OUTPUT\nLEVEL"}, // KM_LOWOUTLEVEL
{keypads_positive , "DECAY"}, // KM_DECAY {keypads_positive , "DECAY"}, // KM_DECAY
{keypads_positive , "NOISE\nLEVEL"}, // KM_NOISE {keypads_positive , "NOISE\nLEVEL"}, // KM_NOISE
{keypads_freq , "FREQ"}, // KM_30MHz | KM_10MHz {keypads_freq , "FREQ"}, // KM_30MHz | KM_10MHz
@ -463,7 +464,7 @@ static const struct {
{keypads_positive , "MINIMUM\nGRIDLINES"}, // KM_GRIDLINES {keypads_positive , "MINIMUM\nGRIDLINES"}, // KM_GRIDLINES
{keypads_freq , "MARKER\nFREQ"}, // KM_MARKER {keypads_freq , "MARKER\nFREQ"}, // KM_MARKER
{keypads_freq , "MODULATION\nFREQ"}, // KM_MODULATION {keypads_freq , "MODULATION\nFREQ"}, // KM_MODULATION
{keypads_plusmin , "LEVEL"}, // KM_HIGHOUTLEVEL #25 {keypads_plusmin , "OUTPUT\nLEVEL"}, // KM_HIGHOUTLEVEL #25
#ifdef TINYSA4 #ifdef TINYSA4
{keypads_plusmin , "COR\nAM"}, // KM_COR_AM {keypads_plusmin , "COR\nAM"}, // KM_COR_AM
{keypads_plusmin , "COR\nWFM"}, // KM_COR_WFM {keypads_plusmin , "COR\nWFM"}, // KM_COR_WFM
@ -476,6 +477,7 @@ static const struct {
{keypads_positive , "ATTACK"}, // KM_ATTACK {keypads_positive , "ATTACK"}, // KM_ATTACK
#ifdef TINYSA4 #ifdef TINYSA4
{keypads_freq , "ULTRA\nSTART"}, // KM_LPF {keypads_freq , "ULTRA\nSTART"}, // KM_LPF
{keypads_plusmin , "LEVEL"}, // KM_LEVEL
#endif #endif
#ifdef __LIMITS__ #ifdef __LIMITS__
{keypads_freq , "END\nFREQ"}, // KM_LIMIT_FREQ {keypads_freq , "END\nFREQ"}, // KM_LIMIT_FREQ
@ -532,6 +534,71 @@ static UI_FUNCTION_ADV_CALLBACK(menu_sweep_acb)
menu_push_submenu(menu_sweep); menu_push_submenu(menu_sweep);
} }
static UI_FUNCTION_ADV_CALLBACK(menu_curve_acb)
{
(void)item;
if (b){
plot_printf(uistat.text, sizeof uistat.text, "%.3QHz %+.1fdB",
config.correction_frequency[CORRECTION_LOW_OUT][data],
config.correction_value[CORRECTION_LOW_OUT][data]);
b->param_1.text = uistat.text;
return;
}
if (config.low_level_output_offset == 100)
return;
int old_m = setting.mode;
reset_settings(M_GENLOW);
set_level(-35);
set_sweep_frequency(ST_CW, config.correction_frequency[CORRECTION_LOW_OUT][data]);
setting.mute = false;
perform(false, 0, config.correction_frequency[CORRECTION_LOW_OUT][data], false);
perform(false, 1, config.correction_frequency[CORRECTION_LOW_OUT][data], false);
plot_printf(uistat.text, sizeof uistat.text, "Level of %.3QHz output",
config.correction_frequency[CORRECTION_LOW_OUT][data]);
kp_help_text = uistat.text;
kp_buf[0]=0;
ui_mode_keypad(KM_LEVEL);
if (kp_buf[0] != 0) {
float new_offset = (-35.0) - uistat.value + config.correction_value[CORRECTION_LOW_OUT][data]; // calculate offset based on difference between measured peak level and known peak level
if (new_offset > -25 && new_offset < 25) {
config.correction_value[CORRECTION_LOW_OUT][data] = new_offset;
config_save();
}
}
reset_settings(old_m);
}
static UI_FUNCTION_ADV_CALLBACK(menu_output_level_acb)
{
(void)item;
(void)data;
if (b){
return;
}
int old_m = setting.mode;
reset_settings(M_GENLOW);
set_level(-25);
set_sweep_frequency(ST_CW, 30000000);
setting.mute = false;
perform(false, 0, 30000000, false);
perform(false, 1, 30000000, false);
kp_buf[0]=0;
ui_mode_keypad(KM_LEVEL);
if (kp_buf[0] != 0) {
float old_offset = config.low_level_output_offset;
if (old_offset == 100) old_offset = 0;
float new_offset = uistat.value - (-25.0) + old_offset; // calculate offset based on difference between measured peak level and known peak level
if (uistat.value == 100) new_offset = 100;
if ((new_offset > -5 && new_offset < 5) || new_offset == 100) {
config.low_level_output_offset = new_offset;
config_save();
}
}
reset_settings(old_m);
}
static UI_FUNCTION_ADV_CALLBACK(menu_mode_acb) static UI_FUNCTION_ADV_CALLBACK(menu_mode_acb)
{ {
@ -2172,12 +2239,61 @@ static const menuitem_t menu_settings2[] =
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
//#ifdef TINYSA4
static const menuitem_t menu_curve3[] = {
{ MT_FORM | MT_ADV_CALLBACK, 14, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 15, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 16, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 17, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 18, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 19, "%s", menu_curve_acb },
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_curve2[] = {
{ MT_FORM | MT_ADV_CALLBACK, 7, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 8, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 9, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 10, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 11, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 12, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 13, "%s", menu_curve_acb },
{ MT_FORM | MT_SUBMENU, 0, S_RARROW" MORE", menu_curve3},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_curve[] = {
{ MT_FORM | MT_ADV_CALLBACK, 0, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 1, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 2, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 3, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 4, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 5, "%s", menu_curve_acb },
{ MT_FORM | MT_ADV_CALLBACK, 6, "%s", menu_curve_acb },
{ MT_FORM | MT_SUBMENU, 0, S_RARROW" MORE", menu_curve2},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
//#endif
static const menuitem_t menu_actual_power[] =
{
{ MT_KEYPAD, KM_ACTUALPOWER, "INPUT\nLEVEL", "dBm"},
{ MT_ADV_CALLBACK, 0, "OUTPUT\nLEVEL", menu_output_level_acb},
#ifdef TINYSA4
{ MT_SUBMENU | MT_LOW,0, "OUTPUT\nCURVE", menu_curve},
#endif
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_settings[] = static const menuitem_t menu_settings[] =
{ {
{ MT_ADV_CALLBACK | MT_LOW, 0,"LO OUTPUT", menu_lo_output_acb}, { MT_ADV_CALLBACK | MT_LOW, 0,"LO OUTPUT", menu_lo_output_acb},
#ifndef TINYSA4 { MT_SUBMENU, 0, "ACTUAL\nPOWER", menu_actual_power},
{ MT_KEYPAD, KM_ACTUALPOWER, "ACTUAL\nPOWER", NULL},
#endif
{ MT_KEYPAD | MT_LOW, KM_IF, "IF FREQ", "0=auto IF"}, { MT_KEYPAD | MT_LOW, KM_IF, "IF FREQ", "0=auto IF"},
{ MT_SUBMENU,0, "SCAN SPEED", menu_scanning_speed}, { MT_SUBMENU,0, "SCAN SPEED", menu_scanning_speed},
#ifndef TINYSA4 #ifndef TINYSA4
@ -2287,7 +2403,6 @@ static const menuitem_t menu_config[] = {
{ MT_SUBMENU, 0, "CONNECTION", menu_connection}, { MT_SUBMENU, 0, "CONNECTION", menu_connection},
#endif #endif
#ifdef TINYSA4 #ifdef TINYSA4
{ MT_KEYPAD, KM_ACTUALPOWER, "ACTUAL\nPOWER", NULL},
{ MT_KEYPAD, KM_REPEAT, "SAMPLE\nREPEAT", "1..100"}, { MT_KEYPAD, KM_REPEAT, "SAMPLE\nREPEAT", "1..100"},
#endif #endif
{ MT_SUBMENU, 0, "EXPERT\nCONFIG", menu_settings}, { MT_SUBMENU, 0, "EXPERT\nCONFIG", menu_settings},
@ -2526,10 +2641,10 @@ static void fetch_numeric_target(void)
case KM_LOWOUTLEVEL: case KM_LOWOUTLEVEL:
uistat.value = get_level(); // compensation for dB offset during low output mode uistat.value = get_level(); // compensation for dB offset during low output mode
float end_level = ((int32_t)uistat.value)+setting.level_sweep; float end_level = ((int32_t)uistat.value)+setting.level_sweep;
if (end_level < level_min) if (end_level < level_min())
end_level = level_min; end_level = level_min();
if (end_level > level_max) if (end_level > level_max())
end_level = level_max; end_level = level_max();
uistat.value += setting.external_gain; uistat.value += setting.external_gain;
end_level += setting.external_gain; end_level += setting.external_gain;
if (setting.level_sweep != 0) if (setting.level_sweep != 0)
@ -2715,6 +2830,8 @@ set_numeric_value(void)
config_save(); config_save();
ultra_threshold = config.ultra_threshold; ultra_threshold = config.ultra_threshold;
break; break;
case KM_LEVEL:
break;
#endif #endif
#ifdef __LIMITS__ #ifdef __LIMITS__
case KM_LIMIT_FREQ: case KM_LIMIT_FREQ:

Loading…
Cancel
Save

Powered by TurnKey Linux.