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:
@@ -31,131 +31,166 @@ 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 buildHeader(Window * window)
|
void checkEvents() override
|
||||||
{
|
{
|
||||||
new StaticText(window,
|
Window::checkEvents();
|
||||||
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP, LCD_W - PAGE_TITLE_LEFT,
|
int newValue = channelOutputs[channel];
|
||||||
PAGE_LINE_HEIGHT},
|
if (value != newValue) {
|
||||||
STR_MENULIMITS, 0, COLOR_THEME_PRIMARY2);
|
value = newValue;
|
||||||
new StaticText(window,
|
body.clear();
|
||||||
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP + PAGE_LINE_HEIGHT,
|
buildBody(&body);
|
||||||
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
|
}
|
||||||
getSourceString(MIXSRC_CH1 + channel), 0, COLOR_THEME_PRIMARY2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildBody(FormWindow * window)
|
void buildHeader(Window * window)
|
||||||
{
|
{
|
||||||
FormGridLayout grid;
|
new StaticText(window,
|
||||||
grid.spacer(8);
|
{PAGE_TITLE_LEFT, PAGE_TITLE_TOP,
|
||||||
|
LCD_W - PAGE_TITLE_LEFT, PAGE_LINE_HEIGHT},
|
||||||
|
STR_MENULIMITS, 0, COLOR_THEME_PRIMARY2);
|
||||||
|
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,
|
||||||
|
COLOR_THEME_PRIMARY2);
|
||||||
|
}
|
||||||
|
|
||||||
int limit = (g_model.extendedLimits ? LIMIT_EXT_MAX : LIMIT_STD_MAX);
|
void buildBody(FormWindow * window)
|
||||||
|
{
|
||||||
|
FormGridLayout grid;
|
||||||
|
grid.spacer(8);
|
||||||
|
|
||||||
LimitData * output = limitAddress(channel);
|
int limit = (g_model.extendedLimits ? LIMIT_EXT_MAX : LIMIT_STD_MAX);
|
||||||
|
|
||||||
// Name
|
LimitData *output = limitAddress(channel);
|
||||||
new StaticText(window, grid.getLabelSlot(), STR_NAME, 0,
|
int chanVal = calcRESXto100(channelOutputs[channel]);
|
||||||
COLOR_THEME_PRIMARY1);
|
|
||||||
new ModelTextEdit(window, grid.getFieldSlot(), output->name,
|
|
||||||
sizeof(output->name));
|
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
// Offset
|
// Name
|
||||||
new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_SUBTRIM, 0,
|
new StaticText(window, grid.getLabelSlot(), STR_NAME, 0,
|
||||||
COLOR_THEME_PRIMARY1);
|
COLOR_THEME_PRIMARY1);
|
||||||
new GVarNumberEdit(window, grid.getFieldSlot(), -LIMIT_STD_MAX,
|
new ModelTextEdit(window, grid.getFieldSlot(), output->name,
|
||||||
+LIMIT_STD_MAX, GET_SET_DEFAULT(output->offset), 0,
|
sizeof(output->name));
|
||||||
PREC1);
|
grid.nextLine();
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
// Min
|
// Offset
|
||||||
new StaticText(window, grid.getLabelSlot(), TR_MIN, 0,
|
new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_SUBTRIM,
|
||||||
COLOR_THEME_PRIMARY1);
|
0, COLOR_THEME_PRIMARY1);
|
||||||
new GVarNumberEdit(window, grid.getFieldSlot(), -limit, 0,
|
new GVarNumberEdit(window, grid.getFieldSlot(), -LIMIT_STD_MAX,
|
||||||
GET_SET_DEFAULT(output->min), 0, PREC1
|
+LIMIT_STD_MAX, GET_SET_DEFAULT(output->offset), 0,
|
||||||
, -LIMIT_STD_MAX);
|
PREC1);
|
||||||
grid.nextLine();
|
grid.nextLine();
|
||||||
|
|
||||||
// Max
|
//TRACE("ch=%d cV=%d zero=%d", channel, chanVal, chanZero);
|
||||||
new StaticText(window, grid.getLabelSlot(), TR_MAX, 0,
|
|
||||||
COLOR_THEME_PRIMARY1);
|
|
||||||
new GVarNumberEdit(window, grid.getFieldSlot(), 0, +limit,
|
|
||||||
GET_SET_DEFAULT(output->max), 0, PREC1
|
|
||||||
, +LIMIT_STD_MAX);
|
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
// Direction
|
// Min
|
||||||
new StaticText(window, grid.getLabelSlot(), STR_INVERTED, 0, COLOR_THEME_PRIMARY1);
|
new StaticText(
|
||||||
new CheckBox(window, grid.getFieldSlot(), GET_SET_DEFAULT(output->revert));
|
window, grid.getLabelSlot(), TR_MIN, 0,
|
||||||
grid.nextLine();
|
chanVal < chanZero - 1 ? COLOR_THEME_ACTIVE : COLOR_THEME_PRIMARY1);
|
||||||
|
new GVarNumberEdit(window, grid.getFieldSlot(), -limit, 0,
|
||||||
|
GET_SET_DEFAULT(output->min), 0, PREC1,
|
||||||
|
-LIMIT_STD_MAX);
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
// Curve
|
// Max
|
||||||
new StaticText(window, grid.getLabelSlot(), TR_CURVE, 0,
|
new StaticText(
|
||||||
COLOR_THEME_PRIMARY1);
|
window, grid.getLabelSlot(), TR_MAX, 0,
|
||||||
auto edit = new NumberEdit(window, grid.getFieldSlot(), -MAX_CURVES,
|
chanVal > chanZero + 1 ? COLOR_THEME_ACTIVE : COLOR_THEME_PRIMARY1);
|
||||||
+MAX_CURVES, GET_SET_DEFAULT(output->curve));
|
new GVarNumberEdit(window, grid.getFieldSlot(), 0, +limit,
|
||||||
edit->setDisplayHandler(
|
GET_SET_DEFAULT(output->max), 0, PREC1,
|
||||||
[](BitmapBuffer *dc, LcdFlags flags, int32_t value) {
|
+LIMIT_STD_MAX);
|
||||||
dc->drawText(2, 2, getCurveString(value));
|
grid.nextLine();
|
||||||
});
|
|
||||||
grid.nextLine();
|
|
||||||
|
|
||||||
// PPM center
|
// Direction
|
||||||
new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_PPMCENTER,
|
new StaticText(window, grid.getLabelSlot(), STR_INVERTED, 0,
|
||||||
0, COLOR_THEME_PRIMARY1);
|
COLOR_THEME_PRIMARY1);
|
||||||
new NumberEdit(window, grid.getFieldSlot(), PPM_CENTER - PPM_CENTER_MAX,
|
new CheckBox(window, grid.getFieldSlot(),
|
||||||
PPM_CENTER + PPM_CENTER_MAX,
|
GET_DEFAULT(output->revert),
|
||||||
GET_VALUE(output->ppmCenter + PPM_CENTER),
|
[output, this] (uint8_t newValue) {
|
||||||
SET_VALUE(output->ppmCenter, newValue - PPM_CENTER));
|
if (newValue != output->revert) chanZero = -chanZero;
|
||||||
grid.nextLine();
|
output->revert = newValue;
|
||||||
|
SET_DIRTY();
|
||||||
|
});
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
// Subtrims mode
|
// Curve
|
||||||
new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_SUBTRIMMODE,
|
new StaticText(window, grid.getLabelSlot(), TR_CURVE, 0,
|
||||||
0, COLOR_THEME_PRIMARY1);
|
COLOR_THEME_PRIMARY1);
|
||||||
new Choice(window, grid.getFieldSlot(), STR_SUBTRIMMODES, 0, 1,
|
auto edit = new NumberEdit(window, grid.getFieldSlot(), -MAX_CURVES,
|
||||||
GET_SET_DEFAULT(output->symetrical));
|
+MAX_CURVES, GET_SET_DEFAULT(output->curve));
|
||||||
grid.nextLine();
|
edit->setDisplayHandler(
|
||||||
|
[](BitmapBuffer *dc, LcdFlags flags, int32_t value) {
|
||||||
|
dc->drawText(2, 2, getCurveString(value));
|
||||||
|
});
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
window->setInnerHeight(grid.getWindowHeight());
|
// PPM center
|
||||||
}
|
new StaticText(window, grid.getLabelSlot(), TR_LIMITS_HEADERS_PPMCENTER,
|
||||||
};
|
0, COLOR_THEME_PRIMARY1);
|
||||||
|
new NumberEdit(window, grid.getFieldSlot(), PPM_CENTER - PPM_CENTER_MAX,
|
||||||
|
PPM_CENTER + PPM_CENTER_MAX,
|
||||||
|
GET_VALUE(output->ppmCenter + PPM_CENTER),
|
||||||
|
SET_VALUE(output->ppmCenter, newValue - PPM_CENTER));
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
|
// Subtrims mode
|
||||||
|
new StaticText(window, grid.getLabelSlot(),
|
||||||
|
TR_LIMITS_HEADERS_SUBTRIMMODE, 0, COLOR_THEME_PRIMARY1);
|
||||||
|
new Choice(window, grid.getFieldSlot(), STR_SUBTRIMMODES, 0, 1,
|
||||||
|
GET_SET_DEFAULT(output->symetrical));
|
||||||
|
grid.nextLine();
|
||||||
|
|
||||||
|
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,
|
||||||
-LIMITS_MIN_MAX_OFFSET);
|
-GV_RANGELARGE, 0, PREC1 | textFlag, nullptr,
|
||||||
|
-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, [=]() {
|
||||||
|
|||||||
Reference in New Issue
Block a user