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