cam: Add a way to check if a frame is ready without blocking

This commit is contained in:
Jeff Epler 2021-06-01 20:15:58 -05:00
parent 5d5098152a
commit 400d1d90c9
2 changed files with 14 additions and 0 deletions

View File

@ -372,6 +372,13 @@ size_t cam_take(uint8_t **buffer_p) {
return frame_buffer_event.len;
}
bool cam_ready(void) {
frame_buffer_event_t frame_buffer_event;
BaseType_t result = xQueuePeek(cam_obj->frame_buffer_queue, (void *)&frame_buffer_event, 0);
return result != pdFALSE;
}
void cam_give(uint8_t *buffer) {
if (buffer == cam_obj->frame1_buffer) {
cam_obj->frame1_buffer_en = 1;

View File

@ -66,6 +66,13 @@ void cam_stop(void);
*/
size_t cam_take(uint8_t **buffer_p);
/**
* @brief Check whether a frame is available
*
* @return - true if cam_take() will complete immediately, false if it will block
*/
bool cam_ready(void);
/**
* @brief enable frame buffer to get the next frame data.
*