Fix power indexhandling

This commit is contained in:
jflyper 2019-02-13 05:29:55 +09:00
parent 038d3969e9
commit d3d111dbb6
2 changed files with 7 additions and 5 deletions

View File

@ -181,7 +181,9 @@ static void trampCmsInitSettings(void)
trampCmsPitMode = trampPitMode + 1;
if (trampConfiguredPower > 0) {
trampCmsPower = vtxCommonGetPowerIndex(vtxCommonDevice(), &trampCmsPower);
if (!vtxCommonGetPowerIndex(vtxCommonDevice(), &trampCmsPower)) {
trampCmsPower = 1;
}
}
vtxDevice_t *device = vtxCommonDevice();

View File

@ -201,8 +201,8 @@ bool trampCommitChanges(void)
// return false if index out of range
static bool trampDevSetPowerByIndex(uint8_t index)
{
if (index > 0 && index <= sizeof(trampPowerTable)) {
trampSetRFPower(trampPowerTable[index - 1]);
if (index > 0 && index <= vtxTramp.capability.powerCount) {
trampSetRFPower(vtxTramp.powerValues[index - 1]);
trampCommitChanges();
return true;
}
@ -552,8 +552,8 @@ static bool vtxTrampGetPowerIndex(const vtxDevice_t *vtxDevice, uint8_t *pIndex)
}
if (trampConfiguredPower > 0) {
for (uint8_t i = 0; i < sizeof(trampPowerTable); i++) {
if (trampConfiguredPower <= trampPowerTable[i]) {
for (uint8_t i = 0; i < vtxTramp.capability.powerCount; i++) {
if (trampConfiguredPower <= vtxTramp.powerValues[i]) {
*pIndex = i + 1;
break;
}