Rev 1141 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1141 | Rev 1157 | ||
---|---|---|---|
Line 7... | Line 7... | ||
7 | 7 | ||
8 | #include "main.h" |
8 | #include "main.h" |
9 | #include "parameter.h" |
9 | #include "parameter.h" |
10 | #include "pitch_neutral.h" |
10 | #include "pitch_neutral.h" |
- | 11 | #include "pitch_md.h" |
|
11 | #include "pitch_md.h" |
12 | #include "pitch_inc.h" |
Line 12... | Line 13... | ||
12 | #include "pitch.h" |
13 | #include "pitch.h" |
13 | 14 | ||
Line 20... | Line 21... | ||
20 | 21 | ||
21 | char *pitchModeStrings[] = { |
22 | char *pitchModeStrings[] = { |
22 | "Normal ", |
23 | "Normal ", |
23 | "Neutral ", |
24 | "Neutral ", |
- | 25 | "MD ", |
|
- | 26 | "Increment" |
|
- | 27 | "Undefined", |
|
- | 28 | "Undefined", |
|
24 | "MD ", |
29 | "Undefined", |
25 | "Inaktiv " |
30 | "Invalid ", |
Line 26... | Line 31... | ||
26 | }; |
31 | }; |
27 | 32 | ||
Line 28... | Line 33... | ||
28 | 33 | ||
- | 34 | // Zeiger auf den durch das Setting bestimmten Pitch-Steuerungsalgorithmus |
|
29 | // Zeiger auf den durch das Setting bestimmten Pitch-Steuerungsalgorithmus |
35 | int (* pitchValueFP)( void ); |
Line 30... | Line 36... | ||
30 | int (* pitch_value_ptr)( void ); |
36 | |
31 | 37 | // Prototyp |
|
32 | // Prototyp |
38 | void pitch_mk_init( void ); |
33 | int pitch_mk_value( void ); |
39 | int pitch_mk_value( void ); |
34 | 40 | ||
35 | /* |
41 | /* |
Line -... | Line 42... | ||
- | 42 | * Führt die Initialisierung der Pitch-Steuerung durch. Diese Funktion |
|
- | 43 | * wird nach jeder Setting-Auswahl sowie nach jeder Setting-Änderung |
|
- | 44 | * aufgerufen. |
|
- | 45 | */ |
|
36 | * Führt die Initialisierung der Pitch-Steuerung durch. Diese Funktion |
46 | void pitch_init( void ) { |
37 | * wird nach jeder Setting-Auswahl sowie nach jeder Setting-Änderung |
47 | |
Line 38... | Line 48... | ||
38 | * aufgerufen. |
48 | |
39 | */ |
49 | pitchMode = PARAM_PITCH_MODE; |
40 | void pitch_init( void ) { |
50 | pitchValueFP = pitch_mk_value; // Reasonable default |
Line 41... | Line 51... | ||
41 | 51 | ||
42 | // Nur beim Einschalten ermitteln, da beim Setting-Wechsel ungültig |
52 | // Nur beim Einschalten ermitteln, da beim Setting-Wechsel ungültig |
Line 43... | Line -... | ||
43 | if( pitchInitialStickValue == UNDEFINED ) { |
- | |
44 | - | ||
45 | // Warten, bis ein gültiger Wert von der Fernsteuerung anliegt |
53 | if( pitchInitialStickValue == UNDEFINED ) { |
46 | unsigned int timer = SetDelay( 500 ); |
54 | |
47 | while( !CheckDelay( timer ) ); |
55 | // Warten, bis ein gültiger Wert von der Fernsteuerung anliegt |
48 | 56 | unsigned int timer = SetDelay( 500 ); |
|
- | 57 | while( !CheckDelay( timer ) ); |
|
49 | pitchInitialStickValue = PPM_in[ EE_Parameter.Kanalbelegung[ K_GAS ] ]; |
58 | |
50 | } |
59 | pitchInitialStickValue = PPM_in[ EE_Parameter.Kanalbelegung[ K_GAS ] ]; |
51 | 60 | } |
|
- | 61 | ||
52 | pitchMode = PARAM_PITCH_MODE; |
62 | /* Die Stick-Position beim Einschalten muß mit dem im Setting eingestellten |
- | 63 | * Pitch-Modus übereinstimmen. Sonst wird die Pitch-Steuerung aus Sicherheits- |
|
53 | 64 | * gründen deaktiviert. Selbiges gilt, wenn die Höhenregelung deaktiviert wurde. |
|
54 | /* Die Stick-Position beim Einschalten muß mit dem im Setting eingestellten |
65 | */ |
- | 66 | ||
- | 67 | switch( pitchMode ) { |
|
- | 68 | // Pitch-Modi mit neutralisiertem Gas |
|
- | 69 | case PARAM_PITCH_MODE_NEUTRAL: |
|
- | 70 | printf("\r\nPARAM_PITCH_MODE_NEUTRAL\r\n"); |
|
- | 71 | case PARAM_PITCH_MODE_MD: |
|
- | 72 | printf("\r\nPARAM_PITCH_MODE_MD\r\n"); |
|
- | 73 | if( !( EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG ) || abs( pitchInitialStickValue ) > PARAM_PITCH_STICK_THRESHOLD ) |
|
- | 74 | pitchMode = PARAM_PITCH_MODE_INVALID; |
|
- | 75 | else { |
|
- | 76 | if( pitchMode == PARAM_PITCH_MODE_NEUTRAL) |
|
55 | * Pitch-Modus übereinstimmen. Sonst wird die Pitch-Steuerung aus Sicherheits- |
77 | pitch_neutral_init(); |
56 | * gründen deaktiviert. Selbiges gilt, wenn die Höhenregelung deaktiviert wurde. |
78 | else if( pitchMode == PARAM_PITCH_MODE_MD) |
- | 79 | pitch_md_init(); |
|
- | 80 | } |
|
57 | */ |
81 | break; |
Line 58... | Line 82... | ||
58 | switch( pitchMode ) { |
82 | |
59 | // Pitch-Modi mit neutralisiertem Gas |
83 | // Pitch-Modi mit incrementellem Gas |
- | 84 | case PARAM_PITCH_MODE_INC: |
|
60 | case PARAM_PITCH_MODE_NEUTRAL: |
85 | printf("\r\nPARAM_PITCH_MODE_INC\r\n"); |
61 | case PARAM_PITCH_MODE_MD: |
86 | if( abs( pitchInitialStickValue ) > PARAM_PITCH_STICK_THRESHOLD ) |
- | 87 | pitchMode = PARAM_PITCH_MODE_INVALID; |
|
- | 88 | else |
|
62 | if( !( EE_Parameter.GlobalConfig & CFG_HOEHENREGELUNG ) ) |
89 | pitch_inc_init(); |
63 | pitchMode = PARAM_PITCH_MODE_INVALID; |
90 | break; |
Line 64... | Line 91... | ||
64 | if( abs( pitchInitialStickValue ) > PARAM_PITCH_STICK_THRESHOLD ) |
91 | |
65 | pitchMode = PARAM_PITCH_MODE_INVALID; |
92 | // Pitch-Modi mit 0-Gas |
- | 93 | case PARAM_PITCH_MODE_NORMAL: |
|
Line -... | Line 94... | ||
- | 94 | printf("\r\nPARAM_PITCH_MODE_NORMAL\r\n"); |
|
66 | break; |
95 | if( pitchInitialStickValue > 35 - 120 ) |
67 | 96 | pitchMode = PARAM_PITCH_MODE_INVALID; |
|
68 | // Pitch-Modi mit 0-Gas |
97 | else |
69 | case PARAM_PITCH_MODE_NORMAL: |
98 | pitch_mk_init(); |
70 | if( pitchInitialStickValue > 35 - 120 ) |
99 | break; |
Line 71... | Line 100... | ||
71 | pitchMode = PARAM_PITCH_MODE_INVALID; |
100 | } |
72 | break; |
101 | |
- | 102 | if( pitchMode == PARAM_PITCH_MODE_INVALID) |
|
- | 103 | printf("\r\nPARAM_PITCH_MODE_INVALID, stick: %d\r\n", pitchInitialStickValue); //TODO |
|
- | 104 | ||
- | 105 | ||
73 | } |
106 | /* |
Line 74... | Line 107... | ||
74 | 107 | // Moved to pitch_xxx_init() |
|
75 | pitch_neutral_init(); |
108 | switch( pitchMode ) { |
76 | pitch_md_init(); |
109 | case PARAM_PITCH_MODE_NEUTRAL: |
- | 110 | pitch_value_ptr = &pitch_neutral_value; |
|
Line 77... | Line 111... | ||
77 | 111 | break; |
|
78 | // FIXME Funktioniert noch nicht |
112 | |
Line -... | Line 113... | ||
- | 113 | case PARAM_PITCH_MODE_MD: |
|
79 | switch( pitchMode ) { |
114 | pitch_value_ptr = &pitch_md_value; |
- | 115 | break; |
|
80 | case PARAM_PITCH_MODE_NEUTRAL: |
116 | |
81 | pitch_value_ptr = pitch_neutral_value; |
117 | case PARAM_PITCH_MODE_INC: |
82 | break; |
118 | pitch_value_ptr = &pitch_inc_value; |
Line 83... | Line 119... | ||
83 | 119 | break; |
|
84 | case PARAM_PITCH_MODE_MD: |
120 | |
Line 85... | Line 121... | ||
85 | pitch_value_ptr = pitch_md_value; |
121 | default: |
86 | break; |
122 | pitch_value_ptr = &pitch_mk_value; |
Line -... | Line 123... | ||
- | 123 | } |
|
- | 124 | */ |
|
- | 125 | ||
- | 126 | // Hier können weitere Initialisierungen folgen |
|
87 | 127 | } |
|
88 | default: |
128 | |
89 | pitch_value_ptr = pitch_mk_value; |
129 | |
- | 130 | /* |
|
- | 131 | int pitch_value( void ) { // -> int (* pitch_value)( void ); |
|
- | 132 | ||
- | 133 | switch( pitchMode ) { |
|
90 | } |
134 | case PARAM_PITCH_MODE_NEUTRAL: |
- | 135 | return pitch_neutral_value(); |
|
Line 91... | Line 136... | ||
91 | 136 | ||
92 | // Hier können weitere Initialisierungen folgen |
137 | case PARAM_PITCH_MODE_MD: |
93 | } |
138 | return pitch_md_value(); |
Line 120... | Line 165... | ||
120 | DebugOut.Analog[26] = stickValue; |
165 | DebugOut.Analog[26] = stickValue; |
121 | DebugOut.Analog[28] = pitchCount; |
166 | DebugOut.Analog[28] = pitchCount; |
Line 122... | Line 167... | ||
122 | 167 | ||
123 | return pitchCount; |
168 | return pitchCount; |
- | 169 | } |
|
- | 170 | ||
- | 171 | void pitch_mk_init( void ) { |
|
- | 172 | ||
- | 173 | printf("\r\npitch_mk_init()"); |
|
- | 174 | ||
- | 175 | pitchValueFP = pitch_mk_value; |
|
- | 176 | } |
|
- | 177 |