diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 31022f0..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index cd2d90d..b48d0b8 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ ui/ # VSCode .vscode +.DS_Store diff --git a/CMakeLists.txt b/CMakeLists.txt index c799c91..b9cccbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,9 +70,9 @@ target_include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR} ${SDL2_INCLUDE_DIRS # Create the main executable, depending on the FreeRTOS option if(USE_FREERTOS) add_executable(main - ${PROJECT_SOURCE_DIR}/src/main_sim.c + ${PROJECT_SOURCE_DIR}/src/main.c ${PROJECT_SOURCE_DIR}/src/freertos_main.cpp - ${PROJECT_SOURCE_DIR}/src/mouse_cursor_icon.c + ${PROJECT_SOURCE_DIR}/assets/mouse_cursor_icon.c ${PROJECT_SOURCE_DIR}/src/FreeRTOS_Posix_Port.c ${FREERTOS_SOURCES} # Add only if USE_FREERTOS is enabled ) @@ -80,8 +80,8 @@ if(USE_FREERTOS) target_link_libraries(main freertos_config FreeRTOS) else() add_executable(main - ${PROJECT_SOURCE_DIR}/src/main_sim.c - ${PROJECT_SOURCE_DIR}/src/mouse_cursor_icon.c + ${PROJECT_SOURCE_DIR}/src/main.c + ${PROJECT_SOURCE_DIR}/assets/mouse_cursor_icon.c ) endif() diff --git a/README.md b/README.md index ad2a6f4..e5d0b09 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ UI интерфейс для контроллера кондиционера-д ``` ├── src/ -│ ├── main_sim.c # Точка входа для симулятора +│ ├── main.c # Точка входа для симулятора │ ├── gui_generated.c # Основной код UI │ └── gui_generated.h # Заголовочный файл UI ├── assets/ # Изображения и шрифты (.c файлы) diff --git a/src/mouse_cursor_icon.c b/assets/mouse_cursor_icon.c similarity index 100% rename from src/mouse_cursor_icon.c rename to assets/mouse_cursor_icon.c diff --git a/src/main.c b/src/main.c index b90fe4d..d3ab3fd 100644 --- a/src/main.c +++ b/src/main.c @@ -1,12 +1,8 @@ - /** - * @file main - * + * @file main_sim + * Simulator entry point for GUI Editor design */ -/********************* - * INCLUDES - *********************/ #ifndef _DEFAULT_SOURCE #define _DEFAULT_SOURCE /* needed for usleep() */ #endif @@ -20,57 +16,12 @@ #include #endif #include "lvgl/lvgl.h" -#include "lvgl/examples/lv_examples.h" -#include "lvgl/demos/lv_demos.h" #include +#include "gui_generated.h" -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ static lv_display_t * hal_init(int32_t w, int32_t h); -/********************** - * STATIC VARIABLES - **********************/ - -/********************** - * MACROS - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ - extern void freertos_main(void); -extern void placeWidgets(); - -/********************* - * DEFINES - *********************/ - -/********************** - * TYPEDEFS - **********************/ - -/********************** - * VARIABLES - **********************/ - -/********************** - * STATIC PROTOTYPES - **********************/ - -/********************** - * GLOBAL FUNCTIONS - **********************/ int main(int argc, char **argv) { @@ -85,7 +36,7 @@ int main(int argc, char **argv) #if LV_USE_OS == LV_OS_NONE - placeWidgets(); + gui_init(); while(1) { /* Periodically call the lv_task handler. @@ -108,10 +59,6 @@ int main(int argc, char **argv) return 0; } -/********************** - * STATIC FUNCTIONS - **********************/ - /** * Initialize the Hardware Abstraction Layer (HAL) for the LVGL graphics * library diff --git a/src/main_sim.c b/src/main_sim.c deleted file mode 100644 index d3ab3fd..0000000 --- a/src/main_sim.c +++ /dev/null @@ -1,93 +0,0 @@ -/** - * @file main_sim - * Simulator entry point for GUI Editor design - */ - -#ifndef _DEFAULT_SOURCE - #define _DEFAULT_SOURCE /* needed for usleep() */ -#endif - -#include -#include -#ifdef _MSC_VER - #include -#else - #include - #include -#endif -#include "lvgl/lvgl.h" -#include -#include "gui_generated.h" - -static lv_display_t * hal_init(int32_t w, int32_t h); - -extern void freertos_main(void); - -int main(int argc, char **argv) -{ - (void)argc; /*Unused*/ - (void)argv; /*Unused*/ - - /*Initialize LVGL*/ - lv_init(); - - /*Initialize the HAL (display, input devices, tick) for LVGL*/ - hal_init(800, 480); - - #if LV_USE_OS == LV_OS_NONE - - gui_init(); - - while(1) { - /* Periodically call the lv_task handler. - * It could be done in a timer interrupt or an OS task too.*/ - lv_timer_handler(); -#ifdef _MSC_VER - Sleep(5); -#else - usleep(5 * 1000); -#endif - } - - #elif LV_USE_OS == LV_OS_FREERTOS - - /* Run FreeRTOS and create lvgl task */ - freertos_main(); - - #endif - - return 0; -} - -/** - * Initialize the Hardware Abstraction Layer (HAL) for the LVGL graphics - * library - */ -static lv_display_t * hal_init(int32_t w, int32_t h) -{ - - lv_group_set_default(lv_group_create()); - - lv_display_t * disp = lv_sdl_window_create(w, h); - - lv_indev_t * mouse = lv_sdl_mouse_create(); - lv_indev_set_group(mouse, lv_group_get_default()); - lv_indev_set_display(mouse, disp); - lv_display_set_default(disp); - - LV_IMAGE_DECLARE(mouse_cursor_icon); /*Declare the image file.*/ - lv_obj_t * cursor_obj; - cursor_obj = lv_image_create(lv_screen_active()); /*Create an image object for the cursor */ - lv_image_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/ - lv_indev_set_cursor(mouse, cursor_obj); /*Connect the image object to the driver*/ - - lv_indev_t * mousewheel = lv_sdl_mousewheel_create(); - lv_indev_set_display(mousewheel, disp); - lv_indev_set_group(mousewheel, lv_group_get_default()); - - lv_indev_t * kb = lv_sdl_keyboard_create(); - lv_indev_set_display(kb, disp); - lv_indev_set_group(kb, lv_group_get_default()); - - return disp; -}