Paparazzi UAS
v5.18.0_stable
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"
31
#include "
subsystems/electrical.h
"
32
#include "
subsystems/radio_control.h
"
33
#include "
autopilot.h
"
34
#include "autopilot_rc_helpers.h"
35
36
#include "
modules/light/led_safety_status.h
"
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
{
44
LED_ON
(
SAFETY_WARNING_LED
);
45
led_safety_status_periodic
();
46
}
47
48
void
led_safety_status_periodic
(
void
)
49
{
50
if
(
radio_control
.
status
==
RC_LOST
||
radio_control
.
status
==
RC_REALLY_LOST
) {
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
{
77
LED_ON
(
SAFETY_WARNING_LED
);
78
}
79
}
80
#endif
autopilot_get_motors_on
bool autopilot_get_motors_on(void)
get motors status
Definition:
autopilot.c:212
radio_control.h
electrical.h
RC_LOST
#define RC_LOST
Definition:
radio_control.h:57
LED_OFF
#define LED_OFF(i)
Definition:
led_hw.h:52
LED_ON
#define LED_ON(i)
Definition:
led_hw.h:51
THROTTLE_STICK_DOWN
#define THROTTLE_STICK_DOWN()
Definition:
autopilot_rc_helpers.h:40
LED_TOGGLE
#define LED_TOGGLE(i)
Definition:
led_hw.h:53
led_safety_status.h
Electrical::vsupply
float vsupply
supply voltage in V
Definition:
electrical.h:45
LOW_BAT_LEVEL
#define LOW_BAT_LEVEL
low battery level in Volts (for 3S LiPo)
Definition:
electrical.h:36
YAW_STICK_CENTERED
#define YAW_STICK_CENTERED()
Definition:
autopilot_rc_helpers.h:45
led_safety_status_periodic
void led_safety_status_periodic(void)
Periodic function that makes the leds blink in the right pattern for each situation.
SAFETY_WARNING_LED
#define SAFETY_WARNING_LED
Definition:
px4fmu_4.0.h:466
RadioControl::status
uint8_t status
Definition:
radio_control.h:64
led_safety_status_init
void led_safety_status_init(void)
Initialises periodic loop; place more init functions here if expanding driver.
autopilot.h
led.h
arch independent LED (Light Emitting Diodes) API
PITCH_STICK_CENTERED
#define PITCH_STICK_CENTERED()
Definition:
autopilot_rc_helpers.h:48
ROLL_STICK_CENTERED
#define ROLL_STICK_CENTERED()
Definition:
autopilot_rc_helpers.h:51
electrical
struct Electrical electrical
Definition:
electrical.c:66
autopilot_get_mode
uint8_t autopilot_get_mode(void)
get autopilot mode
Definition:
autopilot.c:184
MODE_MANUAL
#define MODE_MANUAL
Default RC mode.
Definition:
autopilot_static.h:60
RC_REALLY_LOST
#define RC_REALLY_LOST
Definition:
radio_control.h:58
radio_control
struct RadioControl radio_control
Definition:
radio_control.c:30
sw
airborne
modules
light
led_safety_status.c
Generated on Tue Feb 1 2022 13:51:16 for Paparazzi UAS by
1.8.17