Subversion Repositories FlightCtrl

Rev

Rev 1112 | Rev 1118 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1112 Rev 1114
Line 1... Line 1...
1
#include <inttypes.h>
1
#include <inttypes.h>
2
#include "main.h"
2
#include "main.h"
3
#include "parameter.h"
3
#include "parameter.h"
Line 4... Line 4...
4
 
4
 
5
uint16_t        LED1_Timing = 0;
5
uint16_t        LED1_Timing   = 0;
Line 6... Line 6...
6
uint16_t        LED2_Timing = 0;
6
uint16_t        LED2_Timing   = 0;
7
 
7
 
Line 8... Line 8...
8
unsigned char   J16Blinkcount = 0, J16Mask = 1;
8
unsigned char   J16Blinkcount = 0, J16Mask = 1;
-
 
9
unsigned char   J17Blinkcount = 0, J17Mask = 1;
Line 9... Line 10...
9
unsigned char   J17Blinkcount = 0, J17Mask = 1;
10
 
Line -... Line 11...
-
 
11
unsigned char   lightsEnabled = 0;
-
 
12
unsigned char   forceEnabled = 0;
-
 
13
 
-
 
14
extern char     MotorenEin;
-
 
15
 
-
 
16
 
-
 
17
void setJ16( char enabled ) {
-
 
18
        if( PARAM_LED_NEGATE )
-
 
19
                enabled = !enabled;
-
 
20
        if( enabled && forceEnabled )
-
 
21
                J16_ON;
-
 
22
        else
-
 
23
                J16_OFF;
-
 
24
}
-
 
25
 
-
 
26
void setJ17( char enabled ) {
-
 
27
        if( PARAM_LED_NEGATE )
-
 
28
                enabled = !enabled;
10
 
29
        if( enabled && forceEnabled )
11
unsigned char   lightsEnabled = 0;
30
                J17_ON;
12
 
31
        else
13
extern char     MotorenEin;
32
                J17_OFF;
14
 
33
}
15
 
34
 
16
// initializes the LED control outputs J16, J17
35
// initializes the LED control outputs J16, J17
17
void LED_Init( void ) {
36
void LED_Init( void ) {
18
        // set PC2 & PC3 as output (control of J16 & J17)
37
        // set PC2 & PC3 as output (control of J16 & J17)
Line 19... Line 38...
19
        DDRC |= (1<<DDC2)|(1<<DDC3);
38
        DDRC |= (1<<DDC2)|(1<<DDC3);
20
        J16_OFF;
39
        setJ16( 0 );
Line 21... Line 40...
21
        J17_OFF;
40
        setJ17( 0 );
22
        J16Blinkcount = 0; J16Mask = 128;
41
        J16Blinkcount = 0; J16Mask = 128;
23
        J17Blinkcount = 0; J17Mask = 128;
42
        J17Blinkcount = 0; J17Mask = 128;
Line 24... Line 43...
24
}
43
}
25
 
44
 
26
 
45
 
Line 52... Line 71...
52
        }
71
        }
Line 53... Line 72...
53
       
72
       
54
        if( PARAM_LED_ENGINE_ENABLED ) {
73
        if( PARAM_LED_ENGINE_ENABLED ) {
55
                lightsEnabled = MotorenEin;
74
                lightsEnabled = MotorenEin;
56
        }
75
        }
-
 
76
 
-
 
77
        forceEnabled = lightsEnabled;
57
       
78
               
