|
|
|
@@ -95,15 +95,39 @@ void loadCustomScreens()
|
|
|
|
|
screen->attach(ViewMain::instance);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//customScreens[g_model.view]->attach(ViewMain::instance);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Layout::decorate(bool topbar, bool sliders, bool trims, bool flightMode)
|
|
|
|
|
{
|
|
|
|
|
// check if deco setting are still up-to-date
|
|
|
|
|
uint8_t checkSettings =
|
|
|
|
|
(topbar ? 1 << 0 : 0) |
|
|
|
|
|
(sliders ? 1 << 1 : 0) |
|
|
|
|
|
(trims ? 1 << 2 : 0) |
|
|
|
|
|
(flightMode ? 1 << 3 : 0);
|
|
|
|
|
|
|
|
|
|
if (checkSettings == decorationSettings) {
|
|
|
|
|
// everything ok, exit!
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// kill all decorations & re-decorate
|
|
|
|
|
for (auto deco: decorations) {
|
|
|
|
|
deco->deleteLater();
|
|
|
|
|
}
|
|
|
|
|
decorations.clear();
|
|
|
|
|
topBar = nullptr;
|
|
|
|
|
|
|
|
|
|
// effect a full redraw
|
|
|
|
|
invalidate();
|
|
|
|
|
|
|
|
|
|
// save settings
|
|
|
|
|
decorationSettings = checkSettings;
|
|
|
|
|
|
|
|
|
|
if (topbar) {
|
|
|
|
|
topBar = new TopBar(this);
|
|
|
|
|
topBar->load();
|
|
|
|
|
decorations.push_back(topBar);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sliders) {
|
|
|
|
@@ -111,49 +135,69 @@ void Layout::decorate(bool topbar, bool sliders, bool trims, bool flightMode)
|
|
|
|
|
coord_t yOffset = (trims ? - TRIM_SQUARE_SIZE : 0) + (topbar ? TOPBAR_HEIGHT / 2 : 0);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
new MainViewHorizontalSlider(this, {HMARGIN, LCD_H - TRIM_SQUARE_SIZE, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_POT1]; });
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewHorizontalSlider(this, {HMARGIN, LCD_H - TRIM_SQUARE_SIZE, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_POT1]; })
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (IS_POT_MULTIPOS(POT2)) {
|
|
|
|
|
new MainView6POS(this, {LCD_W / 2 - MULTIPOS_W / 2, LCD_H - TRIM_SQUARE_SIZE, MULTIPOS_W + 1, MULTIPOS_H},
|
|
|
|
|
[=] { return (1 + (potsPos[1] & 0x0f)); });
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainView6POS(this, {LCD_W / 2 - MULTIPOS_W / 2, LCD_H - TRIM_SQUARE_SIZE, MULTIPOS_W + 1, MULTIPOS_H},
|
|
|
|
|
[=] { return (1 + (potsPos[1] & 0x0f)); })
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
else if (IS_POT(POT2)) {
|
|
|
|
|
new MainViewHorizontalSlider(this, {LCD_W - HORIZONTAL_SLIDERS_WIDTH - HMARGIN, LCD_H - TRIM_SQUARE_SIZE, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_POT2]; });
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewHorizontalSlider(this, {LCD_W - HORIZONTAL_SLIDERS_WIDTH - HMARGIN, LCD_H - TRIM_SQUARE_SIZE, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_POT2]; })
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if defined(HARDWARE_POT3)
|
|
|
|
|
new MainViewHorizontalSlider(this, {LCD_W - HORIZONTAL_SLIDERS_WIDTH - HMARGIN, LCD_H - TRIM_SQUARE_SIZE, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_POT3]; });
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewHorizontalSlider(this, {LCD_W - HORIZONTAL_SLIDERS_WIDTH - HMARGIN, LCD_H - TRIM_SQUARE_SIZE, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_POT3]; })
|
|
|
|
|
);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(HARDWARE_EXT1)
|
|
|
|
|
if (IS_POT_SLIDER_AVAILABLE(EXT1)) {
|
|
|
|
|
new MainViewVerticalSlider(this, {HMARGIN, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_LEFT]; });
|
|
|
|
|
new MainViewVerticalSlider(this, {HMARGIN, LCD_H / 2 + yOffset, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_POT_EXT1]; });
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewVerticalSlider(this, {HMARGIN, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_LEFT]; })
|
|
|
|
|
);
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewVerticalSlider(this, {HMARGIN, LCD_H / 2 + yOffset, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_POT_EXT1]; })
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
new MainViewVerticalSlider(this, {HMARGIN, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar)},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_LEFT]; });
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewVerticalSlider(this, {HMARGIN, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar)},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_LEFT]; })
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(HARDWARE_EXT2)
|
|
|
|
|
if (IS_POT_SLIDER_AVAILABLE(EXT2)) {
|
|
|
|
|
new MainViewVerticalSlider(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE,
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewVerticalSlider(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE,
|
|
|
|
|
VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_RIGHT]; });
|
|
|
|
|
new MainViewVerticalSlider(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE, LCD_H / 2 + yOffset, TRIM_SQUARE_SIZE,
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_RIGHT]; })
|
|
|
|
|
);
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewVerticalSlider(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE, LCD_H / 2 + yOffset, TRIM_SQUARE_SIZE,
|
|
|
|
|
VERTICAL_SLIDERS_HEIGHT(topbar) / 2},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_POT_EXT2]; });
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_POT_EXT2]; })
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
new MainViewVerticalSlider(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE,
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewVerticalSlider(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE, LCD_H / 2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset, TRIM_SQUARE_SIZE,
|
|
|
|
|
VERTICAL_SLIDERS_HEIGHT(topbar)},
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_RIGHT]; });
|
|
|
|
|
[=] { return calibratedAnalogs[CALIBRATED_SLIDER_REAR_RIGHT]; })
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
@@ -169,24 +213,35 @@ void Layout::decorate(bool topbar, bool sliders, bool trims, bool flightMode)
|
|
|
|
|
// Trim order TRIM_LH, TRIM_LV, TRIM_RV, TRIM_RH
|
|
|
|
|
|
|
|
|
|
// Left
|
|
|
|
|
new MainViewHorizontalTrim(this, {HMARGIN, LCD_H - TRIM_SQUARE_SIZE + yOffset, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
|
|
|
|
[=] { return getTrimValue(mixerCurrentFlightMode, 0); });
|
|
|
|
|
// Right
|
|
|
|
|
new MainViewHorizontalTrim(this, {LCD_W - HORIZONTAL_SLIDERS_WIDTH - HMARGIN, LCD_H - TRIM_SQUARE_SIZE + yOffset, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
|
|
|
|
[=] { return getTrimValue(mixerCurrentFlightMode, 3); });
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewHorizontalTrim(this, {HMARGIN, LCD_H - TRIM_SQUARE_SIZE + yOffset, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
|
|
|
|
[=] { return getTrimValue(mixerCurrentFlightMode, 0); })
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Right
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewHorizontalTrim(this, {LCD_W - HORIZONTAL_SLIDERS_WIDTH - HMARGIN, LCD_H - TRIM_SQUARE_SIZE + yOffset, HORIZONTAL_SLIDERS_WIDTH, TRIM_SQUARE_SIZE},
|
|
|
|
|
[=] { return getTrimValue(mixerCurrentFlightMode, 3); })
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Left
|
|
|
|
|
new MainViewVerticalTrim(this, {HMARGIN + xOffset, LCD_H /2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset + (topbar ? TOPBAR_HEIGHT / 2 : 0), TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar)},
|
|
|
|
|
[=] { return getTrimValue(mixerCurrentFlightMode, 1); });
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewVerticalTrim(this, {HMARGIN + xOffset, LCD_H /2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset + (topbar ? TOPBAR_HEIGHT / 2 : 0), TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar)},
|
|
|
|
|
[=] { return getTrimValue(mixerCurrentFlightMode, 1); })
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Right
|
|
|
|
|
new MainViewVerticalTrim(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE - xOffset, LCD_H /2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset + (topbar ? TOPBAR_HEIGHT / 2 : 0), TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar)},
|
|
|
|
|
[=] { return getTrimValue(mixerCurrentFlightMode, 2); });
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new MainViewVerticalTrim(this, {LCD_W - HMARGIN - TRIM_SQUARE_SIZE - xOffset, LCD_H /2 - VERTICAL_SLIDERS_HEIGHT(topbar) / 2 + yOffset + (topbar ? TOPBAR_HEIGHT / 2 : 0), TRIM_SQUARE_SIZE, VERTICAL_SLIDERS_HEIGHT(topbar)},
|
|
|
|
|
[=] { return getTrimValue(mixerCurrentFlightMode, 2); })
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flightMode) {
|
|
|
|
|
new DynamicText(this, {50, LCD_H - 4 - (sliders? 2 * TRIM_SQUARE_SIZE: TRIM_SQUARE_SIZE), LCD_W - 100, 20}, [=] {
|
|
|
|
|
decorations.push_back(
|
|
|
|
|
new DynamicText(this, {50, LCD_H - 4 - (sliders? 2 * TRIM_SQUARE_SIZE: TRIM_SQUARE_SIZE), LCD_W - 100, 20}, [=] {
|
|
|
|
|
return g_model.flightModeData[mixerCurrentFlightMode].name;
|
|
|
|
|
}, CENTERED);
|
|
|
|
|
}, CENTERED)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|