feat: Show channel change direction in the output screen via text color (#1526)

chore: Remove COPROCESSOR

* Show channel direction on the output screens (#1385)

* minor cleanup
This commit is contained in:
eshifri
2022-02-11 10:23:42 +10:00
committed by GitHub
parent 407ada00f8
commit c04a716bce
+75 -28
View File
@@ -31,23 +31,38 @@ class OutputEditWindow : public Page {
Page(ICON_MODEL_OUTPUTS), Page(ICON_MODEL_OUTPUTS),
channel(channel) channel(channel)
{ {
chanZero = calcRESXto100(channelOutputs[channel]);
buildBody(&body); buildBody(&body);
buildHeader(&header); buildHeader(&header);
} }
protected: protected:
uint8_t channel; uint8_t channel;
int value = 0;
int chanZero = 0;
void checkEvents() override
{
Window::checkEvents();
int newValue = channelOutputs[channel];
if (value != newValue) {
value = newValue;
body.clear();
buildBody(&body);
}
}
void buildHeader(Window * window) void buildHeader(Window * window)
{ {
new StaticText(window, new StaticText(window,
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP,
PAGE_LINE_HEIGHT}, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
STR_MENULIMITS, 0, COLOR_THEME_PRIMARY2); STR_MENULIMITS, 0, COLOR_THEME_PRIMARY2);
new StaticText(window, new StaticText(window,
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT, {PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT,
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT}, LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
getSourceString(MIXSRC_CH1 + channel), 0, COLOR_THEME_PRIMARY2); getSourceString(MIXSRC_CH1 + channel), 0,
COLOR_THEME_PRIMARY2);
} }
void buildBody(FormWindow * window) void buildBody(FormWindow * window)
@@ -57,7 +72,8 @@ class OutputEditWindow : public Page {
int limit = (g_model.extendedLimits ? LIMIT_EXT_MAX : LIMIT_STD_MAX); int limit = (g_model.extendedLimits ? LIMIT_EXT_MAX : LIMIT_STD_MAX);
LimitData * output = limitAddress(channel); LimitData *output = limitAddress(channel);
int chanVal = calcRESXto100(channelOutputs[channel]);
// Name // Name
new StaticText(window, grid.getLabelSlot(), STR_NAME, 0, new StaticText(window, grid.getLabelSlot(), STR_NAME, 0,
@@ -67,32 +83,43 @@ class OutputEditWindow : public Page {
grid.nextLine(); grid.nextLine();
// Offset // Offset
new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_SUBTRIM, 0, new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_SUBTRIM,
COLOR_THEME_PRIMARY1); 0, COLOR_THEME_PRIMARY1);
new GVarNumberEdit(window, grid.getFieldSlot(), -LIMIT_STD_MAX, new GVarNumberEdit(window, grid.getFieldSlot(), -LIMIT_STD_MAX,
+LIMIT_STD_MAX, GET_SET_DEFAULT(output->offset), 0, +LIMIT_STD_MAX, GET_SET_DEFAULT(output->offset), 0,
PREC1); PREC1);
grid.nextLine(); grid.nextLine();
//TRACE("ch=%d cV=%d zero=%d", channel, chanVal, chanZero);
// Min // Min
new StaticText(window, grid.getLabelSlot(), TR_MIN, 0, new StaticText(
COLOR_THEME_PRIMARY1); window, grid.getLabelSlot(), TR_MIN, 0,
chanVal < chanZero - 1 ? COLOR_THEME_ACTIVE : COLOR_THEME_PRIMARY1);
new GVarNumberEdit(window, grid.getFieldSlot(), -limit, 0, new GVarNumberEdit(window, grid.getFieldSlot(), -limit, 0,
GET_SET_DEFAULT(output->min), 0, PREC1 GET_SET_DEFAULT(output->min), 0, PREC1,
, -LIMIT_STD_MAX); -LIMIT_STD_MAX);
grid.nextLine(); grid.nextLine();
// Max // Max
new StaticText(window, grid.getLabelSlot(), TR_MAX, 0, new StaticText(
COLOR_THEME_PRIMARY1); window, grid.getLabelSlot(), TR_MAX, 0,
chanVal > chanZero + 1 ? COLOR_THEME_ACTIVE : COLOR_THEME_PRIMARY1);
new GVarNumberEdit(window, grid.getFieldSlot(), 0, +limit, new GVarNumberEdit(window, grid.getFieldSlot(), 0, +limit,
GET_SET_DEFAULT(output->max), 0, PREC1 GET_SET_DEFAULT(output->max), 0, PREC1,
, +LIMIT_STD_MAX); +LIMIT_STD_MAX);
grid.nextLine(); grid.nextLine();
// Direction // Direction
new StaticText(window, grid.getLabelSlot(), STR_INVERTED, 0, COLOR_THEME_PRIMARY1); new StaticText(window, grid.getLabelSlot(), STR_INVERTED, 0,
new CheckBox(window, grid.getFieldSlot(), GET_SET_DEFAULT(output->revert)); COLOR_THEME_PRIMARY1);
new CheckBox(window, grid.getFieldSlot(),
GET_DEFAULT(output->revert),
[output, this] (uint8_t newValue) {
if (newValue != output->revert) chanZero = -chanZero;
output->revert = newValue;
SET_DIRTY();
});
grid.nextLine(); grid.nextLine();
// Curve // Curve
@@ -116,46 +143,54 @@ class OutputEditWindow : public Page {
grid.nextLine(); grid.nextLine();
// Subtrims mode // Subtrims mode
new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_SUBTRIMMODE, new StaticText(window, grid.getLabelSlot(),
0, COLOR_THEME_PRIMARY1); TR_LIMITS_HEADERS_SUBTRIMMODE, 0, COLOR_THEME_PRIMARY1);
new Choice(window, grid.getFieldSlot(), STR_SUBTRIMMODES, 0, 1, new Choice(window, grid.getFieldSlot(), STR_SUBTRIMMODES, 0, 1,
GET_SET_DEFAULT(output->symetrical)); GET_SET_DEFAULT(output->symetrical));
grid.nextLine(); grid.nextLine();
window->setInnerHeight(grid.getWindowHeight()); window->setInnerHeight(grid.getWindowHeight());
} }
}; };
class OutputLineButton : public Button { class OutputLineButton : public Button {
public: public:
OutputLineButton(FormGroup * parent, const rect_t &rect, LimitData * output) : OutputLineButton(FormGroup * parent, const rect_t &rect, LimitData * output, int ch) :
Button(parent, rect), Button(parent, rect),
output(output) output(output),
channel(ch)
{ {
if (output->revert || output->curve || output->name[0]) { if (output->revert || output->curve || output->name[0]) {
setHeight(height() + PAGE_LINE_HEIGHT + FIELD_PADDING_TOP); setHeight(height() + PAGE_LINE_HEIGHT + FIELD_PADDING_TOP);
} }
chanZero = calcRESXto100(channelOutputs[channel]);
} }
void paint(BitmapBuffer * dc) override void paint(BitmapBuffer * dc) override
{ {
LcdFlags textColor = COLOR_THEME_SECONDARY1; LcdFlags textColor = COLOR_THEME_SECONDARY1;
LcdFlags bgColor = COLOR_THEME_PRIMARY2; LcdFlags bgColor = COLOR_THEME_PRIMARY2;
LcdFlags textColorActive = COLOR_THEME_ACTIVE;
LcdFlags textFlag;
int chanVal = calcRESXto100(channelOutputs[channel]);
dc->drawSolidFilledRect(0, 0, width(), height(), bgColor); dc->drawSolidFilledRect(0, 0, width(), height(), bgColor);
//TRACE("ch=%d cV=%d zero=%d", channel, chanVal, chanZero);
// first line // first line
// Min // Min
drawValueOrGVar(dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, textFlag = (chanVal < chanZero - 1) ? textColorActive : textColor;
output->min, -GV_RANGELARGE, drawValueOrGVar(
0, PREC1 | textColor, nullptr, dc, FIELD_PADDING_LEFT, FIELD_PADDING_TOP, output->min,
-GV_RANGELARGE, 0, PREC1 | textFlag, nullptr,
-LIMITS_MIN_MAX_OFFSET); -LIMITS_MIN_MAX_OFFSET);
// Max // Max
textFlag = (chanVal > chanZero + 1) ? textColorActive : textColor;
drawValueOrGVar(dc, 68, FIELD_PADDING_TOP, drawValueOrGVar(dc, 68, FIELD_PADDING_TOP,
output->max, 0, output->max, 0,
GV_RANGELARGE, PREC1 | textColor, nullptr, GV_RANGELARGE, PREC1 | textFlag, nullptr,
+LIMITS_MIN_MAX_OFFSET); +LIMITS_MIN_MAX_OFFSET);
// Offset // Offset
@@ -194,8 +229,20 @@ class OutputLineButton : public Button {
} }
protected: protected:
LimitData * output; void checkEvents() override
}; {
Window::checkEvents();
int newValue = channelOutputs[channel];
if (value != newValue) {
value = newValue;
invalidate();
}
}
LimitData *output;
int channel;
int chanZero;
int value = 0;
};
ModelOutputsPage::ModelOutputsPage() : ModelOutputsPage::ModelOutputsPage() :
PageTab(STR_MENULIMITS, ICON_MODEL_OUTPUTS) PageTab(STR_MENULIMITS, ICON_MODEL_OUTPUTS)
@@ -233,7 +280,7 @@ void ModelOutputsPage::build(FormWindow * window, int8_t focusChannel)
BUTTON_BACKGROUND, CENTERED | COLOR_THEME_PRIMARY1); BUTTON_BACKGROUND, CENTERED | COLOR_THEME_PRIMARY1);
// Channel settings // Channel settings
Button * button = new OutputLineButton(window, grid.getFieldSlot(), output); Button * button = new OutputLineButton(window, grid.getFieldSlot(), output, ch);
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
Menu * menu = new Menu(window); Menu * menu = new Menu(window);
menu->addLine(STR_EDIT, [=]() { menu->addLine(STR_EDIT, [=]() {