@@ -710,6 +710,21 @@ void TXModuleEndpoint::SetTlmRatio(uint8_t idx)
710710 }
711711}
712712
713+ void TXModuleEndpoint::SetMaxPower (uint8_t idx)
714+ {
715+ config.SetPower (idx);
716+ if (!config.IsModified ())
717+ {
718+ ResetPower ();
719+ }
720+ }
721+
722+ void TXModuleEndpoint::SetDynamicPower (uint8_t idx)
723+ {
724+ config.SetDynamicPower (idx > 0 );
725+ config.SetBoostChannel ((idx - 1 ) > 0 ? idx - 1 : 0 );
726+ }
727+
713728/* **
714729 * @brief: Update the dynamic strings used for folder names and labels
715730 ***/
@@ -885,16 +900,11 @@ void TXModuleEndpoint::registerParameters()
885900 // POWER folder
886901 registerParameter (&luaPowerFolder);
887902 filterOptions (&luaPower, POWERMGNT::getMinPower (), POWERMGNT::getMaxPower (), strPowerLevels);
888- registerParameter (&luaPower, [](propertiesCommon *item, uint8_t arg) {
889- config.SetPower ((PowerLevels_e)constrain (arg + POWERMGNT::getMinPower (), POWERMGNT::getMinPower (), POWERMGNT::getMaxPower ()));
890- if (!config.IsModified ())
891- {
892- ResetPower ();
893- }
903+ registerParameter (&luaPower, [this ](propertiesCommon *item, uint8_t arg) {
904+ SetMaxPower (constrain (arg + POWERMGNT::getMinPower (), POWERMGNT::getMinPower (), POWERMGNT::getMaxPower ()));
894905 }, luaPowerFolder.common .id );
895- registerParameter (&luaDynamicPower, [](propertiesCommon *item, uint8_t arg) {
896- config.SetDynamicPower (arg > 0 );
897- config.SetBoostChannel ((arg - 1 ) > 0 ? arg - 1 : 0 );
906+ registerParameter (&luaDynamicPower, [this ](propertiesCommon *item, uint8_t arg) {
907+ SetDynamicPower (arg);
898908 }, luaPowerFolder.common .id );
899909 }
900910 if (GPIO_PIN_FAN_EN != UNDEF_PIN || GPIO_PIN_FAN_PWM != UNDEF_PIN) {
0 commit comments