* Range mode RSSI (Fix for #356 ) * Formatting
This commit is contained in:
@@ -21,18 +21,23 @@
|
|||||||
#include "static.h"
|
#include "static.h"
|
||||||
|
|
||||||
MessageDialog::MessageDialog(Window* parent, const char* title,
|
MessageDialog::MessageDialog(Window* parent, const char* title,
|
||||||
const char* message, const char* info) :
|
const char* message, const char* info,
|
||||||
|
const int lineHeight,
|
||||||
|
const WindowFlags windowFlags,
|
||||||
|
const LcdFlags textFlags) :
|
||||||
Dialog(parent, title, {50, 73, LCD_W - 100, LCD_H - 146})
|
Dialog(parent, title, {50, 73, LCD_W - 100, LCD_H - 146})
|
||||||
{
|
{
|
||||||
|
setWindowFlags(windowFlags);
|
||||||
|
|
||||||
messageWidget = new StaticText(
|
messageWidget = new StaticText(
|
||||||
this,
|
this,
|
||||||
{0, coord_t(height() - PAGE_LINE_HEIGHT) / 2, width(), PAGE_LINE_HEIGHT},
|
{0, coord_t(height() - PAGE_LINE_HEIGHT) / 2, width(), PAGE_LINE_HEIGHT},
|
||||||
message, 0, CENTERED);
|
message, 0, CENTERED);
|
||||||
|
|
||||||
infoWidget = new StaticText(this,
|
infoWidget = new StaticText(
|
||||||
{0, 30 + coord_t(height() - PAGE_LINE_HEIGHT) / 2,
|
this,
|
||||||
width(), PAGE_LINE_HEIGHT},
|
{0, 30 + coord_t(height() - PAGE_LINE_HEIGHT) / 2, width(), lineHeight},
|
||||||
info, 0, CENTERED);
|
info, 0, textFlags);
|
||||||
setCloseWhenClickOutside(true);
|
setCloseWhenClickOutside(true);
|
||||||
setFocus();
|
setFocus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,28 +23,27 @@
|
|||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "static.h"
|
#include "static.h"
|
||||||
|
|
||||||
class MessageDialog: public Dialog {
|
class MessageDialog : public Dialog
|
||||||
public:
|
{
|
||||||
MessageDialog(Window * parent, const char * title, const char * message, const char * info = "");
|
public:
|
||||||
|
MessageDialog(Window* parent, const char* title, const char* message,
|
||||||
|
const char* info = "", const int lineHeight = PAGE_LINE_HEIGHT,
|
||||||
|
const WindowFlags windowFlags = 0,
|
||||||
|
const LcdFlags textFlags = CENTERED);
|
||||||
|
// Attn.: FONT(XXL) is not supported by MessageDialog
|
||||||
|
|
||||||
void setInfoText(std::string text)
|
void setInfoText(std::string text) { infoWidget->setText(std::move(text)); }
|
||||||
{
|
|
||||||
infoWidget->setText(std::move(text));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
StaticText * messageWidget;
|
|
||||||
StaticText * infoWidget;
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
StaticText* messageWidget;
|
||||||
|
StaticText* infoWidget;
|
||||||
|
LcdFlags textFlags;
|
||||||
#if defined(DEBUG_WINDOWS)
|
#if defined(DEBUG_WINDOWS)
|
||||||
std::string getName() const override
|
std::string getName() const override { return "MessageDialog"; }
|
||||||
{
|
|
||||||
return "MessageDialog";
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HARDWARE_KEYS)
|
#if defined(HARDWARE_KEYS)
|
||||||
void onEvent(event_t event) override;
|
void onEvent(event_t event) override;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,27 @@ std::string switchWarninglabel(swsrc_t index)
|
|||||||
1);
|
1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RssiDialog : public MessageDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RssiDialog(Window* parent, const char* title, const char* message,
|
||||||
|
const char* info = "", const int lineHeight = PAGE_LINE_HEIGHT,
|
||||||
|
const WindowFlags windowFlags = 0,
|
||||||
|
const LcdFlags textFlags = CENTERED) :
|
||||||
|
MessageDialog(parent, title, message, info, lineHeight, windowFlags,
|
||||||
|
textFlags)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void checkEvents()
|
||||||
|
{
|
||||||
|
char buf[10];
|
||||||
|
sprintf(buf, "%d", (int)TELEMETRY_RSSI());
|
||||||
|
setInfoText(buf);
|
||||||
|
MessageDialog::checkEvents();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class ChannelFailsafeBargraph: public Window {
|
class ChannelFailsafeBargraph: public Window {
|
||||||
public:
|
public:
|
||||||
ChannelFailsafeBargraph(Window * parent, const rect_t & rect, uint8_t moduleIdx, uint8_t channel):
|
ChannelFailsafeBargraph(Window * parent, const rect_t & rect, uint8_t moduleIdx, uint8_t channel):
|
||||||
@@ -840,6 +861,13 @@ class ModuleWindow : public FormGroup {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
moduleState[moduleIdx].mode = MODULE_MODE_RANGECHECK;
|
moduleState[moduleIdx].mode = MODULE_MODE_RANGECHECK;
|
||||||
|
auto rssiDialog = new RssiDialog(
|
||||||
|
this, "Range Test", "RSSI:", "", 50, REFRESH_ALWAYS,
|
||||||
|
DEFAULT_COLOR | CENTERED | FONT(BOLD) | FONT(XL));
|
||||||
|
rssiDialog->setCloseHandler([this]() {
|
||||||
|
rangeButton->check(false);
|
||||||
|
moduleState[moduleIdx].mode = MODULE_MODE_NORMAL;
|
||||||
|
});
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user