Merge with latest 2.3

This commit is contained in:
Bertrand Songis
2020-05-30 11:57:03 +02:00
240 changed files with 16050 additions and 14404 deletions
+2 -1
View File
@@ -32,6 +32,7 @@
#define DEFAULT_SCROLLBAR_X (LCD_W-1)
#define NUM_BODY_LINES (LCD_LINES-1)
#define TEXT_VIEWER_LINES NUM_BODY_LINES
#define MENU_HEADER_HEIGHT FH
#define MODEL_BITMAP_WIDTH 64
@@ -226,7 +227,6 @@ swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr, event_t e
void gvarWeightItem(coord_t x, coord_t y, MixData * md, LcdFlags attr, event_t event);
extern uint8_t s_curveChan;
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags);
extern uint8_t editNameCursorPos;
@@ -244,6 +244,7 @@ extern uint8_t s_copyMode;
extern int8_t s_copySrcRow;
extern int8_t s_copyTgtOfs;
extern uint8_t s_currIdx;
extern uint8_t s_currIdxSubMenu;
extern uint8_t s_maxLines;
extern uint8_t s_copySrcIdx;
extern uint8_t s_copySrcCh;
+36 -19
View File
@@ -18,6 +18,7 @@
* GNU General Public License for more details.
*/
#include <limits.h>
#include "opentx.h"
#include "common/stdlcd/fonts.h"
@@ -87,11 +88,11 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width,
uint8_t lines = (height+7)/8;
assert(lines <= 5);
for (int8_t i=0; i<(int8_t)(width+2); i++) {
if (x<LCD_W) {
for (int8_t i = 0; i < int8_t(width + 2); i++) {
if (x < LCD_W) {
uint8_t b[5] = { 0 };
if (i==0) {
if (x==0 || !inv) {
if (i == 0) {
if (x == 0 || !inv) {
lcdNextPos++;
continue;
}
@@ -100,11 +101,11 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width,
x--;
}
}
else if (i<=width) {
else if (i <= width) {
uint8_t skip = true;
for (uint8_t j=0; j<lines; j++) {
b[j] = *(pattern++); /*top byte*/
if (b[j] != 0xff) {
if (b[j] != 0xFF) {
skip = false;
}
}
@@ -120,20 +121,24 @@ void lcdPutPattern(coord_t x, coord_t y, const uint8_t * pattern, uint8_t width,
}
}
for (int8_t j=-1; j<=(int8_t)(height); j++) {
for (int8_t j = -1; j <= int8_t(height); j++) {
bool plot;
if (j < 0 || ((j == height) && !(FONTSIZE(flags) == SMLSIZE))) {
if (j < 0 || (j == height && FONTSIZE(flags) != SMLSIZE)) {
plot = false;
if (height >= 12) continue;
if (j<0 && !inv) continue;
if (y+j < 0) continue;
if (height >= 12)
continue;
if (j < 0 && !inv)
continue;
if (y + j < 0)
continue;
}
else {
uint8_t line = (j / 8);
uint8_t pixel = (j % 8);
plot = b[line] & (1 << pixel);
}
if (inv) plot = !plot;
if (inv)
plot = !plot;
if (!blink) {
if (flags & VERTICAL)
lcdDrawPoint(y+j, LCD_H-x, plot ? FORCE : ERASE);
@@ -154,10 +159,10 @@ void getCharPattern(PatternData * pattern, unsigned char c, LcdFlags flags)
uint32_t fontsize = FONTSIZE(flags);
unsigned char c_remapped = 0;
if (fontsize == DBLSIZE || (flags&BOLD)) {
if (fontsize == DBLSIZE || (flags & BOLD)) {
// To save space only some DBLSIZE and BOLD chars are available
// c has to be remapped. All non existing chars mapped to 0 (space)
if (c>=',' && c<=':')
if (c >= ',' && c <= ':')
c_remapped = c - ',' + 1;
else if (c>='A' && c<='Z')
c_remapped = c - 'A' + 16;
@@ -221,7 +226,7 @@ uint8_t getCharWidth(char c, LcdFlags flags)
}
#endif
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags)
void lcdDrawChar(coord_t x, coord_t y, char c, LcdFlags flags)
{
lcdNextPos = x-1;
#if defined(BOOT)
@@ -234,7 +239,7 @@ void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags flags)
#endif
}
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c)
void lcdDrawChar(coord_t x, coord_t y, char c)
{
lcdDrawChar(x, y, c, 0);
}
@@ -285,7 +290,7 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
break;
}
else if (c >= 0x20) {
if ( ( c == 46) && ((FONTSIZE(flags) == TINSIZE))) { // '.' handling
if (c == 46 && FONTSIZE(flags) == TINSIZE) { // '.' handling
if (((flags & BLINK) && BLINK_ON_PHASE) || ((!(flags & BLINK) && (flags & INVERS)))) {
lcdDrawSolidVerticalLine(x, y-1, 5);
lcdDrawPoint(x, y + 5);
@@ -293,7 +298,7 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
else {
lcdDrawPoint(x, y + 5 -1 , flags);
}
x+=2;
x += 2;
}
else {
lcdDrawChar(x, y, c, flags);
@@ -320,7 +325,7 @@ void lcdDrawSizedText(coord_t x, coord_t y, const char * s, uint8_t len, LcdFlag
x += 1;
}
else {
x += (c*FW/2); // EXTENDED SPACE
x += (c * FW/2); // EXTENDED SPACE
}
s++;
}
@@ -398,7 +403,19 @@ void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags flags, uint8_t le
int idx = 0;
int mode = MODE(flags);
bool neg = false;
if (val == INT_MAX) {
flags &= ~(LEADING0 | PREC1 | PREC2);
lcdDrawText(x, y, "INT_MAX", flags);
return;
}
if (val < 0) {
if (val == INT_MIN) {
flags &= ~(LEADING0 | PREC1 | PREC2);
lcdDrawText(x, y, "INT_MIN", flags);
return;
}
val = -val;
neg = true;
}
+3 -3
View File
@@ -100,12 +100,12 @@ extern coord_t lcdNextPos;
#define DISPLAY_END (displayBuf + DISPLAY_BUFFER_SIZE)
#define ASSERT_IN_DISPLAY(p) assert((p) >= displayBuf && (p) < DISPLAY_END)
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c);
void lcdDrawChar(coord_t x, coord_t y, const unsigned char c, LcdFlags mode);
void lcdDrawChar(coord_t x, coord_t y, char c);
void lcdDrawChar(coord_t x, coord_t y, char c, LcdFlags mode);
void lcdDrawCenteredText(coord_t y, const char * s, LcdFlags flags = 0);
void lcdDrawText(coord_t x, coord_t y, const char * s, LcdFlags mode);
void lcdDrawTextAtIndex(coord_t x, coord_t y, const char * s,uint8_t idx, LcdFlags mode);
void lcdDrawSizedText(coord_t x, coord_t y, const char * s,unsigned char len, LcdFlags mode);
void lcdDrawSizedText(coord_t x, coord_t y, const char * s, unsigned char len, LcdFlags mode);
void lcdDrawText(coord_t x, coord_t y, const char * s);
void lcdDrawSizedText(coord_t x, coord_t y, const char * s, unsigned char len);
void lcdDrawTextAlignedLeft(coord_t y, const char * s);
+2
View File
@@ -63,7 +63,9 @@ uint8_t editNameCursorPos = 0;
void editSingleName(coord_t x, coord_t y, const char * label, char *name, uint8_t size, event_t event, uint8_t active)
{
lcdDrawTextAlignedLeft(y, label);
TRACE("EDIT SINGLE NAME %s", name);
editName(x, y, name, size, event, active);
}
uint8_t s_currIdx;
uint8_t s_currIdxSubMenu;
+13 -13
View File
@@ -52,8 +52,8 @@ void runPopupCurvePreset(event_t event)
if (warningResult) {
warningResult = 0;
CurveHeader & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
CurveHeader & crv = g_model.curves[s_currIdxSubMenu];
int8_t * points = curveAddress(s_currIdxSubMenu);
int k = 25 * reusableBuffer.curveEdit.preset;
int dx = 2000 / (5+crv.points-1);
for (uint8_t i=0; i<5+crv.points; i++) {
@@ -73,14 +73,14 @@ void onCurveOneMenu(const char * result)
POPUP_INPUT(STR_PRESET, runPopupCurvePreset);
}
else if (result == STR_MIRROR) {
CurveHeader & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
CurveHeader & crv = g_model.curves[s_currIdxSubMenu];
int8_t * points = curveAddress(s_currIdxSubMenu);
for (int i=0; i<5+crv.points; i++)
points[i] = -points[i];
}
else if (result == STR_CLEAR) {
CurveHeader & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
CurveHeader & crv = g_model.curves[s_currIdxSubMenu];
int8_t * points = curveAddress(s_currIdxSubMenu);
for (int i=0; i<5+crv.points; i++)
points[i] = 0;
if (crv.type == CURVE_TYPE_CUSTOM) {
@@ -92,10 +92,10 @@ void onCurveOneMenu(const char * result)
void menuModelCurveOne(event_t event)
{
static uint8_t pointsOfs = 0;
CurveHeader & crv = g_model.curves[s_curveChan];
int8_t * points = curveAddress(s_curveChan);
CurveHeader & crv = g_model.curves[s_currIdxSubMenu];
int8_t * points = curveAddress(s_currIdxSubMenu);
drawStringWithIndex(PSIZE(TR_MENUCURVES)*FW+FW, 0, "CV", s_curveChan+1);
drawStringWithIndex(PSIZE(TR_MENUCURVES)*FW+FW, 0, "CV", s_currIdxSubMenu+1);
lcdDrawText(11*FW+FW/2, 0, TR_PT "\002X\006Y");
lcdDrawFilledRect(0, 0, LCD_W, FH, SOLID, FILL_WHITE|GREY_DEFAULT);
@@ -114,9 +114,9 @@ void menuModelCurveOne(event_t event)
uint8_t newType = checkIncDecModelZero(event, crv.type, CURVE_TYPE_LAST);
if (newType != crv.type) {
for (int i = 1; i < 4 + crv.points; i++) {
points[i] = calcRESXto100(applyCustomCurve(calc100toRESX(getCurveX(5 + crv.points, i)), s_curveChan));
points[i] = calcRESXto100(applyCustomCurve(calc100toRESX(getCurveX(5 + crv.points, i)), s_currIdxSubMenu));
}
if (moveCurve(s_curveChan, checkIncDec_Ret > 0 ? 3 + crv.points : -3 - crv.points)) {
if (moveCurve(s_currIdxSubMenu, checkIncDec_Ret > 0 ? 3 + crv.points : -3 - crv.points)) {
if (newType == CURVE_TYPE_CUSTOM) {
resetCustomCurveX(points, 5 + crv.points);
}
@@ -137,8 +137,8 @@ void menuModelCurveOne(event_t event)
newPoints[0] = points[0];
newPoints[4 + count] = points[4 + crv.points];
for (int i = 1; i < 4 + count; i++)
newPoints[i] = calcRESXto100(applyCustomCurve(calc100toRESX(getCurveX(5 + count, i)), s_curveChan));
if (moveCurve(s_curveChan, checkIncDec_Ret * (crv.type == CURVE_TYPE_CUSTOM ? 2 : 1))) {
newPoints[i] = calcRESXto100(applyCustomCurve(calc100toRESX(getCurveX(5 + count, i)), s_currIdxSubMenu));
if (moveCurve(s_currIdxSubMenu, checkIncDec_Ret * (crv.type == CURVE_TYPE_CUSTOM ? 2 : 1))) {
for (int i = 0; i < 5 + count; i++) {
points[i] = newPoints[i];
if (crv.type == CURVE_TYPE_CUSTOM && i != 0 && i != 4 + count)
+1 -1
View File
@@ -212,7 +212,7 @@ void menuModelLimits(event_t event)
case ITEM_LIMITS_CURVE:
drawCurveName(LIMITS_CURVE_POS, y, ld->curve, attr);
if (attr && event==EVT_KEY_LONG(KEY_ENTER) && ld->curve>0) {
s_curveChan = (ld->curve<0 ? -ld->curve-1 : ld->curve-1);
s_currIdxSubMenu = (ld->curve<0 ? -ld->curve-1 : ld->curve-1);
pushMenu(menuModelCurveOne);
}
if (active) {
-1
View File
@@ -20,7 +20,6 @@
#include "opentx.h"
#define MODELSIZE_POS_X 170
#define MODELSEL_W 133
void onModelSelectMenu(const char * result)
+65 -18
View File
@@ -98,6 +98,7 @@ enum MenuModelSetupItems {
ITEM_MODEL_SETUP_EXTERNAL_MODULE_LABEL,
ITEM_MODEL_SETUP_EXTERNAL_MODULE_TYPE,
#if defined (MULTIMODULE)
ITEM_MODEL_SETUP_EXTERNAL_MODULE_PROTOCOL,
ITEM_MODEL_SETUP_EXTERNAL_MODULE_STATUS,
ITEM_MODEL_SETUP_EXTERNAL_MODULE_SYNCSTATUS,
#endif
@@ -248,11 +249,6 @@ inline uint8_t EXTERNAL_MODULE_TYPE_ROW()
{
if (isModuleXJT(EXTERNAL_MODULE) || isModuleR9MNonAccess(EXTERNAL_MODULE) || isModuleDSM2(EXTERNAL_MODULE))
return 1;
#if defined(MULTIMODULE)
else if (isModuleMultimodule(EXTERNAL_MODULE)) {
return 1 + MULTIMODULE_RFPROTO_COLUMNS(EXTERNAL_MODULE);
}
#endif
else
return 0;
}
@@ -362,6 +358,7 @@ void menuModelSetup(event_t event)
LABEL(ExternalModule),
EXTERNAL_MODULE_TYPE_ROW(),
MULTIMODULE_TYPE_ROW(EXTERNAL_MODULE)
MULTIMODULE_STATUS_ROWS(EXTERNAL_MODULE)
MODULE_CHANNELS_ROWS(EXTERNAL_MODULE),
IF_NOT_ACCESS_MODULE_RF(EXTERNAL_MODULE, MODULE_BIND_ROWS(EXTERNAL_MODULE)),
@@ -813,15 +810,6 @@ void menuModelSetup(event_t event)
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_DSM_PROTOCOLS, g_model.moduleData[EXTERNAL_MODULE].rfProtocol, menuHorizontalPosition==1 ? attr : 0);
else if (isModuleR9MNonAccess(EXTERNAL_MODULE))
lcdDrawTextAtIndex(lcdNextPos + 3, y, STR_R9M_REGION, g_model.moduleData[EXTERNAL_MODULE].subType, (menuHorizontalPosition==1 ? attr : 0));
#if defined(MULTIMODULE)
else if (isModuleMultimodule(EXTERNAL_MODULE)) {
uint8_t multi_rfProto = g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol();
// Do not use MODEL_SETUP_3RD_COLUMN here since some the protocol string are so long that we cannot afford the 2 spaces (+6) here
lcdDrawMultiProtocolString(lcdNextPos + 3, y, EXTERNAL_MODULE, multi_rfProto, menuHorizontalPosition == 1 ? attr : 0);
if (MULTIMODULE_HAS_SUBTYPE(EXTERNAL_MODULE))
lcdDrawMultiSubProtocolString(lcdNextPos + 3, y, EXTERNAL_MODULE, g_model.moduleData[EXTERNAL_MODULE].subType, menuHorizontalPosition==2 ? attr : 0);
}
#endif
if (attr && menuHorizontalPosition == 0) {
if (s_editMode > 0) {
g_model.moduleData[EXTERNAL_MODULE].type = MODULE_TYPE_NONE;
@@ -906,6 +894,59 @@ void menuModelSetup(event_t event)
}
break;
#if defined(MULTIMODULE)
case ITEM_MODEL_SETUP_EXTERNAL_MODULE_PROTOCOL:
{
lcdDrawTextAlignedLeft(y, TR_TYPE);
uint8_t multi_rfProto = g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol();
lcdDrawMultiProtocolString(MODEL_SETUP_2ND_COLUMN, y, EXTERNAL_MODULE, multi_rfProto, menuHorizontalPosition == 0 ? attr : 0);
if (MULTIMODULE_HAS_SUBTYPE(EXTERNAL_MODULE))
lcdDrawMultiSubProtocolString(MODEL_SETUP_3RD_COLUMN + 15, y, EXTERNAL_MODULE, g_model.moduleData[EXTERNAL_MODULE].subType,
menuHorizontalPosition == 1 ? attr : 0);
if (attr) {
switch (menuHorizontalPosition) {
case 0: {
int multiRfProto = g_model.moduleData[EXTERNAL_MODULE].getMultiProtocol();
MultiModuleStatus &status = getMultiModuleStatus(EXTERNAL_MODULE);
if (status.isValid()) {
int8_t direction = checkIncDec(event, 0, -1, 1);
if (direction == -1) {
if (multiRfProto == MODULE_SUBTYPE_MULTI_FRSKY)
multiRfProto = MODULE_SUBTYPE_MULTI_FRSKYX_RX;
else
multiRfProto = convertMultiToOtx(status.protocolPrev);
}
if (direction == 1) {
if (multiRfProto == MODULE_SUBTYPE_MULTI_FRSKY)
multiRfProto = MODULE_SUBTYPE_MULTI_FRSKYX2;
else
multiRfProto = convertMultiToOtx(status.protocolNext);
}
}
else {
CHECK_INCDEC_MODELVAR_CHECK(event, multiRfProto, MODULE_SUBTYPE_MULTI_FIRST, MULTI_MAX_PROTOCOLS, isMultiProtocolSelectable);
}
if (checkIncDec_Ret) {
g_model.moduleData[EXTERNAL_MODULE].setMultiProtocol(multiRfProto);
g_model.moduleData[EXTERNAL_MODULE].subType = 0;
resetMultiProtocolsOptions(EXTERNAL_MODULE);
storageDirty(EE_MODEL);
}
}
break;
case 1:
CHECK_INCDEC_MODELVAR(event, g_model.moduleData[EXTERNAL_MODULE].subType, 0, getMaxMultiSubtype(EXTERNAL_MODULE));
if (checkIncDec_Ret) {
resetMultiProtocolsOptions(EXTERNAL_MODULE);
}
break;
}
}
}
break;
#endif
case ITEM_MODEL_SETUP_TRAINER_LABEL:
lcdDrawTextAlignedLeft(y, STR_TRAINER);
break;
@@ -1100,8 +1141,13 @@ void menuModelSetup(event_t event)
lcdDrawText(INDENT_WIDTH, y, STR_RECEIVER_NUM);
}
if (isModuleBindRangeAvailable(moduleIdx)) {
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[moduleIdx], (l_posHorz==0 ? attr : 0) | LEADING0|LEFT, 2);
bindButtonPos = lcdNextPos + FW;
if (!IS_RX_MULTI(moduleIdx)) {
lcdDrawNumber(MODEL_SETUP_2ND_COLUMN, y, g_model.header.modelId[moduleIdx], (l_posHorz == 0 ? attr : 0) | LEADING0 | LEFT, 2);
bindButtonPos = lcdNextPos + FW;
}
else {
bindButtonPos = MODEL_SETUP_2ND_COLUMN;
}
if (attr && l_posHorz==0) {
if (s_editMode>0) {
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.header.modelId[moduleIdx], getMaxRxNum(moduleIdx));
@@ -1119,7 +1165,8 @@ void menuModelSetup(event_t event)
}
}
lcdDrawText(bindButtonPos, y, STR_MODULE_BIND, l_posHorz==1 ? attr : 0);
lcdDrawText(lcdNextPos + FW, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0);
if (!IS_RX_MULTI(moduleIdx))
lcdDrawText(lcdNextPos + FW, y, STR_MODULE_RANGE, l_posHorz==2 ? attr : 0);
uint8_t newFlag = 0;
#if defined(MULTIMODULE)
if (getMultiBindStatus(moduleIdx) == MULTI_BIND_FINISHED) {
@@ -1284,7 +1331,7 @@ void menuModelSetup(event_t event)
}
#if defined (MULTIMODULE)
else if (isModuleMultimodule(moduleIdx)) {
g_model.moduleData[EXTERNAL_MODULE].multi.lowPowerMode = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].multi.lowPowerMode, MODEL_SETUP_2ND_COLUMN, y, STR_MULTI_LOWPOWER, attr, event);
g_model.moduleData[EXTERNAL_MODULE].multi.lowPowerMode = editCheckBox(g_model.moduleData[EXTERNAL_MODULE].multi.lowPowerMode, MODEL_SETUP_2ND_COLUMN, y, IS_RX_MULTI(moduleIdx) ? STR_MULTI_LNA_DISABLE : STR_MULTI_LOWPOWER, attr, event);
}
#endif
break;
-8
View File
@@ -38,12 +38,4 @@ void menuRadioDiagAnalogs(event_t event)
lcdDrawNumber(x+10*FW-1, y, (int16_t)calibratedAnalogs[CONVERT_MODE(i)]*25/256, RIGHT);
#endif
}
// RAS
if ((isModuleXJT(INTERNAL_MODULE) && IS_INTERNAL_MODULE_ON()) || (isModulePXX1(EXTERNAL_MODULE) && !IS_INTERNAL_MODULE_ON())) {
lcdDrawTextAlignedLeft(MENU_HEADER_HEIGHT+6*FH, "RAS");
lcdDrawNumber(10*FW-1, MENU_HEADER_HEIGHT+6*FH, telemetryData.swrInternal.value(), RIGHT);
lcdDrawText(LCD_W/2, MENU_HEADER_HEIGHT+6*FH, "XJTVER");
lcdDrawNumber(LCD_W/2 + 10*FW-1, MENU_HEADER_HEIGHT+6*FH, telemetryData.xjtVersion, RIGHT);
}
}