Bandscope menu changed

This commit is contained in:
M0WID 2020-08-21 12:33:06 +01:00
parent f105b70210
commit 76d7cd9aee
7 changed files with 276 additions and 69 deletions

View File

@ -169,10 +169,7 @@ static uint16_t chunkIndex;
autoSweepFreqStep = ( setting.BandscopeSpan ) / sweepPoints;
offsetFreqIncrement = autoSweepFreqStep; // 2500 Hz for 200kHz span, 80 points per sweep
vbw = autoSweepFreqStep / 1000.0; // Set the video resolution
ownrbw = 3.1; // and fix the resolution bandwidth to 2.6kHz
bandwidth = rcvr.SetRBW ( ownrbw * 10.0, &delaytime ); // Set it in the receiver Si4432
bandwidth = rcvr.SetRBW ( setting.BandscopeRBW10, &delaytime ); // Set it in the receiver Si4432
//Serial.printf("set rcvr Freq get:%u, tempIF:%u\n", rcvr.GetFrequency(), tempIF);
rcvr.SetFrequency ( setting.IF_Freq ); // Set the RX Si4432 to the IF frequency
@ -678,6 +675,10 @@ void resetOffsets ()
offsetIncrement = 8; // 8 * 312.5 = 2500
}
if (setting.BandscopeSpan == 400000) // wider span, same no of points
offsetIncrement = offsetIncrement * 2;
offsetFreq = offsetStep * offsetFreqIncrement;
offsetValue = offsetStep * offsetIncrement;
}

View File

