1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-26 01:35:21 +03:00

Code maintainability

This commit is contained in:
bsongis 2012-10-24 12:44:57 +00:00
parent 6a35d36c0a
commit 20894baf69
2 changed files with 18 additions and 10 deletions

View file

@ -317,26 +317,25 @@ int16_t intpol(int16_t x, uint8_t idx) // -100, -75, -50, -25, 0 ,25 ,50, 75, 10
} }
#if defined(CURVES) #if defined(CURVES)
// TODO use an enum here and replace CURVE_BASE
int16_t applyCurve(int16_t x, int8_t idx) int16_t applyCurve(int16_t x, int8_t idx)
{ {
/* already tried to have only one return at the end */ /* already tried to have only one return at the end */
switch(idx) { switch(idx) {
case 0: case CURVE_NONE:
return x; return x;
case 1: case CURVE_X_GT0:
if (x < 0) x = 0; //x|x>0 if (x < 0) x = 0; //x|x>0
return x; return x;
case 2: case CURVE_X_LT0:
if (x > 0) x = 0; //x|x<0 if (x > 0) x = 0; //x|x<0
return x; return x;
case 3: // x|abs(x) case CURVE_ABS_X: // x|abs(x)
return abs(x); return abs(x);
case 4: //f|f>0 case CURVE_F_GT0: //f|f>0
return x > 0 ? RESX : 0; return x > 0 ? RESX : 0;
case 5: //f|f<0 case CURVE_F_LT0: //f|f<0
return x < 0 ? -RESX : 0; return x < 0 ? -RESX : 0;
case 6: //f|abs(f) case CURVE_ABS_F: //f|abs(f)
return x > 0 ? RESX : -RESX; return x > 0 ? RESX : -RESX;
} }
if (idx < 0) { if (idx < 0) {
@ -1754,7 +1753,7 @@ BeepANACenter evalSticks()
{ {
BeepANACenter anaCenter = 0; BeepANACenter anaCenter = 0;
#ifdef HELI #if defined(HELI)
uint16_t d = 0; uint16_t d = 0;
if (g_model.swashR.value) { if (g_model.swashR.value) {
uint32_t v = (int32_t(calibratedStick[ELE_STICK])*calibratedStick[ELE_STICK] + uint32_t v = (int32_t(calibratedStick[ELE_STICK])*calibratedStick[ELE_STICK] +

View file

@ -480,7 +480,16 @@ public:
extern Key keys[NUM_KEYS]; extern Key keys[NUM_KEYS];
#define CURVE_BASE 7 enum BaseCurves {
CURVE_NONE,
CURVE_X_GT0,
CURVE_X_LT0,
CURVE_ABS_X,
CURVE_F_GT0,
CURVE_F_LT0,
CURVE_ABS_F,
CURVE_BASE
};
#define SWASH_TYPE_120 1 #define SWASH_TYPE_120 1
#define SWASH_TYPE_120X 2 #define SWASH_TYPE_120X 2