diff --git a/Bandscope.ino b/Bandscope.ino index c4b1d3a..96c79a6 100644 --- a/Bandscope.ino +++ b/Bandscope.ino @@ -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; } diff --git a/SigLo.ino b/SigLo.ino index 7c0183e..d1a5f99 100644 --- a/SigLo.ino +++ b/SigLo.ino @@ -17,11 +17,14 @@ void initSigLow() //img.unloadFont(); // Free up memory from any previous incarnation of img img.deleteSprite(); img.setColorDepth ( 16 ); - img.setAttribute ( PSRAM_ENABLE, false ); // Don't use the PSRAM on the WROVERs - img.createSprite ( 320, 55 ); // used for frequency display + img.setAttribute ( PSRAM_ENABLE, false ); // Don't use the PSRAM on the WROVERs + img.createSprite ( 320, 55 ); // used for frequency display img.loadFont(SA_FONT_LARGE); 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) { diff --git a/cmd.cpp b/cmd.cpp index 0c06c65..46f8af3 100644 --- a/cmd.cpp +++ b/cmd.cpp @@ -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 (); + } +} + /* diff --git a/cmd.h b/cmd.h index c9a290d..3ad0f3d 100644 --- a/cmd.h +++ b/cmd.h @@ -165,19 +165,23 @@ uint8_t GetPreampGain ( bool* agc, uint8_t* reg ); void SetSweepStart ( uint32_t freq ); // Added in Version 2.3 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 ); -void SetIFsweepStart ( uint32_t freq ); // Added in Version 3.0c +void SetIFsweepStart ( uint32_t freq ); // Added in Version 3.0c uint32_t GetIFsweepStart ( void ); void SetBandscopeStart ( uint32_t freq ); // Added in Version 3.0f 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 ); -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 ); void SetIFsweepSigFreq ( uint32_t freq ); // Added in Version 3.0c diff --git a/simpleSA.h b/simpleSA.h index b120d9a..3edf04b 100644 --- a/simpleSA.h +++ b/simpleSA.h @@ -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: diff --git a/simpleSA.ino b/simpleSA.ino index 28ec176..3c2e49f 100644 --- a/simpleSA.ino +++ b/simpleSA.ino @@ -1064,21 +1064,22 @@ void init_sweep() old_settingSpur = -100; 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 rcvr.SetPreampGain ( setting.PreampGain ); #ifdef SI_TG_IF_CS 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 #ifdef SI_TG_LO_CS 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 diff --git a/ui.cpp b/ui.cpp index 9c97364..608389b 100644 --- a/ui.cpp +++ b/ui.cpp @@ -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,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 { 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, "\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,10 +2491,18 @@ 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; + } uint32_t x = uistat.value; @@ -2793,11 +2918,39 @@ 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; + + } // End of "switch" 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); touch_wait_release (); - - // test to see if the touch is in the marker area - if ( (touch_y < 10) && (touch_x < 160) ) - { - marker[0].Toggle(); // marker 1 - return; - } - else if ( (touch_y < 10) && (touch_x > 160) ) - { - marker[2].Toggle(); // marker 3 - return; - } - else if ( (touch_y < 20) && (touch_x < 160) ) - { - marker[1].Toggle(); // marker 2 - return; - } - else if ( (touch_y < 20) && (touch_x > 160) ) - { - marker[3].Toggle(); // marker 4 - return; - } - else if ( (touch_y < 40) && (touch_x > 30) ) - StartMarkerMenu(); - else if ( (touch_y > 210) && ( setting.Mode == SA_LOW_RANGE ) ) - StartSweepMenu(); - else if ( (touch_x < 30) && (touch_y < 60) && ( setting.Mode == SA_LOW_RANGE ) ) - StartRBWMenu(); - else if ( (touch_x < 30) && (touch_y > CHAR_HEIGHT * 20 ) && ( touch_y < CHAR_HEIGHT * 22 ) && ( setting.Mode == SA_LOW_RANGE ) ) - { - SetSpur (!setting.Spur); - return; - } - else if ( (touch_x < 30) && ( setting.Mode == SA_LOW_RANGE ) ) - StartDisplayMenu(); +/* + * 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) ) + { + marker[0].Toggle(); // marker 1 + return; + } + else if ( (touch_y < 10) && (touch_x > 160) ) + { + marker[2].Toggle(); // marker 3 + return; + } + else if ( (touch_y < 20) && (touch_x < 160) ) + { + marker[1].Toggle(); // marker 2 + return; + } + else if ( (touch_y < 20) && (touch_x > 160) ) + { + marker[3].Toggle(); // marker 4 + return; + } + else if ( (touch_y < 40) && (touch_x > 30) ) + StartMarkerMenu(); + else if ( touch_y > 210 ) + StartSweepMenu(); + else if ( (touch_x < 30) && (touch_y < 60) ) + StartRBWMenu(); + else if ( (touch_x < 30) && (touch_y > CHAR_HEIGHT * 20 ) && ( touch_y < CHAR_HEIGHT * 22 ) ) + { + SetSpur (!setting.Spur); + return; + } + else if ( (touch_x < 30) ) + StartDisplayMenu(); + } selection = -1; // Switch menu mode bg = BLACK; // black background