Facelift round 2

This commit is contained in:
Raphael Coeffic
2021-06-14 06:34:57 +02:00
parent 57aa76c424
commit 85bc612f4a
11 changed files with 286 additions and 177 deletions
+48 -25
View File
@@ -58,18 +58,30 @@ class MixerChannelBar : public ChannelBar
chanVal = limit<int>(-VIEW_CHANNELS_LIMIT_PCT, chanVal, VIEW_CHANNELS_LIMIT_PCT); chanVal = limit<int>(-VIEW_CHANNELS_LIMIT_PCT, chanVal, VIEW_CHANNELS_LIMIT_PCT);
// Draw Background // Draw Background
dc->drawSolidFilledRect(0, 0, width(), height(), BARGRAPH_BGCOLOR); dc->drawSolidFilledRect(0, 0, width(), height(), FIELD_BGCOLOR);
// Draw mixer bar // Draw mixer bar
if (chanVal > 0) { if (chanVal > 0) {
dc->drawSolidFilledRect(0 + width() / 2, 0, divRoundClosest(chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2), height(), BARGRAPH2_COLOR);
dc->drawNumber(width() / 2 - 10, 0, displayVal, FONT(XS) | DEFAULT_COLOR | RIGHT, 0, nullptr, "%"); dc->drawSolidFilledRect(
} 0 + width() / 2, 0,
else if (chanVal < 0) { divRoundClosest(chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2),
height(), FOCUS_BGCOLOR);
dc->drawNumber(width() / 2 - 10, 0, displayVal,
FONT(XS) | DEFAULT_COLOR | RIGHT, 0, nullptr, "%");
} else if (chanVal < 0) {
const unsigned endpoint = width() / 2; const unsigned endpoint = width() / 2;
const unsigned size = divRoundClosest(-chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2); const unsigned size =
dc->drawSolidFilledRect(endpoint - size, 0, size, height(), BARGRAPH2_COLOR); divRoundClosest(-chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2);
dc->drawNumber(10 + width() / 2, 0, displayVal, FONT(XS) | DEFAULT_COLOR, 0, nullptr, "%");
dc->drawSolidFilledRect(endpoint - size, 0, size, height(),
FOCUS_BGCOLOR);
dc->drawNumber(10 + width() / 2, 0, displayVal,
FONT(XS) | DEFAULT_COLOR, 0, nullptr, "%");
} }
// Draw middle bar // Draw middle bar
@@ -100,36 +112,47 @@ class OutputChannelBar : public ChannelBar
int chanVal = calcRESXto100(channelOutputs[channel]); int chanVal = calcRESXto100(channelOutputs[channel]);
int displayVal = chanVal; int displayVal = chanVal;
chanVal = limit<int>(-VIEW_CHANNELS_LIMIT_PCT, chanVal, VIEW_CHANNELS_LIMIT_PCT); chanVal = limit<int>(-VIEW_CHANNELS_LIMIT_PCT, chanVal,
VIEW_CHANNELS_LIMIT_PCT);
// Draw Background // Draw Background
dc->drawSolidFilledRect(0, 0, width(), height(), BARGRAPH_BGCOLOR); dc->drawSolidFilledRect(0, 0, width(), height(), FIELD_BGCOLOR);
// Draw output bar // Draw output bar
if (chanVal > 0) { if (chanVal > 0) {
dc->drawSolidFilledRect(width() / 2, 0, divRoundClosest(chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2), height(), BARGRAPH1_COLOR);
dc->drawNumber(width() / 2 - 10, 0, displayVal, FONT(XS) | DEFAULT_COLOR | RIGHT, 0, nullptr, "%"); dc->drawSolidFilledRect(
} width() / 2, 0,
else if (chanVal < 0) { divRoundClosest(chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2),
height(), HIGHLIGHT_COLOR);
dc->drawNumber(width() / 2 - 10, 0, displayVal,
FONT(XS) | DEFAULT_COLOR | RIGHT, 0, nullptr, "%");
} else if (chanVal < 0) {
unsigned endpoint = width() / 2; unsigned endpoint = width() / 2;
unsigned size = divRoundClosest(-chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2); unsigned size =
dc->drawSolidFilledRect(endpoint - size, 0, size, height(), BARGRAPH1_COLOR); divRoundClosest(-chanVal * width(), VIEW_CHANNELS_LIMIT_PCT * 2);
dc->drawNumber(width() / 2 + 10, 0, displayVal, FONT(XS) | DEFAULT_COLOR, 0, nullptr, "%");
dc->drawSolidFilledRect(endpoint - size, 0, size, height(),
HIGHLIGHT_COLOR);
dc->drawNumber(width() / 2 + 10, 0, displayVal,
FONT(XS) | DEFAULT_COLOR, 0, nullptr, "%");
} }
// Draw middle bar // Draw middle bar
dc->drawSolidVerticalLine(width() / 2, 0, height(), DEFAULT_COLOR); dc->drawSolidVerticalLine(width() / 2, 0, height(), DEFAULT_COLOR);
// Draw output limits bars // Draw output limits bars
LimitData * ld = limitAddress(channel); LimitData* ld = limitAddress(channel);
if (ld && ld->revert) { if (ld && ld->revert) {
drawOutputBarLimits(dc, posOnBar(-100 - ld->max / 10), posOnBar(100 - ld->min / 10)); drawOutputBarLimits(dc, posOnBar(-100 - ld->max / 10),
//lcd->drawBitmap(x - X_OFFSET + 7, y + 25, chanMonInvertedBitmap); posOnBar(100 - ld->min / 10));
} else if (ld) {
drawOutputBarLimits(dc, posOnBar(-100 + ld->min / 10),
posOnBar(100 + ld->max / 10));
} }
else if (ld) {
drawOutputBarLimits(dc, posOnBar(-100 + ld->min / 10), posOnBar(100 + ld->max / 10));
}
} }
inline unsigned posOnBar(int value_to100) inline unsigned posOnBar(int value_to100)
@@ -215,4 +238,4 @@ class ComboChannelBar : public ChannelBar
protected: protected:
int value = 0; int value = 0;
}; };
+4 -2
View File
@@ -56,6 +56,8 @@ enum LcdColorIndex
MAINVIEW_PANES_COLOR_INDEX, MAINVIEW_PANES_COLOR_INDEX,
MENU_BGCOLOR_INDEX, MENU_BGCOLOR_INDEX,
MENU_COLOR_INDEX, MENU_COLOR_INDEX,
MENU_HIGHLIGHT_COLOR_INDEX,
MENU_LINE_COLOR_INDEX,
MENU_TITLE_DISABLE_COLOR_INDEX, MENU_TITLE_DISABLE_COLOR_INDEX,
OVERLAY_COLOR_INDEX, OVERLAY_COLOR_INDEX,
SCROLLBAR_COLOR_INDEX, SCROLLBAR_COLOR_INDEX,
@@ -73,8 +75,8 @@ enum LcdColorIndex
}; };
#define MENU_HIGHLIGHT_COLOR_INDEX HIGHLIGHT_COLOR_INDEX //#define MENU_HIGHLIGHT_COLOR_INDEX HIGHLIGHT_COLOR_INDEX
#define MENU_LINE_COLOR_INDEX LINE_COLOR_INDEX //#define MENU_LINE_COLOR_INDEX LINE_COLOR_INDEX
// //
+21 -6
View File
@@ -42,10 +42,16 @@ class CurveEditWindow : public Page
void buildHeader(Window * window) void buildHeader(Window * window)
{ {
new StaticText(window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, STR_MENUCURVE, 0, MENU_COLOR); new StaticText(window,
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT,
PAGE_LINE_HEIGHT},
STR_MENUCURVE, 0, MENU_COLOR);
char s[16]; char s[16];
strAppendStringWithIndex(s, STR_CV, index + 1); strAppendStringWithIndex(s, STR_CV, index + 1);
new StaticText(window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, s, 0, MENU_COLOR); new StaticText(window,
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT,
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
s, 0, MENU_COLOR);
} }
#if LCD_W > LCD_H #if LCD_W > LCD_H
@@ -226,8 +232,14 @@ class CurveButton : public Button {
void paint(BitmapBuffer * dc) override void paint(BitmapBuffer * dc) override
{ {
dc->drawSolidFilledRect(0, 0, rect.w, rect.h, FIELD_BGCOLOR);
// bounding rect // bounding rect
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, hasFocus() ? CHECKBOX_COLOR : DISABLE_COLOR); if (hasFocus()) {
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FOCUS_BGCOLOR);
} else {
dc->drawSolidRect(0, 0, rect.w, rect.h, 1, FIELD_FRAME_COLOR);
}
// curve characteristics // curve characteristics
if (isCurveUsed(index)) { if (isCurveUsed(index)) {
@@ -297,7 +309,10 @@ void ModelCurvesPage::build(FormWindow * window, int8_t focusIndex)
if (isCurveUsed(index)) { if (isCurveUsed(index)) {
// Curve label // Curve label
new StaticText(window, grid.getLabelSlot(), getCurveString(1 + index), BUTTON_BACKGROUND, CENTERED); auto text =
new StaticText(window, grid.getLabelSlot(), getCurveString(1 + index),
BUTTON_BACKGROUND, CENTERED);
text->setBackgroundColor(FOCUS_COLOR);
// Curve drawing // Curve drawing
Button * button = new CurveButton(window, grid.getFieldSlot(), index); Button * button = new CurveButton(window, grid.getFieldSlot(), index);
@@ -325,10 +340,10 @@ void ModelCurvesPage::build(FormWindow * window, int8_t focusIndex)
} }
grid.spacer(button->height() + 5); grid.spacer(button->height() + 5);
} } else {
else {
auto button = new TextButton(window, grid.getLabelSlot(), auto button = new TextButton(window, grid.getLabelSlot(),
getCurveString(1 + index)); getCurveString(1 + index));
button->setPressHandler([=]() { button->setPressHandler([=]() {
Menu *menu = new Menu(window); Menu *menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() { menu->addLine(STR_EDIT, [=]() {
+39 -20
View File
@@ -302,19 +302,23 @@ void CommonInputOrMixButton::checkEvents()
Button::checkEvents(); Button::checkEvents();
} }
void CommonInputOrMixButton::drawFlightModes(BitmapBuffer *dc, FlightModesType value) void CommonInputOrMixButton::drawFlightModes(BitmapBuffer *dc,
FlightModesType value,
LcdFlags textColor)
{ {
dc->drawMask(146, 2 + PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupFlightmodeIcon, DEFAULT_COLOR); dc->drawMask(146, 2 + PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
mixerSetupFlightmodeIcon, textColor);
coord_t x = 166; coord_t x = 166;
for (int i = 0; i < MAX_FLIGHT_MODES; i++) { for (int i = 0; i < MAX_FLIGHT_MODES; i++) {
char s[] = " "; char s[] = " ";
s[0] = '0' + i; s[0] = '0' + i;
if (value & (1 << i)) { if (value & (1 << i)) {
dc->drawText(x, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP + 2, s, FONT(XS) | TEXT_DISABLE_COLOR); dc->drawText(x, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP + 2, s,
} FONT(XS) | TEXT_DISABLE_COLOR);
else { } else {
dc->drawSolidFilledRect(x, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP + 2, 8, 3, CHECKBOX_COLOR); dc->drawSolidFilledRect(x, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP + 2, 8, 3,
dc->drawText(x, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP + 2, s, FONT(XS)); FOCUS_BGCOLOR);
dc->drawText(x, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP + 2, s, FONT(XS) | textColor);
} }
x += 8; x += 8;
} }
@@ -322,10 +326,11 @@ void CommonInputOrMixButton::drawFlightModes(BitmapBuffer *dc, FlightModesType v
void CommonInputOrMixButton::paint(BitmapBuffer * dc) void CommonInputOrMixButton::paint(BitmapBuffer * dc)
{ {
if (active) dc->drawSolidFilledRect(0, 0, width(), height(),
dc->drawSolidFilledRect(2, 2, rect.w - 4, rect.h - 4, HIGHLIGHT_COLOR); hasFocus() ? FOCUS_BGCOLOR : FIELD_BGCOLOR);
paintBody(dc); paintBody(dc);
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, hasFocus() ? CHECKBOX_COLOR : DISABLE_COLOR); if (!hasFocus())
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, FIELD_FRAME_COLOR);
} }
class InputLineButton : public CommonInputOrMixButton { class InputLineButton : public CommonInputOrMixButton {
@@ -348,28 +353,38 @@ class InputLineButton : public CommonInputOrMixButton {
{ {
const ExpoData & line = g_model.expoData[index]; const ExpoData & line = g_model.expoData[index];
LcdFlags textColor = DEFAULT_COLOR;
if (hasFocus())
textColor = FOCUS_COLOR;
// first line ... // first line ...
drawValueOrGVar(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, line.weight, -100, 100); drawValueOrGVar(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, line.weight,
drawSource(dc, 60, FIELD_PADDING_TOP, line.srcRaw); -100, 100, textColor);
drawSource(dc, 60, FIELD_PADDING_TOP, line.srcRaw, textColor);
if (line.name[0]) { if (line.name[0]) {
dc->drawMask(146, FIELD_PADDING_TOP, mixerSetupLabelIcon, DEFAULT_COLOR); dc->drawMask(146, FIELD_PADDING_TOP, mixerSetupLabelIcon, textColor);
dc->drawSizedText(166, FIELD_PADDING_TOP, line.name, sizeof(line.name)); dc->drawSizedText(166, FIELD_PADDING_TOP, line.name, sizeof(line.name),
textColor);
} }
// second line ... // second line ...
if (line.swtch) { if (line.swtch) {
dc->drawMask(3, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupSwitchIcon, DEFAULT_COLOR); dc->drawMask(3, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
drawSwitch(dc, 21, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.swtch); mixerSetupSwitchIcon, textColor);
drawSwitch(dc, 21, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.swtch,
textColor);
} }
if (line.curve.value != 0 ) { if (line.curve.value != 0 ) {
dc->drawMask(60, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupCurveIcon, DEFAULT_COLOR); dc->drawMask(60, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
drawCurveRef(dc, 80, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.curve); mixerSetupCurveIcon, textColor);
drawCurveRef(dc, 80, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.curve,
textColor);
} }
if (line.flightModes) { if (line.flightModes) {
drawFlightModes(dc, line.flightModes); drawFlightModes(dc, line.flightModes, textColor);
} }
} }
}; };
@@ -406,7 +421,11 @@ void ModelInputsPage::build(FormWindow * window, int8_t focusIndex)
ExpoData * line = g_model.expoData; ExpoData * line = g_model.expoData;
for (uint8_t input = 0; input < MAX_INPUTS; input++) { for (uint8_t input = 0; input < MAX_INPUTS; input++) {
if (inputIndex < MAX_EXPOS && line->chn == input && EXPO_VALID(line)) { if (inputIndex < MAX_EXPOS && line->chn == input && EXPO_VALID(line)) {
new StaticText(window, grid.getLabelSlot(), getSourceString(MIXSRC_FIRST_INPUT + input), BUTTON_BACKGROUND, CENTERED); auto txt = new StaticText(window, grid.getLabelSlot(),
getSourceString(MIXSRC_FIRST_INPUT + input),
0, CENTERED);
txt->setBackgroundColor(FIELD_BGCOLOR);
while (inputIndex < MAX_EXPOS && line->chn == input && EXPO_VALID(line)) { while (inputIndex < MAX_EXPOS && line->chn == input && EXPO_VALID(line)) {
Button * button = new InputLineButton(window, grid.getFieldSlot(), inputIndex); Button * button = new InputLineButton(window, grid.getFieldSlot(), inputIndex);
if (focusIndex == inputIndex) if (focusIndex == inputIndex)
+1 -1
View File
@@ -56,7 +56,7 @@ class CommonInputOrMixButton : public Button {
void checkEvents() override; void checkEvents() override;
void drawFlightModes(BitmapBuffer *dc, FlightModesType value); void drawFlightModes(BitmapBuffer *dc, FlightModesType value, LcdFlags textColor);
void paint(BitmapBuffer * dc) override; void paint(BitmapBuffer * dc) override;
+23 -10
View File
@@ -246,28 +246,38 @@ class MixLineButton : public CommonInputOrMixButton {
{ {
const MixData & line = g_model.mixData[index]; const MixData & line = g_model.mixData[index];
LcdFlags textColor = DEFAULT_COLOR;
if (hasFocus())
textColor = FOCUS_COLOR;
// first line ... // first line ...
drawValueOrGVar(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, line.weight, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX); drawValueOrGVar(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, line.weight,
drawSource(dc, 60, FIELD_PADDING_TOP, line.srcRaw); MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, textColor);
drawSource(dc, 60, FIELD_PADDING_TOP, line.srcRaw, textColor);
if (line.name[0]) { if (line.name[0]) {
dc->drawMask(146, FIELD_PADDING_TOP, mixerSetupLabelIcon, DEFAULT_COLOR); dc->drawMask(146, FIELD_PADDING_TOP, mixerSetupLabelIcon, textColor);
dc->drawSizedText(166, FIELD_PADDING_TOP, line.name, sizeof(line.name)); dc->drawSizedText(166, FIELD_PADDING_TOP, line.name, sizeof(line.name),
textColor);
} }
// second line ... // second line ...
if (line.swtch) { if (line.swtch) {
dc->drawMask(3, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupSwitchIcon, DEFAULT_COLOR); dc->drawMask(3, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
drawSwitch(dc, 21, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.swtch); mixerSetupSwitchIcon, textColor);
drawSwitch(dc, 21, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.swtch,
textColor);
} }
if (line.curve.value) { if (line.curve.value) {
dc->drawMask(60, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupCurveIcon, DEFAULT_COLOR); dc->drawMask(60, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
drawCurveRef(dc, 80, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.curve, 0); mixerSetupCurveIcon, textColor);
drawCurveRef(dc, 80, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, line.curve,
textColor);
} }
if (line.flightModes) { if (line.flightModes) {
drawFlightModes(dc, line.flightModes); drawFlightModes(dc, line.flightModes, textColor);
} }
} }
}; };
@@ -329,7 +339,10 @@ void ModelMixesPage::build(FormWindow * window, int8_t focusMixIndex)
MixData * mix = g_model.mixData; MixData * mix = g_model.mixData;
for (uint8_t ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) { for (uint8_t ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++) {
if (mixIndex < MAX_MIXERS && mix->srcRaw > 0 && mix->destCh == ch) { if (mixIndex < MAX_MIXERS && mix->srcRaw > 0 && mix->destCh == ch) {
new StaticText(window, grid.getLabelSlot(), getSourceString(MIXSRC_CH1 + ch), BUTTON_BACKGROUND, CENTERED); auto txt = new StaticText(window, grid.getLabelSlot(),
getSourceString(MIXSRC_CH1 + ch), 0,
CENTERED);
txt->setBackgroundColor(FIELD_BGCOLOR);
uint8_t count = 0; uint8_t count = 0;
while (mixIndex < MAX_MIXERS && mix->srcRaw > 0 && mix->destCh == ch) { while (mixIndex < MAX_MIXERS && mix->srcRaw > 0 && mix->destCh == ch) {
Button * button = new MixLineButton(window, grid.getFieldSlot(), mixIndex); Button * button = new MixLineButton(window, grid.getFieldSlot(), mixIndex);
+42 -14
View File
@@ -39,8 +39,14 @@ class OutputEditWindow : public Page {
void buildHeader(Window * window) void buildHeader(Window * window)
{ {
new StaticText(window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, STR_MENULIMITS, 0, MENU_COLOR); new StaticText(window,
new StaticText(window, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, getSourceString(MIXSRC_CH1 + channel), 0, MENU_COLOR); {PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT,
PAGE_LINE_HEIGHT},
STR_MENULIMITS, 0, MENU_COLOR);
new StaticText(window,
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT,
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
getSourceString(MIXSRC_CH1 + channel), 0, MENU_COLOR);
} }
void buildBody(FormWindow * window) void buildBody(FormWindow * window)
@@ -120,28 +126,47 @@ class OutputLineButton : public Button {
void paint(BitmapBuffer * dc) override void paint(BitmapBuffer * dc) override
{ {
LcdFlags textColor = DEFAULT_COLOR;
LcdFlags bgColor = FIELD_BGCOLOR;
if (hasFocus()) {
textColor = FOCUS_COLOR;
bgColor = FOCUS_BGCOLOR;
}
dc->drawSolidFilledRect(0, 0, width(), height(), bgColor);
// first line // first line
dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, output->min - 1000, PREC1); dc->drawNumber(FIELD_PADDING_LEFT, FIELD_PADDING_TOP, output->min - 1000,
dc->drawNumber(68, FIELD_PADDING_TOP, output->max + 1000, PREC1); PREC1 | textColor);
dc->drawNumber(132, FIELD_PADDING_TOP, output->offset, PREC1); dc->drawNumber(68, FIELD_PADDING_TOP, output->max + 1000, PREC1 | textColor);
dc->drawNumber(226, FIELD_PADDING_TOP, PPM_CENTER + output->ppmCenter, RIGHT); dc->drawNumber(132, FIELD_PADDING_TOP, output->offset, PREC1 | textColor);
dc->drawText(228, FIELD_PADDING_TOP, output->symetrical ? "=" : "\210"); dc->drawNumber(226, FIELD_PADDING_TOP, PPM_CENTER + output->ppmCenter,
RIGHT | textColor);
dc->drawText(228, FIELD_PADDING_TOP, output->symetrical ? "=" : "\210",
textColor);
// second line // second line
if (output->revert) { if (output->revert) {
dc->drawTextAtIndex(4, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, STR_MMMINV, output->revert); dc->drawTextAtIndex(4, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, STR_MMMINV,
output->revert, textColor);
} }
if (output->curve) { if (output->curve) {
dc->drawMask(68, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupCurveIcon, DEFAULT_COLOR); dc->drawMask(68, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
dc->drawText(88, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, getCurveString(output->curve)); mixerSetupCurveIcon, textColor);
dc->drawText(88, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
getCurveString(output->curve), textColor);
} }
if (output->name[0]) { if (output->name[0]) {
dc->drawMask(146, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, mixerSetupLabelIcon, DEFAULT_COLOR); dc->drawMask(146, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
dc->drawSizedText(166, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP, output->name, sizeof(output->name)); mixerSetupLabelIcon, textColor);
dc->drawSizedText(166, PAGE_LINE_HEIGHT + FIELD_PADDING_TOP,
output->name, sizeof(output->name), textColor);
} }
// bounding rect // bounding rect
dc->drawSolidRect(0, 0, rect.w, rect.h, 2, hasFocus() ? CHECKBOX_COLOR : DISABLE_COLOR); dc->drawSolidRect(0, 0, rect.w, rect.h, 2,
hasFocus() ? FOCUS_BGCOLOR : FIELD_FRAME_COLOR);
} }
protected: protected:
@@ -171,7 +196,10 @@ void ModelOutputsPage::build(FormWindow * window, int8_t focusChannel)
LimitData * output = limitAddress(ch); LimitData * output = limitAddress(ch);
// Channel label // Channel label
new StaticText(window, grid.getLabelSlot(), getSourceString(MIXSRC_CH1 + ch), BUTTON_BACKGROUND, CENTERED); auto txt = new StaticText(window, grid.getLabelSlot(),
getSourceString(MIXSRC_CH1 + ch), 0,
CENTERED);
txt->setBackgroundColor(FIELD_BGCOLOR);
// Channel settings // Channel settings
Button * button = new OutputLineButton(window, grid.getFieldSlot(), output); Button * button = new OutputLineButton(window, grid.getFieldSlot(), output);
@@ -36,7 +36,7 @@ constexpr uint16_t __TAB_BACKGROUND_COLOR = RGB(0xE4, 0xEE, 0xF2);
constexpr uint16_t __PARAM_BACKGROUND_COLOR = WHITE; constexpr uint16_t __PARAM_BACKGROUND_COLOR = WHITE;
constexpr uint16_t __EDIT_MARKER_COLOR = RGB(0x00, 0x99, 0x09); constexpr uint16_t __EDIT_MARKER_COLOR = RGB(0x00, 0x99, 0x09);
constexpr uint16_t __ACTIVE_MARKER_COLOR = RGB(0xFF, 0x99, 0x00); constexpr uint16_t __ACTIVE_MARKER_COLOR = RGB(0xFF, 0xDE, 0x00);
class Theme480: public OpenTxTheme class Theme480: public OpenTxTheme
{ {
@@ -69,7 +69,7 @@ class Theme480: public OpenTxTheme
lcdColorTable[HEADER_COLOR_INDEX] = __BACKGROUND_COLOR; lcdColorTable[HEADER_COLOR_INDEX] = __BACKGROUND_COLOR;
lcdColorTable[HEADER_CURRENT_BGCOLOR_INDEX] = __FOCUS_COLOR; lcdColorTable[HEADER_CURRENT_BGCOLOR_INDEX] = __FOCUS_COLOR;
lcdColorTable[HEADER_ICON_BGCOLOR_INDEX] = __BACKGROUND_COLOR; lcdColorTable[HEADER_ICON_BGCOLOR_INDEX] = __BACKGROUND_COLOR;
lcdColorTable[HIGHLIGHT_COLOR_INDEX] = YELLOW; lcdColorTable[HIGHLIGHT_COLOR_INDEX] = __ACTIVE_MARKER_COLOR;
lcdColorTable[LINE_COLOR_INDEX] = GREY; lcdColorTable[LINE_COLOR_INDEX] = GREY;
lcdColorTable[MAINVIEW_GRAPHICS_COLOR_INDEX] = RED; lcdColorTable[MAINVIEW_GRAPHICS_COLOR_INDEX] = RED;
lcdColorTable[MAINVIEW_PANES_COLOR_INDEX] = WHITE; lcdColorTable[MAINVIEW_PANES_COLOR_INDEX] = WHITE;
@@ -383,7 +383,7 @@ class Theme480: public OpenTxTheme
dc->drawSolidFilledRect(0, MENU_TITLE_TOP, LCD_W, MENU_TITLE_HEIGHT, dc->drawSolidFilledRect(0, MENU_TITLE_TOP, LCD_W, MENU_TITLE_HEIGHT,
TITLE_BGCOLOR); // the title line background TITLE_BGCOLOR); // the title line background
if (title) { if (title) {
dc->drawText(MENUS_MARGIN_LEFT, MENU_TITLE_TOP + 3, title, MENU_COLOR); dc->drawText(MENUS_MARGIN_LEFT, MENU_TITLE_TOP + 3, title, FOCUS_COLOR);
} }
drawMenuDatetime(dc); drawMenuDatetime(dc);
+2 -2
View File
@@ -57,8 +57,8 @@ class ChannelsViewFooter: public Window {
// Draw legend bar // Draw legend bar
coord_t x = 10; coord_t x = 10;
dc->drawSolidFilledRect(0, 0, width(), height(), TITLE_BGCOLOR); dc->drawSolidFilledRect(0, 0, width(), height(), TITLE_BGCOLOR);
x = drawChannelsMonitorLegend(dc, MENUS_MARGIN_LEFT, STR_MONITOR_OUTPUT_DESC, BARGRAPH1_COLOR); x = drawChannelsMonitorLegend(dc, MENUS_MARGIN_LEFT, STR_MONITOR_OUTPUT_DESC, HIGHLIGHT_COLOR);
drawChannelsMonitorLegend(dc, x, STR_MONITOR_MIXER_DESC, BARGRAPH2_COLOR); drawChannelsMonitorLegend(dc, x, STR_MONITOR_MIXER_DESC, FOCUS_BGCOLOR);
} }
}; };
@@ -27,27 +27,30 @@
class LogicalSwitchDisplayButton : public TextButton class LogicalSwitchDisplayButton : public TextButton
{ {
public: public:
LogicalSwitchDisplayButton(FormGroup * parent, const rect_t & rect, std::string text, unsigned index): LogicalSwitchDisplayButton(FormGroup* parent, const rect_t& rect,
TextButton(parent, rect, std::move(text)), std::string text, unsigned index) :
index(index) TextButton(parent, rect, std::move(text), nullptr, OPAQUE), index(index)
{ {
} setBgColorHandler([=]() -> LcdFlags {
if (getSwitch(SWSRC_SW1 + index)) return HIGHLIGHT_COLOR;
return FIELD_BGCOLOR;
});
}
void checkEvents() override void checkEvents() override
{ {
bool newvalue = getSwitch(SWSRC_SW1 + index); bool newvalue = getSwitch(SWSRC_SW1 + index);
if (value != newvalue) { if (value != newvalue) {
if (newvalue) { if (newvalue) {
setTextFlags(FONT(BOLD) | HIGHLIGHT_COLOR); setTextFlags(FONT(BOLD) | DEFAULT_COLOR);
} } else {
else { setTextFlags(FONT(STD) | DEFAULT_COLOR);
setTextFlags(FONT(STD) | DEFAULT_COLOR); }
} value = newvalue;
value = newvalue; invalidate();
invalidate(); }
} Button::checkEvents();
Button::checkEvents(); }
}
protected: protected:
unsigned index = 0; unsigned index = 0;
@@ -61,21 +64,28 @@ void LogicalSwitchesViewPage::build(FormWindow * window)
grid.spacer(PAGE_PADDING); grid.spacer(PAGE_PADDING);
grid.setLabelWidth(8); grid.setLabelWidth(8);
// Footer
footer = new LogicalSwitchDisplayFooter(
window, {0, window->height() - LSW_VIEW_FOOTER_HEIGHT, window->width(),
LSW_VIEW_FOOTER_HEIGHT});
// LSW table // LSW table
std::string lsString ("LS64"); std::string lsString("LS64");
lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(160, 160, 160); lcdColorTable[CUSTOM_COLOR_INDEX] = RGB(160, 160, 160);
for (uint8_t i = 0; i < MAX_LOGICAL_SWITCHES; i++) { for (uint8_t i = 0; i < MAX_LOGICAL_SWITCHES; i++) {
strAppendSigned(&lsString[1], i + 1, 2); strAppendSigned(&lsString[1], i + 1, 2);
auto button = new LogicalSwitchDisplayButton(window, grid.getFieldSlot(8, i % 8), lsString, i);
button->setPressHandler([=]() { auto button = new LogicalSwitchDisplayButton(
footer->setIndex(i); window, grid.getFieldSlot(8, i % 8), lsString, i);
footer->invalidate();
button->setFocusHandler([=](bool focus) {
if (focus) {
footer->setIndex(i);
footer->invalidate();
}
return 0; return 0;
}); });
if ((i + 1) % 8 == 0) if ((i + 1) % 8 == 0) grid.nextLine();
grid.nextLine();
} }
// Footer
footer = new LogicalSwitchDisplayFooter(window, {0,window->height() - LSW_VIEW_FOOTER_HEIGHT, window->width(), LSW_VIEW_FOOTER_HEIGHT});
} }
+63 -64
View File
@@ -30,77 +30,76 @@ constexpr coord_t CSW_4TH_COLUMN = 280;
constexpr coord_t CSW_5TH_COLUMN = 340; constexpr coord_t CSW_5TH_COLUMN = 340;
constexpr coord_t CSW_6TH_COLUMN = 390; constexpr coord_t CSW_6TH_COLUMN = 390;
void putsEdgeDelayParam(BitmapBuffer * dc, coord_t x, coord_t y, LogicalSwitchData * ls, LcdFlags flags); void putsEdgeDelayParam(BitmapBuffer* dc, coord_t x, coord_t y,
LogicalSwitchData* ls, LcdFlags flags);
class LogicalSwitchDisplayFooter: public Window { class LogicalSwitchDisplayFooter : public Window
public: {
explicit LogicalSwitchDisplayFooter(Window * parent, rect_t rect): public:
Window(parent, rect, OPAQUE), explicit LogicalSwitchDisplayFooter(Window* parent, rect_t rect) :
rect(rect) Window(parent, rect, OPAQUE), rect(rect)
{ {
}
void setIndex(unsigned value) { index = value; }
void paint(BitmapBuffer* dc) override
{
dc->clear(TITLE_BGCOLOR);
LogicalSwitchData* cs = lswAddress(index);
LcdFlags textColor = FOCUS_COLOR;
dc->drawTextAtIndex(10, 1, STR_VCSWFUNC, cs->func, textColor);
// CSW params
unsigned int cstate = lswFamily(cs->func);
if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) {
drawSwitch(dc, CSW_2ND_COLUMN, 1, cs->v1, textColor);
drawSwitch(dc, CSW_3RD_COLUMN, 1, cs->v2, textColor);
} else if (cstate == LS_FAMILY_EDGE) {
drawSwitch(dc, CSW_2ND_COLUMN, 1, cs->v1, textColor);
putsEdgeDelayParam(dc, CSW_3RD_COLUMN, 1, cs, textColor);
} else if (cstate == LS_FAMILY_COMP) {
drawSource(dc, CSW_2ND_COLUMN, 1, cs->v1, textColor);
drawSource(dc, CSW_3RD_COLUMN, 1, cs->v2, textColor);
} else if (cstate == LS_FAMILY_TIMER) {
dc->drawNumber(CSW_2ND_COLUMN, 1, lswTimerValue(cs->v1),
LEFT | PREC1 | textColor);
dc->drawNumber(CSW_3RD_COLUMN, 1, lswTimerValue(cs->v2),
LEFT | PREC1 | textColor);
} else {
drawSource(dc, CSW_2ND_COLUMN, 1, cs->v1, textColor);
drawSourceCustomValue(
dc, CSW_3RD_COLUMN, 1, cs->v1,
cs->v1 <= MIXSRC_LAST_CH ? calc100toRESX(cs->v2) : cs->v2,
LEFT | textColor);
} }
void setIndex(unsigned value) // CSW AND switch
{ drawSwitch(dc, CSW_4TH_COLUMN, 1, cs->andsw, textColor);
index = value;
// CSW duration
if (cs->duration > 0)
dc->drawNumber(CSW_5TH_COLUMN, 1, cs->duration,
PREC1 | LEFT | textColor);
else
dc->drawTextAtIndex(CSW_5TH_COLUMN, 1, STR_MMMINV, 0, textColor);
// CSW delay
if (cstate == LS_FAMILY_EDGE) {
dc->drawText(CSW_6TH_COLUMN, 1, STR_NA, textColor);
} else if (cs->delay > 0) {
dc->drawNumber(CSW_6TH_COLUMN, 1, cs->delay, PREC1 | LEFT | textColor);
} else {
dc->drawTextAtIndex(CSW_6TH_COLUMN, 1, STR_MMMINV, 0, textColor);
} }
}
void paint(BitmapBuffer * dc) override protected:
{ rect_t rect;
dc->clear(TITLE_BGCOLOR); unsigned index = 0;
LogicalSwitchData * cs = lswAddress(index);
dc->drawTextAtIndex(10, 1, STR_VCSWFUNC, cs->func, MENU_COLOR);
// CSW params
unsigned int cstate = lswFamily(cs->func);
if (cstate == LS_FAMILY_BOOL || cstate == LS_FAMILY_STICKY) {
drawSwitch(dc, CSW_2ND_COLUMN, 1, cs->v1, MENU_COLOR);
drawSwitch(dc, CSW_3RD_COLUMN, 1, cs->v2, MENU_COLOR);
}
else if (cstate == LS_FAMILY_EDGE) {
drawSwitch(dc, CSW_2ND_COLUMN, 1, cs->v1, MENU_COLOR);
putsEdgeDelayParam(dc, CSW_3RD_COLUMN, 1, cs, MENU_COLOR);
}
else if (cstate == LS_FAMILY_COMP) {
drawSource(dc, CSW_2ND_COLUMN, 1, cs->v1, MENU_COLOR);
drawSource(dc, CSW_3RD_COLUMN, 1, cs->v2, MENU_COLOR);
}
else if (cstate == LS_FAMILY_TIMER) {
dc->drawNumber(CSW_2ND_COLUMN, 1, lswTimerValue(cs->v1), LEFT | PREC1 | MENU_COLOR);
dc->drawNumber(CSW_3RD_COLUMN, 1, lswTimerValue(cs->v2), LEFT | PREC1 | MENU_COLOR);
}
else {
drawSource(dc, CSW_2ND_COLUMN, 1, cs->v1, MENU_COLOR);
drawSourceCustomValue(dc, CSW_3RD_COLUMN, 1, cs->v1, cs->v1 <= MIXSRC_LAST_CH ? calc100toRESX(cs->v2) : cs->v2, LEFT | MENU_COLOR);
}
// CSW AND switch
drawSwitch(dc, CSW_4TH_COLUMN, 1, cs->andsw, MENU_COLOR);
// CSW duration
if (cs->duration > 0)
dc->drawNumber(CSW_5TH_COLUMN, 1, cs->duration, PREC1 | LEFT | MENU_COLOR);
else
dc->drawTextAtIndex(CSW_5TH_COLUMN, 1, STR_MMMINV, 0, MENU_COLOR);
// CSW delay
if (cstate == LS_FAMILY_EDGE) {
dc->drawText(CSW_6TH_COLUMN, 1, STR_NA, MENU_COLOR);
}
else if (cs->delay > 0) {
dc->drawNumber(CSW_6TH_COLUMN, 1, cs->delay, PREC1 | LEFT | MENU_COLOR);
}
else {
dc->drawTextAtIndex(CSW_6TH_COLUMN, 1, STR_MMMINV, 0, MENU_COLOR);
}
}
protected:
rect_t rect;
unsigned index = 0;
}; };
class LogicalSwitchesViewPage : public PageTab class LogicalSwitchesViewPage : public PageTab
{ {
public: public: