[X10 Express] Power meter
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <opentx.h>
|
||||
#include "opentx.h"
|
||||
|
||||
extern uint8_t g_moduleIdx;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <opentx.h>
|
||||
#include "opentx.h"
|
||||
|
||||
extern uint8_t g_moduleIdx;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <opentx.h>
|
||||
#include "opentx.h"
|
||||
|
||||
extern uint8_t g_moduleIdx;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <opentx.h>
|
||||
#include "opentx.h"
|
||||
#include <math.h>
|
||||
|
||||
#define RECEIVER_OPTIONS_2ND_COLUMN 200
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <opentx.h>
|
||||
#include "opentx.h"
|
||||
#include <math.h>
|
||||
|
||||
#define RECEIVER_OPTIONS_2ND_COLUMN (11*FW)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <opentx.h>
|
||||
#include "opentx.h"
|
||||
|
||||
extern uint8_t g_moduleIdx;
|
||||
|
||||
@@ -136,7 +136,7 @@ if(PXX2)
|
||||
set(GUI_SRC
|
||||
${GUI_SRC}
|
||||
radio_spectrum_analyser.cpp
|
||||
# radio_power_meter.cpp
|
||||
radio_power_meter.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <opentx.h>
|
||||
#include "opentx.h"
|
||||
|
||||
class Pxx2Telemetry
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <opentx.h>
|
||||
#include "opentx.h"
|
||||
|
||||
uint8_t telemetryStreaming = 0;
|
||||
uint8_t R9ModuleStreaming = 0;
|
||||
|
||||
Reference in New Issue
Block a user