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; autoSweepFreqStep = ( setting.BandscopeSpan ) / sweepPoints;
offsetFreqIncrement = autoSweepFreqStep; // 2500 Hz for 200kHz span, 80 points per sweep offsetFreqIncrement = autoSweepFreqStep; // 2500 Hz for 200kHz span, 80 points per sweep
vbw = autoSweepFreqStep / 1000.0; // Set the video resolution bandwidth = rcvr.SetRBW ( setting.BandscopeRBW10, &delaytime ); // Set it in the receiver Si4432
ownrbw = 3.1; // and fix the resolution bandwidth to 2.6kHz
bandwidth = rcvr.SetRBW ( ownrbw * 10.0, &delaytime ); // Set it in the receiver Si4432
//Serial.printf("set rcvr Freq get:%u, tempIF:%u\n", rcvr.GetFrequency(), tempIF); //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 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 offsetIncrement = 8; // 8 * 312.5 = 2500
} }
if (setting.BandscopeSpan == 400000) // wider span, same no of points
offsetIncrement = offsetIncrement * 2;
offsetFreq = offsetStep * offsetFreqIncrement; offsetFreq = offsetStep * offsetFreqIncrement;
offsetValue = offsetStep * offsetIncrement; offsetValue = offsetStep * offsetIncrement;
} }

View File

