Add 4+2 super flexi layout (#7992)

This commit is contained in:
3djc
2020-10-16 16:28:32 +02:00
committed by GitHub
parent 596738b968
commit 4aae4983e5
8 changed files with 121 additions and 10 deletions
+1 -1
View File
@@ -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);
+111
View File
@@ -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("Layout4P2", LBM_LAYOUT_4P2, OPTIONS_LAYOUT_4P2);
Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

-1
View File
@@ -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)
+1
View File
@@ -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) {
+6 -6
View File
@@ -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<<i)))) {
uint16_t x = xm + TRIM_LEN + (trim>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);
}
}
}
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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[];