diff --git a/radio/src/gui/480x272/draw_functions.h b/radio/src/gui/480x272/draw_functions.h index 0d872d87e..f4f672c72 100644 --- a/radio/src/gui/480x272/draw_functions.h +++ b/radio/src/gui/480x272/draw_functions.h @@ -74,7 +74,7 @@ void drawShutdownAnimation(uint32_t duration, uint32_t totalDuration, const char // Main view standard widgets void drawTopBar(); void drawMainPots(); -void drawTrims(uint8_t flightMode); +void drawTrims(uint8_t flightMode, bool sliderdisplayed = true); void drawReceiverName(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t receiverIdx, LcdFlags flags); diff --git a/radio/src/gui/480x272/layouts/layout4+2.cpp b/radio/src/gui/480x272/layouts/layout4+2.cpp new file mode 100644 index 000000000..c9846ec04 --- /dev/null +++ b/radio/src/gui/480x272/layouts/layout4+2.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "opentx.h" + +#define HAS_TOPBAR() (persistentData->options[0].boolValue == true) +#define HAS_FM() (persistentData->options[1].boolValue == true) +#define HAS_SLIDERS() (persistentData->options[2].boolValue == true) +#define HAS_TRIMS() (persistentData->options[3].boolValue == true) +#define IS_MIRRORED() (persistentData->options[4].boolValue == true) + +const uint8_t LBM_LAYOUT_4P2[] = { +#include "mask_layout4+2.lbm" +}; + +const ZoneOption OPTIONS_LAYOUT_4P2[] = { + { STR_TOP_BAR, ZoneOption::Bool }, + { STR_FLIGHT_MODE, ZoneOption::Bool }, + { STR_SLIDERS, ZoneOption::Bool }, + { STR_TRIMS, ZoneOption::Bool }, + { STR_MIRROR, ZoneOption::Bool }, + { NULL, ZoneOption::Bool } +}; + +class Layout4P2: public Layout +{ + public: + Layout4P2(const LayoutFactory * factory, Layout::PersistentData * persistentData): + Layout(factory, persistentData) + { + } + + virtual void create() + { + Layout::create(); + persistentData->options[0].boolValue = true; + persistentData->options[1].boolValue = true; + persistentData->options[2].boolValue = true; + persistentData->options[3].boolValue = true; + persistentData->options[4].boolValue = false; + persistentData->options[5].boolValue = false; + } + + virtual unsigned int getZonesCount() const + { + return 6; + } + + virtual Zone getZone(unsigned int index) const + { + coord_t areaw = LCD_W - (HAS_SLIDERS() ? 55 : 8) - (HAS_TRIMS() ? 55 : 8); + coord_t areah = LCD_H - 4 - (HAS_TOPBAR() ? 55 : 8) - (HAS_SLIDERS() ? 26 : 4) - (HAS_TRIMS() ? 26 : 4); + + Zone zone; + zone.x = IS_MIRRORED() ? ((index >= 4) ? (LCD_W - areaw) / 2 - 4 : 245) : ((index >= 4) ? 245 : (LCD_W - areaw) / 2 - 4); + zone.h = (index >= 4) ? (areah / 2) : (areah / 4) - 2; + zone.y = (index >= 4) ? (HAS_TOPBAR() ? 52 : 6) + (index == 5 ? zone.h + ((HAS_TRIMS() + HAS_SLIDERS() == 1) ? 8 : 10): 0): (HAS_TOPBAR() ? 52 : 6) + (index % 4) * (zone.h + 6); + zone.w = areaw / 2; + + return zone; + } + + virtual void refresh(); +}; + +void Layout4P2::refresh() +{ + theme->drawBackground(); + + if (HAS_TOPBAR()) { + drawTopBar(); + } + + if (HAS_FM()) { + // Flight mode + lcdDrawSizedText(LCD_W / 2 - getTextWidth(g_model.flightModeData[mixerCurrentFlightMode].name, sizeof(g_model.flightModeData[mixerCurrentFlightMode].name), + ZCHAR | SMLSIZE) / 2, 232, g_model.flightModeData[mixerCurrentFlightMode].name, + sizeof(g_model.flightModeData[mixerCurrentFlightMode].name), ZCHAR | SMLSIZE); + } + + if (HAS_SLIDERS()) { + // Pots and rear sliders positions + drawMainPots(); + } + + if (HAS_TRIMS()) { + // Trims + drawTrims(mixerCurrentFlightMode, HAS_SLIDERS()); + } + + Layout::refresh(); +} + +BaseLayoutFactory layout4P2("Layout4P2", LBM_LAYOUT_4P2, OPTIONS_LAYOUT_4P2); \ No newline at end of file diff --git a/radio/src/gui/480x272/layouts/mask_layout4+2.png b/radio/src/gui/480x272/layouts/mask_layout4+2.png new file mode 100644 index 000000000..c441da1a3 Binary files /dev/null and b/radio/src/gui/480x272/layouts/mask_layout4+2.png differ diff --git a/radio/src/gui/480x272/radio_diaganas.cpp b/radio/src/gui/480x272/radio_diaganas.cpp index 19e50914f..b971cdd2a 100644 --- a/radio/src/gui/480x272/radio_diaganas.cpp +++ b/radio/src/gui/480x272/radio_diaganas.cpp @@ -26,7 +26,6 @@ #endif constexpr coord_t LEFT_NAME_COLUMN = MENUS_MARGIN_LEFT; -constexpr coord_t RIGHT_NAME_COLUMN = LCD_W / 2; constexpr coord_t ANA_OFFSET = 150; bool menuRadioDiagAnalogs(event_t event) diff --git a/radio/src/gui/480x272/screens_setup.cpp b/radio/src/gui/480x272/screens_setup.cpp index e73afed68..8738d564a 100644 --- a/radio/src/gui/480x272/screens_setup.cpp +++ b/radio/src/gui/480x272/screens_setup.cpp @@ -614,6 +614,7 @@ bool menuScreenSetup(int index, event_t event) ZoneOptionValue * value = currentScreen->getOptionValue(o); if (editZoneOption(y, option, value, attr, EE_MODEL, event)) { currentScreen->update(); + loadCustomScreens(); } } else if (menuPageCount > 3 && o == optionsCount) { diff --git a/radio/src/gui/480x272/view_main.cpp b/radio/src/gui/480x272/view_main.cpp index cbc38b69b..91482e843 100644 --- a/radio/src/gui/480x272/view_main.cpp +++ b/radio/src/gui/480x272/view_main.cpp @@ -22,7 +22,7 @@ #define TRIM_LH_X 10 #define TRIM_LV_X 24 -#define TRIM_RV_X (LCD_W-35) +#define TRIM_RV_X (LCD_W-36) #define TRIM_RH_X (LCD_W-175) #define TRIM_V_Y 55 #define TRIM_H_Y (LCD_H-37) @@ -47,10 +47,10 @@ void drawMainPots() drawVerticalSlider(LCD_W-18, TRIM_V_Y, 160, calibratedAnalogs[CALIBRATED_SLIDER_REAR_RIGHT], -RESX, RESX, 40, OPTION_SLIDER_TICKS | OPTION_SLIDER_BIG_TICKS | OPTION_SLIDER_SQUARE_BUTTON); } -void drawTrims(uint8_t flightMode) +void drawTrims(uint8_t flightMode, bool sliderdisplayed) { for (uint8_t i=0; i<4; i++) { - static const coord_t x[4] = { TRIM_LH_X, TRIM_LV_X, TRIM_RV_X, TRIM_RH_X }; + coord_t x[4] = { TRIM_LH_X, sliderdisplayed ? TRIM_LV_X : 4, sliderdisplayed ? TRIM_RV_X : TRIM_RV_X + 18, TRIM_RH_X }; static uint8_t vert[4] = {0, 1, 1, 0}; unsigned int stickIndex = CONVERT_MODE(i); coord_t xm = x[stickIndex]; @@ -76,15 +76,15 @@ void drawTrims(uint8_t flightMode) } else { if (g_model.extendedTrims == 1) { - drawHorizontalSlider(xm, TRIM_H_Y, 160, trim, TRIM_EXTENDED_MIN, TRIM_EXTENDED_MAX, 0, OPTION_SLIDER_EMPTY_BAR|OPTION_SLIDER_TRIM_BUTTON); + drawHorizontalSlider(xm, sliderdisplayed ? TRIM_H_Y : TRIM_H_Y + 22, 160, trim, TRIM_EXTENDED_MIN, TRIM_EXTENDED_MAX, 0, OPTION_SLIDER_EMPTY_BAR|OPTION_SLIDER_TRIM_BUTTON); } else { - drawHorizontalSlider(xm, TRIM_H_Y, 160, trim, TRIM_MIN, TRIM_MAX, 0, OPTION_SLIDER_EMPTY_BAR|OPTION_SLIDER_TRIM_BUTTON); + drawHorizontalSlider(xm, sliderdisplayed ? TRIM_H_Y : TRIM_H_Y + 20, 160, trim, TRIM_MIN, TRIM_MAX, 0, OPTION_SLIDER_EMPTY_BAR|OPTION_SLIDER_TRIM_BUTTON); } if (g_model.displayTrims != DISPLAY_TRIMS_NEVER && trim != 0) { if (g_model.displayTrims == DISPLAY_TRIMS_ALWAYS || (trimsDisplayTimer > 0 && (trimsDisplayMask & (1<0 ? -TRIM_LEN/2 : TRIM_LEN/2); - lcdDrawNumber(x, TRIM_H_Y+2, trim, TINSIZE | CENTERED); + lcdDrawNumber(x, sliderdisplayed ? TRIM_H_Y + 2 : TRIM_H_Y + 22, trim, TINSIZE | CENTERED); } } } diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index f7a6e04f8..4883d7f58 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -131,6 +131,7 @@ const char STR_REFRESHRATE[] = TR_REFRESHRATE; const char STR_MS[] = TR_MS; const char STR_SWITCH[] = TR_SWITCH; const char STR_TRIMS[] = TR_TRIMS; +const char STR_MIRROR[] = TR_MIRROR; const char STR_FADEIN[] = TR_FADEIN; const char STR_FADEOUT[] = TR_FADEOUT; const char STR_DEFAULT[] = TR_DEFAULT; @@ -548,7 +549,6 @@ const char STR_MIN[] = TR_MIN; const char STR_MAX[] = TR_MAX; const char STR_CURVE_PRESET[] = TR_CURVE_PRESET; const char STR_PRESET[] = TR_PRESET; -const char STR_MIRROR[] = TR_MIRROR; const char STR_CLEAR[] = TR_CLEAR; const char STR_RESET[] = TR_RESET; const char STR_COUNT[] = TR_COUNT; diff --git a/radio/src/translations.h b/radio/src/translations.h index 1e02adcf9..8fa8bddb3 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -228,6 +228,7 @@ extern const char STR_REFRESHRATE[]; extern const char STR_MS[]; extern const char STR_SWITCH[]; extern const char STR_TRIMS[]; +extern const char STR_MIRROR[]; extern const char STR_FADEIN[]; extern const char STR_FADEOUT[]; extern const char STR_DEFAULT[]; @@ -854,7 +855,6 @@ extern const char STR_MIN[]; extern const char STR_MAX[]; extern const char STR_CURVE_PRESET[]; extern const char STR_PRESET[]; -extern const char STR_MIRROR[]; extern const char STR_CLEAR[]; extern const char STR_RESET[]; extern const char STR_COUNT[];