Rev 1136 | Rev 1139 | 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 | |||
15 | // Zeiger auf den durch das Setting bestimmten Pitch-Steuerungsalgorithmus |
||
16 | int (* pitch_value_ptr)( void ); |
||
17 | |||
18 | // Prototyp |
||
19 | int pitch_mk_value( void ); |
||
20 | |||
21 | /* |
||
22 | * Führt die Initialisierung der Pitch-Steuerung durch. Diese Funktion |
||
23 | * wird nach jeder Setting-Auswahl sowie nach jeder Setting-Änderung |
||
24 | * aufgerufen. |
||
25 | */ |
||
26 | void pitch_init( void ) { |
||
27 | |||
28 | // FIXME Funktioniert noch nicht |
||
29 | switch( PARAM_PITCH_MODE ) { |
||
30 | case PARAM_PITCH_MODE_NEUTRAL: |
||
31 | pitch_value_ptr = pitch_neutral_value; |
||
32 | break; |
||
33 | |||
34 | case PARAM_PITCH_MODE_MD: |
||
35 | pitch_value_ptr = pitch_md_value; |
||
36 | break; |
||
37 | |||
38 | default: |
||
39 | pitch_value_ptr = pitch_mk_value; |
||
40 | } |
||
41 | |||
42 | // Hier können weitere Initialisierungen folgen |
||
43 | } |
||
44 | |||
45 | |||
46 | int pitch_value( void ) { |
||
47 | switch( PARAM_PITCH_MODE ) { |
||
48 | case PARAM_PITCH_MODE_NEUTRAL: |
||
49 | return pitch_neutral_value(); |
||
50 | |||
51 | case PARAM_PITCH_MODE_MD: |
||
52 | return pitch_md_value(); |
||
53 | |||
54 | default: |
||
55 | return pitch_mk_value(); |
||
56 | } |
||
57 | } |
||
58 | |||
59 | |||
60 | /* |
||
61 | * Führt eine Pitch-Berechnung aus, die der Original-SW entspricht. |
||
62 | */ |
||
63 | int pitch_mk_value( void ) { |
||
64 | register int stickValue = PPM_in[ EE_Parameter.Kanalbelegung[ K_GAS ] ]; |
||
1137 | krheinwald | 65 | register int pitchCount = stickValue + 120; // Warum 120? Gas= 0 ist -125 |
1134 | thjac | 66 | |
67 | DebugOut.Analog[26] = stickValue; |
||
68 | DebugOut.Analog[28] = pitchCount; |
||
69 | |||
70 | return pitchCount; |
||
71 | } |