Skip to content

Commit

Permalink
feat(bw): Change layout of telemetry page on B&W radios to match colo…
Browse files Browse the repository at this point in the history
…r layout (EdgeTX#3770)

* Improve telemetry sensors view

* Improve telemetry sensors view (212)

* Remove undue TRACES

* COLORLCD compilation fix

* chore: Quit your no EoF newline whining Github!

---------

Co-authored-by: Phil Mitchell <phil.a.mitchell@gmail.com>
  • Loading branch information
2 people authored and pfeerick committed Jul 7, 2023
1 parent a6323b5 commit 16c6852
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 43 deletions.
11 changes: 0 additions & 11 deletions radio/src/gui/128x64/model_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,17 +542,6 @@ uint8_t viewOptChoice(coord_t y, const char* title, uint8_t value, uint8_t attr,
return editChoice(96, y, nullptr, STR_ADCFILTERVALUES, value, 0, 2, attr, event);
}

uint8_t expandableSection(coord_t y, const char* title, uint8_t value, uint8_t attr, event_t event)
{
lcdDrawTextAlignedLeft(y, title);
lcdDrawText(120, y, value ? STR_CHAR_UP : STR_CHAR_DOWN, attr);
if (attr && (event == EVT_KEY_BREAK(KEY_ENTER))) {
value = !value;
s_editMode = 0;
}
return value;
}

void menuModelSetup(event_t event)
{
int8_t old_editMode = s_editMode;
Expand Down
29 changes: 21 additions & 8 deletions radio/src/gui/128x64/model_telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@

enum MenuModelTelemetryFrskyItems {
ITEM_TELEMETRY_PROTOCOL_TYPE,
ITEM_TELEMETRY_RSSI_LABEL,
ITEM_TELEMETRY_RSSI_ALARM1,
ITEM_TELEMETRY_RSSI_ALARM2,
ITEM_TELEMETRY_DISABLE_ALARMS,
ITEM_TELEMETRY_SENSORS_LABEL,
ITEM_TELEMETRY_SENSOR_FIRST,
ITEM_TELEMETRY_SENSOR_LAST = ITEM_TELEMETRY_SENSOR_FIRST + MAX_TELEMETRY_SENSORS - 1,
ITEM_TELEMETRY_DISCOVER_SENSORS,
ITEM_TELEMETRY_NEW_SENSOR,
ITEM_TELEMETRY_DELETE_ALL_SENSORS,
ITEM_TELEMETRY_IGNORE_SENSOR_INSTANCE,
ITEM_TELEMETRY_RSSI_LABEL,
ITEM_TELEMETRY_RSSI_ALARM1,
ITEM_TELEMETRY_RSSI_ALARM2,
ITEM_TELEMETRY_DISABLE_ALARMS,
#if defined(VARIO)
ITEM_TELEMETRY_VARIO_LABEL,
ITEM_TELEMETRY_VARIO_SOURCE,
Expand All @@ -43,6 +43,19 @@ enum MenuModelTelemetryFrskyItems {
ITEM_TELEMETRY_MAX
};

PACK(struct ExpandState {
uint8_t sensors:1;
});

struct ExpandState telemExpandState;

uint8_t SENSOR_ROW(uint8_t value)
{
if (telemExpandState.sensors)
return value;
return HIDDEN_ROW;
}

#if defined(TRANSLATIONS_CZ)
#define TELEM_COL2 (9*FW)
#else
Expand All @@ -52,8 +65,8 @@ enum MenuModelTelemetryFrskyItems {
#define TELEM_COL3 (17 * FW)

#define RSSI_ROWS LABEL(RSSI), 0, 0, 0,
#define SENSOR_ROWS(x) (isTelemetryFieldAvailable(x) ? (uint8_t)0 : HIDDEN_ROW)
#define SENSORS_ROWS LABEL(Sensors), SENSOR_ROWS(0), SENSOR_ROWS(1), SENSOR_ROWS(2), SENSOR_ROWS(3), SENSOR_ROWS(4), SENSOR_ROWS(5), SENSOR_ROWS(6), SENSOR_ROWS(7), SENSOR_ROWS(8), SENSOR_ROWS(9), SENSOR_ROWS(10), SENSOR_ROWS(11), SENSOR_ROWS(12), SENSOR_ROWS(13), SENSOR_ROWS(14), SENSOR_ROWS(15), SENSOR_ROWS(16), SENSOR_ROWS(17), SENSOR_ROWS(18), SENSOR_ROWS(19), SENSOR_ROWS(20), SENSOR_ROWS(21), SENSOR_ROWS(22), SENSOR_ROWS(23), SENSOR_ROWS(24), SENSOR_ROWS(25), SENSOR_ROWS(26), SENSOR_ROWS(27), SENSOR_ROWS(28), SENSOR_ROWS(29), SENSOR_ROWS(30), SENSOR_ROWS(31), SENSOR_ROWS(32), SENSOR_ROWS(33), SENSOR_ROWS(34), SENSOR_ROWS(35), SENSOR_ROWS(36), SENSOR_ROWS(37), SENSOR_ROWS(38), SENSOR_ROWS(39), 0, 0, 0, 0,
#define SENSOR_ROWS(x) SENSOR_ROW((isTelemetryFieldAvailable(x) ? (uint8_t)0 : HIDDEN_ROW))
#define SENSORS_ROWS 0, SENSOR_ROWS(0), SENSOR_ROWS(1), SENSOR_ROWS(2), SENSOR_ROWS(3), SENSOR_ROWS(4), SENSOR_ROWS(5), SENSOR_ROWS(6), SENSOR_ROWS(7), SENSOR_ROWS(8), SENSOR_ROWS(9), SENSOR_ROWS(10), SENSOR_ROWS(11), SENSOR_ROWS(12), SENSOR_ROWS(13), SENSOR_ROWS(14), SENSOR_ROWS(15), SENSOR_ROWS(16), SENSOR_ROWS(17), SENSOR_ROWS(18), SENSOR_ROWS(19), SENSOR_ROWS(20), SENSOR_ROWS(21), SENSOR_ROWS(22), SENSOR_ROWS(23), SENSOR_ROWS(24), SENSOR_ROWS(25), SENSOR_ROWS(26), SENSOR_ROWS(27), SENSOR_ROWS(28), SENSOR_ROWS(29), SENSOR_ROWS(30), SENSOR_ROWS(31), SENSOR_ROWS(32), SENSOR_ROWS(33), SENSOR_ROWS(34), SENSOR_ROWS(35), SENSOR_ROWS(36), SENSOR_ROWS(37), SENSOR_ROWS(38), SENSOR_ROWS(39), 0, 0, 0, 0,
#if defined(VARIO)
#define VARIO_ROWS LABEL(Vario), 0, 1, 2,
#else
Expand Down Expand Up @@ -113,7 +126,7 @@ void onDeleteAllSensorsConfirm(const char * result)

void menuModelTelemetry(event_t event)
{
MENU(STR_MENUTELEMETRY, menuTabModel, MENU_MODEL_TELEMETRY, HEADER_LINE+ITEM_TELEMETRY_MAX, { HEADER_LINE_COLUMNS TELEMETRY_TYPE_ROWS RSSI_ROWS SENSORS_ROWS VARIO_ROWS });
MENU(STR_MENUTELEMETRY, menuTabModel, MENU_MODEL_TELEMETRY, HEADER_LINE+ITEM_TELEMETRY_MAX, { HEADER_LINE_COLUMNS TELEMETRY_TYPE_ROWS SENSORS_ROWS RSSI_ROWS VARIO_ROWS });

uint8_t sub = menuVerticalPosition - HEADER_LINE;

Expand Down Expand Up @@ -184,7 +197,7 @@ void menuModelTelemetry(event_t event)


case ITEM_TELEMETRY_SENSORS_LABEL:
lcdDrawTextAlignedLeft(y, STR_TELEMETRY_SENSORS);
telemExpandState.sensors = expandableSection(y, STR_TELEMETRY_SENSORS, telemExpandState.sensors, attr, event);
break;

case ITEM_TELEMETRY_DISCOVER_SENSORS:
Expand Down
11 changes: 0 additions & 11 deletions radio/src/gui/212x64/model_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,17 +490,6 @@ uint8_t viewOptChoice(coord_t y, const char* title, uint8_t value, uint8_t attr,
return rv;
}

uint8_t expandableSection(coord_t y, const char* title, uint8_t value, uint8_t attr, event_t event)
{
lcdDrawTextAlignedLeft(y, title);
lcdDrawText(200, y, value ? STR_CHAR_UP : STR_CHAR_DOWN, attr);
if (attr && (event == EVT_KEY_BREAK(KEY_ENTER))) {
value = !value;
s_editMode = 0;
}
return value;
}

void menuModelSetup(event_t event)
{
horzpos_t l_posHorz = menuHorizontalPosition;
Expand Down
37 changes: 26 additions & 11 deletions radio/src/gui/212x64/model_telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@

enum MenuModelTelemetryFrskyItems {
ITEM_TELEMETRY_PROTOCOL_TYPE,
ITEM_TELEMETRY_RSSI_LABEL,
ITEM_TELEMETRY_RSSI_ALARM1,
ITEM_TELEMETRY_RSSI_ALARM2,
ITEM_TELEMETRY_DISABLE_ALARMS,
ITEM_TELEMETRY_SENSORS_LABEL,
ITEM_TELEMETRY_SENSOR_FIRST,
ITEM_TELEMETRY_SENSOR_LAST = ITEM_TELEMETRY_SENSOR_FIRST + MAX_TELEMETRY_SENSORS - 1,
ITEM_TELEMETRY_DISCOVER_SENSORS,
ITEM_TELEMETRY_NEW_SENSOR,
ITEM_TELEMETRY_DELETE_ALL_SENSORS,
ITEM_TELEMETRY_IGNORE_SENSOR_INSTANCE,
ITEM_TELEMETRY_RSSI_LABEL,
ITEM_TELEMETRY_RSSI_ALARM1,
ITEM_TELEMETRY_RSSI_ALARM2,
ITEM_TELEMETRY_DISABLE_ALARMS,
#if defined(VARIO)
ITEM_TELEMETRY_VARIO_LABEL,
ITEM_TELEMETRY_VARIO_SOURCE,
Expand All @@ -43,12 +43,25 @@ enum MenuModelTelemetryFrskyItems {
ITEM_TELEMETRY_MAX
};

PACK(struct ExpandState {
uint8_t sensors:1;
});

struct ExpandState telemExpandState;

uint8_t SENSOR_ROW(uint8_t value)
{
if (telemExpandState.sensors)
return value;
return HIDDEN_ROW;
}

#define TELEM_COL2 (16*FW)
#define TELEM_COL3 (30*FW+2)

#define RSSI_ROWS LABEL(RSSI), 0, 0, 0,
#define SENSOR_ROWS(x) (isTelemetryFieldAvailable(x) ? (uint8_t)0 : HIDDEN_ROW)
#define SENSORS_ROWS LABEL(Sensors), SENSOR_ROWS(0), SENSOR_ROWS(1), SENSOR_ROWS(2), SENSOR_ROWS(3), SENSOR_ROWS(4), SENSOR_ROWS(5), SENSOR_ROWS(6), SENSOR_ROWS(7), SENSOR_ROWS(8), SENSOR_ROWS(9), SENSOR_ROWS(10), SENSOR_ROWS(11), SENSOR_ROWS(12), SENSOR_ROWS(13), SENSOR_ROWS(14), SENSOR_ROWS(15), SENSOR_ROWS(16), SENSOR_ROWS(17), SENSOR_ROWS(18), SENSOR_ROWS(19), SENSOR_ROWS(20), SENSOR_ROWS(21), SENSOR_ROWS(22), SENSOR_ROWS(23), SENSOR_ROWS(24), SENSOR_ROWS(25), SENSOR_ROWS(26), SENSOR_ROWS(27), SENSOR_ROWS(28), SENSOR_ROWS(29), SENSOR_ROWS(30), SENSOR_ROWS(31), SENSOR_ROWS(32), SENSOR_ROWS(33), SENSOR_ROWS(34), SENSOR_ROWS(35), SENSOR_ROWS(36), SENSOR_ROWS(37), SENSOR_ROWS(38), SENSOR_ROWS(39), SENSOR_ROWS(40), SENSOR_ROWS(41), SENSOR_ROWS(42), SENSOR_ROWS(43), SENSOR_ROWS(44), SENSOR_ROWS(45), SENSOR_ROWS(46), SENSOR_ROWS(47), SENSOR_ROWS(48), SENSOR_ROWS(49), SENSOR_ROWS(50), SENSOR_ROWS(51), SENSOR_ROWS(52), SENSOR_ROWS(53), SENSOR_ROWS(54), SENSOR_ROWS(55), SENSOR_ROWS(56), SENSOR_ROWS(57), SENSOR_ROWS(58), SENSOR_ROWS(59), 0, 0, 0, 0,
#define SENSOR_ROWS(x) SENSOR_ROW((isTelemetryFieldAvailable(x) ? (uint8_t)0 : HIDDEN_ROW))
#define SENSORS_ROWS 0, SENSOR_ROWS(0), SENSOR_ROWS(1), SENSOR_ROWS(2), SENSOR_ROWS(3), SENSOR_ROWS(4), SENSOR_ROWS(5), SENSOR_ROWS(6), SENSOR_ROWS(7), SENSOR_ROWS(8), SENSOR_ROWS(9), SENSOR_ROWS(10), SENSOR_ROWS(11), SENSOR_ROWS(12), SENSOR_ROWS(13), SENSOR_ROWS(14), SENSOR_ROWS(15), SENSOR_ROWS(16), SENSOR_ROWS(17), SENSOR_ROWS(18), SENSOR_ROWS(19), SENSOR_ROWS(20), SENSOR_ROWS(21), SENSOR_ROWS(22), SENSOR_ROWS(23), SENSOR_ROWS(24), SENSOR_ROWS(25), SENSOR_ROWS(26), SENSOR_ROWS(27), SENSOR_ROWS(28), SENSOR_ROWS(29), SENSOR_ROWS(30), SENSOR_ROWS(31), SENSOR_ROWS(32), SENSOR_ROWS(33), SENSOR_ROWS(34), SENSOR_ROWS(35), SENSOR_ROWS(36), SENSOR_ROWS(37), SENSOR_ROWS(38), SENSOR_ROWS(39), SENSOR_ROWS(40), SENSOR_ROWS(41), SENSOR_ROWS(42), SENSOR_ROWS(43), SENSOR_ROWS(44), SENSOR_ROWS(45), SENSOR_ROWS(46), SENSOR_ROWS(47), SENSOR_ROWS(48), SENSOR_ROWS(49), SENSOR_ROWS(50), SENSOR_ROWS(51), SENSOR_ROWS(52), SENSOR_ROWS(53), SENSOR_ROWS(54), SENSOR_ROWS(55), SENSOR_ROWS(56), SENSOR_ROWS(57), SENSOR_ROWS(58), SENSOR_ROWS(59), 0, 0, 0, 0,
#if defined(VARIO)
#define VARIO_ROWS LABEL(Vario), 0, 1, 2,
#else
Expand Down Expand Up @@ -101,7 +114,7 @@ void onDeleteAllSensorsConfirm(const char * result)

void menuModelTelemetry(event_t event)
{
MENU(STR_MENUTELEMETRY, menuTabModel, MENU_MODEL_TELEMETRY, HEADER_LINE+ITEM_TELEMETRY_MAX, { HEADER_LINE_COLUMNS TELEMETRY_TYPE_ROWS RSSI_ROWS SENSORS_ROWS VARIO_ROWS });
MENU(STR_MENUTELEMETRY, menuTabModel, MENU_MODEL_TELEMETRY, HEADER_LINE+ITEM_TELEMETRY_MAX, { HEADER_LINE_COLUMNS TELEMETRY_TYPE_ROWS SENSORS_ROWS RSSI_ROWS VARIO_ROWS });

uint8_t sub = menuVerticalPosition - HEADER_LINE;

Expand Down Expand Up @@ -172,10 +185,12 @@ void menuModelTelemetry(event_t event)
break;

case ITEM_TELEMETRY_SENSORS_LABEL:
lcdDrawTextAlignedLeft(y, STR_TELEMETRY_SENSORS);
lcdDrawText(TELEM_COL2, y, STR_VALUE, 0);
if (!g_model.ignoreSensorIds /*&& !IS_SPEKTRUM_PROTOCOL()*/) {
lcdDrawText(TELEM_COL3, y, STR_ID, 0);
telemExpandState.sensors = expandableSection(y, STR_TELEMETRY_SENSORS, telemExpandState.sensors, attr, event);
if (telemExpandState.sensors) {
lcdDrawText(TELEM_COL2, y, STR_VALUE, 0);
if (!g_model.ignoreSensorIds /*&& !IS_SPEKTRUM_PROTOCOL()*/) {
lcdDrawText(TELEM_COL3, y, STR_ID, 0);
}
}
break;

Expand Down
15 changes: 13 additions & 2 deletions radio/src/gui/gui_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,9 +1149,7 @@ const mm_protocol_definition *getMultiProtocolDefinition (uint8_t protocol)
// Return the empty last protocol
return pdef;
}
#endif

#if defined(MULTIMODULE)
const char * getMultiOptionTitleStatic(uint8_t moduleIdx)
{
const uint8_t multi_proto = g_model.moduleData[moduleIdx].multi.rfProtocol;
Expand All @@ -1173,3 +1171,16 @@ const char * getMultiOptionTitle(uint8_t moduleIdx)
return getMultiOptionTitleStatic(moduleIdx);
}
#endif

#if !defined(COLORLCD)
uint8_t expandableSection(coord_t y, const char* title, uint8_t value, uint8_t attr, event_t event)
{
lcdDrawTextAlignedLeft(y, title);
lcdDrawText(LCD_W == 128 ? 120 : 200, y, value ? STR_CHAR_UP : STR_CHAR_DOWN, attr);
if (attr && (event == EVT_KEY_BREAK(KEY_ENTER))) {
value = !value;
s_editMode = 0;
}
return value;
}
#endif
2 changes: 2 additions & 0 deletions radio/src/gui/gui_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,6 @@ const char *getMultiOptionTitle(uint8_t moduleIdx);

const char * writeScreenshot();

uint8_t expandableSection(coord_t y, const char* title, uint8_t value, uint8_t attr, event_t event);

#endif // _GUI_COMMON_H_

0 comments on commit 16c6852

Please sign in to comment.