Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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 
29 #include "led.h"
30 #include "generated/airframe.h"
33 #include "autopilot.h"
34 #include "autopilot_rc_helpers.h"
35 
37 
38 #ifndef SAFETY_WARNING_LED
39 #error You must define SAFETY_WARNING_LED to use this module!
40 #else
41 
42 void led_safety_status_init(void)
43 {
46 }
47 
49 {
51  RunXTimesEvery(0, 60, 5, 7, {LED_TOGGLE(SAFETY_WARNING_LED);});
52  RunXTimesEvery(130, 130, 10, 6, {LED_TOGGLE(SAFETY_WARNING_LED);});
53  } else if (!(autopilot_get_mode() == MODE_MANUAL) && !autopilot_get_motors_on()) {
54  RunXTimesEvery(20, 240, 40, 1, {LED_ON(SAFETY_WARNING_LED);});
55  RunXTimesEvery(0, 240, 40, 1, {LED_OFF(SAFETY_WARNING_LED);});
56  } else if (!THROTTLE_STICK_DOWN() && !autopilot_get_motors_on()) {
57  RunXTimesEvery(20, 240, 40, 2, {LED_ON(SAFETY_WARNING_LED);});
58  RunXTimesEvery(0, 240, 40, 2, {LED_OFF(SAFETY_WARNING_LED);});
59  } else if (!ROLL_STICK_CENTERED() && !autopilot_get_motors_on()) {
60  RunXTimesEvery(20, 240, 40, 3, {LED_ON(SAFETY_WARNING_LED);});
61  RunXTimesEvery(0, 240, 40, 3, {LED_OFF(SAFETY_WARNING_LED);});
62  } else if (!PITCH_STICK_CENTERED() && !autopilot_get_motors_on()) {
63  RunXTimesEvery(20, 240, 40, 4, {LED_ON(SAFETY_WARNING_LED);});
64  RunXTimesEvery(0, 240, 40, 4, {LED_OFF(SAFETY_WARNING_LED);});
65  } else if (!YAW_STICK_CENTERED() && !autopilot_get_motors_on()) {
66  RunXTimesEvery(20, 240, 40, 5, {LED_ON(SAFETY_WARNING_LED);});
67  RunXTimesEvery(0, 240, 40, 5, {LED_OFF(SAFETY_WARNING_LED);});
68  }
69 #ifdef LOW_BAT_LEVEL
70  else if (electrical.vsupply < LOW_BAT_LEVEL) {
71  RunOnceEvery(20, {LED_TOGGLE(SAFETY_WARNING_LED);});
72  } else if (electrical.vsupply < (LOW_BAT_LEVEL + 0.5)) {
73  RunXTimesEvery(0, 300, 10, 10, {LED_TOGGLE(SAFETY_WARNING_LED);});
74  }
75 #endif
76  else {
78  }
79 }
80 #endif
uint8_t autopilot_get_mode(void)
get autopilot mode
Definition: autopilot.c:217
bool autopilot_get_motors_on(void)
get motors status
Definition: autopilot.c:290
Core autopilot interface common to all firmwares.
#define LED_ON(i)
Definition: led_hw.h:51
#define LED_OFF(i)
Definition: led_hw.h:52
#define LED_TOGGLE(i)
Definition: led_hw.h:53
struct Electrical electrical
Definition: electrical.c:92
Interface for electrical status: supply voltage, current, battery status, etc.
#define LOW_BAT_LEVEL
low battery level in Volts (for 3S LiPo)
Definition: electrical.h:36
float vsupply
supply voltage in V
Definition: electrical.h:45
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...
void led_safety_status_init(void)
Initialises periodic loop; place more init functions here if expanding driver.
void led_safety_status_periodic(void)
Periodic function that makes the leds blink in the right pattern for each situation.
#define SAFETY_WARNING_LED
Definition: px4fmu_4.0.h:466
struct RadioControl radio_control
Definition: radio_control.c:33
Generic interface for radio control modules.
#define RC_REALLY_LOST
Definition: radio_control.h:51
uint8_t status
Definition: radio_control.h:61
#define RC_LOST
Definition: radio_control.h:50
#define THROTTLE_STICK_DOWN()
#define ROLL_STICK_CENTERED()
#define PITCH_STICK_CENTERED()
#define YAW_STICK_CENTERED()
#define MODE_MANUAL
Default RC mode.