FLIR: Faster UVC streaming.

This commit is contained in:
iabdalkader 2018-10-29 20:55:09 +02:00
parent 36cd44ad23
commit d140a8ef1b

View File

@ -346,7 +346,7 @@ void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi)
} }
} }
static int snapshot(sensor_t *sensor, image_t *image, streaming_cb_t cb) static int snapshot(sensor_t *sensor, image_t *image, streaming_cb_t streaming_cb)
{ {
fb_update_jpeg_buffer(); fb_update_jpeg_buffer();
@ -354,6 +354,10 @@ static int snapshot(sensor_t *sensor, image_t *image, streaming_cb_t cb)
return -1; return -1;
} }
bool frame_ready = false;
bool streaming = (streaming_cb != NULL); // Streaming mode.
do {
// The SPI DMA device is always clocking the FLIR Lepton in the background. // The SPI DMA device is always clocking the FLIR Lepton in the background.
// The code below resets the vospi control values to let data be pulled in. // The code below resets the vospi control values to let data be pulled in.
// If we need to re-sync we do it. Otherwise, after we finish pulling data // If we need to re-sync we do it. Otherwise, after we finish pulling data
@ -368,7 +372,13 @@ static int snapshot(sensor_t *sensor, image_t *image, streaming_cb_t cb)
if (vospi_resync == true) { if (vospi_resync == true) {
lepton_sync(); lepton_sync();
} }
if (frame_ready == true && streaming_cb != NULL) {
// Start streaming the frame while a new one is captured.
streaming = streaming_cb(image);
frame_ready = false;
} else {
__WFI(); __WFI();
}
} while (vospi_pid < vospi_packets); // only checking one volatile var so atomic. } while (vospi_pid < vospi_packets); // only checking one volatile var so atomic.
MAIN_FB()->w = MAIN_FB()->u; MAIN_FB()->w = MAIN_FB()->u;
@ -440,6 +450,8 @@ static int snapshot(sensor_t *sensor, image_t *image, streaming_cb_t cb)
} }
} }
frame_ready = true;
} while (streaming && streaming_cb != NULL);
return 0; return 0;
} }