Rev 1159 | Rev 1161 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1157 | krheinwald | 1 | /* pitch_inc.c |
2 | * |
||
3 | * Copyright 2009 Klaus Rheinwald |
||
4 | * |
||
5 | */ |
||
6 | |||
7 | #include "main.h" |
||
8 | #include "parameter.h" |
||
9 | #include "fc.h" |
||
10 | #include "pitch.h" |
||
11 | |||
12 | #define STICK_FACTOR ((int16_t) 256) |
||
13 | |||
1159 | krheinwald | 14 | static int16_t stickValue = INT16_MIN; // Aktueller Stick-Wert |
1157 | krheinwald | 15 | |
16 | int pitch_inc_value( void ) { |
||
17 | |||
1159 | krheinwald | 18 | int32_t rawStickValue = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]]; |
1160 | krheinwald | 19 | // int16_t rawStickValue = PPM_in[EE_Parameter.Kanalbelegung[K_GAS]]; |
1157 | krheinwald | 20 | |
21 | DebugOut.Analog[25] = rawStickValue; |
||
22 | |||
1160 | krheinwald | 23 | // rawStickValue = ((rawStickValue * rawStickValue * rawStickValue) / (PARAM_INC_GAS_SCALE+1)) / (PARAM_INC_GAS_SCALE+1); |
24 | rawStickValue = (rawStickValue * rawStickValue * rawStickValue) / (PARAM_INC_GAS_SCALE+1); |
||
25 | // rawStickValue = (rawStickValue * rawStickValue) / ((rawStickValue > 0 ? PARAM_INC_GAS_SCALE : -PARAM_INC_GAS_SCALE) +1); |
||
1157 | krheinwald | 26 | |
27 | // Neuer Stick-Wert |
||
1159 | krheinwald | 28 | if (rawStickValue < 0 && stickValue < INT16_MIN - rawStickValue) // ToDo |
29 | stickValue = INT16_MIN; |
||
1157 | krheinwald | 30 | else if (rawStickValue > 0 && stickValue > INT16_MAX - rawStickValue ) |
31 | stickValue = INT16_MAX; |
||
32 | else if (rawStickValue != 0) |
||
33 | stickValue += rawStickValue; |
||
34 | |||
35 | DebugOut.Analog[26] = stickValue; |
||
36 | DebugOut.Analog[31] = stickValue / STICK_FACTOR; |
||
37 | |||
38 | return stickValue / STICK_FACTOR + 125; |
||
39 | } |
||
40 | |||
41 | void pitch_inc_init( void ) { |
||
42 | |||
43 | printf("\r\npitch_inc_init()"); |
||
44 | |||
1159 | krheinwald | 45 | stickValue = INT16_MIN; |
1157 | krheinwald | 46 | |
47 | pitchValueFP = pitch_inc_value; |
||
48 | } |
||
49 |