Subversion Repositories FlightCtrl

Rev

Rev 1607 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1607 Rev 1610
1
#include <inttypes.h>
1
#include <inttypes.h>
2
#include "main.h"
2
#include "main.h"
-
 
3
 
-
 
4
#define PHOTO_MODE_DELAY                        2000/10
-
 
5
#define PHOTO_MODE_TRIGGER_TIME         1000/10
-
 
6
#define PHOTO_MODE_TRIGGER_PERIOD       4000/10
3
 
7
 
4
uint16_t LED1_Timing = 0;
8
uint16_t LED1_Timing = 0;
5
uint16_t LED2_Timing = 0;
9
uint16_t LED2_Timing = 0;
6
unsigned char J16Blinkcount = 0, J16Mask = 1;
10
unsigned char J16Blinkcount = 0, J16Mask = 1;
7
unsigned char J17Blinkcount = 0, J17Mask = 1;
11
unsigned char J17Blinkcount = 0, J17Mask = 1;
-
 
12
 
-
 
13
uint8_t PhotoModeDelayCounter ;
-
 
14
uint16_t PhotoModelCounter;
-
 
15
 
-
 
16
 
-
 
17
 
8
 
18
 
9
// initializes the LED control outputs J16, J17
19
// initializes the LED control outputs J16, J17
10
void LED_Init(void)
20
void LED_Init(void)
11
{
21
{
12
    // set PC2 & PC3 as output (control of J16 & J17)
22
    // set PC2 & PC3 as output (control of J16 & J17)
13
    DDRC |= (1<<DDC2)|(1<<DDC3);
23
    DDRC |= (1<<DDC2)|(1<<DDC3);
14
    J16_OFF;
24
    J16_OFF;
15
    J17_OFF;
25
    J17_OFF;
16
    J16Blinkcount = 0; J16Mask = 128;
26
    J16Blinkcount = 0; J16Mask = 128;
17
    J17Blinkcount = 0; J17Mask = 128;
27
    J17Blinkcount = 0; J17Mask = 128;
18
}
28
}
19
 
29
 
20
// called in UpdateMotors() every 2ms
30
// called in UpdateMotors() every 2ms
21
void LED_Update(void)
31
void LED_Update(void)
22
{
32
{
23
    static char delay = 0;
33
    static char delay = 0;
24
 
34
 
25
    if(!delay--)  // 10ms Intervall
35
    if(!delay--)  // 10ms Intervall
26
    {
36
    {
27
        delay = 4;
37
        delay = 4;
28
 
38
 
29
        if (Parameter_J16Timing < 10)
39
        if (Parameter_J16Timing < 10)
30
        {
40
        {
-
 
41
                // Low: select camera 1
31
            J16_OFF;
42
            J16_OFF;
32
            J17_OFF;
43
            J17_OFF;
33
        }
44
        }
34
        else if (Parameter_J16Timing < 180)
45
        else if (Parameter_J16Timing < 180)
35
        {
46
        {
-
 
47
                // Middle: select camera 2, no trigger
36
            J16_ON;
48
            J16_ON;
37
            J17_OFF;
49
            J17_OFF;
-
 
50
            PhotoModeDelayCounter = PHOTO_MODE_DELAY;
-
 
51
            PhotoModelCounter = 0;
38
        }
52
        }
39
        else
53
        else
40
        {
54
        {
-
 
55
                // High: select camera 2 and trigger
41
            J16_ON;
56
            J16_ON;
-
 
57
 
-
 
58
            if (PhotoModeDelayCounter)
-
 
59
            {
-
 
60
                // Not in photo-mode (yet)
-
 
61
                PhotoModeDelayCounter--;
42
            J17_ON;
62
                J17_ON;
-
 
63
            }
-
 
64
            else
-
 
65
            {
-
 
66
                PhotoModelCounter++;
-
 
67
 
-
 
68
                // In photo-mode
-
 
69
                if (PhotoModelCounter < PHOTO_MODE_TRIGGER_TIME)
-
 
70
                {
-
 
71
                        J17_ON;
-
 
72
                }
-
 
73
                else if (PhotoModelCounter < PHOTO_MODE_TRIGGER_PERIOD-PHOTO_MODE_TRIGGER_TIME)
-
 
74
                {
-
 
75
                        J17_OFF;
-
 
76
                }
-
 
77
                else
-
 
78
                {
-
 
79
                        PhotoModelCounter = 0;
-
 
80
                }
-
 
81
            }
-
 
82
 
43
        }
83
        }
44
    }
84
    }
45
}
85
}
46
 
86