@@ -59,10 +59,10 @@ PG_REGISTER_ARRAY_WITH_RESET_FN(vtxTrampPwOverride_t, VTX_TRAMP_MAX_SUPPORTED_PW
5959
6060void pgResetFn_vtxTrampPwOverride (vtxTrampPwOverride_t * table )
6161{
62- for (int current_pw_lvl = 0 ; current_pw_lvl < VTX_TRAMP_MAX_SUPPORTED_PW_LEVELS ; current_pw_lvl ++ )
62+ for (int currentPwLvl = 0 ; currentPwLvl < VTX_TRAMP_MAX_SUPPORTED_PW_LEVELS ; currentPwLvl ++ )
6363 {
64- RESET_CONFIG (vtxTrampPwOverride_t , & table [current_pw_lvl ],
65- .vtxPwOverrideMw = -1
64+ RESET_CONFIG (vtxTrampPwOverride_t , & table [currentPwLvl ],
65+ .vtxPwOverrideMw = VTX_TRAMP_NULL_PW_CONFIG
6666 );
6767 }
6868}
@@ -576,87 +576,71 @@ static vtxDevice_t impl_vtxDevice = {
576576};
577577
578578// Backwards compatable mutable data structures to allow for configuration to be added.
579- static uint16_t mutableTablePowers [VTX_TRAMP_MAX_SUPPORTED_PW_LEVELS ];
580- #define MAX_VTX_PWR_NAME_CHARS 6
581- static char mutableTablePowerNames [VTX_TRAMP_MAX_SUPPORTED_PW_LEVELS + 1 ][MAX_VTX_PWR_NAME_CHARS ];
579+ static uint16_t mutablePowerTable [VTX_TRAMP_MAX_SUPPORTED_PW_LEVELS ];
580+ #define MAX_VTX_POWER_PLACES_DECIMAL 6
581+ static char mutablePowerTableNames [VTX_TRAMP_MAX_SUPPORTED_PW_LEVELS + 1 ][MAX_VTX_POWER_PLACES_DECIMAL + 1 ];
582582
583- // Default table power levels
583+ // Default power level tables
584584const uint16_t trampPowerTable_5G8_200 [VTX_TRAMP_5G8_MAX_POWER_COUNT ] = { 25 , 100 , 200 , 200 , 200 };
585585const uint16_t trampPowerTable_5G8_400 [VTX_TRAMP_5G8_MAX_POWER_COUNT ] = { 25 , 100 , 200 , 400 , 400 };
586586const uint16_t trampPowerTable_5G8_600 [VTX_TRAMP_5G8_MAX_POWER_COUNT ] = { 25 , 100 , 200 , 400 , 600 };
587587const uint16_t trampPowerTable_5G8_800 [VTX_TRAMP_5G8_MAX_POWER_COUNT ] = { 25 , 100 , 200 , 500 , 800 };
588588const uint16_t trampPowerTable_1G3_800 [VTX_TRAMP_1G3_MAX_POWER_COUNT ] = { 25 , 200 , 800 };
589589const uint16_t trampPowerTable_1G3_2000 [VTX_TRAMP_1G3_MAX_POWER_COUNT ] = { 25 , 200 , 2000 };
590590
591- // Dump the VTX operating params to the console. Used for configuration validation to ensure that the VTX is being commanded as
592- // expected. Used to debug VTX issues such as inconsistent power levels (IE command 1 mw for first power, 2 mw for second, etc),
593- // frequency issues (commanded != requested), etc. This does require that the CLI serial interface is exposed, but better that than
594- // exposing the VTX driver internals to the CLI.
595591void dumpLiveVtxTrampConfig (consolePrintf_t consolePrint )
596592{
597- // Dump configuration
598- consolePrint ("Configured power levels: %d\n" , impl_vtxDevice .capability .powerCount );
593+ consolePrint ("PLs Configured: %d\n" , impl_vtxDevice .capability .powerCount );
599594 for (uint8_t current_pl = 0 ; current_pl < VTX_TRAMP_MAX_SUPPORTED_PW_LEVELS ; current_pl ++ )
600595 {
601- consolePrint ("PL %d: %d mw\n" , current_pl + 1 , mutableTablePowers [current_pl ]);
596+ consolePrint ("PL %d: %d mw\n" , current_pl + 1 , mutablePowerTable [current_pl ]);
602597 }
603598
604- consolePrint ("Actual VTX Freq: %u\n" , vtxState .state .freq );
605- consolePrint ("Actual VTX Power: %u\n" , vtxState .state .power );
599+ const char actual [] = "Act" ;
600+ const char req [] = "Req" ;
601+ const char pwr [] = "Pwr" ;
602+ const char freq [] = "Freq" ;
603+ consolePrint ("%s %s: %u\n" , actual , freq , vtxState .state .freq );
604+ consolePrint ("%s %s: %u\n" , actual , pwr , vtxState .state .power );
606605
607- consolePrint ("Requested VTX Freq : %u\n" , vtxState .request .freq );
608- consolePrint ("Requested VTX Power : %u\n" , vtxState .request .power );
609- consolePrint ("Requested VTX Power IDX: %u\n" , vtxState .request .powerIndex );
606+ consolePrint ("%s %s : %u\n" , req , freq , vtxState .request .freq );
607+ consolePrint ("%s %s : %u\n" , req , pwr , vtxState .request .power );
608+ consolePrint ("%s %s IDX: %u\n" , req , pwr , vtxState .request .powerIndex );
610609}
611610
612- // Construct the power table. Takes into account any configured override power values.
613- // baseTable - Pointer to the base table configuration
614- // tableCount - Entries in the table configuration
615- static void constructPowerTable (const uint16_t * baseTable , const uint16_t tableCount )
611+ static void constructPowerTable (const uint16_t * defaultTable , const uint16_t defaultTableSize )
616612{
617- // Update the 0th power index
618- strcpy (mutableTablePowerNames [0 ], "---" );
613+ // Update the 0th power index to the common start entry string
614+ strcpy (mutablePowerTableNames [0 ], "---" );
619615
620616 // Now construct each table
621- const vtxTrampPwOverride_t * pwr_config ;
617+ const vtxTrampPwOverride_t * pwrConfig ;
622618 uint16_t currentPwLvl = 0 ;
623619 for (currentPwLvl = 0 ; currentPwLvl < VTX_TRAMP_MAX_SUPPORTED_PW_LEVELS ; currentPwLvl ++ )
624620 {
625- pwr_config = vtxTrampPwOverride (currentPwLvl );
626- if (pwr_config -> vtxPwOverrideMw >= 0 )
621+ pwrConfig = vtxTrampPwOverride (currentPwLvl );
622+ // If user defined table entry contains valid data, use it in place of the default
623+ if (pwrConfig -> vtxPwOverrideMw >= 0 )
627624 {
628- // Only override if power is configured to a valid value. If negative, this value is not configured and
629- // will be set to the default table for the power level.
630- mutableTablePowers [currentPwLvl ] = (uint16_t ) pwr_config -> vtxPwOverrideMw ;
625+ mutablePowerTable [currentPwLvl ] = (uint16_t ) pwrConfig -> vtxPwOverrideMw ;
631626 }
632-
633- else if (currentPwLvl < tableCount )
627+ // Otherwise, use the default's entry.
628+ else if (currentPwLvl < defaultTableSize )
634629 {
635- // Not configured, so use the default.
636- mutableTablePowers [currentPwLvl ] = * (baseTable + currentPwLvl );
630+ mutablePowerTable [currentPwLvl ] = * (defaultTable + currentPwLvl );
637631 }
638632 else
639633 {
640- // No default value and no configured value. Nothing to write, so terminate from the loop.
641634 break ;
642635 }
643636
644- // Update the "stringified" power. Always add 1 to the working power level since 0 is reserved.
645- sprintf (mutableTablePowerNames [currentPwLvl + 1 ], "%u" , mutableTablePowers [currentPwLvl ]);
637+ sprintf (mutablePowerTableNames [currentPwLvl + 1 ], "%u" , mutablePowerTable [currentPwLvl ]);
646638 }
647639
648- // Update the stored params.
649- vtxState .metadata .powerTablePtr = mutableTablePowers ;
650-
651- // NOTE: If loop broke before max (IE 2 overrides and three default, < 5, idx = 3) the last loop index will be the total
652- // quantity configured. Set that here.
653640 vtxState .metadata .powerTableCount = currentPwLvl ;
654-
655- impl_vtxDevice .capability .powerNames = (char * * ) mutableTablePowerNames ;
641+ vtxState .metadata .powerTablePtr = mutablePowerTable ;
656642 impl_vtxDevice .capability .powerCount = currentPwLvl ;
657-
658- // NOTE: If less power levels than max supported are passed, then the upper values in the config are left as-is.
659- // The result is that they are not used.
643+ impl_vtxDevice .capability .powerNames = (char * * ) mutablePowerTableNames ;
660644}
661645
662646static void vtxProtoUpdatePowerMetadata (uint16_t maxPower )
0 commit comments