StartRationalise

Start to create some common functions
This commit is contained in:
M0WID 2020-09-14 21:49:22 +01:00
parent 19f102e3ec
commit 0015491a5e
7 changed files with 36 additions and 60 deletions

View File

@ -237,14 +237,8 @@ static uint16_t chunkIndex;
if ( numberOfWebsocketClients > 0 ) // Start off the json document for the scan
{
jsonDocument.clear ();
chunkIndex = 0;
jsonDocument["PreAmp"] = setting.PreampGain;
jsonDocument["mType"] = "chunkSweep";
jsonDocument["StartIndex"] = 0;
jsonDocument["sweepPoints"] = sweepPoints;
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
initChunkSweepDoc (autoSweepStep);
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
jsonDocInitialised = true;
}
@ -395,12 +389,8 @@ static uint16_t chunkIndex;
if ( ( chunkIndex >= wiFiPoints ) || !jsonDocInitialised ) // Start new jSon document
{
chunkIndex = 0;
jsonDocument.clear();
jsonDocument["mType"] = "chunkSweep";
jsonDocument["StartIndex"] = autoSweepStep;
jsonDocument["sweepPoints"] = sweepPoints;
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
Points = jsonDocument.createNestedArray ("Points" ); // Add Points array
initChunkSweepDoc (autoSweepStep);
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
jsonDocInitialised = true;
}
}

View File

@ -120,6 +120,7 @@ static uint16_t chunkIndex;
} // initSweep || changedSetting
autoSweepStep = 0; // Set the step counter to zero
sweepStep = 0;
autoSweepFreq = startFreq_IF; // Set the start frequency.
nextPointFreq = autoSweepFreq + autoSweepFreqStep;
@ -142,24 +143,16 @@ static uint16_t chunkIndex;
if ( numberOfWebsocketClients > 0 ) // Start off the json document for the scan
{
jsonDocument.clear ();
chunkIndex = 0;
jsonDocument["PreAmp"] = setting.PreampGain; // Fixed gain
jsonDocument["mType"] = "chunkSweep";
jsonDocument["StartIndex"] = 0;
jsonDocument["sweepPoints"] = sweepPoints;
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
initChunkSweepDoc (sweepStep);
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
jsonDocInitialised = true;
}
else
jsonDocInitialised = false;
#endif // #ifdef USE_WIFI
sweepStep = 0;
startFreq = startFreq_IF + sigFreq_IF; // Start 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
{
chunkIndex = 0;
jsonDocument.clear();
jsonDocument["mType"] = "chunkSweep";
jsonDocument["StartIndex"] = sweepStep;
jsonDocument["sweepPoints"] = sweepPoints;
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
Points = jsonDocument.createNestedArray ("Points" ); // Add Points array
initChunkSweepDoc (sweepStep);
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
jsonDocInitialised = true;
}
}

View File

@ -126,6 +126,7 @@ static uint16_t chunkIndex;
} // initSweep || changedSetting
autoSweepStep = 0; // Set the step counter to zero
sweepStep = 0;
autoSweepFreq = startFreq_RX; // Set the start frequency.
nextPointFreq = autoSweepFreq + autoSweepFreqStep;
@ -148,24 +149,16 @@ static uint16_t chunkIndex;
if ( numberOfWebsocketClients > 0 ) // Start off the json document for the scan
{
jsonDocument.clear ();
chunkIndex = 0;
jsonDocument["PreAmp"] = setting.PreampGain;
jsonDocument["mType"] = "chunkSweep";
jsonDocument["StartIndex"] = 0;
jsonDocument["sweepPoints"] = sweepPoints;
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
initChunkSweepDoc (sweepStep);
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
jsonDocInitialised = true;
}
else
jsonDocInitialised = false;
#endif // #ifdef USE_WIFI
sweepStep = 0;
startFreq = startFreq_RX; // Start 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
{
chunkIndex = 0;
jsonDocument.clear();
jsonDocument["mType"] = "chunkSweep";
jsonDocument["StartIndex"] = sweepStep;
jsonDocument["sweepPoints"] = sweepPoints;
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
Points = jsonDocument.createNestedArray ("Points" ); // Add Points array
initChunkSweepDoc (sweepStep);
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
jsonDocInitialised = true;
}
}

View File

@ -185,6 +185,7 @@ static uint32_t offsetIF; // IF frequency offset by half the bandwidth to pos
} // initSweep || changedSetting
autoSweepStep = 0; // Set the step counter to zero
sweepStep = 0;
autoSweepFreq = setting.ScanStart; // Set the start frequency.
nextPointFreq = autoSweepFreq + autoSweepFreqStep;
@ -253,22 +254,15 @@ static uint32_t offsetIF; // IF frequency offset by half the bandwidth to pos
{
jsonDocument.clear ();
chunkIndex = 0;
jsonDocument["PreAmp"] = setting.PreampGain; // Fixed gain
jsonDocument["mType"] = "chunkSweep";
jsonDocument["StartIndex"] = 0;
jsonDocument["sweepPoints"] = sweepPoints;
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
initChunkSweepDoc (sweepStep);
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
jsonDocInitialised = true;
}
else
jsonDocInitialised = false;
#endif // #ifdef USE_WIFI
sweepStep = 0;
startFreq = setting.ScanStart + tempIF; // Start 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
{
chunkIndex = 0;
jsonDocument.clear();
jsonDocument["mType"] = "chunkSweep";
jsonDocument["StartIndex"] = sweepStep;
jsonDocument["sweepPoints"] = sweepPoints;
jsonDocument["sweepTime"] = (uint32_t)(sweepMicros/1000);
Points = jsonDocument.createNestedArray ("Points" ); // Add Points array
initChunkSweepDoc (sweepStep);
Points = jsonDocument.createNestedArray ( "Points" ); // Add Points array
jsonDocInitialised = true;
}
}

View File

@ -352,10 +352,10 @@ uint16_t websocketFailCount;
#ifdef USE_WIFI
// Json document buffers
size_t capacity = JSON_ARRAY_SIZE ( MAX_WIFI_POINTS + 1 )
+ ( MAX_WIFI_POINTS + 1 ) * JSON_OBJECT_SIZE ( 2 ) + JSON_OBJECT_SIZE( 5 );
//size_t capacity = JSON_ARRAY_SIZE ( MAX_WIFI_POINTS + 1 )
// + ( 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
#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.

View File

@ -33,6 +33,8 @@ extern uint16_t displayPoints;
extern uint16_t xDelta;
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 updateSidebar; // Flag to indicate no of clients has changed

View File

@ -51,6 +51,7 @@
void pushIFSweepSettings ();
void pushRXSweepSettings ();
void pushBandscopeSettings ();
void initChunkSweepDoc (uint32_t startIndex);
/*
* Functions outside of "TinySA_wifi: