AP_Camera: add singleton

This commit is contained in:
Peter Barker 2018-04-14 14:03:29 +10:00 committed by Randy Mackay
parent 44fd85ff29
commit fb786b8d56
2 changed files with 23 additions and 0 deletions

View File

@ -444,3 +444,15 @@ void AP_Camera::update_trigger()
}
}
}
// singleton instance
AP_Camera *AP_Camera::_singleton;
namespace AP {
AP_Camera *camera()
{
return AP_Camera::get_singleton();
}
}

View File

@ -44,6 +44,10 @@ public:
AP_Camera(const AP_Camera &other) = delete;
AP_Camera &operator=(const AP_Camera&) = delete;
// get singleton instance
static AP_Camera *get_singleton() {
return _singleton;
}
// MAVLink methods
void control_msg(const mavlink_message_t* msg);
@ -71,6 +75,9 @@ public:
void set_is_auto_mode(bool enable) { _is_in_auto_mode = enable; }
private:
static AP_Camera *_singleton;
AP_Int8 _trigger_type; // 0:Servo,1:Relay
AP_Int8 _trigger_duration; // duration in 10ths of a second that the camera shutter is held open
AP_Int8 _relay_on; // relay value to trigger camera
@ -127,3 +134,7 @@ private:
bool using_feedback_pin(void) const { return _feedback_pin > 0; }
};
namespace AP {
AP_Camera *camera();
};