* [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
141 lines
3.5 KiB
C++
141 lines
3.5 KiB
C++
/*
|
|
* Copyright (C) OpenTX
|
|
*
|
|
* Based on code named
|
|
* th9x - http://code.google.com/p/th9x
|
|
* er9x - http://code.google.com/p/er9x
|
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
|
*
|
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include "opentx.h"
|
|
|
|
#if defined(TELEMETRY_MAVLINK)
|
|
#include "view_mavlink.h"
|
|
#endif
|
|
|
|
uint8_t editDelay(coord_t y, event_t event, uint8_t attr, const pm_char * str, uint8_t delay)
|
|
{
|
|
lcdDrawTextAlignedLeft(y, str);
|
|
lcdDrawNumber(MIXES_2ND_COLUMN, y, (10/DELAY_STEP)*delay, attr|PREC1|LEFT);
|
|
if (attr) CHECK_INCDEC_MODELVAR_ZERO(event, delay, DELAY_MAX);
|
|
return delay;
|
|
}
|
|
|
|
uint8_t s_copyMode = 0;
|
|
int8_t s_copySrcRow;
|
|
int8_t s_copyTgtOfs;
|
|
uint8_t s_maxLines = 8;
|
|
uint8_t s_copySrcIdx;
|
|
uint8_t s_copySrcCh;
|
|
|
|
#if !defined(CPUM64)
|
|
uint8_t editNameCursorPos = 0;
|
|
#endif
|
|
|
|
#if !defined(CPUARM)
|
|
void editName(coord_t x, coord_t y, char * name, uint8_t size, event_t event, uint8_t active)
|
|
{
|
|
#if defined(CPUM64)
|
|
// in order to save flash
|
|
lcdDrawTextAlignedLeft(y, STR_NAME);
|
|
#endif
|
|
|
|
uint8_t mode = 0;
|
|
if (active) {
|
|
if (s_editMode <= 0)
|
|
mode = INVERS + FIXEDWIDTH;
|
|
else
|
|
mode = FIXEDWIDTH;
|
|
}
|
|
|
|
lcdDrawSizedText(x, y, name, size, ZCHAR | mode);
|
|
|
|
if (active) {
|
|
uint8_t cur = editNameCursorPos;
|
|
if (s_editMode > 0) {
|
|
int8_t c = name[cur];
|
|
int8_t v = c;
|
|
|
|
if (p1valdiff || IS_ROTARY_RIGHT(event) || IS_ROTARY_LEFT(event) || event==EVT_KEY_FIRST(KEY_DOWN) || event==EVT_KEY_FIRST(KEY_UP)
|
|
|| event==EVT_KEY_REPT(KEY_DOWN) || event==EVT_KEY_REPT(KEY_UP)) {
|
|
v = checkIncDec(event, abs(v), 0, ZCHAR_MAX, 0);
|
|
if (c <= 0) v = -v;
|
|
}
|
|
|
|
switch (event) {
|
|
#if defined(ROTARY_ENCODER_NAVIGATION)
|
|
case EVT_ROTARY_BREAK:
|
|
if (s_editMode == EDIT_MODIFY_FIELD) {
|
|
s_editMode = EDIT_MODIFY_STRING;
|
|
cur = 0;
|
|
}
|
|
else if (cur<size-1)
|
|
cur++;
|
|
else
|
|
s_editMode = 0;
|
|
break;
|
|
#endif
|
|
|
|
case EVT_KEY_BREAK(KEY_LEFT):
|
|
if (cur>0) cur--;
|
|
break;
|
|
case EVT_KEY_BREAK(KEY_RIGHT):
|
|
if (cur<size-1) cur++;
|
|
break;
|
|
|
|
#if defined(ROTARY_ENCODER_NAVIGATION)
|
|
case EVT_ROTARY_LONG:
|
|
if (v == 0) {
|
|
s_editMode = 0;
|
|
killEvents(event);
|
|
break;
|
|
}
|
|
// no break
|
|
#endif
|
|
|
|
case EVT_KEY_LONG(KEY_LEFT):
|
|
case EVT_KEY_LONG(KEY_RIGHT):
|
|
if (v>=-26 && v<=26) {
|
|
v = -v; // toggle case
|
|
if (event==EVT_KEY_LONG(KEY_LEFT))
|
|
killEvents(KEY_LEFT);
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (c != v) {
|
|
name[cur] = v;
|
|
storageDirty(EE_MODEL);
|
|
}
|
|
|
|
lcdDrawChar(x+editNameCursorPos*FW, y, idx2char(v), ERASEBG|INVERS|FIXEDWIDTH);
|
|
}
|
|
else {
|
|
cur = 0;
|
|
}
|
|
editNameCursorPos = cur;
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#if !defined(CPUM64)
|
|
void editSingleName(coord_t x, coord_t y, const pm_char * label, char * name, uint8_t size, event_t event, uint8_t active)
|
|
{
|
|
lcdDrawTextAlignedLeft(y, label);
|
|
editName(x, y, name, size, event, active);
|
|
}
|
|
#endif
|
|
|
|
uint8_t s_currIdx;
|