From d3d111dbb6efebe688fdc6defcb3094a4df97007 Mon Sep 17 00:00:00 2001 From: jflyper Date: Wed, 13 Feb 2019 05:29:55 +0900 Subject: [PATCH 1/2] Fix power indexhandling --- src/main/cms/cms_menu_vtx_tramp.c | 4 +++- src/main/io/vtx_tramp.c | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/cms/cms_menu_vtx_tramp.c b/src/main/cms/cms_menu_vtx_tramp.c index a4724d22b5..c307a1abe6 100644 --- a/src/main/cms/cms_menu_vtx_tramp.c +++ b/src/main/cms/cms_menu_vtx_tramp.c @@ -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(); diff --git a/src/main/io/vtx_tramp.c b/src/main/io/vtx_tramp.c index c620976ccb..bf904f3bd5 100644 --- a/src/main/io/vtx_tramp.c +++ b/src/main/io/vtx_tramp.c @@ -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; } From 5d5447abd86cdbf5f9091d7a2d0ed2dd91677486 Mon Sep 17 00:00:00 2001 From: jflyper Date: Wed, 13 Feb 2019 09:44:50 +0900 Subject: [PATCH 2/2] Use vtxTramp directly instead of calling vtxCommonDevice within the driver --- src/main/io/vtx_tramp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/io/vtx_tramp.c b/src/main/io/vtx_tramp.c index bf904f3bd5..7514535a0e 100644 --- a/src/main/io/vtx_tramp.c +++ b/src/main/io/vtx_tramp.c @@ -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) @@ -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; }