diff --git a/Bandscope.ino b/Bandscope.ino
index 1c74aba..8c97d61 100644
--- a/Bandscope.ino
+++ b/Bandscope.ino
@@ -497,7 +497,7 @@ static uint16_t chunkIndex;
}
- myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation
+// myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation
if ( autoSweepStep >= sweepPoints ) // If we have got to the end of the sweep
@@ -513,7 +513,7 @@ static uint16_t chunkIndex;
{
myActual[setting.BandscopePoints-1] = rxRSSI; // Yes, save it
myGain[setting.BandscopePoints-1] = gainReading;
- myFreq[setting.BandscopePoints-1] = oldSweepFreq;
+// myFreq[setting.BandscopePoints-1] = oldSweepFreq;
}
if ( showRSSI == 1 ) // Only show it once?
diff --git a/IFsweep.ino b/IFsweep.ino
index 763d009..f9f836c 100644
--- a/IFsweep.ino
+++ b/IFsweep.ino
@@ -449,7 +449,7 @@ static uint16_t chunkIndex;
if ( oldSweepStep > 0 ) // Only push if not first point (two pixel wide img)
img.pushSprite ( xOrigin+oldSweepStep-1, yOrigin );
- myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation
+// myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation
} // End of "if ( autoSweepFreq >= nextPointFreq )"
@@ -467,7 +467,7 @@ static uint16_t chunkIndex;
{
myActual[displayPoints-1] = rxRSSI; // Yes, save it
myGain[displayPoints-1] = gainReading;
- myFreq[displayPoints-1] = oldSweepFreq;
+// myFreq[displayPoints-1] = oldSweepFreq;
}
if ( showRSSI == 1 ) // Only show it once?
diff --git a/RXsweep.ino b/RXsweep.ino
index 7cd25a2..2ef61c9 100644
--- a/RXsweep.ino
+++ b/RXsweep.ino
@@ -496,7 +496,7 @@ static uint16_t bpfCalFirstSweepDone;
if ( oldSweepStep > 0 ) // Only push if not first point (two pixel wide img)
img.pushSprite ( xOrigin+oldSweepStep-1, yOrigin );
- myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation
+// myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation
} // End of "if ( autoSweepFreq >= nextPointFreq )"
@@ -514,7 +514,7 @@ static uint16_t bpfCalFirstSweepDone;
{
myActual[displayPoints-1] = rxRSSI; // Yes, save it
myGain[displayPoints-1] = gainReading;
- myFreq[displayPoints-1] = oldSweepFreq;
+// myFreq[displayPoints-1] = oldSweepFreq;
}
if ( showRSSI == 1 ) // Only show it once?
diff --git a/SweepLo.ino b/SweepLo.ino
index 935b2d6..791be57 100644
--- a/SweepLo.ino
+++ b/SweepLo.ino
@@ -198,6 +198,7 @@ static uint32_t tgIF; // Track gen IF - SA IF plus any offset if both SI4432
case 2: // generator mode
tg_lo.TxMode ( trackGenSetting.LO_Drive ); // Set tracking generator LO on
tg_if.TxMode ( trackGenSetting.IF_Drive ); // Set tracking generator IF on
+ delayMicroseconds(300);
tg_lo.SetFrequency ( setting.IF_Freq + trackGenSetting.Offset + trackGenSetting.Frequency );
break;
@@ -451,6 +452,7 @@ static uint32_t tgIF; // Track gen IF - SA IF plus any offset if both SI4432
JsonObject dataPoint = Points.createNestedObject (); // Add an object to the Json array to be pushed to the client
dataPoint["x"] = oldSweepFreq/1000000.0; // Set the x(frequency) value
dataPoint["y"] = rxRSSI; // Set the y (RSSI) value
+ dataPoint["g"] = gainReading; // Set the y (gain) value
// Serial.printf ( "Add point chunkIndex %u, sweepStep %u of %u \n", chunkIndex, sweepStep, sweepPoints);
chunkIndex++; // increment no of data points in current WiFi chunk
@@ -463,6 +465,7 @@ static uint32_t tgIF; // Track gen IF - SA IF plus any offset if both SI4432
// Serial.print("D");
serializeJson ( jsonDocument, wsBuffer );
// Serial.printf("J%u", wsBuffer.length() );
+ // Serial.println(wsBuffer);
unsigned long s = millis();
webSocket.broadcastTXT ( wsBuffer ); // Send to all connected websocket clients
if (millis() - s > 1000)
@@ -681,7 +684,7 @@ static uint32_t tgIF; // Track gen IF - SA IF plus any offset if both SI4432
if ( oldSweepStep > 0 ) // Only push if not first point (two pixel wide img)
img.pushSprite ( xOrigin+oldSweepStep-1, yOrigin );
- myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation
+// myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation
} // End of "if ( autoSweepFreq >= nextPointFreq )"
@@ -702,7 +705,7 @@ static uint32_t tgIF; // Track gen IF - SA IF plus any offset if both SI4432
{
myActual[displayPoints-1] = rxRSSI; // Yes, save it
myGain[displayPoints-1] = gainReading;
- myFreq[displayPoints-1] = oldSweepFreq;
+// myFreq[displayPoints-1] = oldSweepFreq;
}
if ( showRSSI == 1 ) // Only show it once?
diff --git a/data/index.html b/data/index.html
index a564972..9295fd8 100644
--- a/data/index.html
+++ b/data/index.html
@@ -50,11 +50,11 @@
-
+
-
+
Signal Generator
@@ -107,6 +107,7 @@
+
@@ -1055,7 +1056,8 @@ connect(hostName.value);
$(document).ready(function () {
- update();
+// update();
+ sendValue("r", 0); // get settings
var chartUpdateVar;
// chartUpdateVar = setInterval(renderChart, 500);
});
@@ -1382,15 +1384,22 @@ function handleChunkData (data)
data.Points.forEach (function (point, index) { // copy data into the chart data series
var p = {};
- p = point; // create a copy not a reference ??
+ p = point.y; // create a copy not a reference ??
var f = {};
f = point.x;
- chartSA.options.data[1].dataPoints[dataStart + index] = p; // RSSI
+ var g = {};
+ g = point.g;
- chartSA.options.data[0].dataPoints[dataStart + index].x = f * 1;
- var dB = p.y/2+b;
+ chartSA.options.data[1].dataPoints[dataStart + index].x = f * 1; // RSSI
+ chartSA.options.data[1].dataPoints[dataStart + index].y = p * 1;
+
+ chartSA.options.data[0].dataPoints[dataStart + index].x = f * 1; // dBm
+ var dB = p/2+b;
chartSA.options.data[0].dataPoints[dataStart + index].y = dB * 1;
+ chartSA.options.data[2].dataPoints[dataStart + index].x = f * 1; // gain
+ chartSA.options.data[2].dataPoints[dataStart + index].y = g * 1;
+
//chartSA.options.data[3].dataPoints[dataStart + index] = point;
//try {
@@ -1440,14 +1449,14 @@ function handleChunkData (data)
})
}
- if (chartSA.options.data[2].visible) {
- $.getJSON( "getGainSweep") // proper line
+// if (chartSA.options.data[2].visible) {
+// $.getJSON( "getGainSweep") // proper line
// $.getJSON( "getGainSweep.json") // for local test
- .done(function (data) {
+// .done(function (data) {
// We have the data, process it.
- chartSA.options.data[2].dataPoints = data.gainPoints; // Gain trace
- });
- }
+// chartSA.options.data[2].dataPoints = data.gainPoints; // Gain trace
+// });
+// }
}
diff --git a/simpleSA.h b/simpleSA.h
index 507eefd..fb92fe8 100644
--- a/simpleSA.h
+++ b/simpleSA.h
@@ -32,7 +32,7 @@
#define PROGRAM_NAME "simpleSA" // These are for the WiFi interface
-#define PROGRAM_VERSION "Version 0.1" // Current version - beta!
+#define PROGRAM_VERSION "Version 0.11" // Current version - beta!
/*
@@ -190,7 +190,7 @@
*/
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, BANDSCOPE, RX_SWEEP };
+ IF_SWEEP, ZERO_SPAN_LOW_RANGE, ZERO_SPAN_HIGH_RANGE, BANDSCOPE, RX_SWEEP, OTA_UPDATE };
/*
diff --git a/simpleSA.ino b/simpleSA.ino
index e5d6b77..b1735f1 100644
--- a/simpleSA.ino
+++ b/simpleSA.ino
@@ -372,9 +372,9 @@ 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 );
+// + ( MAX_WIFI_POINTS + 1 ) * JSON_OBJECT_SIZE ( 3 ) + JSON_OBJECT_SIZE( 5 );
-static DynamicJsonDocument jsonDocument ( 4000 ); // Buffer for json data to be pushed to the web clients
+static DynamicJsonDocument jsonDocument ( 5000 ); // Buffer for json data to be pushed to the web clients
static JsonArray Points = jsonDocument.createNestedArray ( "Points" ); // add Points array
#endif
@@ -502,7 +502,7 @@ uint8_t myData[SCREEN_WIDTH+1];
uint8_t myStorage[SCREEN_WIDTH+1];
uint8_t myActual[SCREEN_WIDTH+1];
uint8_t myGain[SCREEN_WIDTH+1]; // Preamp gain
-uint32_t myFreq[SCREEN_WIDTH+1]; // Frequency for XML file
+//uint32_t myFreq[SCREEN_WIDTH+1]; // Frequency for XML file
uint16_t peakLevel; // Current maximum signal level
uint16_t oldPeakLevel; // Old maximum signal level
@@ -843,6 +843,14 @@ bool fsStatus = false; // True if SPIFFS loads ok
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
+ tft.setCursor ( 20, 200);
+ tft.setTextColor(WHITE);
+ tft.setFreeFont ( &FreeSansBold9pt7b ); // Select Free Serif 9 point font
+ tft.print( "Progress:");
+ tft.fillRect(120, 180, 100, 20, SIG_BACKGROUND_COLOR); // x, y, w, h, color
+ tft.setCursor (120, 200);
+ tft.printf("%u%%", (progress / (total / 100)));
+
})
.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
@@ -919,8 +927,8 @@ loopStartMicros = micros();
#if USE_WIFI
//Serial.println("l");
- if ( ( numberOfWebsocketClients > 0) || (loopStartMicros - lastWebsocketMicros > websocketInterval)
- || (loopStartMicros < lastWebsocketMicros) ) // handles rollover of micros()
+ if ( ( numberOfWebsocketClients > 0) || ( loopStartMicros - lastWebsocketMicros > websocketInterval )
+ || ( loopStartMicros < lastWebsocketMicros ) ) // handles rollover of micros()
{
// Serial.print("L");
webSocket.loop (); // Check websockets for events, but not at first
@@ -928,12 +936,12 @@ loopStartMicros = micros();
lastWebsocketMicros = loopStartMicros;
}
- ArduinoOTA.handle(); // check if OTA programming requested
#endif
CheckCommand (); // Anything from the serial input?
- if ( ( setting.Mode != SIG_GEN_LOW_RANGE ) || (ui_mode != UI_NORMAL ) )
+ if ( ( ( tinySA_mode != SIG_GEN_LOW_RANGE ) && ( tinySA_mode != OTA_UPDATE ) )
+ || ( ui_mode != UI_NORMAL ) )
{
UiProcessTouch (); // Handle the touch screen
if ( ui_mode != UI_NORMAL )
@@ -947,7 +955,7 @@ loopStartMicros = micros();
* Not fully implemented yet.
*/
- switch ( setting.Mode )
+ switch ( tinySA_mode )
{
case SA_LOW_RANGE:
doSweepLow(); // Spectrum Analyser Low Frequency range
@@ -977,6 +985,10 @@ loopStartMicros = micros();
doBandscope(); // Bandscope Sweep
break;
+ case OTA_UPDATE: // Over the air (wifi) update
+ doOTA();
+ break;
+
default:
DisplayError ( ERR_WARN,
"Invalid Mode!",
@@ -1024,6 +1036,9 @@ void setMode ( uint16_t newMode )
initRX_Sweep();
break;
+ case OTA_UPDATE:
+ initOTA();
+ break;
default:
DisplayError ( ERR_WARN,
@@ -1083,6 +1098,10 @@ void menuExit()
else
initBandscope();
break;
+
+ case OTA_UPDATE:
+ initOTA();
+ break;
default:
// add handler here
@@ -1272,9 +1291,61 @@ void doSigGenHigh ()
}
+/*
+ * Over The Air (OTA) update allows the ESP32 to be programmed over wifi
+ * This is handled as a separte mode as it has a hit on scan times
+ * The Init function just draws a simple page indicating it is in OTA Mode
+ */
+void initOTA()
+{
+ boolean pressed;
+ uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
+ tft.fillScreen(SIG_BACKGROUND_COLOR);
+ tft.setTextColor(WHITE);
+ tft.setFreeFont ( &FreeSansBold9pt7b ); // Select Free Serif 9 point font
+ tft.setTextDatum ( TC_DATUM ); // Top center text position datum
+ tft.drawString ( "simpleSA", 160, 20 );
+ tft.drawString ( "OTA Mode", 160, 60 );
+ tft.drawString ( "Press to Exit", 160, 100 );
+ tft.setTextDatum ( TL_DATUM ); // Back to default top left
+ tft.setFreeFont ( NULL ); // Select default font
+
+ // Make sure touch is not pressed when leaving
+ do {
+ pressed = tft.getTouch(&t_x, &t_y); // Just uses standard TFT_eSPI function as not bothered about speed
+ } while ( pressed );
+ tinySA_mode = OTA_UPDATE; // don't set the setting.Mode as we may want to return to previous mode
+}
+
+/*
+ * Here we just call the OTA monitor and check if the user has pessed the screen to exit
+ * This is called once every main loop scan
+ */
+
+void doOTA()
+{
+ uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
+ static boolean lastPress = true;
+
+ ArduinoOTA.handle(); // check if OTA programming requested
+
+ // Get current touch state and coordinates
+ boolean pressed = tft.getTouch(&t_x, &t_y); // Just uses standard TFT_eSPI function as not bothered about speed
+
+ if ( pressed && !lastPress )
+ {
+ // go back to previous mode
+ // wait for press to be released
+ do {
+ pressed = tft.getTouch(&t_x, &t_y); // Just uses standard TFT_eSPI function as not bothered about speed
+ } while ( pressed );
+ setMode(setting.Mode);
+ }
+ lastPress = pressed;
+}
/*
* "SetRX" - Mode 3 is sig gen, 0 is normal (RX as receive, LO on), 1 is both
diff --git a/simpleSA_wifi.cpp b/simpleSA_wifi.cpp
index 77ff81a..91ae0a6 100644
--- a/simpleSA_wifi.cpp
+++ b/simpleSA_wifi.cpp
@@ -511,23 +511,23 @@ void addTagNameValue ( char *b, char *_name, char *value )
* or perhaps just create the xml at the end of each scan - investigate later
*/
-void onGetScan ( AsyncWebServerRequest *request )
-{
- response = request->beginResponseStream ( "text/xml" );
-// Serial.println ( "onGetScan" );
-
- response->print ( "" );
- response->println ( "" );
-
- for( int i = 0; i < displayPoints-1; i++ ) // For each data point
- {
-// Serial.printf ( " %i\n",myFreq[i], myData[i], i );
- response->printf ( "