StartRationalise
Start to create some common functions
This commit is contained in:
parent
19f102e3ec
commit
0015491a5e
@ -237,14 +237,8 @@ static uint16_t chunkIndex;
|
|||||||
|
|
||||||
if ( numberOfWebsocketClients > 0 ) // Start off the json document for the scan
|
if ( numberOfWebsocketClients > 0 ) // Start off the json document for the scan
|
||||||
{
|
{
|
||||||
jsonDocument.clear ();
|
|
||||||
chunkIndex = 0;
|
chunkIndex = 0;
|
||||||
|
initChunkSweepDoc (autoSweepStep);
|
||||||
jsonDocument["PreAmp"] = setting.PreampGain;
|
|
||||||
jsonDocument["mType"] = "chunkSweep";
|
|
||||||
jsonDocument["StartIndex"] = 0;
|
|
||||||
jsonDocument["sweepPoints"] = sweepPoints;
|
|
||||||
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
|
|
||||||
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
|
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
|
||||||
jsonDocInitialised = true;
|
jsonDocInitialised = true;
|
||||||
}
|
}
|
||||||
@ -395,12 +389,8 @@ static uint16_t chunkIndex;
|
|||||||
if ( ( chunkIndex >= wiFiPoints ) || !jsonDocInitialised ) // Start new jSon document
|
if ( ( chunkIndex >= wiFiPoints ) || !jsonDocInitialised ) // Start new jSon document
|
||||||
{
|
{
|
||||||
chunkIndex = 0;
|
chunkIndex = 0;
|
||||||
jsonDocument.clear();
|
initChunkSweepDoc (autoSweepStep);
|
||||||
jsonDocument["mType"] = "chunkSweep";
|
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
|
||||||
jsonDocument["StartIndex"] = autoSweepStep;
|
|
||||||
jsonDocument["sweepPoints"] = sweepPoints;
|
|
||||||
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
|
|
||||||
Points = jsonDocument.createNestedArray ("Points" ); // Add Points array
|
|
||||||
jsonDocInitialised = true;
|
jsonDocInitialised = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
IFsweep.ino
19
IFsweep.ino
@ -120,6 +120,7 @@ static uint16_t chunkIndex;
|
|||||||
} // initSweep || changedSetting
|
} // initSweep || changedSetting
|
||||||
|
|
||||||
autoSweepStep = 0; // Set the step counter to zero
|
autoSweepStep = 0; // Set the step counter to zero
|
||||||
|
sweepStep = 0;
|
||||||
autoSweepFreq = startFreq_IF; // Set the start frequency.
|
autoSweepFreq = startFreq_IF; // Set the start frequency.
|
||||||
|
|
||||||
nextPointFreq = autoSweepFreq + autoSweepFreqStep;
|
nextPointFreq = autoSweepFreq + autoSweepFreqStep;
|
||||||
@ -142,24 +143,16 @@ static uint16_t chunkIndex;
|
|||||||
|
|
||||||
if ( numberOfWebsocketClients > 0 ) // Start off the json document for the scan
|
if ( numberOfWebsocketClients > 0 ) // Start off the json document for the scan
|
||||||
{
|
{
|
||||||
jsonDocument.clear ();
|
|
||||||
chunkIndex = 0;
|
chunkIndex = 0;
|
||||||
|
initChunkSweepDoc (sweepStep);
|
||||||
jsonDocument["PreAmp"] = setting.PreampGain; // Fixed gain
|
|
||||||
jsonDocument["mType"] = "chunkSweep";
|
|
||||||
jsonDocument["StartIndex"] = 0;
|
|
||||||
jsonDocument["sweepPoints"] = sweepPoints;
|
|
||||||
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
|
|
||||||
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
|
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
|
||||||
jsonDocInitialised = true;
|
jsonDocInitialised = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
jsonDocInitialised = false;
|
jsonDocInitialised = false;
|
||||||
|
|
||||||
#endif // #ifdef USE_WIFI
|
#endif // #ifdef USE_WIFI
|
||||||
|
|
||||||
sweepStep = 0;
|
|
||||||
startFreq = startFreq_IF + sigFreq_IF; // Start freq for the LO
|
startFreq = startFreq_IF + sigFreq_IF; // Start freq for the LO
|
||||||
stopFreq = stopFreq_IF + sigFreq_IF; // Stop freq for the LO
|
stopFreq = stopFreq_IF + sigFreq_IF; // Stop freq for the LO
|
||||||
|
|
||||||
@ -315,12 +308,8 @@ static uint16_t chunkIndex;
|
|||||||
if ( ( chunkIndex >= wiFiPoints ) || !jsonDocInitialised ) // Start new jSon document
|
if ( ( chunkIndex >= wiFiPoints ) || !jsonDocInitialised ) // Start new jSon document
|
||||||
{
|
{
|
||||||
chunkIndex = 0;
|
chunkIndex = 0;
|
||||||
jsonDocument.clear();
|
initChunkSweepDoc (sweepStep);
|
||||||
jsonDocument["mType"] = "chunkSweep";
|
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
|
||||||
jsonDocument["StartIndex"] = sweepStep;
|
|
||||||
jsonDocument["sweepPoints"] = sweepPoints;
|
|
||||||
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
|
|
||||||
Points = jsonDocument.createNestedArray ("Points" ); // Add Points array
|
|
||||||
jsonDocInitialised = true;
|
jsonDocInitialised = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
RXsweep.ino
19
RXsweep.ino
@ -126,6 +126,7 @@ static uint16_t chunkIndex;
|
|||||||
} // initSweep || changedSetting
|
} // initSweep || changedSetting
|
||||||
|
|
||||||
autoSweepStep = 0; // Set the step counter to zero
|
autoSweepStep = 0; // Set the step counter to zero
|
||||||
|
sweepStep = 0;
|
||||||
autoSweepFreq = startFreq_RX; // Set the start frequency.
|
autoSweepFreq = startFreq_RX; // Set the start frequency.
|
||||||
|
|
||||||
nextPointFreq = autoSweepFreq + autoSweepFreqStep;
|
nextPointFreq = autoSweepFreq + autoSweepFreqStep;
|
||||||
@ -148,24 +149,16 @@ static uint16_t chunkIndex;
|
|||||||
|
|
||||||
if ( numberOfWebsocketClients > 0 ) // Start off the json document for the scan
|
if ( numberOfWebsocketClients > 0 ) // Start off the json document for the scan
|
||||||
{
|
{
|
||||||
jsonDocument.clear ();
|
|
||||||
chunkIndex = 0;
|
chunkIndex = 0;
|
||||||
|
initChunkSweepDoc (sweepStep);
|
||||||
jsonDocument["PreAmp"] = setting.PreampGain;
|
|
||||||
jsonDocument["mType"] = "chunkSweep";
|
|
||||||
jsonDocument["StartIndex"] = 0;
|
|
||||||
jsonDocument["sweepPoints"] = sweepPoints;
|
|
||||||
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
|
|
||||||
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
|
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
|
||||||
jsonDocInitialised = true;
|
jsonDocInitialised = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
jsonDocInitialised = false;
|
jsonDocInitialised = false;
|
||||||
|
|
||||||
#endif // #ifdef USE_WIFI
|
#endif // #ifdef USE_WIFI
|
||||||
|
|
||||||
sweepStep = 0;
|
|
||||||
startFreq = startFreq_RX; // Start freq for the RX
|
startFreq = startFreq_RX; // Start freq for the RX
|
||||||
stopFreq = stopFreq_RX; // Stop freq for the RX
|
stopFreq = stopFreq_RX; // Stop freq for the RX
|
||||||
|
|
||||||
@ -322,12 +315,8 @@ static uint16_t chunkIndex;
|
|||||||
if ( ( chunkIndex >= wiFiPoints ) || !jsonDocInitialised ) // Start new jSon document
|
if ( ( chunkIndex >= wiFiPoints ) || !jsonDocInitialised ) // Start new jSon document
|
||||||
{
|
{
|
||||||
chunkIndex = 0;
|
chunkIndex = 0;
|
||||||
jsonDocument.clear();
|
initChunkSweepDoc (sweepStep);
|
||||||
jsonDocument["mType"] = "chunkSweep";
|
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
|
||||||
jsonDocument["StartIndex"] = sweepStep;
|
|
||||||
jsonDocument["sweepPoints"] = sweepPoints;
|
|
||||||
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
|
|
||||||
Points = jsonDocument.createNestedArray ("Points" ); // Add Points array
|
|
||||||
jsonDocInitialised = true;
|
jsonDocInitialised = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
SweepLo.ino
18
SweepLo.ino
@ -185,6 +185,7 @@ static uint32_t offsetIF; // IF frequency offset by half the bandwidth to pos
|
|||||||
} // initSweep || changedSetting
|
} // initSweep || changedSetting
|
||||||
|
|
||||||
autoSweepStep = 0; // Set the step counter to zero
|
autoSweepStep = 0; // Set the step counter to zero
|
||||||
|
sweepStep = 0;
|
||||||
autoSweepFreq = setting.ScanStart; // Set the start frequency.
|
autoSweepFreq = setting.ScanStart; // Set the start frequency.
|
||||||
|
|
||||||
nextPointFreq = autoSweepFreq + autoSweepFreqStep;
|
nextPointFreq = autoSweepFreq + autoSweepFreqStep;
|
||||||
@ -253,22 +254,15 @@ static uint32_t offsetIF; // IF frequency offset by half the bandwidth to pos
|
|||||||
{
|
{
|
||||||
jsonDocument.clear ();
|
jsonDocument.clear ();
|
||||||
chunkIndex = 0;
|
chunkIndex = 0;
|
||||||
|
initChunkSweepDoc (sweepStep);
|
||||||
jsonDocument["PreAmp"] = setting.PreampGain; // Fixed gain
|
|
||||||
jsonDocument["mType"] = "chunkSweep";
|
|
||||||
jsonDocument["StartIndex"] = 0;
|
|
||||||
jsonDocument["sweepPoints"] = sweepPoints;
|
|
||||||
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
|
|
||||||
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
|
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
|
||||||
jsonDocInitialised = true;
|
jsonDocInitialised = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
jsonDocInitialised = false;
|
jsonDocInitialised = false;
|
||||||
|
|
||||||
#endif // #ifdef USE_WIFI
|
#endif // #ifdef USE_WIFI
|
||||||
|
|
||||||
sweepStep = 0;
|
|
||||||
startFreq = setting.ScanStart + tempIF; // Start freq for the LO
|
startFreq = setting.ScanStart + tempIF; // Start freq for the LO
|
||||||
stopFreq = setting.ScanStop + tempIF; // Stop freq for the LO
|
stopFreq = setting.ScanStop + tempIF; // Stop freq for the LO
|
||||||
|
|
||||||
@ -454,12 +448,8 @@ static uint32_t offsetIF; // IF frequency offset by half the bandwidth to pos
|
|||||||
if ( ( chunkIndex >= wiFiPoints ) || !jsonDocInitialised ) // Start new jSon document
|
if ( ( chunkIndex >= wiFiPoints ) || !jsonDocInitialised ) // Start new jSon document
|
||||||
{
|
{
|
||||||
chunkIndex = 0;
|
chunkIndex = 0;
|
||||||
jsonDocument.clear();
|
initChunkSweepDoc (sweepStep);
|
||||||
jsonDocument["mType"] = "chunkSweep";
|
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
|
||||||
jsonDocument["StartIndex"] = sweepStep;
|
|
||||||
jsonDocument["sweepPoints"] = sweepPoints;
|
|
||||||
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
|
|
||||||
Points = jsonDocument.createNestedArray ("Points" ); // Add Points array
|
|
||||||
jsonDocInitialised = true;
|
jsonDocInitialised = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
21
simpleSA.ino
21
simpleSA.ino
@ -352,10 +352,10 @@ uint16_t websocketFailCount;
|
|||||||
|
|
||||||
#ifdef USE_WIFI
|
#ifdef USE_WIFI
|
||||||
// Json document buffers
|
// Json document buffers
|
||||||
size_t capacity = JSON_ARRAY_SIZE ( MAX_WIFI_POINTS + 1 )
|
//size_t capacity = JSON_ARRAY_SIZE ( MAX_WIFI_POINTS + 1 )
|
||||||
+ ( MAX_WIFI_POINTS + 1 ) * JSON_OBJECT_SIZE ( 2 ) + JSON_OBJECT_SIZE( 5 );
|
// + ( MAX_WIFI_POINTS + 1 ) * JSON_OBJECT_SIZE ( 2 ) + JSON_OBJECT_SIZE( 5 );
|
||||||
|
|
||||||
static DynamicJsonDocument jsonDocument ( capacity ); // Buffer for json data to be pushed to the web clients
|
static DynamicJsonDocument jsonDocument ( 4000 ); // Buffer for json data to be pushed to the web clients
|
||||||
static JsonArray Points = jsonDocument.createNestedArray ( "Points" ); // add Points array
|
static JsonArray Points = jsonDocument.createNestedArray ( "Points" ); // add Points array
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1114,6 +1114,21 @@ void init_sweep()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialise the JSON document that is used to push the sweep data to the web clients
|
||||||
|
* Used in all the sweep modes
|
||||||
|
*/
|
||||||
|
void initChunkSweepDoc (uint32_t startIndex)
|
||||||
|
{
|
||||||
|
jsonDocument.clear ();
|
||||||
|
jsonDocument["PreAmp"] = setting.PreampGain; // Fixed gain
|
||||||
|
jsonDocument["mType"] = "chunkSweep";
|
||||||
|
jsonDocument["StartIndex"] = startIndex;
|
||||||
|
jsonDocument["sweepPoints"] = sweepPoints;
|
||||||
|
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialise high frequency mode sweep.
|
* Initialise high frequency mode sweep.
|
||||||
|
@ -33,6 +33,8 @@ extern uint16_t displayPoints;
|
|||||||
extern uint16_t xDelta;
|
extern uint16_t xDelta;
|
||||||
extern uint16_t waterfallHeight;
|
extern uint16_t waterfallHeight;
|
||||||
|
|
||||||
|
extern unsigned long sweepMicros; // To report the scan time
|
||||||
|
|
||||||
|
|
||||||
extern int bpfCount; // Number of elements in the bandpassFilters array
|
extern int bpfCount; // Number of elements in the bandpassFilters array
|
||||||
extern int updateSidebar; // Flag to indicate no of clients has changed
|
extern int updateSidebar; // Flag to indicate no of clients has changed
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
void pushIFSweepSettings ();
|
void pushIFSweepSettings ();
|
||||||
void pushRXSweepSettings ();
|
void pushRXSweepSettings ();
|
||||||
void pushBandscopeSettings ();
|
void pushBandscopeSettings ();
|
||||||
|
void initChunkSweepDoc (uint32_t startIndex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Functions outside of "TinySA_wifi:
|
* Functions outside of "TinySA_wifi:
|
||||||
|
Loading…
Reference in New Issue
Block a user