1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-25 01:05:21 +03:00

Merge pull request #2877 from iNavFlight/agh_vtx_ram_savings

Save some RAM in VTX control system
This commit is contained in:
Konstantin Sharlaimov 2018-03-06 20:24:42 +10:00 committed by GitHub
commit ae05b1c993
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 173 additions and 141 deletions

View file

@ -220,6 +220,11 @@ static void cmsPagePrev(displayPort_t *instance)
cmsPageSelect(instance, currentCtx.page - 1);
}
static bool cmsElementIsLabel(OSD_MenuElement element)
{
return element == OME_Label || element == OME_LabelFunc;
}
static void cmsFormatFloat(int32_t value, char *floatString)
{
uint8_t k;
@ -265,7 +270,7 @@ static void cmsPadToSize(char *buf, int size)
static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row)
{
#define CMS_DRAW_BUFFER_LEN 10u
#define CMS_DRAW_BUFFER_LEN 32u
char buff[CMS_DRAW_BUFFER_LEN];
int cnt = 0;
@ -464,9 +469,22 @@ static int cmsDrawMenuEntry(displayPort_t *pDisplay, OSD_Entry *p, uint8_t row)
break;
case OME_Label:
if (IS_PRINTVALUE(p) && p->data) {
case OME_LabelFunc:
if (IS_PRINTVALUE(p)) {
// A label with optional string, immediately following text
cnt = displayWrite(pDisplay, LEFT_MENU_COLUMN + 2 + strlen(p->text), row, p->data);
const char *text = p->data;
if (p->type == OME_LabelFunc) {
// Label is generated by a function
bool (*label_func)(char *buf, unsigned size) = p->data;
if (label_func(buff, sizeof(buff))) {
text = buff;
} else {
text = NULL;
}
}
if (text) {
cnt = displayWrite(pDisplay, LEFT_MENU_COLUMN + 2 + strlen(p->text), row, text);
}
CLR_PRINTVALUE(p);
}
break;
@ -525,7 +543,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
// Cursor manipulation
while ((pageTop + currentCtx.cursorRow)->type == OME_Label) // skip label
while (cmsElementIsLabel((pageTop + currentCtx.cursorRow)->type)) // skip label
currentCtx.cursorRow++;
cmsPageDebug();
@ -549,7 +567,7 @@ static void cmsDrawMenu(displayPort_t *pDisplay, uint32_t currentTimeUs)
for (i = 0, p = pageTop; i < MAX_MENU_ITEMS(pDisplay) && p->type != OME_END; i++, p++) {
if (IS_PRINTLABEL(p)) {
uint8_t coloff = LEFT_MENU_COLUMN;
coloff += (p->type == OME_Label) ? 1 : 2;
coloff += cmsElementIsLabel(p->type) ? 1 : 2;
room -= displayWrite(pDisplay, coloff, i + top, p->text);
CLR_PRINTLABEL(p);
if (room < 30)
@ -781,10 +799,10 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
currentCtx.cursorRow--;
// Skip non-title labels
if ((pageTop + currentCtx.cursorRow)->type == OME_Label && currentCtx.cursorRow > 0)
if (cmsElementIsLabel((pageTop + currentCtx.cursorRow)->type) && currentCtx.cursorRow > 0)
currentCtx.cursorRow--;
if (currentCtx.cursorRow == -1 || (pageTop + currentCtx.cursorRow)->type == OME_Label) {
if (currentCtx.cursorRow == -1 || cmsElementIsLabel((pageTop + currentCtx.cursorRow)->type)) {
// Goto previous page
cmsPagePrev(pDisplay);
currentCtx.cursorRow = pageMaxRow;
@ -1017,6 +1035,7 @@ STATIC_UNIT_TESTED uint16_t cmsHandleKey(displayPort_t *pDisplay, uint8_t key)
break;
case OME_Label:
case OME_LabelFunc:
case OME_END:
break;

View file

@ -17,6 +17,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "platform.h"
@ -103,71 +104,76 @@ void saCmsUpdate(void)
saCmsPower = saDacToPowerIndex(saDevice.power) + 1;
}
}
saUpdateStatusString();
}
char saCmsStatusString[31] = "- -- ---- ---";
// m bc ffff ppp
// 0123456789012
static long saCmsConfigOpmodelByGvar(displayPort_t *, const void *self);
static long saCmsConfigPitFModeByGvar(displayPort_t *, const void *self);
static long saCmsConfigBandByGvar(displayPort_t *, const void *self);
static long saCmsConfigChanByGvar(displayPort_t *, const void *self);
static long saCmsConfigPowerByGvar(displayPort_t *, const void *self);
void saUpdateStatusString(void)
static bool saCmsDrawStatusString(char *buf, unsigned bufsize)
{
const char *defaultString = "- -- ---- ---";
// m bc ffff ppp
// 0123456789012
if (bufsize < strlen(defaultString) + 1) {
return false;
}
strcpy(buf, defaultString);
if (saDevice.version == 0)
return;
return true;
// XXX These should be done somewhere else
if (saCmsDeviceStatus == 0 && saDevice.version != 0)
saCmsDeviceStatus = saDevice.version;
if (saCmsORFreq == 0 && saDevice.orfreq != 0)
saCmsORFreq = saDevice.orfreq;
if (saCmsUserFreq == 0 && saDevice.freq != 0)
saCmsUserFreq = saDevice.freq;
// XXX These should be done somewhere else
if (saCmsDeviceStatus == 0 && saDevice.version != 0)
saCmsDeviceStatus = saDevice.version;
if (saCmsORFreq == 0 && saDevice.orfreq != 0)
saCmsORFreq = saDevice.orfreq;
if (saCmsUserFreq == 0 && saDevice.freq != 0)
saCmsUserFreq = saDevice.freq;
if (saDevice.mode & SA_MODE_GET_OUT_RANGE_PITMODE)
saCmsPitFMode = 1;
else
saCmsPitFMode = 0;
if (saDevice.mode & SA_MODE_GET_OUT_RANGE_PITMODE)
saCmsPitFMode = 1;
else
saCmsPitFMode = 0;
saCmsStatusString[0] = "-FR"[saCmsOpmodel];
buf[0] = "-FR"[saCmsOpmodel];
if (saCmsFselMode == 0) {
saCmsStatusString[2] = "ABEFR"[saDevice.channel / 8];
saCmsStatusString[3] = '1' + (saDevice.channel % 8);
buf[2] = "ABEFR"[saDevice.channel / 8];
buf[3] = '1' + (saDevice.channel % 8);
} else {
saCmsStatusString[2] = 'U';
saCmsStatusString[3] = 'F';
buf[2] = 'U';
buf[3] = 'F';
}
if ((saDevice.mode & SA_MODE_GET_PITMODE)
&& (saDevice.mode & SA_MODE_GET_OUT_RANGE_PITMODE))
tfp_sprintf(&saCmsStatusString[5], "%4d", saDevice.orfreq);
tfp_sprintf(&buf[5], "%4d", saDevice.orfreq);
else if (saDevice.mode & SA_MODE_GET_FREQ_BY_FREQ)
tfp_sprintf(&saCmsStatusString[5], "%4d", saDevice.freq);
tfp_sprintf(&buf[5], "%4d", saDevice.freq);
else
tfp_sprintf(&saCmsStatusString[5], "%4d",
tfp_sprintf(&buf[5], "%4d",
vtx58frequencyTable[saDevice.channel / 8][saDevice.channel % 8]);
saCmsStatusString[9] = ' ';
buf[9] = ' ';
if (saDevice.mode & SA_MODE_GET_PITMODE) {
saCmsStatusString[10] = 'P';
buf[10] = 'P';
if (saDevice.mode & SA_MODE_GET_IN_RANGE_PITMODE) {
saCmsStatusString[11] = 'I';
buf[11] = 'I';
} else {
saCmsStatusString[11] = 'O';
buf[11] = 'O';
}
saCmsStatusString[12] = 'R';
saCmsStatusString[13] = 0;
buf[12] = 'R';
buf[13] = 0;
} else {
tfp_sprintf(&saCmsStatusString[10], "%3d", (saDevice.version == 2) ? saPowerTable[saDevice.power].rfpower : saPowerTable[saDacToPowerIndex(saDevice.power)].rfpower);
tfp_sprintf(&buf[10], "%3d", (saDevice.version == 2) ? saPowerTable[saDevice.power].rfpower : saPowerTable[saDacToPowerIndex(saDevice.power)].rfpower);
}
return true;
}
static long saCmsConfigBandByGvar(displayPort_t *pDisp, const void *self)
@ -563,11 +569,11 @@ static CMS_Menu saCmsMenuCommence = {
static OSD_Entry saCmsMenuFreqModeEntries[] = {
{ "- SMARTAUDIO -", OME_Label, NULL, NULL, 0 },
{ "", OME_Label, NULL, saCmsStatusString, DYNAMIC },
{ "FREQ", OME_Submenu, (CMSEntryFuncPtr)saCmsUserFreqGetString, &saCmsMenuUserFreq, OPTSTRING },
{ "POWER", OME_TAB, saCmsConfigPowerByGvar, &saCmsEntPower, 0 },
{ "SET", OME_Submenu, cmsMenuChange, &saCmsMenuCommence, 0 },
{ "CONFIG", OME_Submenu, cmsMenuChange, &saCmsMenuConfig, 0 },
{ "", OME_LabelFunc, NULL, saCmsDrawStatusString, DYNAMIC },
{ "FREQ", OME_Submenu, (CMSEntryFuncPtr)saCmsUserFreqGetString, &saCmsMenuUserFreq, OPTSTRING },
{ "POWER", OME_TAB, saCmsConfigPowerByGvar, &saCmsEntPower, 0 },
{ "SET", OME_Submenu, cmsMenuChange, &saCmsMenuCommence, 0 },
{ "CONFIG", OME_Submenu, cmsMenuChange, &saCmsMenuConfig, 0 },
{ "BACK", OME_Back, NULL, NULL, 0 },
{ NULL, OME_END, NULL, NULL, 0 }
@ -577,13 +583,13 @@ static OSD_Entry saCmsMenuChanModeEntries[] =
{
{ "- SMARTAUDIO -", OME_Label, NULL, NULL, 0 },
{ "", OME_Label, NULL, saCmsStatusString, DYNAMIC },
{ "BAND", OME_TAB, saCmsConfigBandByGvar, &saCmsEntBand, 0 },
{ "CHAN", OME_TAB, saCmsConfigChanByGvar, &saCmsEntChan, 0 },
{ "(FREQ)", OME_UINT16, NULL, &saCmsEntFreqRef, DYNAMIC },
{ "POWER", OME_TAB, saCmsConfigPowerByGvar, &saCmsEntPower, 0 },
{ "SET", OME_Submenu, cmsMenuChange, &saCmsMenuCommence, 0 },
{ "CONFIG", OME_Submenu, cmsMenuChange, &saCmsMenuConfig, 0 },
{ "", OME_LabelFunc, NULL, saCmsDrawStatusString, DYNAMIC },
{ "BAND", OME_TAB, saCmsConfigBandByGvar, &saCmsEntBand, 0 },
{ "CHAN", OME_TAB, saCmsConfigChanByGvar, &saCmsEntChan, 0 },
{ "(FREQ)", OME_UINT16, NULL, &saCmsEntFreqRef, DYNAMIC },
{ "POWER", OME_TAB, saCmsConfigPowerByGvar, &saCmsEntPower, 0 },
{ "SET", OME_Submenu, cmsMenuChange, &saCmsMenuCommence, 0 },
{ "CONFIG", OME_Submenu, cmsMenuChange, &saCmsMenuConfig, 0 },
{ "BACK", OME_Back, NULL, NULL, 0 },
{ NULL, OME_END, NULL, NULL, 0 }
@ -593,8 +599,8 @@ static OSD_Entry saCmsMenuOfflineEntries[] =
{
{ "- VTX SMARTAUDIO -", OME_Label, NULL, NULL, 0 },
{ "", OME_Label, NULL, saCmsStatusString, DYNAMIC },
{ "STATX", OME_Submenu, cmsMenuChange, &saCmsMenuStats, 0 },
{ "", OME_LabelFunc, NULL, saCmsDrawStatusString, DYNAMIC },
{ "STATX", OME_Submenu, cmsMenuChange, &saCmsMenuStats, 0 },
{ "BACK", OME_Back, NULL, NULL, 0 },
{ NULL, OME_END, NULL, NULL, 0 }

View file

@ -23,5 +23,4 @@
extern CMS_Menu cmsx_menuVtxSmartAudio;
void saCmsUpdate(void);
void saUpdateStatusString(void);
void saCmsResetOpmodel();

View file

@ -17,6 +17,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "platform.h"
@ -35,28 +36,41 @@
#include "io/vtx_string.h"
#include "io/vtx_tramp.h"
char trampCmsStatusString[31] = "- -- ---- ----";
static bool trampCmsDrawStatusString(char *buf, unsigned bufsize)
{
const char *defaultString = "- -- ---- ----";
// m bc ffff tppp
// 01234567890123
void trampCmsUpdateStatusString(void)
{
trampCmsStatusString[0] = '*';
trampCmsStatusString[1] = ' ';
trampCmsStatusString[2] = vtx58BandLetter[trampBand];
trampCmsStatusString[3] = vtx58ChannelNames[trampChannel][0];
trampCmsStatusString[4] = ' ';
if (trampCurFreq)
tfp_sprintf(&trampCmsStatusString[5], "%4d", trampCurFreq);
else
tfp_sprintf(&trampCmsStatusString[5], "----");
if (trampPower) {
tfp_sprintf(&trampCmsStatusString[9], " %c%3d", (trampPower == trampConfiguredPower) ? ' ' : '*', trampPower);
if (bufsize < strlen(defaultString) + 1) {
return false;
}
strcpy(buf, defaultString);
if (!trampIsAvailable()) {
return true;
}
buf[0] = '*';
buf[1] = ' ';
buf[2] = vtx58BandLetter[trampData.band];
buf[3] = vtx58ChannelNames[trampData.channel][0];
buf[4] = ' ';
if (trampData.curFreq)
tfp_sprintf(&buf[5], "%4d", trampData.curFreq);
else
tfp_sprintf(&trampCmsStatusString[9], " ----");
tfp_sprintf(&buf[5], "----");
if (trampData.power) {
tfp_sprintf(&buf[9], " %c%3d", (trampData.power == trampData.configuredPower) ? ' ' : '*', trampData.power);
}
else {
tfp_sprintf(&buf[9], " ----");
}
return true;
}
uint8_t trampCmsPitMode = 0;
@ -120,7 +134,7 @@ static long trampCmsConfigPower(displayPort_t *pDisp, const void *self)
return 0;
}
static OSD_INT16_t trampCmsEntTemp = { &trampTemperature, -100, 300, 0 };
static OSD_INT16_t trampCmsEntTemp = { &trampData.temperature, -100, 300, 0 };
static const char * const trampCmsPitModeNames[] = {
"---", "OFF", "ON "
@ -160,15 +174,15 @@ static long trampCmsCommence(displayPort_t *pDisp, const void *self)
static void trampCmsInitSettings(void)
{
if(trampBand > 0) trampCmsBand = trampBand;
if(trampChannel > 0) trampCmsChan = trampChannel;
if(trampData.band > 0) trampCmsBand = trampData.band;
if(trampData.channel > 0) trampCmsChan = trampData.channel;
trampCmsUpdateFreqRef();
trampCmsPitMode = trampPitMode + 1;
trampCmsPitMode = trampData.pitMode + 1;
if (trampConfiguredPower > 0) {
if (trampData.configuredPower > 0) {
for (uint8_t i = 0; i < sizeof(trampPowerTable); i++) {
if (trampConfiguredPower <= trampPowerTable[i]) {
if (trampData.configuredPower <= trampPowerTable[i]) {
trampCmsPower = i + 1;
break;
}
@ -204,14 +218,14 @@ static OSD_Entry trampMenuEntries[] =
{
{ "- TRAMP -", OME_Label, NULL, NULL, 0 },
{ "", OME_Label, NULL, trampCmsStatusString, DYNAMIC },
{ "PIT", OME_TAB, trampCmsSetPitMode, &trampCmsEntPitMode, 0 },
{ "BAND", OME_TAB, trampCmsConfigBand, &trampCmsEntBand, 0 },
{ "CHAN", OME_TAB, trampCmsConfigChan, &trampCmsEntChan, 0 },
{ "(FREQ)", OME_UINT16, NULL, &trampCmsEntFreqRef, DYNAMIC },
{ "POWER", OME_TAB, trampCmsConfigPower, &trampCmsEntPower, 0 },
{ "T(C)", OME_INT16, NULL, &trampCmsEntTemp, DYNAMIC },
{ "SET", OME_Submenu, cmsMenuChange, &trampCmsMenuCommence, 0 },
{ "", OME_LabelFunc, NULL, trampCmsDrawStatusString, DYNAMIC },
{ "PIT", OME_TAB, trampCmsSetPitMode, &trampCmsEntPitMode, 0 },
{ "BAND", OME_TAB, trampCmsConfigBand, &trampCmsEntBand, 0 },
{ "CHAN", OME_TAB, trampCmsConfigChan, &trampCmsEntChan, 0 },
{ "(FREQ)", OME_UINT16, NULL, &trampCmsEntFreqRef, DYNAMIC },
{ "POWER", OME_TAB, trampCmsConfigPower, &trampCmsEntPower, 0 },
{ "T(C)", OME_INT16, NULL, &trampCmsEntTemp, DYNAMIC },
{ "SET", OME_Submenu, cmsMenuChange, &trampCmsMenuCommence, 0 },
{ "BACK", OME_Back, NULL, NULL, 0 },
{ NULL, OME_END, NULL, NULL, 0 }

View file

@ -19,6 +19,4 @@
#include "cms/cms.h"
#include "cms/cms_types.h"
extern CMS_Menu cmsx_menuVtxTramp;
void trampCmsUpdateStatusString(void);
extern CMS_Menu cmsx_menuVtxTramp;

View file

@ -31,6 +31,7 @@
typedef enum
{
OME_Label,
OME_LabelFunc, // bool func(char *buf, unsigned bufsize) - returns wether buf should be printed
OME_Back,
OME_OSD_Exit,
OME_Submenu,

View file

@ -333,7 +333,6 @@ static void saProcessResponse(uint8_t *buf, int len)
#ifdef USE_CMS
// Export current device status for CMS
saCmsUpdate();
saUpdateStatusString();
#endif
}

View file

@ -27,8 +27,6 @@
#include "build/debug.h"
#include "cms/cms_menu_vtx_tramp.h"
#include "common/utils.h"
#include "drivers/vtx_common.h"
@ -66,7 +64,6 @@ static vtxDevice_t vtxTramp = {
static serialPort_t *trampSerialPort = NULL;
static uint8_t trampReqBuffer[16];
static uint8_t trampRespBuffer[16];
typedef enum {
@ -79,32 +76,24 @@ typedef enum {
trampStatus_e trampStatus = TRAMP_STATUS_OFFLINE;
uint32_t trampRFFreqMin;
uint32_t trampRFFreqMax;
uint32_t trampRFPowerMax;
// TODO: These fields are currently removed by the compiler because they're
// never read. Decide if we want to use them for something or remove them.
static uint16_t trampRFFreqMin;
static uint16_t trampRFFreqMax;
static uint16_t trampRFPowerMax;
uint32_t trampCurFreq = 0;
uint8_t trampBand = 0;
uint8_t trampChannel = 0;
uint16_t trampPower = 0; // Actual transmitting power
uint16_t trampConfiguredPower = 0; // Configured transmitting power
int16_t trampTemperature = 0;
uint8_t trampPitMode = 0;
trampData_t trampData;
// Maximum number of requests sent to try a config change
#define TRAMP_MAX_RETRIES 2
uint32_t trampConfFreq = 0;
uint16_t trampConfFreq = 0;
uint8_t trampFreqRetries = 0;
uint16_t trampConfPower = 0;
uint8_t trampPowerRetries = 0;
static void trampWriteBuf(uint8_t *buf)
{
serialWriteBuf(trampSerialPort, buf, 16);
}
static uint8_t trampChecksum(uint8_t *trampBuf)
{
uint8_t cksum = 0;
@ -120,19 +109,20 @@ void trampCmdU16(uint8_t cmd, uint16_t param)
if (!trampSerialPort)
return;
uint8_t trampReqBuffer[16];
memset(trampReqBuffer, 0, ARRAYLEN(trampReqBuffer));
trampReqBuffer[0] = 15;
trampReqBuffer[1] = cmd;
trampReqBuffer[2] = param & 0xff;
trampReqBuffer[3] = (param >> 8) & 0xff;
trampReqBuffer[14] = trampChecksum(trampReqBuffer);
trampWriteBuf(trampReqBuffer);
serialWriteBuf(trampSerialPort, trampReqBuffer, sizeof(trampReqBuffer));
}
void trampSetFreq(uint16_t freq)
{
trampConfFreq = freq;
if(trampConfFreq != trampCurFreq)
if(trampConfFreq != trampData.curFreq)
trampFreqRetries = TRAMP_MAX_RETRIES;
}
@ -149,7 +139,7 @@ void trampSetBandAndChannel(uint8_t band, uint8_t channel)
void trampSetRFPower(uint16_t level)
{
trampConfPower = level;
if(trampConfPower != trampPower)
if(trampConfPower != trampData.power)
trampPowerRetries = TRAMP_MAX_RETRIES;
}
@ -158,6 +148,11 @@ void trampSendRFPower(uint16_t level)
trampCmdU16('P', level);
}
bool trampIsAvailable(void)
{
return trampStatus != TRAMP_STATUS_BAD_DEVICE && trampStatus != TRAMP_STATUS_OFFLINE;
}
// return false if error
bool trampCommitChanges(void)
{
@ -197,14 +192,14 @@ char trampHandleResponse(void)
{
uint16_t freq = trampRespBuffer[2]|(trampRespBuffer[3] << 8);
if(freq != 0) {
trampCurFreq = freq;
trampConfiguredPower = trampRespBuffer[4]|(trampRespBuffer[5] << 8);
trampPitMode = trampRespBuffer[7];
trampPower = trampRespBuffer[8]|(trampRespBuffer[9] << 8);
vtx58_Freq2Bandchan(trampCurFreq, &trampBand, &trampChannel);
trampData.curFreq = freq;
trampData.configuredPower = trampRespBuffer[4]|(trampRespBuffer[5] << 8);
trampData.pitMode = trampRespBuffer[7];
trampData.power = trampRespBuffer[8]|(trampRespBuffer[9] << 8);
vtx58_Freq2Bandchan(trampData.curFreq, &trampData.band, &trampData.channel);
if(trampConfFreq == 0) trampConfFreq = trampCurFreq;
if(trampConfPower == 0) trampConfPower = trampPower;
if(trampConfFreq == 0) trampConfFreq = trampData.curFreq;
if(trampConfPower == 0) trampConfPower = trampData.power;
return 'v';
}
@ -216,7 +211,7 @@ char trampHandleResponse(void)
{
uint16_t temp = (int16_t)(trampRespBuffer[6]|(trampRespBuffer[7] << 8));
if(temp != 0) {
trampTemperature = temp;
trampData.temperature = temp;
return 's';
}
}
@ -372,7 +367,7 @@ void vtxTrampProcess(uint32_t currentTimeUs)
case TRAMP_STATUS_SET_FREQ_PW:
{
bool done = true;
if (trampConfFreq && trampFreqRetries && (trampConfFreq != trampCurFreq)) {
if (trampConfFreq && trampFreqRetries && (trampConfFreq != trampData.curFreq)) {
trampSendFreq(trampConfFreq);
trampFreqRetries--;
#ifdef TRAMP_DEBUG
@ -380,7 +375,7 @@ void vtxTrampProcess(uint32_t currentTimeUs)
#endif
done = false;
}
else if (trampConfPower && trampPowerRetries && (trampConfPower != trampConfiguredPower)) {
else if (trampConfPower && trampPowerRetries && (trampConfPower != trampData.configuredPower)) {
trampSendRFPower(trampConfPower);
trampPowerRetries--;
#ifdef TRAMP_DEBUG
@ -399,8 +394,8 @@ void vtxTrampProcess(uint32_t currentTimeUs)
// everything has been done, let's return to original state
trampStatus = TRAMP_STATUS_ONLINE;
// reset configuration value in case it failed (no more retries)
trampConfFreq = trampCurFreq;
trampConfPower = trampPower;
trampConfFreq = trampData.curFreq;
trampConfPower = trampData.power;
trampFreqRetries = trampPowerRetries = 0;
}
}
@ -422,10 +417,6 @@ void vtxTrampProcess(uint32_t currentTimeUs)
debug[2] = debugPowReqCounter;
debug[3] = 0;
#endif
#ifdef USE_CMS
trampCmsUpdateStatusString();
#endif
}
@ -469,8 +460,8 @@ bool vtxTrampGetBandAndChannel(uint8_t *pBand, uint8_t *pChannel)
if (!vtxTrampIsReady())
return false;
*pBand = trampBand;
*pChannel = trampChannel;
*pBand = trampData.band;
*pChannel = trampData.channel;
return true;
}
@ -479,9 +470,9 @@ bool vtxTrampGetPowerIndex(uint8_t *pIndex)
if (!vtxTrampIsReady())
return false;
if (trampConfiguredPower > 0) {
if (trampData.configuredPower > 0) {
for (uint8_t i = 0; i < sizeof(trampPowerTable); i++) {
if (trampConfiguredPower <= trampPowerTable[i]) {
if (trampData.configuredPower <= trampPowerTable[i]) {
*pIndex = i + 1;
break;
}
@ -496,7 +487,7 @@ bool vtxTrampGetPitMode(uint8_t *pOnOff)
if (!vtxTrampIsReady())
return false;
*pOnOff = trampPitMode;
*pOnOff = trampData.pitMode;
return true;
}

View file

@ -36,15 +36,20 @@
extern const uint16_t trampPowerTable[VTX_TRAMP_POWER_COUNT];
extern const char * const trampPowerNames[VTX_TRAMP_POWER_COUNT+1];
extern uint8_t trampBand;
extern uint8_t trampChannel;
extern uint16_t trampPower; // Actual transmitting power
extern uint8_t trampPitMode;
extern uint32_t trampCurFreq;
extern uint16_t trampConfiguredPower; // Configured transmitting power
extern int16_t trampTemperature;
typedef struct trampData_s {
uint8_t band;
uint8_t channel;
uint16_t power; // Actual transmitting power
uint16_t curFreq;
uint16_t configuredPower; // Configured transmitting power
int16_t temperature;
uint8_t pitMode;
} trampData_t;
extern trampData_t trampData;
bool vtxTrampInit(void);
bool trampIsAvailable(void);
bool trampCommitChanges(void);
void trampSetPitMode(uint8_t onoff);
void trampSetBandAndChannel(uint8_t band, uint8_t channel);