Merge pull request #1065 from openmv/framebuffer_init

Move framebuffer initialization to framebuffer.c
This commit is contained in:
Ibrahim Abd Elkader 2020-12-30 01:58:35 +02:00 committed by GitHub
commit 0385d70959
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 18 deletions

View File

@ -70,6 +70,28 @@ void fb_encode_for_ide(uint8_t *ptr, image_t *img)
*ptr++ = 0xFE; *ptr++ = 0xFE;
} }
void framebuffer_init0()
{
// Save fb_enabled flag state
int fb_enabled = JPEG_FB()->enabled;
// Clear framebuffers
memset(MAIN_FB(), 0, sizeof(*MAIN_FB()));
memset(JPEG_FB(), 0, sizeof(*JPEG_FB()));
// Skip the first frame.
MAIN_FB()->bpp = -1;
// Enable streaming.
MAIN_FB()->streaming_enabled = true; // controlled by the OpenMV Cam.
// Set default quality
JPEG_FB()->quality = ((JPEG_QUALITY_HIGH - JPEG_QUALITY_LOW) / 2) + JPEG_QUALITY_LOW;
// Set fb_enabled
JPEG_FB()->enabled = fb_enabled; // controlled by the IDE.
}
void framebuffer_initialize_image(image_t *img) void framebuffer_initialize_image(image_t *img)
{ {
img->w = framebuffer->w; img->w = framebuffer->w;

View File

@ -46,6 +46,8 @@ bool fb_get_streaming_enabled();
int fb_encode_for_ide_new_size(image_t *img); int fb_encode_for_ide_new_size(image_t *img);
void fb_encode_for_ide(uint8_t *ptr, image_t *img); void fb_encode_for_ide(uint8_t *ptr, image_t *img);
void framebuffer_init0();
// Initializes an image_t struct with the frame buffer. // Initializes an image_t struct with the frame buffer.
void framebuffer_initialize_image(image_t *img); void framebuffer_initialize_image(image_t *img);

View File

@ -78,6 +78,8 @@
#endif #endif
#include "usbdbg.h" #include "usbdbg.h"
#include "framebuffer.h"
#include "omv_boardconfig.h"
uint32_t HAL_GetHalVersion() uint32_t HAL_GetHalVersion()
{ {
@ -166,6 +168,8 @@ soft_reset:
uart_init0(); uart_init0();
#endif #endif
framebuffer_init0();
#if (MICROPY_PY_BLE_NUS == 0) && (MICROPY_HW_USB_CDC == 0) #if (MICROPY_PY_BLE_NUS == 0) && (MICROPY_HW_USB_CDC == 0)
{ {
mp_obj_t args[2] = { mp_obj_t args[2] = {

View File

@ -500,6 +500,7 @@ soft_reset:
spi_init0(); spi_init0();
uart_init0(); uart_init0();
sensor_init0(); sensor_init0();
framebuffer_init0();
fb_alloc_init0(); fb_alloc_init0();
#ifdef IMLIB_ENABLE_IMAGE_IO #ifdef IMLIB_ENABLE_IMAGE_IO
file_buffer_init0(); file_buffer_init0();

View File

@ -233,24 +233,6 @@ void sensor_init0()
{ {
dcmi_abort(); dcmi_abort();
// Save fb_enabled flag state
int fb_enabled = JPEG_FB()->enabled;
// Clear framebuffers
memset(MAIN_FB(), 0, sizeof(*MAIN_FB()));
memset(JPEG_FB(), 0, sizeof(*JPEG_FB()));
// Skip the first frame.
MAIN_FB()->bpp = -1;
// Enable streaming.
MAIN_FB()->streaming_enabled = true; // controlled by the OpenMV Cam.
// Set default quality
JPEG_FB()->quality = ((JPEG_QUALITY_HIGH - JPEG_QUALITY_LOW) / 2) + JPEG_QUALITY_LOW;
// Set fb_enabled
JPEG_FB()->enabled = fb_enabled; // controlled by the IDE.
#ifdef PORTENTA #ifdef PORTENTA
// The Portenta board uses the same I2C bus for the sensor and // The Portenta board uses the same I2C bus for the sensor and
// user scripts. The I2C bus must be reinitialized on soft-reset. // user scripts. The I2C bus must be reinitialized on soft-reset.

View File

@ -180,6 +180,7 @@ int main()
#endif #endif
sensor_init0(); sensor_init0();
framebuffer_init0();
fb_alloc_init0(); fb_alloc_init0();
// Initialize the sensor // Initialize the sensor