mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 01:35:21 +03:00
Review switch warning and switch definitions
This commit is contained in:
parent
61fffdd7cb
commit
5f5fac621f
2 changed files with 20 additions and 4 deletions
|
@ -25,6 +25,18 @@
|
||||||
|
|
||||||
#define SET_DIRTY() storageDirty(EE_MODEL)
|
#define SET_DIRTY() storageDirty(EE_MODEL)
|
||||||
|
|
||||||
|
std::string switchWarninglabel(swsrc_t index)
|
||||||
|
{
|
||||||
|
static const char switchPositions[] = {
|
||||||
|
' ',
|
||||||
|
CHAR_UP,
|
||||||
|
'-',
|
||||||
|
CHAR_DOWN
|
||||||
|
};
|
||||||
|
|
||||||
|
return TEXT_AT_INDEX(STR_VSRCRAW, (index + MIXSRC_FIRST_SWITCH - MIXSRC_Rud + 1)) + std::string(&switchPositions[g_model.switchWarningState >> (3*index) & 0x07], 1);
|
||||||
|
}
|
||||||
|
|
||||||
class MultimoduleStatus: public StaticText
|
class MultimoduleStatus: public StaticText
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -1074,14 +1086,13 @@ void ModelSetupPage::build(FormWindow * window)
|
||||||
auto group = new FormGroup(window, grid.getFieldSlot(), FORM_BORDER_FOCUS_ONLY | PAINT_CHILDREN_FIRST);
|
auto group = new FormGroup(window, grid.getFieldSlot(), FORM_BORDER_FOCUS_ONLY | PAINT_CHILDREN_FIRST);
|
||||||
GridLayout switchesGrid(group);
|
GridLayout switchesGrid(group);
|
||||||
for (int i = 0, j = -1; i < NUM_SWITCHES; i++) {
|
for (int i = 0, j = -1; i < NUM_SWITCHES; i++) {
|
||||||
char s[SWITCH_WARNING_STR_SIZE];
|
|
||||||
if (SWITCH_EXISTS(i))
|
if (SWITCH_EXISTS(i))
|
||||||
j++;
|
j++;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
if (j > 0 && (j % 3) == 0)
|
if (j > 0 && (j % 3) == 0)
|
||||||
switchesGrid.nextLine();
|
switchesGrid.nextLine();
|
||||||
auto button = new TextButton(group, switchesGrid.getSlot(3, j % 3), getSwitchWarningString(s, i), nullptr,
|
auto button = new TextButton(group, switchesGrid.getSlot(3, j % 3), switchWarninglabel(i), nullptr,
|
||||||
(bfGet(g_model.switchWarningState, 3 * i, 3) == 0 ? 0 : BUTTON_CHECKED));
|
(bfGet(g_model.switchWarningState, 3 * i, 3) == 0 ? 0 : BUTTON_CHECKED));
|
||||||
button->setPressHandler([button, i] {
|
button->setPressHandler([button, i] {
|
||||||
swarnstate_t newstate = bfGet(g_model.switchWarningState, 3 * i, 3);
|
swarnstate_t newstate = bfGet(g_model.switchWarningState, 3 * i, 3);
|
||||||
|
@ -1091,7 +1102,7 @@ void ModelSetupPage::build(FormWindow * window)
|
||||||
newstate = (newstate + 1) % 4;
|
newstate = (newstate + 1) % 4;
|
||||||
g_model.switchWarningState = bfSet(g_model.switchWarningState, newstate, 3 * i, 3);
|
g_model.switchWarningState = bfSet(g_model.switchWarningState, newstate, 3 * i, 3);
|
||||||
SET_DIRTY();
|
SET_DIRTY();
|
||||||
button->setText(getSwitchWarningString(i));
|
button->setText(switchWarninglabel(i));
|
||||||
return newstate > 0;
|
return newstate > 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,12 @@ class SwitchDynamicLabel: public StaticText {
|
||||||
|
|
||||||
std::string label()
|
std::string label()
|
||||||
{
|
{
|
||||||
return TEXT_AT_INDEX(STR_VSRCRAW, (index + MIXSRC_FIRST_SWITCH - MIXSRC_Rud + 1)) + std::string(&"\300-\301"[lastpos], 1);
|
static const char switchPositions[] = {
|
||||||
|
CHAR_UP,
|
||||||
|
'-',
|
||||||
|
CHAR_DOWN
|
||||||
|
};
|
||||||
|
return TEXT_AT_INDEX(STR_VSRCRAW, (index + MIXSRC_FIRST_SWITCH - MIXSRC_Rud + 1)) + std::string(&switchPositions[lastpos], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void update()
|
void update()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue