Possibility to remove completely the CURVES Menu and calculations (CURVES=NO Makefile option)
This commit is contained in:
@@ -144,6 +144,10 @@ DEBUG = NO
|
||||
# Values = YES, NO
|
||||
FLIGHT_PHASES = YES
|
||||
|
||||
# Curves
|
||||
# Values = YES, NO
|
||||
CURVES = YES
|
||||
|
||||
# Customizable Curves
|
||||
# Values = YES, NO
|
||||
XCURVES = YES
|
||||
@@ -285,6 +289,10 @@ ifeq ($(FLIGHT_PHASES), YES)
|
||||
CPPDEFS += -DFLIGHT_PHASES
|
||||
endif
|
||||
|
||||
ifeq ($(CURVES), YES)
|
||||
CPPDEFS += -DCURVES
|
||||
endif
|
||||
|
||||
ifeq ($(XCURVES), YES)
|
||||
CPPDEFS += -DXCURVES
|
||||
endif
|
||||
|
||||
+23
-6
@@ -49,7 +49,9 @@ enum EnumTabModel {
|
||||
e_ExposAll,
|
||||
e_MixAll,
|
||||
e_Limits,
|
||||
#ifdef CURVES
|
||||
e_CurvesAll,
|
||||
#endif
|
||||
e_CustomSwitches,
|
||||
e_FunctionSwitches,
|
||||
#ifdef FRSKY
|
||||
@@ -94,7 +96,9 @@ const MenuFuncP_PROGMEM menuTabModel[] PROGMEM = {
|
||||
menuProcExposAll,
|
||||
menuProcMixAll,
|
||||
menuProcLimits,
|
||||
#ifdef CURVES
|
||||
menuProcCurvesAll,
|
||||
#endif
|
||||
menuProcCustomSwitches,
|
||||
menuProcFunctionSwitches,
|
||||
#ifdef FRSKY
|
||||
@@ -1062,8 +1066,6 @@ void menuProcHeli(uint8_t event)
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint8_t s_curveChan;
|
||||
|
||||
typedef int16_t (*FnFuncP) (int16_t x);
|
||||
|
||||
int16_t expoFn(int16_t x)
|
||||
@@ -1075,10 +1077,13 @@ int16_t expoFn(int16_t x)
|
||||
return anas[ed->chn];
|
||||
}
|
||||
|
||||
#if defined(CURVES)
|
||||
static uint8_t s_curveChan;
|
||||
int16_t curveFn(int16_t x)
|
||||
{
|
||||
return intpol(x, s_curveChan);
|
||||
}
|
||||
#endif
|
||||
|
||||
void DrawCurve(FnFuncP fn)
|
||||
{
|
||||
@@ -1092,9 +1097,10 @@ void DrawCurve(FnFuncP fn)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CURVES)
|
||||
bool moveCurve(uint8_t index, int8_t shift, int8_t custom=0)
|
||||
{
|
||||
if (g_model.curves[MAX_CURVES-1] + shift > NUM_POINTS-5*MAX_CURVES) {
|
||||
if (g_model.curves[MAX_CURVES-1] + shift > NUM_POINTS-CURVES_OFFSET_SHIFT(MAX_CURVES)) {
|
||||
AUDIO_WARNING2();
|
||||
return false;
|
||||
}
|
||||
@@ -1106,7 +1112,7 @@ bool moveCurve(uint8_t index, int8_t shift, int8_t custom=0)
|
||||
}
|
||||
|
||||
int8_t *nextCrv = curveaddress(index+1);
|
||||
memmove(nextCrv+shift, nextCrv, 5*(MAX_CURVES-index-1)+g_model.curves[MAX_CURVES-1]);
|
||||
memmove(nextCrv+shift, nextCrv, CURVES_OFFSET_SHIFT(MAX_CURVES-index-1)+g_model.curves[MAX_CURVES-1]);
|
||||
if (shift < 0) memclear(&g_model.points[NUM_POINTS-1] + shift, -shift);
|
||||
while (index<MAX_CURVES)
|
||||
g_model.curves[index++] += shift;
|
||||
@@ -1239,6 +1245,7 @@ void menuProcCurveOne(uint8_t event)
|
||||
|
||||
DrawCurve(curveFn);
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t getExpoMixCount(uint8_t expo)
|
||||
{
|
||||
@@ -1436,7 +1443,9 @@ enum ExposFields {
|
||||
#endif
|
||||
EXPO_FIELD_WIDTH,
|
||||
EXPO_FIELD_EXPO,
|
||||
#ifdef CURVES
|
||||
EXPO_FIELD_CURVE,
|
||||
#endif
|
||||
#ifdef FLIGHT_PHASES
|
||||
EXPO_FIELD_FLIGHT_PHASE,
|
||||
#endif
|
||||
@@ -1483,6 +1492,7 @@ void menuProcExpoOne(uint8_t event)
|
||||
lcd_outdezAtt(9*FW+5, y, ed->expo, attr|INFLIGHT(ed->expo));
|
||||
if (attr) CHECK_INFLIGHT_INCDEC_MODELVAR(event, ed->expo, -100, 100, 0, STR_DREXPO);
|
||||
break;
|
||||
#ifdef CURVES
|
||||
case EXPO_FIELD_CURVE:
|
||||
putsCurve(6*FW+5, y, ed->curve, attr);
|
||||
if (attr) {
|
||||
@@ -1493,6 +1503,7 @@ void menuProcExpoOne(uint8_t event)
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef FLIGHT_PHASES
|
||||
case EXPO_FIELD_FLIGHT_PHASE:
|
||||
{
|
||||
@@ -1543,9 +1554,11 @@ enum MixFields {
|
||||
MIX_FIELD_DIFFERENTIAL,
|
||||
MIX_FIELD_OFFSET,
|
||||
MIX_FIELD_TRIM,
|
||||
#if defined(CURVES)
|
||||
MIX_FIELD_CURVE,
|
||||
#endif
|
||||
MIX_FIELD_SWITCH,
|
||||
#ifdef FLIGHT_PHASES
|
||||
#if defined(FLIGHT_PHASES)
|
||||
MIX_FIELD_FLIGHT_PHASE,
|
||||
#endif
|
||||
MIX_FIELD_WARNING,
|
||||
@@ -1614,6 +1627,7 @@ void menuProcMixOne(uint8_t event)
|
||||
if (attr) md2->carryTrim = -checkIncDecModel(event, carryTrim, not_stick ? TRIM_ON : -TRIM_OFF, -TRIM_AIL);
|
||||
break;
|
||||
}
|
||||
#if defined(CURVES)
|
||||
case MIX_FIELD_CURVE:
|
||||
lcd_putsLeft(y, STR_CURVES);
|
||||
putsCurve(MIXES_2ND_COLUMN, y, md2->curve, attr);
|
||||
@@ -1623,12 +1637,13 @@ void menuProcMixOne(uint8_t event)
|
||||
pushMenu(menuProcCurveOne);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case MIX_FIELD_SWITCH:
|
||||
lcd_putsLeft(y, STR_SWITCH);
|
||||
putsSwitches(MIXES_2ND_COLUMN, y,md2->swtch,attr);
|
||||
if(attr) CHECK_INCDEC_MODELSWITCH( event, md2->swtch, -MAX_SWITCH, MAX_SWITCH);
|
||||
break;
|
||||
#ifdef FLIGHT_PHASES
|
||||
#if defined(FLIGHT_PHASES)
|
||||
case MIX_FIELD_FLIGHT_PHASE:
|
||||
lcd_putsLeft(y, STR_FPHASE);
|
||||
putsFlightPhase(MIXES_2ND_COLUMN, y, md2->phase, attr);
|
||||
@@ -2140,6 +2155,7 @@ void menuProcLimits(uint8_t _event)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(CURVES)
|
||||
void menuProcCurvesAll(uint8_t event)
|
||||
{
|
||||
SIMPLE_MENU(STR_MENUCURVES, menuTabModel, e_CurvesAll, 1+MAX_CURVES);
|
||||
@@ -2173,6 +2189,7 @@ void menuProcCurvesAll(uint8_t event)
|
||||
s_curveChan = sub;
|
||||
DrawCurve(curveFn);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PCBARM)
|
||||
enum CustomSwitchFields {
|
||||
|
||||
+4
-2
@@ -592,10 +592,12 @@ PACK(typedef struct t_PhaseData {
|
||||
|
||||
#if defined(PCBARM)
|
||||
#define MAX_CURVES 16
|
||||
#define NUM_POINTS 256
|
||||
#define NUM_POINTS 512
|
||||
#define CURVTYPE uint16_t
|
||||
#else
|
||||
#define MAX_CURVES 8
|
||||
#define NUM_POINTS (112-MAX_CURVES)
|
||||
#define CURVTYPE int8_t
|
||||
#endif
|
||||
|
||||
#define MIN_POINTS 3
|
||||
@@ -676,7 +678,7 @@ PACK(typedef struct t_ModelData {
|
||||
LimitData limitData[NUM_CHNOUT];
|
||||
ExpoData expoData[MAX_EXPOS];
|
||||
|
||||
int8_t curves[MAX_CURVES];
|
||||
CURVTYPE curves[MAX_CURVES];
|
||||
int8_t points[NUM_POINTS];
|
||||
|
||||
CustomSwData customSw[NUM_CSW];
|
||||
|
||||
@@ -162,10 +162,18 @@ LimitData *limitaddress(uint8_t idx)
|
||||
return &g_model.limitData[idx];
|
||||
}
|
||||
|
||||
#if defined(PCBARM)
|
||||
int8_t *curveaddress(uint8_t idx)
|
||||
{
|
||||
return &g_model.points[idx==0 ? 0 : g_model.curves[idx-1]];
|
||||
}
|
||||
#else
|
||||
int8_t *curveaddress(uint8_t idx)
|
||||
{
|
||||
return &g_model.points[idx==0 ? 0 : 5*idx+g_model.curves[idx-1]];
|
||||
}
|
||||
#endif
|
||||
|
||||
CurveInfo curveinfo(uint8_t idx)
|
||||
{
|
||||
CurveInfo result;
|
||||
@@ -299,6 +307,7 @@ int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 10
|
||||
return erg / 25; // 100*D5/RESX;
|
||||
}
|
||||
|
||||
#if defined(CURVES)
|
||||
int16_t applyCurve(int16_t x, int8_t idx)
|
||||
{
|
||||
/* already tried to have only one return at the end */
|
||||
@@ -326,6 +335,9 @@ int16_t applyCurve(int16_t x, int8_t idx)
|
||||
}
|
||||
return intpol(x, idx - 7);
|
||||
}
|
||||
#else
|
||||
#define applyCurve(x, idx) (x)
|
||||
#endif
|
||||
|
||||
// expo-funktion:
|
||||
// ---------------
|
||||
|
||||
@@ -819,6 +819,12 @@ struct CurveInfo {
|
||||
};
|
||||
extern CurveInfo curveinfo(uint8_t idx);
|
||||
|
||||
#if defined(PCBARM)
|
||||
#define CURVES_OFFSET_SHIFT(x) (0)
|
||||
#else
|
||||
#define CURVES_OFFSET_SHIFT(x) (5*(x))
|
||||
#endif
|
||||
|
||||
extern void deleteExpoMix(uint8_t expo, uint8_t idx);
|
||||
|
||||
extern void incSubtrim(uint8_t idx, int16_t inc);
|
||||
|
||||
+7
-2
@@ -27,8 +27,10 @@ def generate(str, idx, alternate=0):
|
||||
if "speak" in sys.argv:
|
||||
if "sapi" in sys.argv:
|
||||
tts.Speak(str)
|
||||
else:
|
||||
elif "espeak" in sys.argv:
|
||||
subprocess.Popen(["espeak", "-v", espeakVoice, "-s", espeakspeed, "-z", str.encode("latin-1")], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
|
||||
else:
|
||||
print "which speach engine?"
|
||||
else:
|
||||
if isinstance(idx, int):
|
||||
result = "%04d.wav" % idx
|
||||
@@ -54,8 +56,11 @@ def generate(str, idx, alternate=0):
|
||||
o.writeframes(f[6400:-6400])
|
||||
o.close()
|
||||
os.remove(temp)
|
||||
else:
|
||||
elif "espeak" in sys.argv:
|
||||
subprocess.Popen(["espeak", "-v", espeakVoice, "-s", espeakspeed, "-z", "-w", result, str.encode("latin-1")], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
|
||||
else:
|
||||
print "which speach engine?"
|
||||
return []
|
||||
|
||||
if 'ad4' in sys.argv:
|
||||
subprocess.Popen(["AD4CONVERTER", "-E4", result], stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
|
||||
|
||||
Reference in New Issue
Block a user