Fix and normalize TX power levels.

This commit is contained in:
Nunu 2023-12-30 13:06:33 +01:00
parent 99f6bc0e9e
commit d0e06c4b0c
4 changed files with 22 additions and 45 deletions

View File

@ -44,7 +44,7 @@ ENABLE_RSSI_BAR := 1
ENABLE_AUDIO_BAR := 1
ENABLE_COPY_CHAN_TO_VFO := 1
ENABLE_SPECTRUM := 1
ENABLE_REDUCE_LOW_MID_TX_POWER := 1
ENABLE_REDUCE_LOW_POWER := 1
ENABLE_BYP_RAW_DEMODULATORS := 0
ENABLE_BLMIN_TMP_OFF := 0
ENABLE_SCAN_RANGES := 1
@ -350,8 +350,8 @@ endif
ifeq ($(ENABLE_BAND_SCOPE),1)
CFLAGS += -DENABLE_BAND_SCOPE
endif
ifeq ($(ENABLE_REDUCE_LOW_MID_TX_POWER),1)
CFLAGS += -DENABLE_REDUCE_LOW_MID_TX_POWER
ifeq ($(ENABLE_REDUCE_LOW_POWER),1)
CFLAGS += -DENABLE_REDUCE_LOW_POWER
endif
ifeq ($(ENABLE_BYP_RAW_DEMODULATORS),1)
CFLAGS += -DENABLE_BYP_RAW_DEMODULATORS

View File

@ -141,7 +141,7 @@ ENABLE_RSSI_BAR := 1 enable a dBm/Sn RSSI bar graph lev
ENABLE_AUDIO_BAR := 1 experimental, display an audio bar level when TX'ing
ENABLE_COPY_CHAN_TO_VFO := 1 copy current channel into the other VFO. Long press `1 BAND` when in channel mode
ENABLE_SPECTRUM := 1 fagci spectrum analyzer, activated with `F` + `5 NOAA`
ENABLE_REDUCE_LOW_MID_TX_POWER := 1 makes medium and low power settings even lower
ENABLE_REDUCE_LOW_POWER := 1 makes low power settings even lower
ENABLE_BYP_RAW_DEMODULATORS := 0 additional BYP (bypass?) and RAW demodulation options, proved not to be very useful, but it is there if you want to experiment
ENABLE_BLMIN_TMP_OFF := 0 additional function for configurable buttons that toggles `BLMin` on and off wihout saving it to the EEPROM
ENABLE_SCAN_RANGES := 1 scan range mode for frequency scanning, see wiki for instructions (radio operation -> frequency scanning)

View File

@ -656,38 +656,20 @@ void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const b
BK4819_WriteRegister(BK4819_REG_43, val);
}
void BK4819_SetupPowerAmplifier(const uint8_t bias, const uint32_t frequency)
{
// REG_36 <15:8> 0 PA Bias output 0 ~ 3.2V
// 255 = 3.2V
// 0 = 0V
//
// REG_36 <7> 0
// 1 = Enable PA-CTL output
// 0 = Disable (Output 0 V)
//
// REG_36 <5:3> 7 PA gain 1 tuning
// 7 = max
// 0 = min
//
// REG_36 <2:0> 7 PA gain 2 tuning
// 7 = max
// 0 = min
//
// 280MHz gain 1 = 1 gain 2 = 0 gain 1 = 4 gain 2 = 2
const uint8_t enable = 1;
void BK4819_SetupPowerAmplifier(uint8_t Bias, uint32_t Frequency) {
uint8_t Gain;
#ifdef ENABLE_ULTRA_LOW_POWER_TX
uint8_t gain = (frequency < 28000000) ? (1u << 3) | (0u << 0) : (4u << 3) | (2u << 0);
gain = 0b000010;
(void)bias;
(void)frequency;
BK4819_WriteRegister(BK4819_REG_36, (16 << 8) | (enable << 7) | (gain << 0));
#else
const uint8_t gain = (frequency < 28000000) ? (1u << 3) | (0u << 0) : (4u << 3) | (2u << 0);
BK4819_WriteRegister(BK4819_REG_36, (bias << 8) | (enable << 7) | (gain << 0));
#endif
if (Frequency < 28000000) {
// Gain 1 = 1
// Gain 2 = 0
Gain = 0x08U;
} else {
// Gain 1 = 4
// Gain 2 = 2
Gain = 0x22U;
}
// Enable PACTLoutput
BK4819_WriteRegister(BK4819_REG_36, (Bias << 8) | 0x80U | Gain);
}
void BK4819_SetFrequency(uint32_t Frequency)

15
radio.c
View File

@ -496,17 +496,12 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo)
EEPROM_ReadBuffer(0x1ED0 + (Band * 16) + (pInfo->OUTPUT_POWER * 3), Txp, 3);
#ifdef ENABLE_REDUCE_LOW_MID_TX_POWER
// make low and mid even lower
#ifdef ENABLE_REDUCE_LOW_POWER
// make low even lower
if (pInfo->OUTPUT_POWER == OUTPUT_POWER_LOW) {
Txp[0] /= 5;
Txp[1] /= 5;
Txp[2] /= 5;
}
else if (pInfo->OUTPUT_POWER == OUTPUT_POWER_MID){
Txp[0] /= 3;
Txp[1] /= 3;
Txp[2] /= 3;
Txp[0] /= 2;
Txp[1] /= 2;
Txp[2] /= 2;
}
#endif