diff --git a/Bandscope.ino b/Bandscope.ino
index 5ee0bf5..7a23125 100644
--- a/Bandscope.ino
+++ b/Bandscope.ino
@@ -63,7 +63,7 @@ void initBandscope()
old_settingMin = -1;
old_startFreq = -1;
old_stopFreq = -1;
- old_ownrbw = -1;
+ old_requiredRBW10 = -1;
old_vbw = -1;
old_settingAverage = -1;
old_settingSpur = -100;
diff --git a/IFsweep.ino b/IFsweep.ino
index 0aecf39..263d51c 100644
--- a/IFsweep.ino
+++ b/IFsweep.ino
@@ -24,6 +24,15 @@ void initIF_Sweep()
tinySA_mode = IF_SWEEP;
setting.Mode = tinySA_mode;
+// Turn off track gen
+#ifdef SI_TG_IF_CS
+ tg_if.RxMode();
+#endif
+
+#ifdef SI_TG_LO_CS
+ tg_lo.RxMode();
+#endif
+
ResetIFsweepMenuStack(); // Put menu stack back to root level
}
@@ -75,19 +84,6 @@ static uint16_t chunkIndex;
autoSweepFreqStep = ( stopFreq_IF - startFreq_IF ) / displayPoints;
vbw = autoSweepFreqStep / 1000.0; // Set the video resolution
-// ownrbw = ((float) ( stopFreq_IF - startFreq_IF )) / displayPoints / 1000.0; // kHz
-//
-// if ( ownrbw < 2.6 ) // If it's less than 2.6KHz
-// ownrbw = 2.6; // set it to 2.6KHz
-//
-// if ( ownrbw > 620.7 )
-// ownrbw = 620.7;
-//
-// if ( ownrbw != old_ownrbw )
-// {
-// bandwidth = rcvr.SetRBW ( ownrbw * 10.0, &delaytime ); // Set it in the receiver Si4432
-// old_ownrbw = ownrbw;
-// }
bandwidth = rcvr.SetRBW ( 106.0, &delaytime ); // Set it in the receiver Si4432. delaytime is returned
diff --git a/RXsweep.ino b/RXsweep.ino
index 2857202..7fbd054 100644
--- a/RXsweep.ino
+++ b/RXsweep.ino
@@ -26,6 +26,16 @@ void initRX_Sweep()
tinySA_mode = RX_SWEEP;
setting.Mode = tinySA_mode;
+// Turn off track gen
+#ifdef SI_TG_IF_CS
+ tg_if.RxMode();
+#endif
+
+#ifdef SI_TG_LO_CS
+ tg_lo.RxMode();
+#endif
+
+
ResetRXsweepMenuStack(); // Put menu stack back to root level
}
@@ -104,7 +114,7 @@ static uint16_t chunkIndex;
wiFiPoints = displayPoints*OVERLAP;
// Serial.printf("No of wifiPoints set to %i\n", wiFiPoints);
- pushIFSweepSettings();
+ pushRXSweepSettings();
#endif // #ifdef USE_WIFI
@@ -136,7 +146,7 @@ static uint16_t chunkIndex;
jsonDocument.clear ();
chunkIndex = 0;
- jsonDocument["PreAmp"] = setting.PreampGain; // Fixed gain
+ jsonDocument["PreAmp"] = setting.PreampGain;
jsonDocument["mType"] = "chunkSweep";
jsonDocument["StartIndex"] = 0;
jsonDocument["sweepPoints"] = sweepPoints;
diff --git a/SweepLo.ino b/SweepLo.ino
index cc67e7e..7d6fe7b 100644
--- a/SweepLo.ino
+++ b/SweepLo.ino
@@ -95,21 +95,21 @@ static uint32_t offsetIF; // IF frequency offset by half the bandwidth to pos
autoSweepFreqStep = ( setting.ScanStop - setting.ScanStart ) / displayPoints;
vbw = autoSweepFreqStep / 1000.0; // Set the video resolution
- ownrbw = setting.Bandwidth10 / 10.0; // and the resolution bandwidth
+ requiredRBW10 = setting.Bandwidth10; // and the resolution bandwidth
- if ( ownrbw == 0.0 ) // If the bandwidth is on "Auto" work out the required RBW
- ownrbw = ((float) ( setting.ScanStop - setting.ScanStart )) / 290000.0; // 290 points on display
+ if ( requiredRBW10 == 0 ) // If the bandwidth is on "Auto" work out the required RBW
+ requiredRBW10 = (( setting.ScanStop - setting.ScanStart )) / 29000; // 290 points on display, kHz
- if ( ownrbw < 2.6 ) // If it's less than 2.6KHz
- ownrbw = 2.6; // set it to 2.6KHz
+ if ( requiredRBW10 < 26 ) // If it's less than 2.6KHz
+ requiredRBW10 = 26; // set it to 2.6KHz
- if ( ownrbw > 620.7 )
- ownrbw = 620.7;
+ if ( requiredRBW10 > 6207 )
+ requiredRBW10 = 6207;
- if ( ownrbw != old_ownrbw )
+ if ( requiredRBW10 != old_requiredRBW10 )
{
- bandwidth = rcvr.SetRBW ( ownrbw * 10.0, &delaytime ); // Set it in the receiver Si4432
- old_ownrbw = ownrbw;
+ bandwidth = rcvr.SetRBW ( requiredRBW10, &delaytime ); // Set it in the receiver Si4432
+ old_requiredRBW10 = requiredRBW10;
}
/*
@@ -190,7 +190,7 @@ static uint32_t offsetIF; // IF frequency offset by half the bandwidth to pos
* How well this works depends on how flat the SAW filter (and SI4432 filter) response is
*/
if (setting.Spur && spurToggle) {
- uint32_t IF_Shift = ownrbw * 1000; // bandwidth in Hz
+ uint32_t IF_Shift = requiredRBW10 * 100; // bandwidth in Hz
if (IF_Shift > MAX_IF_SHIFT)
IF_Shift = MAX_IF_SHIFT;
tempIF = offsetIF - IF_Shift;
diff --git a/cmd.cpp b/cmd.cpp
index 4f1a0f6..39d6632 100644
--- a/cmd.cpp
+++ b/cmd.cpp
@@ -182,6 +182,7 @@ extern uint8_t dBmToRSSI ( double dBm );
{ "WFGAIN", MSG_WFGAIN }, // Gain for waterfall colours
{ "RXSWEEP", MSG_RX_SWEEP }, // Set RX Sweep Mode
{ "RXSIGNAL", MSG_RXSIGNAL }, // IF sweep signal frequency
+ { "EXTGAIN", MSG_EXTGAIN }, // External gain or attenuation
{ "", MSG_NONE } // Unrecognized command
};
@@ -219,6 +220,9 @@ void ShowMenu ()
Serial.printf ( " ATTEN.........Set or get the attenuator setting; currently: %ddB\n",
setting.Attenuate );
+ Serial.printf ( " EXTGAIN.......Set or get the external gain setting; currently: %ddB\n",
+ setting.ExternalGain );
+
Serial.printf ( " SPUR......... Turn Spur Reduction 'ON' or 'OFF'; currently: %s\n",
setting.Spur ? "ON" : "OFF" );
@@ -1679,6 +1683,21 @@ uint8_t reg69; // Ditto
}
Serial.printf ( "RX Sweep Signal frequency: %s\n", FormatFrequency ( GetRXsweepSigFreq() ));
return true;
+
+/*
+ * Set external gain or attenuation
+ */
+ case MSG_EXTGAIN:
+ if ( dataLen != 0 ) // Value specified?
+ {
+ tempFloat = atof ( dataBuff ); // Yes
+ SetExtGain( tempFloat );
+ DisplayInfo (); // Re display the scan
+ }
+
+ Serial.printf ( "External gain: %4.1f\n", setting.ExternalGain );
+ return true;
+
default:
@@ -2113,6 +2132,7 @@ int oldG = setting.Generate;
/*
* "SetTracking" - sets the Tracking Generator Mode
+ * 0 = off, 1 = track, 2 = sig gen
*/
void SetTracking ( int8_t m )
@@ -2125,6 +2145,8 @@ int oldM = trackGenSetting.Mode;
{
changedSetting = true;
WriteTrackGenSettings ();
+ pushSettings ();
+// Serial.println("SetTracking - pushSettings");
}
}
@@ -2201,6 +2223,21 @@ int oldAtten = setting.Attenuate;
}
+/*
+ * Set the external gain value
+ * +ve for gain, -ve for attenuation
+ */
+void SetExtGain ( double a )
+{
+ setting.ExternalGain = a;
+}
+
+double GetExtGain (void )
+{
+ return setting.ExternalGain;
+}
+
+
/*
* "SetStorage" - Saves the results of a scan for comparison to an active one.
*/
@@ -2274,6 +2311,7 @@ int oldOffset = setting.LevelOffset;
changedSetting = true;
RedrawHisto (); // Redraw labels and restart sweep with new settings
WriteSettings ();
+ pushSettings();
}
}
@@ -2297,7 +2335,7 @@ int16_t tempBw;
setting.Bandwidth10 = bw;
- bandwidth = rcvr.SetRBW ( tempBw, &delaytime );
+// bandwidth = rcvr.SetRBW ( tempBw, &delaytime ); // Not needed as will be done at start of sweep
RedrawHisto (); // Redraw labels and restart sweep with new settings
if ( setting.Bandwidth10 != oldRBW )
@@ -2385,6 +2423,7 @@ int oldLevel = setting.Drive;
{
changedSetting = true;
WriteSettings ();
+ pushSettings ();
}
}
}
@@ -2525,11 +2564,34 @@ int oldLevel = trackGenSetting.IF_Drive;
{
changedSetting = true;
WriteTrackGenSettings ();
+ pushSettings ();
}
}
}
#endif
+
+void SetTGPower ( int16_t dBm )
+{
+ // Add algorithm to set attenuator and IF drive level
+ // initially limit to just set drive levels
+ // TG Output = IF output - mixer loss - attenuator pads
+ int16_t pathLoss = 10; //6.9 mixer + 3 pad;
+ int16_t maxOut = 20 - pathLoss;
+ int16_t minOut = 1 - pathLoss;
+
+ if (dBm > maxOut)
+ dBm = maxOut;
+ if (dBm < minOut)
+ dBm = minOut;
+
+ uint8_t level = ( dBm + pathLoss + 1 ) / 3;
+ Serial.printf("Set TG power - req dBm %i - level set to %i\n", dBm, level);
+
+ trackGenSetting.Power = dBm; // saved in SetTGIFDrive
+ SetTGIfDrive ( level );
+}
+
/*
* Set Tracking generator IF offset from main SA IF
* Ideally TG IF should be outside bandwidth of main RX
diff --git a/cmd.h b/cmd.h
index 1b90a97..5b47225 100644
--- a/cmd.h
+++ b/cmd.h
@@ -77,6 +77,7 @@
#define MSG_WFGAIN 48 // set the gain for waterfall colouring
#define MSG_RX_SWEEP 49 // Set the RX Sweep Mode
#define MSG_RXSIGNAL 50 // Set frequency of injected signal for IF Sweep
+#define MSG_EXTGAIN 51 // Set external gain or attenuation
#define MSG_COLOURTEST 99 // test of waterfall colours - remove this when done!
@@ -146,9 +147,13 @@ void SetTGLoDrive ( uint8_t level ); // set tracking generator drive
void SetTGIfDrive ( uint8_t level );
bool SetTGOffset ( int32_t offset); // set tracking generator offset - returns false if invalid
int32_t GetTGOffset (void );
+void SetTGPower ( int16_t dBm ); // Set TG attenuator and drive levels
void SetAttenuation ( int a ); // Sets the PE4302 attenuation
+void SetExtGain ( double a ); // Sets the external gain or attenuation
+double GetExtGain (void );
+
void SetStorage ( void ); // Saves the results of a scan
void SetClearStorage ( void ); // Logically erases the saved scan
void SetSubtractStorage(void); // Sets the "setting.SubtractStorage" flag
diff --git a/data/index.html b/data/index.html
index b408327..908d9d3 100644
--- a/data/index.html
+++ b/data/index.html
@@ -140,7 +140,16 @@
-