diff --git a/applications/main/subghz/helpers/subghz_txrx.c b/applications/main/subghz/helpers/subghz_txrx.c index 46d0a7eef..93f197399 100644 --- a/applications/main/subghz/helpers/subghz_txrx.c +++ b/applications/main/subghz/helpers/subghz_txrx.c @@ -110,25 +110,45 @@ void subghz_txrx_set_preset( uint8_t* subghz_txrx_set_tx_power(uint8_t* preset_data, size_t preset_data_size, uint32_t tx_power) { -#define TX_POWER_OFFSET 7 -#define TX_PRESET_POWER_COUNT 11 - const uint32_t tx_power_value[TX_PRESET_POWER_COUNT] = { +#define TX_POWER_OFFSET_FM 8 +#define TX_POWER_OFFSET_AM 7 +#define TX_PRESET_POWER_COUNT 9 + //I had to skip the +10dBM and -6dBm Values, use only ones AM/FM have in common. + //Highest Value is 12dBm for AM, 10 for FM. So Menu needs to reflect that. + const uint8_t tx_power_value_AM[TX_PRESET_POWER_COUNT] = { 0, - 0xC0, - 0xC5, - 0xCD, - 0x86, - 0x50, - 0x37, - 0x26, - 0x1D, - 0x17, - 0x03, + 0xC0, //12dBm + 0xCD, //7dBm + 0x86, //5dBm + 0x50, //0dBm + 0x26, // -10dBm + 0x1D, // -15dBm + 0x17, //-20dBm + 0x03 //-30dBm + }; + + //FM PATable Values. We have 8, not 10 (missing 12dBM and -6dBm that are in AM) + const uint8_t tx_power_value_FM[TX_PRESET_POWER_COUNT] = { + 0, + 0xC0, // 10dBm + 0xC8, //7dBm + 0x84, //5dBm + 0x60, //0dBm + 0x34, //-10dBm + 0x1D, //-15dBm + 0x0E, // -20dBm + 0x12, //-30dBm }; //Set the TX Power Here in the CC1101 register... - if(tx_power) - preset_data[preset_data_size - TX_POWER_OFFSET] = (uint8_t)tx_power_value[tx_power]; + if(tx_power) { + //Are we on an AM or FM preset? The PA table is different! + if(preset_data[preset_data_size - TX_POWER_OFFSET_FM]) { + preset_data[preset_data_size - TX_POWER_OFFSET_FM] = tx_power_value_FM[tx_power]; + } else if(preset_data[preset_data_size - TX_POWER_OFFSET_AM]) { + preset_data[preset_data_size - TX_POWER_OFFSET_AM] = tx_power_value_AM[tx_power]; + } //else //Must be a custom Preset with weird PA table not in FW code, dont touch it. + } //Pass back the preset_so we can call one liners. return preset_data; diff --git a/applications/main/subghz/scenes/subghz_scene_radio_settings.c b/applications/main/subghz/scenes/subghz_scene_radio_settings.c index 87e2d8269..be75723be 100644 --- a/applications/main/subghz/scenes/subghz_scene_radio_settings.c +++ b/applications/main/subghz/scenes/subghz_scene_radio_settings.c @@ -67,15 +67,13 @@ const int32_t debug_counter_val[DEBUG_COUNTER_COUNT] = { }; //TX Power -#define TX_POWER_COUNT 11 +#define TX_POWER_COUNT 9 const char* const tx_power_text[TX_POWER_COUNT] = { "Preset", - "12dBm", - "10dBm", + "10dBm +", "7dBm", "5dBm", "0dBm", - "-6dBm", "-10dBm", "-15dBm", "-20dBm",