1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-21 15:25:17 +03:00

Bsongis/x7d fixes (#4019)

* [X7D] Various fixes

[Others]
- Fixes the Mixer / Inputs MOVE / COPY problem on X9E
- Adds the copy/paste/rename feature in SDCARD menu on X7D/SKY9X
- Merges some duplicated code using the new directory structure
- Cosmetics
This commit is contained in:
Bertrand Songis 2016-11-13 19:06:21 +01:00 committed by GitHub
parent fd33cc9d2b
commit bfb5e9b8a6
42 changed files with 1285 additions and 2188 deletions

View file

@ -55,3 +55,100 @@ FlightModesType editFlightModes(coord_t x, coord_t y, event_t event, FlightModes
return value;
}
#endif
#if defined(CPUARM)
void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, uint8_t active, LcdFlags attr)
{
uint8_t mode = 0;
if (active) {
if (s_editMode <= 0)
mode = INVERS + FIXEDWIDTH;
else
mode = FIXEDWIDTH;
}
lcdDrawSizedText(x, y, name, size, attr | mode);
coord_t backupNextPos = lcdNextPos;
if (active) {
uint8_t cur = editNameCursorPos;
if (s_editMode > 0) {
int8_t c = name[cur];
int8_t v = c;
if (IS_NEXT_EVENT(event) || IS_PREVIOUS_EVENT(event)) {
if (attr == ZCHAR) {
v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0);
if (c <= 0) v = -v;
}
else {
v = checkIncDec(event, abs(v), '0', 'z', 0);
}
}
switch (event) {
case EVT_KEY_BREAK(KEY_ENTER):
if (s_editMode == EDIT_MODIFY_FIELD) {
s_editMode = EDIT_MODIFY_STRING;
cur = 0;
}
else if (cur<size-1)
cur++;
else
s_editMode = 0;
break;
case EVT_KEY_LONG(KEY_ENTER):
if (attr & ZCHAR) {
if (v == 0) {
s_editMode = 0;
killEvents(event);
}
else if (v>=-26 && v<=26) {
v = -v; // toggle case
}
}
else {
if (v == ' ') {
s_editMode = 0;
killEvents(event);
break;
}
else if (v>='A' && v<='Z') {
v = 'a'+v-'A'; // toggle case
}
else if (v>='a' && v<='z') {
v = 'A'+v-'a'; // toggle case
}
}
break;
}
if (c != v) {
name[cur] = v;
storageDirty(menuVerticalPositions[0] == 0 ? EE_MODEL : EE_GENERAL);
}
if (attr == ZCHAR) {
lcdDrawChar(x+editNameCursorPos*FW, y, idx2char(v), ERASEBG|INVERS|FIXEDWIDTH);
}
else {
lcdDrawChar(x+editNameCursorPos*FW, y, v, ERASEBG|INVERS|FIXEDWIDTH);
}
}
else {
cur = 0;
}
editNameCursorPos = cur;
lcdNextPos = backupNextPos;
}
}
#endif
void gvarWeightItem(coord_t x, coord_t y, MixData * md, LcdFlags attr, event_t event)
{
u_int8int16_t weight;
MD_WEIGHT_TO_UNION(md, weight);
weight.word = GVAR_MENU_ITEM(x, y, weight.word, GV_RANGELARGE_WEIGHT_NEG, GV_RANGELARGE_WEIGHT, attr, 0, event);
MD_UNION_TO_WEIGHT(weight, md);
}