feat: use any source for expo/weight/offset (#5220)

Co-authored-by: philmoz <phil.a.mitchell@gmail.com>
Co-authored-by: 3djc <3djc@gh.com>
Co-authored-by: elecpower <elecpower@users.noreply.github.com>
This commit is contained in:
philmoz
2024-07-26 20:51:21 +10:00
committed by GitHub
co-authored by philmoz 3djc elecpower
parent 326c58a7fd
commit 4b917b762c
87 changed files with 2751 additions and 1671 deletions
+17 -9
View File
@@ -25,6 +25,8 @@
#include "libopenui.h"
#endif
extern int32_t getSourceNumFieldValue(int16_t val, int16_t min, int16_t max);
constexpr int DEFAULT_POINTS = 5;
constexpr int STD_CURVE_POINTS(int p) { return p + DEFAULT_POINTS; }
constexpr int CUSTOM_CURVE_POINTS(int p) { return 2 * p + (2 * DEFAULT_POINTS - 2); }
@@ -318,10 +320,13 @@ int intpol(int x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 100
int applyCurve(int x, CurveRef & curve)
{
SourceNumVal v;
v.rawValue = curve.value;
switch (curve.type) {
case CURVE_REF_DIFF:
{
int curveParam = GET_GVAR_PREC1(curve.value, -100, 100, mixerCurrentFlightMode);
int curveParam = getSourceNumFieldValue(curve.value, -100, 100);
if (curveParam > 0 && x < 0)
x = (x * (1000 - curveParam)) / 1000;
else if (curveParam < 0 && x > 0)
@@ -331,12 +336,12 @@ int applyCurve(int x, CurveRef & curve)
case CURVE_REF_EXPO:
{
int curveParam = GET_GVAR_PREC1(curve.value, -100, 100, mixerCurrentFlightMode) / 10;
int curveParam = getSourceNumFieldValue(curve.value, -100, 100) / 10;
return expo(x, curveParam);
}
case CURVE_REF_FUNC:
switch (curve.value) {
switch (v.value) {
case CURVE_X_GT0:
if (x < 0) x = 0; //x|x>0
return x;
@@ -356,7 +361,7 @@ int applyCurve(int x, CurveRef & curve)
case CURVE_REF_CUSTOM:
{
int curveParam = curve.value;
int curveParam = v.value;
if (curveParam < 0) {
x = -x;
curveParam = -curveParam;
@@ -423,24 +428,27 @@ char *getCurveRefString(char *dest, size_t len, const CurveRef& curve)
if (!len) return dest;
char *s = dest;
if (curve.value != 0) {
SourceNumVal v;
v.rawValue = curve.value;
if (v.value != 0) {
switch (curve.type) {
case CURVE_REF_DIFF:
*(s++) = 'D'; if (--len == 0) return dest;
getValueOrGVarString(s, len, curve.value, -100, 100, 0, "%");
getValueOrSrcVarString(s, len, curve.value, -100, 100, 0, "%");
return dest;
case CURVE_REF_EXPO:
*(s++) = 'E'; if (--len == 0) return dest;
getValueOrGVarString(s, len, curve.value, -100, 100, 0, "%");
getValueOrSrcVarString(s, len, curve.value, -100, 100, 0, "%");
return dest;
case CURVE_REF_FUNC:
strAppend(dest, STR_VCURVEFUNC[curve.value], len);
strAppend(dest, STR_VCURVEFUNC[v.value], len);
return dest;
case CURVE_REF_CUSTOM:
return getCurveString(dest, curve.value);
return getCurveString(dest, v.value);
}
}
+1
View File
@@ -541,6 +541,7 @@ enum MixSources {
MIXSRC_LAST_TELEM SKIP = MIXSRC_FIRST_TELEM + 3 * MAX_TELEMETRY_SENSORS - 1,
MIXSRC_INVERT SKIP,
MIXSRC_VALUE SKIP, // Special case to trigger source as value conversion
};
+10 -10
View File
@@ -42,7 +42,7 @@ static inline void check_struct()
CHKSIZE(CurveRef, 2);
CHKSIZE(VarioData, 5);
CHKSIZE(MixData, 20);
CHKSIZE(ExpoData, 17);
CHKSIZE(ExpoData, 18);
CHKSIZE(SwashRingData, 8);
CHKSIZE(CurveHeader, 4);
CHKSIZE(LogicalSwitchData, 9);
@@ -91,23 +91,23 @@ static inline void check_struct()
#endif
#if defined(RADIO_TPRO) || defined(RADIO_TPROV2)
CHKSIZE(ModelData, 6290);
CHKSIZE(ModelData, 6354);
#elif defined(RADIO_FAMILY_T20)
CHKSIZE(ModelData, 6326);
CHKSIZE(ModelData, 6390);
#elif defined(PCBX9E)
CHKSIZE(ModelData, 6707);
CHKSIZE(ModelData, 6771);
#elif defined(PCBX9D) || defined(PCBX9DP)
CHKSIZE(ModelData, 6706);
CHKSIZE(ModelData, 6770);
#elif defined(PCBX7) || defined(PCBXLITE) || defined(PCBX9LITE)
CHKSIZE(ModelData, 6265);
CHKSIZE(ModelData, 6329);
#elif defined(PCBNV14)
CHKSIZE(ModelData, 15591);
CHKSIZE(ModelData, 15655);
#elif defined(PCBPL18)
CHKSIZE(ModelData, 15771);
CHKSIZE(ModelData, 15835);
#elif defined(RADIO_T15)
CHKSIZE(ModelData, 15760);
CHKSIZE(ModelData, 15824);
#elif defined(PCBHORUS)
CHKSIZE(ModelData, 15735);
CHKSIZE(ModelData, 15799);
#else
#error CHKSIZE not set up
#endif
+28 -10
View File
@@ -62,26 +62,43 @@
#include "storage/yaml/yaml_defs.h"
PACK(union SourceNumVal {
struct {
int16_t value:10;
bool isSource:1;
};
uint16_t rawValue:11;
});
inline uint16_t makeSourceNumVal(int16_t val, bool isSource = false)
{
SourceNumVal v;
v.value = val;
v.isSource= isSource;
return v.rawValue;
}
/*
* Mixer structure
*/
PACK(struct CurveRef {
uint8_t type;
int8_t value CUST(in_read_weight,in_write_weight);
uint16_t type:5;
int16_t value:11 CUST(r_sourceNumVal,w_sourceNumVal);
});
PACK(struct MixData {
int16_t weight:11 CUST(in_read_weight,in_write_weight); // GV1=-1024, -GV1=1023
uint16_t destCh:5;
int16_t srcRaw:10 CUST(r_mixSrcRawEx,w_mixSrcRawEx); // srcRaw=0 means not used
uint16_t carryTrim:1;
uint16_t mixWarn:2; // mixer warning
uint16_t mltpx:2 ENUM(MixerMultiplex);
uint16_t speedPrec:1;
int32_t offset:13 CUST(in_read_weight,in_write_weight);
uint16_t flightModes:9 CUST(r_flightModes, w_flightModes);
uint16_t spare:2;
uint32_t weight:11 CUST(r_sourceNumVal,w_sourceNumVal);
uint32_t offset:11 CUST(r_sourceNumVal,w_sourceNumVal);
int32_t swtch:10 CUST(r_swtchSrc,w_swtchSrc);
uint32_t flightModes:9 CUST(r_flightModes, w_flightModes);
CurveRef curve;
uint8_t delayUp;
uint8_t delayDown;
@@ -100,13 +117,14 @@ PACK(struct ExpoData {
CUST_ATTR(carryTrim, r_carryTrim, nullptr); //pre 2.9
int16_t trimSource:6;
int16_t srcRaw:10 ENUM(MixSources) CUST(r_mixSrcRawEx,w_mixSrcRawEx);
uint32_t chn:5;
uint32_t weight:11 CUST(r_sourceNumVal,w_sourceNumVal);
uint32_t offset:11 CUST(r_sourceNumVal,w_sourceNumVal);
int32_t swtch:10 CUST(r_swtchSrc,w_swtchSrc);
uint32_t flightModes:9 CUST(r_flightModes, w_flightModes);
int32_t weight:8 CUST(in_read_weight,in_write_weight);
NOBACKUP(char name[LEN_EXPOMIX_NAME]);
int8_t offset CUST(in_read_weight,in_write_weight);
CurveRef curve;
uint16_t chn:5;
uint16_t flightModes:9 CUST(r_flightModes, w_flightModes);
uint16_t spare:2;
NOBACKUP(char name[LEN_EXPOMIX_NAME]);
});
/*
+7 -4
View File
@@ -47,7 +47,7 @@
#define CURVE_CENTER_X (LCD_W-CURVE_SIDE_WIDTH-3)
#define CURVE_CENTER_Y (LCD_H/2)
#define MIXES_2ND_COLUMN (12*FW)
#define MIXES_2ND_COLUMN (10*FW)
// Temporary no highlight
extern uint8_t noHighlightCounter;
@@ -80,6 +80,10 @@ uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const char *label,
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr,
event_t event);
uint16_t editSrcVarFieldValue(coord_t x, coord_t y, const char* title, uint16_t value,
int16_t min, int16_t max, LcdFlags attr, event_t event,
IsValueAvailable isValueAvailable, int16_t sourceMin);
#if defined(GVARS)
#define GVAR_MENU_ITEM(x, y, v, min, max, attr, editflags, event) \
@@ -110,8 +114,6 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min,
#endif
void gvarWeightItem(coord_t x, coord_t y, MixData * md, LcdFlags attr, event_t event);
void editName(coord_t x, coord_t y, char *name, uint8_t size, event_t event,
uint8_t active, LcdFlags attr, uint8_t old_editMode);
@@ -198,7 +200,8 @@ void showAlertBox(const char * title, const char * text, const char * action , u
#define IS_TELEMETRY_VIEW_DISPLAYED() menuHandlers[0] == menuViewTelemetry
#define IS_OTHER_VIEW_DISPLAYED() menuHandlers[0] == menuChannelsView
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags);
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags,
IsValueAvailable isValueAvailable, int16_t sourceMin);
#if defined(FLIGHT_MODES)
void displayFlightModes(coord_t x, coord_t y, FlightModesType value);
-49
View File
@@ -662,55 +662,6 @@ void putsVBat(coord_t x, coord_t y, LcdFlags att)
putsVolts(x, y, g_vbat100mV, att);
}
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att)
{
uint16_t aidx = abs(idx);
bool inverted = idx < 0;
if (aidx == MIXSRC_NONE) {
lcdDrawText(x, y, STR_EMPTY, att);
}
else if (aidx <= MIXSRC_LAST_INPUT) {
if (inverted) {
lcdDrawChar(x, y, '!');
x += 2;
}
lcdDrawChar(x+2, y+1, CHR_INPUT, TINSIZE);
lcdDrawSolidFilledRect(x, y, 7, 7);
if (g_model.inputNames[aidx-MIXSRC_FIRST_INPUT][0])
lcdDrawSizedText(x+8, y, g_model.inputNames[aidx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, att);
else
lcdDrawNumber(x+8, y, aidx, att|LEADING0|LEFT, 2);
}
#if defined(LUA_INPUTS)
else if (aidx <= MIXSRC_LAST_LUA) {
div_t qr = div((uint16_t)(aidx-MIXSRC_FIRST_LUA), MAX_SCRIPT_OUTPUTS);
#if defined(LUA_MODEL_SCRIPTS)
if (inverted) {
lcdDrawChar(x, y, '!');
x += 2;
}
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
lcdDrawChar(x+2, y+1, '1'+qr.quot, TINSIZE);
lcdDrawFilledRect(x, y, 7, 7, 0);
lcdDrawSizedText(x+8, y, scriptInputsOutputs[qr.quot].outputs[qr.rem].name, att & STREXPANDED ? 9 : 4, att);
}
else
#endif
{
drawStringWithIndex(x, y, "LUA", qr.quot+1, att);
lcdDrawChar(lcdLastRightPos, y, 'a' + qr.rem, att);
}
}
#endif
else {
const char* s = getSourceString(idx);
if (idx >= MIXSRC_FIRST_TELEM && idx <= MIXSRC_LAST_TELEM)
s += strlen(STR_CHAR_TELEMETRY);
lcdDrawText(x, y, s, att);
}
}
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
{
lcdDrawText(x, y, getAnalogShortLabel(idx), att);
-1
View File
@@ -116,7 +116,6 @@ void lcdDraw8bitsNumber(coord_t x, coord_t y, int8_t val);
void drawModelName(coord_t x, coord_t y, char * name, uint8_t id, LcdFlags att);
#if !defined(BOOT) // TODO not here ...
void drawSwitch(coord_t x, coord_t y, swsrc_t swtch, LcdFlags att=0, bool autoBold = true);
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att=0);
#endif
void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att=0);
+14 -14
View File
@@ -21,7 +21,7 @@
#include "opentx.h"
#define EXPO_ONE_2ND_COLUMN (7*FW+3*FW+2)
#define EXPO_ONE_2ND_COLUMN (6*FW+1)
int expoFn(int x)
{
@@ -91,39 +91,39 @@ void menuModelExpoOne(event_t event)
switch (i) {
case EXPO_FIELD_INPUT_NAME:
editSingleName(EXPO_ONE_2ND_COLUMN - LEN_INPUT_NAME * FW, y,
editSingleName(EXPO_ONE_2ND_COLUMN, y,
STR_INPUTNAME, g_model.inputNames[ed->chn],
LEN_INPUT_NAME, event, (attr != 0), old_editMode);
break;
case EXPO_FIELD_LINE_NAME:
editSingleName(EXPO_ONE_2ND_COLUMN - LEN_EXPOMIX_NAME * FW, y,
editSingleName(EXPO_ONE_2ND_COLUMN, y,
STR_EXPONAME, ed->name, LEN_EXPOMIX_NAME, event,
(attr != 0), old_editMode);
break;
case EXPO_FIELD_SOURCE:
lcdDrawTextAlignedLeft(y, STR_SOURCE);
drawSource(EXPO_ONE_2ND_COLUMN, y, ed->srcRaw, RIGHT|STREXPANDED|attr);
drawSource(EXPO_ONE_2ND_COLUMN, y, ed->srcRaw, STREXPANDED|attr);
if (attr)
ed->srcRaw = checkIncDec(event, ed->srcRaw, INPUTSRC_FIRST, INPUTSRC_LAST, EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isSourceAvailableInInputs);
break;
case EXPO_FIELD_SCALE:
lcdDrawTextAlignedLeft(y, STR_SCALE);
drawSensorCustomValue(EXPO_ONE_2ND_COLUMN, y, (abs(ed->srcRaw) - MIXSRC_FIRST_TELEM)/3, convertTelemValue(abs(ed->srcRaw) - MIXSRC_FIRST_TELEM + 1, ed->scale), RIGHT | attr);
drawSensorCustomValue(EXPO_ONE_2ND_COLUMN, y, (abs(ed->srcRaw) - MIXSRC_FIRST_TELEM)/3, convertTelemValue(abs(ed->srcRaw) - MIXSRC_FIRST_TELEM + 1, ed->scale), attr);
if (attr)
ed->scale = checkIncDec(event, ed->scale, 0, maxTelemValue(abs(ed->srcRaw) - MIXSRC_FIRST_TELEM + 1), EE_MODEL);
break;
case EXPO_FIELD_WEIGHT:
lcdDrawTextAlignedLeft(y, STR_WEIGHT);
ed->weight = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->weight, -100, 100, RIGHT | attr, 0, event);
ed->weight = editSrcVarFieldValue(EXPO_ONE_2ND_COLUMN, y, STR_WEIGHT, ed->weight,
-100, 100, attr, event, isSourceAvailableInInputs, INPUTSRC_FIRST);
break;
case EXPO_FIELD_OFFSET:
lcdDrawTextAlignedLeft(y, STR_OFFSET);
ed->offset = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->offset, -100, 100, RIGHT | attr, 0, event);
ed->offset = editSrcVarFieldValue(EXPO_ONE_2ND_COLUMN, y, STR_OFFSET, ed->offset,
-100, 100, attr, event, isSourceAvailableInInputs, INPUTSRC_FIRST);
break;
case EXPO_FIELD_CURVE_LABEL:
@@ -131,7 +131,7 @@ void menuModelExpoOne(event_t event)
break;
case EXPO_FIELD_CURVE:
editCurveRef(EXPO_ONE_2ND_COLUMN, y, ed->curve, event, RIGHT | attr);
editCurveRef(FW + 1, y, ed->curve, event, attr, isSourceAvailableInInputs, INPUTSRC_FIRST);
break;
#if defined(FLIGHT_MODES)
@@ -140,23 +140,23 @@ void menuModelExpoOne(event_t event)
break;
case EXPO_FIELD_FLIGHT_MODES:
ed->flightModes = editFlightModes(EXPO_ONE_2ND_COLUMN-9*FW+1, y, event, ed->flightModes, attr);
ed->flightModes = editFlightModes(EXPO_ONE_2ND_COLUMN-5*FW-2, y, event, ed->flightModes, attr);
break;
#endif
case EXPO_FIELD_SWITCH:
ed->swtch = editSwitch(EXPO_ONE_2ND_COLUMN, y, ed->swtch, RIGHT | attr, event);
ed->swtch = editSwitch(EXPO_ONE_2ND_COLUMN, y, ed->swtch, attr, event);
break;
case EXPO_FIELD_SIDE:
ed->mode = 4 - editChoice(EXPO_ONE_2ND_COLUMN, y, STR_SIDE, STR_VCURVEFUNC, 4-ed->mode, 1, 3, RIGHT | attr, event);
ed->mode = 4 - editChoice(EXPO_ONE_2ND_COLUMN, y, STR_SIDE, STR_VCURVEFUNC, 4-ed->mode, 1, 3, attr, event);
break;
case EXPO_FIELD_TRIM:
lcdDrawTextAlignedLeft(y, STR_TRIM);
{
const char* trim_str = getTrimSourceLabel(abs(ed->srcRaw), ed->trimSource);
LcdFlags flags = RIGHT | (menuHorizontalPosition==0 ? attr : 0);
LcdFlags flags = (menuHorizontalPosition==0 ? attr : 0);
lcdDrawText(EXPO_ONE_2ND_COLUMN, y, trim_str, flags);
if (attr) {
+10 -13
View File
@@ -43,13 +43,15 @@ enum MixFields {
extern uint8_t FM_ROW(uint8_t);
extern int32_t getSourceNumFieldValue(int16_t val, int16_t min, int16_t max);
void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
{
const int gaugeWidth = 33;
const int gaugeHeight = 6;
int offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode);
int weight = GET_GVAR(MD_WEIGHT(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode);
int offset = getSourceNumFieldValue(md->offset, MIX_OFFSET_MIN, MIX_OFFSET_MAX) / 10;
int weight = getSourceNumFieldValue(md->weight, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX) / 10;
int barMin = offset - weight;
int barMax = offset + weight;
if (y > 15) {
@@ -137,20 +139,15 @@ void menuModelMixOne(event_t event)
break;
case MIX_FIELD_WEIGHT:
lcdDrawTextAlignedLeft(y, STR_WEIGHT);
gvarWeightItem(MIXES_2ND_COLUMN, y, md2, attr|LEFT, event);
md2->weight = editSrcVarFieldValue(MIXES_2ND_COLUMN, y, STR_WEIGHT, md2->weight,
MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, attr, event, isSourceAvailable, 1);
break;
case MIX_FIELD_OFFSET:
{
lcdDrawTextAlignedLeft(y, STR_OFFSET);
u_int8int16_t offset;
MD_OFFSET_TO_UNION(md2, offset);
offset.word = GVAR_MENU_ITEM(MIXES_2ND_COLUMN, y, offset.word, MIX_OFFSET_MIN, MIX_OFFSET_MAX, attr|LEFT, 0, event);
MD_UNION_TO_OFFSET(offset, md2);
drawOffsetBar(MIXES_2ND_COLUMN+22, y, md2);
md2->offset = editSrcVarFieldValue(MIXES_2ND_COLUMN, y, STR_OFFSET, md2->offset,
MIX_OFFSET_MIN, MIX_OFFSET_MAX, attr, event, isSourceAvailable, 1);
drawOffsetBar(LCD_W - 33, y, md2);
break;
}
case MIX_FIELD_TRIM:
lcdDrawTextAlignedLeft(y, STR_TRIM);
@@ -162,7 +159,7 @@ void menuModelMixOne(event_t event)
lcdDrawTextAlignedLeft(y, STR_CURVE);
s_currSrcRaw = md2->srcRaw;
s_currScale = 0;
editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, event, attr);
editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, event, attr, isSourceAvailable, 1);
break;
#if defined(FLIGHT_MODES)
+24
View File
@@ -162,6 +162,30 @@ void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr)
drawSlider(x, y, 5*FW - 1, value, max, attr);
}
uint16_t editSrcVarFieldValue(coord_t x, coord_t y, const char* title, uint16_t value,
int16_t min, int16_t max, LcdFlags attr, event_t event,
IsValueAvailable isValueAvailable, int16_t sourceMin)
{
if (title)
lcdDrawTextAlignedLeft(y, title);
SourceNumVal v;
v.rawValue = value;
if (v.isSource) {
drawSource(x, y, v.value, attr);
if (attr & (~RIGHT)) {
value = checkIncDec(event, value, sourceMin, MIXSRC_LAST,
EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_VALUE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isValueAvailable);
}
} else {
lcdDrawNumber(x, y, v.value, attr);
if (attr & (~RIGHT)) {
value = checkIncDec(event, value, min, max,
EE_MODEL|INCDEC_SOURCE_VALUE|NO_INCDEC_MARKS|(sourceMin == INPUTSRC_FIRST ? INCDEC_SOURCE_NOINPUTS : 0));
}
}
return value;
}
#if defined(GVARS)
void drawGVarValue(coord_t x, coord_t y, uint8_t gvar, gvar_t value, LcdFlags flags)
{
+6 -3
View File
@@ -91,6 +91,10 @@ uint8_t editCheckBox(uint8_t value, coord_t x, coord_t y, const char *label,
swsrc_t editSwitch(coord_t x, coord_t y, swsrc_t value, LcdFlags attr,
event_t event);
uint16_t editSrcVarFieldValue(coord_t x, coord_t y, const char* title, uint16_t value,
int16_t min, int16_t max, LcdFlags attr, event_t event,
IsValueAvailable isValueAvailable, int16_t sourceMin);
#if defined(GVARS)
void drawGVarValue(coord_t x, coord_t y, uint8_t gvar, gvar_t value,
LcdFlags flags = 0);
@@ -117,9 +121,8 @@ int16_t editGVarFieldValue(coord_t x, coord_t y, int16_t value, int16_t min,
#endif
void gvarWeightItem(coord_t x, coord_t y, MixData * md, LcdFlags attr, event_t event);
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags);
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags,
IsValueAvailable isValueAvailable, int16_t sourceMin);
extern uint8_t editNameCursorPos;
-45
View File
@@ -632,51 +632,6 @@ void drawMainControlLabel(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
lcdDrawSizedText(x, y, getMainControlLabel(idx), UINT8_MAX, att);
}
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att)
{
uint16_t aidx = abs(idx);
bool inverted = idx < 0;
if (aidx == MIXSRC_NONE) {
lcdDrawText(x, y, STR_EMPTY, att);
}
else if (aidx <= MIXSRC_LAST_INPUT) {
if (inverted) {
lcdDrawChar(x, y, '!');
x += 2;
}
lcdDrawChar(x+2, y+1, CHR_INPUT, TINSIZE);
lcdDrawFilledRect(x, y, 7, 7);
if (ZEXIST(g_model.inputNames[aidx-MIXSRC_FIRST_INPUT]))
lcdDrawSizedText(x+8, y, g_model.inputNames[aidx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, att);
else
lcdDrawNumber(x+8, y, aidx, att|LEADING0|LEFT, 2);
}
else if (aidx <= MIXSRC_LAST_LUA) {
div_t qr = div((uint16_t)(aidx-MIXSRC_FIRST_LUA), MAX_SCRIPT_OUTPUTS);
#if defined(LUA_MODEL_SCRIPTS)
if (inverted) {
lcdDrawChar(x, y, '!');
x += 2;
}
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
lcdDrawChar(x+2, y+1, '1'+qr.quot, TINSIZE);
lcdDrawFilledRect(x, y, 7, 7);
lcdDrawSizedText(x+8, y, scriptInputsOutputs[qr.quot].outputs[qr.rem].name, att & STREXPANDED ? 9 : 4, att);
}
else
#endif
{
drawStringWithIndex(x, y, "LUA", qr.quot+1, att);
lcdDrawChar(lcdLastRightPos, y, 'a'+qr.rem, att);
}
}
else {
lcdDrawText(x, y, getSourceString(idx), att);
}
}
void putsChnLetter(coord_t x, coord_t y, uint8_t idx, LcdFlags att)
{
lcdDrawText(x, y, getAnalogShortLabel(idx), att);
-1
View File
@@ -114,7 +114,6 @@ void lcdDrawNumber(coord_t x, coord_t y, int32_t val, LcdFlags mode=0);
void drawModelName(coord_t x, coord_t y, char *name, uint8_t id, LcdFlags att);
void drawSwitch(coord_t x, coord_t y, int32_t swtch, LcdFlags att=0, bool autoBold = true);
void drawMainControlLabel(coord_t x, coord_t y, uint8_t idx, LcdFlags att=0);
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att=0);
void drawCurveName(coord_t x, coord_t y, int8_t idx, LcdFlags att=0);
void drawTimerMode(coord_t x, coord_t y, swsrc_t mode, LcdFlags att=0);
+5 -5
View File
@@ -119,18 +119,18 @@ void menuModelExpoOne(event_t event)
break;
case EXPO_FIELD_WEIGHT:
lcdDrawTextAlignedLeft(y, STR_WEIGHT);
ed->weight = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->weight, -100, 100, LEFT|attr, 0, event);
ed->weight = editSrcVarFieldValue(EXPO_ONE_2ND_COLUMN, y, STR_WEIGHT, ed->weight,
-100, 100, attr, event, isSourceAvailableInInputs, INPUTSRC_FIRST);
break;
case EXPO_FIELD_OFFSET:
lcdDrawTextAlignedLeft(y, STR_OFFSET);
ed->offset = GVAR_MENU_ITEM(EXPO_ONE_2ND_COLUMN, y, ed->offset, -100, 100, LEFT|attr, 0, event);
ed->offset = editSrcVarFieldValue(EXPO_ONE_2ND_COLUMN, y, STR_OFFSET, ed->offset,
-100, 100, attr, event, isSourceAvailableInInputs, INPUTSRC_FIRST);
break;
case EXPO_FIELD_CURVE:
lcdDrawTextAlignedLeft(y, STR_CURVE);
editCurveRef(EXPO_ONE_2ND_COLUMN, y, ed->curve, event, attr);
editCurveRef(EXPO_ONE_2ND_COLUMN, y, ed->curve, event, attr, isSourceAvailableInInputs, INPUTSRC_FIRST);
break;
#if defined(FLIGHT_MODES)
+9 -12
View File
@@ -43,13 +43,15 @@ enum MixFields {
extern uint8_t FM_ROW(uint8_t);
extern int32_t getSourceNumFieldValue(int16_t val, int16_t min, int16_t max);
void drawOffsetBar(uint8_t x, uint8_t y, MixData * md)
{
const int gaugeWidth = 33;
const int gaugeHeight = 6;
int offset = GET_GVAR(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode);
int weight = GET_GVAR(MD_WEIGHT(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode);
int offset = getSourceNumFieldValue(md->offset, MIX_OFFSET_MIN, MIX_OFFSET_MAX) / 10;
int weight = getSourceNumFieldValue(md->weight, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX) / 10;
int barMin = offset - weight;
int barMax = offset + weight;
if (y > 15) {
@@ -130,20 +132,15 @@ void menuModelMixOne(event_t event)
break;
case MIX_FIELD_WEIGHT:
lcdDrawTextAlignedLeft(y, STR_WEIGHT);
gvarWeightItem(MIXES_2ND_COLUMN, y, md2, attr|LEFT, event);
md2->weight = editSrcVarFieldValue(MIXES_2ND_COLUMN, y, STR_WEIGHT, md2->weight,
MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, attr, event, isSourceAvailable, 1);
break;
case MIX_FIELD_OFFSET:
{
lcdDrawTextAlignedLeft(y, STR_OFFSET);
u_int8int16_t offset;
MD_OFFSET_TO_UNION(md2, offset);
offset.word = GVAR_MENU_ITEM(MIXES_2ND_COLUMN, y, offset.word, MIX_OFFSET_MIN, MIX_OFFSET_MAX, attr|LEFT, 0, event);
MD_UNION_TO_OFFSET(offset, md2);
md2->offset = editSrcVarFieldValue(MIXES_2ND_COLUMN, y, STR_OFFSET, md2->offset,
MIX_OFFSET_MIN, MIX_OFFSET_MAX, attr, event, isSourceAvailable, 1);
drawOffsetBar(MIXES_2ND_COLUMN+35, y, md2);
break;
}
case MIX_FIELD_TRIM:
lcdDrawTextAlignedLeft(y, STR_TRIM);
@@ -157,7 +154,7 @@ void menuModelMixOne(event_t event)
lcdDrawTextAlignedLeft(y, STR_CURVE);
s_currSrcRaw = md2->srcRaw;
s_currScale = 0;
editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, event, attr);
editCurveRef(MIXES_2ND_COLUMN, y, md2->curve, event, attr, isSourceAvailable, 1);
break;
#if defined(FLIGHT_MODES)
+24
View File
@@ -120,6 +120,30 @@ void drawSlider(coord_t x, coord_t y, uint8_t value, uint8_t max, uint8_t attr)
if (attr && (!(attr & BLINK) || !BLINK_ON_PHASE)) lcdDrawFilledRect(x, y, 5*FW-1, FH-1);
}
uint16_t editSrcVarFieldValue(coord_t x, coord_t y, const char* title, uint16_t value,
int16_t min, int16_t max, LcdFlags attr, event_t event,
IsValueAvailable isValueAvailable, int16_t sourceMin)
{
if (title)
lcdDrawTextAlignedLeft(y, title);
SourceNumVal v;
v.rawValue = value;
if (v.isSource) {
drawSource(x, y, v.value, attr);
if (attr & (~RIGHT)) {
value = checkIncDec(event, value, sourceMin,
MIXSRC_LAST, EE_MODEL|INCDEC_SOURCE|INCDEC_SOURCE_VALUE|INCDEC_SOURCE_INVERT|NO_INCDEC_MARKS, isValueAvailable);
}
} else {
lcdDrawNumber(x, y, v.value, attr);
if (attr & (~RIGHT)) {
value = checkIncDec(event, value, min, max,
EE_MODEL|INCDEC_SOURCE_VALUE|NO_INCDEC_MARKS|(sourceMin == INPUTSRC_FIRST ? INCDEC_SOURCE_NOINPUTS : 0));
}
}
return value;
}
#if defined(GVARS)
void drawGVarValue(coord_t x, coord_t y, uint8_t gvar, gvar_t value, LcdFlags flags)
{
+1
View File
@@ -111,6 +111,7 @@ set(GUI_SRC
radio_tools.cpp
radio_trainer.cpp
radio_version.cpp
source_numberedit.cpp
)
macro(add_gui_src src)
+5 -1
View File
@@ -243,7 +243,11 @@ void Curve::clearPoints()
update();
}
void Curve::update() { base.update(); }
void Curve::update()
{
base.update();
updatePosition();
}
void Curve::checkEvents()
{
+39 -24
View File
@@ -22,6 +22,7 @@
#include "curve_param.h"
#include "gvar_numberedit.h"
#include "source_numberedit.h"
#include "model_curves.h"
#include "opentx.h"
@@ -37,21 +38,12 @@ void CurveParam::LongPressHandler(void* data)
}
}
void CurveParam::value_changed(lv_event_t* e)
{
auto obj = lv_event_get_target(e);
auto param = (CurveParam*)lv_obj_get_user_data(obj);
if (!param) return;
param->update();
}
class CurveChoice : public Choice
{
public:
CurveChoice(Window* parent, CurveRef* ref, std::function<void(int32_t)> setRefValue, std::function<void(void)> refreshView) :
Choice(parent, rect_t{}, -MAX_CURVES, MAX_CURVES, GET_DEFAULT(ref->value), setRefValue),
ref(ref), refreshView(refreshView)
CurveChoice(Window* parent, std::function<int()> getRefValue, std::function<void(int32_t)> setRefValue, std::function<void(void)> refreshView) :
Choice(parent, rect_t{}, -MAX_CURVES, MAX_CURVES, getRefValue, setRefValue),
refreshView(std::move(refreshView))
{
setTextHandler([](int value) { return getCurveString(value); });
}
@@ -59,21 +51,21 @@ class CurveChoice : public Choice
bool onLongPress() override
{
if (modelCurvesEnabled()) {
if (ref->value) {
ModelCurvesPage::pushEditCurve(abs(ref->value) - 1, refreshView);
if (_getValue()) {
ModelCurvesPage::pushEditCurve(abs(_getValue()) - 1, refreshView);
}
}
return true;
}
protected:
CurveRef* ref;
std::function<void(void)> refreshView;
};
CurveParam::CurveParam(Window* parent, const rect_t& rect, CurveRef* ref,
std::function<void(int32_t)> setRefValue, std::function<void(void)> refreshView) :
Window(parent, rect), ref(ref)
std::function<void(int32_t)> setRefValue, int16_t sourceMin,
std::function<void(void)> refreshView) :
Window(parent, rect), ref(ref), refreshView(std::move(refreshView))
{
padAll(PAD_TINY);
lv_obj_set_flex_flow(lvobj, LV_FLEX_FLOW_ROW_WRAP);
@@ -85,23 +77,42 @@ CurveParam::CurveParam(Window* parent, const rect_t& rect, CurveRef* ref,
ref->type = newValue;
ref->value = 0;
SET_DIRTY();
lv_event_send(lvobj, LV_EVENT_VALUE_CHANGED, nullptr);
update();
});
lv_obj_add_event_cb(lvobj, CurveParam::value_changed, LV_EVENT_VALUE_CHANGED,
nullptr);
// CURVE_REF_DIFF
// CURVE_REF_EXPO
auto gv = new GVarNumberEdit(this, -100, 100, GET_DEFAULT(ref->value), setRefValue);
auto gv = new SourceNumberEdit(this, -100, 100, GET_DEFAULT(ref->value), setRefValue, sourceMin);
gv->setSuffix("%");
value_edit = gv;
// CURVE_REF_FUNC
func_choice = new Choice(this, rect_t{}, STR_VCURVEFUNC, 0, CURVE_BASE - 1,
GET_DEFAULT(ref->value), setRefValue);
[=]() {
SourceNumVal v;
v.rawValue = ref->value;
return v.value;
},
[=](int32_t newValue) {
SourceNumVal v;
v.isSource = false;
v.value = newValue;
setRefValue(v.rawValue);
});
// CURVE_REF_CUSTOM
cust_choice = new CurveChoice(this, ref, setRefValue, refreshView);
cust_choice = new CurveChoice(this,
[=]() {
SourceNumVal v;
v.rawValue = ref->value;
return v.value;
},
[=](int32_t newValue) {
SourceNumVal v;
v.isSource = false;
v.value = newValue;
setRefValue(v.rawValue);
}, refreshView);
update();
}
@@ -117,14 +128,17 @@ void CurveParam::update()
switch (ref->type) {
case CURVE_REF_DIFF:
case CURVE_REF_EXPO:
value_edit->update();
act_field = value_edit;
break;
case CURVE_REF_FUNC:
func_choice->update();
act_field = func_choice;
break;
case CURVE_REF_CUSTOM:
cust_choice->update();
act_field = cust_choice;
break;
@@ -133,10 +147,11 @@ void CurveParam::update()
}
act_field->show();
if (refreshView)
refreshView();
auto act_obj = act_field->getLvObj();
if (has_focus) {
lv_group_focus_obj(act_obj);
}
lv_event_send(act_obj, LV_EVENT_VALUE_CHANGED, nullptr);
}
+16 -10
View File
@@ -24,24 +24,30 @@
#include "window.h"
struct CurveRef;
class Choice;
class SourceNumberEdit;
class CurveParam : public Window
{
public:
CurveParam(Window* parent, const rect_t& rect, CurveRef* ref,
std::function<void(int32_t)> setRefValue,
int16_t sourceMin,
std::function<void(void)> refreshView = nullptr);
protected:
// Curve
CurveRef* ref;
// Controls
Window* value_edit;
Window* func_choice;
Window* cust_choice;
SourceNumberEdit* value_edit;
Choice* func_choice;
Choice* cust_choice;
Window* act_field = nullptr;
void update();
static void value_changed(lv_event_t* e);
static void LongPressHandler(void* data);
std::function<void(void)> refreshView;
public:
CurveParam(Window* parent, const rect_t& rect, CurveRef* ref,
std::function<void(int32_t)> setRefValue,
std::function<void(void)> refreshView = nullptr);
void update();
static void LongPressHandler(void* data);
};
+59 -15
View File
@@ -24,6 +24,7 @@
#include "curve_param.h"
#include "curveedit.h"
#include "gvar_numberedit.h"
#include "source_numberedit.h"
#include "input_edit_adv.h"
#include "input_source.h"
#include "opentx.h"
@@ -106,23 +107,23 @@ void InputEditWindow::buildBody(Window* form)
line = form->newLine(grid);
new StaticText(line, rect_t{}, STR_WEIGHT);
auto gvar =
new GVarNumberEdit(line, -100, 100, GET_DEFAULT(input->weight),
[=](int32_t newValue) {
input->weight = newValue;
preview->update();
SET_DIRTY();
});
new SourceNumberEdit(line, -100, 100, GET_DEFAULT(input->weight),
[=](int32_t newValue) {
input->weight = newValue;
preview->update();
SET_DIRTY();
}, INPUTSRC_FIRST);
gvar->setSuffix("%");
// Offset
line = form->newLine(grid);
new StaticText(line, rect_t{}, STR_OFFSET);
gvar = new GVarNumberEdit(line, -100, 100,
GET_DEFAULT(input->offset), [=](int32_t newValue) {
input->offset = newValue;
preview->update();
SET_DIRTY();
});
gvar = new SourceNumberEdit(line, -100, 100,
GET_DEFAULT(input->offset), [=](int32_t newValue) {
input->offset = newValue;
preview->update();
SET_DIRTY();
}, INPUTSRC_FIRST);
gvar->setSuffix("%");
// Switch
@@ -138,11 +139,13 @@ void InputEditWindow::buildBody(Window* form)
new CurveParam(line, rect_t{}, &input->curve,
[=](int32_t newValue) {
input->curve.value = newValue;
preview->update();
if (preview)
preview->update();
SET_DIRTY();
},
}, INPUTSRC_FIRST,
[=]() {
preview->update();
if (preview)
preview->update();
});
lv_obj_set_style_grid_cell_x_align(param->getLvObj(), LV_GRID_ALIGN_STRETCH,
0);
@@ -164,3 +167,44 @@ void InputEditWindow::deleteLater(bool detach, bool trash)
Page::deleteLater(detach, trash);
}
}
void InputEditWindow::checkEvents()
{
ExpoData* input = expoAddress(index);
bool updatePreview = false;
getvalue_t val;
SourceNumVal v;
v.rawValue = input->weight;
if (v.isSource) {
val = getValue(v.value);
if (val != lastWeightVal) {
lastWeightVal = val;
updatePreview = true;
}
}
v.rawValue = input->offset;
if (v.isSource) {
val = getValue(v.value);
if (val != lastOffsetVal) {
lastOffsetVal = val;
updatePreview = true;
}
}
v.rawValue = input->curve.value;
if (v.isSource) {
val = getValue(v.value);
if (val != lastCurveVal) {
lastCurveVal = val;
updatePreview = true;
}
}
if (updatePreview)
preview->update();
Page::checkEvents();
}
+5 -1
View File
@@ -38,9 +38,13 @@ class InputEditWindow : public Page
protected:
uint8_t input;
uint8_t index;
Curve* preview;
Curve* preview = nullptr;
getvalue_t lastWeightVal = 0;
getvalue_t lastOffsetVal = 0;
getvalue_t lastCurveVal = 0;
void buildBody(Window *window);
void checkEvents() override;
void deleteLater(bool detach = true, bool trash = true) override;
};
+18 -1
View File
@@ -71,6 +71,7 @@ InputMixButtonBase::InputMixButtonBase(Window* parent, uint8_t index) :
weight = lv_label_create(lvobj);
lv_obj_set_pos(weight, WGT_X, WGT_Y);
lv_obj_set_size(weight, WGT_W, WGT_H);
etx_font(weight, FONT_XS_INDEX, LV_STATE_USER_1);
source = lv_label_create(lvobj);
lv_obj_set_pos(source, SRC_X, SRC_Y);
@@ -79,6 +80,7 @@ InputMixButtonBase::InputMixButtonBase(Window* parent, uint8_t index) :
opts = lv_label_create(lvobj);
lv_obj_set_pos(opts, OPT_X, OPT_Y);
lv_obj_set_size(opts, OPT_W, OPT_H);
etx_font(opts, FONT_XS_INDEX, LV_STATE_USER_1);
}
InputMixButtonBase::~InputMixButtonBase()
@@ -89,7 +91,12 @@ InputMixButtonBase::~InputMixButtonBase()
void InputMixButtonBase::setWeight(gvar_t value, gvar_t min, gvar_t max)
{
char s[32];
getValueOrGVarString(s, sizeof(s), value, min, max, 0, "%");
getValueOrSrcVarString(s, sizeof(s), value, min, max, 0, "%");
if (getTextWidth(s, 0, FONT(STD)) > WGT_W)
lv_obj_add_state(weight, LV_STATE_USER_1);
else
lv_obj_clear_state(weight, LV_STATE_USER_1);
lv_label_set_text(weight, s);
}
@@ -99,6 +106,16 @@ void InputMixButtonBase::setSource(mixsrc_t idx)
lv_label_set_text(source, s);
}
void InputMixButtonBase::setOpts(const char* s)
{
if (getTextWidth(s, 0, FONT(STD)) > OPT_W)
lv_obj_add_state(opts, LV_STATE_USER_1);
else
lv_obj_clear_state(opts, LV_STATE_USER_1);
lv_label_set_text(opts, s);
}
void InputMixButtonBase::setFlightModes(uint16_t modes)
{
if (!modelFMEnabled()) return;
+3 -2
View File
@@ -54,6 +54,7 @@ class InputMixButtonBase : public ListLineButton
void setWeight(gvar_t value, gvar_t min, gvar_t max);
void setSource(mixsrc_t idx);
void setOpts(const char* s);
void setFlightModes(uint16_t modes);
virtual void updatePos(coord_t x, coord_t y) = 0;
@@ -66,7 +67,7 @@ class InputMixButtonBase : public ListLineButton
static LAYOUT_VAL(BTN_W, 389, 229)
static constexpr coord_t WGT_X = PAD_TINY;
static constexpr coord_t WGT_Y = PAD_TINY;
static LAYOUT_VAL(WGT_W, 43, 43)
static LAYOUT_VAL(WGT_W, 50, 50)
static LAYOUT_VAL(WGT_H, 21, 21)
static constexpr coord_t SRC_X = WGT_X + WGT_W + PAD_TINY;
static constexpr coord_t SRC_Y = WGT_Y;
@@ -74,7 +75,7 @@ class InputMixButtonBase : public ListLineButton
static constexpr coord_t SRC_H = WGT_H;
static constexpr coord_t OPT_X = SRC_X + SRC_W + PAD_TINY;
static constexpr coord_t OPT_Y = WGT_Y;
static LAYOUT_VAL(OPT_W, 171, 106)
static LAYOUT_VAL(OPT_W, 164, 99)
static constexpr coord_t OPT_H = WGT_H;
static LAYOUT_VAL(LN_X, 73, 73)
static LAYOUT_VAL(FM_X, (OPT_X + OPT_W + PAD_TINY), 12)
+8 -7
View File
@@ -22,8 +22,9 @@
#include "mixer_edit.h"
#include "channel_bar.h"
#include "curve_param.h"
#include "gvar_numberedit.h"
#include "source_numberedit.h"
#include "curve_param.h"
#include "mixer_edit_adv.h"
#include "mixes.h"
#include "opentx.h"
@@ -108,14 +109,14 @@ void MixEditWindow::buildBody(Window *form)
// Weight
line = form->newLine(grid);
new StaticText(line, rect_t{}, STR_WEIGHT);
auto gvar = new GVarNumberEdit(line, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX,
GET_SET_DEFAULT(mix->weight));
gvar->setSuffix("%");
auto svar = new SourceNumberEdit(line, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX,
GET_SET_DEFAULT(mix->weight), 0);
svar->setSuffix("%");
// Offset
new StaticText(line, rect_t{}, STR_OFFSET);
gvar = new GVarNumberEdit(line, MIX_OFFSET_MIN, MIX_OFFSET_MAX,
GET_SET_DEFAULT(mix->offset));
auto gvar = new SourceNumberEdit(line, MIX_OFFSET_MIN, MIX_OFFSET_MAX,
GET_SET_DEFAULT(mix->offset), 0);
gvar->setSuffix("%");
// Switch
@@ -126,7 +127,7 @@ void MixEditWindow::buildBody(Window *form)
// Curve
new StaticText(line, rect_t{}, STR_CURVE);
new CurveParam(line, rect_t{}, &mix->curve, SET_DEFAULT(mix->curve.value));
new CurveParam(line, rect_t{}, &mix->curve, SET_DEFAULT(mix->curve.value), 0);
line = form->newLine(grid);
line->padAll(PAD_LARGE);
+21 -21
View File
@@ -129,29 +129,29 @@ class InputLineButton : public InputMixButtonBase
}
}
if (line.swtch || line.curve.value) {
if (line.swtch) {
char* sw_pos = getSwitchPositionName(line.swtch);
int cnt = lv_snprintf(s, maxlen, "%s ", sw_pos);
if ((size_t)cnt >= maxlen)
maxlen = 0;
else {
maxlen -= cnt;
s += cnt;
}
}
if (line.curve.value != 0) {
getCurveRefString(s, maxlen, line.curve);
int cnt = strnlen(s, maxlen);
if ((size_t)cnt >= maxlen)
maxlen = 0;
else {
maxlen -= cnt;
s += cnt;
}
if (line.swtch) {
char* sw_pos = getSwitchPositionName(line.swtch);
int cnt = lv_snprintf(s, maxlen, "%s ", sw_pos);
if ((size_t)cnt >= maxlen)
maxlen = 0;
else {
maxlen -= cnt;
s += cnt;
}
}
lv_label_set_text_fmt(opts, "%.*s", (int)sizeof(tmp_str), tmp_str);
if (line.curve.value != 0) {
getCurveRefString(s, maxlen, line.curve);
int cnt = strnlen(s, maxlen);
if ((size_t)cnt >= maxlen)
maxlen = 0;
else {
maxlen -= cnt;
s += cnt;
}
}
setOpts(s);
setFlightModes(line.flightModes);
}
+12 -19
View File
@@ -98,32 +98,25 @@ class MixLineButton : public InputMixButtonBase
setSource(line.srcRaw);
char tmp_str[64];
size_t maxlen = sizeof(tmp_str);
char *s = tmp_str;
*s = '\0';
if (line.name[0]) {
int cnt = lv_snprintf(s, maxlen, "%.*s ", (int)sizeof(line.name), line.name);
if ((size_t)cnt >= maxlen) maxlen = 0;
else { maxlen -= cnt; s += cnt; }
s = strAppend(s, line.name, LEN_EXPOMIX_NAME);
}
if (line.swtch || line.curve.value) {
if (line.swtch) {
char* sw_pos = getSwitchPositionName(line.swtch);
int cnt = lv_snprintf(s, maxlen, "%s ", sw_pos);
if ((size_t)cnt >= maxlen) maxlen = 0;
else { maxlen -= cnt; s += cnt; }
}
if (line.curve.value != 0) {
getCurveRefString(s, maxlen, line.curve);
int cnt = strnlen(s, maxlen);
if ((size_t)cnt >= maxlen) maxlen = 0;
else { maxlen -= cnt; s += cnt; }
}
if (line.swtch) {
if (tmp_str[0]) s = strAppend(s, " ");
char* sw_pos = getSwitchPositionName(line.swtch);
s = strAppend(s, sw_pos);
}
lv_label_set_text_fmt(opts, "%.*s", (int)sizeof(tmp_str), tmp_str);
if (line.curve.value != 0) {
if (tmp_str[0]) s = strAppend(s, " ");
getCurveRefString(s, sizeof(tmp_str) - (s - tmp_str), line.curve);
}
setOpts(tmp_str);
mplex->refresh();
@@ -0,0 +1,147 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* 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 "source_numberedit.h"
#include "opentx.h"
#include "sourcechoice.h"
void SourceNumberEdit::value_changed(lv_event_t* e)
{
auto obj = lv_event_get_target(e);
auto edit = (SourceNumberEdit*)lv_obj_get_user_data(obj);
if (!edit) return;
edit->update();
}
SourceNumberEdit::SourceNumberEdit(Window* parent,
int32_t vmin, int32_t vmax,
std::function<int32_t()> getValue,
std::function<void(int32_t)> setValue,
int16_t sourceMin,
LcdFlags textFlags, int32_t voffset,
int32_t vdefault) :
Window(parent, {0, 0, NUM_EDIT_W + SRC_BTN_W + PAD_TINY * 3, EdgeTxStyles::UI_ELEMENT_HEIGHT + PAD_TINY * 2}),
vmin(vmin),
vmax(vmax),
getValue(getValue),
setValue(setValue),
textFlags(textFlags),
voffset(voffset)
{
padAll(PAD_TINY);
lv_obj_set_flex_flow(lvobj, LV_FLEX_FLOW_ROW_WRAP);
lv_obj_set_style_flex_cross_place(lvobj, LV_FLEX_ALIGN_CENTER, 0);
lv_obj_set_size(lvobj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
// Source field
source_field = new SourceChoice(
this, {0, 0, NUM_EDIT_W, 0}, sourceMin, INPUTSRC_LAST,
[=]() {
SourceNumVal v;
v.rawValue = getValue();
return v.value;
},
[=](int newValue) {
SourceNumVal v = {(int16_t)newValue, true};
setValue(v.rawValue);
}, true);
num_field = new NumberEdit(
this, {0, 0, NUM_EDIT_W, 0}, vmin, vmax,
[=]() {
SourceNumVal v;
v.rawValue = getValue();
return v.value;
},
[=](int newValue) {
SourceNumVal v = {(int16_t)newValue, false};
setValue(v.rawValue);
},
textFlags);
num_field->setDefault(vdefault);
// The Source button
m_srcBtn = new TextButton(this, {NUM_EDIT_W + PAD_TINY, 0, SRC_BTN_W, 0}, "SRC", [=]() {
switchSourceMode();
return isSource();
});
m_srcBtn->check(isSource());
lv_obj_add_event_cb(lvobj, SourceNumberEdit::value_changed,
LV_EVENT_VALUE_CHANGED, nullptr);
// update field type based on value
update();
}
bool SourceNumberEdit::isSource()
{
SourceNumVal v;
v.rawValue = getValue();
return v.isSource;
}
void SourceNumberEdit::switchSourceMode()
{
SourceNumVal v;
v.rawValue = getValue();
v.isSource = !v.isSource;
// TODO: convert value???
v.value = 0;
setValue(v.rawValue);
// update field type based on value
update();
}
void SourceNumberEdit::setSuffix(std::string value)
{
num_field->setSuffix(value);
}
void SourceNumberEdit::update()
{
bool has_focus = act_field && act_field->hasFocus();
source_field->hide();
num_field->hide();
if (isSource()) {
// Source mode
act_field = source_field;
source_field->show();
source_field->update();
lv_event_send(source_field->getLvObj(), LV_EVENT_VALUE_CHANGED, nullptr);
} else {
// number edit mode
act_field = num_field;
num_field->show();
num_field->update();
}
m_srcBtn->check(isSource());
if (has_focus) {
lv_group_focus_obj(act_field->getLvObj());
}
}
@@ -0,0 +1,67 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* 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.
*/
#pragma once
#include "choice.h"
#include "form.h"
#include "numberedit.h"
class TextButton;
class SourceNumberEdit : public Window
{
public:
SourceNumberEdit(Window* parent, int32_t vmin, int32_t vmax,
std::function<int32_t()> getValue,
std::function<void(int32_t)> setValue,
int16_t sourceMin,
LcdFlags textFlags = 0, int32_t voffset = 0,
int32_t vdefault = 0);
void switchSourceMode();
void setSuffix(std::string value);
void setFastStep(int value) { num_field->setFastStep(value); }
void setAccelFactor(int value) { num_field->setAccelFactor(value); }
void update();
static LAYOUT_VAL(NUM_EDIT_W, 84, 74)
static LAYOUT_VAL(SRC_BTN_W, 38, 38)
protected:
Choice* source_field = nullptr;
NumberEdit* num_field = nullptr;
FormField* act_field = nullptr;
TextButton* m_srcBtn = nullptr;
int32_t vmin;
int32_t vmax;
std::function<int32_t()> getValue;
std::function<void(int32_t)> setValue;
LcdFlags textFlags;
int32_t voffset;
bool isSource();
static void value_changed(lv_event_t* e);
};
+87 -10
View File
@@ -292,14 +292,6 @@ void editName(coord_t x, coord_t y, char* name, uint8_t size, event_t event,
}
}
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, MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, attr, 0, event);
MD_UNION_TO_WEIGHT(weight, md);
}
void drawGVarName(coord_t x, coord_t y, int8_t idx, LcdFlags flags)
{
char s[8];
@@ -405,12 +397,12 @@ void drawCurveRef(coord_t x, coord_t y, CurveRef & curve, LcdFlags att)
switch (curve.type) {
case CURVE_REF_DIFF:
lcdDrawText(x, y, "D", att);
GVAR_MENU_ITEM(lcdNextPos, y, curve.value, -100, 100, LEFT|att, 0, 0);
editSrcVarFieldValue(lcdNextPos, y, nullptr, curve.value, -100, 100, LEFT|att, 0, 0, 0);
break;
case CURVE_REF_EXPO:
lcdDrawText(x, y, "E", att);
GVAR_MENU_ITEM(lcdNextPos, y, curve.value, -100, 100, LEFT|att, 0, 0);
editSrcVarFieldValue(lcdNextPos, y, nullptr, curve.value, -100, 100, LEFT|att, 0, 0, 0);
break;
case CURVE_REF_FUNC:
@@ -543,3 +535,88 @@ void runFatalErrorScreen(const char * message)
}
}
}
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att)
{
uint16_t aidx = abs(idx);
bool inverted = idx < 0;
if (aidx == MIXSRC_NONE) {
lcdDrawText(x, y, STR_EMPTY, att);
}
else if (aidx <= MIXSRC_LAST_INPUT) {
if (att & RIGHT) {
if (g_model.inputNames[aidx-MIXSRC_FIRST_INPUT][0])
lcdDrawSizedText(x, y, g_model.inputNames[aidx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, att);
else
lcdDrawNumber(x, y, aidx, att|LEADING0, 2);
x = lcdLastLeftPos - 5;
if (inverted)
lcdDrawChar(x-5, y, '-');
lcdDrawChar(x, y+1, CHR_INPUT, RIGHT|TINSIZE);
lcdDrawSolidFilledRect(x-1, y, 5, 7);
} else {
if (inverted) {
lcdDrawChar(x-1, y, '-');
x += 3;
}
lcdDrawChar(x+1, y+1, CHR_INPUT, TINSIZE);
lcdDrawSolidFilledRect(x, y, 5, 7);
if (g_model.inputNames[aidx-MIXSRC_FIRST_INPUT][0])
lcdDrawSizedText(x+6, y, g_model.inputNames[aidx-MIXSRC_FIRST_INPUT], LEN_INPUT_NAME, att);
else
lcdDrawNumber(x+6, y, aidx, att|LEADING0, 2);
}
}
#if defined(LUA_INPUTS)
else if (aidx <= MIXSRC_LAST_LUA) {
div_t qr = div((uint16_t)(aidx-MIXSRC_FIRST_LUA), MAX_SCRIPT_OUTPUTS);
if (att & RIGHT) {
#if defined(LUA_MODEL_SCRIPTS)
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
lcdDrawSizedText(x, y, scriptInputsOutputs[qr.quot].outputs[qr.rem].name, att & STREXPANDED ? 9 : 4, att);
x = lcdLastLeftPos - 4;
if (inverted)
lcdDrawChar(x-5, y, '-');
lcdDrawChar(x, y+1, '1'+qr.quot, TINSIZE);
lcdDrawFilledRect(x-1, y, 5, 7, SOLID);
}
else
#endif
{
lcdDrawChar(x, y, 'a' + qr.rem, att);
drawStringWithIndex(lcdLastLeftPos, y, "LUA", qr.quot+1, att);
#if defined(LUA_MODEL_SCRIPTS)
if (inverted)
lcdDrawChar(lcdLastLeftPos, y, '-', att);
#endif
}
} else {
#if defined(LUA_MODEL_SCRIPTS)
if (inverted) {
lcdDrawChar(x-1, y, '-');
x += 3;
}
if (qr.quot < MAX_SCRIPTS && qr.rem < scriptInputsOutputs[qr.quot].outputsCount) {
lcdDrawChar(x+1, y+1, '1'+qr.quot, TINSIZE);
lcdDrawFilledRect(x, y, 5, 7, SOLID);
lcdDrawSizedText(x+5, y, scriptInputsOutputs[qr.quot].outputs[qr.rem].name, att & STREXPANDED ? 9 : 4, att);
}
else
#endif
{
drawStringWithIndex(x, y, "LUA", qr.quot+1, att);
lcdDrawChar(lcdLastRightPos, y, 'a' + qr.rem, att);
}
}
}
#endif
else {
const char* s = getSourceString(idx);
#if LCD_W < 212
if (idx >= MIXSRC_FIRST_TELEM && idx <= MIXSRC_LAST_TELEM)
s += strlen(STR_CHAR_TELEMETRY);
#endif
lcdDrawText(x, y, s, att);
}
}
+2 -3
View File
@@ -19,8 +19,7 @@
* GNU General Public License for more details.
*/
#ifndef _STDLCD_DRAW_FUNCTIONS_H_
#define _STDLCD_DRAW_FUNCTIONS_H_
#pragma once
#include "lcd.h"
void lcdDrawMultiProtocolString(coord_t x, coord_t y, uint8_t moduleIdx, uint8_t protocol, LcdFlags flags = 0);
@@ -55,4 +54,4 @@ void drawFunction(FnFuncP fn, uint8_t offset = 0);
void drawCursor(FnFuncP fn, uint8_t offset = 0);
void drawCurve(coord_t offset = 0);
#endif // _STDLCD_DRAW_FUNCTIONS_H_
void drawSource(coord_t x, coord_t y, mixsrc_t idx, LcdFlags att=0);
+20 -7
View File
@@ -96,7 +96,8 @@ void menuModelCurvesAll(event_t event)
}
}
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags)
void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlags flags,
IsValueAvailable isValueAvailable, int16_t sourceMin)
{
coord_t x1 = x;
LcdFlags flags1 = flags;
@@ -126,24 +127,36 @@ void editCurveRef(coord_t x, coord_t y, CurveRef & curve, event_t event, LcdFlag
switch (curve.type) {
case CURVE_REF_DIFF:
case CURVE_REF_EXPO:
curve.value = GVAR_MENU_ITEM(x, y, curve.value, -100, 100, LEFT | flags, 0, event);
curve.value = editSrcVarFieldValue(x, y, nullptr, curve.value, -100, 100, flags, event, isValueAvailable, sourceMin);
break;
case CURVE_REF_FUNC:
lcdDrawTextAtIndex(x, y, STR_VCURVEFUNC, curve.value, flags);
if (active && menuHorizontalPosition==1) CHECK_INCDEC_MODELVAR_ZERO(event, curve.value, CURVE_BASE-1);
{
SourceNumVal v;
v.rawValue = curve.value;
lcdDrawTextAtIndex(x, y, STR_VCURVEFUNC, v.value, flags);
if (active && menuHorizontalPosition==1) {
CHECK_INCDEC_MODELVAR_ZERO(event, v.value, CURVE_BASE-1);
curve.value = v.rawValue;
}
break;
}
case CURVE_REF_CUSTOM:
drawCurveName(x, y, curve.value, flags);
{
SourceNumVal v;
v.rawValue = curve.value;
drawCurveName(x, y, v.value, flags);
if (active && menuHorizontalPosition == 1) {
if (event == EVT_KEY_LONG(KEY_ENTER) && curve.value != 0) {
if (event == EVT_KEY_LONG(KEY_ENTER) && v.value != 0) {
s_currIdxSubMenu = abs(curve.value) - 1;
pushMenu(menuModelCurveOne);
}
else {
CHECK_INCDEC_MODELVAR(event, curve.value, -MAX_CURVES, MAX_CURVES);
CHECK_INCDEC_MODELVAR(event, v.value, -MAX_CURVES, MAX_CURVES);
curve.value = v.rawValue;
}
}
break;
}
}
}
+9 -6
View File
@@ -391,7 +391,7 @@ void menuModelExposAll(event_t event)
coord_t y = MENU_HEADER_HEIGHT+1+(cur-menuVerticalOffset)*FH;
if (i<MAX_EXPOS && (ed=expoAddress(i))->chn+1 == ch && EXPO_VALID(ed)) {
if (cur-menuVerticalOffset >= 0 && cur-menuVerticalOffset < NUM_BODY_LINES) {
drawSource(0, y, ch, 0);
drawSource(0, y, ch, ((s_copyMode || sub != cur) ? 0 : INVERS));
}
uint8_t mixCnt = 0;
do {
@@ -410,10 +410,10 @@ void menuModelExposAll(event_t event)
s_currIdx = i;
}
if (cur-menuVerticalOffset >= 0 && cur-menuVerticalOffset < NUM_BODY_LINES) {
LcdFlags attr = ((s_copyMode || sub != cur) ? 0 : INVERS);
GVAR_MENU_ITEM(EXPO_LINE_WEIGHT_POS, y, ed->weight, -100, 100, RIGHT | attr | (isExpoActive(i) ? BOLD : 0), 0, 0);
displayExpoLine(y, ed, attr);
editSrcVarFieldValue(EXPO_LINE_WEIGHT_POS, y, nullptr, ed->weight,
-100, 100, RIGHT | (isExpoActive(i) ? BOLD : 0),
0, 0, 0);
displayExpoLine(y, ed, 0);
if (s_copyMode) {
if ((s_copyMode==COPY_MODE || s_copyTgtOfs == 0) && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) {
@@ -422,11 +422,14 @@ void menuModelExposAll(event_t event)
}
if (cur == sub) {
/* invert the raw when it's the current one */
lcdDrawSolidFilledRect(EXPO_LINE_SELECT_POS+1, y, LCD_W-EXPO_LINE_SELECT_POS-2, 7);
lcdDrawSolidFilledRect(0, y, LCD_W, 7);
}
}
}
cur++; y+=FH; mixCnt++; i++; ed++;
if (sub == cur && ed->chn+1 == ch) {
lcdDrawText(INDENT_WIDTH, y, "->", ((s_copyMode || sub != cur) ? 0 : INVERS));
}
} while (i<MAX_EXPOS && ed->chn+1 == ch && EXPO_VALID(ed));
if (s_copyMode == MOVE_MODE && cur-menuVerticalOffset >= 0 && cur-menuVerticalOffset < NUM_BODY_LINES && s_copySrcCh == ch && i == (s_copySrcIdx + (s_copyTgtOfs<0))) {
lcdDrawRect(EXPO_LINE_SELECT_POS, y-1, LCD_W-EXPO_LINE_SELECT_POS, 9, DOTTED);
+7 -7
View File
@@ -307,7 +307,7 @@ void menuModelMixAll(event_t event)
MixData * md = mixAddress(i);
if (i < getMixCount() && (md->destCh + 1 == ch)) {
if (cur-menuVerticalOffset >= 0 && cur-menuVerticalOffset < NUM_BODY_LINES) {
putsChn(0, y, ch, 0); // show CHx
putsChn(0, y, ch, ((s_copyMode || sub != cur) ? 0 : INVERS)); // show CHx
}
uint8_t mixCnt = 0;
do {
@@ -326,17 +326,17 @@ void menuModelMixAll(event_t event)
s_currIdx = i;
}
if (cur-menuVerticalOffset >= 0 && cur-menuVerticalOffset < NUM_BODY_LINES) {
LcdFlags attr = ((s_copyMode || sub != cur) ? 0 : INVERS);
if (mixCnt > 0) lcdDrawTextAtIndex(FW, y, STR_VMLTPX2, md->mltpx, 0);
if (mixCnt > 0) lcdDrawTextAtIndex(FW, y, STR_VMLTPX2, md->mltpx, ((s_copyMode || sub != cur) ? 0 : INVERS));
drawSource(MIX_LINE_SRC_POS, y, md->srcRaw, 0);
if (mixCnt == 0 && md->mltpx == 1) {
lcdDrawText(MIX_LINE_WEIGHT_POS, y, "MULT!", RIGHT | attr | (isMixActive(i) ? BOLD : 0));
lcdDrawText(MIX_LINE_WEIGHT_POS, y, "MULT!", RIGHT | ((isMixActive(i) ? BOLD : 0)));
}
else {
gvarWeightItem(MIX_LINE_WEIGHT_POS, y, md, RIGHT | attr | (isMixActive(i) ? BOLD : 0), 0);
editSrcVarFieldValue(MIX_LINE_WEIGHT_POS, y, nullptr, md->weight,
MIX_WEIGHT_MIN, MIX_WEIGHT_MAX, RIGHT | ((isMixActive(i) ? BOLD : 0)),
0, 0, 0);
}
#if LCD_W >= 212
@@ -352,7 +352,7 @@ void menuModelMixAll(event_t event)
}
if (cur == sub) {
/* invert the raw when it's the current one */
lcdDrawSolidFilledRect(23, y, LCD_W-24, 7);
lcdDrawSolidFilledRect(0, y, LCD_W, 7);
}
}
}
+2
View File
@@ -117,6 +117,8 @@ void onSourceLongEnterPress(const char * result)
}
} else if (result == STR_MENU_INVERT) {
checkIncDecSelection = MIXSRC_INVERT;
} else if (result == STR_CONSTANT) {
checkIncDecSelection = MIXSRC_VALUE;
}
}
+2
View File
@@ -74,6 +74,8 @@ extern int8_t s_editMode; // global editmode
#define INCDEC_REP10 0x40
#define NO_DBLKEYS 0x80
#define INCDEC_SOURCE_INVERT 0x100
#define INCDEC_SOURCE_VALUE 0x200 // Field can be source or value
#define INCDEC_SOURCE_NOINPUTS 0x400 // Do not allow Inputs in source selection
int checkIncDec(event_t event, int val, int i_min, int i_max,
unsigned int i_flags = 0, IsValueAvailable isValueAvailable = nullptr,
+110 -3
View File
@@ -51,7 +51,26 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
{
int newval = val;
bool isSource = false;
bool origIsSource = false;
if (i_flags & INCDEC_SOURCE_VALUE) {
SourceNumVal v;
v.rawValue = val;
// Save isSource flag;
origIsSource = isSource = v.isSource;
// Remove isSource flag;
val = v.value;
newval = v.value;
}
if (s_editMode > 0) {
bool invert = false;
if ((i_flags & INCDEC_SOURCE_INVERT) && (newval < 0)) {
invert = true;
newval = -newval;
val = -val;
}
if (event == EVT_KEY_FIRST(KEY_UP) || event == EVT_KEY_REPT(KEY_UP) ||
event == EVT_KEY_FIRST(KEY_RIGHT) || event == EVT_KEY_REPT(KEY_RIGHT)) {
do {
@@ -94,10 +113,17 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
#endif
#if defined(AUTOSOURCE)
if (i_flags & INCDEC_SOURCE) {
int8_t source = GET_MOVED_SOURCE(i_min, i_max);
if (i_flags & (INCDEC_SOURCE|INCDEC_SOURCE_VALUE)) {
int source = GET_MOVED_SOURCE(i_min, i_max);
if (source) {
newval = source;
if (i_flags & INCDEC_SOURCE_VALUE) {
if (isSource) {
// Only use moved source if already a source value
newval = source;
}
} else {
newval = source;
}
}
#if defined(AUTOSWITCH)
else {
@@ -109,6 +135,11 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
#endif
}
#endif
if (invert) {
newval = -newval;
val = -val;
}
}
if (i_min == 0 && i_max == 1 &&
@@ -117,6 +148,75 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
newval = !val;
}
if (i_flags & (INCDEC_SOURCE | INCDEC_SOURCE_VALUE)) {
if (event == EVT_KEY_LONG(KEY_ENTER)) {
checkIncDecSelection = MIXSRC_NONE;
if (i_flags & INCDEC_SOURCE_VALUE && isSource) {
POPUP_MENU_ADD_ITEM(STR_CONSTANT);
}
if (i_min <= MIXSRC_FIRST_INPUT && i_max >= MIXSRC_FIRST_INPUT) {
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE &&
(i_flags & INCDEC_SOURCE_NOINPUTS) == 0) {
POPUP_MENU_ADD_ITEM(STR_MENU_INPUTS);
}
}
#if defined(LUA_MODEL_SCRIPTS)
if (i_min <= MIXSRC_FIRST_LUA && i_max >= MIXSRC_FIRST_LUA) {
if (getFirstAvailable(MIXSRC_FIRST_LUA, MIXSRC_LAST_LUA, isSourceAvailable) != MIXSRC_NONE) {
POPUP_MENU_ADD_ITEM(STR_MENU_LUA);
}
}
#endif
if (i_min <= MIXSRC_FIRST_STICK && i_max >= MIXSRC_FIRST_STICK) POPUP_MENU_ADD_ITEM(STR_MENU_STICKS);
if (i_min <= MIXSRC_FIRST_POT && i_max >= MIXSRC_FIRST_POT) POPUP_MENU_ADD_ITEM(STR_MENU_POTS);
if (i_min <= MIXSRC_MIN && i_max >= MIXSRC_MIN) POPUP_MENU_ADD_ITEM(STR_MENU_MIN);
if (i_min <= MIXSRC_MAX && i_max >= MIXSRC_MAX) POPUP_MENU_ADD_ITEM(STR_MENU_MAX);
#if defined(HELI)
if (modelHeliEnabled())
if (i_min <= MIXSRC_FIRST_HELI && i_max >= MIXSRC_FIRST_HELI && isValueAvailable && isValueAvailable(MIXSRC_FIRST_HELI))
POPUP_MENU_ADD_ITEM(STR_MENU_HELI);
#endif
if (i_min <= MIXSRC_FIRST_TRIM && i_max >= MIXSRC_FIRST_TRIM) POPUP_MENU_ADD_ITEM(STR_MENU_TRIMS);
if (i_min <= MIXSRC_FIRST_SWITCH && i_max >= MIXSRC_FIRST_SWITCH) POPUP_MENU_ADD_ITEM(STR_MENU_SWITCHES);
if (i_min <= MIXSRC_FIRST_TRAINER && i_max >= MIXSRC_FIRST_TRAINER) POPUP_MENU_ADD_ITEM(STR_MENU_TRAINER);
if (i_min <= MIXSRC_FIRST_CH && i_max >= MIXSRC_FIRST_CH) POPUP_MENU_ADD_ITEM(STR_MENU_CHANNELS);
if (i_min <= MIXSRC_FIRST_GVAR && i_max >= MIXSRC_FIRST_GVAR && isValueAvailable && isValueAvailable(MIXSRC_FIRST_GVAR)) {
POPUP_MENU_ADD_ITEM(STR_MENU_GVARS);
}
if (modelTelemetryEnabled() && i_min <= MIXSRC_FIRST_TELEM && i_max >= MIXSRC_FIRST_TELEM) {
for (int i = 0; i < MAX_TELEMETRY_SENSORS; i++) {
TelemetrySensor * sensor = & g_model.telemetrySensors[i];
if (sensor->isAvailable()) {
POPUP_MENU_ADD_ITEM(STR_MENU_TELEMETRY);
break;
}
}
}
if (i_flags & INCDEC_SOURCE_INVERT) POPUP_MENU_ADD_ITEM(STR_MENU_INVERT);
POPUP_MENU_START(onSourceLongEnterPress);
}
if (checkIncDecSelection != 0) {
if (i_flags & INCDEC_SOURCE_VALUE) {
if (checkIncDecSelection == MIXSRC_VALUE) {
newval = 0;
isSource = false;
} else {
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
if (checkIncDecSelection != MIXSRC_INVERT)
isSource = true;
}
} else {
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
}
if (checkIncDecSelection != MIXSRC_MIN && checkIncDecSelection != MIXSRC_MAX)
s_editMode = EDIT_MODIFY_FIELD;
checkIncDecSelection = 0;
}
}
if (newval != val) {
if (!(i_flags & NO_INCDEC_MARKS) && (newval != i_max) &&
(newval != i_min) && stops.contains(newval)) {
@@ -136,6 +236,13 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
checkIncDec_Ret = 0;
}
if (i_flags & INCDEC_SOURCE_VALUE) {
SourceNumVal v;
v.isSource = isSource;
v.value = newval;
newval = v.rawValue;
}
return newval;
}
+50 -7
View File
@@ -60,6 +60,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
}
#endif
bool isSource = false;
bool origIsSource = false;
if (i_flags & INCDEC_SOURCE_VALUE) {
SourceNumVal v;
v.rawValue = val;
// Save isSource flag;
origIsSource = isSource = v.isSource;
// Remove isSource flag;
val = v.value;
newval = v.value;
}
if (s_editMode > 0) {
bool invert = false;
if ((i_flags & INCDEC_SOURCE_INVERT) && (newval < 0)) {
@@ -111,10 +123,17 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
#endif
#if defined(AUTOSOURCE)
if (i_flags & INCDEC_SOURCE) {
if (i_flags & (INCDEC_SOURCE|INCDEC_SOURCE_VALUE)) {
int source = GET_MOVED_SOURCE(i_min, i_max);
if (source) {
newval = source;
if (i_flags & INCDEC_SOURCE_VALUE) {
if (isSource) {
// Only use moved source if already a source value
newval = source;
}
} else {
newval = source;
}
}
#if defined(AUTOSWITCH)
else {
@@ -139,18 +158,24 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
newval = !val;
}
if (i_flags & INCDEC_SOURCE) {
if (i_flags & (INCDEC_SOURCE | INCDEC_SOURCE_VALUE)) {
if (event == EVT_KEY_LONG(KEY_ENTER)) {
checkIncDecSelection = MIXSRC_NONE;
if (i_flags & INCDEC_SOURCE_VALUE && isSource) {
POPUP_MENU_ADD_ITEM(STR_CONSTANT);
}
if (i_min <= MIXSRC_FIRST_INPUT && i_max >= MIXSRC_FIRST_INPUT) {
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE) {
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE &&
(i_flags & INCDEC_SOURCE_NOINPUTS) == 0) {
POPUP_MENU_ADD_ITEM(STR_MENU_INPUTS);
}
}
#if defined(LUA_MODEL_SCRIPTS)
if (i_min <= MIXSRC_FIRST_LUA && i_max >= MIXSRC_FIRST_LUA) {
if (getFirstAvailable(MIXSRC_FIRST_LUA, MIXSRC_LAST_LUA, isSourceAvailable) != MIXSRC_NONE) {
if (getFirstAvailable(MIXSRC_FIRST_LUA, MIXSRC_LAST_LUA, isSourceAvailable) != MIXSRC_NONE &&
(i_flags & INCDEC_SOURCE_NOINPUTS) == 0) {
POPUP_MENU_ADD_ITEM(STR_MENU_LUA);
}
}
@@ -185,7 +210,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
POPUP_MENU_START(onSourceLongEnterPress);
}
if (checkIncDecSelection != 0) {
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
if (i_flags & INCDEC_SOURCE_VALUE) {
if (checkIncDecSelection == MIXSRC_VALUE) {
newval = 0;
isSource = false;
} else {
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
if (checkIncDecSelection != MIXSRC_INVERT)
isSource = true;
}
} else {
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
}
if (checkIncDecSelection != MIXSRC_MIN && checkIncDecSelection != MIXSRC_MAX)
s_editMode = EDIT_MODIFY_FIELD;
checkIncDecSelection = 0;
@@ -216,7 +252,7 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
}
}
if (newval != val) {
if (newval != val || isSource != origIsSource) {
storageDirty(i_flags & (EE_GENERAL|EE_MODEL));
checkIncDec_Ret = (newval > val ? 1 : -1);
}
@@ -224,6 +260,13 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
checkIncDec_Ret = 0;
}
if (i_flags & INCDEC_SOURCE_VALUE) {
SourceNumVal v;
v.isSource = isSource;
v.value = newval;
newval = v.rawValue;
}
return newval;
}
+47 -5
View File
@@ -60,6 +60,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
}
#endif
bool isSource = false;
bool origIsSource = false;
if (i_flags & INCDEC_SOURCE_VALUE) {
SourceNumVal v;
v.rawValue = val;
// Save isSource flag;
origIsSource = isSource = v.isSource;
// Remove isSource flag;
val = v.value;
newval = v.value;
}
if (s_editMode > 0) {
bool invert = false;
if ((i_flags & INCDEC_SOURCE_INVERT) && (newval < 0)) {
@@ -111,10 +123,17 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
#endif
#if defined(AUTOSOURCE)
if (i_flags & INCDEC_SOURCE) {
if (i_flags & (INCDEC_SOURCE|INCDEC_SOURCE_VALUE)) {
int source = GET_MOVED_SOURCE(i_min, i_max);
if (source) {
newval = source;
if (i_flags & INCDEC_SOURCE_VALUE) {
if (isSource) {
// Only use moved source if already a source value
newval = source;
}
} else {
newval = source;
}
}
#if defined(AUTOSWITCH)
else {
@@ -139,12 +158,17 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
newval = !val;
}
if (i_flags & INCDEC_SOURCE) {
if (i_flags & (INCDEC_SOURCE | INCDEC_SOURCE_VALUE)) {
if (event == EVT_KEY_LONG(KEY_ENTER)) {
checkIncDecSelection = MIXSRC_NONE;
if (i_flags & INCDEC_SOURCE_VALUE && isSource) {
POPUP_MENU_ADD_ITEM(STR_CONSTANT);
}
if (i_min <= MIXSRC_FIRST_INPUT && i_max >= MIXSRC_FIRST_INPUT) {
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE) {
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE &&
(i_flags & INCDEC_SOURCE_NOINPUTS) == 0) {
POPUP_MENU_ADD_ITEM(STR_MENU_INPUTS);
}
}
@@ -185,7 +209,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
POPUP_MENU_START(onSourceLongEnterPress);
}
if (checkIncDecSelection != 0) {
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
if (i_flags & INCDEC_SOURCE_VALUE) {
if (checkIncDecSelection == MIXSRC_VALUE) {
newval = 0;
isSource = false;
} else {
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
if (checkIncDecSelection != MIXSRC_INVERT)
isSource = true;
}
} else {
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
}
if (checkIncDecSelection != MIXSRC_MIN && checkIncDecSelection != MIXSRC_MAX)
s_editMode = EDIT_MODIFY_FIELD;
checkIncDecSelection = 0;
@@ -258,6 +293,13 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
checkIncDec_Ret = 0;
}
if (i_flags & INCDEC_SOURCE_VALUE) {
SourceNumVal v;
v.isSource = isSource;
v.value = newval;
newval = v.rawValue;
}
return newval;
}
+48 -6
View File
@@ -49,6 +49,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
{
int newval = val;
bool isSource = false;
bool origIsSource = false;
if (i_flags & INCDEC_SOURCE_VALUE) {
SourceNumVal v;
v.rawValue = val;
// Save isSource flag;
origIsSource = isSource = v.isSource;
// Remove isSource flag;
val = v.value;
newval = v.value;
}
if (s_editMode > 0) {
bool invert = false;
if ((i_flags & INCDEC_SOURCE_INVERT) && (newval < 0)) {
@@ -101,10 +113,17 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
#endif
#if defined(AUTOSOURCE)
if (i_flags & INCDEC_SOURCE) {
int8_t source = GET_MOVED_SOURCE(i_min, i_max);
if (i_flags & (INCDEC_SOURCE|INCDEC_SOURCE_VALUE)) {
int source = GET_MOVED_SOURCE(i_min, i_max);
if (source) {
newval = source;
if (i_flags & INCDEC_SOURCE_VALUE) {
if (isSource) {
// Only use moved source if already a source value
newval = source;
}
} else {
newval = source;
}
}
#if defined(AUTOSWITCH)
else {
@@ -148,12 +167,17 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
checkIncDec_Ret = 0;
}
if (i_flags & INCDEC_SOURCE) {
if (i_flags & (INCDEC_SOURCE | INCDEC_SOURCE_VALUE)) {
if (event == EVT_KEY_LONG(KEY_ENTER) && !keysGetState(KEY_SHIFT)) {
checkIncDecSelection = MIXSRC_NONE;
if (i_flags & INCDEC_SOURCE_VALUE && isSource) {
POPUP_MENU_ADD_ITEM(STR_CONSTANT);
}
if (i_min <= MIXSRC_FIRST_INPUT && i_max >= MIXSRC_FIRST_INPUT) {
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE) {
if (getFirstAvailable(MIXSRC_FIRST_INPUT, MIXSRC_LAST_INPUT, isInputAvailable) != MIXSRC_NONE &&
(i_flags & INCDEC_SOURCE_NOINPUTS) == 0) {
POPUP_MENU_ADD_ITEM(STR_MENU_INPUTS);
}
}
@@ -194,7 +218,18 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
POPUP_MENU_START(onSourceLongEnterPress);
}
if (checkIncDecSelection != 0) {
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
if (i_flags & INCDEC_SOURCE_VALUE) {
if (checkIncDecSelection == MIXSRC_VALUE) {
newval = 0;
isSource = false;
} else {
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
if (checkIncDecSelection != MIXSRC_INVERT)
isSource = true;
}
} else {
newval = (checkIncDecSelection == MIXSRC_INVERT ? -newval : checkIncDecSelection);
}
if (checkIncDecSelection != MIXSRC_MIN && checkIncDecSelection != MIXSRC_MAX)
s_editMode = EDIT_MODIFY_FIELD;
checkIncDecSelection = 0;
@@ -225,6 +260,13 @@ int checkIncDec(event_t event, int val, int i_min, int i_max,
}
}
if (i_flags & INCDEC_SOURCE_VALUE) {
SourceNumVal v;
v.isSource = isSource;
v.value = newval;
newval = v.rawValue;
}
return newval;
}
+30 -6
View File
@@ -681,10 +681,18 @@ static int luaModelInsertInput(lua_State *L)
expo->scale = luaL_checkinteger(L, -1);
}
else if (!strcmp(key, "weight")) {
expo->weight = luaL_checkinteger(L, -1);
int val = luaL_checkinteger(L, -1);
SourceNumVal v;
v.isSource = (abs(val) >= 1024);
v.value = val;
expo->weight = v.rawValue;
}
else if (!strcmp(key, "offset")) {
expo->offset = luaL_checkinteger(L, -1);
int val = luaL_checkinteger(L, -1);
SourceNumVal v;
v.isSource = (abs(val) >= 1024);
v.value = val;
expo->offset = v.rawValue;
}
else if (!strcmp(key, "switch")) {
expo->swtch = luaL_checkinteger(L, -1);
@@ -693,7 +701,11 @@ static int luaModelInsertInput(lua_State *L)
expo->curve.type = luaL_checkinteger(L, -1);
}
else if (!strcmp(key, "curveValue")) {
expo->curve.value = luaL_checkinteger(L, -1);
int val = luaL_checkinteger(L, -1);
SourceNumVal v;
v.isSource = (abs(val) >= 1024);
v.value = val;
expo->curve.value = v.rawValue;
}
else if (!strcmp(key, "trimSource")) {
expo->trimSource = - luaL_checkinteger(L, -1);
@@ -904,10 +916,18 @@ static int luaModelInsertMix(lua_State *L)
mix->srcRaw = luaL_checkinteger(L, -1);
}
else if (!strcmp(key, "weight")) {
mix->weight = luaL_checkinteger(L, -1);
int val = luaL_checkinteger(L, -1);
SourceNumVal v;
v.isSource = (abs(val) >= 1024);
v.value = val;
mix->weight = v.rawValue;
}
else if (!strcmp(key, "offset")) {
mix->offset = luaL_checkinteger(L, -1);
int val = luaL_checkinteger(L, -1);
SourceNumVal v;
v.isSource = (abs(val) >= 1024);
v.value = val;
mix->offset = v.rawValue;
}
else if (!strcmp(key, "switch")) {
mix->swtch = luaL_checkinteger(L, -1);
@@ -916,7 +936,11 @@ static int luaModelInsertMix(lua_State *L)
mix->curve.type = luaL_checkinteger(L, -1);
}
else if (!strcmp(key, "curveValue")) {
mix->curve.value = luaL_checkinteger(L, -1);
int val = luaL_checkinteger(L, -1);
SourceNumVal v;
v.isSource = (abs(val) >= 1024);
v.value = val;
mix->curve.value = v.rawValue;
}
else if (!strcmp(key, "multiplex")) {
mix->mltpx = luaL_checkinteger(L, -1);
+23 -4
View File
@@ -53,6 +53,25 @@ int16_t ex_chans[MAX_OUTPUT_CHANNELS] = {0}; // Outputs (before LIMITS) of the l
int16_t cyc_anas[3] = {0};
#endif
// TOOD: find better home for this.
int32_t getSourceNumFieldValue(int16_t val, int16_t min, int16_t max)
{
int32_t result;
SourceNumVal v; v.rawValue = val;
if (v.isSource) {
result = getValue(v.value);
if (v.value >= MIXSRC_FIRST_GVAR && v.value <= MIXSRC_LAST_GVAR) {
// Mimic behviour of GET_GVAR_PREC1
result = result * 10;
} else {
result = calcRESXto1000(result);
}
} else {
result = v.value * 10;
}
return limit<int>(min * 10, result, max * 10);
}
// #define EXTENDED_EXPO
// increases range of expo curve but costs about 82 bytes flash
@@ -193,11 +212,11 @@ void applyExpos(int16_t * anas, uint8_t mode, int16_t ovwrIdx, int16_t ovwrValue
}
//========== WEIGHT ===============
int32_t weight = GET_GVAR_PREC1(ed->weight, -100, 100, mixerCurrentFlightMode);
int32_t weight = getSourceNumFieldValue(ed->weight, -100, 100);
v = divRoundClosest((int32_t)v * weight, 1000);
//========== OFFSET ===============
int32_t offset = GET_GVAR_PREC1(ed->offset, -100, 100, mixerCurrentFlightMode);
int32_t offset = getSourceNumFieldValue(ed->offset, -100, 100);
if (offset) v += divRoundClosest(calc100toRESX(offset), 10);
//========== TRIMS ================
@@ -951,7 +970,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
}
}
int32_t weight = GET_GVAR_PREC1(MD_WEIGHT(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode);
int32_t weight = getSourceNumFieldValue(md->weight, -RESX, RESX);
weight = calc100to256_16Bits(weight);
//========== SPEED ===============
// now its on input side, but without weight compensation. More like other remote controls
@@ -1006,7 +1025,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms)
//========== OFFSET / AFTER ===============
if (applyOffsetAndCurve) {
int32_t offset = GET_GVAR_PREC1(MD_OFFSET(md), GV_RANGELARGE_NEG, GV_RANGELARGE, mixerCurrentFlightMode);
int32_t offset = getSourceNumFieldValue(md->offset, -RESX, RESX);
if (offset) dv += divRoundClosest(calc100toRESX_16Bits(offset), 10) << 8;
}
-8
View File
@@ -272,14 +272,6 @@ enum DisplayTrims
extern RadioData g_eeGeneral;
extern ModelData g_model;
PACK(union u_int8int16_t {
struct {
int8_t lo;
uint8_t hi;
} bytes_t;
int16_t word;
});
constexpr uint8_t EE_GENERAL = 0x01;
constexpr uint8_t EE_MODEL = 0x02;
constexpr uint8_t EE_LABELS = 0x04;
@@ -391,21 +391,22 @@ static const struct YamlNode struct_TimerData[] = {
YAML_END
};
static const struct YamlNode struct_CurveRef[] = {
YAML_UNSIGNED( "type", 8 ),
YAML_SIGNED_CUST( "value", 8, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "type", 5 ),
YAML_SIGNED_CUST( "value", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_END
};
static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "destCh", 5 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_SIGNED_CUST( "offset", 13, in_read_weight, in_write_weight ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "delayUp", 8 ),
YAML_UNSIGNED( "delayDown", 8 ),
@@ -433,13 +434,14 @@ static const struct YamlNode struct_ExpoData[] = {
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
YAML_SIGNED( "trimSource", 6 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_SIGNED_CUST( "weight", 8, in_read_weight, in_write_weight ),
YAML_STRING("name", 6),
YAML_SIGNED_CUST( "offset", 8, in_read_weight, in_write_weight ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_STRING("name", 6),
YAML_END
};
static const struct YamlNode struct_CurveHeader[] = {
@@ -798,7 +800,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "beepANACenter", 16 ),
YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL),
YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL),
YAML_ARRAY("expoData", 136, 64, struct_ExpoData, NULL),
YAML_ARRAY("expoData", 144, 64, struct_ExpoData, NULL),
YAML_ARRAY("curves", 32, 32, struct_CurveHeader, NULL),
YAML_ARRAY("points", 8, 512, struct_signed_8, NULL),
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
@@ -463,6 +463,40 @@ static bool w_mixSrcRawEx(const YamlNode* node, uint32_t val, yaml_writer_func w
return wf(opaque, "\"", 1);
}
static uint32_t r_sourceNumVal(const YamlNode* node, const char* val, uint8_t val_len)
{
SourceNumVal v;
if (((val[0] == '-') && (val[1] >= '0' && val[1] <= '9')) || (val[0] >= '0' && val[0] <= '9')) {
v.isSource = 0;
v.value = (uint32_t)yaml_str2int(val, val_len);
} else if ((val[0] == '-') && (val[1] == 'G')) {
v.isSource = 1;
v.value = -((val[3] - '0') + MIXSRC_FIRST_GVAR - 1);
} else if (val[0] == 'G') {
v.isSource = 1;
v.value = (val[2] - '0') + MIXSRC_FIRST_GVAR - 1;
} else {
v.isSource = 1;
v.value = r_mixSrcRawEx(node, val, val_len);
}
return v.rawValue;
}
bool w_sourceNumVal(const YamlNode* node, uint32_t val, yaml_writer_func wf,
void* opaque)
{
SourceNumVal v;
v.rawValue = val;
if (v.isSource)
return w_mixSrcRawEx(node, v.value, wf, opaque);
char* s = yaml_signed2str(v.value);
return wf(opaque, s, strlen(s));
}
static void r_rssiDisabled(void* user, uint8_t* data, uint32_t bitoffs,
const char* val, uint8_t val_len)
{
@@ -417,21 +417,22 @@ static const struct YamlNode struct_TimerData[] = {
YAML_END
};
static const struct YamlNode struct_CurveRef[] = {
YAML_UNSIGNED( "type", 8 ),
YAML_SIGNED_CUST( "value", 8, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "type", 5 ),
YAML_SIGNED_CUST( "value", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_END
};
static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "destCh", 5 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_SIGNED_CUST( "offset", 13, in_read_weight, in_write_weight ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "delayUp", 8 ),
YAML_UNSIGNED( "delayDown", 8 ),
@@ -459,13 +460,14 @@ static const struct YamlNode struct_ExpoData[] = {
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
YAML_SIGNED( "trimSource", 6 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_SIGNED_CUST( "weight", 8, in_read_weight, in_write_weight ),
YAML_STRING("name", 6),
YAML_SIGNED_CUST( "offset", 8, in_read_weight, in_write_weight ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_STRING("name", 6),
YAML_END
};
static const struct YamlNode struct_CurveHeader[] = {
@@ -832,7 +834,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "beepANACenter", 16 ),
YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL),
YAML_ARRAY("limitData", 104, 32, struct_LimitData, NULL),
YAML_ARRAY("expoData", 136, 64, struct_ExpoData, NULL),
YAML_ARRAY("expoData", 144, 64, struct_ExpoData, NULL),
YAML_ARRAY("curves", 32, 32, struct_CurveHeader, NULL),
YAML_ARRAY("points", 8, 512, struct_signed_8, NULL),
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
@@ -417,21 +417,22 @@ static const struct YamlNode struct_TimerData[] = {
YAML_END
};
static const struct YamlNode struct_CurveRef[] = {
YAML_UNSIGNED( "type", 8 ),
YAML_SIGNED_CUST( "value", 8, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "type", 5 ),
YAML_SIGNED_CUST( "value", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_END
};
static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "destCh", 5 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_SIGNED_CUST( "offset", 13, in_read_weight, in_write_weight ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "delayUp", 8 ),
YAML_UNSIGNED( "delayDown", 8 ),
@@ -459,13 +460,14 @@ static const struct YamlNode struct_ExpoData[] = {
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
YAML_SIGNED( "trimSource", 6 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_SIGNED_CUST( "weight", 8, in_read_weight, in_write_weight ),
YAML_STRING("name", 6),
YAML_SIGNED_CUST( "offset", 8, in_read_weight, in_write_weight ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_STRING("name", 6),
YAML_END
};
static const struct YamlNode struct_CurveHeader[] = {
@@ -832,7 +834,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "beepANACenter", 16 ),
YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL),
YAML_ARRAY("limitData", 104, 32, struct_LimitData, NULL),
YAML_ARRAY("expoData", 136, 64, struct_ExpoData, NULL),
YAML_ARRAY("expoData", 144, 64, struct_ExpoData, NULL),
YAML_ARRAY("curves", 32, 32, struct_CurveHeader, NULL),
YAML_ARRAY("points", 8, 512, struct_signed_8, NULL),
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
+13 -11
View File
@@ -419,21 +419,22 @@ static const struct YamlNode struct_TimerData[] = {
YAML_END
};
static const struct YamlNode struct_CurveRef[] = {
YAML_UNSIGNED( "type", 8 ),
YAML_SIGNED_CUST( "value", 8, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "type", 5 ),
YAML_SIGNED_CUST( "value", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_END
};
static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "destCh", 5 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_SIGNED_CUST( "offset", 13, in_read_weight, in_write_weight ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "delayUp", 8 ),
YAML_UNSIGNED( "delayDown", 8 ),
@@ -461,13 +462,14 @@ static const struct YamlNode struct_ExpoData[] = {
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
YAML_SIGNED( "trimSource", 6 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_SIGNED_CUST( "weight", 8, in_read_weight, in_write_weight ),
YAML_STRING("name", 6),
YAML_SIGNED_CUST( "offset", 8, in_read_weight, in_write_weight ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_STRING("name", 6),
YAML_END
};
static const struct YamlNode struct_CurveHeader[] = {
@@ -838,7 +840,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "beepANACenter", 16 ),
YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL),
YAML_ARRAY("limitData", 104, 32, struct_LimitData, NULL),
YAML_ARRAY("expoData", 136, 64, struct_ExpoData, NULL),
YAML_ARRAY("expoData", 144, 64, struct_ExpoData, NULL),
YAML_ARRAY("curves", 32, 32, struct_CurveHeader, NULL),
YAML_ARRAY("points", 8, 512, struct_signed_8, NULL),
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
+13 -11
View File
@@ -391,21 +391,22 @@ static const struct YamlNode struct_TimerData[] = {
YAML_END
};
static const struct YamlNode struct_CurveRef[] = {
YAML_UNSIGNED( "type", 8 ),
YAML_SIGNED_CUST( "value", 8, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "type", 5 ),
YAML_SIGNED_CUST( "value", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_END
};
static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "destCh", 5 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_SIGNED_CUST( "offset", 13, in_read_weight, in_write_weight ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "delayUp", 8 ),
YAML_UNSIGNED( "delayDown", 8 ),
@@ -433,13 +434,14 @@ static const struct YamlNode struct_ExpoData[] = {
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
YAML_SIGNED( "trimSource", 6 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_SIGNED_CUST( "weight", 8, in_read_weight, in_write_weight ),
YAML_STRING("name", 6),
YAML_SIGNED_CUST( "offset", 8, in_read_weight, in_write_weight ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_STRING("name", 6),
YAML_END
};
static const struct YamlNode struct_CurveHeader[] = {
@@ -798,7 +800,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "beepANACenter", 16 ),
YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL),
YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL),
YAML_ARRAY("expoData", 136, 64, struct_ExpoData, NULL),
YAML_ARRAY("expoData", 144, 64, struct_ExpoData, NULL),
YAML_ARRAY("curves", 32, 32, struct_CurveHeader, NULL),
YAML_ARRAY("points", 8, 512, struct_signed_8, NULL),
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
@@ -391,21 +391,22 @@ static const struct YamlNode struct_TimerData[] = {
YAML_END
};
static const struct YamlNode struct_CurveRef[] = {
YAML_UNSIGNED( "type", 8 ),
YAML_SIGNED_CUST( "value", 8, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "type", 5 ),
YAML_SIGNED_CUST( "value", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_END
};
static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "destCh", 5 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_SIGNED_CUST( "offset", 13, in_read_weight, in_write_weight ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "delayUp", 8 ),
YAML_UNSIGNED( "delayDown", 8 ),
@@ -433,13 +434,14 @@ static const struct YamlNode struct_ExpoData[] = {
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
YAML_SIGNED( "trimSource", 6 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_SIGNED_CUST( "weight", 8, in_read_weight, in_write_weight ),
YAML_STRING("name", 6),
YAML_SIGNED_CUST( "offset", 8, in_read_weight, in_write_weight ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_STRING("name", 6),
YAML_END
};
static const struct YamlNode struct_CurveHeader[] = {
@@ -798,7 +800,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "beepANACenter", 16 ),
YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL),
YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL),
YAML_ARRAY("expoData", 136, 64, struct_ExpoData, NULL),
YAML_ARRAY("expoData", 144, 64, struct_ExpoData, NULL),
YAML_ARRAY("curves", 32, 32, struct_CurveHeader, NULL),
YAML_ARRAY("points", 8, 512, struct_signed_8, NULL),
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
+13 -11
View File
@@ -419,21 +419,22 @@ static const struct YamlNode struct_TimerData[] = {
YAML_END
};
static const struct YamlNode struct_CurveRef[] = {
YAML_UNSIGNED( "type", 8 ),
YAML_SIGNED_CUST( "value", 8, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "type", 5 ),
YAML_SIGNED_CUST( "value", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_END
};
static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "destCh", 5 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_SIGNED_CUST( "offset", 13, in_read_weight, in_write_weight ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "delayUp", 8 ),
YAML_UNSIGNED( "delayDown", 8 ),
@@ -461,13 +462,14 @@ static const struct YamlNode struct_ExpoData[] = {
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
YAML_SIGNED( "trimSource", 6 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_SIGNED_CUST( "weight", 8, in_read_weight, in_write_weight ),
YAML_STRING("name", 6),
YAML_SIGNED_CUST( "offset", 8, in_read_weight, in_write_weight ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_STRING("name", 6),
YAML_END
};
static const struct YamlNode struct_CurveHeader[] = {
@@ -833,7 +835,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "beepANACenter", 16 ),
YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL),
YAML_ARRAY("limitData", 104, 32, struct_LimitData, NULL),
YAML_ARRAY("expoData", 136, 64, struct_ExpoData, NULL),
YAML_ARRAY("expoData", 144, 64, struct_ExpoData, NULL),
YAML_ARRAY("curves", 32, 32, struct_CurveHeader, NULL),
YAML_ARRAY("points", 8, 512, struct_signed_8, NULL),
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
@@ -419,21 +419,22 @@ static const struct YamlNode struct_TimerData[] = {
YAML_END
};
static const struct YamlNode struct_CurveRef[] = {
YAML_UNSIGNED( "type", 8 ),
YAML_SIGNED_CUST( "value", 8, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "type", 5 ),
YAML_SIGNED_CUST( "value", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_END
};
static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "destCh", 5 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_SIGNED_CUST( "offset", 13, in_read_weight, in_write_weight ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "delayUp", 8 ),
YAML_UNSIGNED( "delayDown", 8 ),
@@ -461,13 +462,14 @@ static const struct YamlNode struct_ExpoData[] = {
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
YAML_SIGNED( "trimSource", 6 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_SIGNED_CUST( "weight", 8, in_read_weight, in_write_weight ),
YAML_STRING("name", 6),
YAML_SIGNED_CUST( "offset", 8, in_read_weight, in_write_weight ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_STRING("name", 6),
YAML_END
};
static const struct YamlNode struct_CurveHeader[] = {
@@ -833,7 +835,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "beepANACenter", 16 ),
YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL),
YAML_ARRAY("limitData", 104, 32, struct_LimitData, NULL),
YAML_ARRAY("expoData", 136, 64, struct_ExpoData, NULL),
YAML_ARRAY("expoData", 144, 64, struct_ExpoData, NULL),
YAML_ARRAY("curves", 32, 32, struct_CurveHeader, NULL),
YAML_ARRAY("points", 8, 512, struct_signed_8, NULL),
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
+13 -11
View File
@@ -390,21 +390,22 @@ static const struct YamlNode struct_TimerData[] = {
YAML_END
};
static const struct YamlNode struct_CurveRef[] = {
YAML_UNSIGNED( "type", 8 ),
YAML_SIGNED_CUST( "value", 8, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "type", 5 ),
YAML_SIGNED_CUST( "value", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_END
};
static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "destCh", 5 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_SIGNED_CUST( "offset", 13, in_read_weight, in_write_weight ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "delayUp", 8 ),
YAML_UNSIGNED( "delayDown", 8 ),
@@ -432,13 +433,14 @@ static const struct YamlNode struct_ExpoData[] = {
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
YAML_SIGNED( "trimSource", 6 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_SIGNED_CUST( "weight", 8, in_read_weight, in_write_weight ),
YAML_STRING("name", 6),
YAML_SIGNED_CUST( "offset", 8, in_read_weight, in_write_weight ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_STRING("name", 6),
YAML_END
};
static const struct YamlNode struct_CurveHeader[] = {
@@ -797,7 +799,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "beepANACenter", 16 ),
YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL),
YAML_ARRAY("limitData", 104, 32, struct_LimitData, NULL),
YAML_ARRAY("expoData", 136, 64, struct_ExpoData, NULL),
YAML_ARRAY("expoData", 144, 64, struct_ExpoData, NULL),
YAML_ARRAY("curves", 32, 32, struct_CurveHeader, NULL),
YAML_ARRAY("points", 8, 512, struct_signed_8, NULL),
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
+13 -11
View File
@@ -391,21 +391,22 @@ static const struct YamlNode struct_TimerData[] = {
YAML_END
};
static const struct YamlNode struct_CurveRef[] = {
YAML_UNSIGNED( "type", 8 ),
YAML_SIGNED_CUST( "value", 8, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "type", 5 ),
YAML_SIGNED_CUST( "value", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_END
};
static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "destCh", 5 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_SIGNED_CUST( "offset", 13, in_read_weight, in_write_weight ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "delayUp", 8 ),
YAML_UNSIGNED( "delayDown", 8 ),
@@ -433,13 +434,14 @@ static const struct YamlNode struct_ExpoData[] = {
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
YAML_SIGNED( "trimSource", 6 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_SIGNED_CUST( "weight", 8, in_read_weight, in_write_weight ),
YAML_STRING("name", 6),
YAML_SIGNED_CUST( "offset", 8, in_read_weight, in_write_weight ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_STRING("name", 6),
YAML_END
};
static const struct YamlNode struct_CurveHeader[] = {
@@ -798,7 +800,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "beepANACenter", 16 ),
YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL),
YAML_ARRAY("limitData", 104, 32, struct_LimitData, NULL),
YAML_ARRAY("expoData", 136, 64, struct_ExpoData, NULL),
YAML_ARRAY("expoData", 144, 64, struct_ExpoData, NULL),
YAML_ARRAY("curves", 32, 32, struct_CurveHeader, NULL),
YAML_ARRAY("points", 8, 512, struct_signed_8, NULL),
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
@@ -394,21 +394,22 @@ static const struct YamlNode struct_TimerData[] = {
YAML_END
};
static const struct YamlNode struct_CurveRef[] = {
YAML_UNSIGNED( "type", 8 ),
YAML_SIGNED_CUST( "value", 8, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "type", 5 ),
YAML_SIGNED_CUST( "value", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_END
};
static const struct YamlNode struct_MixData[] = {
YAML_SIGNED_CUST( "weight", 11, in_read_weight, in_write_weight ),
YAML_UNSIGNED( "destCh", 5 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "carryTrim", 1 ),
YAML_UNSIGNED( "mixWarn", 2 ),
YAML_ENUM("mltpx", 2, enum_MixerMultiplex),
YAML_UNSIGNED( "speedPrec", 1 ),
YAML_SIGNED_CUST( "offset", 13, in_read_weight, in_write_weight ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "delayUp", 8 ),
YAML_UNSIGNED( "delayDown", 8 ),
@@ -436,13 +437,14 @@ static const struct YamlNode struct_ExpoData[] = {
YAML_CUSTOM("carryTrim",r_carryTrim,nullptr),
YAML_SIGNED( "trimSource", 6 ),
YAML_SIGNED_CUST( "srcRaw", 10, r_mixSrcRawEx, w_mixSrcRawEx ),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "weight", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_UNSIGNED_CUST( "offset", 11, r_sourceNumVal, w_sourceNumVal ),
YAML_SIGNED_CUST( "swtch", 10, r_swtchSrc, w_swtchSrc ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_SIGNED_CUST( "weight", 8, in_read_weight, in_write_weight ),
YAML_STRING("name", 6),
YAML_SIGNED_CUST( "offset", 8, in_read_weight, in_write_weight ),
YAML_STRUCT("curve", 16, struct_CurveRef, NULL),
YAML_UNSIGNED( "chn", 5 ),
YAML_UNSIGNED_CUST( "flightModes", 9, r_flightModes, w_flightModes ),
YAML_UNSIGNED( "spare", 2 ),
YAML_STRING("name", 6),
YAML_END
};
static const struct YamlNode struct_CurveHeader[] = {
@@ -801,7 +803,7 @@ static const struct YamlNode struct_ModelData[] = {
YAML_UNSIGNED( "beepANACenter", 16 ),
YAML_ARRAY("mixData", 160, 64, struct_MixData, NULL),
YAML_ARRAY("limitData", 88, 32, struct_LimitData, NULL),
YAML_ARRAY("expoData", 136, 64, struct_ExpoData, NULL),
YAML_ARRAY("expoData", 144, 64, struct_ExpoData, NULL),
YAML_ARRAY("curves", 32, 32, struct_CurveHeader, NULL),
YAML_ARRAY("points", 8, 512, struct_signed_8, NULL),
YAML_ARRAY("logicalSw", 72, 64, struct_LogicalSwitchData, NULL),
+20 -2
View File
@@ -380,7 +380,7 @@ char *getCurveString(char *dest, int idx)
char *s = dest;
if (idx < 0) {
*s++ = '!';
*s++ = '-';
idx = -idx;
}
@@ -429,6 +429,24 @@ char *getValueOrGVarString(char *dest, size_t len, gvar_t value, gvar_t vmin,
formatNumberAsString(dest, len, value, flags, 0, nullptr, suffix);
return dest;
}
char *getValueOrSrcVarString(char *dest, size_t len, gvar_t value, gvar_t vmin,
gvar_t vmax, LcdFlags flags, const char *suffix,
gvar_t offset, bool usePPMUnit)
{
SourceNumVal v;
v.rawValue = value;
if (v.isSource) {
const char* s = getSourceString(v.value);
strncpy(dest, s, len);
} else {
v.value += offset;
if (usePPMUnit && g_eeGeneral.ppmunit == PPM_US)
v.value = v.value * 128 / 25;
formatNumberAsString(dest, len, v.value, flags, 0, nullptr, suffix);
}
return dest;
}
#endif
char *getFlightModeString(char *dest, int8_t idx)
@@ -640,7 +658,7 @@ char *getSourceString(char (&destRef)[L], mixsrc_t idx)
if (idx < 0) {
idx = -idx;
dest[0] = '!';
dest[0] = '-';
dest += 1;
dest_len -= 1;
}
+3
View File
@@ -98,6 +98,9 @@ char *getGVarString(int idx);
char *getValueOrGVarString(char *dest, size_t len, gvar_t value, gvar_t vmin,
gvar_t vmax, LcdFlags flags = 0,
const char *suffix = nullptr, gvar_t offset = 0, bool usePPMUnit = false);
char *getValueOrSrcVarString(char *dest, size_t len, gvar_t value, gvar_t vmin,
gvar_t vmax, LcdFlags flags = 0,
const char *suffix = nullptr, gvar_t offset = 0, bool usePPMUnit = false);
const char *getSwitchWarnSymbol(uint8_t pos);
const char *getSwitchPositionSymbol(uint8_t pos);
char *getSwitchPositionName(char *dest, swsrc_t idx);
+5 -2
View File
@@ -134,7 +134,9 @@ TEST(Lua, testModelInputs)
EXPECT_EQ(3, (int)g_model.expoData[0].chn);
EXPECT_STRNEQ("test2", g_model.expoData[0].name);
EXPECT_EQ(MIXSRC_FIRST_STICK, g_model.expoData[0].srcRaw);
EXPECT_EQ(-56, g_model.expoData[0].weight);
SourceNumVal v;
v.rawValue = g_model.expoData[0].weight;
EXPECT_EQ(-56, v.value);
EXPECT_EQ(0, g_model.expoData[0].offset);
EXPECT_EQ(0, g_model.expoData[0].swtch);
@@ -155,7 +157,8 @@ TEST(Lua, testModelInputs)
EXPECT_EQ(3, (int)g_model.expoData[0].chn);
EXPECT_STRNEQ("test2", g_model.expoData[0].name);
EXPECT_EQ(MIXSRC_FIRST_STICK, g_model.expoData[0].srcRaw);
EXPECT_EQ(-56, g_model.expoData[0].weight);
v.rawValue = g_model.expoData[0].weight;
EXPECT_EQ(-56, v.value);
EXPECT_EQ(0, g_model.expoData[0].offset);
EXPECT_EQ(0, g_model.expoData[0].swtch);
+34 -34
View File
@@ -279,7 +279,7 @@ TEST_F(TrimsTest, throttleTrimWithZeroWeightOnThrottle)
g_model.thrTrim = 1;
// the input already exists
ExpoData *expo = expoAddress(THR_STICK);
expo->weight = 0;
expo->weight = makeSourceNumVal(0);
// stick max + trim max
anaSetFiltered(THR_STICK, +1024);
setTrimValue(0, THR_STICK, TRIM_MAX);
@@ -350,7 +350,7 @@ TEST_F(TrimsTest, invertedThrottlePlusthrottleTrimWithZeroWeightOnThrottle)
g_model.thrTrim = 1;
// the input already exists
ExpoData *expo = expoAddress(THR_STICK);
expo->weight = 0;
expo->weight = makeSourceNumVal(0);
// stick max + trim max
anaSetFiltered(THR_STICK, +1024);
setTrimValue(0, THR_STICK, TRIM_MAX);
@@ -579,7 +579,7 @@ TEST_F(TrimsTest, InstantTrimNegativeCurve)
{
ExpoData *expo = expoAddress(AIL_STICK);
expo->curve.type = CURVE_REF_CUSTOM;
expo->curve.value = 1;
expo->curve.value = makeSourceNumVal(1);
g_model.points[0] = -100;
g_model.points[1] = -75;
g_model.points[2] = -50;
@@ -616,13 +616,13 @@ TEST_F(MixerTest, InfiniteRecursiveChannels)
{
g_model.mixData[0].destCh = 0;
g_model.mixData[0].srcRaw = MIXSRC_FIRST_CH + 1;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[1].destCh = 1;
g_model.mixData[1].srcRaw = MIXSRC_FIRST_CH + 2;
g_model.mixData[1].weight = 100;
g_model.mixData[1].weight = makeSourceNumVal(100);
g_model.mixData[2].destCh = 2;
g_model.mixData[2].srcRaw = MIXSRC_FIRST_CH;
g_model.mixData[2].weight = 100;
g_model.mixData[2].weight = makeSourceNumVal(100);
evalFlightModeMixes(e_perout_mode_normal, 0);
EXPECT_EQ(chans[2], 0);
EXPECT_EQ(chans[1], 0);
@@ -633,7 +633,7 @@ TEST_F(MixerTest, BlockingChannel)
{
g_model.mixData[0].destCh = 0;
g_model.mixData[0].srcRaw = MIXSRC_FIRST_CH;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
evalFlightModeMixes(e_perout_mode_normal, 0);
EXPECT_EQ(chans[0], 0);
}
@@ -643,14 +643,14 @@ TEST_F(MixerTest, RecursiveAddChannel)
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = 50;
g_model.mixData[0].weight = makeSourceNumVal(50);
g_model.mixData[1].destCh = 0;
g_model.mixData[1].mltpx = MLTPX_ADD;
g_model.mixData[1].srcRaw = MIXSRC_FIRST_CH + 1;
g_model.mixData[1].weight = 100;
g_model.mixData[1].weight = makeSourceNumVal(100);
g_model.mixData[2].destCh = 1;
g_model.mixData[2].srcRaw = MIXSRC_FIRST_STICK;
g_model.mixData[2].weight = 100;
g_model.mixData[2].weight = makeSourceNumVal(100);
anaSetFiltered(0, 0);
evalFlightModeMixes(e_perout_mode_normal, 0);
@@ -665,15 +665,15 @@ TEST_F(MixerTest, RecursiveAddChannelAfterInactivePhase)
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_FIRST_CH + 1;
g_model.mixData[0].flightModes = 0b11110;
g_model.mixData[0].weight = 50;
g_model.mixData[0].weight = makeSourceNumVal(50);
g_model.mixData[1].destCh = 0;
g_model.mixData[1].mltpx = MLTPX_ADD;
g_model.mixData[1].srcRaw = MIXSRC_MAX;
g_model.mixData[1].flightModes = 0b11101;
g_model.mixData[1].weight = 50;
g_model.mixData[1].weight = makeSourceNumVal(50);
g_model.mixData[2].destCh = 1;
g_model.mixData[2].srcRaw = MIXSRC_MAX;
g_model.mixData[2].weight = 100;
g_model.mixData[2].weight = makeSourceNumVal(100);
simuSetSwitch(3, -1);
evalMixes(1);
EXPECT_EQ(chans[0], CHANNEL_MAX/2);
@@ -691,7 +691,7 @@ TEST_F(MixerTest, SlowOnPhase)
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[0].flightModes = 0x2 + 0x4 + 0x8 + 0x10 /*only enabled in phase 0*/;
g_model.mixData[0].speedUp = 50;
g_model.mixData[0].speedDown = 50;
@@ -714,7 +714,7 @@ TEST_F(MixerTest, SlowOnSwitchSource)
g_eeGeneral.switchConfig = 0x03;
g_model.mixData[0].srcRaw = MIXSRC_FIRST_SWITCH;
int switchIndex = 0;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[0].speedUp = 50;
g_model.mixData[0].speedDown = 50;
@@ -734,7 +734,7 @@ TEST_F(MixerTest, SlowOnPhasePrec10ms)
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[0].flightModes = 0x2 + 0x4 + 0x8 + 0x10 /*only enabled in phase 0*/;
g_model.mixData[0].speedUp = 50;
g_model.mixData[0].speedDown = 50;
@@ -758,7 +758,7 @@ TEST_F(MixerTest, SlowOnSwitchSourcePrec10ms)
g_eeGeneral.switchConfig = 0x03;
g_model.mixData[0].srcRaw = MIXSRC_FIRST_SWITCH;
int switchIndex = 0;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[0].speedUp = 50;
g_model.mixData[0].speedDown = 50;
g_model.mixData[0].speedPrec = 1;
@@ -778,7 +778,7 @@ TEST_F(MixerTest, SlowDisabledOnStartup)
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[0].speedUp = 50;
g_model.mixData[0].speedDown = 50;
@@ -791,7 +791,7 @@ TEST_F(MixerTest, DelayOnSwitch)
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[0].swtch = SWSRC_FIRST_SWITCH + 2;
g_model.mixData[0].delayUp = 50;
g_model.mixData[0].delayDown = 50;
@@ -822,7 +822,7 @@ TEST_F(MixerTest, DelayOnSwitch2)
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_FIRST_SWITCH;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
// g_model.mixData[0].swtch = SWSRC_ON;
g_model.mixData[0].delayUp = 50;
g_model.mixData[0].delayDown = 50;
@@ -851,11 +851,11 @@ TEST_F(MixerTest, SlowOnMultiply)
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[1].destCh = 0;
g_model.mixData[1].mltpx = MLTPX_MUL;
g_model.mixData[1].srcRaw = MIXSRC_MAX;
g_model.mixData[1].weight = 100;
g_model.mixData[1].weight = makeSourceNumVal(100);
g_model.mixData[1].swtch = SWSRC_FIRST_SWITCH;
g_model.mixData[1].speedUp = 50;
g_model.mixData[1].speedDown = 50;
@@ -877,11 +877,11 @@ TEST_F(MixerTest, SlowOnMultiplyPrec10ms)
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[1].destCh = 0;
g_model.mixData[1].mltpx = MLTPX_MUL;
g_model.mixData[1].srcRaw = MIXSRC_MAX;
g_model.mixData[1].weight = 100;
g_model.mixData[1].weight = makeSourceNumVal(100);
g_model.mixData[1].swtch = SWSRC_FIRST_SWITCH;
g_model.mixData[1].speedUp = 50;
g_model.mixData[1].speedDown = 50;
@@ -938,15 +938,15 @@ TEST(Heli, BasicTest)
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_CYC1;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[1].destCh = 1;
g_model.mixData[1].mltpx = MLTPX_ADD;
g_model.mixData[1].srcRaw = MIXSRC_CYC2;
g_model.mixData[1].weight = 100;
g_model.mixData[1].weight = makeSourceNumVal(100);
g_model.mixData[2].destCh = 2;
g_model.mixData[2].mltpx = MLTPX_ADD;
g_model.mixData[2].srcRaw = MIXSRC_CYC3;
g_model.mixData[2].weight = 100;
g_model.mixData[2].weight = makeSourceNumVal(100);
anaSetFiltered(THR_STICK, 0);
anaSetFiltered(ELE_STICK, 1024);
anaSetFiltered(AIL_STICK, 0);
@@ -974,15 +974,15 @@ TEST(Heli, Mode2Test)
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_CYC1;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[1].destCh = 1;
g_model.mixData[1].mltpx = MLTPX_ADD;
g_model.mixData[1].srcRaw = MIXSRC_CYC2;
g_model.mixData[1].weight = 100;
g_model.mixData[1].weight = makeSourceNumVal(100);
g_model.mixData[2].destCh = 2;
g_model.mixData[2].mltpx = MLTPX_ADD;
g_model.mixData[2].srcRaw = MIXSRC_CYC3;
g_model.mixData[2].weight = 100;
g_model.mixData[2].weight = makeSourceNumVal(100);
anaSetFiltered(THR_STICK, 0);
anaSetFiltered(ELE_STICK, 1024);
anaSetFiltered(AIL_STICK, 0);
@@ -1003,7 +1003,7 @@ TEST(Trainer, UnpluggedTest)
g_model.mixData[0].destCh = 0;
g_model.mixData[0].mltpx = MLTPX_ADD;
g_model.mixData[0].srcRaw = MIXSRC_FIRST_TRAINER;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[0].delayUp = 50;
g_model.mixData[0].delayDown = 50;
trainerSetTimer(0);
@@ -1026,12 +1026,12 @@ TEST_F(MixerTest, flightModeTransition)
g_model.mixData[0].mltpx = MLTPX_REPL;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].flightModes = 0b11110;
g_model.mixData[0].weight = 100;
g_model.mixData[0].weight = makeSourceNumVal(100);
g_model.mixData[1].destCh = 0;
g_model.mixData[1].mltpx = MLTPX_REPL;
g_model.mixData[1].srcRaw = MIXSRC_MAX;
g_model.mixData[1].flightModes = 0b11101;
g_model.mixData[1].weight = -10;
g_model.mixData[1].weight = makeSourceNumVal(-10);
evalMixes(1);
simuSetSwitch(0, 1);
CHECK_FLIGHT_MODE_TRANSITION(0, 1000, 1024, -102);
@@ -1050,7 +1050,7 @@ TEST_F(MixerTest, flightModeOverflow)
g_model.mixData[0].mltpx = MLTPX_REPL;
g_model.mixData[0].srcRaw = MIXSRC_MAX;
g_model.mixData[0].flightModes = 0;
g_model.mixData[0].weight = 250;
g_model.mixData[0].weight = makeSourceNumVal(250);
evalMixes(1);
simuSetSwitch(0, 1);
CHECK_FLIGHT_MODE_TRANSITION(0, 1000, 1024, 1024);
+2 -1
View File
@@ -153,7 +153,8 @@ void Choice::setValue(int val)
void Choice::onClicked()
{
openMenu();
if (!deleted())
openMenu();
}
void Choice::fillMenu(Menu* menu, const FilterFct& filter)