1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

fix add MP support for LVGL 3rd party libraries (#2666)

* Fixes for MP support for LVGL 3rd party libraries

Add missing lv_qrcode_class

Remove 'struct JDEC' from public API. This struct is needed intenally on tjpgd.c and lv_sjpg.c, but doesn't need to be exposed in the public API. When exposed, it increases Micropython binding program size and some fields are not supported today (uint8_t* huffbits[2][2]). To overcome this, moved it to a new H file which is not included in public API, only in sjpg C files

Related: https://github.com/lvgl/lv_binding_micropython/issues/180

* lv_qrcode: add lv_class_qrcode

Must define a distinct class for every widget, to allow Micropython bindings convert lv_obj_t into the specific class

* gifdec.c: fix uninitialized

ESP32 reports some potentially uninitialized variables. Initialize them to prevent the errors

* src/extra/libs/sjpg: smaller public header

Only keep lv_split_jpeg_init in public header, since JPEG is used with image decoder

* Remove tjdec.h
This commit is contained in:
Amir Gonnen 2021-10-20 11:46:22 +03:00 committed by GitHub
parent 64527a5a1b
commit eaf25348a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 39 deletions

View File

@ -378,12 +378,12 @@ static int
read_image_data(gd_GIF *gif, int interlace)
{
uint8_t sub_len, shift, byte;
int init_key_size, key_size, table_is_full;
int frm_off, frm_size, str_len, i, p, x, y;
int init_key_size, key_size, table_is_full=0;
int frm_off, frm_size, str_len=0, i, p, x, y;
uint16_t key, clear, stop;
int ret;
Table *table;
Entry entry;
Entry entry = {0};
size_t start, end;
f_gif_read(gif, &byte, 1);

View File

@ -28,6 +28,10 @@
* STATIC VARIABLES
**********************/
const lv_obj_class_t lv_qrcode_class = {
.base_class = &lv_canvas_class
};
/**********************
* MACROS
**********************/

View File

@ -20,6 +20,8 @@ extern "C" {
* DEFINES
*********************/
extern const lv_obj_class_t lv_qrcode_class;
/**********************
* TYPEDEFS
**********************/

View File

@ -50,6 +50,7 @@
#include "tjpgd.h"
#include "lv_sjpg.h"
#include "../../../misc/lv_fs.h"
/*********************
@ -69,6 +70,39 @@
* TYPEDEFS
**********************/
enum io_source_type {
SJPEG_IO_SOURCE_C_ARRAY,
SJPEG_IO_SOURCE_DISK,
};
typedef struct {
enum io_source_type type;
lv_fs_file_t lv_file;
uint8_t* img_cache_buff;
int img_cache_x_res;
int img_cache_y_res;
uint8_t *raw_sjpg_data; //Used when type==SJPEG_IO_SOURCE_C_ARRAY.
uint32_t raw_sjpg_data_size; //Num bytes pointed to by raw_sjpg_data.
uint32_t raw_sjpg_data_next_read_pos; //Used for all types.
} io_source_t;
typedef struct {
uint8_t *sjpeg_data;
uint32_t sjpeg_data_size;
int sjpeg_x_res;
int sjpeg_y_res;
int sjpeg_total_frames;
int sjpeg_single_frame_height;
int sjpeg_cache_frame_index;
uint8_t **frame_base_array; //to save base address of each split frames upto sjpeg_total_frames.
int *frame_base_offset; //to save base offset for fseek
uint8_t *frame_cache;
uint8_t* workb; //JPG work buffer for jpeg library
JDEC *tjpeg_jd;
io_source_t io;
} SJPEG;
/**********************
* STATIC PROTOTYPES
**********************/

View File

@ -15,52 +15,16 @@ extern "C" {
*********************/
#include <stdio.h>
#include "tjpgd.h"
#include "../../../misc/lv_fs.h"
#if LV_USE_SJPG
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
enum io_source_type {
SJPEG_IO_SOURCE_C_ARRAY,
SJPEG_IO_SOURCE_DISK,
};
typedef struct {
enum io_source_type type;
lv_fs_file_t lv_file;
uint8_t* img_cache_buff;
int img_cache_x_res;
int img_cache_y_res;
uint8_t *raw_sjpg_data; //Used when type==SJPEG_IO_SOURCE_C_ARRAY.
uint32_t raw_sjpg_data_size; //Num bytes pointed to by raw_sjpg_data.
uint32_t raw_sjpg_data_next_read_pos; //Used for all types.
} io_source_t;
typedef struct {
uint8_t *sjpeg_data;
uint32_t sjpeg_data_size;
int sjpeg_x_res;
int sjpeg_y_res;
int sjpeg_total_frames;
int sjpeg_single_frame_height;
int sjpeg_cache_frame_index;
uint8_t **frame_base_array; //to save base address of each split frames upto sjpeg_total_frames.
int *frame_base_offset; //to save base offset for fseek
uint8_t *frame_cache;
uint8_t* workb; //JPG work buffer for jpeg library
JDEC *tjpeg_jd;
io_source_t io;
} SJPEG;
/**********************
* GLOBAL PROTOTYPES