Store SX127X tx power in variable, attempt to fix #39

This commit is contained in:
jacob.eva 2024-10-12 22:26:42 +01:00
parent c7e24f7966
commit 858a35b2f9
No known key found for this signature in database
GPG Key ID: 0B92E083BBCCAA1E
2 changed files with 12 additions and 12 deletions

View File

@ -119,7 +119,7 @@ sx126x::sx126x(uint8_t index, SPIClass* spi, bool tcxo, bool dio2_as_rf_switch,
RadioInterface(index), RadioInterface(index),
_spiSettings(8E6, MSBFIRST, SPI_MODE0), _spiModem(spi), _ss(ss), _spiSettings(8E6, MSBFIRST, SPI_MODE0), _spiModem(spi), _ss(ss),
_sclk(sclk), _mosi(mosi), _miso(miso), _reset(reset), _dio0(dio0), _sclk(sclk), _mosi(mosi), _miso(miso), _reset(reset), _dio0(dio0),
_busy(busy), _rxen(rxen), _frequency(0), _txp(0), _sf(0x07), _bw(0x04), _busy(busy), _rxen(rxen), _frequency(0), _sf(0x07), _bw(0x04),
_cr(0x01), _ldro(0x00), _packetIndex(0), _implicitHeaderMode(0), _cr(0x01), _ldro(0x00), _packetIndex(0), _implicitHeaderMode(0),
_payloadLength(255), _crcMode(1), _fifo_tx_addr_ptr(0), _payloadLength(255), _crcMode(1), _fifo_tx_addr_ptr(0),
_fifo_rx_addr_ptr(0), _preinit_done(false), _tcxo(tcxo), _fifo_rx_addr_ptr(0), _preinit_done(false), _tcxo(tcxo),
@ -793,7 +793,7 @@ void sx126x::setTxPower(int level, int outputPin) {
executeOpcode(OP_TX_PARAMS_6X, tx_buf, 2); executeOpcode(OP_TX_PARAMS_6X, tx_buf, 2);
} }
uint8_t sx126x::getTxPower() { int8_t sx126x::getTxPower() {
return _txp; return _txp;
} }
@ -1384,9 +1384,10 @@ void sx127x::setTxPower(int level, int outputPin) {
writeRegister(REG_PA_DAC_7X, 0x84); writeRegister(REG_PA_DAC_7X, 0x84);
writeRegister(REG_PA_CONFIG_7X, PA_BOOST_7X | (level - 2)); writeRegister(REG_PA_CONFIG_7X, PA_BOOST_7X | (level - 2));
} }
_txp = level;
} }
uint8_t sx127x::getTxPower() { byte txp = readRegister(REG_PA_CONFIG_7X); return txp; } int8_t sx127x::getTxPower() { return _txp; }
void sx127x::setFrequency(uint32_t frequency) { void sx127x::setFrequency(uint32_t frequency) {
_frequency = frequency; _frequency = frequency;
@ -1617,7 +1618,7 @@ sx128x::sx128x(uint8_t index, SPIClass* spi, bool tcxo, int ss, int sclk, int mo
_spiSettings(8E6, MSBFIRST, SPI_MODE0), _spiSettings(8E6, MSBFIRST, SPI_MODE0),
_spiModem(spi), _spiModem(spi),
_ss(ss), _sclk(sclk), _mosi(mosi), _miso(miso), _reset(reset), _dio0(dio0), _ss(ss), _sclk(sclk), _mosi(mosi), _miso(miso), _reset(reset), _dio0(dio0),
_busy(busy), _rxen(rxen), _txen(txen), _frequency(0), _txp(0), _sf(0x05), _busy(busy), _rxen(rxen), _txen(txen), _frequency(0), _sf(0x05),
_bw(0x34), _cr(0x01), _packetIndex(0), _implicitHeaderMode(0), _bw(0x34), _cr(0x01), _packetIndex(0), _implicitHeaderMode(0),
_payloadLength(255), _crcMode(0), _fifo_tx_addr_ptr(0), _fifo_rx_addr_ptr(0), _payloadLength(255), _crcMode(0), _fifo_tx_addr_ptr(0), _fifo_rx_addr_ptr(0),
_rxPacketLength(0), _preinit_done(false), _rxPacketLength(0), _preinit_done(false),
@ -2445,7 +2446,7 @@ void sx128x::setTxPower(int level, int outputPin) {
executeOpcode(OP_TX_PARAMS_8X, tx_buf, 2); executeOpcode(OP_TX_PARAMS_8X, tx_buf, 2);
} }
uint8_t sx128x::getTxPower() { int8_t sx128x::getTxPower() {
return _txp; return _txp;
} }

View File

@ -76,7 +76,7 @@ public:
_post_tx_yield_timeout(0), _csma_slot_ms(50), _csma_p(85), _csma_p_min(0.15), _post_tx_yield_timeout(0), _csma_slot_ms(50), _csma_p(85), _csma_p_min(0.15),
_csma_p_max(0.333), _csma_b_speed(0.15), _preambleLength(6), _lora_symbol_time_ms(0.0), _csma_p_max(0.333), _csma_b_speed(0.15), _preambleLength(6), _lora_symbol_time_ms(0.0),
_lora_symbol_rate(0.0), _lora_us_per_byte(0.0), _bitrate(0), _lora_symbol_rate(0.0), _lora_us_per_byte(0.0), _bitrate(0),
_packet{0}, _onReceive(NULL) {}; _packet{0}, _onReceive(NULL), _txp(0) {};
virtual int begin() = 0; virtual int begin() = 0;
virtual void end() = 0; virtual void end() = 0;
@ -108,7 +108,7 @@ public:
virtual void sleep() = 0; virtual void sleep() = 0;
virtual bool preInit() = 0; virtual bool preInit() = 0;
virtual uint8_t getTxPower() = 0; virtual int8_t getTxPower() = 0;
virtual void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN) = 0; virtual void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN) = 0;
virtual uint32_t getFrequency() = 0; virtual uint32_t getFrequency() = 0;
virtual void setFrequency(uint32_t frequency) = 0; virtual void setFrequency(uint32_t frequency) = 0;
@ -296,6 +296,7 @@ protected:
virtual void implicitHeaderMode() = 0; virtual void implicitHeaderMode() = 0;
uint8_t _index; uint8_t _index;
int8_t _txp;
bool _radio_locked; bool _radio_locked;
bool _radio_online; bool _radio_online;
float _st_airtime_limit; float _st_airtime_limit;
@ -371,7 +372,7 @@ public:
void sleep(); void sleep();
bool preInit(); bool preInit();
uint8_t getTxPower(); int8_t getTxPower();
void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN); void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN);
uint32_t getFrequency(); uint32_t getFrequency();
void setFrequency(uint32_t frequency); void setFrequency(uint32_t frequency);
@ -439,7 +440,6 @@ private:
int _rxen; int _rxen;
int _busy; int _busy;
uint32_t _frequency; uint32_t _frequency;
int _txp;
uint8_t _sf; uint8_t _sf;
uint8_t _bw; uint8_t _bw;
uint8_t _cr; uint8_t _cr;
@ -491,7 +491,7 @@ public:
void sleep(); void sleep();
bool preInit(); bool preInit();
uint8_t getTxPower(); int8_t getTxPower();
void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN); void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN);
uint32_t getFrequency(); uint32_t getFrequency();
void setFrequency(uint32_t frequency); void setFrequency(uint32_t frequency);
@ -585,7 +585,7 @@ public:
void sleep(); void sleep();
bool preInit(); bool preInit();
uint8_t getTxPower(); int8_t getTxPower();
void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN); void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN);
uint32_t getFrequency(); uint32_t getFrequency();
void setFrequency(uint32_t frequency); void setFrequency(uint32_t frequency);
@ -653,7 +653,6 @@ private:
int _busy; int _busy;
int _modem; int _modem;
uint32_t _frequency; uint32_t _frequency;
int _txp;
uint8_t _sf; uint8_t _sf;
uint8_t _bw; uint8_t _bw;
uint8_t _cr; uint8_t _cr;