diff --git a/ports/esp32s2/cam.c b/ports/esp32s2/cam.c index 7d87b35826..5cdae71e19 100644 --- a/ports/esp32s2/cam.c +++ b/ports/esp32s2/cam.c @@ -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; diff --git a/ports/esp32s2/cam.h b/ports/esp32s2/cam.h index b55d23dc04..779e575750 100644 --- a/ports/esp32s2/cam.h +++ b/ports/esp32s2/cam.h @@ -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. *