Paparazzi UAS
v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
light.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2009 Gautier Hattenberger
3
*
4
* This file is part of paparazzi.
5
*
6
* paparazzi is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
9
* any later version.
10
*
11
* paparazzi is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with paparazzi; see the file COPYING. If not, write to
18
* the Free Software Foundation, 59 Temple Place - Suite 330,
19
* Boston, MA 02111-1307, USA.
20
*
21
*/
22
23
#include "
modules/light/light.h
"
24
#include "
led.h
"
25
#include "generated/airframe.h"
26
27
uint8_t
strobe_light_mode
;
28
uint8_t
nav_light_mode
;
29
30
#ifndef LIGHT_LED_STROBE
31
#define LIGHT_LED_STROBE 2
32
#endif
33
34
#ifndef STROBE_LIGHT_MODE_DEFAULT
35
#define STROBE_LIGHT_MODE_DEFAULT 6
36
#endif
37
38
#ifndef NAV_LIGHT_MODE_DEFAULT
39
#define NAV_LIGHT_MODE_DEFAULT 4
40
#endif
41
42
43
void
init_light
(
void
)
44
{
45
// this part is already done by led_init in fact
46
LED_INIT
(
LIGHT_LED_STROBE
);
47
LED_OFF
(
LIGHT_LED_STROBE
);
48
strobe_light_mode
=
STROBE_LIGHT_MODE_DEFAULT
;
49
#ifdef LIGHT_LED_NAV
50
LED_INIT
(LIGHT_LED_NAV);
51
LED_OFF
(LIGHT_LED_NAV);
52
nav_light_mode
=
NAV_LIGHT_MODE_DEFAULT
;
53
#endif
54
}
55
56
void
periodic_light
(
void
)
57
{
58
static
uint8_t
counter
= 0;
59
#ifdef LIGHT_LED_NAV
60
static
uint8_t
counter_nav = 0;
61
#endif
62
63
switch
(
strobe_light_mode
) {
64
default
:
// Always off
65
LED_OFF
(
LIGHT_LED_STROBE
);
66
break
;
67
case
1:
// Always on
68
LED_ON
(
LIGHT_LED_STROBE
);
69
break
;
70
case
2:
// Blink
71
case
3:
72
case
4:
73
if
(counter == (
strobe_light_mode
* 5 - 4)) {
74
LED_OFF
(
LIGHT_LED_STROBE
);
75
}
else
if
(counter >= 20) {
76
LED_ON
(
LIGHT_LED_STROBE
);
77
counter = 0;
78
}
79
break
;
80
case
5:
// Complex Blinking
81
if
(counter == 3) {
82
LED_OFF
(
LIGHT_LED_STROBE
);
83
}
else
if
(counter == 4) {
84
LED_ON
(
LIGHT_LED_STROBE
);
85
}
else
if
(counter == 6) {
86
LED_OFF
(
LIGHT_LED_STROBE
);
87
}
else
if
(counter == 7) {
88
LED_ON
(
LIGHT_LED_STROBE
);
89
}
else
if
(counter == 8) {
90
LED_OFF
(
LIGHT_LED_STROBE
);
91
}
else
if
(counter >= 25) {
92
LED_ON
(
LIGHT_LED_STROBE
);
93
counter = 0;
94
}
95
break
;
96
case
6:
97
if
(counter <= 18) {
98
if
((counter % 2) == 0) {
99
LED_ON
(
LIGHT_LED_STROBE
);
100
}
else
{
101
LED_OFF
(
LIGHT_LED_STROBE
);
102
}
103
}
else
if
(counter == 35) {
104
counter = 0;
105
}
106
break
;
107
}
108
109
#ifdef LIGHT_LED_NAV
110
switch
(
nav_light_mode
) {
111
default
:
// Always off
112
LED_OFF
(LIGHT_LED_NAV);
113
break
;
114
case
1:
// Always on
115
LED_ON
(LIGHT_LED_NAV);
116
break
;
117
case
2:
// Blink
118
case
3:
119
case
4:
120
if
(counter_nav == (
nav_light_mode
* 5 - 4)) {
121
LED_OFF
(LIGHT_LED_NAV);
122
}
else
if
(counter_nav >= 20) {
123
LED_ON
(LIGHT_LED_NAV);
124
counter_nav = 0;
125
}
126
break
;
127
}
128
counter_nav++;
129
#endif
130
131
counter++;
132
}
133
nav_light_mode
uint8_t nav_light_mode
Definition:
light.c:28
periodic_light
void periodic_light(void)
Definition:
light.c:56
NAV_LIGHT_MODE_DEFAULT
#define NAV_LIGHT_MODE_DEFAULT
Definition:
light.c:39
LIGHT_LED_STROBE
#define LIGHT_LED_STROBE
Definition:
light.c:31
LED_OFF
#define LED_OFF(i)
Definition:
led_hw.h:51
LED_INIT
#define LED_INIT(i)
Definition:
led_hw.h:49
light.h
STROBE_LIGHT_MODE_DEFAULT
#define STROBE_LIGHT_MODE_DEFAULT
Definition:
light.c:35
counter
int32_t counter
Definition:
avoid_navigation.c:55
init_light
void init_light(void)
Definition:
light.c:43
uint8_t
unsigned char uint8_t
Definition:
types.h:14
led.h
arch independent LED (Light Emitting Diodes) API
LED_ON
#define LED_ON(i)
Definition:
led_hw.h:50
strobe_light_mode
uint8_t strobe_light_mode
Definition:
light.c:27
sw
airborne
modules
light
light.c
Generated on Sat Feb 9 2019 07:05:50 for Paparazzi UAS by
1.8.8