upd struct of prj
This commit is contained in:
parent
9a688e62a7
commit
fa806d5d4b
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@ ui/
|
||||
# VSCode
|
||||
.vscode
|
||||
|
||||
.DS_Store
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ UI интерфейс для контроллера кондиционера-д
|
||||
|
||||
```
|
||||
├── src/
|
||||
│ ├── main_sim.c # Точка входа для симулятора
|
||||
│ ├── main.c # Точка входа для симулятора
|
||||
│ ├── gui_generated.c # Основной код UI
|
||||
│ └── gui_generated.h # Заголовочный файл UI
|
||||
├── assets/ # Изображения и шрифты (.c файлы)
|
||||
|
||||
61
src/main.c
61
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 <pthread.h>
|
||||
#endif
|
||||
#include "lvgl/lvgl.h"
|
||||
#include "lvgl/examples/lv_examples.h"
|
||||
#include "lvgl/demos/lv_demos.h"
|
||||
#include <SDL.h>
|
||||
#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
|
||||
|
||||
@ -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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include "lvgl/lvgl.h"
|
||||
#include <SDL.h>
|
||||
#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;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user