#
# Copyright (c) 2018-2019 Jan Van Winkel <jan.van_winkel@dxplore.eu>
#
# SPDX-License-Identifier: Apache-2.0
#

menuconfig LVGL
	bool "LittlevGL GUI library"
	help
	  This option enables the LittlevGL GUI library.

if LVGL

module = LVGL
module-str = lvgl
source "subsys/logging/Kconfig.template.log_config"

config LVGL_DISPLAY_DEV_NAME
	string "Display device name"
	default "DISPLAY"
	help
	  Name of the display device to use for rendering.

config LVGL_HOR_RES
	int "Horizontal Screen Resolution"
	default 320
	help
	  Horizontal screen resolution in pixels

config LVGL_VER_RES
	int "Vertical Screen Resolution"
	default 240
	help
	  Vertical screen resolution in pixels

config LVGL_DPI
	int "DPI"
	default 100
	help
	  Dots per inch (DPI)

choice LVGL_COLOR_DEPTH
	prompt "Color Depth"
	default LVGL_COLOR_DEPTH_32
	help
	  Color depth to be used by library

	config LVGL_COLOR_DEPTH_32
		bool "32-bit"

	config LVGL_COLOR_DEPTH_16
		bool "16-bit"

	config LVGL_COLOR_DEPTH_8
		bool "8-bit"

	config LVGL_COLOR_DEPTH_1
		bool "1-bit"

endchoice

config LVGL_BITS_PER_PIXEL
	int "Bits per pixel"
	default 32
	range 1 32
	depends on LVGL_BUFFER_ALLOC_STATIC
	help
	  Number of bits per pixel.

if LVGL_COLOR_DEPTH_16

config LVGL_COLOR_16_SWAP
	bool "RGB565 byte swap"
	help
	  Swap the 2 bytes of a RGB565 pixel.

endif

if LVGL_COLOR_DEPTH_32

config LVGL_COLOR_SCREEN_TRANSP
	bool "Transparency support"
	help
	  Enable screen transparency. Useful for OSD or other overlapping GUISs.

endif

choice
	prompt "Chroma key color"
	default LVGL_CHROMA_KEY_GREEN
	help
	  Color to to use as chroma key

	config LVGL_CHROMA_KEY_RED
		bool "Red"

	config LVGL_CHROMA_KEY_GREEN
		bool "Green"

	config LVGL_CHROMA_KEY_BLUE
		bool "Blue"

	config LVGL_CHROMA_KEY_CUSTOM
		bool "Custom"

endchoice

if LVGL_CHROMA_KEY_CUSTOM
config LVGL_CUSTOM_CHROMA_KEY_RED
	hex "Chroma Key Red"
	range 0x00 0xFF
	default 0x00
	help
	  Value of the color red to be used in the chroma key

config LVGL_CUSTOM_CHROMA_KEY_GREEN
	hex "Chroma Key Green"
	range 0x00 0xFF
	default 0xFF
	help
	  Value of the color green to be used in the chroma key

config LVGL_CUSTOM_CHROMA_KEY_BLUE
	hex "Chroma Key Blue"
	range 0x00 0xFF
	default 0x00
	help
	  Value of the color blue to be used in the chroma key

endif

choice
	prompt "Memory pool"
	default LVGL_MEM_POOL_HEAP_KERNEL
	help
	  Memory pool to use for lvgl allocated objects

	config LVGL_MEM_POOL_HEAP_KERNEL
		bool "Kernel Heap"
		depends on HEAP_MEM_POOL_SIZE != 0
		help
		  Use k_malloc and k_free to allocate objects on the kernel heap

	config LVGL_MEM_POOL_HEAP_LIB_C
	  bool "C library Heap"
	  depends on NEWLIB_LIBC || (MINIMAL_LIBC_MALLOC_ARENA_SIZE != 0)
	  help
		Use C library malloc and free to allocate objects on the C library heap

	config LVGL_MEM_POOL_KERNEL
		bool "Kernel space lvgl pool"
		help
		  Use a dedicated memory pool in kernel space to allocate lvgl objects
		  on

	config LVGL_MEM_POOL_USER
		bool "User space lvgl pool"
		help
		  Use a dedicated memory pool in user space to allocate lvgl objects on

endchoice

if LVGL_MEM_POOL_KERNEL || LVGL_MEM_POOL_USER

config LVGL_MEM_POOL_MIN_SIZE
	int "Minimum memory pool block size"
	default 16
	help
	  Size of the smallest block in the memory pool in bytes

