From 8726c4e0efd6f9de170e73c44c5792f961938528 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 21 Aug 2019 09:40:14 +0200 Subject: [PATCH] [X10 Express] Power meter --- radio/src/gui/128x64/menu_model.cpp | 1 - radio/src/gui/128x64/model_failsafe.cpp | 2 +- radio/src/gui/212x64/model_failsafe.cpp | 2 +- radio/src/gui/480x272/model_failsafe.cpp | 2 +- .../src/gui/480x272/model_module_options.cpp | 2 +- radio/src/gui/480x272/radio_power_meter.cpp | 35 ++++++++++--------- radio/src/gui/480x272/radio_tools.cpp | 8 ++--- .../common/stdlcd/model_module_options.cpp | 2 +- .../gui/common/stdlcd/radio_power_meter.cpp | 1 - radio/src/targets/horus/CMakeLists.txt | 2 +- radio/src/telemetry/frsky_pxx2.cpp | 1 - radio/src/telemetry/telemetry.cpp | 2 +- 12 files changed, 30 insertions(+), 30 deletions(-) diff --git a/radio/src/gui/128x64/menu_model.cpp b/radio/src/gui/128x64/menu_model.cpp index 8d4f80dd0..0f64fab14 100644 --- a/radio/src/gui/128x64/menu_model.cpp +++ b/radio/src/gui/128x64/menu_model.cpp @@ -20,7 +20,6 @@ #include "opentx.h" - uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const char * str, uint8_t delay) { lcdDrawTextAlignedLeft(y, str); diff --git a/radio/src/gui/128x64/model_failsafe.cpp b/radio/src/gui/128x64/model_failsafe.cpp index d3db3115b..f0a926074 100644 --- a/radio/src/gui/128x64/model_failsafe.cpp +++ b/radio/src/gui/128x64/model_failsafe.cpp @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include +#include "opentx.h" extern uint8_t g_moduleIdx; diff --git a/radio/src/gui/212x64/model_failsafe.cpp b/radio/src/gui/212x64/model_failsafe.cpp index 60c9c6177..3fdc2ee28 100644 --- a/radio/src/gui/212x64/model_failsafe.cpp +++ b/radio/src/gui/212x64/model_failsafe.cpp @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include +#include "opentx.h" extern uint8_t g_moduleIdx; diff --git a/radio/src/gui/480x272/model_failsafe.cpp b/radio/src/gui/480x272/model_failsafe.cpp index 16494ccfc..269cfad75 100644 --- a/radio/src/gui/480x272/model_failsafe.cpp +++ b/radio/src/gui/480x272/model_failsafe.cpp @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include +#include "opentx.h" extern uint8_t g_moduleIdx; diff --git a/radio/src/gui/480x272/model_module_options.cpp b/radio/src/gui/480x272/model_module_options.cpp index 4d21f6b3b..4f088fd6a 100644 --- a/radio/src/gui/480x272/model_module_options.cpp +++ b/radio/src/gui/480x272/model_module_options.cpp @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include +#include "opentx.h" #include #define RECEIVER_OPTIONS_2ND_COLUMN 200 diff --git a/radio/src/gui/480x272/radio_power_meter.cpp b/radio/src/gui/480x272/radio_power_meter.cpp index 1e4983c19..46472d8bf 100644 --- a/radio/src/gui/480x272/radio_power_meter.cpp +++ b/radio/src/gui/480x272/radio_power_meter.cpp @@ -18,7 +18,6 @@ * GNU General Public License for more details. */ -#include #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 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; } diff --git a/radio/src/gui/480x272/radio_tools.cpp b/radio/src/gui/480x272/radio_tools.cpp index 9ccdf3d12..72dbcf3c2 100644 --- a/radio/src/gui/480x272/radio_tools.cpp +++ b/radio/src/gui/480x272/radio_tools.cpp @@ -89,14 +89,14 @@ bool menuRadioTools(event_t event) if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER)) addRadioModuleTool(index++, STR_SPECTRUM_ANALYSER_INT, menuRadioSpectrumAnalyser, INTERNAL_MODULE); -// if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER)) -// addRadioModuleTool(index++, STR_POWER_METER_INT, menuRadioPowerMeter, INTERNAL_MODULE); + if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[INTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER)) + addRadioModuleTool(index++, STR_POWER_METER_INT, menuRadioPowerMeter, INTERNAL_MODULE); if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_SPECTRUM_ANALYSER)) addRadioModuleTool(index++, STR_SPECTRUM_ANALYSER_EXT, menuRadioSpectrumAnalyser, EXTERNAL_MODULE); -// if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER)) -// addRadioModuleTool(index++, STR_POWER_METER_EXT, menuRadioPowerMeter, EXTERNAL_MODULE); + if (isPXX2ModuleOptionAvailable(reusableBuffer.hardwareAndSettings.modules[EXTERNAL_MODULE].information.modelID, MODULE_OPTION_POWER_METER)) + addRadioModuleTool(index++, STR_POWER_METER_EXT, menuRadioPowerMeter, EXTERNAL_MODULE); #endif #if defined(LUA) diff --git a/radio/src/gui/common/stdlcd/model_module_options.cpp b/radio/src/gui/common/stdlcd/model_module_options.cpp index a4181ac15..858e357a4 100644 --- a/radio/src/gui/common/stdlcd/model_module_options.cpp +++ b/radio/src/gui/common/stdlcd/model_module_options.cpp @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include +#include "opentx.h" #include #define RECEIVER_OPTIONS_2ND_COLUMN (11*FW) diff --git a/radio/src/gui/common/stdlcd/radio_power_meter.cpp b/radio/src/gui/common/stdlcd/radio_power_meter.cpp index 673f671e1..589da52f0 100644 --- a/radio/src/gui/common/stdlcd/radio_power_meter.cpp +++ b/radio/src/gui/common/stdlcd/radio_power_meter.cpp @@ -18,7 +18,6 @@ * GNU General Public License for more details. */ -#include #include "opentx.h" extern uint8_t g_moduleIdx; diff --git a/radio/src/targets/horus/CMakeLists.txt b/radio/src/targets/horus/CMakeLists.txt index 8f7e81233..2efefe473 100644 --- a/radio/src/targets/horus/CMakeLists.txt +++ b/radio/src/targets/horus/CMakeLists.txt @@ -136,7 +136,7 @@ if(PXX2) set(GUI_SRC ${GUI_SRC} radio_spectrum_analyser.cpp -# radio_power_meter.cpp + radio_power_meter.cpp ) endif() diff --git a/radio/src/telemetry/frsky_pxx2.cpp b/radio/src/telemetry/frsky_pxx2.cpp index 52a5e86e6..e9db1fd88 100644 --- a/radio/src/telemetry/frsky_pxx2.cpp +++ b/radio/src/telemetry/frsky_pxx2.cpp @@ -18,7 +18,6 @@ * GNU General Public License for more details. */ -#include #include "opentx.h" class Pxx2Telemetry diff --git a/radio/src/telemetry/telemetry.cpp b/radio/src/telemetry/telemetry.cpp index 6d7a1ea6d..ffddd7bee 100644 --- a/radio/src/telemetry/telemetry.cpp +++ b/radio/src/telemetry/telemetry.cpp @@ -18,7 +18,7 @@ * GNU General Public License for more details. */ -#include +#include "opentx.h" uint8_t telemetryStreaming = 0; uint8_t R9ModuleStreaming = 0;