Line data Source code
1 : #include "AP_Camera_Scripting.h" 2 : 3 : #if AP_CAMERA_SCRIPTING_ENABLED 4 : 5 : extern const AP_HAL::HAL& hal; 6 : 7 : // entry point to actually take a picture 8 0 : bool AP_Camera_Scripting::trigger_pic() 9 : { 10 : // increment counter to allow backend to notice request 11 0 : _cam_state.take_pic_incr++; 12 0 : return true; 13 : } 14 : 15 : // start or stop video recording. returns true on success 16 : // set start_recording = true to start record, false to stop recording 17 0 : bool AP_Camera_Scripting::record_video(bool start_recording) 18 : { 19 0 : _cam_state.recording_video = start_recording; 20 0 : return true; 21 : } 22 : 23 : // set zoom specified as a rate or percentage 24 0 : bool AP_Camera_Scripting::set_zoom(ZoomType zoom_type, float zoom_value) 25 : { 26 0 : _cam_state.zoom_type = (uint8_t)zoom_type; 27 0 : _cam_state.zoom_value = zoom_value; 28 0 : return true; 29 : } 30 : 31 : // set focus specified as rate, percentage or auto 32 : // focus in = -1, focus hold = 0, focus out = 1 33 0 : SetFocusResult AP_Camera_Scripting::set_focus(FocusType focus_type, float focus_value) 34 : { 35 0 : _cam_state.focus_type = (uint8_t)focus_type; 36 0 : _cam_state.focus_value = focus_value; 37 0 : return SetFocusResult::ACCEPTED; 38 : } 39 : 40 : // set tracking to none, point or rectangle (see TrackingType enum) 41 : // if POINT only p1 is used, if RECTANGLE then p1 is top-left, p2 is bottom-right 42 : // p1,p2 are in range 0 to 1. 0 is left or top, 1 is right or bottom 43 0 : bool AP_Camera_Scripting::set_tracking(TrackingType tracking_type, const Vector2f& p1, const Vector2f& p2) 44 : { 45 0 : _cam_state.tracking_type = (uint8_t)tracking_type; 46 0 : _cam_state.tracking_p1 = p1; 47 0 : _cam_state.tracking_p2 = p2; 48 0 : return true; 49 : } 50 : 51 : // access for scripting backend to retrieve state 52 : // returns true on success and cam_state is filled in 53 0 : bool AP_Camera_Scripting::get_state(AP_Camera::camera_state_t& cam_state) 54 : { 55 0 : cam_state = _cam_state; 56 0 : return true; 57 : } 58 : 59 : #endif // AP_CAMERA_SCRIPTING_ENABLED