Line 58... Line 79...
58
        if( !delay-- ) {
79
        if( !delay-- ) {
Line 59... Line 80...
59
 
80
 
60
                delay = 4;      // 10ms Intervall
81
                delay = 4;      // 10ms Intervall
Line 61... Line 82...
61
 
82
 
62
                // Soll die Unterspannungswarnung zu einem schnelleren Blinken führen?
83
                // Soll die Unterspannungswarnung zu einem schnelleren Blinken führen?
Line -... Line 84...
-
 
84
                if( PARAM_LED_WARNING_ENABLED ) {
-
 
85
               
-
 
86
                        // Grenze für Unterspannungswarnung erreicht?
-
 
87
                        if( UBat < EE_Parameter.UnterspannungsWarnung ) {
-
 
88
                       
-
 
89
                                // Erzwingt die Aktivierung der Ausgänge
-
 
90
                                if( PARAM_LED_FORCE_WARNING_ENABLED )
63
                if( PARAM_LED_WARNING_ENABLED ) {
91
                                        forceEnabled = 1;
-
 
92
                               
64
               
93
                                if( PARAM_LED_WARNING_FAST_ENABLED ) {
65
                        // Grenze für Unterspannungswarnung erreicht?
94
                                        delay = 1;      // 2,5ms Intervall
Line 66... Line 95...
66
                        if( UBat < EE_Parameter.UnterspannungsWarnung ) {
95
                                } else {
67
                       
96
                                        delay = 2;      // 5ms Intervall
68
                                delay = 2;      // 5ms Intervall
97
                                }
69
                        }
98
                        }
70
                }
-
 
71
               
-
 
72
                /* J16
-
 
73
                 */
99
                }
74
                if( ( EE_Parameter.J16Timing > 250 ) && ( Parameter_J16Timing > 230 ) ) {
100
               
75
                        if( EE_Parameter.J16Bitmask & 128 )
-
 
76
                                J16_ON;
-
 
77
                        else
-
 
78
                                J16_OFF;
101
                /* J16
Line 79... Line 102...
79
                } else if( ( EE_Parameter.J16Timing > 250 ) && ( Parameter_J16Timing < 10 ) ) {
102
                 */
Line 80... Line 103...
80
                        if( EE_Parameter.J16Bitmask & 128 )
103
                if( ( EE_Parameter.J16Timing > 250 ) && ( Parameter_J16Timing > 230 ) ) {
81
                                J16_OFF;
104
                        setJ16( EE_Parameter.J16Bitmask & 128 );
82
                        else
105
                } else if( ( EE_Parameter.J16Timing > 250 ) && ( Parameter_J16Timing < 10 ) ) {
83
                                J16_ON;
106
                        setJ16( !( EE_Parameter.J16Bitmask & 128 ) );
84
                } else if( !J16Blinkcount-- ) {
107
                } else if( !J16Blinkcount-- ) {
85
               
-
 
86
                        J16Blinkcount = Parameter_J16Timing-1;
-
 
87
                       
-
 
88
                        if( J16Mask == 1 )
108
               
Line 89... Line 109...
89
                                J16Mask = 128;
109
                        J16Blinkcount = Parameter_J16Timing-1;
90
                        else
110
                       
91
                                J16Mask /= 2;
111
                        if( J16Mask == 1 )
92
                        if( J16Mask & EE_Parameter.J16Bitmask )
112
                                J16Mask = 128;
93
                                J16_ON;
-
 
94
                        else
-
 
95
                                J16_OFF;
-
 
96
                }  
113
                        else
97
               
114
                                J16Mask /= 2;
98
                /* J17
-
 
99
                 */
-
 
100
                if( ( EE_Parameter.J17Timing > 250 ) && ( Parameter_J17Timing > 230 ) ) {
-
 
101
                        if( EE_Parameter.J17Bitmask & 128 )
115
                        setJ16( J16Mask & EE_Parameter.J16Bitmask );
Line 102... Line 116...
102
                                J17_ON;
116
                }  
Line 103... Line 117...
103
                        else
117
               
104
                                J17_OFF;
118
                /* J17
105
                } else if( ( EE_Parameter.J17Timing > 250 ) && ( Parameter_J17Timing < 10 ) ) {
119
                 */
106
                        if( EE_Parameter.J17Bitmask & 128 )
120
                if( ( EE_Parameter.J17Timing > 250 ) && ( Parameter_J17Timing > 230 ) ) {
107
                                J17_OFF;
121
                        setJ17( EE_Parameter.J17Bitmask & 128 );
108
                        else
-
 
109
                                J17_ON;
-
 
110
                } else if( !J17Blinkcount-- ) {
-
 
111
               
122
                } else if( ( EE_Parameter.J17Timing > 250 ) && ( Parameter_J17Timing < 10 ) ) {
112
                        J17Blinkcount = Parameter_J17Timing-1;
123
                        setJ17( !( EE_Parameter.J17Bitmask & 128 ) );
113
                       
-
 
114
                        if( J17Mask == 1 )
-
 
115
                                J17Mask = 128;
-
 
116
                        else
-
 
117
                                J17Mask /= 2;
-
 
118
                        if( J17Mask & EE_Parameter.J17Bitmask )
-
 
119
                                J17_ON;
124
                } else if( !J17Blinkcount-- ) {