/// <summary> /// Remove a callback handler for a given port. /// </summary> /// <param name="port">The port we are removing the callback handler on.</param> public static void RemoveCallback(ControlPortBase port) { if (WorkingHandlers.ContainsKey(port)) { WorkingHandlers.Remove(port); } }
/// <summary> /// This is the camera's control port callback function. The callback is used if /// MMALCameraConfig.SetChangeEventRequest is set to true. /// </summary> /// <seealso cref="MMALCameraConfig.SetChangeEventRequest" /> /// <param name="buffer">The buffer header being sent from MMAL.</param> /// <param name="port">The managed control port instance.</param> internal unsafe void CameraControlCallback(MMALBufferImpl buffer, ControlPortBase port) { if (buffer.Cmd == MMALEvents.MMAL_EVENT_PARAMETER_CHANGED) { var data = (MMAL_EVENT_PARAMETER_CHANGED_T *)buffer.Data; if (data->Hdr.Id == MMALParametersCamera.MMAL_PARAMETER_CAMERA_SETTINGS) { var settings = (MMAL_PARAMETER_CAMERA_SETTINGS_T *)data; MMALLog.Logger.Debug($"Analog gain num {settings->AnalogGain.Num}"); MMALLog.Logger.Debug($"Analog gain den {settings->AnalogGain.Den}"); MMALLog.Logger.Debug($"Exposure {settings->Exposure}"); MMALLog.Logger.Debug($"Focus position {settings->FocusPosition}"); } } else if (buffer.Cmd == MMALEvents.MMAL_EVENT_ERROR) { MMALLog.Logger.Info("No data received from sensor. Check all connections, including the Sunny one on the camera board"); } else { MMALLog.Logger.Info("Received unexpected camera control callback event"); } }
/// <summary> /// Finds and returns a <see cref="IControlCallbackHandler"/> for a given port. If no handler is registered, a /// <see cref="DefaultControlCallbackHandler"/> will be returned. /// </summary> /// <param name="port">The port we are retrieving the callback handler on.</param> /// <returns>A <see cref="IControlCallbackHandler"/> for a given port. If no handler is registered, a /// <see cref="DefaultControlCallbackHandler"/> will be returned.</returns> public static IControlCallbackHandler FindCallback(ControlPortBase port) { if (WorkingHandlers.ContainsKey(port)) { return(WorkingHandlers[port]); } return(new DefaultControlCallbackHandler(port)); }
/// <summary> /// Creates a new instance of <see cref="DefaultControlCallbackHandler"/>. /// </summary> /// <param name="port">The working <see cref="ControlPortBase"/>.</param> public DefaultControlCallbackHandler(ControlPortBase port) : base(port) { }
/// <summary> /// Creates a new instance of <see cref="ControlCallbackHandlerBase"/>. /// </summary> /// <param name="port">The <see cref="ControlPortBase"/>.</param> protected ControlCallbackHandlerBase(ControlPortBase port) { this.WorkingPort = port; }
internal static void SetChangeEventRequest(this ControlPortBase controlPort, MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T value) { MMALCheck(MMALPort.mmal_port_parameter_set(controlPort.Ptr, &value.Hdr), "Unable to set camera event request."); }