Rev 1378 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1378 | Rev 1550 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "main.h" |
1 | #include "main.h" |
2 | #include "spectrum.h" |
- | |
- | 2 | ||
Line 3... | Line 3... | ||
3 | 3 | ||
4 | volatile unsigned int CountMilliseconds = 0; |
4 | volatile unsigned int CountMilliseconds = 0; |
5 | volatile static unsigned int tim_main; |
5 | volatile static unsigned int tim_main; |
6 | volatile unsigned char UpdateMotor = 0; |
6 | volatile unsigned char UpdateMotor = 0; |
Line 29... | Line 29... | ||
29 | SIGNAL (SIG_OVERFLOW0) // 9,7kHz |
29 | SIGNAL (SIG_OVERFLOW0) // 9,7kHz |
30 | { |
30 | { |
31 | static unsigned char cnt_1ms = 1,cnt = 0; |
31 | static unsigned char cnt_1ms = 1,cnt = 0; |
32 | unsigned char pieper_ein = 0; |
32 | unsigned char pieper_ein = 0; |
33 | if(SendSPI) SendSPI--; |
33 | if(SendSPI) SendSPI--; |
34 | if(SpektrumTimer) SpektrumTimer--; |
34 | if(SpektrumTimer) SpektrumTimer--; |
Line 35... | Line 35... | ||
35 | 35 | ||
36 | if(!cnt--) |
36 | if(!cnt--) |
37 | { |
37 | { |
38 | cnt = 9; |
38 | cnt = 9; |
Line 66... | Line 66... | ||
66 | { |
66 | { |
67 | if(PlatinenVersion == 10) PORTD &= ~(1<<2); |
67 | if(PlatinenVersion == 10) PORTD &= ~(1<<2); |
68 | else PORTC &= ~(1<<7); |
68 | else PORTC &= ~(1<<7); |
69 | } |
69 | } |
Line 70... | Line 70... | ||
70 | 70 | ||
71 | if(EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) |
71 | if(!NaviDataOkay && EE_Parameter.GlobalConfig & CFG_KOMPASS_AKTIV) |
72 | { |
72 | { |
73 | if(PINC & 0x10) |
73 | if(PINC & 0x10) |
74 | { |
74 | { |
75 | cntKompass++; |
75 | cntKompass++; |
Line 78... | Line 78... | ||
78 | { |
78 | { |
79 | if((cntKompass) && (cntKompass < 362)) |
79 | if((cntKompass) && (cntKompass < 362)) |
80 | { |
80 | { |
81 | cntKompass += cntKompass / 41; |
81 | cntKompass += cntKompass / 41; |
82 | if(cntKompass > 10) KompassValue = cntKompass - 10; else KompassValue = 0; |
82 | if(cntKompass > 10) KompassValue = cntKompass - 10; else KompassValue = 0; |
83 | } |
- | |
84 | // if(cntKompass < 10) cntKompass =r 10; |
- | |
85 | // KompassValue = (unsigned long)((unsigned long)(cntKompass-10)*720L + 1L) / 703L; |
- | |
86 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
83 | KompassRichtung = ((540 + KompassValue - KompassStartwert) % 360) - 180; |
- | 84 | } |
|
87 | cntKompass = 0; |
85 | cntKompass = 0; |
88 | } |
86 | } |
89 | } |
87 | } |
90 | - | ||
91 | } |
88 | } |
Line 92... | Line 89... | ||
92 | 89 | ||
93 | - | ||
94 | // ----------------------------------------------------------------------- |
90 | |
95 | 91 | // ----------------------------------------------------------------------- |
|
96 | unsigned int SetDelay (unsigned int t) |
92 | unsigned int SetDelay (unsigned int t) |
97 | { |
93 | { |
98 | // TIMSK0 &= ~_BV(TOIE0); |
94 | // TIMSK0 &= ~_BV(TOIE0); |
Line 132... | Line 128... | ||
132 | { |
128 | { |
133 | uint8_t sreg = SREG; |
129 | uint8_t sreg = SREG; |
Line 134... | Line 130... | ||
134 | 130 | ||
135 | // disable all interrupts before reconfiguration |
131 | // disable all interrupts before reconfiguration |
136 | cli(); |
132 | cli(); |
137 | 133 | ||
Line 138... | Line 134... | ||
138 | PORTD &= ~(1<<PORTD7); // set PD7 to low |
134 | PORTD &= ~(1<<PORTD7); // set PD7 to low |
139 | 135 | ||
140 | DDRC |= (1<<DDC6); // set PC6 as output (Reset for HEF4017) |
136 | DDRC |= (1<<DDC6); // set PC6 as output (Reset for HEF4017) |
Line 214... | Line 210... | ||
214 | 210 | ||
215 | #define MULTIPLYER 4 |
211 | #define MULTIPLYER 4 |
216 | static int16_t ServoNickOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
212 | static int16_t ServoNickOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
Line 217... | Line 213... | ||
217 | static int16_t ServoRollOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
213 | static int16_t ServoRollOffset = (255 / 2) * MULTIPLYER; // initial value near center positon |
218 | 214 | ||
219 | if(PlatinenVersion < 20) |
215 | if((PlatinenVersion < 20) && (Parameter_UserParam8 < 128 )) |
220 | { |
216 | { |
221 | //--------------------------- |
217 | //--------------------------- |
222 | // Nick servo state machine |
218 | // Nick servo state machine |
Line 337... | Line 333... | ||
337 | } |
333 | } |
338 | RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
334 | RemainingPulse += ServoRollValue - (256 / 2) * MULTIPLYER; // shift ServoNickValue to center position |
339 | ServoRollValue /= MULTIPLYER; |
335 | ServoRollValue /= MULTIPLYER; |
340 | //DebugOut.Analog[20] = ServoRollValue; |
336 | //DebugOut.Analog[20] = ServoRollValue; |
341 | break; |
337 | break; |
- | 338 | case 3: RemainingPulse += 2 * Parameter_Servo3; |
|
- | 339 | break; |
|
- | 340 | case 4: RemainingPulse += 2 * Parameter_Servo4; |
|
- | 341 | break; |
|
- | 342 | case 5: RemainingPulse += 2 * Parameter_Servo5; |
|
342 | 343 | break; |
|
343 | default: // other servo channels |
344 | default: // other servo channels |
344 | RemainingPulse += 2 * PPM_in[ServoIndex]; // add channel value, factor of 2 because timer 1 increments 3.2µs |
345 | RemainingPulse += 2 * PPM_in[ServoIndex]; // add channel value, factor of 2 because timer 1 increments 3.2µs |
345 | break; |
346 | break; |
346 | } |
347 | } |
347 | // range servo pulse width |
348 | // range servo pulse width |