samples settings

This commit is contained in:
Egor
2024-10-13 20:00:42 -07:00
parent 00368dc137
commit 7c3d48a44d
4 changed files with 82 additions and 45 deletions

View File

@@ -26,9 +26,11 @@
<label for="gateway">Gateway Address</label> <label for="gateway">Gateway Address</label>
<input type="text" id="gateway" name="gateway" value="192.168.1.1"><br> <input type="text" id="gateway" name="gateway" value="192.168.1.1"><br>
<label for="fstart">FREQ START</label> <label for="fstart">FREQ START</label>
<input type="text" id="fstart" name="fstart" value="800"><br> <input type="number" id="fstart" name="fstart" value="800"><br>
<label for="fend">FREQ END</label> <label for="fend">FREQ END</label>
<input type="text" id="fend" name="fend" value="960"><br> <input type="number" id="fend" name="fend" value="960"><br>
<label for="samples">SCAN SAMPLES</label>
<input type="number" id="samples" name="samples" value="10"><br>
<input type="submit" value="Submit"> <input type="submit" value="Submit">
</p> </p>
</form> </form>

View File

@@ -19,7 +19,7 @@ const String FEND = "fend";
// Variables to save values from HTML form // Variables to save values from HTML form
String ssid = "LoraSA", pass = "1234567890", ip = "192.168.1.100", String ssid = "LoraSA", pass = "1234567890", ip = "192.168.1.100",
gateway = "192.168.1.1", fstart = "", fend = ""; gateway = "192.168.1.1", fstart = "", fend = "", smpls = "";
IPAddress localIP; IPAddress localIP;
// Set your Gateway IP address // Set your Gateway IP address
@@ -111,23 +111,48 @@ void serverServer()
} }
Serial.println(request->params()); Serial.println(request->params());
String p = request->getParam(SSID, true)->value(); String p;
writeParameterToParameterFile(SSID, p); if (request->hasParam(IP, true))
{
p = request->getParam(IP, true)->value();
writeParameterToParameterFile(IP, p);
}
p = request->getParam(PASS, true)->value(); if (request->hasParam(IP, true))
writeParameterToParameterFile(PASS, p); {
p = request->getParam(IP, true)->value();
writeParameterToParameterFile(IP, p);
}
p = request->getParam(IP, true)->value(); if (request->hasParam(IP, true))
writeParameterToParameterFile(IP, p); {
p = request->getParam(IP, true)->value();
writeParameterToParameterFile(IP, p);
}
p = request->getParam(GATEWAY, true)->value(); if (request->hasParam(GATEWAY, true))
writeParameterToParameterFile(GATEWAY, p); {
p = request->getParam(GATEWAY, true)->value();
writeParameterToParameterFile(GATEWAY, p);
}
p = request->getParam(FSTART, true)->value(); if (request->hasParam(FSTART, true))
writeParameterToParameterFile(FSTART, p); {
p = request->getParam(FSTART, true)->value();
writeParameterToParameterFile(FSTART, p);
}
p = request->getParam(FEND, true)->value(); if (request->hasParam(FEND, true))
writeParameterToParameterFile(FEND, p); {
p = request->getParam(FEND, true)->value();
writeParameterToParameterFile(FEND, p);
}
if (request->hasParam("samples", true))
{
p = request->getParam("samples", true)->value();
writeParameterToParameterFile("samples", p);
}
request->send(200, "text/plain", request->send(200, "text/plain",
"Done. ESP will restart, connect to your router and " "Done. ESP will restart, connect to your router and "

View File

@@ -145,10 +145,9 @@ int SCAN_RANGES[] = {};
// MHZ per page // MHZ per page
// to put everything into one page set RANGE_PER_PAGE = FREQ_END - 800 // to put everything into one page set RANGE_PER_PAGE = FREQ_END - 800
uint64_t RANGE_PER_PAGE; // FREQ_END - FREQ_BEGIN uint64_t RANGE_PER_PAGE; // FREQ_END - CONF_FREQ_BEGIN
uint64_t CONF_FREQ_END, CONF_FREQ_BEGIN; uint64_t CONF_FREQ_END, CONF_FREQ_BEGIN; // To Enable Multi Screen scan
// To Enable Multi Screen scan
// uint64_t RANGE_PER_PAGE = 50; // uint64_t RANGE_PER_PAGE = 50;
// Default Range on Menu Button Switch // Default Range on Menu Button Switch
@@ -228,11 +227,12 @@ uint64_t ranges_count = 0;
int rssi = 0; int rssi = 0;
int state = 0; int state = 0;
int CONF_SAMPLES;
#ifdef METHOD_SPECTRAL #ifdef METHOD_SPECTRAL
constexpr int samples = SAMPLES; int samples = SAMPLES;
#endif #endif
#ifdef METHOD_RSSI #ifdef METHOD_RSSI
constexpr int samples = SAMPLES_RSSI; int samples = SAMPLES_RSSI;
#endif #endif
uint8_t result_index = 0; uint8_t result_index = 0;
@@ -305,8 +305,8 @@ void osdProcess()
// memset(max_step_range, 33, 30); // memset(max_step_range, 33, 30);
max_bin = 32; max_bin = 32;
osd.displayString(12, 1, String(FREQ_BEGIN)); osd.displayString(12, 1, String(CONF_FREQ_BEGIN));
osd.displayString(12, OSD_WIDTH - 8, String(FREQ_END)); osd.displayString(12, OSD_WIDTH - 8, String(CONF_FREQ_END));
// Finding biggest in result // Finding biggest in result
// Skiping 0 and 32 31 to avoid overflow // Skiping 0 and 32 31 to avoid overflow
for (int i = 1; i < MAX_POWER_LEVELS - 3; i++) for (int i = 1; i < MAX_POWER_LEVELS - 3; i++)
@@ -343,7 +343,7 @@ void osdProcess()
#ifdef OSD_SIDE_BAR #ifdef OSD_SIDE_BAR
{ {
osd.displayString(col, OSD_WIDTH - 7, osd.displayString(col, OSD_WIDTH - 7,
String(FREQ_BEGIN + (col * osd_mhz_in_bin)) + "-" + String(CONF_FREQ_BEGIN + (col * osd_mhz_in_bin)) + "-" +
String(max_step_range) + " "); String(max_step_range) + " ");
} }
#endif #endif
@@ -404,9 +404,9 @@ void init_radio()
// initialize SX1262 FSK modem at the initial frequency // initialize SX1262 FSK modem at the initial frequency
both.println("Init radio"); both.println("Init radio");
#if defined(USING_SX1280PA) || defined(USING_LR1121) #if defined(USING_SX1280PA) || defined(USING_LR1121)
state = radio.beginGFSK(FREQ_BEGIN); state = radio.beginGFSK(CONF_FREQ_BEGIN);
#else #else
state = radio.beginFSK(FREQ_BEGIN); state = radio.beginFSK(CONF_FREQ_BEGIN);
#endif #endif
if (state == RADIOLIB_ERR_NONE) if (state == RADIOLIB_ERR_NONE)
{ {
@@ -458,7 +458,7 @@ void init_radio()
// calibrate only once ,,, at startup // calibrate only once ,,, at startup
// TODO: check documentation (9.2.1) if we must calibrate in certain ranges // TODO: check documentation (9.2.1) if we must calibrate in certain ranges
#ifdef USING_SX1280PA #ifdef USING_SX1280PA
state = radio.setFrequency(FREQ_BEGIN); state = radio.setFrequency(CONF_FREQ_BEGIN);
if (state != RADIOLIB_ERR_NONE) if (state != RADIOLIB_ERR_NONE)
{ {
Serial.println("Error:setFrequency:" + String(state)); Serial.println("Error:setFrequency:" + String(state));
@@ -470,9 +470,9 @@ void init_radio()
} }
#elif USING_SX1276 #elif USING_SX1276
// Sets carrier frequency. Allowed values range from 137.0 MHz to 1020.0 MHz. // Sets carrier frequency. Allowed values range from 137.0 MHz to 1020.0 MHz.
radio.setFrequency(FREQ_BEGIN); radio.setFrequency(CONF_FREQ_BEGIN);
#else #else
radio.setFrequency(FREQ_BEGIN, true); radio.setFrequency(CONF_FREQ_BEGIN, true);
#endif #endif
delay(50); delay(50);
@@ -612,8 +612,6 @@ void setup(void)
} }
} }
init_radio();
initLittleFS(); initLittleFS();
// writeFile(LittleFS, "/text.txt", "{WIFI:{name:\"sdfsdf\", Password:\"sdfsdf\"}"); // writeFile(LittleFS, "/text.txt", "{WIFI:{name:\"sdfsdf\", Password:\"sdfsdf\"}");
@@ -635,16 +633,22 @@ void setup(void)
fend = readParameterFromParameterFile(FEND); fend = readParameterFromParameterFile(FEND);
Serial.println("FEND: " + fend); Serial.println("FEND: " + fend);
smpls = readParameterFromParameterFile("samples");
Serial.println("SAMPLES: " + smpls);
both.println("Starting WIFI-SERVER"); both.println("Starting WIFI-SERVER");
serverStart(); serverStart();
CONF_SAMPLES = (smpls == "") ? samples : atoi(smpls.c_str());
samples = CONF_SAMPLES;
CONF_FREQ_BEGIN = (fstart == "") ? FREQ_BEGIN : atoi(fstart.c_str()); CONF_FREQ_BEGIN = (fstart == "") ? FREQ_BEGIN : atoi(fstart.c_str());
CONF_FREQ_END = (fend == "") ? FREQ_END : atoi(fend.c_str()); CONF_FREQ_END = (fend == "") ? FREQ_END : atoi(fend.c_str());
both.println("C FREQ BEGIN:" + String(CONF_FREQ_BEGIN)); both.println("C FREQ BEGIN:" + String(CONF_FREQ_BEGIN));
both.println("C FREQ END:" + String(CONF_FREQ_END)); both.println("C FREQ END:" + String(CONF_FREQ_END));
both.println("C SAMPLES:" + String(CONF_SAMPLES));
RANGE_PER_PAGE = CONF_FREQ_END - CONF_FREQ_BEGIN; // FREQ_END - FREQ_BEGIN RANGE_PER_PAGE = CONF_FREQ_END - CONF_FREQ_BEGIN; // FREQ_END - CONF_FREQ_BEGIN
RANGE = (int)(CONF_FREQ_END - CONF_FREQ_BEGIN); RANGE = (int)(CONF_FREQ_END - CONF_FREQ_BEGIN);
@@ -654,9 +658,11 @@ void setup(void)
iterations = RANGE / RANGE_PER_PAGE; iterations = RANGE / RANGE_PER_PAGE;
// uint64_t range_frequency = FREQ_END - FREQ_BEGIN; // uint64_t range_frequency = FREQ_END - CONF_FREQ_BEGIN;
median_frequency = (CONF_FREQ_BEGIN + CONF_FREQ_END) / 2; median_frequency = (CONF_FREQ_BEGIN + CONF_FREQ_END) / 2;
init_radio();
#ifndef LILYGO #ifndef LILYGO
vbat = heltec_vbat(); vbat = heltec_vbat();
both.printf("V battery: %.2fV (%d%%)\n", vbat, heltec_battery_percent(vbat)); both.printf("V battery: %.2fV (%d%%)\n", vbat, heltec_battery_percent(vbat));
@@ -763,8 +769,9 @@ void setup(void)
r.trigger_level = TRIGGER_LEVEL; r.trigger_level = TRIGGER_LEVEL;
stacked.reset(0, 0, display.width(), display.height()); stacked.reset(0, 0, display.width(), display.height());
bar = new DecoratedBarChart(display, 0, 0, display.width(), 0, FREQ_BEGIN, FREQ_END, bar = new DecoratedBarChart(display, 0, 0, display.width(), 0, CONF_FREQ_BEGIN,
LO_RSSI_THRESHOLD, HI_RSSI_THRESHOLD, r.trigger_level); CONF_FREQ_END, LO_RSSI_THRESHOLD, HI_RSSI_THRESHOLD,
r.trigger_level);
size_t b = stacked.addChart(bar); size_t b = stacked.addChart(bar);
@@ -778,9 +785,9 @@ void setup(void)
delete[] multiples; delete[] multiples;
waterChart = waterChart = new WaterfallChart(display, 0, WATERFALL_START, display.width(), 0,
new WaterfallChart(display, 0, WATERFALL_START, display.width(), 0, FREQ_BEGIN, CONF_FREQ_BEGIN, CONF_FREQ_END, r.trigger_level,
FREQ_END, r.trigger_level, WATERFALL_SENSITIVITY, model); WATERFALL_SENSITIVITY, model);
size_t c = stacked.addChart(waterChart); size_t c = stacked.addChart(waterChart);
stacked.setHeight(c, stacked.height - WATERFALL_START - statusBar->height); stacked.setHeight(c, stacked.height - WATERFALL_START - statusBar->height);
@@ -1011,13 +1018,13 @@ void loop(void)
} }
// do the scan // do the scan
range = FREQ_END - FREQ_BEGIN; range = CONF_FREQ_END - CONF_FREQ_BEGIN;
if (RANGE_PER_PAGE > range) if (RANGE_PER_PAGE > range)
{ {
RANGE_PER_PAGE = range; RANGE_PER_PAGE = range;
} }
r.fr_begin = FREQ_BEGIN; r.fr_begin = CONF_FREQ_BEGIN;
r.fr_end = r.fr_begin; r.fr_end = r.fr_begin;
// 50 is a single-screen range // 50 is a single-screen range
@@ -1150,7 +1157,7 @@ void loop(void)
// Spectrum analyzer using getRSSI // Spectrum analyzer using getRSSI
{ {
LOG("METHOD RSSI"); LOG("METHOD RSSI");
uint16_t max_rssi = r.rssiMethod(SAMPLES_RSSI, result, uint16_t max_rssi = r.rssiMethod(CONF_SAMPLES, result,
RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE); RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE);
if (max_x_rssi[display_x] > max_rssi) if (max_x_rssi[display_x] > max_rssi)
@@ -1162,7 +1169,7 @@ void loop(void)
// if this code is not executed LORA radio doesn't work // if this code is not executed LORA radio doesn't work
// basically SX1262 requires delay // basically SX1262 requires delay
// osd.displayString(12, 1, String(FREQ_BEGIN)); // osd.displayString(12, 1, String(CONF_FREQ_BEGIN));
// osd.displayString(12, 30 - 8, String(FREQ_END)); // osd.displayString(12, 30 - 8, String(FREQ_END));
// delay(2); // delay(2);

View File

@@ -16,6 +16,8 @@
// temporary dirty import ... to be solved durring upcoming refactoring // temporary dirty import ... to be solved durring upcoming refactoring
extern unsigned int RANGE_PER_PAGE; extern unsigned int RANGE_PER_PAGE;
extern uint64_t CONF_FREQ_BEGIN;
extern uint64_t CONF_FREQ_END;
extern unsigned int median_frequency; extern unsigned int median_frequency;
extern unsigned int drone_detected_frequency_start; extern unsigned int drone_detected_frequency_start;
extern unsigned int drone_detected_frequency_end; extern unsigned int drone_detected_frequency_end;
@@ -95,7 +97,8 @@ void StatusBar::draw()
// Frequency start // Frequency start
display.setTextAlignment(TEXT_ALIGN_LEFT); display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(pos_x, text_y, display.drawString(pos_x, text_y,
(r.fr_begin == 0) ? String(FREQ_BEGIN) : String(r.fr_begin)); (r.fr_begin == 0) ? String(CONF_FREQ_BEGIN)
: String(r.fr_begin));
// Frequency detected // Frequency detected
display.setTextAlignment(TEXT_ALIGN_CENTER); display.setTextAlignment(TEXT_ALIGN_CENTER);
@@ -106,7 +109,7 @@ void StatusBar::draw()
// Frequency end // Frequency end
display.setTextAlignment(TEXT_ALIGN_RIGHT); display.setTextAlignment(TEXT_ALIGN_RIGHT);
display.drawString(pos_x + width, text_y, display.drawString(pos_x + width, text_y,
(r.fr_end == 0) ? String(FREQ_END) : String(r.fr_end)); (r.fr_end == 0) ? String(CONF_FREQ_END) : String(r.fr_end));
} }
// Status text block // Status text block
@@ -170,11 +173,11 @@ void StatusBar::draw()
display.drawString(pos_x, text_y, String(loop_time)); display.drawString(pos_x, text_y, String(loop_time));
#else #else
display.setTextAlignment(TEXT_ALIGN_LEFT); display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(pos_x, text_y, String(FREQ_BEGIN)); display.drawString(pos_x, text_y, String(CONF_FREQ_BEGIN));
#endif #endif
display.setTextAlignment(TEXT_ALIGN_RIGHT); display.setTextAlignment(TEXT_ALIGN_RIGHT);
display.drawString(pos_x + width, text_y, String(FREQ_END)); display.drawString(pos_x + width, text_y, String(CONF_FREQ_END));
} }
else if (ranges_count > 0) else if (ranges_count > 0)
{ {