Rev 1137 | Rev 1141 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1134 | thjac | 1 | /* pitch.c |
2 | * |
||
3 | * Copyright 2009 Thomas Jachmann |
||
4 | * |
||
5 | * Pitch-Steuerung |
||
6 | */ |
||
7 | |||
8 | #include "main.h" |
||
9 | #include "parameter.h" |
||
10 | #include "pitch_neutral.h" |
||
11 | #include "pitch_md.h" |
||
12 | #include "pitch.h" |
||
13 | |||
14 | |||
1139 | thjac | 15 | unsigned char pitchMode; |
16 | |||
17 | char *pitchModeStrings[] = { |
||
18 | "Normal ", |
||
19 | "Neutral ", |
||
20 | "MD " |
||
21 | }; |
||
22 | |||
23 | |||
1134 | thjac | 24 | // Zeiger auf den durch das Setting bestimmten Pitch-Steuerungsalgorithmus |
25 | int (* pitch_value_ptr)( void ); |
||
26 | |||
27 | // Prototyp |
||
28 | int pitch_mk_value( void ); |
||
29 | |||
30 | /* |
||
31 | * Führt die Initialisierung der Pitch-Steuerung durch. Diese Funktion |
||
32 | * wird nach jeder Setting-Auswahl sowie nach jeder Setting-Änderung |
||
33 | * aufgerufen. |
||
34 | */ |
||
35 | void pitch_init( void ) { |
||
36 | |||
1139 | thjac | 37 | pitchMode = PARAM_PITCH_MODE; |
38 | |||
39 | pitch_md_init(); |
||
40 | |||
1134 | thjac | 41 | // FIXME Funktioniert noch nicht |
1139 | thjac | 42 | switch( pitchMode ) { |
1134 | thjac | 43 | case PARAM_PITCH_MODE_NEUTRAL: |
44 | pitch_value_ptr = pitch_neutral_value; |
||
45 | break; |
||
46 | |||
47 | case PARAM_PITCH_MODE_MD: |
||
48 | pitch_value_ptr = pitch_md_value; |
||
49 | break; |
||
50 | |||
51 | default: |
||
52 | pitch_value_ptr = pitch_mk_value; |
||
53 | } |
||
54 | |||
55 | // Hier können weitere Initialisierungen folgen |
||
56 | } |
||
57 | |||
58 | |||
59 | int pitch_value( void ) { |
||
1139 | thjac | 60 | switch( pitchMode ) { |
1134 | thjac | 61 | case PARAM_PITCH_MODE_NEUTRAL: |
62 | return pitch_neutral_value(); |
||
63 | |||
64 | case PARAM_PITCH_MODE_MD: |
||
65 | return pitch_md_value(); |
||
66 | |||
67 | default: |
||
68 | return pitch_mk_value(); |
||
69 | } |
||
70 | } |
||
71 | |||
72 | |||
73 | /* |
||
74 | * Führt eine Pitch-Berechnung aus, die der Original-SW entspricht. |
||
75 | */ |
||
76 | int pitch_mk_value( void ) { |
||
77 | register int stickValue = PPM_in[ EE_Parameter.Kanalbelegung[ K_GAS ] ]; |
||
1137 | krheinwald | 78 | register int pitchCount = stickValue + 120; // Warum 120? Gas= 0 ist -125 |
1134 | thjac | 79 | |
80 | DebugOut.Analog[26] = stickValue; |
||
81 | DebugOut.Analog[28] = pitchCount; |
||
82 | |||
83 | return pitchCount; |
||
84 | } |