First commit

Needs web page for Sig gen mode and mechanism to load new page on certain modes
This commit is contained in:
M0WID 2020-09-07 23:31:06 +01:00
parent 4aa452c2f2
commit ab03435f55
8 changed files with 119 additions and 30 deletions

View File

@ -55,7 +55,20 @@
<div class = "Grid-cell-side" id="postSweepSettings" > <div class = "Grid-cell-side" id="postSweepSettings" >
<!--<form style="width: 90vw; margin-left: 80px" action="doSetSweep" method="get"> --> <!--<form style="width: 90vw; margin-left: 80px" action="doSetSweep" method="get"> -->
<h1>Sweep</h1> <div class="setting" >
<select class="Sweep-select" id="setMode" name="setMode">
<option class="sweep-option" value="0">Sweep Low</option>
<!-- <option class="sweep-option" value="1">Sweep High</option> -->
<option class="sweep-option" value="2">Sig Gen</option>
<!-- <option class="sweep-option" value="3">Sig Gen High</option> -->
<option class="sweep-option" value="4">SAW Test</option>
<option class="sweep-option" value="5">Zero Span</option>
<!-- <option class="sweep-option" value="6">Zero Span High</option> -->
<option class="sweep-option" value="7">Bandscope</option>
<option class="sweep-option" value="8">RBW Test</option>
</select>
<img src="refresh.png" id="refresh" name = "refresh" height = "18">
</div>
<div class="setting" > <div class="setting" >
<label for="setStart" class="setting-label">Start:</label> <label for="setStart" class="setting-label">Start:</label>
<input class="value-input" name='setStart' type="number" id="setStart" maxlength="9" min="0" max="350" required> <input class="value-input" name='setStart' type="number" id="setStart" maxlength="9" min="0" max="350" required>
@ -114,6 +127,7 @@
<div class="setting" > <div class="setting" >
<label for="setAtten" class="setting-label">Atten:</label> <label for="setAtten" class="setting-label">Atten:</label>
<input class="value-input" name='setAtten' type="number" step="1" id ="setAtten" maxlength="3" min="0" max="31" required> <input class="value-input" name='setAtten' type="number" step="1" id ="setAtten" maxlength="3" min="0" max="31" required>
dB
<label for="setExtern" class="setting-label">External:</label> <label for="setExtern" class="setting-label">External:</label>
<input class="value-input" name='setExtern' type="number" step="1" id ="setExtern" maxlength="3" min="-60" max="60" required> <input class="value-input" name='setExtern' type="number" step="1" id ="setExtern" maxlength="3" min="-60" max="60" required>
<!--<select class="select-input" id="setAtten" name="setAtten"></select> --> <!--<select class="select-input" id="setAtten" name="setAtten"></select> -->
@ -270,6 +284,8 @@
<script type="text/javascript"> <script type="text/javascript">
var refreshInterval = document.getElementById('refreshInterval'); var refreshInterval = document.getElementById('refreshInterval');
var refresh = document.getElementById('refresh');
var setMode = document.getElementById('setMode');
var sweepStart = document.getElementById('sweepStart'); var sweepStart = document.getElementById('sweepStart');
var sweepStop = document.getElementById('sweepStop'); var sweepStop = document.getElementById('sweepStop');
var setStart = document.getElementById('setStart'); var setStart = document.getElementById('setStart');
@ -526,9 +542,16 @@ renderChart();
// Add handlers for the change events in the input fields // Add handlers for the change events in the input fields
refresh.addEventListener('click', (event) => {
sendValue("r", 0);
});
setMode.addEventListener('change', (event) => {
sendValue("m", setMode.value);
});
setStart.addEventListener('change', (event) => { setStart.addEventListener('change', (event) => {
sendValue("a", setStart.value); sendValue("a", setStart.value);
}); });
setStop.addEventListener('change', (event) => { setStop.addEventListener('change', (event) => {
@ -703,6 +726,8 @@ var indexUpdateMilliSeconds = 1 * 1000;
function handleSettings (settings) function handleSettings (settings)
{ {
setMode.value = settings.mode;
actRBW.value = settings.bandwidth; actRBW.value = settings.bandwidth;
@ -1095,17 +1120,19 @@ function connect(host)
connection.send('Hello from Browser :-) ' + new Date()); connection.send('Hello from Browser :-) ' + new Date());
sendMessage(); sendMessage();
sendPingVar = setInterval(function(){ sendPing() }, 30000); sendPingVar = setInterval(function(){ sendPing() }, 30000);
sendValue("r",0); // request settings
// Get the settings to make sure current // Get the settings to make sure current
$.getJSON( "getSettings") //$.getJSON( "getSettings")
.done(function (settings) { // .done(function (settings) {
handleSettings(settings); // handleSettings(settings);
}) // })
//
.fail(function(jqxhr, textStatus, error) { // .fail(function(jqxhr, textStatus, error) {
var err = textStatus +", " + error; // var err = textStatus +", " + error;
console.log("Settings Request Failed: " + err); // console.log("Settings Request Failed: " + err);
}); // });
var items = document.querySelectorAll(".value-input"); var items = document.querySelectorAll(".value-input");
var i; var i;
@ -1176,7 +1203,7 @@ function connect(host)
} }
else if (myObject.mType == "chunkSweep") else if (myObject.mType == "chunkSweep")
{ {
console.log("handle chunk Sweep:" + myObject.StartIndex); //console.log("handle chunk Sweep:" + myObject.StartIndex);
handleChunkData(myObject); handleChunkData(myObject);
} }
else else
@ -1210,9 +1237,11 @@ function sendValue(c, val)
// s Span // s Span
// d Local Oscillator Drive // d Local Oscillator Drive
// g PreAmpGain/Mode // g PreAmpGain/Mode
// p set actual power to peak value
// i IF frequency // i IF frequency
// m mode
// p set actual power to peak value
// o RefOut // o RefOut
// r request Settings are pushed
// A internal attenuation (PE4302) // A internal attenuation (PE4302)
// E external gain ( eg attenuator(-ve) or preamp(+ve) ) // E external gain ( eg attenuator(-ve) or preamp(+ve) )
// R requested RBW // R requested RBW

View File

@ -627,7 +627,7 @@ store1.addEventListener('change', (event) => {
}); });
store2.addEventListener('change', (event) => { store2.addEventListener('change', (event) => {
if (store1.checked) { if (store2.checked) {
var b = parseInt(levelOffset.value) + parseInt(setAtten.value) - 120; var b = parseInt(levelOffset.value) + parseInt(setAtten.value) - 120;
chartSA.options.data[6].dataPoints = chartSA.options.data[1].dataPoints.map(obj => { chartSA.options.data[6].dataPoints = chartSA.options.data[1].dataPoints.map(obj => {
let rObj = {} let rObj = {}
@ -641,7 +641,7 @@ store2.addEventListener('change', (event) => {
}); });
store3.addEventListener('change', (event) => { store3.addEventListener('change', (event) => {
if (store1.checked) { if (store3.checked) {
var b = parseInt(levelOffset.value) + parseInt(setAtten.value) - 120; var b = parseInt(levelOffset.value) + parseInt(setAtten.value) - 120;
chartSA.options.data[7].dataPoints = chartSA.options.data[1].dataPoints.map(obj => { chartSA.options.data[7].dataPoints = chartSA.options.data[1].dataPoints.map(obj => {
let rObj = {} let rObj = {}
@ -655,7 +655,7 @@ store3.addEventListener('change', (event) => {
}); });
store4.addEventListener('change', (event) => { store4.addEventListener('change', (event) => {
if (store1.checked) { if (store4.checked) {
var b = parseInt(levelOffset.value) + parseInt(setAtten.value) - 120; var b = parseInt(levelOffset.value) + parseInt(setAtten.value) - 120;
chartSA.options.data[8].dataPoints = chartSA.options.data[1].dataPoints.map(obj => { chartSA.options.data[8].dataPoints = chartSA.options.data[1].dataPoints.map(obj => {
let rObj = {} let rObj = {}

BIN
data/refresh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

View File

@ -159,11 +159,27 @@ input[type="number"] {
width: 75px; width: 75px;
display: inline-block; display: inline-block;
} }
.Sweep-select {
border: solid 1px grey;
text-align: left;
text-align-last: left;
width: 150px;
display: inline-block;
color: black;
font-weight: bolder;
background-repeat: no-repeat;
margin: 10px;
}
.select-option { .select-option {
text-align: right; text-align: right;
text-align-last: right; text-align-last: right;
} }
.sweep-option {
text-align: left;
text-align-last: left;
}
.set-button { .set-button {
font-size: 14px; font-size: 14px;

View File

@ -186,7 +186,7 @@
*/ */
enum { SA_LOW_RANGE, SA_HIGH_RANGE, SIG_GEN_LOW_RANGE, SIG_GEN_HIGH_RANGE, enum { SA_LOW_RANGE, SA_HIGH_RANGE, SIG_GEN_LOW_RANGE, SIG_GEN_HIGH_RANGE,
IF_SWEEP, ZERO_SPAN_LOW_RANGE, ZERO_SPAN_HIGH_RANGE, TRACKING_GENERATOR, BANDSCOPE, RX_SWEEP }; IF_SWEEP, ZERO_SPAN_LOW_RANGE, ZERO_SPAN_HIGH_RANGE, BANDSCOPE, RX_SWEEP };
/* /*

View File

@ -380,7 +380,7 @@ int16_t minGrid;
* Some varibales for the various operating modes * Some varibales for the various operating modes
*/ */
uint16_t tinySA_mode = SA_LOW_RANGE; // Low frequency range uint16_t tinySA_mode = SA_LOW_RANGE; // Low frequency range
const char *modeText[] = { "SALo", "SAHi", "SGLo", "SGHi", "IFSw", "0SpL", "0SpH", "TrGn", "BScp", "RXSw" }; // For mode display const char *modeText[] = { "SALo", "SAHi", "SGLo", "SGHi", "IFSw", "0SpL", "0SpH", "BScp", "RXSw" }; // For mode display
float bandwidth; // The current bandwidth (not * 10) float bandwidth; // The current bandwidth (not * 10)

View File

@ -39,6 +39,7 @@ extern int updateSidebar; // Flag to indicate no of clients has changed
extern void ClearDisplay (); extern void ClearDisplay ();
extern void DisplayError ( uint8_t severity, const char *l1, const char *l2, const char *l3, const char *l4 ); extern void DisplayError ( uint8_t severity, const char *l1, const char *l2, const char *l3, const char *l4 );
extern void setMode (uint16_t newMode);
/* /*
* In Version 1.8, the transmitter and receiver Si4432 modules are implemented as * In Version 1.8, the transmitter and receiver Si4432 modules are implemented as
@ -257,6 +258,10 @@ void webSocketEvent ( uint8_t num, WStype_t type, uint8_t* payload, size_t paylo
SetIFFrequency ( (int32_t) ( value * 1000000.0 )); SetIFFrequency ( (int32_t) ( value * 1000000.0 ));
break; break;
case 'm': // Set mode
setMode ( (int16_t) ( value ));
break;
case 'o': // Ref Output (LO GPIO2) case 'o': // Ref Output (LO GPIO2)
SetRefOutput ( (int) value ); SetRefOutput ( (int) value );
break; break;
@ -265,6 +270,31 @@ void webSocketEvent ( uint8_t num, WStype_t type, uint8_t* payload, size_t paylo
RequestSetPowerLevel( value ); RequestSetPowerLevel( value );
break; break;
case 'r': // request of settings by client
switch (setting.Mode)
{
case (SA_LOW_RANGE):
pushSettings();
break;
case (IF_SWEEP):
pushIFSweepSettings();
break;
case (RX_SWEEP):
pushRXSweepSettings();
break;
case (BANDSCOPE):
pushBandscopeSettings();
break;
default:
Serial.println("Invalid mode in Request setting handler - simpleSA_wifi.cpp");
}
break;
case 's': // Adjust sweep span case 's': // Adjust sweep span
SetSweepSpan ( (int32_t) ( value * 1000000.0 )); SetSweepSpan ( (int32_t) ( value * 1000000.0 ));
break; break;
@ -508,6 +538,7 @@ void onGetSettings (AsyncWebServerRequest *request)
JsonObject root = response->getRoot(); JsonObject root = response->getRoot();
root["mType"] = "Settings"; root["mType"] = "Settings";
root["mode"] = setting.Mode;
root["dispPoints"] = displayPoints; root["dispPoints"] = displayPoints;
root["start"] = setting.ScanStart / 1000.0; root["start"] = setting.ScanStart / 1000.0;
root["stop"] = setting.ScanStop / 1000.0; root["stop"] = setting.ScanStop / 1000.0;
@ -546,10 +577,11 @@ if ( numberOfWebsocketClients == 0 )
return; return;
size_t capacity = JSON_ARRAY_SIZE ( SCREEN_WIDTH ) size_t capacity = JSON_ARRAY_SIZE ( SCREEN_WIDTH )
+ SCREEN_WIDTH*JSON_OBJECT_SIZE ( 2 ) + JSON_OBJECT_SIZE ( 16 ); + SCREEN_WIDTH*JSON_OBJECT_SIZE ( 2 ) + JSON_OBJECT_SIZE ( 17 );
static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to be pushed to the web clients static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to be pushed to the web clients
jsonDocument["mType"] = "Settings"; jsonDocument["mType"] = "Settings";
jsonDocument["mode"] = setting.Mode;
jsonDocument["dispPoints"] = displayPoints; jsonDocument["dispPoints"] = displayPoints;
jsonDocument["start"] = setting.ScanStart / 1000.0; jsonDocument["start"] = setting.ScanStart / 1000.0;
jsonDocument["stop"] = setting.ScanStop / 1000.0; jsonDocument["stop"] = setting.ScanStop / 1000.0;
@ -593,10 +625,11 @@ static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to
void pushIFSweepSettings () void pushIFSweepSettings ()
{ {
size_t capacity = JSON_ARRAY_SIZE ( SCREEN_WIDTH ) size_t capacity = JSON_ARRAY_SIZE ( SCREEN_WIDTH )
+ SCREEN_WIDTH*JSON_OBJECT_SIZE ( 2 ) + JSON_OBJECT_SIZE ( 13 ); + SCREEN_WIDTH*JSON_OBJECT_SIZE ( 2 ) + JSON_OBJECT_SIZE ( 17 );
static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to be pushed to the web clients static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to be pushed to the web clients
jsonDocument["mType"] = "Settings"; jsonDocument["mType"] = "Settings";
jsonDocument["mode"] = setting.Mode;
jsonDocument["dispPoints"] = displayPoints; jsonDocument["dispPoints"] = displayPoints;
jsonDocument["start"] = startFreq_IF / 1000.0; jsonDocument["start"] = startFreq_IF / 1000.0;
jsonDocument["stop"] = stopFreq_IF / 1000.0; jsonDocument["stop"] = stopFreq_IF / 1000.0;
@ -610,6 +643,8 @@ static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to
jsonDocument["Drive"] = setting.Drive; jsonDocument["Drive"] = setting.Drive;
jsonDocument["sweepPoints"] = sweepPoints; jsonDocument["sweepPoints"] = sweepPoints;
jsonDocument["spur"] = setting.Spur; jsonDocument["spur"] = setting.Spur;
jsonDocument["tg"] = trackGenSetting.Mode;
jsonDocument["tgPower"] = trackGenSetting.Power;
if ( AGC_On ) if ( AGC_On )
jsonDocument["PreAmp"] = 0x60; // Auto jsonDocument["PreAmp"] = 0x60; // Auto
@ -638,10 +673,11 @@ static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to
void pushRXSweepSettings () void pushRXSweepSettings ()
{ {
size_t capacity = JSON_ARRAY_SIZE ( SCREEN_WIDTH ) size_t capacity = JSON_ARRAY_SIZE ( SCREEN_WIDTH )
+ SCREEN_WIDTH*JSON_OBJECT_SIZE ( 2 ) + JSON_OBJECT_SIZE ( 13 ); + SCREEN_WIDTH*JSON_OBJECT_SIZE ( 2 ) + JSON_OBJECT_SIZE ( 17 );
static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to be pushed to the web clients static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to be pushed to the web clients
jsonDocument["mType"] = "Settings"; jsonDocument["mType"] = "Settings";
jsonDocument["mode"] = setting.Mode;
jsonDocument["dispPoints"] = displayPoints; jsonDocument["dispPoints"] = displayPoints;
jsonDocument["start"] = startFreq_RX / 1000.0; jsonDocument["start"] = startFreq_RX / 1000.0;
jsonDocument["stop"] = stopFreq_RX / 1000.0; jsonDocument["stop"] = stopFreq_RX / 1000.0;
@ -655,6 +691,8 @@ static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to
jsonDocument["Drive"] = setting.Drive; jsonDocument["Drive"] = setting.Drive;
jsonDocument["sweepPoints"] = sweepPoints; jsonDocument["sweepPoints"] = sweepPoints;
jsonDocument["spur"] = setting.Spur; jsonDocument["spur"] = setting.Spur;
jsonDocument["tg"] = trackGenSetting.Mode;
jsonDocument["tgPower"] = trackGenSetting.Power;
if ( AGC_On ) if ( AGC_On )
jsonDocument["PreAmp"] = 0x60; // Auto jsonDocument["PreAmp"] = 0x60; // Auto
@ -683,10 +721,11 @@ static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to
void pushBandscopeSettings () void pushBandscopeSettings ()
{ {
size_t capacity = JSON_ARRAY_SIZE ( SCREEN_WIDTH ) size_t capacity = JSON_ARRAY_SIZE ( SCREEN_WIDTH )
+ SCREEN_WIDTH*JSON_OBJECT_SIZE ( 2 ) + JSON_OBJECT_SIZE ( 13 ); + SCREEN_WIDTH*JSON_OBJECT_SIZE ( 2 ) + JSON_OBJECT_SIZE ( 17 );
static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to be pushed to the web clients static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to be pushed to the web clients
jsonDocument["mType"] = "Settings"; jsonDocument["mType"] = "Settings";
jsonDocument["mode"] = setting.Mode;
jsonDocument["dispPoints"] = setting.BandscopePoints; jsonDocument["dispPoints"] = setting.BandscopePoints;
jsonDocument["start"] = setting.BandscopeStart / 1000.0; jsonDocument["start"] = setting.BandscopeStart / 1000.0;
jsonDocument["stop"] = ( setting.BandscopeStart + setting.BandscopeSpan ) / 1000.0; jsonDocument["stop"] = ( setting.BandscopeStart + setting.BandscopeSpan ) / 1000.0;
@ -700,6 +739,8 @@ static DynamicJsonDocument jsonDocument ( capacity ); // buffer for json data to
jsonDocument["Drive"] = setting.Drive; jsonDocument["Drive"] = setting.Drive;
jsonDocument["sweepPoints"] = sweepPoints; jsonDocument["sweepPoints"] = sweepPoints;
jsonDocument["spur"] = setting.Spur; jsonDocument["spur"] = setting.Spur;
jsonDocument["tg"] = trackGenSetting.Mode;
jsonDocument["tgPower"] = trackGenSetting.Power;
if ( AGC_On ) if ( AGC_On )
jsonDocument["PreAmp"] = 0x60; // Auto jsonDocument["PreAmp"] = 0x60; // Auto

View File

@ -40,14 +40,17 @@
* Function prototypes: * Function prototypes:
*/ */
extern boolean startAP (); boolean startAP ();
extern boolean connectWiFi (); boolean connectWiFi ();
extern void buildServer (); void buildServer ();
extern void addTagNameValue ( char *b, char *_name, char *value ); void addTagNameValue ( char *b, char *_name, char *value );
extern char *escapeXML ( char *s ); char *escapeXML ( char *s );
extern void webSocketEvent ( uint8_t num, WStype_t type, uint8_t* payload, size_t lenght ); void webSocketEvent ( uint8_t num, WStype_t type, uint8_t* payload, size_t lenght );
extern char *FormatIPAddress ( IPAddress ipAddress ); char *FormatIPAddress ( IPAddress ipAddress );
void pushSettings ();
void pushIFSweepSettings ();
void pushRXSweepSettings ();
void pushBandscopeSettings ();
/* /*
* Functions outside of "TinySA_wifi: * Functions outside of "TinySA_wifi: