2013-09-19 03:27:31 -03:00
|
|
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __AP_NOTIFY_H__
|
|
|
|
#define __AP_NOTIFY_H__
|
|
|
|
|
|
|
|
#include <AP_Common.h>
|
|
|
|
#include <AP_BoardLED.h>
|
|
|
|
#include <ToshibaLED.h>
|
|
|
|
#include <ToshibaLED_I2C.h>
|
|
|
|
#include <ToshibaLED_PX4.h>
|
|
|
|
#include <ToneAlarm_PX4.h>
|
2013-11-28 00:00:02 -04:00
|
|
|
#include <ExternalLED.h>
|
2014-03-31 05:52:16 -03:00
|
|
|
#include <Buzzer.h>
|
2013-09-19 03:27:31 -03:00
|
|
|
|
|
|
|
class AP_Notify
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// notify_type - bitmask of notification types
|
|
|
|
struct notify_type {
|
|
|
|
uint16_t initialising : 1; // 1 if initialising and copter should not be moved
|
2014-03-31 20:19:28 -03:00
|
|
|
uint16_t gps_status : 3; // 0 = no gps, 1 = no lock, 2 = 2d lock, 3 = 3d lock, 4 = dgps lock, 5 = rtk lock
|
2013-09-22 10:18:34 -03:00
|
|
|
uint16_t gps_glitching : 1; // 1 if gps position is not good
|
2013-09-19 03:27:31 -03:00
|
|
|
uint16_t armed : 1; // 0 = disarmed, 1 = armed
|
|
|
|
uint16_t pre_arm_check : 1; // 0 = failing checks, 1 = passed
|
|
|
|
uint16_t save_trim : 1; // 1 if gathering trim data
|
|
|
|
uint16_t esc_calibration : 1; // 1 if calibrating escs
|
|
|
|
uint16_t failsafe_radio : 1; // 1 if radio failsafe
|
|
|
|
uint16_t failsafe_battery : 1; // 1 if battery failsafe
|
2013-11-30 09:53:40 -04:00
|
|
|
uint16_t failsafe_gps : 1; // 1 if gps failsafe
|
2014-03-31 20:19:28 -03:00
|
|
|
uint16_t arming_failed : 1; // 1 if copter failed to arm after user input
|
2014-04-15 03:51:26 -03:00
|
|
|
uint16_t parachute_release : 1; // 1 if parachute is being released
|
2013-11-30 09:53:40 -04:00
|
|
|
|
|
|
|
// additional flags
|
2014-03-31 05:52:16 -03:00
|
|
|
uint16_t external_leds : 1; // 1 if external LEDs are enabled (normally only used for copter)
|
2013-09-19 03:27:31 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
// the notify flags are static to allow direct class access
|
|
|
|
// without declaring the object
|
|
|
|
static struct notify_type flags;
|
|
|
|
|
|
|
|
// initialisation
|
2013-11-30 09:53:40 -04:00
|
|
|
void init(bool enable_external_leds);
|
2013-09-19 03:27:31 -03:00
|
|
|
|
|
|
|
/// update - allow updates of leds that cannot be updated during a timed interrupt
|
|
|
|
void update(void);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// individual drivers
|
|
|
|
AP_BoardLED boardled;
|
2013-09-28 06:24:45 -03:00
|
|
|
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
2013-09-19 03:27:31 -03:00
|
|
|
ToshibaLED_PX4 toshibaled;
|
|
|
|
ToneAlarm_PX4 tonealarm;
|
2014-03-31 05:52:16 -03:00
|
|
|
#elif CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2
|
|
|
|
ToshibaLED_I2C toshibaled;
|
2013-11-28 00:00:02 -04:00
|
|
|
ExternalLED externalled;
|
2013-11-28 00:28:14 -04:00
|
|
|
Buzzer buzzer;
|
2014-03-31 14:48:41 -03:00
|
|
|
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
|
2014-05-30 17:58:34 -03:00
|
|
|
ToshibaLED_I2C toshibaled;
|
|
|
|
ExternalLED externalled;
|
|
|
|
Buzzer buzzer;
|
2013-09-28 06:24:45 -03:00
|
|
|
#else
|
|
|
|
ToshibaLED_I2C toshibaled;
|
2013-09-19 03:27:31 -03:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __AP_NOTIFY_H__
|