mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 14:25:11 +03:00
Add safety and context to spektrum and power meter
This commit is contained in:
parent
cc33d5833b
commit
63383f15c1
8 changed files with 61 additions and 3 deletions
|
@ -398,6 +398,12 @@ void lcdDrawText(coord_t x, coord_t y, const char * s, LcdFlags flags)
|
||||||
lcdDrawSizedText(x, y, s, 255, flags);
|
lcdDrawSizedText(x, y, s, 255, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcdDrawCenteredText(coord_t y, const char * s, LcdFlags flags)
|
||||||
|
{
|
||||||
|
coord_t x = (LCD_W - FW * strlen(s)) / 2;
|
||||||
|
lcdDrawText(x, y, s, flags);
|
||||||
|
}
|
||||||
|
|
||||||
void lcdDrawText(coord_t x, coord_t y, const char * s)
|
void lcdDrawText(coord_t x, coord_t y, const char * s)
|
||||||
{
|
{
|
||||||
lcdDrawText(x, y, s, 0);
|
lcdDrawText(x, y, s, 0);
|
||||||
|
|
|
@ -115,6 +115,7 @@ extern coord_t lcdNextPos;
|
||||||
|
|
||||||
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c);
|
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c);
|
||||||
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags);
|
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags);
|
||||||
|
void lcdDrawCenteredText(coord_t y, const char * s, LcdFlags flags = 0);
|
||||||
void lcdDrawText(coord_t x, coord_t y, const char * s, LcdFlags flags);
|
void lcdDrawText(coord_t x, coord_t y, const char * s, LcdFlags flags);
|
||||||
void lcdDrawTextAtIndex(coord_t x, coord_t y, const char * s, uint8_t idx, LcdFlags flags);
|
void lcdDrawTextAtIndex(coord_t x, coord_t y, const char * s, uint8_t idx, LcdFlags flags);
|
||||||
void lcdDrawSizedText(coord_t x, coord_t y, const char * s, unsigned char len, LcdFlags flags);
|
void lcdDrawSizedText(coord_t x, coord_t y, const char * s, unsigned char len, LcdFlags flags);
|
||||||
|
|
|
@ -347,6 +347,12 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len)
|
||||||
lcdDrawSizedText(x, y, s, len, 0);
|
lcdDrawSizedText(x, y, s, len, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcdDrawCenteredText(coord_t y, const char * s, LcdFlags flags)
|
||||||
|
{
|
||||||
|
coord_t x = (LCD_W - FW * strlen(s)) / 2;
|
||||||
|
lcdDrawText(x, y, s, flags);
|
||||||
|
}
|
||||||
|
|
||||||
void lcdDrawText(coord_t x, coord_t y, const char * s, LcdFlags flags)
|
void lcdDrawText(coord_t x, coord_t y, const char * s, LcdFlags flags)
|
||||||
{
|
{
|
||||||
lcdDrawSizedText(x, y, s, 255, flags);
|
lcdDrawSizedText(x, y, s, 255, flags);
|
||||||
|
|
|
@ -106,6 +106,7 @@ extern coord_t lcdNextPos;
|
||||||
|
|
||||||
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c);
|
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c);
|
||||||
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags mode);
|
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags mode);
|
||||||
|
void lcdDrawCenteredText(coord_t y, const char * s, LcdFlags flags = 0);
|
||||||
void lcdDrawText(coord_t x, coord_t y, const char * s, LcdFlags mode);
|
void lcdDrawText(coord_t x, coord_t y, const char * s, LcdFlags mode);
|
||||||
void lcdDrawTextAtIndex(coord_t x, coord_t y, const char * s,uint8_t idx, LcdFlags mode);
|
void lcdDrawTextAtIndex(coord_t x, coord_t y, const char * s,uint8_t idx, LcdFlags mode);
|
||||||
void lcdDrawSizedText(coord_t x, coord_t y, const char * s,unsigned char len, LcdFlags mode);
|
void lcdDrawSizedText(coord_t x, coord_t y, const char * s,unsigned char len, LcdFlags mode);
|
||||||
|
|
|
@ -132,6 +132,11 @@ inline void lcdDrawText(coord_t x, coord_t y, const char * s, LcdFlags attr=0)
|
||||||
lcd->drawText(x, y, s, attr);
|
lcd->drawText(x, y, s, attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void lcdDrawCenteredText(coord_t y, const char * s, LcdFlags attr=0)
|
||||||
|
{
|
||||||
|
lcd->drawText(LCD_W/2, y, s, attr | CENTERED);
|
||||||
|
}
|
||||||
|
|
||||||
inline void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlags attr=0)
|
inline void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlags attr=0)
|
||||||
{
|
{
|
||||||
lcd->drawSizedText(x, y, s, len, attr);
|
lcd->drawSizedText(x, y, s, len, attr);
|
||||||
|
|
|
@ -21,8 +21,20 @@
|
||||||
#include <opentx.h>
|
#include <opentx.h>
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
|
void pxx2ModuleRequiredScreen(event_t event);
|
||||||
|
|
||||||
void menuRadioPowerMeter(event_t event)
|
void menuRadioPowerMeter(event_t event)
|
||||||
{
|
{
|
||||||
|
if(!isModulePXX2(INTERNAL_MODULE)) {
|
||||||
|
pxx2ModuleRequiredScreen(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(TELEMETRY_STREAMING()) {
|
||||||
|
lcdDrawCenteredText(LCD_H/2, "Turn off receiver");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SIMPLE_SUBMENU("POWER METER", 1);
|
SIMPLE_SUBMENU("POWER METER", 1);
|
||||||
|
|
||||||
if (menuEvent) {
|
if (menuEvent) {
|
||||||
|
@ -32,8 +44,9 @@ void menuRadioPowerMeter(event_t event)
|
||||||
watchdogSuspend(500);
|
watchdogSuspend(500);
|
||||||
RTOS_WAIT_MS(500);
|
RTOS_WAIT_MS(500);
|
||||||
resumePulses();
|
resumePulses();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (event == EVT_ENTRY) {
|
else if (moduleSettings[INTERNAL_MODULE].mode != MODULE_MODE_SPECTRUM_ANALYSER) {
|
||||||
memclear(&reusableBuffer.powerMeter, sizeof(reusableBuffer.powerMeter));
|
memclear(&reusableBuffer.powerMeter, sizeof(reusableBuffer.powerMeter));
|
||||||
reusableBuffer.powerMeter.freq = 2400;
|
reusableBuffer.powerMeter.freq = 2400;
|
||||||
moduleSettings[INTERNAL_MODULE].mode = MODULE_MODE_POWER_METER;
|
moduleSettings[INTERNAL_MODULE].mode = MODULE_MODE_POWER_METER;
|
||||||
|
|
|
@ -20,8 +20,20 @@
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
|
extern void pxx2ModuleRequiredScreen(event_t event);
|
||||||
|
|
||||||
void menuRadioSpectrumAnalyser(event_t event)
|
void menuRadioSpectrumAnalyser(event_t event)
|
||||||
{
|
{
|
||||||
|
if(!isModulePXX2(INTERNAL_MODULE)) {
|
||||||
|
pxx2ModuleRequiredScreen(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(TELEMETRY_STREAMING()) {
|
||||||
|
lcdDrawCenteredText(15, "Turn off receiver");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SIMPLE_SUBMENU("SPECTRUM ANALYSER", 1);
|
SIMPLE_SUBMENU("SPECTRUM ANALYSER", 1);
|
||||||
|
|
||||||
if (menuEvent) {
|
if (menuEvent) {
|
||||||
|
@ -31,8 +43,9 @@ void menuRadioSpectrumAnalyser(event_t event)
|
||||||
watchdogSuspend(500);
|
watchdogSuspend(500);
|
||||||
RTOS_WAIT_MS(500);
|
RTOS_WAIT_MS(500);
|
||||||
resumePulses();
|
resumePulses();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (event == EVT_ENTRY) {
|
else if (moduleSettings[INTERNAL_MODULE].mode != MODULE_MODE_SPECTRUM_ANALYSER) {
|
||||||
memclear(reusableBuffer.spectrumAnalyser.bars, sizeof(reusableBuffer.spectrumAnalyser.bars));
|
memclear(reusableBuffer.spectrumAnalyser.bars, sizeof(reusableBuffer.spectrumAnalyser.bars));
|
||||||
moduleSettings[INTERNAL_MODULE].mode = MODULE_MODE_SPECTRUM_ANALYSER;
|
moduleSettings[INTERNAL_MODULE].mode = MODULE_MODE_SPECTRUM_ANALYSER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,19 @@
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
|
void pxx2ModuleRequiredScreen(event_t event)
|
||||||
|
{
|
||||||
|
lcdClear();
|
||||||
|
lcdDrawCenteredText(15, "THIS FEATURE REQUIRES");
|
||||||
|
lcdDrawCenteredText(30, "ACCESS UPGRADE ON");
|
||||||
|
lcdDrawCenteredText(45, "YOUR INTERNAL MODULE");
|
||||||
|
|
||||||
|
if(event == EVT_KEY_FIRST(KEY_EXIT)) {
|
||||||
|
killEvents(event);
|
||||||
|
popMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void addRadioTool(uint8_t index, const char * label, void (* tool)(event_t event), event_t event)
|
void addRadioTool(uint8_t index, const char * label, void (* tool)(event_t event), event_t event)
|
||||||
{
|
{
|
||||||
int8_t sub = menuVerticalPosition - HEADER_LINE;
|
int8_t sub = menuVerticalPosition - HEADER_LINE;
|
||||||
|
@ -37,7 +50,7 @@ void menuRadioTools(event_t event)
|
||||||
{
|
{
|
||||||
SIMPLE_MENU("TOOLS", menuTabGeneral, MENU_RADIO_TOOLS, HEADER_LINE + 2);
|
SIMPLE_MENU("TOOLS", menuTabGeneral, MENU_RADIO_TOOLS, HEADER_LINE + 2);
|
||||||
|
|
||||||
#if defined(PXX2)
|
#if defined(PXX2) && !(defined(PCBX9D) || defined(PCBX9DP) || defined(PCBX9E) || defined(PCBX7) || (defined(PCBXLITE) && !defined(PCBXLITES)))
|
||||||
addRadioTool(0, "Spectrum Analyser", menuRadioSpectrumAnalyser, event);
|
addRadioTool(0, "Spectrum Analyser", menuRadioSpectrumAnalyser, event);
|
||||||
addRadioTool(1, "Power Meter", menuRadioPowerMeter, event);
|
addRadioTool(1, "Power Meter", menuRadioPowerMeter, event);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue