Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
led_safety_status.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Pranay Sinha <psinha@transition-robotics.com>
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 #include "led.h"
23 #include "generated/airframe.h"
24 #include "subsystems/electrical.h"
26 #include "autopilot.h"
28 #include "autopilot_rc_helpers.h"
29 
30 #include "led_safety_status.h"
31 
32 #ifndef SAFETY_WARNING_LED
33 #error You must define SAFETY_WARNING_LED to use this module!
34 #else
35 
36 void led_safety_status_init(void) {
37  LED_ON(SAFETY_WARNING_LED);
39 }
40 
41 void led_safety_status_periodic(void) {
43  RunXTimesEvery(0, 60, 5, 7, {LED_TOGGLE(SAFETY_WARNING_LED);});
44  RunXTimesEvery(130, 130, 10, 6, {LED_TOGGLE(SAFETY_WARNING_LED);});
45  }
47  RunXTimesEvery(20, 240, 40, 1, {LED_ON(SAFETY_WARNING_LED);});
48  RunXTimesEvery(0, 240, 40, 1, {LED_OFF(SAFETY_WARNING_LED);});
49  }
51  RunXTimesEvery(20, 240, 40, 2, {LED_ON(SAFETY_WARNING_LED);});
52  RunXTimesEvery(0, 240, 40, 2, {LED_OFF(SAFETY_WARNING_LED);});
53  }
55  RunXTimesEvery(20, 240, 40, 3, {LED_ON(SAFETY_WARNING_LED);});
56  RunXTimesEvery(0, 240, 40, 3, {LED_OFF(SAFETY_WARNING_LED);});
57  }
59  RunXTimesEvery(20, 240, 40, 4, {LED_ON(SAFETY_WARNING_LED);});
60  RunXTimesEvery(0, 240, 40, 4, {LED_OFF(SAFETY_WARNING_LED);});
61  }
62  else if (!YAW_STICK_CENTERED() && !autopilot_motors_on){
63  RunXTimesEvery(20, 240, 40, 5, {LED_ON(SAFETY_WARNING_LED);});
64  RunXTimesEvery(0, 240, 40, 5, {LED_OFF(SAFETY_WARNING_LED);});
65  }
66 #ifdef MIN_BAT_LEVEL
67  else if (electrical.vsupply < (MIN_BAT_LEVEL * 10)){
68  RunOnceEvery(20, {LED_TOGGLE(SAFETY_WARNING_LED);});
69  }
70  else if (electrical.vsupply < ((MIN_BAT_LEVEL + 0.5) * 10)){
71  RunXTimesEvery(0, 300, 10, 10, {LED_TOGGLE(SAFETY_WARNING_LED);});
72  }
73 #endif
74  else {
75  LED_ON(SAFETY_WARNING_LED);
76  }
77 }
78 #endif
#define RC_LOST
Definition: radio_control.h:46
Interface to align the AHRS via low-passed measurements at startup.
uint8_t autopilot_mode
Definition: autopilot.c:47
#define ROLL_STICK_CENTERED()
bool_t autopilot_motors_on
Definition: autopilot.c:54
uint16_t vsupply
supply voltage in decivolts
Definition: electrical.h:48
#define LED_ON(i)
Definition: led_hw.h:28
#define MIN_BAT_LEVEL
Definition: electrical.c:56
#define THROTTLE_STICK_DOWN()
#define PITCH_STICK_CENTERED()
Interface for electrical status: supply voltage, current, battery status, etc.
struct RadioControl radio_control
Definition: radio_control.c:25
void led_safety_status_periodic(void)
Periodic function that makes the leds blink in the right pattern for each situation.
#define LED_TOGGLE(i)
Definition: led_hw.h:30
#define RC_REALLY_LOST
Definition: radio_control.h:47
uint8_t status
Definition: radio_control.h:50
Some helper functions to check RC sticks.
void led_safety_status_init(void)
Initialises periodic loop; place more init functions here if expanding driver.
#define YAW_STICK_CENTERED()
#define LED_OFF(i)
Definition: led_hw.h:29
arch independent LED (Light Emitting Diodes) API
Simple module to blink LEDs when battery voltage drops below a certain level, radio control is lost o...
struct Electrical electrical
#define MODE_MANUAL
Default RC mode.
Definition: autopilot.h:81