Merge pull request #7569 from jflyper/bfdev-tramp-vtxtable-fix

[VTXTABLE, TRAMP] Fix power index handling
This commit is contained in:
Michael Keller 2019-02-14 20:49:16 +13:00 committed by GitHub
commit fc8f9130e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 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

@ -165,7 +165,7 @@ static bool trampValidateBandAndChannel(uint8_t band, uint8_t channel)
static void trampDevSetBandAndChannel(uint8_t band, uint8_t channel)
{
trampDevSetFreq(vtxCommonLookupFrequency(vtxCommonDevice(), band, channel));
trampDevSetFreq(vtxCommonLookupFrequency(&vtxTramp, band, channel));
}
void trampSetBandAndChannel(uint8_t band, uint8_t channel)
@ -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;
}
@ -244,7 +244,7 @@ static char trampHandleResponse(void)
trampPower = trampRespBuffer[8]|(trampRespBuffer[9] << 8);
// if no band/chan match then make sure set-by-freq mode is flagged
if (!vtxCommonLookupBandChan(vtxCommonDevice(), trampCurFreq, &trampBand, &trampChannel)) {
if (!vtxCommonLookupBandChan(&vtxTramp, trampCurFreq, &trampBand, &trampChannel)) {
trampSetByFreqFlag = 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;
}