MootSeeker 0a8220a874
Add FreeRTOS Kernel and C++ Support to Simulator (#59)
* Add FreeRTOS

* Add FreeRTOS Task

* Update README.md

* Upgrade to C++

* Update Code to run multiple tasks

* Add ui folder

Add UI folder for SquareLine Studio files

* Update ui.cpp

* Add UI files to CMake from SquareLine Studio

Add UI files to CMake path.
UI folder setup so files from SquareLine Studio can be used.
Add more heap to debug SDL.

* Update README.md

* Add drop den menu test

* Add global include file

* remove cpp file to test stability

* Fixing wrong cmake configuration

remove ui files from here

* work

* Change project structure

Changed project structure and CMake file so freertos implementation will be activated when enabled in lv_conf.h

* Refactor project structure and CMake configuration, remove unused UI components

- Restructured the project and updated the CMake file to conditionally activate FreeRTOS based on lv_conf.h settings.
- Removed UI files and C++ files related to SquareLine Studio to improve project stability.
- Added a global include.
- Updated the README.md to reflect the changes.
- Increased heap size for debugging with SDL.

* Move to CPP file

Moved to cpp file created task with lv_thread_init()

* Update freertos_main.cpp

* Clean up code

Not using task notification, since pxTCD is always NULL

Changed back to LV_OS_NONE since user of this project has to device what he want to use

Commented freertos posix file with AI :)

Cleanup freertos_main.cpp as mentioned in PR

* Update README.md

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>

* Update README.md

* Update main/src/FreeRTOS_Posix_Port.c

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>

* Update main/src/main.c

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>

* Update README.md

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>

* Update README.md

* Update README.md

---------

Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
2024-09-12 10:45:51 +02:00

134 lines
2.8 KiB
C

/**
* @file main
*
*/
/*********************
* INCLUDES
*********************/
#define _DEFAULT_SOURCE /* needed for usleep() */
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include "lvgl/lvgl.h"
#include "lvgl/examples/lv_examples.h"
#include "lvgl/demos/lv_demos.h"
#include "glob.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);
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* VARIABLES
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
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(320, 480);
#if LV_USE_OS == LV_OS_NONE
lv_demo_widgets();
while(1) {
/* Periodically call the lv_task handler.
* It could be done in a timer interrupt or an OS task too.*/
lv_timer_handler();
usleep(5 * 1000);
}
#elif LV_USE_OS == LV_OS_FREERTOS
/* Run FreeRTOS and create lvgl task */
freertos_main();
#endif
return 0;
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* 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;
}