LilyGO T3S3 works

This commit is contained in:
Sassa NF
2024-09-26 21:35:32 +01:00
parent d88040ab84
commit 94c042a186
8 changed files with 10 additions and 182 deletions
+2
View File
@@ -63,6 +63,8 @@ board_build.f_cpu = 240000000
lib_deps =
ropg/Heltec_ESP32_LoRa_v3@^0.9.1
RadioLib
U8g2
XPowersLib
build_flags =
-DLILYGO
-DT3_S3_V1_2_SX1280_PA
+7 -3
View File
@@ -21,7 +21,7 @@
https://jgromes.github.io/RadioLib/
*/
// #define HELTEC_NO_DISPLAY
// #define HELTEC_NO_DISPLAY
#include <Arduino.h>
@@ -36,7 +36,8 @@
// library internals.
#define RADIOLIB_GODMODE (1)
#include "radioScan/radioScan.h"
#include <LoRaBoards.h>
#include <scan.h>
#ifndef LILYGO
#include <heltec_unofficial.h>
@@ -354,7 +355,6 @@ void init_radio()
// initialize SX1262 FSK modem at the initial frequency
both.println("Init radio");
#ifdef USING_SX1280PA
// radio.begin();
state = radio.beginGFSK(FREQ_BEGIN);
#else
state = radio.beginFSK(FREQ_BEGIN);
@@ -423,6 +423,10 @@ void init_radio()
void setup(void)
{
setupBoards();
delay(5000);
Serial.println("setup is done");
// LED brightness
heltec_led(25);
#ifdef OSD_ENABLED
-128
View File
@@ -1,128 +0,0 @@
#ifndef LORASA_CORE_CPP
#define LORASA_CORE_CPP
#include "radioScan.h"
#include <cstdint>
#include <cstring>
#include <stdlib.h>
uint16_t Scan::rssiMethod(size_t samples, uint16_t *result, size_t res_size)
{
float scale((float)res_size / (HI_RSSI_THRESHOLD - LO_RSSI_THRESHOLD + 0.1));
memset(result, 0, res_size * sizeof(uint16_t));
int result_index = 0;
//
uint16_t max_signal = 65535;
// N of samples
for (int r = 0; r < samples; r++)
{
float rssi = getRSSI();
if (rssi < -65535)
rssi = -65535;
uint16_t abs_rssi = abs(rssi);
if (abs_rssi < max_signal)
{
max_signal = abs_rssi;
}
// ToDO: check if 4 is correct value for 33 power bins
// Now we have more space because we are ignoring low dB values
// we can / 3 default 4
if (RSSI_OUTPUT_FORMULA == 1)
{
result_index =
/// still not clear formula but it works
uint8_t(abs(rssi) / 4);
}
else if (RSSI_OUTPUT_FORMULA == 2)
{
if (rssi > HI_RSSI_THRESHOLD)
{
rssi = HI_RSSI_THRESHOLD;
}
else if (rssi < LO_RSSI_THRESHOLD)
{
rssi = LO_RSSI_THRESHOLD;
}
result_index = uint8_t((HI_RSSI_THRESHOLD - rssi) * scale);
}
if (result_index >= res_size)
{
// Maximum index possible
result_index = res_size - 1;
}
LOG("RSSI: %f IDX: %d\n", rssi, result_index);
if (result[result_index] == 0 || result[result_index] > abs_rssi)
{
result[result_index] = abs_rssi;
}
}
return max_signal;
}
size_t Scan::detect(uint16_t *result, bool *filtered_result, size_t result_size,
int samples)
{
size_t max_rssi_x = 999;
for (int y = 0; y < result_size; y++)
{
LOG("%i:%i,", y, result[y]);
#if !defined(FILTER_SPECTRUM_RESULTS) || FILTER_SPECTRUM_RESULTS == false
if (result[y] && result[y] != 0)
{
filtered_result[y] = 1;
}
else
{
filtered_result[y] = 0;
}
#endif
// if samples low ~1 filter removes all values
#if FILTER_SPECTRUM_RESULTS
filtered_result[y] = 0;
// Filter Elements without neighbors
// if RSSI method actual value is -xxx dB
if (result[y] > 0 && samples > 1)
{
// do not process 'first' and 'last' row to avoid out of index
// access.
if ((y > 0) && (y < (result_size - 2)))
{
if (((result[y + 1] != 0) && (result[y + 2] != 0)) ||
(result[y - 1] != 0))
{
filtered_result[y] = 1;
// Fill empty pixel
result[y + 1] = 1;
}
else
{
LOG("Filtered::%i,", y);
}
}
} // not filtering if samples == 1 because it will be filtered
else if (result[y] > 0 && samples == 1)
{
filtered_result[y] = 1;
}
#endif
if (filtered_result[y] && max_rssi_x > y)
{
max_rssi_x = y;
}
}
return max_rssi_x;
}
#endif
-50
View File
@@ -1,50 +0,0 @@
#include <cstdint>
#include <stdlib.h>
#ifndef LORASA_CORE_H
#define LORASA_CORE_H
#ifdef PRINT_DEBUG
#define LOG(args...) Serial.printf(args...)
#define LOG_IF(cond, args...) \
if (cond) \
LOG(args...)
#elif !defined(LOG)
#define LOG(args...)
#define LOG_IF(cond, args...)
#endif
// Output Pixel Formula
// 1 = rssi / 4, 2 = (rssi / 2) - 22 or 20
constexpr int RSSI_OUTPUT_FORMULA = 2;
// based on the formula for RSSI_OUTPUT_FORMULA == 2
// -2 * (22 + RADIOLIB_SX126X_SPECTRAL_SCAN_RES_SIZE) < rssi =< -44
// practice may require a better pair of thresholds
constexpr float HI_RSSI_THRESHOLD = -44.0;
constexpr float LO_RSSI_THRESHOLD = HI_RSSI_THRESHOLD - 66;
// number of samples for RSSI method
#define SAMPLES_RSSI 12 // 21 //
struct Scan
{
virtual float getRSSI() = 0;
// rssiMethod gets the data similar to the scan method,
// but uses getRSSI directly.
uint16_t rssiMethod(size_t samples, uint16_t *result, size_t res_size);
// detect method analyses result, and produces filtered_result, marking
// those values that represent a detection event.
// It returns index that represents strongest signal at which a detection event
// occurred.
static size_t detect(uint16_t *result, bool *filtered_result, size_t result_size,
int samples);
};
// Remove reading without neighbors
#define FILTER_SPECTRUM_RESULTS true
#endif
+1 -1
View File
@@ -1,6 +1,6 @@
#include <stdio.h>
#define LOG(args...) printf(args)
#include "../src/radioScan/radioScan.cpp"
#include "../lib/scan/scan.cpp"
#include <unity.h>
void setUp(void) {}