feat: More analog diagnostics screens on B&W colorlcd (#1421)
* Show true unscaled and unfiltered analogs for diagnose purpose on the analog diagnose screen. Tested on physical RM TX16S, not yet tested on B/W targets. * Changed to decimal display also on B/W targets. Tested now with RM Zorro as well. * 5 fps refresh rate of the raw analog values. Much nicer to look at. * Time-changing 3 views for color radios: std., filtered raw with deviation, unfiltered raw. * Corrected deviation view output to not use old values. * Changed analogs diagnose page to user navigatable TabsGroup with 3 tabs. * Added fourth analog diagnose tab to show minimum and maximum values and the range (difference between min and max). Left touch screen and IMU output tests only on first page (should also move in the future to their respective dedicated pages). * Use Std. JitterAlpha filtering for Deviation screen to minimize delay, omit filtering for FlySky digital hall gimbals - not necessary, the signal is stable enough. * 2 analog diagnose pages for 128x64 B/W radios: calibrated analogs and raw values with display output limited to 5 frames-per-second due to visibility reasons. * Added 2 analogs diagnose pages also for 212x64 display B/W radios. I was only able to simulate it, not tested on real hardware. * Support also radios that do not have PageUp/PageDn keys, but only Page key (e.g. X7). * Better key handling and improved style thx to @pfeerick
This commit is contained in:
@@ -20,9 +20,24 @@
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
#include "../../hal/adc_driver.h"
|
||||
|
||||
#define HOLDANAVALUEFRAMES 4 /* 4* 50ms = 200 ms update rate */
|
||||
|
||||
void menuRadioDiagAnalogs(event_t event)
|
||||
{
|
||||
static int8_t entryCount = 0;
|
||||
static uint16_t lastShownAnalogValue[NUM_STICKS+NUM_POTS+NUM_SLIDERS];
|
||||
|
||||
enum ANAVIEWS{
|
||||
ANAVIEW_FIRST,
|
||||
ANAVIEW_CALIB=ANAVIEW_FIRST,
|
||||
ANAVIEW_RAWLOWFPS,
|
||||
ANAVIEW_LAST=ANAVIEW_RAWLOWFPS
|
||||
};
|
||||
|
||||
static int viewpage = ANAVIEW_FIRST;
|
||||
|
||||
// TODO enum
|
||||
#if defined(TX_CAPACITY_MEASUREMENT)
|
||||
#define ANAS_ITEMS_COUNT 3
|
||||
@@ -32,25 +47,87 @@ void menuRadioDiagAnalogs(event_t event)
|
||||
#define ANAS_ITEMS_COUNT 1
|
||||
#endif
|
||||
|
||||
SIMPLE_SUBMENU(STR_MENU_RADIO_ANALOGS, HEADER_LINE+ANAS_ITEMS_COUNT);
|
||||
switch (event) {
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
#if defined(KEYS_GPIO_REG_PAGEDN)
|
||||
case EVT_KEY_BREAK(KEY_PAGEDN):
|
||||
#elif defined(NAVIGATION_X7)
|
||||
case EVT_KEY_BREAK(KEY_PAGE):
|
||||
#endif
|
||||
{
|
||||
if (viewpage == ANAVIEW_LAST)
|
||||
viewpage = ANAVIEW_FIRST;
|
||||
else
|
||||
viewpage++;
|
||||
if (viewpage == ANAVIEW_RAWLOWFPS) entryCount = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
#if defined(KEYS_GPIO_REG_PAGEUP)
|
||||
case EVT_KEY_BREAK(KEY_PAGEUP):
|
||||
#elif defined(NAVIGATION_X7)
|
||||
case EVT_KEY_LONG(KEY_PAGE):
|
||||
#endif
|
||||
{
|
||||
if (viewpage == ANAVIEW_FIRST)
|
||||
viewpage = ANAVIEW_LAST;
|
||||
else
|
||||
viewpage--;
|
||||
if (viewpage == ANAVIEW_RAWLOWFPS) entryCount = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (viewpage) {
|
||||
case (ANAVIEW_CALIB):
|
||||
SIMPLE_SUBMENU(STR_MENU_RADIO_ANALOGS_CALIB,
|
||||
HEADER_LINE+ANAS_ITEMS_COUNT);
|
||||
break;
|
||||
case (ANAVIEW_RAWLOWFPS):
|
||||
SIMPLE_SUBMENU(STR_MENU_RADIO_ANALOGS_RAWLOWFPS,
|
||||
HEADER_LINE+ANAS_ITEMS_COUNT);
|
||||
break;
|
||||
}
|
||||
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1;
|
||||
|
||||
lcdDrawTextAlignedLeft(y, STICKS_PWM_ENABLED() ? STR_PWM_STICKS_POTS_SLIDERS : STR_STICKS_POTS_SLIDERS);
|
||||
lcdDrawTextAlignedLeft(y, STICKS_PWM_ENABLED() ? STR_PWM_STICKS_POTS_SLIDERS
|
||||
: STR_STICKS_POTS_SLIDERS);
|
||||
|
||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
|
||||
for (uint8_t i = 0; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
|
||||
uint8_t x;
|
||||
if (i & 1) {
|
||||
x = LCD_W/2 + INDENT_WIDTH;
|
||||
}
|
||||
else {
|
||||
x = LCD_W / 2 + INDENT_WIDTH;
|
||||
} else {
|
||||
x = INDENT_WIDTH;
|
||||
y += FH;
|
||||
}
|
||||
drawStringWithIndex(x, y, "A", i+1);
|
||||
drawStringWithIndex(x, y, "A", i + 1);
|
||||
lcdDrawChar(lcdNextPos, y, ':');
|
||||
lcdDrawHexNumber(x+3*FW-1, y, anaIn(i));
|
||||
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256, RIGHT);
|
||||
switch (viewpage) {
|
||||
case (ANAVIEW_RAWLOWFPS):
|
||||
if (entryCount == 0) {
|
||||
lastShownAnalogValue[i] = getAnalogValue(i); // Update value
|
||||
}
|
||||
lcdDrawNumber(x+3*FW-1, y, lastShownAnalogValue[i],
|
||||
LEADING0|LEFT, 4);
|
||||
break;
|
||||
case (ANAVIEW_CALIB):
|
||||
default:
|
||||
lcdDrawNumber(x+3*FW-1, y, anaIn(i), LEADING0|LEFT, 4);
|
||||
break;
|
||||
}
|
||||
lcdDrawNumber(x+10*FW-1, y,
|
||||
(int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256,
|
||||
RIGHT);
|
||||
}
|
||||
|
||||
if (viewpage == ANAVIEW_RAWLOWFPS) {
|
||||
if (entryCount > HOLDANAVALUEFRAMES)
|
||||
entryCount = 0;
|
||||
else
|
||||
entryCount++;
|
||||
}
|
||||
|
||||
#if defined(GYRO)
|
||||
|
||||
@@ -20,17 +20,58 @@
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
#include "../../hal/adc_driver.h"
|
||||
|
||||
#define HOLDANAVALUEFRAMES 4 /* 4* 50ms = 200 ms update rate */
|
||||
|
||||
void menuRadioDiagAnalogs(event_t event)
|
||||
{
|
||||
SIMPLE_SUBMENU(STR_MENU_RADIO_ANALOGS, 0);
|
||||
static int8_t entryCount = 0;
|
||||
static uint16_t lastShownAnalogValue[NUM_STICKS+NUM_POTS+NUM_SLIDERS];
|
||||
|
||||
enum ANAVIEWS{
|
||||
ANAVIEW_FIRST,
|
||||
ANAVIEW_CALIB=ANAVIEW_FIRST,
|
||||
ANAVIEW_RAWLOWFPS,
|
||||
ANAVIEW_LAST=ANAVIEW_RAWLOWFPS
|
||||
};
|
||||
|
||||
static int viewpage = ANAVIEW_FIRST;
|
||||
|
||||
if (event == EVT_KEY_BREAK(KEY_PAGE)) {
|
||||
if (viewpage == ANAVIEW_LAST)
|
||||
viewpage = ANAVIEW_FIRST;
|
||||
else
|
||||
viewpage++;
|
||||
if (viewpage == ANAVIEW_RAWLOWFPS)
|
||||
entryCount = 0;
|
||||
}
|
||||
|
||||
switch (viewpage)
|
||||
{
|
||||
case (ANAVIEW_CALIB): SIMPLE_SUBMENU(STR_MENU_RADIO_ANALOGS_CALIB, 0); break;
|
||||
case (ANAVIEW_RAWLOWFPS): SIMPLE_SUBMENU(STR_MENU_RADIO_ANALOGS_RAWLOWFPS, 0); break;
|
||||
}
|
||||
|
||||
for (uint8_t i=0; i<NUM_STICKS+NUM_POTS+NUM_SLIDERS; i++) {
|
||||
coord_t y = MENU_HEADER_HEIGHT + 1 + (i/2)*FH;
|
||||
uint8_t x = i&1 ? LCD_W/2 + FW : 0;
|
||||
lcdDrawNumber(x, y, i+1, LEADING0|LEFT, 2);
|
||||
lcdDrawChar(x+2*FW-2, y, ':');
|
||||
lcdDrawHexNumber(x+3*FW-1, y, anaIn(i));
|
||||
|
||||
switch (viewpage)
|
||||
{
|
||||
case (ANAVIEW_RAWLOWFPS):
|
||||
if (entryCount == 0)
|
||||
{
|
||||
lastShownAnalogValue[i] = getAnalogValue(i); // Update value
|
||||
}
|
||||
lcdDrawNumber(x+3*FW-1, y, lastShownAnalogValue[i], LEADING0|LEFT, 4);
|
||||
break;
|
||||
case (ANAVIEW_CALIB):
|
||||
default:
|
||||
lcdDrawNumber(x+3*FW-1, y, anaIn(i), LEADING0|LEFT, 4); break;
|
||||
}
|
||||
#if defined(JITTER_MEASURE)
|
||||
lcdDrawNumber(x+10*FW-1, y, rawJitter[i].get(), RIGHT);
|
||||
lcdDrawNumber(x+13*FW-1, y, avgJitter[i].get(), RIGHT);
|
||||
@@ -39,4 +80,12 @@ void menuRadioDiagAnalogs(event_t event)
|
||||
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256, RIGHT);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (viewpage == ANAVIEW_RAWLOWFPS)
|
||||
{
|
||||
if (entryCount > HOLDANAVALUEFRAMES)
|
||||
entryCount = 0;
|
||||
else
|
||||
entryCount++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "opentx.h"
|
||||
#include "radio_diaganas.h"
|
||||
#include "libopenui.h"
|
||||
#include "../../hal/adc_driver.h"
|
||||
|
||||
#if defined(IMU_LSM6DS33)
|
||||
#include "imu_lsm6ds33.h"
|
||||
@@ -31,11 +32,26 @@
|
||||
#include "../../targets/horus/flyskyHallStick_driver.h"
|
||||
#endif
|
||||
|
||||
constexpr coord_t ANA_OFFSET = 150;
|
||||
#define STATSDEPTH 8 // ideally a value of power of 2
|
||||
|
||||
class RadioAnalogsDiagsWindow: public Window {
|
||||
constexpr coord_t CA_X_OFFSET = 70;
|
||||
constexpr coord_t VALUE_X_OFFSET = 120;
|
||||
constexpr coord_t DEV_X_OFFSET = 125;
|
||||
constexpr coord_t MIN_X_OFFSET = 115;
|
||||
constexpr coord_t MAX_X_OFFSET = 165;
|
||||
constexpr coord_t RANGE_X_OFFSET = 170;
|
||||
|
||||
RadioAnalogsDiagsViewPageGroup::RadioAnalogsDiagsViewPageGroup() : TabsGroup(ICON_STATS)
|
||||
{
|
||||
addTab(new AnaCalibratedViewPage());
|
||||
addTab(new AnaFilteredDevViewPage());
|
||||
addTab(new AnaUnfilteredRawViewPage());
|
||||
addTab(new AnaMinMaxViewPage());
|
||||
}
|
||||
|
||||
class AnaCalibratedViewWindow: public Window {
|
||||
public:
|
||||
RadioAnalogsDiagsWindow(Window * parent, const rect_t & rect):
|
||||
AnaCalibratedViewWindow(Window * parent, const rect_t & rect):
|
||||
Window(parent, rect)
|
||||
{
|
||||
}
|
||||
@@ -52,31 +68,31 @@ class RadioAnalogsDiagsWindow: public Window {
|
||||
if (globalData.flyskygimbals)
|
||||
{
|
||||
for (uint8_t i = 0; i < FLYSKY_HALL_CHANNEL_COUNT; i++) {
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + i * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + i * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
|
||||
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + 3 * 15 - 1, y, hall_raw_values[i], LEFT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + ANA_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + CA_X_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + VALUE_X_OFFSET, y, hall_raw_values[i], RIGHT | COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
|
||||
for (uint8_t i = FLYSKY_HALL_CHANNEL_COUNT; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + i * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + i * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
|
||||
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + 3 * 15 -1, y, anaIn(i), LEFT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + ANA_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + CA_X_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + VALUE_X_OFFSET, y, anaIn(i), RIGHT | COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -84,17 +100,17 @@ class RadioAnalogsDiagsWindow: public Window {
|
||||
if (!globalData.flyskygimbals) // Also Simulator
|
||||
{
|
||||
for (uint8_t i = 0; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + i * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + i * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
|
||||
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + 3 * 15 -1, y, anaIn(i), LEFT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + ANA_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + CA_X_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + VALUE_X_OFFSET, y, anaIn(i), RIGHT | COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +130,7 @@ class RadioAnalogsDiagsWindow: public Window {
|
||||
|
||||
#if defined(HARDWARE_TOUCH)
|
||||
TouchState rawTouchState = getInternalTouchState();
|
||||
constexpr coord_t y = MENU_CONTENT_TOP + 5 * FH;
|
||||
constexpr coord_t y = MENU_CONTENT_TOP + 4 * FH;
|
||||
|
||||
if (rawTouchState.event != TE_NONE && rawTouchState.event != TE_SLIDE_END) {
|
||||
coord_t x = dc->drawText(MENUS_MARGIN_LEFT, y, STR_TOUCH_PANEL);
|
||||
@@ -124,34 +140,403 @@ class RadioAnalogsDiagsWindow: public Window {
|
||||
dc->drawLine(rawTouchState.x - 10, rawTouchState.y - 8 - parent->top(), rawTouchState.x + 10, rawTouchState.y + 8 - parent->top(), SOLID, 0);
|
||||
dc->drawLine(rawTouchState.x - 10, rawTouchState.y + 8 - parent->top(), rawTouchState.x + 10, rawTouchState.y - 8- parent->top(), SOLID, 0);
|
||||
}
|
||||
#if !defined(SIMU) && !defined(PCBNV14)
|
||||
constexpr coord_t y1 = MENU_CONTENT_TOP + 6 * FH;
|
||||
coord_t x1 = MENUS_MARGIN_LEFT;
|
||||
x1 = dc->drawText(x1, y1, "Touch GT911 FW ver:") + 8;
|
||||
x1 = dc->drawNumber(x1, y1, touchGT911fwver, LEFT, 4) + 16;
|
||||
x1 = dc->drawText(x1, y1, "TSI2CEvents:") + 4;
|
||||
dc->drawNumber(x1, y1, touchGT911hiccups, LEFT, 5);
|
||||
#endif
|
||||
#if !defined(SIMU) && !defined(PCBNV14)
|
||||
constexpr coord_t y1 = MENU_CONTENT_TOP + 5 * FH;
|
||||
coord_t x1 = MENUS_MARGIN_LEFT;
|
||||
x1 = dc->drawText(x1, y1, "Touch GT911 FW ver:") + 8;
|
||||
x1 = dc->drawNumber(x1, y1, touchGT911fwver, LEFT, 4) + 16;
|
||||
x1 = dc->drawText(x1, y1, "TSI2CEvents:") + 4;
|
||||
dc->drawNumber(x1, y1, touchGT911hiccups, LEFT, 5);
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
void RadioAnalogsDiagsPage::buildHeader(Window * window)
|
||||
class AnaFilteredDevViewWindow: public Window {
|
||||
protected:
|
||||
class Stats {
|
||||
protected:
|
||||
int16_t buffer[STATSDEPTH] = {0};
|
||||
uint8_t writePos = 0;
|
||||
uint8_t filledElems = 0;
|
||||
|
||||
int16_t intSqrt(int16_t val)
|
||||
{
|
||||
if (val < 0)
|
||||
return 0;
|
||||
if (val <= 1)
|
||||
return val;
|
||||
|
||||
// Try iteratively until i^2 >= val
|
||||
int i = 1, retval = 1;
|
||||
while (retval <= val)
|
||||
{
|
||||
i++;
|
||||
retval = i * i;
|
||||
}
|
||||
return i - 1;
|
||||
}
|
||||
int16_t meanVal()
|
||||
{
|
||||
if (filledElems)
|
||||
{
|
||||
int sum = 0;
|
||||
for (uint8_t i=0; i<filledElems; i++)
|
||||
sum += buffer[i];
|
||||
return (int16_t)(sum/filledElems);
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public:
|
||||
Stats() {}
|
||||
|
||||
void clear()
|
||||
{
|
||||
writePos = 0;
|
||||
filledElems = 0;
|
||||
}
|
||||
|
||||
// Always accept new data, discard old
|
||||
void write(int16_t value)
|
||||
{
|
||||
buffer[writePos] = value;
|
||||
writePos = (writePos + 1) % STATSDEPTH;
|
||||
if (filledElems < STATSDEPTH)
|
||||
filledElems++;
|
||||
}
|
||||
|
||||
uint16_t maxDev()
|
||||
{
|
||||
if (filledElems)
|
||||
{
|
||||
uint16_t ret = 0;
|
||||
for (uint8_t i=0; i<filledElems; i++)
|
||||
ret = max<uint16_t>(ret, abs(buffer[i] - meanVal()));
|
||||
return ret;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16_t stdDev()
|
||||
{
|
||||
if (filledElems)
|
||||
{
|
||||
int16_t mean=meanVal();
|
||||
int calc = 0;
|
||||
for (uint8_t i=0; i<filledElems; i++)
|
||||
calc += (buffer[i] - mean)*(buffer[i] - mean);
|
||||
calc = intSqrt((int16_t)(calc/filledElems));
|
||||
return (int16_t)calc;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
bool ClearStats = true;
|
||||
|
||||
public:
|
||||
AnaFilteredDevViewWindow(Window * parent, const rect_t & rect):
|
||||
Window(parent, rect) {}
|
||||
|
||||
void checkEvents() override
|
||||
{
|
||||
// will always force a full monitor window refresh
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void paint(BitmapBuffer * dc) override
|
||||
{
|
||||
static Stats stats[NUM_STICKS+NUM_POTS+NUM_SLIDERS];
|
||||
|
||||
if (ClearStats)
|
||||
{
|
||||
for (uint8_t i = 0; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
|
||||
stats[i].clear();
|
||||
}
|
||||
ClearStats = false;
|
||||
}
|
||||
|
||||
#if !defined(SIMU) && (defined(RADIO_FAMILY_T16) || defined(PCBNV14))
|
||||
if (globalData.flyskygimbals)
|
||||
{
|
||||
for (uint8_t i = 0; i < FLYSKY_HALL_CHANNEL_COUNT; i++) {
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + i * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
|
||||
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + CA_X_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
stats[i].write(hall_raw_values[i]);
|
||||
dc->drawNumber(x + VALUE_X_OFFSET, y, hall_raw_values[i], RIGHT | COLOR_THEME_PRIMARY1); // no need to use calculated mean for FlySky - the output is stable enough to display directly
|
||||
dc->drawNumber(dc->drawText(x + DEV_X_OFFSET, y, " +/- ", COLOR_THEME_PRIMARY1), y, stats[i].maxDev(), LEFT | COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
|
||||
for (uint8_t i = FLYSKY_HALL_CHANNEL_COUNT; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + i * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
|
||||
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + CA_X_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
stats[i].write(getAnalogValue(i));
|
||||
extern uint32_t s_anaFilt[NUM_ANALOGS];
|
||||
dc->drawNumber(x + VALUE_X_OFFSET, y, s_anaFilt[i]/JITTER_ALPHA, RIGHT | COLOR_THEME_PRIMARY1); // use integrated filter
|
||||
dc->drawNumber(dc->drawText(x + DEV_X_OFFSET, y, " +/- ", COLOR_THEME_PRIMARY1), y, stats[i].maxDev(), LEFT | COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!globalData.flyskygimbals) // Also Simulator
|
||||
{
|
||||
for (uint8_t i = 0; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + i * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
|
||||
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + CA_X_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
stats[i].write(getAnalogValue(i));
|
||||
#if !defined(SIMU)
|
||||
extern uint32_t s_anaFilt[NUM_ANALOGS];
|
||||
dc->drawNumber(x + VALUE_X_OFFSET, y, s_anaFilt[i]/JITTER_ALPHA, RIGHT | COLOR_THEME_PRIMARY1); // use integrated filter
|
||||
#else
|
||||
dc->drawNumber(x + VALUE_X_OFFSET, y, anaIn(i), RIGHT | COLOR_THEME_PRIMARY1); // for simu, can use directly the input values without filtering
|
||||
#endif
|
||||
dc->drawNumber(dc->drawText(x + DEV_X_OFFSET, y, " +/- ", COLOR_THEME_PRIMARY1), y, stats[i].maxDev(), LEFT | COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
class AnaUnfilteredRawViewWindow: public Window {
|
||||
public:
|
||||
AnaUnfilteredRawViewWindow(Window * parent, const rect_t & rect):
|
||||
Window(parent, rect)
|
||||
{
|
||||
}
|
||||
|
||||
void checkEvents() override
|
||||
{
|
||||
// will always force a full monitor window refresh
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void paint(BitmapBuffer * dc) override
|
||||
{
|
||||
#if !defined(SIMU) && (defined(RADIO_FAMILY_T16) || defined(PCBNV14))
|
||||
if (globalData.flyskygimbals)
|
||||
{
|
||||
for (uint8_t i = 0; i < FLYSKY_HALL_CHANNEL_COUNT; i++) {
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + i * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
|
||||
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + CA_X_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + VALUE_X_OFFSET, y, hall_raw_values[i], RIGHT | COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
|
||||
for (uint8_t i = FLYSKY_HALL_CHANNEL_COUNT; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + i * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
|
||||
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + CA_X_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + VALUE_X_OFFSET, y, getAnalogValue(i), RIGHT | COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!globalData.flyskygimbals) // Also Simulator
|
||||
{
|
||||
for (uint8_t i = 0; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + i * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
|
||||
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + CA_X_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + VALUE_X_OFFSET, y, getAnalogValue(i), RIGHT | COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
class AnaMinMaxViewWindow: public Window {
|
||||
protected:
|
||||
class MinMax {
|
||||
protected:
|
||||
bool noElements = true;
|
||||
int16_t minvalue = INT16_MAX;
|
||||
int16_t maxvalue = INT16_MIN;
|
||||
|
||||
public:
|
||||
MinMax() {}
|
||||
|
||||
void clear()
|
||||
{
|
||||
minvalue = INT16_MAX;
|
||||
maxvalue = INT16_MIN;
|
||||
}
|
||||
|
||||
// Always accept new data, discard old
|
||||
void write(int16_t value)
|
||||
{
|
||||
if (value < minvalue)
|
||||
minvalue = value;
|
||||
if (value > maxvalue)
|
||||
maxvalue = value;
|
||||
}
|
||||
|
||||
int16_t MinVal()
|
||||
{
|
||||
return minvalue;
|
||||
}
|
||||
|
||||
int16_t MaxVal()
|
||||
{
|
||||
return maxvalue;
|
||||
}
|
||||
|
||||
uint16_t Range()
|
||||
{
|
||||
if (maxvalue > minvalue)
|
||||
return (uint16_t)(maxvalue - minvalue);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
bool ClearStats = true;
|
||||
|
||||
public:
|
||||
AnaMinMaxViewWindow(Window * parent, const rect_t & rect):
|
||||
Window(parent, rect) {}
|
||||
|
||||
void checkEvents() override
|
||||
{
|
||||
// will always force a full monitor window refresh
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void paint(BitmapBuffer * dc) override
|
||||
{
|
||||
static MinMax minmax[NUM_STICKS+NUM_POTS+NUM_SLIDERS];
|
||||
|
||||
if (ClearStats)
|
||||
{
|
||||
for (uint8_t i = 0; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
|
||||
minmax[i].clear();
|
||||
}
|
||||
ClearStats = false;
|
||||
}
|
||||
dc->drawText(10, 1, STR_ANADIAGS_MOVE, COLOR_THEME_PRIMARY1);
|
||||
|
||||
#if !defined(SIMU) && (defined(RADIO_FAMILY_T16) || defined(PCBNV14))
|
||||
if (globalData.flyskygimbals)
|
||||
{
|
||||
for (uint8_t i = 0; i < FLYSKY_HALL_CHANNEL_COUNT; i++) {
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2 + 1) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + (i + 1) * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
|
||||
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + CA_X_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
minmax[i].write(hall_raw_values[i]);
|
||||
dc->drawNumber(x + MIN_X_OFFSET, y, minmax[i].MinVal(), RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + MAX_X_OFFSET, y, minmax[i].MaxVal(), RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + RANGE_X_OFFSET, y, minmax[i].Range(), LEFT | COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
|
||||
for (uint8_t i = FLYSKY_HALL_CHANNEL_COUNT; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2 + 1) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + (i + 1) * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
|
||||
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + CA_X_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
minmax[i].write(getAnalogValue(i));
|
||||
dc->drawNumber(x + MIN_X_OFFSET, y, minmax[i].MinVal(), RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + MAX_X_OFFSET, y, minmax[i].MaxVal(), RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + RANGE_X_OFFSET, y, minmax[i].Range(), LEFT | COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!globalData.flyskygimbals) // Also Simulator
|
||||
{
|
||||
for (uint8_t i = 0; i < NUM_STICKS + NUM_POTS + NUM_SLIDERS; i++) {
|
||||
#if LCD_W > LCD_H
|
||||
coord_t y = 1 + (i / 2 + 1) * FH;
|
||||
uint8_t x = i & 1 ? LCD_W / 2 + 10 : 10;
|
||||
#else
|
||||
coord_t y = 1 + (i + 1) * FH;
|
||||
uint8_t x = 10;
|
||||
#endif
|
||||
dc->drawNumber(x, y, i + 1, LEADING0 | LEFT | COLOR_THEME_PRIMARY1, 2);
|
||||
dc->drawText(x + 2 * 15 - 2, y, ":", COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + CA_X_OFFSET, y, (int16_t) calibratedAnalogs[CONVERT_MODE(i)] * 25 / 256, RIGHT | COLOR_THEME_PRIMARY1);
|
||||
minmax[i].write(getAnalogValue(i));
|
||||
dc->drawNumber(x + MIN_X_OFFSET, y, minmax[i].MinVal(), RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + MAX_X_OFFSET, y, minmax[i].MaxVal(), RIGHT | COLOR_THEME_PRIMARY1);
|
||||
dc->drawNumber(x + RANGE_X_OFFSET, y, minmax[i].Range(), LEFT | COLOR_THEME_PRIMARY1);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
void AnaCalibratedViewPage::build(FormWindow *window)
|
||||
{
|
||||
new StaticText(window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP + 10, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, STR_MENU_RADIO_ANALOGS, 0, COLOR_THEME_PRIMARY2);
|
||||
new AnaCalibratedViewWindow(window, {10, 10, window->width() - 10, window->height() - 10});
|
||||
}
|
||||
|
||||
void RadioAnalogsDiagsPage::buildBody(Window * window)
|
||||
void AnaFilteredDevViewPage::build(FormWindow *window)
|
||||
{
|
||||
new RadioAnalogsDiagsWindow(window, {10, 10, window->width() - 10, window->height() - 10});
|
||||
new AnaFilteredDevViewWindow(window, {10, 10, window->width() - 10, window->height() - 10});
|
||||
}
|
||||
|
||||
RadioAnalogsDiagsPage::RadioAnalogsDiagsPage():
|
||||
Page(ICON_MODEL_SETUP)
|
||||
void AnaUnfilteredRawViewPage::build(FormWindow *window)
|
||||
{
|
||||
buildHeader(&header);
|
||||
buildBody(&body);
|
||||
setFocus(SET_FOCUS_DEFAULT);
|
||||
new AnaUnfilteredRawViewWindow(window, {10, 10, window->width() - 10, window->height() - 10});
|
||||
}
|
||||
|
||||
void AnaMinMaxViewPage::build(FormWindow *window)
|
||||
{
|
||||
new AnaMinMaxViewWindow(window, {10, 10, window->width() - 10, window->height() - 10});
|
||||
}
|
||||
|
||||
@@ -19,14 +19,52 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "page.h"
|
||||
#pragma once
|
||||
|
||||
class RadioAnalogsDiagsPage: public Page {
|
||||
public:
|
||||
explicit RadioAnalogsDiagsPage();
|
||||
#include "font.h"
|
||||
#include "opentx.h"
|
||||
#include "static.h"
|
||||
#include "tabsgroup.h"
|
||||
#include "window.h"
|
||||
|
||||
protected:
|
||||
void buildHeader(Window * window);
|
||||
void buildBody(Window * window);
|
||||
class RadioAnalogsDiagsViewPageGroup : public TabsGroup
|
||||
{
|
||||
public:
|
||||
RadioAnalogsDiagsViewPageGroup();
|
||||
};
|
||||
|
||||
class AnaCalibratedViewPage : public PageTab
|
||||
{
|
||||
public:
|
||||
AnaCalibratedViewPage() : PageTab(STR_ANADIAGS_CALIB, ICON_STATS_ANALOGS) {}
|
||||
|
||||
protected:
|
||||
void build(FormWindow* window) override;
|
||||
};
|
||||
|
||||
class AnaFilteredDevViewPage : public PageTab
|
||||
{
|
||||
public:
|
||||
AnaFilteredDevViewPage() : PageTab(STR_ANADIAGS_FILTRAWDEV, ICON_STATS_THROTTLE_GRAPH) {}
|
||||
|
||||
protected:
|
||||
void build(FormWindow* window) override;
|
||||
};
|
||||
|
||||
class AnaUnfilteredRawViewPage : public PageTab
|
||||
{
|
||||
public:
|
||||
AnaUnfilteredRawViewPage() : PageTab(STR_ANADIAGS_UNFILTRAW, ICON_RADIO_HARDWARE) {}
|
||||
|
||||
protected:
|
||||
void build(FormWindow* window) override;
|
||||
};
|
||||
|
||||
class AnaMinMaxViewPage : public PageTab
|
||||
{
|
||||
public:
|
||||
AnaMinMaxViewPage() : PageTab(STR_ANADIAGS_MINMAX, ICON_RADIO_CALIBRATION) {}
|
||||
|
||||
protected:
|
||||
void build(FormWindow* window) override;
|
||||
};
|
||||
|
||||
@@ -414,7 +414,7 @@ void RadioHardwarePage::build(FormWindow * window)
|
||||
new StaticText(window, grid.getLabelSlot(), STR_DEBUG, 0, COLOR_THEME_PRIMARY1 | FONT(BOLD));
|
||||
auto debugAnas = new TextButton(window, grid.getFieldSlot(2, 0), STR_ANALOGS_BTN);
|
||||
debugAnas->setPressHandler([=]() -> uint8_t {
|
||||
auto debugAnalogsPage = new RadioAnalogsDiagsPage();
|
||||
auto debugAnalogsPage = new RadioAnalogsDiagsViewPageGroup();
|
||||
debugAnalogsPage->setCloseHandler([=]() {
|
||||
calib->setFocus(SET_FOCUS_DEFAULT);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user