接上文| # 【开鸿智谷NiobeU4开发板免费试用体验】控温(1); |
感谢开鸿智谷研发人员依然小烨哥和 大佬们的支持指导。
准备在上文基础上增加LCD。本文参考大佬们成功移植,
LCD方法:
起动系统及MobaXterm,
cd niobeu4_src/vendor/openvalley/niobeu4/demo/301_user/
git clone https://github.com/lvgl/lvgl.git
参考指令:
cd ~/niobeu4_src/vendor/openvalley/niobeu4/demo/301_user
cp -rf ../107_hdf_spi/st7735.h
cp -rf ../107_hdf_spi/st7735s.c
cp -f lvgl/examples/porting/lv_port_disp_template.c lvgl/lv_port_disp.c
cp -f lvgl/examples/porting/lv_port_disp_template.h lvgl/lv_port_disp.h
复制lvgl/lv_conf_template.h为lvgl/lv_conf.h
将#if 0改为1
暂时将542行的#define LV_USE_WIN 1 改为0
暂时将 39行#define LV_MEM_SIZE (128U * 1024U) / [bytes] /改为
#define LV_MEM_SIZE (12U * 1024U) / [bytes] /
按需提供堆大小,过大可能编译不过,过小可能影响创建对象。
/**
* [url=home.php?mod=space&uid=1455510]@file[/url] lv_conf.h
* Configuration file for v9.0.0-dev
*/
/*
* Copy this file as `lv_conf.h`
* 1. simply next to the `lvgl` folder
* 2. or any other places and
* - define `LV_CONF_INCLUDE_SIMPLE`
* - add the path as include path
*/
/* clang-format off */
#if 1 /*Set it to "1" to enable content*/
#ifndef LV_CONF_H
#define LV_CONF_H
#include <stdint.h>
/*====================
COLOR SETTINGS
*====================*/
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
#define LV_COLOR_DEPTH 16
#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00)
/*=========================
STDLIB WRAPPER SETTINGS
*=========================*/
/*Enable and configure the built-in memory manager*/
#define LV_USE_BUILTIN_MALLOC 1
#if LV_USE_BUILTIN_MALLOC
/*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/
#define LV_MEM_SIZE (12U * 1024U) /*[bytes]*/
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
#define LV_MEM_ADR 0 /*0: unused*/
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
#if LV_MEM_ADR == 0
#undef LV_MEM_POOL_INCLUDE
#undef LV_MEM_POOL_ALLOC
#endif
#endif /*LV_USE_BUILTIN_MALLOC*/
/*Enable lv_memcpy_builtin, lv_memset_builtin, lv_strlen_builtin, lv_strncpy_builtin*/
#define LV_USE_BUILTIN_MEMCPY 1
/*Enable and configure the built-in (v)snprintf */
#define LV_USE_BUILTIN_SNPRINTF 1
#if LV_USE_BUILTIN_SNPRINTF
#define LV_SPRINTF_USE_FLOAT 0
#endif /*LV_USE_BUILTIN_SNPRINTF*/
#define LV_STDLIB_INCLUDE <stdint.h>
#define LV_MALLOC lv_malloc_builtin
#define LV_REALLOC lv_realloc_builtin
#define LV_FREE lv_free_builtin
#define LV_MEMSET lv_memset_builtin
#define LV_MEMCPY lv_memcpy_builtin
#define LV_SNPRINTF lv_snprintf_builtin
#define LV_VSNPRINTF lv_vsnprintf_builtin
#define LV_STRLEN lv_strlen_builtin
#define LV_STRNCPY lv_strncpy_builtin
/*====================
HAL SETTINGS
*====================*/
/*Use a custom tick source that tells the elapsed time in milliseconds.
*It removes the need to manually update the tick with `lv_tick_inc()`)*/
#define LV_TICK_CUSTOM 0
#if LV_TICK_CUSTOM
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
#endif /*LV_TICK_CUSTOM*/
/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
*(Not so important, you can adjust it to modify default sizes and spaces)*/
#define LV_DPI_DEF 130 /*[px/inch]*/
/*========================
* DRAW CONFIGURATION
*========================*/
/*Enable the built in mask engine.
*Required to draw shadow, rounded corners, circles, arc, skew lines, or any other masks*/
#define LV_USE_DRAW_MASKS 1
#define LV_USE_DRAW_SW 1
#if LV_USE_DRAW_SW
/*Enable complex draw engine.
*Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/
#define LV_DRAW_SW_COMPLEX 1
/* If a widget has `style_opa < 255` (not `bg_opa`, `text_opa` etc) or not NORMAL blend mode
* it is buffered into a "simple" layer before rendering. The widget can be buffered in smaller chunks.
* "Transformed layers" (if `transform_angle/zoom` are set) use larger buffers
* and can't be drawn in chunks. */
/*The target buffer size for simple layer chunks.*/
#define LV_DRAW_SW_LAYER_SIMPLE_BUF_SIZE (24 * 1024) /*[bytes]*/
/*Used if `LV_DRAW_SW_LAYER_SIMPLE_BUF_SIZE` couldn't be allocated.*/
#define LV_DRAW_SW_LAYER_SIMPLE_FALLBACK_BUF_SIZE (3 * 1024) /*[bytes]*/
/*Allow buffering some shadow calculation.
*LV_DRAW_SW_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius`
*Caching has LV_DRAW_SW_SHADOW_CACHE_SIZE^2 RAM cost*/
#define LV_DRAW_SW_SHADOW_CACHE_SIZE 0
/* Set number of maximally cached circle data.
* The circumference of 1/4 circle are saved for anti-aliasing
* radius * 4 bytes are used per circle (the most often used radiuses are saved)
* 0: to disable caching */
#define LV_DRAW_SW_CIRCLE_CACHE_SIZE 4
/*Default gradient buffer size.
*When LVGL calculates the gradient "maps" it can save them into a cache to avoid calculating them again.
*LV_DRAW_SW_GRADIENT_CACHE_DEF_SIZE sets the size of this cache in bytes.
*If the cache is too small the map will be allocated only while it's required for the drawing.
*0 mean no caching.*/
#define LV_DRAW_SW_GRADIENT_CACHE_DEF_SIZE 0
/*Allow dithering the gradients (to achieve visual smooth color gradients on limited color depth display)
*LV_DRAW_SW_GRADIENT_DITHER implies allocating one or two more lines of the object's rendering surface
*The increase in memory consumption is (32 bits * object width) plus 24 bits * object width if using error diffusion */
#define LV_DRAW_SW_GRADIENT_DITHER 0
#if LV_DRAW_SW_GRADIENT_DITHER
/*Add support for error diffusion dithering.
*Error diffusion dithering gets a much better visual result, but implies more CPU consumption and memory when drawing.
*The increase in memory consumption is (24 bits * object's width)*/
#define LV_DRAW_SW_GRADIENT_DITHER_ERROR_DIFFUSION 0
#endif
/*Enable subpixel rendering*/
#define LV_DRAW_SW_FONT_SUBPX 0
#if LV_DRAW_SW_FONT_SUBPX
/*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/
#define LV_DRAW_SW_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/
#endif
#endif
/*Use SDL renderer API*/
#define LV_USE_DRAW_SDL 0
#if LV_USE_DRAW_SDL
#define LV_DRAW_SDL_INCLUDE_PATH <SDL2/SDL.h>
/*Texture cache size, 8MB by default*/
#define LV_DRAW_SDL_LRU_SIZE (1024 * 1024 * 8)
/*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/
#define LV_DRAW_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6))
#endif
/*=====================
* GPU CONFIGURATION
*=====================*/
/*Use Arm's 2D acceleration library Arm-2D */
#define LV_USE_GPU_ARM2D 0
/*Use STM32's DMA2D (aka Chrom Art) GPU*/
#define LV_USE_GPU_STM32_DMA2D 0
#if LV_USE_GPU_STM32_DMA2D
/*Must be defined to include path of CMSIS header of target processor
e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#define LV_GPU_DMA2D_CMSIS_INCLUDE
#endif
/*Use GD32 IPA GPU
* This adds support for Image Processing Accelerator on GD32F450 and GD32F470 series MCUs
*
* NOTE: IPA on GD32F450 has a bug where the fill operation overwrites data beyond the
* framebuffer. This driver works around it by saving and restoring affected memory, but
* this makes it not thread-safe. GD32F470 is not affected. */
#define LV_USE_GPU_GD32_IPA 0
/*Use NXP's PXP GPU iMX RTxxx platforms*/
#define LV_USE_GPU_NXP_PXP 0
#if LV_USE_GPU_NXP_PXP
/*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c)
* and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS
* has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected.
*0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init()
*/
#define LV_USE_GPU_NXP_PXP_AUTO_INIT 0
#endif
/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/
#define LV_USE_GPU_NXP_VG_LITE 0
/*Use SWM341's DMA2D GPU*/
#define LV_USE_GPU_SWM341_DMA2D 0
#if LV_USE_GPU_SWM341_DMA2D
#define LV_GPU_SWM341_DMA2D_INCLUDE "SWM341.h"
#endif
/*=======================
* FEATURE CONFIGURATION
*=======================*/
/*-------------
* Logging
*-----------*/
/*Enable the log module*/
#define LV_USE_LOG 0
#if LV_USE_LOG
/*How important log should be added:
*LV_LOG_LEVEL_TRACE A lot of logs to give detailed information
*LV_LOG_LEVEL_INFO Log important events
*LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem
*LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
*LV_LOG_LEVEL_USER Only logs added by the user
*LV_LOG_LEVEL_NONE Do not log anything*/
#define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
/*1: Print the log with 'printf';
*0: User need to register a callback with `lv_log_register_print_cb()`*/
#define LV_LOG_PRINTF 0
/*1: Enable print timestamp;
*0: Disable print timestamp*/
#define LV_LOG_USE_TIMESTAMP 1
/*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/
#define LV_LOG_TRACE_MEM 1
#define LV_LOG_TRACE_TIMER 1
#define LV_LOG_TRACE_INDEV 1
#define LV_LOG_TRACE_DISP_REFR 1
#define LV_LOG_TRACE_EVENT 1
#define LV_LOG_TRACE_OBJ_CREATE 1
#define LV_LOG_TRACE_LAYOUT 1
#define LV_LOG_TRACE_ANIM 1
#endif /*LV_USE_LOG*/
/*-------------
* Asserts
*-----------*/
/*Enable asserts if an operation is failed or an invalid data is found.
*If LV_USE_LOG is enabled an error message will be printed on failure*/
#define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/
#define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/
#define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/
#define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/
#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/
/*Add a custom handler when assert happens e.g. to restart the MCU*/
#define LV_ASSERT_HANDLER_INCLUDE <stdint.h>
#define LV_ASSERT_HANDLER while(1); /*Halt by default*/
/*-------------
* Others
*-----------*/
/*1: Show CPU usage and FPS count*/
#define LV_USE_PERF_MONITOR 0
#if LV_USE_PERF_MONITOR
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
#endif
/*1: Show the used memory and the memory fragmentation
* Requires `LV_USE_BUILTIN_MALLOC = 1`*/
#define LV_USE_MEM_MONITOR 0
#if LV_USE_MEM_MONITOR
#define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
#endif
/*1: Draw random colored rectangles over the redrawn areas*/
#define LV_USE_REFR_DEBUG 0
/*Maximum buffer size to allocate for rotation.
*Only used if software rotation is enabled in the display driver.*/
#define LV_DISP_ROT_MAX_BUF (10*1024)
#define LV_USE_USER_DATA 1
/*Garbage Collector settings
*Used if lvgl is bound to higher level language and the memory is managed by that language*/
#define LV_ENABLE_GC 0
#if LV_ENABLE_GC != 0
#define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/
#endif /*LV_ENABLE_GC*/
/*Default image cache size. Image caching keeps some images opened.
*If only the built-in image formats are used there is no real advantage of caching.
*With other image decoders (e.g. PNG or JPG) caching save the continuous open/decode of images.
*However the opened images consume additional RAM.
*0: to disable caching*/
#define LV_IMG_CACHE_DEF_SIZE 0
/*Number of stops allowed per gradient. Increase this to allow more stops.
*This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/
#define LV_GRADIENT_MAX_STOPS 2
/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently.
* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
#define LV_COLOR_MIX_ROUND_OFS 0
/*=====================
* COMPILER SETTINGS
*====================*/
/*For big endian systems set to 1*/
#define LV_BIG_ENDIAN_SYSTEM 0
/*Define a custom attribute to `lv_tick_inc` function*/
#define LV_ATTRIBUTE_TICK_INC
/*Define a custom attribute to `lv_timer_handler` function*/
#define LV_ATTRIBUTE_TIMER_HANDLER
/*Define a custom attribute to `lv_disp_flush_ready` function*/
#define LV_ATTRIBUTE_FLUSH_READY
/*Required alignment size for buffers*/
#define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1
/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default).
* E.g. __attribute__((aligned(4)))*/
#define LV_ATTRIBUTE_MEM_ALIGN
/*Attribute to mark large constant arrays for example font's bitmaps*/
#define LV_ATTRIBUTE_LARGE_CONST
/*Compiler prefix for a big array declaration in RAM*/
#define LV_ATTRIBUTE_LARGE_RAM_ARRAY
/*Place performance critical functions into a faster memory (e.g RAM)*/
#define LV_ATTRIBUTE_FAST_MEM
/*Export integer constant to binding. This macro is used with constants in the form of LV_<CONST> that
*should also appear on LVGL binding API such as Micropython.*/
#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/
/*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/
#define LV_USE_LARGE_COORD 0
/*==================
* FONT USAGE
*===================*/
/*Montserrat fonts with ASCII range and some symbols using bpp = 4
*https://fonts.google.com/specimen/Montserrat*/
#define LV_FONT_MONTSERRAT_8 0
#define LV_FONT_MONTSERRAT_10 0
#define LV_FONT_MONTSERRAT_12 0
#define LV_FONT_MONTSERRAT_14 1
#define LV_FONT_MONTSERRAT_16 0
#define LV_FONT_MONTSERRAT_18 0
#define LV_FONT_MONTSERRAT_20 0
#define LV_FONT_MONTSERRAT_22 0
#define LV_FONT_MONTSERRAT_24 0
#define LV_FONT_MONTSERRAT_26 0
#define LV_FONT_MONTSERRAT_28 0
#define LV_FONT_MONTSERRAT_30 0
#define LV_FONT_MONTSERRAT_32 0
#define LV_FONT_MONTSERRAT_34 0
#define LV_FONT_MONTSERRAT_36 0
#define LV_FONT_MONTSERRAT_38 0
#define LV_FONT_MONTSERRAT_40 0
#define LV_FONT_MONTSERRAT_42 0
#define LV_FONT_MONTSERRAT_44 0
#define LV_FONT_MONTSERRAT_46 0
#define LV_FONT_MONTSERRAT_48 0
/*Demonstrate special features*/
#define LV_FONT_MONTSERRAT_12_SUBPX 0
#define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/
#define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/
#define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/
/*Pixel perfect monospace fonts*/
#define LV_FONT_UNSCII_8 0
#define LV_FONT_UNSCII_16 0
/*Optionally declare custom fonts here.
*You can use these fonts as default font too and they will be available globally.
*E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/
#define LV_FONT_CUSTOM_DECLARE
/*Always set a default font*/
#define LV_FONT_DEFAULT &lv_font_montserrat_14
/*Enable handling large font and/or fonts with a lot of characters.
*The limit depends on the font size, font face and bpp.
*Compiler error will be triggered if a font needs it.*/
#define LV_FONT_FMT_TXT_LARGE 0
/*Enables/disables support for compressed fonts.*/
#define LV_USE_FONT_COMPRESSED 0
/*Enable drawing placeholders when glyph dsc is not found*/
#define LV_USE_FONT_PLACEHOLDER 1
/*=================
* TEXT SETTINGS
*=================*/
/**
* Select a character encoding for strings.
* Your IDE or editor should have the same character encoding
* - LV_TXT_ENC_UTF8
* - LV_TXT_ENC_ASCII
*/
#define LV_TXT_ENC LV_TXT_ENC_UTF8
/*Can break (wrap) texts on these chars*/
#define LV_TXT_BREAK_CHARS " ,.;:-_)]}"
/*If a word is at least this long, will break wherever "prettiest"
*To disable, set to a value <= 0*/
#define LV_TXT_LINE_BREAK_LONG_LEN 0
/*Minimum number of characters in a long word to put on a line before a break.
*Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3
/*Minimum number of characters in a long word to put on a line after a break.
*Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/
#define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3
/*The control character to use for signalling text recoloring.*/
#define LV_TXT_COLOR_CMD "#"
/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts.
*The direction will be processed according to the Unicode Bidirectional Algorithm:
*https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/
#define LV_USE_BIDI 0
#if LV_USE_BIDI
/*Set the default direction. Supported values:
*`LV_BASE_DIR_LTR` Left-to-Right
*`LV_BASE_DIR_RTL` Right-to-Left
*`LV_BASE_DIR_AUTO` detect texts base direction*/
#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO
#endif
/*Enable Arabic/Persian processing
*In these languages characters should be replaced with an other form based on their position in the text*/
#define LV_USE_ARABIC_PERSIAN_CHARS 0
/*==================
* WIDGETS
*================*/
/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/
#define LV_USE_ANIMIMG 1
#define LV_USE_ARC 1
#define LV_USE_BAR 1
#define LV_USE_BTN 1
#define LV_USE_BTNMATRIX 1
#define LV_USE_CALENDAR 1
#if LV_USE_CALENDAR
#define LV_CALENDAR_WEEK_STARTS_MONDAY 0
#if LV_CALENDAR_WEEK_STARTS_MONDAY
#define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"}
#else
#define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}
#endif
#define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
#define LV_USE_CALENDAR_HEADER_ARROW 1
#define LV_USE_CALENDAR_HEADER_DROPDOWN 1
#endif /*LV_USE_CALENDAR*/
#define LV_USE_CANVAS 1
#define LV_USE_CHART 1
#define LV_USE_CHECKBOX 1
#define LV_USE_COLORWHEEL 1
#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/
#define LV_USE_IMG 1 /*Requires: lv_label*/
#define LV_USE_IMGBTN 1
#define LV_USE_KEYBOARD 1
#define LV_USE_LABEL 1
#if LV_USE_LABEL
#define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/
#define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/
#endif
#define LV_USE_LED 1
#define LV_USE_LINE 1
#define LV_USE_LIST 1
#define LV_USE_MENU 1
#define LV_USE_METER 1
#define LV_USE_MSGBOX 1
#define LV_USE_ROLLER 1 /*Requires: lv_label*/
#define LV_USE_SLIDER 1 /*Requires: lv_bar*/
#define LV_USE_SPAN 1
#if LV_USE_SPAN
/*A line text can contain maximum num of span descriptor */
#define LV_SPAN_SNIPPET_STACK_SIZE 64
#endif
#define LV_USE_SPINBOX 1
#define LV_USE_SPINNER 1
#define LV_USE_SWITCH 1
#define LV_USE_TEXTAREA 1 /*Requires: lv_label*/
#if LV_USE_TEXTAREA != 0
#define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/
#endif
#define LV_USE_TABLE 1
#define LV_USE_TABVIEW 1
#define LV_USE_TILEVIEW 1
#define LV_USE_WIN 0
/*==================
* THEMES
*==================*/
/*A simple, impressive and very complete theme*/
#define LV_USE_THEME_DEFAULT 1
#if LV_USE_THEME_DEFAULT
/*0: Light mode; 1: Dark mode*/
#define LV_THEME_DEFAULT_DARK 0
/*1: Enable grow on press*/
#define LV_THEME_DEFAULT_GROW 1
/*Default transition time in [ms]*/
#define LV_THEME_DEFAULT_TRANSITION_TIME 80
#endif /*LV_USE_THEME_DEFAULT*/
/*A very simple theme that is a good starting point for a custom theme*/
#define LV_USE_THEME_BASIC 1
/*A theme designed for monochrome displays*/
#define LV_USE_THEME_MONO 1
/*==================
* LAYOUTS
*==================*/
/*A layout similar to Flexbox in CSS.*/
#define LV_USE_FLEX 1
/*A layout similar to Grid in CSS.*/
#define LV_USE_GRID 1
/*====================
* 3RD PARTS LIBRARIES
*====================*/
/*File system interfaces for common APIs */
/*API for fopen, fread, etc*/
#define LV_USE_FS_STDIO 0
#if LV_USE_FS_STDIO
#define LV_FS_STDIO_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
#define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
/*API for open, read, etc*/
#define LV_USE_FS_POSIX 0
#if LV_USE_FS_POSIX
#define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
#define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
/*API for CreateFile, ReadFile, etc*/
#define LV_USE_FS_WIN32 0
#if LV_USE_FS_WIN32
#define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
#define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/
#define LV_USE_FS_FATFS 0
#if LV_USE_FS_FATFS
#define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
#define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
#endif
/*PNG decoder library*/
#define LV_USE_PNG 0
/*BMP decoder library*/
#define LV_USE_BMP 0
/* JPG + split JPG decoder library.
* Split JPG is a custom format optimized for embedded systems. */
#define LV_USE_SJPG 0
/*GIF decoder library*/
#define LV_USE_GIF 0
/*QR code library*/
#define LV_USE_QRCODE 0
/*FreeType library*/
#define LV_USE_FREETYPE 0
#if LV_USE_FREETYPE
/*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/
#define LV_FREETYPE_CACHE_SIZE (16 * 1024)
#if LV_FREETYPE_CACHE_SIZE >= 0
/* 1: bitmap cache use the sbit cache, 0:bitmap cache use the image cache. */
/* sbit cache:it is much more memory efficient for small bitmaps(font size < 256) */
/* if font size >= 256, must be configured as image cache */
#define LV_FREETYPE_SBIT_CACHE 0
/* Maximum number of opened FT_Face/FT_Size objects managed by this cache instance. */
/* (0:use system defaults) */
#define LV_FREETYPE_CACHE_FT_FACES 0
#define LV_FREETYPE_CACHE_FT_SIZES 0
#endif
#endif
/* Built-in TTF decoder */
#define LV_USE_TINY_TTF 0
#if LV_USE_TINY_TTF
/* Enable loading TTF data from files */
#define LV_TINY_TTF_FILE_SUPPORT 0
#endif
/*Rlottie library*/
#define LV_USE_RLOTTIE 0
/*FFmpeg library for image decoding and playing videos
*Supports all major image formats so do not enable other image decoder with it*/
#define LV_USE_FFMPEG 0
#if LV_USE_FFMPEG
/*Dump input information to stderr*/
#define LV_FFMPEG_DUMP_FORMAT 0
#endif
/*==================
* OTHERS
*==================*/
/*1: Enable API to take snapshot for object*/
#define LV_USE_SNAPSHOT 0
/*1: Enable Monkey test*/
#define LV_USE_MONKEY 0
/*1: Enable grid navigation*/
#define LV_USE_GRIDNAV 0
/*1: Enable lv_obj fragment*/
#define LV_USE_FRAGMENT 0
/*1: Support using images as font in label or span widgets */
#define LV_USE_IMGFONT 0
#if LV_USE_IMGFONT
/*Imgfont image file path maximum length*/
#define LV_IMGFONT_PATH_MAX_LEN 64
/*1: Use img cache to buffer header information*/
#define LV_IMGFONT_USE_IMG_CACHE_HEADER 0
#endif
/*1: Enable a published subscriber based messaging system */
#define LV_USE_MSG 0
/*1: Enable Pinyin input method*/
/*Requires: lv_keyboard*/
#define LV_USE_IME_PINYIN 0
#if LV_USE_IME_PINYIN
/*1: Use default thesaurus*/
/*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesauruss*/
#define LV_IME_PINYIN_USE_DEFAULT_DICT 1
/*Set the maximum number of candidate panels that can be displayed*/
/*This needs to be adjusted according to the size of the screen*/
#define LV_IME_PINYIN_CAND_TEXT_NUM 6
/*Use 9 key input(k9)*/
#define LV_IME_PINYIN_USE_K9_MODE 1
#if LV_IME_PINYIN_USE_K9_MODE == 1
#define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3
#endif // LV_IME_PINYIN_USE_K9_MODE
#endif
/*1: Enable file explorer*/
/*Requires: lv_table*/
#define LV_USE_FILE_EXPLORER 0
#if LV_USE_FILE_EXPLORER
/*Maximum length of path*/
#define LV_FILE_EXPLORER_PATH_MAX_LEN (128)
/*Quick access bar, 1:use, 0:not use*/
/*Requires: lv_list*/
#define LV_FILE_EXPLORER_QUICK_ACCESS 1
#endif
/*==================
* EXAMPLES
*==================*/
/*Enable the examples to be built with the library*/
#define LV_BUILD_EXAMPLES 1
/*===================
* DEMO USAGE
====================*/
/*Show some widget. It might be required to increase `LV_MEM_SIZE` */
#define LV_USE_DEMO_WIDGETS 0
#if LV_USE_DEMO_WIDGETS
#define LV_DEMO_WIDGETS_SLIDESHOW 0
#endif
/*Demonstrate the usage of encoder and keyboard*/
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0
/*Benchmark your system*/
#define LV_USE_DEMO_BENCHMARK 0
#if LV_USE_DEMO_BENCHMARK
/*Use RGB565A8 images with 16 bit color depth instead of ARGB8565*/
#define LV_DEMO_BENCHMARK_RGB565A8 0
#endif
/*Stress test for LVGL*/
#define LV_USE_DEMO_STRESS 0
/*Music player demo*/
#define LV_USE_DEMO_MUSIC 0
#if LV_USE_DEMO_MUSIC
#define LV_DEMO_MUSIC_SQUARE 0
#define LV_DEMO_MUSIC_LANDSCAPE 0
#define LV_DEMO_MUSIC_ROUND 0
#define LV_DEMO_MUSIC_LARGE 0
#define LV_DEMO_MUSIC_AUTO_PLAY 0
#endif
/*--END OF LV_CONF_H--*/
#endif /*LV_CONF_H*/
#endif /*End of "Content enable"*/
将里面的#if 0改为1,
加入:
#include "../st7735.h"
#define LV_LVGL_H_INCLUDE_SIMPLE 1
#define MY_DISP_HOR_RES ROW_PIXEL
#define MY_DISP_VER_RES COL_PIXEL
/**
* @file lv_port_disp_templ.h
*
*/
/*Copy this file as "lv_port_disp.h" and set this value to "1" to enable content*/
#if 1
#include "../st7735.h"
#ifndef LV_PORT_DISP_TEMPL_H
#define LV_PORT_DISP_TEMPL_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
/*********************
* DEFINES
*********************/
#define LV_LVGL_H_INCLUDE_SIMPLE 1
#define MY_DISP_HOR_RES ROW_PIXEL
#define MY_DISP_VER_RES COL_PIXEL
将里面的#if 0改为1,#include "lv_port_disp_template.h"改为#include "lv_port_disp.h"
修改disp_init(void)加入LcdInit();
修改 lv_port_disp_init(void),
删掉Example for 2)和 Example for 3) 内对应的代码
修改static void disp_flush(),
/ Put a pixel to the display. For example: /
/*put_px(x, y, color_p) /改为lcd_draw_point(x,y,color_p->full);尾部加LcdPush();代码
/**
* @file lv_port_disp_templ.c
*
*/
/*Copy this file as "lv_port_disp.c" and set this value to "1" to enable content*/
#if 1
/*********************
* INCLUDES
*********************/
#include "lv_port_disp.h"
#include <stdbool.h>
/*********************
* DEFINES
*********************/
#ifndef MY_DISP_HOR_RES
#warning Please define or replace the macro MY_DISP_HOR_RES with the actual screen width, default value 320 is used for now.
#define MY_DISP_HOR_RES 320
#endif
#ifndef MY_DISP_VER_RES
#warning Please define or replace the macro MY_DISP_HOR_RES with the actual screen height, default value 240 is used for now.
#define MY_DISP_VER_RES 240
#endif
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void disp_init(void);
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
// const lv_area_t * fill_area, lv_color_t color);
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void lv_port_disp_init(void)
{
/*-------------------------
* Initialize your display
* -----------------------*/
LcdInit();
/*-----------------------------
* Create a buffer for drawing
*----------------------------*/
/**
* LVGL requires a buffer where it internally draws the widgets.
* Later this buffer will passed to your display driver's `flush_cb` to copy its content to your display.
* The buffer has to be greater than 1 display row
*
* There are 3 buffering configurations:
* 1. Create ONE buffer:
* LVGL will draw the display's content here and writes it to your display
*
* 2. Create TWO buffer:
* LVGL will draw the display's content to a buffer and writes it your display.
* You should use DMA to write the buffer's content to the display.
* It will enable LVGL to draw the next part of the screen to the other buffer while
* the data is being sent form the first buffer. It makes rendering and flushing parallel.
*
* 3. Double buffering
* Set 2 screens sized buffers and set disp_drv.full_refresh = 1.
* This way LVGL will always provide the whole rendered screen in `flush_cb`
* and you only need to change the frame buffer's address.
*/
/* Example for 1) */
static lv_disp_draw_buf_t draw_buf_dsc_1;
static lv_color_t buf_1[MY_DISP_HOR_RES * 10]; /*A buffer for 10 rows*/
lv_disp_draw_buf_init(&draw_buf_dsc_1, buf_1, NULL, MY_DISP_HOR_RES * 10); /*Initialize the display buffer*/
/*-----------------------------------
* Register the display in LVGL
*----------------------------------*/
static lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
/*Set up the functions to access to your display*/
/*Set the resolution of the display*/
disp_drv.hor_res = MY_DISP_HOR_RES;
disp_drv.ver_res = MY_DISP_VER_RES;
/*Used to copy the buffer's content to the display*/
disp_drv.flush_cb = disp_flush;
/*Set a display buffer*/
disp_drv.draw_buf = &draw_buf_dsc_1;
/*Required for Example 3)*/
//disp_drv.full_refresh = 1;
/* Fill a memory array with a color if you have GPU.
* Note that, in lv_conf.h you can enable GPUs that has built-in support in LVGL.
* But if you have a different GPU you can use with this callback.*/
//disp_drv.gpu_fill_cb = gpu_fill;
/*Finally register the driver*/
lv_disp_drv_register(&disp_drv);
}
/**********************
* STATIC FUNCTIONS
**********************/
/*Initialize your display and the required peripherals.*/
static void disp_init(void)
{
/*You code here*/LcdInit();
}
volatile bool disp_flush_enabled = true;
/* Enable updating the screen (the flushing process) when disp_flush() is called by LVGL
*/
void disp_enable_update(void)
{
disp_flush_enabled = true;
}
/* Disable updating the screen (the flushing process) when disp_flush() is called by LVGL
*/
void disp_disable_update(void)
{
disp_flush_enabled = false;
}
/*Flush the content of the internal buffer the specific area on the display
*You can use DMA or any hardware acceleration to do this operation in the background but
*'lv_disp_flush_ready()' has to be called when finished.*/
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
{
if(disp_flush_enabled) {
/*The most simple case (but also the slowest) to put all pixels to the screen one-by-one*/
int32_t x;
int32_t y;
for(y = area->y1; y <= area->y2; y++) {
for(x = area->x1; x <= area->x2; x++) {
lcd_draw_point(x,y,color_p->full);
color_p++;
}
}
LcdPush(); }
/*IMPORTANT!!!
*Inform the graphics library that you are ready with the flushing*/
lv_disp_flush_ready(disp_drv);
}
/*OPTIONAL: GPU INTERFACE*/
/*If your MCU has hardware accelerator (GPU) then you can use it to fill a memory with a color*/
//static void gpu_fill(lv_disp_drv_t * disp_drv, lv_color_t * dest_buf, lv_coord_t dest_width,
// const lv_area_t * fill_area, lv_color_t color)
//{
// /*It's an example code which should be done by your GPU*/
// int32_t x, y;
// dest_buf += dest_width * fill_area->y1; /*Go to the first line*/
//
// for(y = fill_area->y1; y <= fill_area->y2; y++) {
// for(x = fill_area->x1; x <= fill_area->x2; x++) {
// dest_buf[x] = color;
// }
// dest_buf+=dest_width; /*Go to the next line*/
// }
//}
#else /*Enable this file at the top*/
/*This dummy typedef exists purely to silence -Wpedantic.*/
typedef int keep_pedantic_happy;
#endif
此处修改方式与参考文件不同,此处修改如下
在/home/lst/niobeu4_src/vendor/openvalley/niobeu4/demo/301_user/lvgl/src/hal/lv_hal_tick.c中加入LOS_Msleep(tick_period);如下
/**
* You have to call this function periodically
* [url=home.php?mod=space&uid=3142012]@param[/url] tick_period the call period of this function in milliseconds
*/
LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period)
{
tick_irq_flag = 0;
sys_time += tick_period;
LOS_Msleep(tick_period);
}
在MobaXterm右侧
在niobeu4_src/vendor/openvalley/niobeu4/demo/301_user目录
下打开# .application_config文件,修改内容:
# Copyright (c) 2022 Hunan OpenValley Digital Industry Development Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
config NIOBEU4_APPLICATION_301
bool "301_user"
select DRIVERS
select DRIVERS_HDF
select DRIVERS_HDF_PLATFORM
select DRIVERS_HDF_CONFIG_MACRO
select DRIVERS_HDF_PLATFORM_SPI
select DRIVERS_HDF_PLATFORM_GPIO
select DRIVERS_HDF_PLATFORM_ADC
在MobaXterm右侧
在niobeu4_src/vendor/openvalley/niobeu4/demo/301_user目录
下打开BUILD.gn文件,修改内容:
将lv_conf.h添加到工程头文件包含路径。
即修改
niobeu4_src/vendor/openvalley/niobeu4/demo/301_user/BUILD.gn
include_dirs = [
下添加一行"lvgl/",
# Copyright (c) 2022 Hunan OpenValley Digital Industry Development Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//kernel/liteos_m/liteos.gni")
assert(defined(LOSCFG_DRIVERS_HDF_CONFIG_MACRO), "Must Config LOSCFG_DRIVERS_HDF_CONFIG_MACRO in kernel/liteos_m menuconfig!")
assert(defined(LOSCFG_DRIVERS_HDF_PLATFORM_SPI), "Must Config LOSCFG_DRIVERS_HDF_PLATFORM_SPI in kernel/liteos_m menuconfig!")
assert(defined(LOSCFG_DRIVERS_HDF_PLATFORM_GPIO), "Must Config LOSCFG_DRIVERS_HDF_PLATFORM_GPIO in kernel/liteos_m menuconfig!")
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name){
sources = [
"os_thread_example.c",
"st7735s.c",
"lvgl/src/core/lv_disp.c",
"lvgl/src/core/lv_event.c",
"lvgl/src/core/lv_group.c",
"lvgl/src/core/lv_indev_scroll.c",
"lvgl/src/core/lv_indev.c",
"lvgl/src/core/lv_obj_class.c",
"lvgl/src/core/lv_obj_draw.c",
"lvgl/src/core/lv_obj_pos.c",
"lvgl/src/core/lv_obj_scroll.c",
"lvgl/src/core/lv_obj_style_gen.c",
"lvgl/src/core/lv_obj_style.c",
"lvgl/src/core/lv_obj_tree.c",
"lvgl/src/core/lv_obj.c",
"lvgl/src/core/lv_refr.c",
"lvgl/src/core/lv_theme.c",
"lvgl/src/draw/sw/lv_draw_sw_arc.c",
"lvgl/src/draw/sw/lv_draw_sw_blend.c",
"lvgl/src/draw/sw/lv_draw_sw_dither.c",
"lvgl/src/draw/sw/lv_draw_sw_gradient.c",
"lvgl/src/draw/sw/lv_draw_sw_img.c",
"lvgl/src/draw/sw/lv_draw_sw_layer.c",
"lvgl/src/draw/sw/lv_draw_sw_letter.c",
"lvgl/src/draw/sw/lv_draw_sw_line.c",
"lvgl/src/draw/sw/lv_draw_sw_polygon.c",
"lvgl/src/draw/sw/lv_draw_sw_rect.c",
"lvgl/src/draw/sw/lv_draw_sw_transform.c",
"lvgl/src/draw/sw/lv_draw_sw.c",
"lvgl/src/draw/lv_draw_arc.c",
"lvgl/src/draw/lv_draw_img.c",
"lvgl/src/draw/lv_draw_label.c",
"lvgl/src/draw/lv_draw_layer.c",
"lvgl/src/draw/lv_draw_line.c",
"lvgl/src/draw/lv_draw_mask.c",
"lvgl/src/draw/lv_draw_rect.c",
"lvgl/src/draw/lv_draw_transform.c",
"lvgl/src/draw/lv_draw_triangle.c",
"lvgl/src/draw/lv_draw.c",
"lvgl/src/draw/lv_img_buf.c",
"lvgl/src/draw/lv_img_cache.c",
"lvgl/src/draw/lv_img_decoder.c",
"lvgl/src/font/lv_font_fmt_txt.c",
"lvgl/src/font/lv_font.c",
"lvgl/src/font/lv_font_montserrat_12.c",
"lvgl/src/font/lv_font_montserrat_14.c",
"lvgl/src/font/lv_font_montserrat_16.c",
"lvgl/src/hal/lv_hal_disp.c",
"lvgl/src/hal/lv_hal_indev.c",
"lvgl/src/hal/lv_hal_tick.c",
"lvgl/src/layouts/flex/lv_flex.c",
"lvgl/src/layouts/grid/lv_grid.c",
"lvgl/src/libs/bmp/lv_bmp.c",
"lvgl/src/libs/ffmpeg/lv_ffmpeg.c",
"lvgl/src/libs/freetype/lv_freetype.c",
"lvgl/src/libs/fsdrv/lv_fs_fatfs.c",
"lvgl/src/libs/fsdrv/lv_fs_posix.c",
"lvgl/src/libs/fsdrv/lv_fs_stdio.c",
"lvgl/src/libs/fsdrv/lv_fs_win32.c",
"lvgl/src/libs/gif/gifdec.c",
"lvgl/src/libs/gif/lv_gif.c",
"lvgl/src/libs/png/lodepng.c",
"lvgl/src/libs/png/lv_png.c",
"lvgl/src/libs/qrcode/lv_qrcode.c",
"lvgl/src/libs/qrcode/qrcodegen.c",
"lvgl/src/libs/rlottie/lv_rlottie.c",
"lvgl/src/libs/sjpg/lv_sjpg.c",
"lvgl/src/libs/sjpg/tjpgd.c",
"lvgl/src/misc/lv_anim_timeline.c",
"lvgl/src/misc/lv_anim.c",
"lvgl/src/misc/lv_area.c",
"lvgl/src/misc/lv_async.c",
"lvgl/src/misc/lv_bidi.c",
"lvgl/src/misc/lv_color.c",
"lvgl/src/misc/lv_fs.c",
"lvgl/src/misc/lv_gc.c",
"lvgl/src/misc/lv_ll.c",
"lvgl/src/misc/lv_log.c",
"lvgl/src/misc/lv_lru.c",
"lvgl/src/misc/lv_malloc_builtin.c",
"lvgl/src/misc/lv_math.c",
"lvgl/src/misc/lv_mem.c",
"lvgl/src/misc/lv_memcpy_builtin.c",
"lvgl/src/misc/lv_printf.c",
"lvgl/src/misc/lv_style_gen.c",
"lvgl/src/misc/lv_style.c",
"lvgl/src/misc/lv_templ.c",
"lvgl/src/misc/lv_timer.c",
"lvgl/src/misc/lv_tlsf.c",
"lvgl/src/misc/lv_txt_ap.c",
"lvgl/src/misc/lv_txt.c",
"lvgl/src/misc/lv_utils.c",
"lvgl/src/others/file_explorer/lv_file_explorer.c",
"lvgl/src/others/fragment/lv_fragment_manager.c",
"lvgl/src/others/fragment/lv_fragment.c",
"lvgl/src/others/gridnav/lv_gridnav.c",
"lvgl/src/others/ime/lv_ime_pinyin.c",
"lvgl/src/others/imgfont/lv_imgfont.c",
"lvgl/src/others/monkey/lv_monkey.c",
"lvgl/src/others/msg/lv_msg.c",
"lvgl/src/others/snapshot/lv_snapshot.c",
"lvgl/src/themes/basic/lv_theme_basic.c",
"lvgl/src/themes/default/lv_theme_default.c",
"lvgl/src/themes/mono/lv_theme_mono.c",
"lvgl/src/widgets/animimg/lv_animimg.c",
"lvgl/src/widgets/arc/lv_arc.c",
"lvgl/src/widgets/bar/lv_bar.c",
"lvgl/src/widgets/btn/lv_btn.c",
"lvgl/src/widgets/btnmatrix/lv_btnmatrix.c",
"lvgl/src/widgets/calendar/lv_calendar_header_arrow.c",
"lvgl/src/widgets/calendar/lv_calendar_header_dropdown.c",
"lvgl/src/widgets/calendar/lv_calendar.c",
"lvgl/src/widgets/canvas/lv_canvas.c",
"lvgl/src/widgets/chart/lv_chart.c",
"lvgl/src/widgets/checkbox/lv_checkbox.c",
"lvgl/src/widgets/colorwheel/lv_colorwheel.c",
"lvgl/src/widgets/dropdown/lv_dropdown.c",
"lvgl/src/widgets/img/lv_img.c",
"lvgl/src/widgets/imgbtn/lv_imgbtn.c",
"lvgl/src/widgets/keyboard/lv_keyboard.c",
"lvgl/src/widgets/label/lv_label.c",
"lvgl/src/widgets/led/lv_led.c",
"lvgl/src/widgets/line/lv_line.c",
"lvgl/src/widgets/list/lv_list.c",
"lvgl/src/widgets/menu/lv_menu.c",
"lvgl/src/widgets/meter/lv_meter.c",
"lvgl/src/widgets/msgbox/lv_msgbox.c",
"lvgl/src/widgets/objx_templ/lv_objx_templ.c",
"lvgl/src/widgets/roller/lv_roller.c",
"lvgl/src/widgets/slider/lv_slider.c",
"lvgl/src/widgets/span/lv_span.c",
"lvgl/src/widgets/spinbox/lv_spinbox.c",
"lvgl/src/widgets/spinner/lv_spinner.c",
"lvgl/src/widgets/switch/lv_switch.c",
"lvgl/src/widgets/table/lv_table.c",
"lvgl/src/widgets/tabview/lv_tabview.c",
"lvgl/src/widgets/textarea/lv_textarea.c",
"lvgl/src/widgets/tileview/lv_tileview.c",
"lvgl/lv_port_disp.c",
#"lvgl/demos/music/lv_demo_music_list.c",
#"lvgl/demos/music/lv_demo_music_main.c",
#"lvgl/demos/music/lv_demo_music.c",
"lvgl/demos/stress/lv_demo_stress.c",
]
include_dirs = [
"//drivers/hdf_core/framework/include/platform/",
"//drivers/hdf_core/framework/include/utils/",
"//drivers/hdf_core/framework/support/platform/include/spi",
"//drivers/hdf_core/adapter/khdf/liteos_m/osal/include/",
"//drivers/hdf_core/framework/include/core/",
"//drivers/hdf_core/framework/include/osal/",
"//drivers/hdf_core/framework/support/platform/include/gpio",
"//kernel/liteos_m/kernel/include",
"//device/soc/esp/esp32/components/esp_adc_cal/include/",
"//device/soc/esp/esp32/components/driver/esp32/include/",
".",
"lvgl/",
"lvgl/src",
]
}
/home/lst/niobeu4_src/vendor/openvalley/niobeu4/demo/301_user 下
os_thread_example.c
/*
* Copyright (c) 2022 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include "stdint.h"
#include "los_task.h"
#include "ohos_run.h"
#include "st7735.h"
#include <math.h>
#include "lv_port_disp.h"
#include "lvgl.h"
#include "demos/lv_demos.h"
#include "esp_adc_cal.h"
#include "gpio_if.h"
#define PWR_SW_PIN_INDEX 2
#define KEY_LED_OFF 0
#define KEY_LED_ON 1
//在hcs文件中对应具体的GPIO口
#define BLUE_LED_PIN_INDEX 0 // 蓝色LED
#define RED_LED_PIN_INDEX 1 // 红色LED
UINT32 button_o=0,key_stateBLUE=0,key_stateRED=0;
void lv_tick_handle(UINT32 arg)
{
printf("%s start tick\r\n", __FUNCTION__);
while(1)
{
lv_tick_inc(50);
lv_timer_handler();
}
}
/* 低优先级任务入口函数 */
UINT32 Example_TaskLo(UINT32 arg)
{
uint16_t key_state = 0;
while(1){
LOS_Msleep(30);
if (button_o==55){
// GpioRead(RED_LED_PIN_INDEX, &);
button_o=0;
printf("[key_state] sw4 : %d\n", key_state);
if (key_stateRED){
GpioWrite(RED_LED_PIN_INDEX, KEY_LED_OFF);
key_stateRED=0;
printf("[RED_LED] sw4 : Off\n");
// lv_label_set_text(label_swb, "RED off");
// lv_led_off(led1);
}
else{
GpioWrite(RED_LED_PIN_INDEX, KEY_LED_ON);
key_stateRED=1;
printf("[RED_LED] sw4 : ON\n");
// lv_label_set_text(label_swb, "RED on");
// lv_led_on(led1);
}
}
// GpioWrite(RED_LED_PIN_INDEX, KEY_LED_ON);
// GpioWrite(BLUE_LED_PIN_INDEX, KEY_LED_OFF);
if (button_o==66){
// GpioRead(BLUE_LED_PIN_INDEX, &key_state);
button_o=0;
printf("[key_state] sw5 : %d\n", key_state);
if (key_stateBLUE){GpioWrite(BLUE_LED_PIN_INDEX, KEY_LED_OFF);
key_stateBLUE=0;
printf("[BLUE_LED] sw5 : Off\n");
// lv_label_set_text(label_swb, "BLUE off");
// lv_led_off(led2);
}
else{
GpioWrite(BLUE_LED_PIN_INDEX, KEY_LED_ON);
key_stateBLUE=1;
printf("[BLUE_LED] sw5 : ON\n");
// lv_label_set_text(label_swb, "BLUE on");
// lv_led_on(led2);
}
}
// GpioWrite(RED_LED_PIN_INDEX, KEY_LED_ON);
// GpioWrite(BLUE_LED_PIN_INDEX, KEY_LED_OFF);
}
// UINT32 ret;
// printf("Enter TaskLo Handler.\n");
// /* 延时100个Ticks,延时后该任务会挂起,执行剩余任务中最高优先级的任务 */
// ret = LOS_TaskDelay(100);
// if (ret != LOS_OK) {
// printf("Delay TaskLo Failed.\n");
// return LOS_NOK;
// }
//
// printf("TaskHi LOS_TaskSuspend Success.\n");
//
// /* 恢复被挂起的任务g_taskHiId */
// ret = LOS_TaskResume(g_taskHiId);
// if (ret != LOS_OK) {
// printf("Resume TaskHi Failed.\n");
// return LOS_NOK;
// }
// return ret;
}
void StartHdfSPITest(void)
{
int raw;
UINT32 g_lv_time_task;
TSK_INIT_PARAM_S task = { 0 };
task.pfnTaskEntry = (TSK_ENTRY_FUNC)lv_tick_handle;
task.pcName = "lv_time_task";
task.uwStackSize = 0x1000;
task.usTaskPrio = 25 - 1;
GpioSetDir(PWR_SW_PIN_INDEX, GPIO_DIR_OUT);
GpioWrite(PWR_SW_PIN_INDEX, 1);
adc1_config_width(ADC_WIDTH_12Bit);
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_11);
printf("[key_led] ADC init\n");
lv_init();
lv_port_disp_init();
//lv_log_register_print_cb(lv_log_print);
LOS_TaskCreate(&g_lv_time_task, &task);
lv_obj_t * btn_sw4 = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/
lv_obj_set_pos(btn_sw4, 10, 10); /*Set its position*/
lv_obj_set_size(btn_sw4, 110, 25); /*Set its size*/
lv_obj_t * label_sw4 = lv_label_create(btn_sw4); /*Add a label to the button*/
lv_obj_center(label_sw4);
lv_obj_t * btn_sw5 = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/
lv_obj_set_pos(btn_sw5, 10, 45); /*Set its position*/
lv_obj_set_size(btn_sw5, 110, 25); /*Set its size*/
lv_obj_t * label_sw5 = lv_label_create(btn_sw5); /*Add a label to the button*/
lv_obj_center(label_sw5);
GpioSetDir(RED_LED_PIN_INDEX, GPIO_DIR_OUT); // 红灯对应GPIO配置为输出
GpioSetDir(BLUE_LED_PIN_INDEX, GPIO_DIR_OUT); // 蓝灯对应GPIO配置为输出
task.pfnTaskEntry = (TSK_ENTRY_FUNC)Example_TaskLo;
task.pcName = "Example_TaskLo";
task.uwStackSize = 0x1000;
task.usTaskPrio = 25 ;
LOS_TaskCreate(&g_lv_time_task, &task);
while(1)
{ lv_label_set_text(label_sw4, "SW4 Release"); /*Set the labels text*/
lv_label_set_text(label_sw5, "SW5 Release"); /*Set the labels text*/
LOS_Msleep(200);
lv_task_handler();
raw = adc1_get_raw(ADC1_CHANNEL_0);
UINT32 button_s=0;
//printf("[key_led] raw: %d\n", raw);
if (raw < 100)
{
LOS_Msleep(30);
lv_label_set_text(label_sw4, "SW4 Pressed"); /*Set the labels text*/
raw = adc1_get_raw(ADC1_CHANNEL_0); //获取ADC1通道0的原始值
if (raw < 100)
{
button_o=55;
button_s++;
printf("[key_led] sw4 pressed raw: %d\n", raw);
while(adc1_get_raw(ADC1_CHANNEL_0)< 100){ LOS_Msleep(30);
button_s++;
if (button_s>34){
printf("[key_led] sw4 pressed long: %d\n", raw);
}
if (button_s>240){button_s=240;}
// GpioWrite(RED_LED_PIN_INDEX, KEY_LED_ON);
// GpioWrite(BLUE_LED_PIN_INDEX, KEY_LED_OFF);
}
button_s=0;
printf("[key_led] sw4 pressed up: %d\n", raw);
// GpioWrite(RED_LED_PIN_INDEX, KEY_LED_ON);
// GpioWrite(BLUE_LED_PIN_INDEX, KEY_LED_OFF);
}
}
else if (raw >1000 && raw < 3000)
{
LOS_Msleep(30);
lv_label_set_text(label_sw5, "SW5 Pressed"); /*Set the labels text*/
raw = adc1_get_raw(ADC1_CHANNEL_0); //获取ADC1通道0的原始值
if (raw >1000 && raw < 3000)
{
button_o=66;
button_s++;
printf("[key_led] sw5 pressed raw: %d\n", raw);
raw = adc1_get_raw(ADC1_CHANNEL_0); //获取ADC1通道0的原始值
while(raw >1000 && raw < 3000){ LOS_Msleep(30);
button_s++;
if (button_s>34){
printf("[key_led] sw5 pressed long: %d\n", raw);
}
if (button_s>240){button_s=240;}
raw = adc1_get_raw(ADC1_CHANNEL_0);
// GpioWrite(RED_LED_PIN_INDEX, KEY_LED_ON);
// GpioWrite(BLUE_LED_PIN_INDEX, KEY_LED_OFF);
}
button_s=0;
printf("[key_led] sw5 pressed up: %d\n", raw);
// GpioWrite(RED_LED_PIN_INDEX, KEY_LED_ON);
// GpioWrite(BLUE_LED_PIN_INDEX, KEY_LED_OFF);
}
// printf("[key_led] sw5 pressed raw: %d\n", raw);
// GpioWrite(RED_LED_PIN_INDEX, KEY_LED_OFF);
// GpioWrite(BLUE_LED_PIN_INDEX, KEY_LED_ON);
}
}
}
OHOS_APP_RUN(StartHdfSPITest);
```![1665816283026.jpg](//file.elecfans.com/web2/M00/70/C8/pYYBAGNKX9yAeQhnAACbqvX3V1U987.jpg)
hb set
hb build –f
构建成功会提示类似如下信息。
[OHOS INFO] iotlink build success
[OHOS INFO] cost time: 0:03:28
ls /home/lst/niobeu4_src/out/niobeu4/iotlink/bin/
| 固件名称 | 用途 |
| ---------------- | ------------------------------- |
| OHOS_Image.bin | OpenHarmony内核及应用镜像文件 |
| bootloader.bin | 启动引导镜像文件 |
| partitions.bin | 分区表镜像文件 |
Windows下可以使用Flash_Download_Tool
工具进行烧录,点击这里开始下载。
图4 Flash_Download_Tool
打开页面图
连接开发板的TypeC口到PC,查看设备管理器,确定串口端口号。
进入下载页面,填入需要烧录的 bin 文件和对应的烧录地址,并根据自己实际 需求填入 SPI SPEED、SPI MODE、COM 及 BAUD。
固件对应烧录地址如下。
//out/niobeu4/iotlink/bin/bootloader.bin ----------> 0x1000
//out/niobeu4/iotlink/bin/partitions.bin ----------> 0x8000
//out/niobeu4/iotlink/OHOS_Image.bin ----------> 0x10000
图6 烧录设置页面图
OHOS_Image.bin
即可。下载完成后,可以看到如下提示。图7 烧录成功页面图
烧录完成后需要按下复位键复位设备,程序才会启动。
com:
[1;32m<--------------- OHOS Application Start Here --------------->[0m
[key_led] ADC init
[2022-10-15 14:44:16.096]# RECV ASCII>
I (161) wifi_init: WiFi RX IRAM OP enabled
E (596) gpio: gpio_set_drive_capability(596): GPIO number error
E (706) spi_master: c
[2022-10-15 14:44:16.197]# RECV ASCII>
heck_trans_valid(706): trans tx_buffer should be NULL and SPI_TRANS_USE_TXDATA should be cleared to skip MOSI phase.
E (706) spi
[2022-10-15 14:44:16.338]# RECV ASCII>
lv_tick_handle start tick
[2022-10-15 14:45:56.791]# RECV ASCII>
[key_led] sw4 pressed raw: 0
[key_state] sw4 : 0
[RED_LED] sw4 : ON
[2022-10-15 14:45:58.261]# RECV ASCII>
[key_led] sw4 pressed long: 0
[key_led] sw4 pressed long: 0
[key_led] sw4 pressed long: 0
[key_led] sw4 pressed long: 0
[key_led] sw4 pressed long: 0
[key_led] sw4 pressed long: 0
[key_led] sw4 pressed long: 0
[key_led] sw4 pressed long: 0
[key_led] sw4 pressed long: 0
[key_led] sw4 pressed long: 0
[key_led] sw4 pressed up: 0
[2022-10-15 14:46:02.024]# RECV ASCII>
[key_led] sw5 pressed raw: 1923
[key_state] sw5 : 0
[BLUE_LED] sw5 : ON
[2022-10-15 14:46:02.984]# RECV ASCII>
[key_led] sw5 pressed up: 4095
[2022-10-15 14:46:04.647]# RECV ASCII>
[key_led] sw4 pressed raw: 0
[key_state] sw4 : 0
[RED_LED] sw4 : Off
[2022-10-15 14:46:04.869]# RECV ASCII>
[key_led] sw4 pressed up: 0
[2022-10-15 14:46:06.101]# RECV ASCII>
[key_led] sw4 pressed raw: 0
[key_state] sw4 : 0
[RED_LED] sw4 : ON
[2022-10-15 14:46:06.235]# RECV ASCII>
[key_led] sw4 pressed up: 0
[2022-10-15 14:46:07.282]# RECV ASCII>
[key_led] sw5 pressed raw: 1923
[key_state] sw5 : 0
[BLUE_LED] sw5 : Off
达到预期状态。
更多回帖