@ -23,6 +23,9 @@ void initSigLow()
SetRX ( 1 ); // LO and RX both in receive until turned on by UI
xmit.SetOffset ( 0 ); // make sure frequency offset registers are zero
rcvr.SetOffset ( 0 );
#ifdef SI_TG_IF_CS
if (tgIF_OK) {
tg_if.RxMode ( ); // turn off the IF oscillator in tracking generator

43
cmd.cpp
View File

@ -2744,12 +2744,33 @@ uint32_t lastStart; // Old sweep start frequency
{
changedSetting = true; // Yes it did
initSweep = true;
// RedrawHisto (); // Redraw labels and restart sweep with new settings
WriteSettings (); // and save the setting structure
}
}
/*
* "SetRBW" - Sets the resolution bandwidth in the "setting" structure. We don't
* bother to actually set it in the receiver Si4432 as that is done at the start
* of each scan cycle.
*/
void SetBandscopeRBW ( int bw )
{
int16_t oldRBW = setting.BandscopeRBW10;
int16_t tempBw = bw;
setting.BandscopeRBW10 = bw;
tempBw = rcvr.SetRBW ( bw, &delaytime );
if ( tempBw != oldRBW )
{
changedSetting = true;
WriteSettings ();
}
}
uint32_t GetBandscopeStart ( void )
{
return setting.BandscopeStart;
@ -2760,7 +2781,6 @@ uint32_t GetBandscopeStart ( void )
/*
* Specific start/stop frequency setting for Bandscope mode
*/
void SetBandscopeSpan ( uint32_t spanFreq )
{
uint32_t lastSpan; // Old sweep span
@ -2793,6 +2813,25 @@ uint32_t GetBandscopeSpan ( void )
}
/*
* "SetBandscopeLevel" - Sets the decibel level for the top line of the graph in Bandscope mode.
*/
void SetBandscopeLevel ( int ref )
{
int oldMin = setting.BandscopeMinGrid;
int oldMax = setting.BandscopeMaxGrid;
setting.BandscopeMaxGrid = ref;
setting.BandscopeMinGrid = ref - yGrid * setting.PowerGrid;
if (( oldMin != setting.BandscopeMinGrid ) || ( oldMax != setting.BandscopeMaxGrid ))
{
changedSetting = true;
WriteSettings ();
}
}
/*

4
cmd.h
View File

@ -177,6 +177,10 @@ uint32_t GetBandscopeStart ( void );
void SetBandscopeSpan ( uint32_t freq ); // Added in Version 3.0f
uint32_t GetBandscopeSpan ( void );
void SetBandscopeRBW ( int v ); // Sets the resolution bandwidth
void SetBandscopeLevel ( int ref ); // Sets the decibel level for the top line of the graph
void SetIFsweepStop ( uint32_t freq ); // Added in Version 3.0c
uint32_t GetIFsweepStop ( void );

View File

@ -251,13 +251,14 @@ typedef struct {
uint16_t Mode = SA_LOW_RANGE; // Default to low freq range Spectrum analyser mode
uint16_t Timebase = 100; // Timebase for Zero IF modes (milliSeconds)
int16_t TriggerLevel = -40; // Trigger level for ZeroIF mode (dBm)
uint32_t BandscopeStart = 7000000; // Start frequency for bandscope sweep
uint32_t BandscopeStart = 14000000; // Start frequency for bandscope sweep
uint32_t BandscopeSpan = 200000; // Span for the bandscope sweep
uint16_t BandscopePoints = BANDSCOPE_POINTS; // No of points in the sweep. 80/160/320
int16_t BandscopeMaxGrid= -30;
int16_t BandscopeMinGrid= -130;
int16_t BandscopeRBW10 = 28; // Resolution Bandwidth setting*10;
int16_t WaterfallMin = 17; // RSSI values below this are treated as zero
float WaterfallGain = 1.5; // Multiply RSSI value to get colour intensity
double WaterfallGain = 1.5; // Multiply RSSI value to get colour intensity
/*
* The following line should read:

View File

@ -1065,6 +1065,7 @@ void init_sweep()
old_bandwidth = 0;
SetRX ( 0 ); // LO to transmit, RX to receive
xmit.SetOffset ( 0 ); // make sure frequency offset registers are zero
xmit.SetDrive ( setting.Drive ); // Set transmitter power level
rcvr.SetPreampGain ( setting.PreampGain );

202
ui.cpp
View File

@ -197,7 +197,8 @@ uint8_t operation_requested = OP_NONE; // No operations so far
enum { KM_START, KM_STOP, KM_CENTER, KM_SPAN, KM_FOCUS,
KM_REFPOS, KM_ATTENUATION, KM_ACTUALPOWER, KM_IFFREQ, KM_PREAMP,
KM_TUNE, KM_SGFREQ, KM_SGLEVEL, KM_SGLEVCAL, KM_IFSTART, KM_IFSTOP,
KM_IFSIG, KM_TGOFFSET, KM_TGLO_DRIVE, KM_TGIF_DRIVE, KM_BANDSCOPESTART, KM_BANDSCOPESPAN };
KM_IFSIG, KM_TGOFFSET, KM_TGLO_DRIVE, KM_TGIF_DRIVE, KM_BANDSCOPESTART,
KM_WFMIN, KM_WFGAIN, KM_BANDSCOPELEVEL };
/*
@ -214,7 +215,8 @@ static const char * const keypad_mode_label[] =
"START", "STOP", "CENTER", "SPAN", "FOCUS",
"REFPOS", "ATTEN", "POWER", "IF FREQ", "PREAMP",
"XTAL CAL", "SG FREQ", "dBm", "Max dBm", "IF START", "IF STOP",
"IF Sig Freq", "TG OFFSET", "TG LO Drive", "TG IF Drive", "START", "SPAN"
"IF Sig Freq", "TG OFFSET", "TG LO Drive", "TG IF Drive", "START",
"WF MIN", "WF GAIN", "REF LEVEL"
};
@ -275,7 +277,14 @@ static void menu_IF_sweep_cb ( int item ); // M0WID added 3.0c
static void menu_recall_cb ( int item );
static void menu_version_cb (int item );
static void menu_generate_cb(int item); // WA2FZW - Added in M0WID's Version 05
static void menu_Bandscope_cb ( int item ); // M0WID added 3.0f
// forward declarations for bandscope menu items
static void menu_BandscopeStart_cb ( int item );
static void menu_BandscopeRbw_cb ( int item );
static void menu_BandscopeSpan_cb ( int item );
static void menu_BandscopeLevel_cb ( int item );
static void menu_WaterfallMin_cb ( int item );
static void menu_WaterfallGain_cb ( int item );
static void menu_tracking_cb(int item); // M0WID - added in 3.0e
static void menu_tg_offset_cb(int item); // M0WID - added in 3.0e
@ -730,15 +739,40 @@ static Menuitem menu_IFsweep_top[] = // This is the main "IF_SWEEP" menu
};
static Menuitem menu_Bandscope_top[] = // This is the main "IF_SWEEP" menu
static Menuitem menu_BandscopeSpan[] = // Badscope Span settings
{
Menuitem ( MT_MENU, "MODE", menu_mode ),
Menuitem ( MT_FUNC, "\2SWEEP\0START", menu_Bandscope_cb ),
Menuitem ( MT_FUNC, "\2SWEEP\0SPAN", menu_Bandscope_cb ),
Menuitem ( MT_FUNC, "200kHz", menu_BandscopeSpan_cb ),
Menuitem ( MT_FUNC, "400kHz", menu_BandscopeSpan_cb ),
Menuitem ( MT_BACK, "<-BACK" ), // Next level up
Menuitem ( MT_END ) // End marker
};
static Menuitem menu_BandscopeRBW[] = // Resolution bandwidth settings
{
Menuitem ( MT_FUNC, "2.6kHz", menu_BandscopeRbw_cb ), // In auto mode, there are many
Menuitem ( MT_FUNC, "2.8kHz", menu_BandscopeRbw_cb ), // more available settings that
Menuitem ( MT_FUNC, "3.1kHz", menu_BandscopeRbw_cb ), // are roughly the sweep range
Menuitem ( MT_FUNC, "3.7kHz", menu_BandscopeRbw_cb ), // divided by 300.
Menuitem ( MT_FUNC, "4.2kHz", menu_BandscopeRbw_cb ),
Menuitem ( MT_FUNC, "5.4kHz", menu_BandscopeRbw_cb ),
Menuitem ( MT_BACK, "<-BACK" ), // Next level up
Menuitem ( MT_END ) // End marker
};
static Menuitem menu_Bandscope_top[] = // This is the main "IF_SWEEP" menu
{
Menuitem ( MT_MENU, "MODE", menu_mode ),
Menuitem ( MT_FUNC, "\2SWEEP\0START", menu_BandscopeStart_cb ),
Menuitem ( MT_MENU, "\2SWEEP\0SPAN", menu_BandscopeSpan ),
Menuitem ( MT_MENU, "RBW", menu_BandscopeRBW ),
Menuitem ( MT_FUNC, "\2REF\0LEVEL", menu_BandscopeLevel_cb ), // Set top line of the grid
Menuitem ( MT_FUNC, "\2W'FALL\0MIN", menu_WaterfallMin_cb ),
Menuitem ( MT_FUNC, "\2W'FALL\0GAIN", menu_WaterfallGain_cb ),
Menuitem ( MT_END ) // End marker
};
/*
* And last but not least the main menu!
@ -1396,7 +1430,7 @@ static void menu_tracking_cb (int item )
}
/*
* "menu_autosettings_cb" seems to set all the defaults then clears the menu
* "menu_autosettings_cb" sets defaults then clears the menu
* from the display.
*
* Modified in Version 2.5 by WA2FZW:
@ -1433,13 +1467,13 @@ static void menu_touch_cb ( int item )
{
switch ( item )
{
case 0: // All these need symbols!
case 0: // Touch calibrate
touch_cal_exec ();
request_to_redraw_grid ();
draw_menu ();
break;
case 1:
case 1: // Touch Draw test
touch_draw_test ();
request_to_redraw_grid ();
draw_menu ();
@ -1740,12 +1774,92 @@ static void menu_IF_sweep_cb ( int item )
ui_process_keypad ();
}
static void menu_Bandscope_cb ( int item )
/*
* *********************************************
* BANDSCOPE MENU ITEMS
* *********************************************
*/
/*
* Handles the Bandscope RBW menu item.
*
*/
static void menu_BandscopeRbw_cb ( int item )
{
ui_mode_keypad ( item + KM_BANDSCOPESTART - 1 ); // item = 1 -> KM_BANDSCOPESTART, 2 -> KM_BANDSCOPESPAN
const int rbwsel[] = { 0, 26, 28, 31, 37 , 42, 54 }; // Resolution bandwidth choices (in KHz * 10)
SetBandscopeRBW ( rbwsel[item] );
menu_move_back ();
ui_mode_normal ();
}
/*
* Set the span for the bandscope
*/
static void menu_BandscopeSpan_cb ( int item )
{
switch ( item )
{
case 0: // 200kHz
setting.BandscopeSpan = 200000;
break;
case 1: // 400kHz
setting.BandscopeSpan = 400000;
break;
}
WriteSettings ();
menu_move_back ();
ui_mode_normal ();
}
/*
* Set the level of the top of the bandscope scale
*/
static void menu_BandscopeLevel_cb ( int item )
{
ui_mode_keypad ( KM_BANDSCOPELEVEL );
ui_process_keypad ();
}
/*
* Set the min for the bandscope waterfall colours
*/
static void menu_WaterfallMin_cb ( int item )
{
ui_mode_keypad ( KM_WFMIN );
ui_process_keypad ();
}
/*
* Set the gain for the bandscope waterfall colours
*/
static void menu_WaterfallGain_cb ( int item )
{
ui_mode_keypad ( KM_WFGAIN );
ui_process_keypad ();
}
/*
* Set the start frequency of the bandscope sweep
*/
static void menu_BandscopeStart_cb ( int item )
{
ui_mode_keypad ( KM_BANDSCOPESTART );
ui_process_keypad ();
}
/*
* "ensure_selection" - Validates that a menu selection is valid
*/
@ -1983,7 +2097,10 @@ static const keypads_t * const keypads_mode_tbl[] =
keypads_level, // KM_TGLO_DRIVE.....Tracking generator LO drive
keypads_level, // KM_TGIF_DRIVE.....Tracking generator IF drive
keypads_freq, // KM_BANDSCOPESTART.IF Sweep start frequency
keypads_freq // KM_BANDSCOPESPAN..IF Sweep stop frequency
keypads_integer, // KM_WFMIN..........Waterfall min level (RSSI)
keypads_level, // KM_WFGAIN.........Waterfall Gain
keypads_level // KM_BANDSCOPELEVEL.Grid reference level
};
@ -2374,8 +2491,16 @@ static void fetch_numeric_target ( void )
uistat.value = setting.BandscopeStart;
break;
case KM_BANDSCOPESPAN:
uistat.value = setting.BandscopeSpan;
case KM_WFMIN:
uistat.value = setting.WaterfallMin;
break;
case KM_WFGAIN:
uistat.value = setting.WaterfallGain;
break;
case KM_BANDSCOPELEVEL:
uistat.value = setting.BandscopeMaxGrid;
break;
}
@ -2793,8 +2918,36 @@ static int keypad_click ( int key )
break;
case KM_BANDSCOPESPAN: // Bandscope span entered?
SetBandscopeSpan (( int32_t ) value );
case KM_WFMIN: // Bandscope span entered?
if ( (value >= 0) && (value <= 200 ) )
setting.WaterfallMin = ( int16_t )value ;
else
{
DisplayError ( ERR_WARN,
"Invalid minimum level!",
"(0 - 200)",
NULL,
NULL );
}
break;
case KM_WFGAIN: // Bandscope span entered?
if ( (value >= 0.1) && (value <= 4.0 ) )
setting.WaterfallGain = value ;
else
{
DisplayError ( ERR_WARN,
"Invalid gain!",
"(0.1 - 4)",
NULL,
NULL );
}
break;
case KM_BANDSCOPELEVEL: // Bandscope level entered?
SetBandscopeLevel (( int32_t ) value );
break;
@ -2991,7 +3144,11 @@ void UiProcessTouch ( void )
Serial.printf("x:%i y:%i\n", touch_x, touch_y);
touch_wait_release ();
/*
* Some touchscreen areas have fast access to the submenu levels, depends on the mode
*/
if ( setting.Mode == SA_LOW_RANGE )
{
// test to see if the touch is in the marker area
if ( (touch_y < 10) && (touch_x < 160) )
{
@ -3015,17 +3172,18 @@ void UiProcessTouch ( void )
}
else if ( (touch_y < 40) && (touch_x > 30) )
StartMarkerMenu();
else if ( (touch_y > 210) && ( setting.Mode == SA_LOW_RANGE ) )
else if ( touch_y > 210 )
StartSweepMenu();
else if ( (touch_x < 30) && (touch_y < 60) && ( setting.Mode == SA_LOW_RANGE ) )
else if ( (touch_x < 30) && (touch_y < 60) )
StartRBWMenu();
else if ( (touch_x < 30) && (touch_y > CHAR_HEIGHT * 20 ) && ( touch_y < CHAR_HEIGHT * 22 ) && ( setting.Mode == SA_LOW_RANGE ) )
else if ( (touch_x < 30) && (touch_y > CHAR_HEIGHT * 20 ) && ( touch_y < CHAR_HEIGHT * 22 ) )
{
SetSpur (!setting.Spur);
return;
}
else if ( (touch_x < 30) && ( setting.Mode == SA_LOW_RANGE ) )
else if ( (touch_x < 30) )
StartDisplayMenu();
}
selection = -1; // Switch menu mode
bg = BLACK; // black background