diff --git a/main.c b/main.c index 71c5f0d..22fd8e6 100644 --- a/main.c +++ b/main.c @@ -1346,19 +1346,21 @@ set_sweep_frequency(int type, freq_t freq) if (freq > STOP_MAX) freq = STOP_MAX; bool cw_mode = FREQ_IS_CW(); // remember old mode - freq_t center, span; + freq_t center, span=0; switch (type) { case ST_START: setting.freq_mode &= ~FREQ_MODE_CENTER_SPAN; setting.frequency0 = freq; // if start > stop then make start = stop if (setting.frequency1 < freq) setting.frequency1 = freq; + span = (setting.frequency1 - setting.frequency0)/2; break; case ST_STOP: setting.freq_mode &= ~FREQ_MODE_CENTER_SPAN; setting.frequency1 = freq; // if start > stop then make start = stop if (setting.frequency0 > freq) setting.frequency0 = freq; + span = (setting.frequency1 - setting.frequency0)/2; break; case ST_CENTER: setting.freq_mode |= FREQ_MODE_CENTER_SPAN; @@ -1379,17 +1381,23 @@ set_sweep_frequency(int type, freq_t freq) center = START_MIN + span; if (center > STOP_MAX - span) center = STOP_MAX - span; - if (span != 0 && span < sweep_points) - span = sweep_points; setting.frequency0 = center - span; setting.frequency1 = center + span; break; case ST_CW: + force_cw: setting.freq_mode |= FREQ_MODE_CENTER_SPAN; setting.frequency0 = freq; setting.frequency1 = freq; + span = 0; break; } + if (span !=0 && span < sweep_points/2) { + freq = (setting.frequency1 + setting.frequency0)/2; + if (freq & 0x0001) + freq++; + goto force_cw; + } if (!cw_mode && FREQ_IS_CW()) // switch to CW mode setting.sweep_time_us = 0; // use minimum as start update_frequencies(); diff --git a/plot.c b/plot.c index 4794d8e..05d2d45 100644 --- a/plot.c +++ b/plot.c @@ -122,7 +122,6 @@ void update_grid(void) } if (config.gridlines < 3) config.gridlines = 6; - while (gdigit > 1) { grid = 5 * gdigit; if (fspan / grid >= config.gridlines) @@ -137,9 +136,13 @@ void update_grid(void) } grid_span = grid; - grid_offset = (WIDTH) * ((fstart % grid) / 100) / (fspan / 100); - grid_width = (WIDTH) * (grid / 100) / (fspan / 1000); - + if (grid > 1000) { + grid_offset = (WIDTH) * ((fstart % grid) / 100) / (fspan / 100); + grid_width = (WIDTH) * (grid / 100) / (fspan / 1000); + } else { + grid_offset = (WIDTH) * ((fstart % grid)) / (fspan); + grid_width = (WIDTH) * (grid) / (fspan/10); + } if (setting.waterfall) set_waterfall(); #ifdef __LEVEL_METER__ diff --git a/sa_core.c b/sa_core.c index d793e19..2ecbaee 100644 --- a/sa_core.c +++ b/sa_core.c @@ -3151,7 +3151,7 @@ static const int am_modulation[MODULATION_STEPS] = { 5, 1, 0, 1, 5, 9, 11, 9 }; #endif #define S1 1.5 -static const int fm_modulation[MODULATION_TABLES][MODULATION_STEPS] = // Avoid sign changes in NFM +static const int fm_modulation[MODULATION_TABLES][MODULATION_STEPS] = { #ifdef TINYSA4 // { 0*LND,(int)( 1.5*LND ), 2*LND, (int)(1.5*LND), 0*LND, (int)(-1.5*LND), (int)-2*LND, (int)(-1.5*LND)}, // High range, MO_NFM @@ -3160,7 +3160,7 @@ static const int fm_modulation[MODULATION_TABLES][MODULATION_STEPS] = // Avoid { 0*HN2D,(int)( 1.5*HN2D ), 2*HN2D, (int)(1.5*HN2D), 0*HN2D, (int)(-1.5*HN2D), (int)-2*HN2D, (int)(-1.5*HN2D)}, // High range, NFM2 { 0*HN3D,(int)( 1.5*HN3D ), 2*HN3D, (int)(1.5*HN3D), 0*HN3D, (int)(-1.5*HN3D), (int)-2*HN3D, (int)(-1.5*HN3D)}, // High range, NFM3 { 0*HWD,(int)( 1.5*HWD ), 2*HWD, (int)(1.5*HWD), 0*HWD, (int)(-1.5*HWD), (int)-2*HWD, (int)(-1.5*HWD)}, // HIgh range, MO_WFM -#else +#else // Avoid sign changes in NFM { 2*LND,(int)( (2+S1)*LND ), 4*LND, (int)((2+S1)*LND), 2*LND, (int)((2-S1)*LND), 0, (int)((2-S1)*LND)}, // Low range, MO_NFM { 0*LWD,(int)( S1*LWD ), 2*LWD, (int)(S1*LWD), 0*LWD, (int)(-S1*LWD), (int)-2*LWD, (int)(-S1*LWD)}, // Low range, MO_WFM { 2*HND,(int)( 3.5*HND ), 4*HND, (int)(3.5*HND), 2*HND, (int)(0.5*HND), 0, (int)(0.5*HND)}, // High range, MO_NFM @@ -7205,7 +7205,7 @@ void calibrate(void) #ifdef TINYSA4 set_sweep_frequency(ST_SPAN, 1000); markers[0].mtype |= M_AVER; - setting.repeat = 100; + setting.repeat = 10; #else set_sweep_frequency(ST_SPAN, 5000000); setting.repeat = 10; diff --git a/ui_sa.c b/ui_sa.c index 31634a5..2e8e478 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1574,10 +1574,16 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb) set_RBW(uistat.value/100); #endif // actual_rbw_x10 +#ifdef TINYSA4 kp_help_text = "Frequency deviation: 3 .. 500kHz"; +#define MINIMUM_DEVIATION 1500 +#else + kp_help_text = "Frequency deviation: 500Hz .. 500kHz"; +#define MINIMUM_DEVIATION 12000 +#endif ui_mode_keypad(KM_SPAN); - if (uistat.value < 12000) - uistat.value = 12000; // minimum span + if (uistat.value < MINIMUM_DEVIATION) + uistat.value = MINIMUM_DEVIATION; // minimum span set_sweep_frequency(ST_SPAN, uistat.value*4); // set_measurement(M_FM); break; @@ -2715,6 +2721,9 @@ const menuitem_t menu_marker_search[] = { { MT_CALLBACK, 3, "MAX\n" S_RARROW" RIGHT", menu_marker_search_cb }, { MT_ADV_CALLBACK, 0, "ENTER\n%s", menu_enter_marker_acb}, { MT_ADV_CALLBACK, M_TRACKING, "TRACKING",menu_marker_modify_acb }, +#ifdef TINYSA4 + { MT_KEYPAD, KM_NOISE, "PEAK\n\b%s", "2..20 dB"}, +#endif { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; @@ -2865,7 +2874,6 @@ static const menuitem_t menu_settings3[] = #ifndef __NEW_SWITCHES__ { MT_ADV_CALLBACK, 0, "ADF OUT", menu_adf_out_acb}, #endif - { MT_ADV_CALLBACK, 0, "ENABLE\nULTRA", menu_ultra_acb}, { MT_KEYPAD, KM_ULTRA_START,"ULTRASTART\n\b%s", "10G=auto"}, { MT_ADV_CALLBACK, 0, "ENABLE\nDIRECT", menu_direct_acb}, // { MT_KEYPAD | MT_LOW, KM_IF2, "IF2 FREQ", "Set to zero for no IF2"}, @@ -2890,8 +2898,6 @@ static const menuitem_t menu_settings3[] = { MT_ADV_CALLBACK, 0, "DEBUG\nSPUR", menu_debug_spur_acb}, #endif { MT_KEYPAD, KM_10MHZ, "CORRECT\nFREQUENCY", "Enter actual l0MHz frequency"}, - { MT_KEYPAD, KM_GRIDLINES, "MINIMUM\nGRIDLINES", "Enter minimum horizontal grid divisions"}, - { MT_CALLBACK, 0 , "CLEAR\nCONFIG", menu_clearconfig_cb}, { MT_ADV_CALLBACK, 0, "PULSE\nHIGH", menu_settings_pulse_acb}, #ifdef __HARMONIC__ { MT_SUBMENU | MT_HIGH,0, "HARMONIC", menu_harmonic}, @@ -2945,7 +2951,6 @@ static const menuitem_t menu_settings2[] = { MT_KEYPAD, KM_ATTACK, "ATTACK\n\b%s", "0..100000ms"}, #endif #ifdef TINYSA4 - { MT_KEYPAD, KM_NOISE, "NOISE LEV\n\b%s", "2..20 dB"}, { MT_KEYPAD, KM_30MHZ, "30MHz*100\n\b%s", "Enter actual 30MHz * 100"}, #endif { MT_SUBMENU, 0, S_RARROW" MORE", menu_settings3}, @@ -3002,18 +3007,10 @@ static const menuitem_t menu_actual_power[] = static const menuitem_t menu_settings[] = { { MT_SUBMENU, 0, "LEVEL\nCORRECTION", menu_actual_power}, - { MT_ADV_CALLBACK | MT_LOW, 0,"LO OUTPUT", menu_lo_output_acb}, { MT_KEYPAD | MT_LOW, KM_IF, "IF FREQ\n\b%s", "0=auto IF"}, { MT_SUBMENU,0, "SCAN\nSPEED", menu_scanning_speed}, -#ifndef TINYSA4 - { MT_KEYPAD, KM_REPEAT, "SAMPLE REP\n\b%s", "1..100"}, -#endif #ifdef TINYSA4 { MT_SUBMENU | MT_LOW,0, "MIXER\nDRIVE", menu_mixer_drive}, - { MT_ADV_CALLBACK, 0, "PULSE\nHIGH", menu_settings_pulse_acb}, -#ifdef __USE_SERIAL_CONSOLE__ - { MT_SUBMENU, 0, "CONNECTION", menu_connection}, -#endif #else { MT_SUBMENU | MT_LOW,0, "MIXER\nDRIVE", menu_lo_drive}, #endif @@ -3100,6 +3097,21 @@ const menuitem_t menu_date_time[] = { }; #endif +static const menuitem_t menu_config2[] = +{ + { MT_ADV_CALLBACK | MT_LOW, 0,"LO OUTPUT", menu_lo_output_acb}, + { MT_ADV_CALLBACK, 0, "PULSE\nHIGH", menu_settings_pulse_acb}, +#ifdef __ULTRA__ + { MT_ADV_CALLBACK, 0, "ENABLE\nULTRA", menu_ultra_acb}, +#endif + { MT_KEYPAD, KM_GRIDLINES, "MINIMUM\nGRIDLINES", "Enter minimum horizontal grid divisions"}, + { MT_CALLBACK, 0 , "CLEAR\nCONFIG", menu_clearconfig_cb}, +#ifdef __USE_SERIAL_CONSOLE__ + { MT_SUBMENU, 0, "CONNECTION", menu_connection}, +#endif + { MT_SUBMENU, 0, "EXPERT\nCONFIG", menu_settings}, + { MT_NONE, 0, NULL, menu_back} // next-> menu_back +}; static const menuitem_t menu_config[] = { { MT_SUBMENU, 0, "TOUCH", menu_touch}, @@ -3111,19 +3123,18 @@ static const menuitem_t menu_config[] = { #ifdef __SPUR__ { MT_ADV_CALLBACK,0, "%s", menu_spur_acb}, #endif -#ifdef TINYSA4 { MT_KEYPAD, KM_REPEAT, "SAMPLE REP\n\b%s", "1..100"}, -#endif #ifdef __LCD_BRIGHTNESS__ { MT_CALLBACK, 0, "BRIGHTNESS", menu_brightness_cb}, #endif #ifdef __USE_RTC__ { MT_SUBMENU, 0, "DATE\nTIME", menu_date_time}, #endif - { MT_SUBMENU, 0, "EXPERT\nCONFIG", menu_settings}, +// { MT_SUBMENU, 0, "EXPERT\nCONFIG", menu_settings}, #ifndef TINYSA4 { MT_SUBMENU, 0, S_RARROW" DFU", menu_dfu}, #endif + { MT_SUBMENU, 0, S_RARROW"MORE", menu_config2}, { MT_NONE, 0, NULL, menu_back} // next-> menu_back }; #if 0