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>
|
2015-02-26 03:07:33 -04:00
|
|
|
#include <GCS_MAVLink.h>
|
2013-09-19 03:27:31 -03:00
|
|
|
#include <AP_BoardLED.h>
|
|
|
|
#include <ToshibaLED.h>
|
|
|
|
#include <ToshibaLED_I2C.h>
|
|
|
|
#include <ToshibaLED_PX4.h>
|
|
|
|
#include <ToneAlarm_PX4.h>
|
2014-08-23 04:42:56 -03:00
|
|
|
#include <ToneAlarm_Linux.h>
|
2014-11-14 10:14:40 -04:00
|
|
|
#include <NavioLED_I2C.h>
|
2013-11-28 00:00:02 -04:00
|
|
|
#include <ExternalLED.h>
|
2014-03-31 05:52:16 -03:00
|
|
|
#include <Buzzer.h>
|
2014-12-30 07:45:27 -04:00
|
|
|
#include <VRBoard_LED.h>
|
2015-02-06 23:24:37 -04:00
|
|
|
#include <OreoLED_PX4.h>
|
2013-09-19 03:27:31 -03:00
|
|
|
|
2015-02-27 02:35:53 -04:00
|
|
|
#ifndef OREOLED_ENABLED
|
|
|
|
# define OREOLED_ENABLED 0 // set to 1 to enable OreoLEDs
|
|
|
|
#endif
|
|
|
|
|
2013-09-19 03:27:31 -03:00
|
|
|
class AP_Notify
|
|
|
|
{
|
|
|
|
public:
|
2014-12-14 23:20:59 -04:00
|
|
|
/// notify_flags_type - bitmask of notification flags
|
|
|
|
struct notify_flags_type {
|
2015-02-02 16:54:19 -04:00
|
|
|
uint32_t initialising : 1; // 1 if initialising and copter should not be moved
|
|
|
|
uint32_t gps_status : 3; // 0 = no gps, 1 = no lock, 2 = 2d lock, 3 = 3d lock, 4 = dgps lock, 5 = rtk lock
|
|
|
|
uint32_t armed : 1; // 0 = disarmed, 1 = armed
|
|
|
|
uint32_t pre_arm_check : 1; // 0 = failing checks, 1 = passed
|
|
|
|
uint32_t pre_arm_gps_check : 1; // 0 = failing pre-arm GPS checks, 1 = passed
|
|
|
|
uint32_t save_trim : 1; // 1 if gathering trim data
|
|
|
|
uint32_t esc_calibration : 1; // 1 if calibrating escs
|
|
|
|
uint32_t failsafe_radio : 1; // 1 if radio failsafe
|
|
|
|
uint32_t failsafe_battery : 1; // 1 if battery failsafe
|
|
|
|
uint32_t parachute_release : 1; // 1 if parachute is being released
|
|
|
|
uint32_t ekf_bad : 1; // 1 if ekf is reporting problems
|
2015-03-06 01:19:48 -04:00
|
|
|
uint32_t autopilot_mode : 1; // 1 if vehicle is in an autopilot flight mode (only used by OreoLEDs)
|
2013-11-30 09:53:40 -04:00
|
|
|
|
|
|
|
// additional flags
|
2015-02-02 16:54:19 -04:00
|
|
|
uint32_t external_leds : 1; // 1 if external LEDs are enabled (normally only used for copter)
|
2015-04-26 09:23:18 -03:00
|
|
|
uint32_t vehicle_lost : 1; // 1 when lost copter tone is requested (normally only used for copter)
|
2013-09-19 03:27:31 -03:00
|
|
|
};
|
|
|
|
|
2014-12-14 23:20:04 -04:00
|
|
|
/// notify_events_type - bitmask of active events.
|
|
|
|
// Notify library is responsible for setting back to zero after notification has been completed
|
2014-10-23 09:04:34 -03:00
|
|
|
struct notify_events_type {
|
2015-02-02 16:57:06 -04:00
|
|
|
uint16_t arming_failed : 1; // 1 if copter failed to arm after user input
|
|
|
|
uint16_t user_mode_change : 1; // 1 if user has initiated a flight mode change
|
|
|
|
uint16_t user_mode_change_failed: 1; // 1 when user initiated flight mode change fails
|
|
|
|
uint16_t failsafe_mode_change : 1; // 1 when failsafe has triggered a flight mode change
|
|
|
|
uint16_t autotune_complete : 1; // 1 when autotune has successfully completed
|
|
|
|
uint16_t autotune_failed : 1; // 1 when autotune has failed
|
|
|
|
uint16_t autotune_next_axis : 1; // 1 when autotune has completed one axis and is moving onto the next
|
|
|
|
uint16_t mission_complete : 1; // 1 when the mission has completed successfully
|
|
|
|
uint16_t waypoint_complete : 1; // 1 as vehicle completes a waypoint
|
2015-03-05 04:17:19 -04:00
|
|
|
uint16_t firmware_update : 1; // 1 just before vehicle firmware is updated
|
2014-10-23 09:04:34 -03:00
|
|
|
};
|
|
|
|
|
2013-09-19 03:27:31 -03:00
|
|
|
// the notify flags are static to allow direct class access
|
|
|
|
// without declaring the object
|
2014-12-14 23:20:59 -04:00
|
|
|
static struct notify_flags_type flags;
|
2014-10-23 09:04:34 -03:00
|
|
|
static struct notify_events_type events;
|
2013-09-19 03:27:31 -03:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
2015-02-26 03:07:33 -04:00
|
|
|
// handle a LED_CONTROL message
|
|
|
|
static void handle_led_control(mavlink_message_t* msg);
|
|
|
|
|
2013-09-19 03:27:31 -03:00
|
|
|
private:
|
2015-07-17 12:15:10 -03:00
|
|
|
static NotifyDevice* _devices[];
|
2013-09-19 03:27:31 -03:00
|
|
|
};
|
|
|
|
|
2014-08-23 04:42:56 -03:00
|
|
|
#endif // __AP_NOTIFY_H__
|