Set more sensible default colors for output widget
And also allow colors to be customised! Fixes #663
This commit is contained in:
@@ -45,7 +45,7 @@ class OutputsWidget: public Widget
|
|||||||
oneColumn(dc);
|
oneColumn(dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t drawChannels(BitmapBuffer * dc, const uint16_t & x, const uint16_t & y, const uint16_t & w, const uint16_t & h, const uint8_t & firstChan, const bool & bg_shown, const uint16_t & bg_color)
|
uint8_t drawChannels(BitmapBuffer * dc, const uint16_t & x, const uint16_t & y, const uint16_t & w, const uint16_t & h, const uint8_t & firstChan, const bool & bg_shown, const uint16_t & bg_color, const uint16_t & txt_color, const uint16_t & bar_color)
|
||||||
{
|
{
|
||||||
const uint8_t numChan = h / ROW_HEIGHT;
|
const uint8_t numChan = h / ROW_HEIGHT;
|
||||||
const uint8_t lastChan = firstChan + numChan;
|
const uint8_t lastChan = firstChan + numChan;
|
||||||
@@ -55,6 +55,9 @@ class OutputsWidget: public Widget
|
|||||||
const uint16_t barLft = x + RECT_BORDER;
|
const uint16_t barLft = x + RECT_BORDER;
|
||||||
const uint16_t barMid = barLft + barW / 2;
|
const uint16_t barMid = barLft + barW / 2;
|
||||||
|
|
||||||
|
LcdFlags barColor = COLOR2FLAGS(bar_color);
|
||||||
|
LcdFlags txtColor = COLOR2FLAGS(txt_color);
|
||||||
|
|
||||||
for (uint8_t curChan = firstChan; curChan < lastChan && curChan <= MAX_OUTPUT_CHANNELS; curChan++) {
|
for (uint8_t curChan = firstChan; curChan < lastChan && curChan <= MAX_OUTPUT_CHANNELS; curChan++) {
|
||||||
const int16_t chanVal = calcRESXto100(channelOutputs[curChan-1]);
|
const int16_t chanVal = calcRESXto100(channelOutputs[curChan-1]);
|
||||||
const uint16_t rowTop = y + (curChan - firstChan) * rowH;
|
const uint16_t rowTop = y + (curChan - firstChan) * rowH;
|
||||||
@@ -66,16 +69,16 @@ class OutputsWidget: public Widget
|
|||||||
dc->drawSolidFilledRect(barLft, barTop, barW , barH, CUSTOM_COLOR);
|
dc->drawSolidFilledRect(barLft, barTop, barW , barH, CUSTOM_COLOR);
|
||||||
}
|
}
|
||||||
if (fillW)
|
if (fillW)
|
||||||
dc->drawSolidFilledRect((chanVal > 0 ? barMid : barMid - fillW), barTop, fillW, barH, COLOR_THEME_SECONDARY1);
|
dc->drawSolidFilledRect((chanVal > 0 ? barMid : barMid - fillW), barTop, fillW, barH, barColor);
|
||||||
lcd->drawSolidVerticalLine(barMid, barTop, barH, COLOR_THEME_SECONDARY1);
|
lcd->drawSolidVerticalLine(barMid, barTop, barH, COLOR_THEME_SECONDARY1);
|
||||||
dc->drawRect(x, rowTop, w, rowH + 1);
|
dc->drawRect(x, rowTop, w, rowH + 1);
|
||||||
dc->drawNumber(x + barW - 10, barTop, chanVal, FONT(XS) | COLOR_THEME_SECONDARY1 | RIGHT, 0, nullptr, "%");
|
dc->drawNumber(x + barW - 10, barTop, chanVal, FONT(XS) | txtColor | RIGHT, 0, nullptr, "%");
|
||||||
if (g_model.limitData[curChan - 1].name[0] != 0) {
|
if (g_model.limitData[curChan - 1].name[0] != 0) {
|
||||||
dc->drawNumber(barLft + 1, barTop, curChan, FONT(XS) | COLOR_THEME_SECONDARY1 | LEFT | LEADING0, 2);
|
dc->drawNumber(barLft + 1, barTop, curChan, FONT(XS) | txtColor | LEFT | LEADING0, 2);
|
||||||
dc->drawSizedText(barLft + 23, barTop, g_model.limitData[curChan - 1].name, sizeof(g_model.limitData[curChan - 1].name), FONT(XS) | COLOR_THEME_SECONDARY1 | LEFT);
|
dc->drawSizedText(barLft + 23, barTop, g_model.limitData[curChan - 1].name, sizeof(g_model.limitData[curChan - 1].name), FONT(XS) | txtColor | LEFT);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
drawSource(dc, barLft + 1, barTop, MIXSRC_FIRST_CH+curChan-1, FONT(XS) | COLOR_THEME_SECONDARY1 | LEFT);
|
drawSource(dc, barLft + 1, barTop, MIXSRC_FIRST_CH+curChan-1, FONT(XS) | txtColor | LEFT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lastChan - 1;
|
return lastChan - 1;
|
||||||
@@ -86,11 +89,15 @@ class OutputsWidget: public Widget
|
|||||||
uint8_t endColumn = drawChannels(dc, 0, 0, (width() / 2) - 1, height(),
|
uint8_t endColumn = drawChannels(dc, 0, 0, (width() / 2) - 1, height(),
|
||||||
persistentData->options[0].value.unsignedValue,
|
persistentData->options[0].value.unsignedValue,
|
||||||
persistentData->options[1].value.boolValue,
|
persistentData->options[1].value.boolValue,
|
||||||
persistentData->options[2].value.unsignedValue);
|
persistentData->options[2].value.unsignedValue,
|
||||||
|
persistentData->options[3].value.unsignedValue,
|
||||||
|
persistentData->options[4].value.unsignedValue);
|
||||||
|
|
||||||
drawChannels(dc, width() / 2, 0, (width() / 2) - 1, height(), endColumn + 1,
|
drawChannels(dc, width() / 2, 0, (width() / 2) - 1, height(), endColumn + 1,
|
||||||
persistentData->options[1].value.boolValue,
|
persistentData->options[1].value.boolValue,
|
||||||
persistentData->options[2].value.unsignedValue);
|
persistentData->options[2].value.unsignedValue,
|
||||||
|
persistentData->options[3].value.unsignedValue,
|
||||||
|
persistentData->options[4].value.unsignedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void oneColumn(BitmapBuffer * dc)
|
void oneColumn(BitmapBuffer * dc)
|
||||||
@@ -98,7 +105,9 @@ class OutputsWidget: public Widget
|
|||||||
drawChannels(dc, 0, 0, width(), height(),
|
drawChannels(dc, 0, 0, width(), height(),
|
||||||
persistentData->options[0].value.unsignedValue,
|
persistentData->options[0].value.unsignedValue,
|
||||||
persistentData->options[1].value.boolValue,
|
persistentData->options[1].value.boolValue,
|
||||||
persistentData->options[2].value.unsignedValue);
|
persistentData->options[2].value.unsignedValue,
|
||||||
|
persistentData->options[3].value.unsignedValue,
|
||||||
|
persistentData->options[4].value.unsignedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkEvents() override
|
void checkEvents() override
|
||||||
@@ -127,6 +136,8 @@ const ZoneOption OutputsWidget::options[] = {
|
|||||||
{ STR_FIRST_CHANNEL, ZoneOption::Integer, OPTION_VALUE_UNSIGNED(1), OPTION_VALUE_UNSIGNED(1), OPTION_VALUE_UNSIGNED(32) },
|
{ STR_FIRST_CHANNEL, ZoneOption::Integer, OPTION_VALUE_UNSIGNED(1), OPTION_VALUE_UNSIGNED(1), OPTION_VALUE_UNSIGNED(32) },
|
||||||
{ STR_FILL_BACKGROUND, ZoneOption::Bool, OPTION_VALUE_BOOL(false) },
|
{ STR_FILL_BACKGROUND, ZoneOption::Bool, OPTION_VALUE_BOOL(false) },
|
||||||
{ STR_BG_COLOR, ZoneOption::Color, OPTION_VALUE_UNSIGNED(LIGHTGREY) },
|
{ STR_BG_COLOR, ZoneOption::Color, OPTION_VALUE_UNSIGNED(LIGHTGREY) },
|
||||||
|
{ STR_TEXT_COLOR, ZoneOption::Color, OPTION_VALUE_UNSIGNED(COLOR_THEME_PRIMARY1>>16) },
|
||||||
|
{ STR_COLOR, ZoneOption::Color, OPTION_VALUE_UNSIGNED(COLOR_THEME_SECONDARY1>>16) },
|
||||||
{ nullptr, ZoneOption::Bool }
|
{ nullptr, ZoneOption::Bool }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user