mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 01:05:27 +03:00
Merge pull request #7569 from jflyper/bfdev-tramp-vtxtable-fix
[VTXTABLE, TRAMP] Fix power index handling
This commit is contained in:
commit
fc8f9130e4
2 changed files with 9 additions and 7 deletions
|
@ -181,7 +181,9 @@ static void trampCmsInitSettings(void)
|
||||||
trampCmsPitMode = trampPitMode + 1;
|
trampCmsPitMode = trampPitMode + 1;
|
||||||
|
|
||||||
if (trampConfiguredPower > 0) {
|
if (trampConfiguredPower > 0) {
|
||||||
trampCmsPower = vtxCommonGetPowerIndex(vtxCommonDevice(), &trampCmsPower);
|
if (!vtxCommonGetPowerIndex(vtxCommonDevice(), &trampCmsPower)) {
|
||||||
|
trampCmsPower = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vtxDevice_t *device = vtxCommonDevice();
|
vtxDevice_t *device = vtxCommonDevice();
|
||||||
|
|
|
@ -165,7 +165,7 @@ static bool trampValidateBandAndChannel(uint8_t band, uint8_t channel)
|
||||||
|
|
||||||
static void trampDevSetBandAndChannel(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)
|
void trampSetBandAndChannel(uint8_t band, uint8_t channel)
|
||||||
|
@ -201,8 +201,8 @@ bool trampCommitChanges(void)
|
||||||
// return false if index out of range
|
// return false if index out of range
|
||||||
static bool trampDevSetPowerByIndex(uint8_t index)
|
static bool trampDevSetPowerByIndex(uint8_t index)
|
||||||
{
|
{
|
||||||
if (index > 0 && index <= sizeof(trampPowerTable)) {
|
if (index > 0 && index <= vtxTramp.capability.powerCount) {
|
||||||
trampSetRFPower(trampPowerTable[index - 1]);
|
trampSetRFPower(vtxTramp.powerValues[index - 1]);
|
||||||
trampCommitChanges();
|
trampCommitChanges();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,7 @@ static char trampHandleResponse(void)
|
||||||
trampPower = trampRespBuffer[8]|(trampRespBuffer[9] << 8);
|
trampPower = trampRespBuffer[8]|(trampRespBuffer[9] << 8);
|
||||||
|
|
||||||
// if no band/chan match then make sure set-by-freq mode is flagged
|
// 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;
|
trampSetByFreqFlag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,8 +552,8 @@ static bool vtxTrampGetPowerIndex(const vtxDevice_t *vtxDevice, uint8_t *pIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trampConfiguredPower > 0) {
|
if (trampConfiguredPower > 0) {
|
||||||
for (uint8_t i = 0; i < sizeof(trampPowerTable); i++) {
|
for (uint8_t i = 0; i < vtxTramp.capability.powerCount; i++) {
|
||||||
if (trampConfiguredPower <= trampPowerTable[i]) {
|
if (trampConfiguredPower <= vtxTramp.powerValues[i]) {
|
||||||
*pIndex = i + 1;
|
*pIndex = i + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue