add output raw

This commit is contained in:
Egor
2025-01-05 15:06:21 -08:00
parent baba077796
commit 6504bd358b
2 changed files with 107 additions and 64 deletions
+51
View File
@@ -35,6 +35,26 @@ build_flags =
-DHELTEC
-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_MODE=1
[env:heltec_wifi_lora_32_V3_lora-TX-scanner]
platform = espressif32
board = heltec_wifi_lora_32_V3
framework = arduino
upload_speed = 921600
monitor_speed = 115200
board_build.f_cpu = 240000000
board_build.filesystem = littlefs
lib_deps =
ropg/Heltec_ESP32_LoRa_v3@^0.9.1
ESP Async WebServer
build_flags =
-DHELTEC_POWER_BUTTON
-DHELTEC
-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_MODE=1
-DDEFAULT_RX=916
-DDEFAULT_TX=915
-DDEFAULT_LORA_ENABLED=true
[env:heltec_wifi_lora_32_V3-OSD]
platform = espressif32
@@ -99,6 +119,37 @@ build_flags =
-DARDUINO_LILYGO_T3_S3_V1_X
-DARDUINO_USB_MODE=1
[env:lilygo-T3S3-v1-2-sx1262-lora-RX-host-reciver]
platform = espressif32
board = t3_s3_v1_x
framework = arduino
upload_speed = 921600
monitor_speed = 115200
board_build.f_cpu = 240000000
board_build.filesystem = littlefs
lib_deps =
ropg/Heltec_ESP32_LoRa_v3@^0.9.1
RadioLib
U8g2
XPowersLib
ESP Async WebServer
build_flags =
-DLILYGO
-DT3_S3_V1_2_SX1262
-DT3_V1_3_SX1262
-DARDUINO_LILYGO_T3S3_SX1262
-DESP32
-DUSING_SX1262
-DARDUINO_ARCH_ESP32
-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_LILYGO_T3_S3_V1_X
-DARDUINO_USB_MODE=1
-DDEFAULT_RX=916
-DDEFAULT_TX=915
-DDEFAULT_LORA_ENABLED=true
-DDEFAULT_IS_LORA_HOST=true
-DDISPLAY_RAW_SCAN=1
[env:lilygo-T3S3-v1-2-lr1121]
platform = espressif32
board = t3_s3_v1_x
+56 -64
View File
@@ -1460,6 +1460,57 @@ Result<int16_t, Message *> checkRadio(RadioComms &c);
void display_scan_result(ScanTaskResult &dump);
std::unordered_map<int, int16_t> findMaxRssi(int16_t *rssis, uint32_t *freqs_khz,
int dump_sz, int level = 80);
void display_raw_scan(ScanTaskResult &dump)
{
// display.setDisplayRotation(1);
// display.println("Host Mode ->");
size_t dump_sz = dump.sz;
int16_t *rssi = dump.rssis;
uint32_t *fr = dump.freqs_khz;
std::unordered_map<int, int16_t> maxMhzRssi = findMaxRssi(rssi, fr, dump_sz, 85);
Serial.println("PRINT SIZE :" + String(maxMhzRssi.size()));
int lx = 0;
int ly = 0;
int i = 0;
for (const auto &pair : maxMhzRssi)
{
if (i == 0 && maxMhzRssi.size() > 0)
{
display.clear();
}
int16_t rssi = pair.second;
int16_t fr = (int)pair.first;
Serial.println("PRINT FR:" + String(fr) + ":" + String(rssi) + " lx " +
String(lx));
// screen overflow protection
if (lx < 130)
{
display.drawString(lx, ly, String(fr) + ":" + String(rssi));
Serial.println("PRINT FR:" + String(fr) + ":" + String(rssi));
// go to next line
ly = ly + 10;
if (ly > 60)
{
ly = 0;
// go to next column
lx = lx + 45;
}
}
i++;
}
if (maxMhzRssi.size() > 0)
{
display.display();
}
}
/*
* If m.to is LOOP, the message is directed at this module; enact the message.
* If m.to is not LOOP, send the message via the respective interface.
@@ -1533,7 +1584,11 @@ void sendMessage(RoutedMessage &m)
case SCAN_MAX_RESULT:
if (config.is_host)
{
#ifdef DISPLAY_RAW_SCAN
display_raw_scan(m.message->payload.dump);
#else
display_scan_result(m.message->payload.dump);
#endif
}
break;
}
@@ -2111,7 +2166,7 @@ void doScan()
std::unordered_map<int, int> previousPac = {/*{916, true}, {915, true}*/};
std::unordered_map<int, int16_t> findMaxRssi(int16_t *rssis, uint32_t *freqs_khz,
int dump_sz, int level = 80)
int dump_sz, int level)
{
std::unordered_map<int, int16_t> maxRssiPerMHz; // Map to store max RSSI per MHz
@@ -2156,34 +2211,6 @@ Result<int16_t, Message *> checkRadio(RadioComms &comms)
return ret;
}
std::unordered_map<int, int> previousPac = {/*{916, true}, {915, true}*/};
std::unordered_map<int, int16_t> findMaxRssi(int16_t *rssis, uint32_t *freqs_khz,
int dump_sz, int level = 80)
{
std::unordered_map<int, int16_t> maxRssiPerMHz; // Map to store max RSSI per MHz
for (int i = 0; i < dump_sz; i++)
{
int16_t rssi = rssis[i];
int freq_mhz = (int)freqs_khz[i] / 1000; // Convert kHz to MHz
// Update the maximum RSSI for this MHz frequency
if (maxRssiPerMHz.find(freq_mhz) == maxRssiPerMHz.end() ||
maxRssiPerMHz[freq_mhz] < rssi)
{
if (abs(rssi) < level)
{
maxRssiPerMHz[freq_mhz] = rssi;
}
}
}
return maxRssiPerMHz;
}
bool lock = false;
int16_t sendMessage(RadioComms &comms, Message &msg)
{
radioIsScan = false;
@@ -2198,41 +2225,6 @@ int16_t sendMessage(RadioComms &comms, Message &msg)
{
lock = true;
// display.setDisplayRotation(1);
// display.println("Host Mode ->");
size_t dump_sz = msg->payload.dump.sz;
int16_t *rssi = msg->payload.dump.rssis;
uint32_t *fr = msg->payload.dump.freqs_khz;
std::unordered_map<int, int16_t> maxMhzRssi = findMaxRssi(rssi, fr, dump_sz, 85);
int lx, ly, i = 0;
for (const auto &pair : maxMhzRssi)
{
if (i == 0 && maxMhzRssi.size() > 0)
{
display.clear();
}
// screen overflow protection
if (lx < 130)
{
int16_t rssi = pair.second;
int16_t fr = (int)pair.first;
display.drawString(lx, ly, String(fr) + ":" + String(rssi));
// go to next line
ly += 10;
if (ly > 60)
{
ly = 0;
// go to next column
lx += 50;
}
display.display();
}
i++;
}
lock = false;
}