Skip to content
This repository was archived by the owner on Oct 19, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/jpegio/lvgl_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
// pixel buffer that happens to start FF D8 falls through to LVGL's built-in
// decoder instead of being claimed.

#include "lvgl.h"
#include "src/draw/lv_image_decoder_private.h" // lv_image_decoder_t.info_cb, lv_image_cache_data_t
#include "src/core/lv_global.h" // LV_GLOBAL_DEFAULT()->image_cache_draw_buf_handlers
#include "lvgl/lvgl.h"
#include "lvgl/src/draw/lv_image_decoder_private.h" // lv_image_decoder_t.info_cb, lv_image_cache_data_t
#include "lvgl/src/core/lv_global.h" // LV_GLOBAL_DEFAULT()->image_cache_draw_buf_handlers

#include <string.h>

Expand Down
29 changes: 9 additions & 20 deletions src/jpegio/micropython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,24 @@ target_sources(displayif_jpegio INTERFACE
# listed earlier in a semicolon-separated USER_C_MODULES. Pass
# -DJPEGIO_LVGL=ON/OFF to decide by hand (the list form with lvgl-micropython
# elsewhere needs ON plus JPEGIO_LVGL_BINDINGS_DIR).
get_filename_component(_JPEGIO_WORKSPACE_DIR ${DISPLAYIF_MOD_DIR} DIRECTORY)
# The LVGL image decoder (lvgl_decoder.c) is built only when lvgl-micropython is
# in this build, decided from USER_C_MODULES the way micropython.mk decides it:
# what is on disk beside displayif says nothing about what this build selected,
# and jpegio has to build without LVGL. Override with -DJPEGIO_LVGL=ON/OFF.
# The decoder includes "lvgl/lvgl.h" and "lvgl/src/...", which resolve through
# the bindings directory lvgl-micropython itself puts on the include path, so
# nothing here needs to know where the bindings are.
if(NOT DEFINED JPEGIO_LVGL)
if(EXISTS ${_JPEGIO_WORKSPACE_DIR}/lvgl-micropython/micropython.cmake OR TARGET lv_micropython)
if("${USER_C_MODULES}" MATCHES "lvgl-micropython")
set(JPEGIO_LVGL ON)
else()
set(JPEGIO_LVGL OFF)
endif()
endif()

if(JPEGIO_LVGL)
# Derived the way lvgl-micropython/micropython.cmake derives BINDINGS_DIR
# (the workspace sibling lvgl-bindings), under a displayif-private name;
# a BINDINGS_DIR already set (command line, or lvgl-micropython included
# earlier) wins so both usermods see one lv_conf.h.
if(NOT DEFINED JPEGIO_LVGL_BINDINGS_DIR)
if(DEFINED BINDINGS_DIR)
set(JPEGIO_LVGL_BINDINGS_DIR ${BINDINGS_DIR})
else()
set(JPEGIO_LVGL_BINDINGS_DIR ${_JPEGIO_WORKSPACE_DIR}/lvgl-bindings)
endif()
endif()
if(NOT EXISTS ${JPEGIO_LVGL_BINDINGS_DIR}/lv_conf.h)
message(FATAL_ERROR "jpegio: JPEGIO_LVGL is ON but ${JPEGIO_LVGL_BINDINGS_DIR}/lv_conf.h does not exist (set JPEGIO_LVGL_BINDINGS_DIR)")
endif()
target_compile_definitions(displayif_jpegio INTERFACE JPEGIO_LVGL_DECODER=1)
target_include_directories(displayif_jpegio INTERFACE
${JPEGIO_LVGL_BINDINGS_DIR}
${JPEGIO_LVGL_BINDINGS_DIR}/lvgl
)
# No qstrs of its own (the Python-visible names live in jpegio.c).
target_sources(displayif_jpegio INTERFACE
${JPEGIO_DIR}/lvgl_decoder.c
)
Expand Down
16 changes: 5 additions & 11 deletions src/jpegio/micropython.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,11 @@ JPEGIO_LVMP_DIR := $(firstword $(filter %/lvgl-micropython,$(USER_C_MODULES:/=))
JPEGIO_LVGL ?= $(if $(JPEGIO_LVMP_DIR),1,0)

ifeq ($(JPEGIO_LVGL),1)
# The bindings checkout, derived the way lvgl-micropython/micropython.mk does
# (BINDINGS_DIR ?= $(abspath $(LVMP_DIR)/../lvgl-bindings)) but under a
# displayif-private name: displayif's micropython.mk is included before
# lvgl-micropython's, so a `BINDINGS_DIR ?=` here would pre-empt theirs. A
# BINDINGS_DIR given on the make command line is honoured so both usermods
# compile against the same lv_conf.h (struct layouts depend on it).
JPEGIO_LVGL_BINDINGS_DIR ?= $(or $(BINDINGS_DIR),$(abspath $(JPEGIO_LVMP_DIR)/../lvgl-bindings))
# -I<bindings> finds lv_conf.h (LVGL's lv_conf_internal.h picks it up through
# __has_include, the same route lvgl-micropython's -I$(BINDINGS_DIR) uses);
# -I<bindings>/lvgl finds lvgl.h and the src/... private headers.
CFLAGS_USERMOD += -DJPEGIO_LVGL_DECODER=1 -I$(JPEGIO_LVGL_BINDINGS_DIR) -I$(JPEGIO_LVGL_BINDINGS_DIR)/lvgl
# lvgl_decoder.c includes "lvgl/lvgl.h" and "lvgl/src/...", which resolve
# through the -I$(BINDINGS_DIR) lvgl-micropython adds, wherever its bindings
# are (a sibling checkout or its own fetched .deps/), so nothing here derives
# that path.
CFLAGS_USERMOD += -DJPEGIO_LVGL_DECODER=1
# No qstrs of its own (the Python-visible names live in jpegio.c).
SRC_USERMOD_LIB_C += $(JPEGIO_DIR)/lvgl_decoder.c
# lvgl.h with LV_USE_FLOAT trips -Werror=double-promotion / float-conversion
Expand Down
Loading