diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..691a8f6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "C_Cpp.errorSquiggles": "Disabled" +} \ No newline at end of file diff --git a/LVGL.Simulator/LVGL.Simulator.cpp b/LVGL.Simulator/LVGL.Simulator.cpp index 1afaa9c..21ac65e 100644 --- a/LVGL.Simulator/LVGL.Simulator.cpp +++ b/LVGL.Simulator/LVGL.Simulator.cpp @@ -1,13 +1,4 @@ -/************************************************************************ - * FilePath : LVGL.Simulator.cpp - * Author : GX.Duan - * Date : 2022-08-07 15:20:34 - * LastEditTime : 2022-09-10 16:05:20 - * LastEditors : ShallowGreen123 2608653986@qq.com - * Copyright (c): 2022 by GX.Duan, All Rights Reserved. - * Github : https://github.com/ShallowGreen123/lvgl_mydemo - ************************************************************************/ -/* +/* * PROJECT: LVGL PC Simulator using Visual Studio * FILE: LVGL.Simulator.cpp * PURPOSE: Implementation for LVGL ported to Windows Desktop diff --git a/LVGL.Simulator/lvgl_mydemo/a.exe b/LVGL.Simulator/lvgl_mydemo/a.exe new file mode 100644 index 0000000..8441809 Binary files /dev/null and b/LVGL.Simulator/lvgl_mydemo/a.exe differ diff --git a/LVGL.Simulator/lvgl_mydemo/lib/lib_c_flie_format.c b/LVGL.Simulator/lvgl_mydemo/lib/lib_c_flie_format.c new file mode 100644 index 0000000..6b04a50 --- /dev/null +++ b/LVGL.Simulator/lvgl_mydemo/lib/lib_c_flie_format.c @@ -0,0 +1,141 @@ +/** + * @file c_flie_format.c + * @author Gx.Duan + * @brief C File format generation + * + * method of application: + * + * 1.Run [a.exe] and input + * [file name] to generate the file in the current path. + * + * 2.Run [a.exe] [file path] + '\' and + * input [file name] to generate the file in the specified path. + * + * @version 0.1 + * @date 2022-10-08 + * + * @copyright Copyright (c) 2022 + * + */ + +#define _CRT_SECURE_NO_WARNINGS +#include +#include +#include +#include + +#define DEF_MAX_FILE_NAME_LEN 32 +#define DEF_MAX_FILE_PATH_LEN 128 + +char file_name[DEF_MAX_FILE_NAME_LEN]; +char file_path[DEF_MAX_FILE_PATH_LEN]; +char file_c[DEF_MAX_FILE_PATH_LEN]; +char file_h[DEF_MAX_FILE_PATH_LEN]; + +// +void WriteCFile(FILE *fp_c); +void WriteHFile(FILE *fc_h); + +int main(int argc, char **argv) +{ + FILE *fp_c = NULL; + FILE *fp_h = NULL; + + if (argv[1] != NULL) { + strcpy(file_path, argv[1]); + } else { + strcpy(file_path, "./"); + } + + printf("intput file name : "); + scanf("%s", file_name); + + sprintf(file_path, "%s%s", file_path, file_name); + + WriteCFile(fp_c); + WriteHFile(fp_h); + + fclose(fp_c); + fclose(fp_h); +} + +void WriteCFile(FILE *fp_c) +{ + int i; + char name_upper[DEF_MAX_FILE_NAME_LEN]; + char name_lower[DEF_MAX_FILE_NAME_LEN]; + + sprintf(file_c, "%s%s", file_path, ".c"); + fp_c = fopen(file_c, "w+"); + + for (i = 0; i < strlen(file_name); i++) { + name_upper[i] = toupper(file_name[i]); + } + for (i = 0; i < strlen(file_name); i++) { + name_lower[i] = tolower(file_name[i]); + } + + fprintf(fp_c, "\n#define DEF_%s_MODULE \n", name_upper); + fprintf(fp_c, "/********************************************************************************* \n"); + fprintf(fp_c, " * INCLUDES \n"); + fprintf(fp_c, " *********************************************************************************/ \n"); + fprintf(fp_c, "#include \"%s.h\" \n\n", name_lower); + fprintf(fp_c, "/********************************************************************************* \n"); + fprintf(fp_c, " * DEFINES \n"); + fprintf(fp_c, " *********************************************************************************/ \n\n"); + fprintf(fp_c, "/********************************************************************************* \n"); + fprintf(fp_c, " * MACROS \n"); + fprintf(fp_c, " *********************************************************************************/ \n\n"); + fprintf(fp_c, "/********************************************************************************* \n"); + fprintf(fp_c, " * TYPEDEFS \n"); + fprintf(fp_c, " *********************************************************************************/ \n\n"); + fprintf(fp_c, "/********************************************************************************* \n"); + fprintf(fp_c, " * STATIC FUNCTION \n"); + fprintf(fp_c, " *********************************************************************************/ \n\n"); + fprintf(fp_c, "/********************************************************************************* \n"); + fprintf(fp_c, " * GLOBAL FUNCTION \n"); + fprintf(fp_c, " *********************************************************************************/ \n\n"); +} + +void WriteHFile(FILE *fp_h) +{ + int i = 0; + char name_upper[DEF_MAX_FILE_NAME_LEN]; + char name_lower[DEF_MAX_FILE_NAME_LEN]; + + sprintf(file_h, "%s%s", file_path, ".h"); + fp_h = fopen(file_h, "w+"); + + for (i = 0; i < strlen(file_name); i++) { + name_upper[i] = toupper(file_name[i]); + } + for (i = 0; i < strlen(file_name); i++) { + name_lower[i] = tolower(file_name[i]); + } + + fprintf(fp_h, "\n#ifndef __%s_H__ \n", name_upper); + fprintf(fp_h, "#define __%s_H__ \n", name_upper); + fprintf(fp_h, "/********************************************************************************* \n"); + fprintf(fp_h, " * INCLUDES \n"); + fprintf(fp_h, " *********************************************************************************/ \n\n"); + fprintf(fp_h, "/********************************************************************************* \n"); + fprintf(fp_h, " * DEFINES \n"); + fprintf(fp_h, " *********************************************************************************/ \n"); + + fprintf(fp_h, "#ifdef DEF_%s_MODULE\n", name_upper); + fprintf(fp_h, "# define DEF_%s_MODULE\n", name_upper); + fprintf(fp_h, "#else \n"); + fprintf(fp_h, "# define DEF_%s_MODULE extern\n", name_upper); + fprintf(fp_h, "#endif\n\n"); + + fprintf(fp_h, "/********************************************************************************* \n"); + fprintf(fp_h, " * MACROS \n"); + fprintf(fp_h, " *********************************************************************************/ \n\n"); + fprintf(fp_h, "/********************************************************************************* \n"); + fprintf(fp_h, " * TYPEDEFS \n"); + fprintf(fp_h, " *********************************************************************************/ \n\n"); + fprintf(fp_h, "/********************************************************************************* \n"); + fprintf(fp_h, " * GLOBAL FUNCTION \n"); + fprintf(fp_h, " *********************************************************************************/ \n\n"); + fprintf(fp_h, "\n#endif /* __%s_H__ */ \n", name_upper); +} diff --git a/LVGL.Simulator/lvgl_mydemo/lib/lib_log.h b/LVGL.Simulator/lvgl_mydemo/lib/lib_log.h index c094913..608162e 100644 --- a/LVGL.Simulator/lvgl_mydemo/lib/lib_log.h +++ b/LVGL.Simulator/lvgl_mydemo/lib/lib_log.h @@ -52,6 +52,7 @@ #define DEF_DBG_LV TRACE_LV_DBG #define DEF_LIB_TRACE_FORCE_PRINTF 1 + #define DEF_LOG_COLOR_PRINT_EN 1 #define DEF_LIB_TRACE_MAX_MSG_SIZE 256 diff --git a/LVGL.Simulator/lvgl_mydemo/lvgl_app.c b/LVGL.Simulator/lvgl_mydemo/lvgl_app.c index e1aa5cf..724bb6e 100644 --- a/LVGL.Simulator/lvgl_mydemo/lvgl_app.c +++ b/LVGL.Simulator/lvgl_mydemo/lvgl_app.c @@ -1,10 +1,10 @@ /************************************************************************ * FilePath : lvgl_app.c * Author : GX.Duan - * Date : 2022-08-07 - * LastEditTime : 2022-08-19 + * Date : 2022-08-07 15:20:41 + * LastEditTime : 2022-10-01 23:02:06 * LastEditors : ShallowGreen123 2608653986@qq.com - * Copyright (c): by GX.Duan, All Rights Reserved. + * Copyright (c): 2022 by GX.Duan, All Rights Reserved. * Github : https://github.com/ShallowGreen123/lvgl_mydemo ************************************************************************/ diff --git a/LVGL.Simulator/lvgl_mydemo/screen/.clang-format b/LVGL.Simulator/lvgl_mydemo/screen/.clang-format index c0b4f0e..32c871c 100644 --- a/LVGL.Simulator/lvgl_mydemo/screen/.clang-format +++ b/LVGL.Simulator/lvgl_mydemo/screen/.clang-format @@ -96,6 +96,16 @@ BreakBeforeBinaryOperators: NonAssignment # Allman(总是在大括号前换行), GNU(总是在大括号前换行,并对于控制语句的大括号增加额外的缩进), WebKit(在函数前换行), Custom # 注:这里认为语句块也属于函数 BreakBeforeBraces: Custom +BraceWrapping: + AfterEnum: false + AfterStruct: false + AfterUnion: false + AfterCaseLabel: false + AfterClass: true + AfterFunction: true + SplitEmptyFunction: false + AfterNamespace: false + AfterExternBlock: false # 在三元运算符前换行 BreakBeforeTernaryOperators: false @@ -133,7 +143,8 @@ FixNamespaceComments: true # 缩进case标签 IndentCaseLabels: false -IndentPPDirectives: None +# Possible values: None\AfterHash\BeforeHash +IndentPPDirectives: AfterHash # 缩进宽度 IndentWidth: 4 @@ -219,7 +230,7 @@ IndentCaseLabels: true #三元运算符将放置在换行符之后 BreakBeforeTernaryOperators: true -BreakBeforeBraces: Attach +BreakBeforeBraces: Custom AllowShortCaseLabelsOnASingleLine: false @@ -230,6 +241,9 @@ AlignTrailingComments: true AlignOperands: AlignAfterOperator #对齐宏 +# They can also be read as a whole for compatibility. +# The choices are: +# - None - Consecutive - AcrossEmptyLines - AcrossComments - AcrossEmptyLinesAndComments AlignConsecutiveMacros: AcrossEmptyLinesAndComments #对齐连续等号 AlignConsecutiveAssignments: AcrossEmptyLines diff --git a/LVGL.Simulator/lvgl_mydemo/screen/gui_main_scr.c b/LVGL.Simulator/lvgl_mydemo/screen/gui_main_scr.c index 3f0f376..04f4e0f 100644 --- a/LVGL.Simulator/lvgl_mydemo/screen/gui_main_scr.c +++ b/LVGL.Simulator/lvgl_mydemo/screen/gui_main_scr.c @@ -2,16 +2,7 @@ * FilePath : gui_main_scr.c * Author : GX.Duan * Date : 2022-08-19 00:25:00 - * LastEditTime : 2022-09-21 22:11:15 - * LastEditors : ShallowGreen123 2608653986@qq.com - * Copyright (c): 2022 by GX.Duan, All Rights Reserved. - * Github : https://github.com/ShallowGreen123/lvgl_mydemo - ************************************************************************/ -/************************************************************************ - * FilePath : gui_main_scr.c - * Author : GX.Duan - * Date : 2022-08-19 00:25:00 - * LastEditTime : 2022-09-10 16:01:12 + * LastEditTime : 2022-10-03 14:42:59 * LastEditors : ShallowGreen123 2608653986@qq.com * Copyright (c): 2022 by GX.Duan, All Rights Reserved. * Github : https://github.com/ShallowGreen123/lvgl_mydemo @@ -43,7 +34,8 @@ static lv_obj_t *label2 = NULL; /********************************************************************************* * STATIC FUNCTION * *******************************************************************************/ -void swithc_btn_event_cb(lv_event_t *e) { +void swithc_btn_event_cb(lv_event_t *e) +{ lv_obj_t *obj = lv_event_get_target(e); if (obj == switch_btn) { @@ -55,7 +47,8 @@ void swithc_btn_event_cb(lv_event_t *e) { /********************************************************************************* * GLOBAL FUNCTION * *******************************************************************************/ -static lv_obj_t *Gui_MainScrCreate(lv_obj_t *parent) { +static lv_obj_t *Gui_MainScrCreate(lv_obj_t *parent) +{ MainScrRoot = lv_obj_create(parent); lv_obj_set_size(MainScrRoot, lv_pct(100), lv_pct(100)); lv_obj_set_style_bg_color(MainScrRoot, lv_color_black(), LV_PART_MAIN); @@ -72,24 +65,28 @@ static lv_obj_t *Gui_MainScrCreate(lv_obj_t *parent) { return MainScrRoot; } -static void Gui_MainScrLayout(void) { +static void Gui_MainScrLayout(void) +{ lv_obj_align_to(label, MainScrRoot, LV_ALIGN_CENTER, 0, -30); lv_obj_center(label2); lv_obj_align_to(switch_btn, MainScrRoot, LV_ALIGN_CENTER, 0, 30); } -static void Gui_MainScrEnter(void) { +static void Gui_MainScrEnter(void) +{ Gui_MainScrLayout(); lv_obj_add_event_cb(switch_btn, swithc_btn_event_cb, LV_EVENT_CLICKED, NULL); } -static void Gui_MainScrExit(void) { +static void Gui_MainScrExit(void) +{ lv_obj_remove_event_cb(switch_btn, swithc_btn_event_cb); } -static void Gui_MainScrDestory(void) { +static void Gui_MainScrDestory(void) +{ } const SCR_MGR_SCR_HANDLE_T Gui_MainScrHandle = { diff --git a/LVGL.Simulator/lvgl_mydemo/screen/gui_main_scr.h b/LVGL.Simulator/lvgl_mydemo/screen/gui_main_scr.h index 8ed45d0..d7186e4 100644 --- a/LVGL.Simulator/lvgl_mydemo/screen/gui_main_scr.h +++ b/LVGL.Simulator/lvgl_mydemo/screen/gui_main_scr.h @@ -23,9 +23,9 @@ * MACROS * *******************************************************************************/ #ifdef __MAIN_SCR_C_ -#define DEF_MAIN_SCR_EXT +# define DEF_MAIN_SCR_EXT #else -#define DEF_MAIN_SCR_EXT extern +# define DEF_MAIN_SCR_EXT extern #endif /********************************************************************************* diff --git a/LVGL.Simulator/lvgl_mydemo/screen/gui_test1_scr.c b/LVGL.Simulator/lvgl_mydemo/screen/gui_test1_scr.c index 3c2787b..e2cc56b 100644 --- a/LVGL.Simulator/lvgl_mydemo/screen/gui_test1_scr.c +++ b/LVGL.Simulator/lvgl_mydemo/screen/gui_test1_scr.c @@ -7,16 +7,6 @@ * Copyright (c): 2022 by GX.Duan, All Rights Reserved. * Github : https://github.com/ShallowGreen123/lvgl_mydemo ************************************************************************/ -/************************************************************************ - * FilePath : gui_test1_scr.c - * Author : GX.Duan - * Date : 2022-09-10 17:10:59 - * LastEditTime : 2022-09-10 17:13:08 - * LastEditors : ShallowGreen123 2608653986@qq.com - * Copyright (c): 2022 by GX.Duan, All Rights Reserved. - * Github : https://github.com/ShallowGreen123/lvgl_mydemo - ************************************************************************/ - #define __MAIN_SCR_C_ /********************************************************************************* @@ -44,7 +34,8 @@ static lv_obj_t *BtnLabel = NULL; /********************************************************************************* * STATIC FUNCTION * *******************************************************************************/ -void test1_btn_event_cb(lv_event_t *e) { +void test1_btn_event_cb(lv_event_t *e) +{ lv_obj_t *obj = lv_event_get_target(e); if (obj == test1_btn) { @@ -56,7 +47,8 @@ void test1_btn_event_cb(lv_event_t *e) { /********************************************************************************* * GLOBAL FUNCTION * *******************************************************************************/ -static lv_obj_t *Gui_Test1ScrCreate(lv_obj_t *parent) { +static lv_obj_t *Gui_Test1ScrCreate(lv_obj_t *parent) +{ Test1ScrRoot = lv_obj_create(parent); lv_obj_set_size(Test1ScrRoot, lv_pct(100), lv_pct(100)); lv_obj_set_style_bg_color(Test1ScrRoot, lv_color_black(), LV_PART_MAIN); @@ -73,24 +65,28 @@ static lv_obj_t *Gui_Test1ScrCreate(lv_obj_t *parent) { return Test1ScrRoot; } -static void Gui_Test1ScrLayout(void) { +static void Gui_Test1ScrLayout(void) +{ lv_obj_align_to(Test1Label, Test1ScrRoot, LV_ALIGN_CENTER, 0, -30); lv_obj_center(BtnLabel); lv_obj_align_to(test1_btn, Test1ScrRoot, LV_ALIGN_CENTER, 0, 30); } -static void Gui_Test1ScrEnter(void) { +static void Gui_Test1ScrEnter(void) +{ Gui_Test1ScrLayout(); lv_obj_add_event_cb(test1_btn, test1_btn_event_cb, LV_EVENT_CLICKED, NULL); } -static void Gui_Test1ScrExit(void) { +static void Gui_Test1ScrExit(void) +{ lv_obj_remove_event_cb(test1_btn, test1_btn_event_cb); } -static void Gui_Test1ScrDestory(void) { +static void Gui_Test1ScrDestory(void) +{ } const SCR_MGR_SCR_HANDLE_T Gui_Test1ScrHandle = { diff --git a/LVGL.Simulator/lvgl_mydemo/screen/gui_test1_scr.h b/LVGL.Simulator/lvgl_mydemo/screen/gui_test1_scr.h index 1bda333..0a7d146 100644 --- a/LVGL.Simulator/lvgl_mydemo/screen/gui_test1_scr.h +++ b/LVGL.Simulator/lvgl_mydemo/screen/gui_test1_scr.h @@ -23,9 +23,9 @@ * MACROS * *******************************************************************************/ #ifdef __TEST1_SCR_C_ -#define DEF_TEST1_SCR_EXT +# define DEF_TEST1_SCR_EXT #else -#define DEF_TEST1_SCR_EXT extern +# define DEF_TEST1_SCR_EXT extern #endif /*********************************************************************************