Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures 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 "light.h"
24 #include "led.h"
25 
28 
29 #ifndef STROBE_LIGHT_MODE_DEFAULT
30 #define STROBE_LIGHT_MODE_DEFAULT 6
31 #endif
32 
33 #ifndef NAV_LIGHT_MODE_DEFAULT
34 #define NAV_LIGHT_MODE_DEFAULT 4
35 #endif
36 
37 
38 void init_light(void) {
39  // this part is already done by led_init in fact
43 #ifdef LIGHT_LED_NAV
44  LED_INIT(LIGHT_LED_NAV);
45  LED_OFF(LIGHT_LED_NAV);
47 #endif
48 }
49 
50 void periodic_light(void)
51 {
52  static uint8_t counter = 0;
53 #ifdef LIGHT_LED_NAV
54  static uint8_t counter_nav = 0;
55 #endif
56 
57  switch (strobe_light_mode)
58  {
59  default: // Always off
61  break;
62  case 1: // Always on
64  break;
65  case 2: // Blink
66  case 3:
67  case 4:
68  if (counter == (strobe_light_mode*5 - 4))
69  {
71  }
72  else if (counter >= 20)
73  {
75  counter = 0;
76  }
77  break;
78  case 5: // Complex Blinking
79  if (counter == 3)
80  {
82  }
83  else if (counter == 4)
84  {
86  }
87  else if (counter == 6)
88  {
90  }
91  else if (counter == 7)
92  {
94  }
95  else if (counter == 8)
96  {
98  }
99  else if (counter >= 25)
100  {
102  counter = 0;
103  }
104  break;
105  case 6:
106  if (counter <= 18)
107  {
108  if ((counter % 2) == 0)
109  {
111  }
112  else
113  {
115  }
116  }
117  else if (counter == 35)
118  {
119  counter = 0;
120  }
121  break;
122  }
123 
124 #ifdef LIGHT_LED_NAV
125  switch (nav_light_mode)
126  {
127  default: // Always off
128  LED_OFF(LIGHT_LED_NAV);
129  break;
130  case 1: // Always on
131  LED_ON(LIGHT_LED_NAV);
132  break;
133  case 2: // Blink
134  case 3:
135  case 4:
136  if (counter_nav == (nav_light_mode*5 - 4))
137  {
138  LED_OFF(LIGHT_LED_NAV);
139  }
140  else if (counter_nav >= 20)
141  {
142  LED_ON(LIGHT_LED_NAV);
143  counter_nav = 0;
144  }
145  break;
146  }
147  counter_nav++;
148 #endif
149 
150  counter++;
151 }
152 
uint8_t nav_light_mode
Definition: light.c:27
void periodic_light(void)
Definition: light.c:50
#define NAV_LIGHT_MODE_DEFAULT
Definition: light.c:34
#define LIGHT_LED_STROBE
Definition: light.h:34
#define LED_ON(i)
Definition: led_hw.h:28
#define STROBE_LIGHT_MODE_DEFAULT
Definition: light.c:30
void init_light(void)
Definition: light.c:38
unsigned char uint8_t
Definition: types.h:14
#define LED_INIT(i)
Definition: led_hw.h:26
#define LED_OFF(i)
Definition: led_hw.h:29
arch independent LED (Light Emitting Diodes) API
uint8_t strobe_light_mode
Definition: light.c:26