mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-28 07:13:25 +00:00
Merge branch 'develop' into 7943-mute-target
This commit is contained in:
commit
a8a6644192
@ -117,6 +117,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define SX126X_MAX_POWER 22
|
#define SX126X_MAX_POWER 22
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HELTEC_V4
|
||||||
|
// Power Amps are often non-linear, so we can use an array of values for the power curve
|
||||||
|
#define NUM_PA_POINTS 22
|
||||||
|
#define TX_GAIN_LORA 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 10, 10, 9, 9, 8, 7
|
||||||
|
#endif
|
||||||
|
|
||||||
// Default system gain to 0 if not defined
|
// Default system gain to 0 if not defined
|
||||||
#ifndef TX_GAIN_LORA
|
#ifndef TX_GAIN_LORA
|
||||||
#define TX_GAIN_LORA 0
|
#define TX_GAIN_LORA 0
|
||||||
|
|||||||
@ -674,11 +674,25 @@ void RadioInterface::limitPower(int8_t loraMaxPower)
|
|||||||
power = maxPower;
|
power = maxPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NUM_PA_POINTS
|
||||||
if (TX_GAIN_LORA > 0) {
|
if (TX_GAIN_LORA > 0) {
|
||||||
LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, TX_GAIN_LORA);
|
LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, TX_GAIN_LORA);
|
||||||
power -= TX_GAIN_LORA;
|
power -= TX_GAIN_LORA;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// we have an array of PA gain values. Find the highest power setting that works.
|
||||||
|
const uint16_t tx_gain[NUM_PA_POINTS] = {TX_GAIN_LORA};
|
||||||
|
for (int radio_dbm = 0; radio_dbm < NUM_PA_POINTS; radio_dbm++) {
|
||||||
|
if (((radio_dbm + tx_gain[radio_dbm]) > power) ||
|
||||||
|
((radio_dbm == (NUM_PA_POINTS - 1)) && ((radio_dbm + tx_gain[radio_dbm]) <= power))) {
|
||||||
|
// we've exceeded the power limit, or hit the max we can do
|
||||||
|
LOG_INFO("Requested Tx power: %d dBm; Device LoRa Tx gain: %d dB", power, tx_gain[radio_dbm]);
|
||||||
|
power -= tx_gain[radio_dbm];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
if (power > loraMaxPower) // Clamp power to maximum defined level
|
if (power > loraMaxPower) // Clamp power to maximum defined level
|
||||||
power = loraMaxPower;
|
power = loraMaxPower;
|
||||||
|
|
||||||
|
|||||||
@ -80,6 +80,9 @@ template <typename T> bool SX126xInterface<T>::init()
|
|||||||
RadioLibInterface::init();
|
RadioLibInterface::init();
|
||||||
|
|
||||||
limitPower(SX126X_MAX_POWER);
|
limitPower(SX126X_MAX_POWER);
|
||||||
|
// Make sure we reach the minimum power supported to turn the chip on (-9dBm)
|
||||||
|
if (power < -9)
|
||||||
|
power = -9;
|
||||||
|
|
||||||
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage, useRegulatorLDO);
|
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage, useRegulatorLDO);
|
||||||
// \todo Display actual typename of the adapter, not just `SX126x`
|
// \todo Display actual typename of the adapter, not just `SX126x`
|
||||||
@ -118,8 +121,8 @@ template <typename T> bool SX126xInterface<T>::init()
|
|||||||
LOG_DEBUG("Set DIO2 as %sRF switch, result: %d", dio2AsRfSwitch ? "" : "not ", res);
|
LOG_DEBUG("Set DIO2 as %sRF switch, result: %d", dio2AsRfSwitch ? "" : "not ", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a pin isn't defined, we set it to RADIOLIB_NC, it is safe to always do external RF switching with RADIOLIB_NC as it has
|
// If a pin isn't defined, we set it to RADIOLIB_NC, it is safe to always do external RF switching with RADIOLIB_NC as it has
|
||||||
// no effect
|
// no effect
|
||||||
#if ARCH_PORTDUINO
|
#if ARCH_PORTDUINO
|
||||||
if (res == RADIOLIB_ERR_NONE) {
|
if (res == RADIOLIB_ERR_NONE) {
|
||||||
LOG_DEBUG("Use MCU pin %i as RXEN and pin %i as TXEN to control RF switching", portduino_config.lora_rxen_pin.pin,
|
LOG_DEBUG("Use MCU pin %i as RXEN and pin %i as TXEN to control RF switching", portduino_config.lora_rxen_pin.pin,
|
||||||
|
|||||||
@ -8,4 +8,3 @@ build_flags =
|
|||||||
-D HELTEC_V4
|
-D HELTEC_V4
|
||||||
-I variants/esp32s3/heltec_v4
|
-I variants/esp32s3/heltec_v4
|
||||||
-D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
|
-D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely.
|
||||||
-D SX126X_MAX_POWER=11
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user