|
|
|
@@ -18,7 +18,6 @@
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <opentx.h>
|
|
|
|
|
#include "opentx.h"
|
|
|
|
|
|
|
|
|
|
extern uint8_t g_moduleIdx;
|
|
|
|
@@ -32,11 +31,11 @@ enum PowerMeterFields {
|
|
|
|
|
POWER_METER_FIELDS_MAX
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define POWER_METER_MARGIN_2ND_COLUMN 180
|
|
|
|
|
constexpr coord_t POWER_METER_2ND_COLUMN = 100;
|
|
|
|
|
|
|
|
|
|
bool menuRadioPowerMeter(event_t event)
|
|
|
|
|
{
|
|
|
|
|
SIMPLE_SUBMENU(STR_MENU_POWER_METER, ICON_RADIO, POWER_METER_FIELDS_MAX-1);
|
|
|
|
|
SUBMENU(STR_MENU_POWER_METER, ICON_RADIO_SPECTRUM_ANALYSER, POWER_METER_FIELDS_MAX-1, {0, 0, READONLY_ROW, READONLY_ROW, READONLY_ROW});
|
|
|
|
|
|
|
|
|
|
if (TELEMETRY_STREAMING()) {
|
|
|
|
|
lcdDrawCenteredText(LCD_H/2, STR_TURN_OFF_RECEIVER);
|
|
|
|
@@ -44,51 +43,54 @@ bool menuRadioPowerMeter(event_t event)
|
|
|
|
|
killEvents(event);
|
|
|
|
|
popMenu();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (menuEvent) {
|
|
|
|
|
lcdDrawCenteredText(LCD_H/2, STR_STOPPING);
|
|
|
|
|
lcdRefresh();
|
|
|
|
|
moduleState[g_moduleIdx].mode = MODULE_MODE_NORMAL;
|
|
|
|
|
moduleState[g_moduleIdx].readModuleInformation(&reusableBuffer.moduleSetup.pxx2.moduleInformation, PXX2_HW_INFO_TX_ID, PXX2_HW_INFO_TX_ID);
|
|
|
|
|
/* wait 1s to resume normal operation before leaving */
|
|
|
|
|
watchdogSuspend(1000);
|
|
|
|
|
RTOS_WAIT_MS(1000);
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (moduleState[g_moduleIdx].mode != MODULE_MODE_POWER_METER) {
|
|
|
|
|
memclear(&reusableBuffer.powerMeter, sizeof(reusableBuffer.powerMeter));
|
|
|
|
|
reusableBuffer.powerMeter.freq = 2400000000;
|
|
|
|
|
reusableBuffer.powerMeter.attn = 4;
|
|
|
|
|
reusableBuffer.powerMeter.dirty = true;
|
|
|
|
|
moduleState[g_moduleIdx].mode = MODULE_MODE_POWER_METER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The warning
|
|
|
|
|
if (reusableBuffer.powerMeter.attn != 0)
|
|
|
|
|
lcdDrawCenteredText(MENU_CONTENT_TOP, STR_POWERMETER_ATTN_NEEDED, BOLD);
|
|
|
|
|
if (reusableBuffer.powerMeter.attn != 0) {
|
|
|
|
|
lcdDrawCenteredText(MENU_BODY_TOP, STR_POWERMETER_ATTN_NEEDED, BOLD | INVERS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (uint8_t i=0; i<POWER_METER_FIELDS_MAX; i++) {
|
|
|
|
|
LcdFlags attr = (menuVerticalPosition == i ? (s_editMode > 0 ? INVERS | BLINK : INVERS) : 0);
|
|
|
|
|
coord_t y = MENU_CONTENT_TOP + 30 + i * FH;
|
|
|
|
|
coord_t y = MENU_BODY_TOP + 2 * FH + i * FH;
|
|
|
|
|
|
|
|
|
|
switch (i) {
|
|
|
|
|
case POWER_METER_FREQ_RANGE:
|
|
|
|
|
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_POWERMETER_FREQ);
|
|
|
|
|
lcdDrawNumber(POWER_METER_MARGIN_2ND_COLUMN, y, reusableBuffer.powerMeter.freq / 1000000, LEFT | attr);
|
|
|
|
|
lcdDrawNumber(POWER_METER_2ND_COLUMN, y, reusableBuffer.powerMeter.freq / 1000000, LEFT | attr);
|
|
|
|
|
lcdDrawText(lcdNextPos, y, " MHz band");
|
|
|
|
|
if (attr) {
|
|
|
|
|
reusableBuffer.powerMeter.freq = checkIncDec(event, reusableBuffer.powerMeter.freq == 900000000, 0, 1) ? 900000000 : 2400000000;
|
|
|
|
|
if (checkIncDec_Ret) {
|
|
|
|
|
reusableBuffer.powerMeter.power = 0;
|
|
|
|
|
reusableBuffer.powerMeter.peak = 0;
|
|
|
|
|
reusableBuffer.powerMeter.dirty = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case POWER_METER_ATTENUATOR:
|
|
|
|
|
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_POWERMETER_ATTN);
|
|
|
|
|
lcdDrawNumber(POWER_METER_MARGIN_2ND_COLUMN, y, -10 * reusableBuffer.powerMeter.attn, LEFT | attr);
|
|
|
|
|
lcdDrawNumber(POWER_METER_2ND_COLUMN, y, -10 * reusableBuffer.powerMeter.attn, LEFT | attr);
|
|
|
|
|
lcdDrawText(lcdNextPos, y, " dB");
|
|
|
|
|
if (attr) {
|
|
|
|
|
reusableBuffer.powerMeter.attn = checkIncDec(event, reusableBuffer.powerMeter.attn, 0, 5, 0);
|
|
|
|
@@ -97,9 +99,9 @@ bool menuRadioPowerMeter(event_t event)
|
|
|
|
|
|
|
|
|
|
case POWER_METER_MAX:
|
|
|
|
|
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_MAX);
|
|
|
|
|
lcdDrawNumber(POWER_METER_MARGIN_2ND_COLUMN, y, -10 + 10 * reusableBuffer.powerMeter.attn);
|
|
|
|
|
lcdDrawText(lcdNextPos, y, "dBm/ ");
|
|
|
|
|
drawPower(lcdNextPos, y, -10 + 10 * reusableBuffer.powerMeter.attn, 0);
|
|
|
|
|
lcdDrawNumber(POWER_METER_2ND_COLUMN, y, -10 + 10 * reusableBuffer.powerMeter.attn);
|
|
|
|
|
lcdDrawText(lcdNextPos + 3, y, "dBm/ ");
|
|
|
|
|
drawPower(lcdNextPos + 3, y, -10 + 10 * reusableBuffer.powerMeter.attn, 0);
|
|
|
|
|
if (attr) {
|
|
|
|
|
reusableBuffer.powerMeter.attn = checkIncDec(event, reusableBuffer.powerMeter.attn, 0, 5, 0);
|
|
|
|
|
}
|
|
|
|
@@ -108,7 +110,7 @@ bool menuRadioPowerMeter(event_t event)
|
|
|
|
|
case POWER_METER_POWER:
|
|
|
|
|
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_POWERMETER_POWER);
|
|
|
|
|
if (reusableBuffer.powerMeter.power) {
|
|
|
|
|
lcdDrawNumber(POWER_METER_MARGIN_2ND_COLUMN, y, reusableBuffer.powerMeter.power + reusableBuffer.powerMeter.attn * 1000, LEFT | PREC2);
|
|
|
|
|
lcdDrawNumber(POWER_METER_2ND_COLUMN, y, reusableBuffer.powerMeter.power + reusableBuffer.powerMeter.attn * 1000, LEFT | PREC2);
|
|
|
|
|
lcdDrawText(lcdNextPos, y, "dBm");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
@@ -116,11 +118,12 @@ bool menuRadioPowerMeter(event_t event)
|
|
|
|
|
case POWER_METER_PEAK:
|
|
|
|
|
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_POWERMETER_PEAK);
|
|
|
|
|
if (reusableBuffer.powerMeter.peak) {
|
|
|
|
|
lcdDrawNumber(POWER_METER_MARGIN_2ND_COLUMN, y, reusableBuffer.powerMeter.peak + reusableBuffer.powerMeter.attn * 1000, LEFT | PREC2);
|
|
|
|
|
lcdDrawNumber(POWER_METER_2ND_COLUMN, y, reusableBuffer.powerMeter.peak + reusableBuffer.powerMeter.attn * 1000, LEFT | PREC2);
|
|
|
|
|
lcdDrawText(lcdNextPos, y, "dBm");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|