configurable RX and AFC bandwidth; configuration display of AFC value

This commit is contained in:
Hansi, dl9rdz 2019-05-06 01:18:41 +02:00
parent 00e67ac018
commit 3549ab21cf
7 changed files with 68 additions and 3 deletions

View File

@ -363,6 +363,7 @@ struct st_configitems config_list[] = {
{"timer", "Spectrum Timer", 0, &sonde.config.timer},
{"marker", "Spectrum MHz marker", 0, &sonde.config.marker},
{"noisefloor", "Sepctrum noisefloor", 0, &sonde.config.noisefloor},
{"showafc", "Show AFC value", 0, &sonde.config.showafc},
{"---", "---", -1, NULL},
/* APRS settings */
{"call", "Call", 8, sonde.config.call},
@ -382,6 +383,10 @@ struct st_configitems config_list[] = {
{"tcp.idformat", "DFM ID Format", -2, &sonde.config.tcpfeed.idformat},
{"tcp.highrate", "Rate limit", 0, &sonde.config.tcpfeed.highrate},
{"---", "---", -1, NULL},
/* RS41 decoder settings */
{"rs41.agcbw", "RS41 AGC bandwidth", 0, &sonde.config.rs41.agcbw},
{"rs41.rxbw", "RS41 RX bandwidth", 0, &sonde.config.rs41.rxbw},
{"---", "---", -1, NULL},
/* Hardware dependeing settings */
{"oled_sda", "OLED SDA (needs reboot)", 0, &sonde.config.oled_sda},
{"oled_scl", "OLED SCL (needs reboot)", 0, &sonde.config.oled_scl},

View File

@ -1,2 +1,2 @@
const char *version_name = "RDZ_TTGO_SONDE";
const char *version_id = "devel20190503";
const char *version_id = "devel20190506";

View File

@ -533,6 +533,30 @@ int16_t SX1278FSK::getRSSI()
return RSSI;
}
/*
Function: Gets the current value of FEI (frequency error indication)
Returns: FEI value in Hz
*/
int32_t SX1278FSK::getFEI()
{
int32_t FEI;
int16_t regval = (readRegister(REG_FEI_MSB)<<8) | readRegister(REG_FEI_LSB);
Serial.printf("feireg: %04x\n", regval);
FEI = (int32_t)(regval * SX127X_FSTEP);
return FEI;
}
/*
Function: Gets the current value of AFC (automated frequency correction)
Returns: AFC value in Hz
*/
int32_t SX1278FSK::getAFC()
{
int32_t AFC;
int16_t regval = (readRegister(REG_AFC_MSB)<<8) | readRegister(REG_AFC_LSB);
Serial.printf("afcreg: %04x\n", regval);
AFC = (int32_t)(regval * SX127X_FSTEP);
return AFC;
}
/*
Function: Gets the current supply limit of the power amplifier, protecting battery chemistries.
@ -693,8 +717,13 @@ uint8_t SX1278FSK::receivePacketTimeout(uint32_t wait, byte *data)
data[di++] = readRegister(REG_FIFO);
if(di==1) {
int rssi=getRSSI();
int fei=getFEI();
int afc=getAFC();
Serial.print("Test: RSSI="); Serial.println(rssi);
Serial.print("Test: FEI="); Serial.println(fei);
Serial.print("Test: AFC="); Serial.println(afc);
sonde.si()->rssi = rssi;
sonde.si()->afc = afc;
}
if(di>520) {
// TODO

View File

@ -31,6 +31,7 @@
*****************************************************************************/
#define SX127X_CRYSTAL_FREQ 32000000
#define SX127X_FSTEP (SX127X_CRYSTAL_FREQ*1.0/(1<<19))
#define SX1278FSK_debug_mode 0
@ -234,6 +235,12 @@ public:
// Get current RSSI value
int16_t getRSSI();
// Get current FEI (frequency error indication) value
int32_t getFEI();
// Get current AFC value
int32_t getAFC();
// Get the maximum current supply by the module.
int getMaxCurrent();

View File

@ -98,11 +98,11 @@ int RS41::setup()
Serial.println(br);
#endif
if(sx1278.setAFCBandwidth(25000)!=0) {
if(sx1278.setAFCBandwidth(sonde.config.rs41.agcbw)!=0) {
RS41_DBG(Serial.println("Setting AFC bandwidth 25 kHz FAILED"));
return 1;
}
if(sx1278.setRxBandwidth(12000)!=0) {
if(sx1278.setRxBandwidth(sonde.config.rs41.rxbw)!=0) {
RS41_DBG(Serial.println("Setting RX bandwidth 12kHz FAILED"));
return 1;
}

View File

@ -74,6 +74,9 @@ Sonde::Sonde() {
config.spectrum=10;
config.timer=0;
config.marker=0;
config.norx_timeout=0;
config.rs41.agcbw=25;
config.rs41.rxbw=12;
config.udpfeed.active = 1;
config.udpfeed.type = 0;
strcpy(config.udpfeed.host, "192.168.42.20");
@ -135,6 +138,14 @@ void Sonde::setConfig(const char *cfg) {
config.timer = atoi(val);
} else if(strcmp(cfg,"marker")==0) {
config.marker = atoi(val);
} else if(strcmp(cfg,"norx_timeout")==0) {
config.norx_timeout = atoi(val);
} else if(strcmp(cfg,"showafc")==0) {
config.showafc = atoi(val);
} else if(strcmp(cfg,"rs41.agcbw")==0) {
config.rs41.agcbw = atoi(val);
} else if(strcmp(cfg,"rs41.rxbw")==0) {
config.rs41.rxbw = atoi(val);
} else if(strcmp(cfg,"axudp.active")==0) {
config.udpfeed.active = atoi(val)>0;
} else if(strcmp(cfg,"axudp.host")==0) {
@ -317,6 +328,10 @@ void Sonde::updateDisplayRXConfig() {
u8x8->drawString(0,0, sondeTypeStr[si()->type]);
snprintf(buf, 16, "%3.3f MHz", si()->freq);
u8x8->drawString(5,0, buf);
if(config.showafc) {
snprintf(buf, 15, " %+3.2fk", si()->afc*0.001);
u8x8->drawString(8,1,buf+strlen(buf)-8);
}
//snprintf(buf, 8, "%s", si()->launchsite);
//u8x8->drawString(0,5, buf);
}

View File

@ -12,6 +12,11 @@ enum RxResult { RX_OK, RX_TIMEOUT, RX_ERROR, RX_UNKNOWN };
enum SondeType { STYPE_DFM06, STYPE_DFM09, STYPE_RS41 };
extern const char *sondeTypeStr[5];
struct st_rs41config {
int agcbw;
int rxbw;
};
typedef struct st_rdzconfig {
int button_pin; // PIN port number menu button (for some boards)
int led_pout; // POUT port number of LED (used as serial monitor)
@ -27,9 +32,12 @@ typedef struct st_rdzconfig {
int timer; // show remaining time in spectrum 0=disable
int marker; // show freq marker in spectrum 0=disable
int maxsonde; // number of max sonde in scan (range=1-99)
int norx_timeout; // Time after which rx mode switches to scan mode (without rx signal)
int noisefloor; // for spectrum display
int showafc; // show afc value in rx screen
char call[9]; // APRS callsign
char passcode[9]; // APRS passcode
struct st_rs41config rs41; // configuration options specific for RS41 receiver
// for now, one feed for each type is enough, but might get extended to more?
struct st_feedinfo udpfeed; // target for AXUDP messages
struct st_feedinfo tcpfeed; // target for APRS-IS TCP connections
@ -54,6 +62,7 @@ typedef struct st_sondeinfo {
uint8_t validPos; // bit pattern for validity of above 6 fields
// RSSI from receiver
int rssi; // signal strength
int32_t afc; // afc correction value
uint8_t rxStat[20];
} SondeInfo;
// rxState: 0=undef[empty] 1=timeout[.] 2=errro[E] 3=ok[1]