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