Ardupilot2/libraries/AP_Notify/AP_Notify.h

63 lines
2.5 KiB
C
Raw Normal View History

2013-08-08 10:13:14 -03:00
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
#ifndef __AP_NOTIFY_H__
#define __AP_NOTIFY_H__
#include <AP_Common.h>
class AP_Notify
{
public:
2013-08-13 23:50:52 -03:00
/// definition of callback function
typedef void (*update_fn_t)(void);
2013-08-08 10:13:14 -03:00
/// notify_type - bitmask of notification types
struct notify_type {
uint16_t initialising : 1; // 1 if initialising and copter should not be moved
uint16_t gps_status : 2; // 0 = no gps, 1 = no lock, 2 = 2d lock, 3 = 3d lock
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
2013-08-13 23:50:52 -03:00
};
static struct notify_type flags;
/// register_callback - allows registering functions to be called with AP_Notify::update() is called from main loop
static void register_update_function(update_fn_t fn) {_update_fn = fn;}
/// update - allow updates of leds that cannot be updated during a timed interrupt
static void update() { if (AP_Notify::_update_fn != NULL) AP_Notify::_update_fn(); }
2013-08-08 10:13:14 -03:00
/// To-Do: potential notifications to add
/// flight_mode
/// void flight_mode(uint8_t mode) = 0;
/// throttle failsafe
/// void fs_throttle(bool uint8_t); // 0 if throttle failsafe is cleared, 1 if activated
/// void fs_battery(bool uint8_t); // 1 if battery voltage is low or consumed amps close to battery capacity, 0 if cleared
/// void fs_gps(bool uint8_t); // 1 if we've lost gps lock and it is required for our current flightmode, 0 if cleared
/// void fs_gcs(bool uint8_t); // 1 if we've lost contact with the gcs and it is required for our current flightmode or pilot input method, 0 if cleared
/// void fence_breach(bool uint8_t); // fence type breached or 0 if cleared
/// switch_aux1(uint8_t state); // 0 if aux switch is off, 1 if in middle, 2 if high
/// switch_aux2(uint8_t state); // 0 if aux switch is off, 1 if in middle, 2 if high
/// reached_waypoint(); // called after we reach a waypoint
/// error(uint8_t subsystem_id, uint8_t error_code); // general error reporting
/// objects that we expect to create:
/// apm2, px4 leds
/// copter leds
/// blinkm
/// buzzer
2013-08-13 23:50:52 -03:00
//private:
static update_fn_t _update_fn;
2013-08-08 10:13:14 -03:00
};
#endif // __AP_NOTIFY_H__