Skip to content

Instantly share code, notes, and snippets.

@jaimemarijke
Created September 19, 2019 15:58
Show Gist options
  • Save jaimemarijke/6ce7c83f874831168819561c463a48a4 to your computer and use it in GitHub Desktop.
Save jaimemarijke/6ce7c83f874831168819561c463a48a4 to your computer and use it in GitHub Desktop.
raspistill LED control patch.diff
diff --git a/buildme b/buildme
index cee90a6..c2f1b3a 100755
--- a/buildme
+++ b/buildme
@@ -25,7 +25,7 @@ if [ $ARCH = "armv6l" ] || [ $ARCH = "armv7l" ] || [ $ARCH = "aarch64" ]; then
if [ $ARCH = "armv6l" ]; then
make
else
- make -j4
+ make -j4 VERBOSE=True
fi
if [ "$1" != "" ]; then
sudo make install DESTDIR=$1
diff --git a/host_applications/linux/apps/raspicam/CMakeLists.txt b/host_applications/linux/apps/raspicam/CMakeLists.txt
index f7db21e..a2cc3e5 100644
--- a/host_applications/linux/apps/raspicam/CMakeLists.txt
+++ b/host_applications/linux/apps/raspicam/CMakeLists.txt
@@ -54,9 +54,9 @@ add_executable(raspividyuv ${COMMON_SOURCES} RaspiVidYUV.c)
set (MMAL_LIBS mmal_core mmal_util mmal_vc_client)
-target_link_libraries(raspistill ${MMAL_LIBS} vcos bcm_host brcmGLESv2 brcmEGL m dl)
-target_link_libraries(raspiyuv ${MMAL_LIBS} vcos bcm_host)
-target_link_libraries(raspivid ${MMAL_LIBS} vcos bcm_host)
-target_link_libraries(raspividyuv ${MMAL_LIBS} vcos bcm_host)
+target_link_libraries(raspistill ${MMAL_LIBS} vcos bcm_host brcmGLESv2 brcmEGL m dl wiringPi)
+target_link_libraries(raspiyuv ${MMAL_LIBS} vcos bcm_host wiringPi)
+target_link_libraries(raspivid ${MMAL_LIBS} vcos bcm_host wiringPi)
+target_link_libraries(raspividyuv ${MMAL_LIBS} vcos bcm_host wiringPi)
install(TARGETS raspistill raspiyuv raspivid raspividyuv RUNTIME DESTINATION bin)
diff --git a/host_applications/linux/apps/raspicam/RaspiCamControl.c b/host_applications/linux/apps/raspicam/RaspiCamControl.c
index 2e43d85..acb1fd6 100644
--- a/host_applications/linux/apps/raspicam/RaspiCamControl.c
+++ b/host_applications/linux/apps/raspicam/RaspiCamControl.c
@@ -30,6 +30,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory.h>
#include <ctype.h>
+#include <wiringPi.h>
+
#include "interface/vcos/vcos.h"
#include "interface/vmcs_host/vc_vchi_gencmd.h"
@@ -1811,6 +1813,23 @@ void default_camera_control_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *bu
settings->awb_red_gain.num, settings->awb_red_gain.den,
settings->awb_blue_gain.num, settings->awb_blue_gain.den);
}
+ case MMAL_PARAMETER_CAPTURE_STATUS:
+ {
+ wiringPiSetup();
+ pinMode(21, OUTPUT);
+ MMAL_PARAMETER_CAPTURE_STATUS_T *status = (MMAL_PARAMETER_CAPTURE_STATUS_T*)param;
+ if (status->status == MMAL_PARAM_CAPTURE_STATUS_CAPTURE_STARTED)
+ {
+ vcos_log_error("Started capture. Setting pin 21 (BCM pin 5) high...");
+ digitalWrite(21, HIGH);
+ }
+ else if (status->status == MMAL_PARAM_CAPTURE_STATUS_CAPTURE_ENDED)
+ {
+ vcos_log_error("Ended capture. Setting pin 21 (BCM pin 5) low...");
+ digitalWrite(21, LOW);
+ }
+
+ }
break;
}
}
diff --git a/host_applications/linux/apps/raspicam/RaspiStill.c b/host_applications/linux/apps/raspicam/RaspiStill.c
index ddbaf70..b206523 100644
--- a/host_applications/linux/apps/raspicam/RaspiStill.c
+++ b/host_applications/linux/apps/raspicam/RaspiStill.c
@@ -826,6 +826,18 @@ static MMAL_STATUS_T create_camera_component(RASPISTILL_STATE *state)
video_port = camera->output[MMAL_CAMERA_VIDEO_PORT];
still_port = camera->output[MMAL_CAMERA_CAPTURE_PORT];
+ {
+ MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T change_event_request =
+ {{MMAL_PARAMETER_CHANGE_EVENT_REQUEST, sizeof(MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T)},
+ MMAL_PARAMETER_CAPTURE_STATUS, 1};
+
+ status = mmal_port_parameter_set(camera->control, &change_event_request.hdr);
+ if ( status != MMAL_SUCCESS )
+ {
+ vcos_log_error("No capture status events");
+ }
+ }
+
// Enable the camera, and tell it its control callback function
status = mmal_port_enable(camera->control, default_camera_control_callback);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment