mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
Merge branch 'master' of https://github.com/lvgl/lvgl
This commit is contained in:
commit
00e5597d69
23
.github/workflows/check_conf.yml
vendored
Normal file
23
.github/workflows/check_conf.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
name: Verify that lv_conf_internal.h matches repository state
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
verify-conf-internal:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: Generate lv_conf_internal.h
|
||||
run: python lv_conf_internal_gen.py
|
||||
working-directory: scripts
|
||||
- name: Check that repository is clean
|
||||
run: git diff --exit-code >/dev/null 2>&1 || (echo "Please regenerate lv_conf_internal.h using scripts/lv_conf_internal_gen.py"; false)
|
7
Kconfig
7
Kconfig
@ -779,6 +779,13 @@ menu "LVGL configuration"
|
||||
string "Set the working directory"
|
||||
depends on LV_USE_FS_POSIX
|
||||
|
||||
config LV_USE_FS_WIN32
|
||||
int "File system on top of Win32 API"
|
||||
default 0
|
||||
config LV_FS_WIN32_PATH
|
||||
string "Set the working directory"
|
||||
depends on LV_USE_FS_WIN32
|
||||
|
||||
config LV_USE_FS_FATFS
|
||||
int "File system on top of FatFS"
|
||||
default 0
|
||||
|
@ -11,8 +11,9 @@ LVG has build in support for
|
||||
- [FATFS](http://elm-chan.org/fsw/ff/00index_e.html)
|
||||
- STDIO (Linux and Windows using C standard function .e.g fopen, fread)
|
||||
- POSIX (Linux and Windows using POSIX function .e.g open, read)
|
||||
- WIN32 (Windows using Win32 API function .e.g CreateFileA, ReadFile)
|
||||
|
||||
You still need to provide the drivers and libraries, this extensions provide only the bridge between FATFS, STDIO, POSIX and LVGL.
|
||||
You still need to provide the drivers and libraries, this extensions provide only the bridge between FATFS, STDIO, POSIX, WIN32 and LVGL.
|
||||
|
||||
## Usage
|
||||
|
||||
|
@ -536,6 +536,9 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
||||
#define LV_USE_FS_POSIX '\0' /*Uses open, read, etc*/
|
||||
//#define LV_FS_POSIX_PATH "/home/john/" /*Set the working directory. If commented it will be "./" */
|
||||
|
||||
#define LV_USE_FS_WIN32 '\0' /*Uses CreateFile, ReadFile, etc*/
|
||||
//#define LV_FS_WIN32_PATH "C:\\Users\\john\\" /*Set the working directory. If commented it will be ".\\" */
|
||||
|
||||
#define LV_USE_FS_FATFS '\0' /*Uses f_open, f_read, etc*/
|
||||
|
||||
/*PNG decoder library*/
|
||||
|
@ -954,6 +954,12 @@ static lv_coord_t calc_content_width(lv_obj_t * obj)
|
||||
/*Normal right aligns. Other are ignored due to possible circular dependencies*/
|
||||
child_res = LV_MAX(child_res, obj->coords.x2 - child->coords.x1 + 1);
|
||||
break;
|
||||
default:
|
||||
/* Consider other cases only if x=0 and use the width of the object.
|
||||
* With x!=0 circular dependency could occur. */
|
||||
if(lv_obj_get_style_y(child, 0) == 0) {
|
||||
child_res = LV_MAX(child_res, lv_area_get_width(&child->coords));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
child_res = LV_MAX(child_res, obj->coords.x2 - child->coords.x1 + 1);
|
||||
@ -976,9 +982,15 @@ static lv_coord_t calc_content_width(lv_obj_t * obj)
|
||||
case LV_ALIGN_TOP_LEFT:
|
||||
case LV_ALIGN_BOTTOM_LEFT:
|
||||
case LV_ALIGN_LEFT_MID:
|
||||
/*Normal left aligns. Other are ignored due to possible circular dependencies*/
|
||||
/*Normal left aligns.*/
|
||||
child_res = LV_MAX(child_res, child->coords.x2 - obj->coords.x1 + 1);
|
||||
break;
|
||||
default:
|
||||
/* Consider other cases only if x=0 and use the width of the object.
|
||||
* With x!=0 circular dependency could occur. */
|
||||
if(lv_obj_get_style_y(child, 0) == 0) {
|
||||
child_res = LV_MAX(child_res, lv_area_get_width(&child->coords));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
child_res = LV_MAX(child_res, child->coords.x2 - obj->coords.x1 + 1);
|
||||
@ -1020,9 +1032,16 @@ static lv_coord_t calc_content_height(lv_obj_t * obj)
|
||||
case LV_ALIGN_TOP_RIGHT:
|
||||
case LV_ALIGN_TOP_MID:
|
||||
case LV_ALIGN_TOP_LEFT:
|
||||
/*Normal top aligns. Other are ignored due to possible circular dependencies*/
|
||||
/*Normal top aligns. */
|
||||
child_res = LV_MAX(child_res, child->coords.y2 - obj->coords.y1 + 1);
|
||||
break;
|
||||
default:
|
||||
/* Consider other cases only if y=0 and use the height of the object.
|
||||
* With y!=0 circular dependency could occur. */
|
||||
if(lv_obj_get_style_y(child, 0) == 0) {
|
||||
child_res = LV_MAX(child_res, lv_area_get_height(&child->coords));
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
child_res = LV_MAX(child_res, child->coords.y2 - obj->coords.y1 + 1);
|
||||
|
@ -264,8 +264,11 @@ static bool lv_ft_font_init_cache(lv_ft_info_t * info)
|
||||
font->subpx = LV_FONT_SUBPX_NONE;
|
||||
font->line_height = (face_size->face->size->metrics.height >> 6);
|
||||
font->base_line = -(face_size->face->size->metrics.descender >> 6);
|
||||
font->underline_position = face_size->face->underline_position;
|
||||
font->underline_thickness = face_size->face->underline_thickness;
|
||||
|
||||
FT_Fixed scale = face_size->face->size->metrics.y_scale;
|
||||
int8_t thickness = FT_MulFix(scale, face_size->face->underline_thickness) >> 6;
|
||||
font->underline_position = FT_MulFix(scale, face_size->face->underline_position) >> 6;
|
||||
font->underline_thickness = thickness < 1 ? 1 : thickness;
|
||||
|
||||
/* return to user */
|
||||
info->font = font;
|
||||
@ -446,10 +449,13 @@ static bool lv_ft_font_init_nocache(lv_ft_info_t * info)
|
||||
font->get_glyph_bitmap = get_glyph_bitmap_cb_nocache;
|
||||
font->line_height = (face->size->metrics.height >> 6);
|
||||
font->base_line = -(face->size->metrics.descender >> 6);
|
||||
font->underline_position = face->underline_position;
|
||||
font->underline_thickness = face->underline_thickness;
|
||||
font->subpx = LV_FONT_SUBPX_NONE;
|
||||
|
||||
FT_Fixed scale = face->size->metrics.y_scale;
|
||||
int8_t thickness = FT_MulFix(scale, face->underline_thickness) >> 6;
|
||||
font->underline_position = FT_MulFix(scale, face->underline_position) >> 6;
|
||||
font->underline_thickness = thickness < 1 ? 1 : thickness;
|
||||
|
||||
info->font = font;
|
||||
return true;
|
||||
|
||||
|
446
src/extra/libs/fsdrv/lv_fs_win32.c
Normal file
446
src/extra/libs/fsdrv/lv_fs_win32.c
Normal file
@ -0,0 +1,446 @@
|
||||
/**
|
||||
* @file lv_fs_win32.c
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../../lvgl.h"
|
||||
#if LV_USE_FS_WIN32 != '\0'
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#ifndef LV_FS_WIN32_PATH
|
||||
#define LV_FS_WIN32_PATH ".\\" /*Project root*/
|
||||
#endif /*LV_FS_WIN32_PATH*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
static bool is_dots_name(LPCSTR name);
|
||||
static lv_fs_res_t fs_error_from_win32(DWORD error);
|
||||
static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode);
|
||||
static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p);
|
||||
static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence);
|
||||
static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
|
||||
static void * fs_dir_open(lv_fs_drv_t * drv, const char * path);
|
||||
static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn);
|
||||
static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Register a driver for the File system interface
|
||||
*/
|
||||
void lv_fs_win32_init(void)
|
||||
{
|
||||
/*---------------------------------------------------
|
||||
* Register the file system interface in LittlevGL
|
||||
*--------------------------------------------------*/
|
||||
|
||||
/* Add a simple drive to open images */
|
||||
static lv_fs_drv_t fs_drv; /*A driver descriptor*/
|
||||
lv_fs_drv_init(&fs_drv);
|
||||
|
||||
/*Set up fields...*/
|
||||
fs_drv.letter = LV_USE_FS_WIN32;
|
||||
fs_drv.open_cb = fs_open;
|
||||
fs_drv.close_cb = fs_close;
|
||||
fs_drv.read_cb = fs_read;
|
||||
fs_drv.write_cb = fs_write;
|
||||
fs_drv.seek_cb = fs_seek;
|
||||
fs_drv.tell_cb = fs_tell;
|
||||
|
||||
fs_drv.dir_close_cb = fs_dir_close;
|
||||
fs_drv.dir_open_cb = fs_dir_open;
|
||||
fs_drv.dir_read_cb = fs_dir_read;
|
||||
|
||||
lv_fs_drv_register(&fs_drv);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Check the dots name
|
||||
* @param name Win32 error code
|
||||
* @return true if the name is dots name
|
||||
*/
|
||||
static bool is_dots_name(LPCSTR name)
|
||||
{
|
||||
return name[0] == L'.' && (!name[1] || (name[1] == L'.' && !name[2]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Win32 error code to error from lv_fs_res_t enum
|
||||
* @param error Win32 error code
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_error_from_win32(DWORD error)
|
||||
{
|
||||
lv_fs_res_t res;
|
||||
|
||||
switch (error) {
|
||||
case ERROR_SUCCESS:
|
||||
res = LV_FS_RES_OK;
|
||||
break;
|
||||
case ERROR_BAD_UNIT:
|
||||
case ERROR_NOT_READY:
|
||||
case ERROR_CRC:
|
||||
case ERROR_SEEK:
|
||||
case ERROR_NOT_DOS_DISK:
|
||||
case ERROR_WRITE_FAULT:
|
||||
case ERROR_READ_FAULT:
|
||||
case ERROR_GEN_FAILURE:
|
||||
case ERROR_WRONG_DISK:
|
||||
res = LV_FS_RES_HW_ERR;
|
||||
break;
|
||||
case ERROR_INVALID_HANDLE:
|
||||
case ERROR_INVALID_TARGET_HANDLE:
|
||||
res = LV_FS_RES_FS_ERR;
|
||||
break;
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
case ERROR_PATH_NOT_FOUND:
|
||||
case ERROR_INVALID_DRIVE:
|
||||
case ERROR_NO_MORE_FILES:
|
||||
case ERROR_SECTOR_NOT_FOUND:
|
||||
case ERROR_BAD_NETPATH:
|
||||
case ERROR_BAD_NET_NAME:
|
||||
case ERROR_BAD_PATHNAME:
|
||||
case ERROR_FILENAME_EXCED_RANGE:
|
||||
res = LV_FS_RES_NOT_EX;
|
||||
break;
|
||||
case ERROR_DISK_FULL:
|
||||
res = LV_FS_RES_FULL;
|
||||
break;
|
||||
case ERROR_SHARING_VIOLATION:
|
||||
case ERROR_LOCK_VIOLATION:
|
||||
case ERROR_DRIVE_LOCKED:
|
||||
res = LV_FS_RES_LOCKED;
|
||||
break;
|
||||
case ERROR_ACCESS_DENIED:
|
||||
case ERROR_CURRENT_DIRECTORY:
|
||||
case ERROR_WRITE_PROTECT:
|
||||
case ERROR_NETWORK_ACCESS_DENIED:
|
||||
case ERROR_CANNOT_MAKE:
|
||||
case ERROR_FAIL_I24:
|
||||
case ERROR_SEEK_ON_DEVICE:
|
||||
case ERROR_NOT_LOCKED:
|
||||
case ERROR_LOCK_FAILED:
|
||||
res = LV_FS_RES_DENIED;
|
||||
break;
|
||||
case ERROR_BUSY:
|
||||
res = LV_FS_RES_BUSY;
|
||||
break;
|
||||
case ERROR_TIMEOUT:
|
||||
res = LV_FS_RES_TOUT;
|
||||
break;
|
||||
case ERROR_NOT_SAME_DEVICE:
|
||||
case ERROR_DIRECT_ACCESS_HANDLE:
|
||||
res = LV_FS_RES_NOT_IMP;
|
||||
break;
|
||||
case ERROR_TOO_MANY_OPEN_FILES:
|
||||
case ERROR_ARENA_TRASHED:
|
||||
case ERROR_NOT_ENOUGH_MEMORY:
|
||||
case ERROR_INVALID_BLOCK:
|
||||
case ERROR_OUT_OF_PAPER:
|
||||
case ERROR_SHARING_BUFFER_EXCEEDED:
|
||||
case ERROR_NOT_ENOUGH_QUOTA:
|
||||
res = LV_FS_RES_OUT_OF_MEM;
|
||||
break;
|
||||
case ERROR_INVALID_FUNCTION:
|
||||
case ERROR_INVALID_ACCESS:
|
||||
case ERROR_INVALID_DATA:
|
||||
case ERROR_BAD_COMMAND:
|
||||
case ERROR_BAD_LENGTH:
|
||||
case ERROR_INVALID_PARAMETER:
|
||||
case ERROR_NEGATIVE_SEEK:
|
||||
res = LV_FS_RES_INV_PARAM;
|
||||
break;
|
||||
default:
|
||||
res = LV_FS_RES_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return pointer to FIL struct or NULL in case of fail
|
||||
*/
|
||||
static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
DWORD desired_access = 0;
|
||||
|
||||
if (mode & LV_FS_MODE_RD) {
|
||||
desired_access |= GENERIC_READ;
|
||||
}
|
||||
|
||||
if (mode & LV_FS_MODE_WR) {
|
||||
desired_access |= GENERIC_WRITE;
|
||||
}
|
||||
|
||||
/*Make the path relative to the current directory (the projects root folder)*/
|
||||
|
||||
char buf[MAX_PATH];
|
||||
sprintf(buf, LV_FS_WIN32_PATH "%s", path);
|
||||
|
||||
return (void*)CreateFileA(
|
||||
buf,
|
||||
desired_access,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an opened file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable. (opened with fs_open)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
return CloseHandle((HANDLE)file_p)
|
||||
? LV_FS_RES_OK
|
||||
: fs_error_from_win32(GetLastError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable.
|
||||
* @param buf pointer to a memory block where to store the read data
|
||||
* @param btr number of Bytes To Read
|
||||
* @param br the real number of read bytes (Byte Read)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
return ReadFile((HANDLE)file_p, buf, btr, (LPDWORD)br, NULL)
|
||||
? LV_FS_RES_OK
|
||||
: fs_error_from_win32(GetLastError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Write into a file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable
|
||||
* @param buf pointer to a buffer with the bytes to write
|
||||
* @param btr Bytes To Write
|
||||
* @param br the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
return WriteFile((HANDLE)file_p, buf, btw, (LPDWORD)bw, NULL)
|
||||
? LV_FS_RES_OK
|
||||
: fs_error_from_win32(GetLastError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the read write pointer. Also expand the file size if necessary.
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable. (opened with fs_open )
|
||||
* @param pos the new position of read write pointer
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
DWORD move_method = (DWORD)-1;
|
||||
if (whence == LV_FS_SEEK_SET) {
|
||||
move_method = FILE_BEGIN;
|
||||
}
|
||||
else if(whence == LV_FS_SEEK_CUR) {
|
||||
move_method = FILE_CURRENT;
|
||||
}
|
||||
else if(whence == LV_FS_SEEK_END) {
|
||||
move_method = FILE_END;
|
||||
}
|
||||
|
||||
LARGE_INTEGER distance_to_move;
|
||||
distance_to_move.QuadPart = pos;
|
||||
return SetFilePointerEx((HANDLE)file_p, distance_to_move, NULL, move_method)
|
||||
? LV_FS_RES_OK
|
||||
: fs_error_from_win32(GetLastError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable.
|
||||
* @param pos_p pointer to to store the result
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
if (!pos_p) {
|
||||
return LV_FS_RES_INV_PARAM;
|
||||
}
|
||||
*pos_p = (uint32_t)-1;
|
||||
|
||||
LARGE_INTEGER file_pointer;
|
||||
file_pointer.QuadPart = 0;
|
||||
|
||||
LARGE_INTEGER distance_to_move;
|
||||
distance_to_move.QuadPart = 0;
|
||||
if (SetFilePointerEx(
|
||||
(HANDLE)file_p,
|
||||
distance_to_move,
|
||||
&file_pointer,
|
||||
FILE_CURRENT)) {
|
||||
if (file_pointer.QuadPart > LONG_MAX) {
|
||||
return LV_FS_RES_INV_PARAM;
|
||||
}
|
||||
else {
|
||||
*pos_p = file_pointer.LowPart;
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return fs_error_from_win32(GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
static char next_fn[256];
|
||||
static lv_fs_res_t next_error = LV_FS_RES_OK;
|
||||
|
||||
/**
|
||||
* Initialize a 'DIR' or 'HANDLE' variable for directory reading
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param path path to a directory
|
||||
* @return pointer to an initialized 'DIR' or 'HANDLE' variable
|
||||
*/
|
||||
static void * fs_dir_open(lv_fs_drv_t * drv, const char * path)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
HANDLE d = INVALID_HANDLE_VALUE;
|
||||
WIN32_FIND_DATAA fdata;
|
||||
|
||||
/*Make the path relative to the current directory (the projects root folder)*/
|
||||
char buf[256];
|
||||
sprintf(buf, LV_FS_WIN32_PATH "%s\\*", path);
|
||||
|
||||
strcpy(next_fn, "");
|
||||
d = FindFirstFileA(buf, &fdata);
|
||||
do {
|
||||
if (is_dots_name(fdata.cFileName)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
sprintf(next_fn, "/%s", fdata.cFileName);
|
||||
}
|
||||
else {
|
||||
sprintf(next_fn, "%s", fdata.cFileName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} while (FindNextFileA(d, &fdata));
|
||||
|
||||
next_error = fs_error_from_win32(GetLastError());
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next filename form a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param dir_p pointer to an initialized 'DIR' or 'HANDLE' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
strcpy(fn, next_fn);
|
||||
lv_fs_res_t current_error = next_error;
|
||||
next_error = LV_FS_RES_OK;
|
||||
|
||||
strcpy(next_fn, "");
|
||||
WIN32_FIND_DATAA fdata;
|
||||
|
||||
while (FindNextFileA(dir_p, &fdata)) {
|
||||
if (is_dots_name(fdata.cFileName)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
sprintf(next_fn, "/%s", fdata.cFileName);
|
||||
}
|
||||
else {
|
||||
sprintf(next_fn, "%s", fdata.cFileName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (next_fn[0] == '\0') {
|
||||
next_error = fs_error_from_win32(GetLastError());
|
||||
}
|
||||
|
||||
return current_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param dir_p pointer to an initialized 'DIR' or 'HANDLE' variable
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
return FindClose((HANDLE)dir_p)
|
||||
? LV_FS_RES_OK
|
||||
: fs_error_from_win32(GetLastError());
|
||||
}
|
||||
|
||||
#endif /*LV_USE_FS_WIN32*/
|
@ -38,6 +38,10 @@ extern "C" {
|
||||
void lv_fs_posix_init(void);
|
||||
#endif
|
||||
|
||||
#if LV_USE_FS_WIN32 != '\0'
|
||||
void lv_fs_win32_init(void);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -79,7 +79,7 @@ static gd_GIF * gif_open(gd_GIF * gif_base)
|
||||
/* Header */
|
||||
f_gif_read(gif_base, sigver, 3);
|
||||
if (memcmp(sigver, "GIF", 3) != 0) {
|
||||
fprintf(stderr, "invalid signature\n");
|
||||
LV_LOG_WARN("invalid signature\n");
|
||||
goto fail;
|
||||
}
|
||||
/* Version */
|
||||
|
@ -13,16 +13,7 @@ extern "C" {
|
||||
|
||||
#include "tjpgdcnf.h"
|
||||
#include <string.h>
|
||||
|
||||
#if defined(_WIN32) /* VC++ or some compiler without stdint.h */
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef short int16_t;
|
||||
typedef unsigned long uint32_t;
|
||||
typedef long int32_t;
|
||||
#else /* Embedded platform */
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#if JD_FASTDECODE >= 1
|
||||
typedef int16_t jd_yuv_t;
|
||||
|
@ -54,6 +54,10 @@ void lv_extra_init(void)
|
||||
lv_fs_posix_init();
|
||||
#endif
|
||||
|
||||
#if LV_USE_FS_WIN32 != '\0'
|
||||
lv_fs_win32_init();
|
||||
#endif
|
||||
|
||||
#if LV_USE_PNG
|
||||
lv_png_init();
|
||||
#endif
|
||||
|
@ -1562,6 +1562,15 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
||||
#endif
|
||||
//#define LV_FS_POSIX_PATH "/home/john/" /*Set the working directory. If commented it will be "./" */
|
||||
|
||||
#ifndef LV_USE_FS_WIN32
|
||||
# ifdef CONFIG_LV_USE_FS_WIN32
|
||||
# define LV_USE_FS_WIN32 CONFIG_LV_USE_FS_WIN32
|
||||
# else
|
||||
# define LV_USE_FS_WIN32 '\0' /*Uses CreateFile, ReadFile, etc*/
|
||||
# endif
|
||||
#endif
|
||||
//#define LV_FS_WIN32_PATH "C:\\Users\\john\\" /*Set the working directory. If commented it will be ".\\" */
|
||||
|
||||
#ifndef LV_USE_FS_FATFS
|
||||
# ifdef CONFIG_LV_USE_FS_FATFS
|
||||
# define LV_USE_FS_FATFS CONFIG_LV_USE_FS_FATFS
|
||||
|
@ -46,8 +46,8 @@ extern "C" {
|
||||
*******************/
|
||||
|
||||
/**
|
||||
* NOTE: In Kconfig instead of `LV_THEME_DEFAULT_FONT`
|
||||
* `CONFIG_LV_THEME_DEFAULT_FONT_<font_name>` is defined
|
||||
* NOTE: In Kconfig instead of `LV_DEFAULT_FONT`
|
||||
* `CONFIG_LV_FONT_DEFAULT_<font_name>` is defined
|
||||
* hence the large selection with if-s
|
||||
*/
|
||||
|
||||
@ -55,59 +55,59 @@ extern "C" {
|
||||
* DEFAULT FONT
|
||||
*-----------------*/
|
||||
#ifdef CONFIG_LV_FONT_DEFAULT_MONTSERRAT_8
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_8
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_8
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_10)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_10
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_10
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_12)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_12
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_12
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_14)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_14
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_14
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_16)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_16
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_16
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_18)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_18
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_18
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_20)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_20
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_20
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_22)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_22
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_22
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_24)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_24
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_24
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_26)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_26
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_26
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_28)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_28
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_28
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_30)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_30
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_30
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_32)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_32
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_32
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_34)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_34
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_34
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_36)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_36
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_36
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_38)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_38
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_38
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_40)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_40
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_40
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_42)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_42
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_42
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_44)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_44
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_44
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_46)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_46
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_46
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_48)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_48
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_48
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_12_SUBPX)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_12_subpx
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_12_subpx
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_MONTSERRAT_28_COMPRESSED)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_montserrat_28_compressed
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_montserrat_28_compressed
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_DEJAVU_16_PERSIAN_HEBREW)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_dejavu_16_persian_hebrew
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_dejavu_16_persian_hebrew
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_SIMSUN_16_CJK)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_simsun_16_cjk
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_simsun_16_cjk
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_UNSCII_8)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_unscii_8
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_unscii_8
|
||||
#elif defined(CONFIG_LV_FONT_DEFAULT_UNSCII_16)
|
||||
# define CONFIG_LV_THEME_DEFAULT_FONT &lv_font_unscii_16
|
||||
# define CONFIG_LV_FONT_DEFAULT &lv_font_unscii_16
|
||||
#endif
|
||||
|
||||
/*------------------
|
||||
|
@ -49,7 +49,6 @@ lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data)
|
||||
return LV_RES_INV;
|
||||
|
||||
/*Create a new timer*/
|
||||
/*Use highest priority so that it will run before a refresh*/
|
||||
lv_timer_t * timer = lv_timer_create(lv_async_timer_cb, 0, info);
|
||||
|
||||
if(timer == NULL) {
|
||||
|
@ -60,7 +60,7 @@ void _lv_timer_core_init(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Call it periodically to handle lv_timers.
|
||||
* Call it periodically to handle lv_timers.
|
||||
* @return the time after which it must be called again
|
||||
*/
|
||||
LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void)
|
||||
@ -69,12 +69,14 @@ LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void)
|
||||
|
||||
/*Avoid concurrent running of the timer handler*/
|
||||
static bool already_running = false;
|
||||
if(already_running) return 1;
|
||||
if(already_running) {
|
||||
TIMER_TRACE("already running, concurrent calls are not allow, returning");
|
||||
return 1;
|
||||
}
|
||||
already_running = true;
|
||||
|
||||
if(lv_timer_run == false) {
|
||||
already_running = false; /*Release mutex*/
|
||||
TIMER_TRACE("already running, concurrent calls are not allow, returning");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -85,7 +87,7 @@ LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void)
|
||||
|
||||
if(handler_start == 0) {
|
||||
static uint32_t run_cnt = 0;
|
||||
run_cnt ++;
|
||||
run_cnt++;
|
||||
if(run_cnt > 100) {
|
||||
run_cnt = 0;
|
||||
LV_LOG_WARN("It seems lv_tick_inc() is not called.");
|
||||
@ -141,6 +143,7 @@ LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void)
|
||||
TIMER_TRACE("finished (%d ms until the next timer call)", time_till_next);
|
||||
return time_till_next;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an "empty" timer. It needs to initialized with at least
|
||||
* `lv_timer_set_cb` and `lv_timer_set_period`
|
||||
@ -168,7 +171,7 @@ lv_timer_t * lv_timer_create(lv_timer_cb_t timer_xcb, uint32_t period, void * us
|
||||
LV_ASSERT_MALLOC(new_timer);
|
||||
if(new_timer == NULL) return NULL;
|
||||
|
||||
new_timer->period = period;
|
||||
new_timer->period = period;
|
||||
new_timer->timer_cb = timer_xcb;
|
||||
new_timer->repeat_count = -1;
|
||||
new_timer->paused = 0;
|
||||
@ -297,12 +300,6 @@ static bool lv_timer_exec(lv_timer_t * timer)
|
||||
{
|
||||
if(timer->paused) return false;
|
||||
|
||||
if(timer->repeat_count == 0) {
|
||||
TIMER_TRACE("deleting timer with %p callback because the repeat count is over", timer->timer_cb);
|
||||
lv_timer_del(timer);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool exec = false;
|
||||
if(lv_timer_time_remaining(timer) == 0) {
|
||||
/* Decrement the repeat count before executing the timer_cb.
|
||||
@ -315,17 +312,16 @@ static bool lv_timer_exec(lv_timer_t * timer)
|
||||
if(timer->timer_cb && original_repeat_count != 0) timer->timer_cb(timer);
|
||||
TIMER_TRACE("timer callback %p finished", timer->timer_cb);
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
|
||||
/*Delete if it was a one shot lv_timer*/
|
||||
if(timer_deleted == false) { /*The timer might be deleted by itself as well*/
|
||||
if(timer->repeat_count == 0) {
|
||||
TIMER_TRACE("deleting timer with %p callback because the repeat count is over", timer->timer_cb);
|
||||
lv_timer_del(timer);
|
||||
}
|
||||
}
|
||||
exec = true;
|
||||
}
|
||||
|
||||
if(timer_deleted == false) { /*The timer might be deleted by itself as well*/
|
||||
if(timer->repeat_count == 0) { /*The repeat count is over, delete the timer*/
|
||||
TIMER_TRACE("deleting timer with %p callback because the repeat count is over", timer->timer_cb);
|
||||
lv_timer_del(timer);
|
||||
}
|
||||
}
|
||||
|
||||
return exec;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ void _lv_timer_core_init(void);
|
||||
//! @cond Doxygen_Suppress
|
||||
|
||||
/**
|
||||
* Call it periodically to handle lv_timers.
|
||||
* Call it periodically to handle lv_timers.
|
||||
* @return time till it needs to be run next (in ms)
|
||||
*/
|
||||
LV_ATTRIBUTE_TIMER_HANDLER uint32_t lv_timer_handler(void);
|
||||
@ -97,7 +97,6 @@ void lv_timer_del(lv_timer_t * timer);
|
||||
/**
|
||||
* Pause/resume a timer.
|
||||
* @param timer pointer to an lv_timer
|
||||
* @param pause true: pause the timer; false: resume
|
||||
*/
|
||||
void lv_timer_pause(lv_timer_t * timer);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user