@ -17,11 +17,14 @@ void initSigLow()
//img.unloadFont(); // Free up memory from any previous incarnation of img //img.unloadFont(); // Free up memory from any previous incarnation of img
img.deleteSprite(); img.deleteSprite();
img.setColorDepth ( 16 ); img.setColorDepth ( 16 );
img.setAttribute ( PSRAM_ENABLE, false ); // Don't use the PSRAM on the WROVERs img.setAttribute ( PSRAM_ENABLE, false ); // Don't use the PSRAM on the WROVERs
img.createSprite ( 320, 55 ); // used for frequency display img.createSprite ( 320, 55 ); // used for frequency display
img.loadFont(SA_FONT_LARGE); img.loadFont(SA_FONT_LARGE);
SetRX ( 1 ); // LO and RX both in receive until turned on by UI 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 #ifdef SI_TG_IF_CS
if (tgIF_OK) { if (tgIF_OK) {

43
cmd.cpp
View File

@ -2744,12 +2744,33 @@ uint32_t lastStart; // Old sweep start frequency
{ {
changedSetting = true; // Yes it did changedSetting = true; // Yes it did
initSweep = true; initSweep = true;
// RedrawHisto (); // Redraw labels and restart sweep with new settings
WriteSettings (); // and save the setting structure 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 ) uint32_t GetBandscopeStart ( void )
{ {
return setting.BandscopeStart; return setting.BandscopeStart;
@ -2760,7 +2781,6 @@ uint32_t GetBandscopeStart ( void )
/* /*
* Specific start/stop frequency setting for Bandscope mode * Specific start/stop frequency setting for Bandscope mode
*/ */
void SetBandscopeSpan ( uint32_t spanFreq ) void SetBandscopeSpan ( uint32_t spanFreq )
{ {
uint32_t lastSpan; // Old sweep span 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 ();
}
}
/* /*

12
cmd.h
View File

@ -165,19 +165,23 @@ uint8_t GetPreampGain ( bool* agc, uint8_t* reg );
void SetSweepStart ( uint32_t freq ); // Added in Version 2.3 void SetSweepStart ( uint32_t freq ); // Added in Version 2.3
uint32_t GetSweepStart ( void ); uint32_t GetSweepStart ( void );
void SetSweepStop ( uint32_t freq ); // Added in Version 2.3 void SetSweepStop ( uint32_t freq ); // Added in Version 2.3
uint32_t GetSweepStop ( void ); uint32_t GetSweepStop ( void );
void SetIFsweepStart ( uint32_t freq ); // Added in Version 3.0c void SetIFsweepStart ( uint32_t freq ); // Added in Version 3.0c
uint32_t GetIFsweepStart ( void ); uint32_t GetIFsweepStart ( void );
void SetBandscopeStart ( uint32_t freq ); // Added in Version 3.0f void SetBandscopeStart ( uint32_t freq ); // Added in Version 3.0f
uint32_t GetBandscopeStart ( void ); uint32_t GetBandscopeStart ( void );
void SetBandscopeSpan ( uint32_t freq ); // Added in Version 3.0f void SetBandscopeSpan ( uint32_t freq ); // Added in Version 3.0f
uint32_t GetBandscopeSpan ( void ); uint32_t GetBandscopeSpan ( void );
void SetIFsweepStop ( uint32_t freq ); // Added in Version 3.0c 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 ); uint32_t GetIFsweepStop ( void );
void SetIFsweepSigFreq ( uint32_t freq ); // Added in Version 3.0c void SetIFsweepSigFreq ( uint32_t freq ); // Added in Version 3.0c

View File

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

View File

@ -1064,21 +1064,22 @@ void init_sweep()
old_settingSpur = -100; old_settingSpur = -100;
old_bandwidth = 0; old_bandwidth = 0;
SetRX ( 0 ); // LO to transmit, RX to receive 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 xmit.SetDrive ( setting.Drive ); // Set transmitter power level
rcvr.SetPreampGain ( setting.PreampGain ); rcvr.SetPreampGain ( setting.PreampGain );
#ifdef SI_TG_IF_CS #ifdef SI_TG_IF_CS
if (tgIF_OK) { if (tgIF_OK) {
tg_if.TxMode ( trackGenSetting.IF_Drive ); // turn on the IF oscillator in tracking generator tg_if.TxMode ( trackGenSetting.IF_Drive ); // turn on the IF oscillator in tracking generator
} }
#endif #endif
#ifdef SI_TG_LO_CS #ifdef SI_TG_LO_CS
if (tgLO_OK) { if (tgLO_OK) {
tg_lo.TxMode ( trackGenSetting.LO_Drive ); // turn on the Local Oscillator in tracking generator tg_lo.TxMode ( trackGenSetting.LO_Drive ); // turn on the Local Oscillator in tracking generator
} }
#endif #endif

262
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, enum { KM_START, KM_STOP, KM_CENTER, KM_SPAN, KM_FOCUS,
KM_REFPOS, KM_ATTENUATION, KM_ACTUALPOWER, KM_IFFREQ, KM_PREAMP, KM_REFPOS, KM_ATTENUATION, KM_ACTUALPOWER, KM_IFFREQ, KM_PREAMP,
KM_TUNE, KM_SGFREQ, KM_SGLEVEL, KM_SGLEVCAL, KM_IFSTART, KM_IFSTOP, 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", "START", "STOP", "CENTER", "SPAN", "FOCUS",
"REFPOS", "ATTEN", "POWER", "IF FREQ", "PREAMP", "REFPOS", "ATTEN", "POWER", "IF FREQ", "PREAMP",
"XTAL CAL", "SG FREQ", "dBm", "Max dBm", "IF START", "IF STOP", "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_recall_cb ( int item );
static void menu_version_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_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_tracking_cb(int item); // M0WID - added in 3.0e
static void menu_tg_offset_cb(int item); // M0WID - added in 3.0e static void menu_tg_offset_cb(int item); // M0WID - added in 3.0e
@ -730,16 +739,41 @@ static Menuitem menu_IFsweep_top[] = // This is the main "IF_SWEEP" menu
}; };
static Menuitem menu_BandscopeSpan[] = // Badscope Span settings
{
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 static Menuitem menu_Bandscope_top[] = // This is the main "IF_SWEEP" menu
{ {
Menuitem ( MT_MENU, "MODE", menu_mode ), Menuitem ( MT_MENU, "MODE", menu_mode ),
Menuitem ( MT_FUNC, "\2SWEEP\0START", menu_Bandscope_cb ), Menuitem ( MT_FUNC, "\2SWEEP\0START", menu_BandscopeStart_cb ),
Menuitem ( MT_FUNC, "\2SWEEP\0SPAN", menu_Bandscope_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 Menuitem ( MT_END ) // End marker
}; };
/* /*
* And last but not least the main menu! * 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. * from the display.
* *
* Modified in Version 2.5 by WA2FZW: * Modified in Version 2.5 by WA2FZW:
@ -1433,13 +1467,13 @@ static void menu_touch_cb ( int item )
{ {
switch ( item ) switch ( item )
{ {
case 0: // All these need symbols! case 0: // Touch calibrate
touch_cal_exec (); touch_cal_exec ();
request_to_redraw_grid (); request_to_redraw_grid ();
draw_menu (); draw_menu ();
break; break;
case 1: case 1: // Touch Draw test
touch_draw_test (); touch_draw_test ();
request_to_redraw_grid (); request_to_redraw_grid ();
draw_menu (); draw_menu ();
@ -1740,12 +1774,92 @@ static void menu_IF_sweep_cb ( int item )
ui_process_keypad (); 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 (); 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 * "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_TGLO_DRIVE.....Tracking generator LO drive
keypads_level, // KM_TGIF_DRIVE.....Tracking generator IF drive keypads_level, // KM_TGIF_DRIVE.....Tracking generator IF drive
keypads_freq, // KM_BANDSCOPESTART.IF Sweep start frequency 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,10 +2491,18 @@ static void fetch_numeric_target ( void )
uistat.value = setting.BandscopeStart; uistat.value = setting.BandscopeStart;
break; break;
case KM_BANDSCOPESPAN: case KM_WFMIN:
uistat.value = setting.BandscopeSpan; uistat.value = setting.WaterfallMin;
break; break;
case KM_WFGAIN:
uistat.value = setting.WaterfallGain;
break;
case KM_BANDSCOPELEVEL:
uistat.value = setting.BandscopeMaxGrid;
break;
} }
uint32_t x = uistat.value; uint32_t x = uistat.value;
@ -2793,11 +2918,39 @@ static int keypad_click ( int key )
break; break;
case KM_BANDSCOPESPAN: // Bandscope span entered? case KM_WFMIN: // Bandscope span entered?
SetBandscopeSpan (( int32_t ) value ); if ( (value >= 0) && (value <= 200 ) )
setting.WaterfallMin = ( int16_t )value ;
else
{
DisplayError ( ERR_WARN,
"Invalid minimum level!",
"(0 - 200)",
NULL,
NULL );
}
break; 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;
} // End of "switch" } // End of "switch"
return KP_DONE; // Indicate finished with the keypad return KP_DONE; // Indicate finished with the keypad
@ -2991,41 +3144,46 @@ void UiProcessTouch ( void )
Serial.printf("x:%i y:%i\n", touch_x, touch_y); Serial.printf("x:%i y:%i\n", touch_x, touch_y);
touch_wait_release (); touch_wait_release ();
/*
// test to see if the touch is in the marker area * Some touchscreen areas have fast access to the submenu levels, depends on the mode
if ( (touch_y < 10) && (touch_x < 160) ) */
{ if ( setting.Mode == SA_LOW_RANGE )
marker[0].Toggle(); // marker 1 {
return; // test to see if the touch is in the marker area
} if ( (touch_y < 10) && (touch_x < 160) )
else if ( (touch_y < 10) && (touch_x > 160) ) {
{ marker[0].Toggle(); // marker 1
marker[2].Toggle(); // marker 3 return;
return; }
} else if ( (touch_y < 10) && (touch_x > 160) )
else if ( (touch_y < 20) && (touch_x < 160) ) {
{ marker[2].Toggle(); // marker 3
marker[1].Toggle(); // marker 2 return;
return; }
} else if ( (touch_y < 20) && (touch_x < 160) )
else if ( (touch_y < 20) && (touch_x > 160) ) {
{ marker[1].Toggle(); // marker 2
marker[3].Toggle(); // marker 4 return;
return; }
} else if ( (touch_y < 20) && (touch_x > 160) )
else if ( (touch_y < 40) && (touch_x > 30) ) {
StartMarkerMenu(); marker[3].Toggle(); // marker 4
else if ( (touch_y > 210) && ( setting.Mode == SA_LOW_RANGE ) ) return;
StartSweepMenu(); }
else if ( (touch_x < 30) && (touch_y < 60) && ( setting.Mode == SA_LOW_RANGE ) ) else if ( (touch_y < 40) && (touch_x > 30) )
StartRBWMenu(); StartMarkerMenu();
else if ( (touch_x < 30) && (touch_y > CHAR_HEIGHT * 20 ) && ( touch_y < CHAR_HEIGHT * 22 ) && ( setting.Mode == SA_LOW_RANGE ) ) else if ( touch_y > 210 )
{ StartSweepMenu();
SetSpur (!setting.Spur); else if ( (touch_x < 30) && (touch_y < 60) )
return; StartRBWMenu();
} else if ( (touch_x < 30) && (touch_y > CHAR_HEIGHT * 20 ) && ( touch_y < CHAR_HEIGHT * 22 ) )
else if ( (touch_x < 30) && ( setting.Mode == SA_LOW_RANGE ) ) {
StartDisplayMenu(); SetSpur (!setting.Spur);
return;
}
else if ( (touch_x < 30) )
StartDisplayMenu();
}
selection = -1; // Switch menu mode selection = -1; // Switch menu mode
bg = BLACK; // black background bg = BLACK; // black background