config LVGL_MEM_POOL_MAX_SIZE
	int "Maximum memory pool block size"
	default 2048
	help
	  Size of the largest block in the memory pool in bytes

config LVGL_MEM_POOL_NUMBER_BLOCKS
	int "Number of max size blocks in memory pool"
	default 1
	help
	  Number of maximum sized blocks in the memory pool.

endif

config LVGL_VDB_SIZE
	int "Rendering buffer size"
	default 10
	range 1 100
	help
	  Size of the buffer used for rendering screen content as a percentage
	  of total display size.

config LVGL_DOUBLE_VDB
	bool "Use two rendering buffers"
	help
	  Use two buffers to render and flush data in parallel

choice
	prompt "Rendering Buffer Allocation"
	default LVGL_BUFFER_ALLOC_STATIC
	help
	  Type of allocation that should be used for allocating rendering buffers

config LVGL_BUFFER_ALLOC_STATIC
	bool "Static"
	help
	  Rendering buffers are statically allocated based on the following
	  configuration parameters:
	  * Horizontal screen resolution
	  * Vertical screen resolution
	  * Rendering buffer size
	  * Bytes per pixel

config LVGL_BUFFER_ALLOC_DYNAMIC
	bool "Dynamic"
	help
	  Rendering buffers are dynamically allocated based on the actual
	  display parameters

endchoice

config LVGL_SCREEN_REFRESH_PERIOD
	int "Screen refresh period"
	default 50
	help
	  Screen refresh period in milliseconds

config LVGL_INPUT_REFRESH_PERIOD
	int "Input device refresh period"
	default 50
	help
	  Refresh period for input devices in milliseconds

config LVGL_INPUT_DRAG_THRESHOLD
	int "Drag Threshold"
	default 10
	help
	  Threshold in pixels before entering drag mode

config LVGL_INPUT_DRAG_THROW_SLOW_DOWN
	int "Drag throw slow-down"
	default 20
	range 0 100
	help
	  Percentage of slow down of a throw following a drag.
	  Greater percentage means faster slow-down.

config LVGL_INPUT_LONG_PRESS_TIME
	int "Long press time"
	default 400
	help
	  Period in milliseconds before a press is seen as a long press

config LVGL_INPUT_LONG_RESS_REPEAT_TIME
	int "Long press repeat time"
	default 100
	help
	  Period in milliseconds after which a new trigger is generated
	  for a long press

choice
	prompt "String character encoding"
	default LVGL_TXT_ENC_ASCII

config LVGL_TXT_ENC_ASCII
	bool "ASCII string encoding"

config LVGL_TXT_ENC_UTF8
	bool "UTF-8 string encoding"

endchoice

config LVGL_TEXT_BREAK_CHARACTERS
	string "Text break characters"
	default " ,.;:-_"
	help
	  Characters on which a text break can take place

config LVGL_ANTIALIAS
	bool "Enable anti-aliasing"
	help
	  Enable anti-aliasing

config LVGL_ANIMATION
	bool "Enable animations"
	help
	  Enable animations

config LVGL_SHADOW
	bool "Enable shadows"
	help
	  Enable shadows

config LVGL_GROUP
	bool "Enable group support"
	help
	  Enable group support.
	  Used by keyboard and button input

config LVGL_GPU
	bool "Enable GPU support"
	help
	  Enable GPU support

config LVGL_IMG_CF_INDEXED
	bool "Enable indexed image support"
	default y
	help
	  Enable support for indexed images

config LVGL_IMG_CF_ALPHA
	bool "Enable alpha indexed image support"
	default y
	help
	  Enable support for alpha indexed images

config LVGL_FILESYSTEM
	bool "Enable file system"
	depends on FILE_SYSTEM
	default y if FILE_SYSTEM
	help
	  Enable LittlevGL file system

config LVGL_IMG_CACHE_DEF_SIZE
	int "Default image cache size"
	default 1
	help
	  Default image cache size, image caching keeps the images open.
	  If only the built-in image formats are used there is no real
	  advantage of caching. With complex image decoders (e.g. PNG or JPG)
	  caching can save the continuous decoding of images. However the
	  opened images might consume additional RAM.

rsource "Kconfig.themes"
rsource "Kconfig.fonts"
rsource "Kconfig.objects"

config APP_LINK_WITH_LVGL
	bool "Link 'app' with LVGL"
	default y
	help
	  Add LVGL header files to the 'app' include path. It may be
	  disabled if the include paths for LVGL are causing aliasing
	  issues for 'app'.

endif # LVGL
