Jump to content

Who can describe integrating uGFX to existing Eclipse project, step by step in detail?


Victor

Recommended Posts

Hello everyone!

I try to integrate uGFX library to existing Eclipse project and couldn't do it. I read "Getting Started -> Integrate uGFX" manual but it couldn't help me. I tried both methods. My Eclipse project has auto-generated makefile.  It couldn't be edited manually, only via project Properties. I searched way to include additional makefile in eclipse project properties, but there was no result. In Eclipse forum I was told that, I had to make two projects. First project is basic application project(my existing project), second project is library, based on eclipse makefile project. This library contain uGFX and I use it in my existing project. Probably, this way is right but I don't sure that the uGFX library dedicated for this without many changes. Also I tried to integrate uGFX library using second method described in  "Getting Started -> Integrate uGFX" manual, but failed. I  added file gfx_mk.c to project sources. I added the source and header files of  drivers to compiler including path. I faced with errors like 'undefined reference to', which I tried to solve it time from time but there was no result. It seemed to me, that i had done something wrong.

Anybody could describe integrating uGFX library to existing Eclipse project in detail?

Link to comment
Share on other sites

15 hours ago, David George said:

Hi Victor - I'm attempting to do the same thing, your right its not easy. I will post the solution when I have one!

Here's some info on including '3rd party' Makefiles into an Automake project : http://www.gnu.org/software/automake/manual/html_node/Third_002dParty-Makefiles.html

 

Hi David, It's very good! Thanks for the info. 

Link to comment
Share on other sites

We never used µGFX in eclipse with auto-generated makefiles - we always work with manually created Makefiles.

We would appreciate it if you guys could write some kind of tutorial/guide on how to use µGFX in Eclipse with auto-makefiles once you got it working. Ideally you would write a new article for the "Using µGFX on..." section in the forum.

Link to comment
Share on other sites

Victor:

I have made some progress on this if you read my parallel post.  To get it to work you need to add directory links to your project and when you do this the autogenerated makefile gets all of the .mk files from all of the directories.

 

Hope this helps.  I have a few more problems to hash out and will let you know when I get it.  Or, if you come up with something different I would be interested.

Link to comment
Share on other sites

I have finally got a uGFX Autotools project to cross-build from the command line and also in Eclipse. I created a 'single' makefile (collating the various .mk files) to make debugging gmake easier. I will now try and work back to getting a build using the original uGFX makefiles - if I can. I will post the final neat solution hopefully next week.

The only changed I made were in my single makefile, just re-arranging some paths and variable defines, probably because autoreconf/configure works slightly differently. No changes to any source code files.

 

 

Link to comment
Share on other sites

  • 2 months later...

Hi!  

I am implementing ugfx to my project( f7-discovery, baremetal).

I do this steps:

1. add gfx_mk.c  with string #include "../ugfx/drivers/gdisp/STM32LTDC/gdisp_lld_STM32LTDC.c"  to source 

2. add following include path:

"../ugfx/drivers/gdisp/STM32LTDC"
"../ugfx/src/gdisp"
"../ugfx"
"../ugfx/boards/base/STM32F746-Discovery"
 

The problem is ../src/../ugfx/drivers/gdisp/STM32LTDC/gdisp_lld_STM32LTDC.c:37:2: error: unknown type name 'LLDCOLOR_TYPE'

How I can configure necessary parts of ugfx to build successfully? 

 

Link to comment
Share on other sites

13 hours ago, Victor said:

1. add gfx_mk.c  with string #include "../ugfx/drivers/gdisp/STM32LTDC/gdisp_lld_STM32LTDC.c"  to source

You are not allowed to do that. Please do never modify the µGFX library sources unless you know what you are doing. The µGFX build system is very delicate because a lot of complex things are happening to ensure maximum portability & compile time optimizations.
Modifications like that results in errors like the one your are describing.

You are supposed to add the driver file ( "/drivers/gdisp/STM32LTDC/gdisp_lld_STM32LTDC.c" ) to your project but you have to do that as part of the Eclipse configuration. You have to tell eclipse that you want to include that file in the build process.

 

13 hours ago, Victor said:

2. add following include path:

"../ugfx/drivers/gdisp/STM32LTDC"
"../ugfx/src/gdisp"
"../ugfx"
"../ugfx/boards/base/STM32F746-Discovery"

You are also missing the path to "../ugfx/src".

Link to comment
Share on other sites

Manual How to implement uGFX lib in existing Eclipse project with autotool makefile.  

  1. Copy ugfx lib folder to your Eclipse project tree and exclude it from build( click right button on folder and choose Resource Configurations).
  2. Copy gfx_mk.c to your src from ugfx/src. Now all necessary sources and headers of ugfx include to build.
  3. Copy gfxconf.h to your include dir and config it.
  4. Choose or create necessary drivers and board files (BSP). You can choose them from ugfx/drivers  and ugfx/boards. Copy necessary folders to your project tree and check including them to build. For example, f7-discovery(LCD + Touch Screen) requires folowing drivers: ugfx/drivers/gdisp/STM32LTDC and ugfx/drivers/ginput/touch/FT5336. Also you can take something usefull from board files ugfx/boards/base/STM32F746-Discovery
  5. Specify following include paths: 

"../ugfx"
"../dviver1 folder"
"../dviver2 folder"
"../board folder"

for f7-discovery them are: 

"../ugfx"
"../STM32LTDC"

"../FT5336"
"../STM32F746-Discovery"


You can use startup files from board folder, but existing projects already has startup, peripheral init, linker script, etc.  Unnecessary files(.c) are excluded from build.

Important, configure necessary peripherals before use  uGFX (UgfxInit()).  

 

 

 

 

 

 

Link to comment
Share on other sites

Could somebody place this words in the frame at the enterance of this site:

Manual How to implement uGFX lib in existing Eclipse project with autotool makefile.  

  1. Copy ugfx lib folder to your Eclipse project tree and exclude it from build( click right button on folder and choose Resource Configurations).
  2. Copy gfx_mk.c to your src from ugfx/src. Now all necessary sources and headers of ugfx include to build.
  3. Copy gfxconf.h to your include dir and config it.
  4. Choose or create necessary drivers and board files (BSP). You can choose them from ugfx/drivers  and ugfx/boards. Copy necessary folders to your project tree and check including them to build. For example, f7-discovery(LCD + Touch Screen) requires folowing drivers: ugfx/drivers/gdisp/STM32LTDC and ugfx/drivers/ginput/touch/FT5336. Also you can take something usefull from board files ugfx/boards/base/STM32F746-Discovery
  5. Specify following include paths: 

"../ugfx"
"../dviver1 folder"
"../dviver2 folder"
"../board folder"

Thanks a lot Victor its working.

Link to comment
Share on other sites

Thank you for sharing your experience. We can create an official guide like the ones we have for other IDEs.

The only object I have is that you copy the gfx_mk.c file. Can't you just include that file into the build while still excluding everything else from the uGFX directory? The problem is that upgrading to a newer version would require you to copy the file again. The same applies for the drivers. The only thing that should be part of the application directory is stuff that is application specific, such as board files and configuration files. Everything else should stay in the uGFX directory so you can easily upgrade to a newer uGFX version by simply replacing the library directory.

Link to comment
Share on other sites

Hello, Joel.

I tried several approaches, but Eclipse/GCC environment is pretty capricious, and in most cases I catch different errors while building.

Only this reached success:

Add uGFX:
1. Copy 'uGFX' library folder to your Eclipse project folder
2. Add 'uGFX' to C/C++ Build pathes:
Properties for $Your_project -> C/C++ Build -> Settings -> Tool Settings -> Includes
add next pathes:
    ../ugfx
    ../ugfx/src
3. Copy 'gfx_mk.c' to '$Your_project/Src from ugfx/src'
4. Copy 'gfxconf.h' to '$Your_project/Inc' and config it.
5. Add next inclusions in 'main.c':
    #include "gfx.h"
    #include "gfxconf.h"

--

Most common errors is: "redefinition of gfxInit ..."

Later I will try again approach that you have offered, maybe I will find some solution.

 

B.R. Constantine.

Link to comment
Share on other sites

1) I looked inside 'gfx_mk.c', and all what I've found is several file definitions.

From your previous post:

Quote

The problem is that upgrading to a newer version would require you to copy the file again

I'm not sure that you change file names for every new library release. On present moment it looks pretty stable.

2) I successfully build GUI under FreeRTOS based on your library in Eclipse. Tomorrow I'll try to describe whole process on my site.

3) SSD1963 driver pretty good. I changed nothing in code, except 'board' porting.

3.1) I think this is useless:

#define CALC_PERIOD(w,b,f,p)                (p+b+w+f)
#define CALC_FPR(w,h,hb,hf,hp,vb,vf,vp,fps)    ((fps * CALC_PERIOD(w,hb,hf,hp) * CALC_PERIOD(h,vb,vf,vp) * 1048576)/100000000)

Edited by Joel Bodenmann
Using quote box
Link to comment
Share on other sites

My main function (CubeMX generated):

int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_FSMC_Init();
  MX_SPI2_Init();
  MX_ADC1_Init();
  MX_CRC_Init();
  MX_SDIO_SD_Init();
  MX_USART2_UART_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
	Create_threads();
  /* USER CODE END 2 */

  /* Call init function for freertos objects (in freertos.c) */
  MX_FREERTOS_Init();

  /* Start scheduler */
  osKernelStart();
  
  /* We should never get here as control is now taken by the scheduler */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
	while (1)
	{
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

	}
  /* USER CODE END 3 */

}

'Create thread' function:

void Create_threads(void) {
	osThreadDef(GUI_task, GUI_thread, osPriorityNormal, 0, 1024); //define thread
	GUITaskHandle = osThreadCreate(osThread(GUI_task), NULL); //create thread - id shouldn't be equal 0x0

	osThreadDef(Image_cycler_task, Image_cycler_thread, osPriorityNormal, 0, 1024); //define thread
	ImageCyclerTaskHandle = osThreadCreate(osThread(Image_cycler_task), NULL); //create thread - id shouldn't be equal 0x0

	if ((GUITaskHandle == 0x0) || (ImageCyclerTaskHandle == 0x0))
		Error_Handler();
}

Threads:

void GUI_thread(void const * argument) {
	gfxInit();
#if GFX_USE_GDISP && GDISP_NEED_TEXT
	font_t font = gdispOpenFont("ISOCPEUR Regular 20");
	gwinSetDefaultFont(font);
#if (DISPLAY_ORIENTATION == 0)
	gdispSetOrientation(GDISP_ROTATE_0);
#elif(DISPLAY_ORIENTATION == 90)
	gdispSetOrientation(GDISP_ROTATE_90);
#elif(DISPLAY_ORIENTATION == 180)
	gdispSetOrientation(GDISP_ROTATE_180);
#elif(DISPLAY_ORIENTATION == 270)
	gdispSetOrientation(GDISP_ROTATE_270);
#endif //DISPLAY_ORIENTATION

	/*From FATFS*/
//	FIL ImgFile;
//	FRESULT res;
//	FATFS fileSystem;

	/*Debug*/
	char buffer[64] = { 0 };

	/*From uGFX*/
	gdispImageError received_error;
	GFILE* imgFile;
	coord_t swidth = 320,
			sheight = 240;

	static gdispImage myImage;
//	MX_FATFS_Init();

//	if (f_mount(&fileSystem, (TCHAR const*) SD_Path, 0) == FR_OK) { //FATFS mount drive

		/*Test for file existence*/
//		res = f_open(&ImgFile, file_name[0], FA_OPEN_EXISTING | FA_READ);
//		f_close(&ImgFile);
		/*End test for file existence*/

		imgFile = gfileOpen(file_name[0], "rb");
		received_error = gdispImageOpenGFile(&myImage, imgFile);
		gdispImageDraw(&myImage, 0, 0, swidth, sheight, 0, 0);
		gdispImageClose(&myImage);
//	}
	gdispFillArea(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, Blue);
	sprintf(buffer, "Received error %x", (int) received_error);
	gdispDrawString(0, 0, buffer, font, White);
	gdispDrawString(0, 20, "Запущено!!!", font, White);
//	CreateGUI();
#endif //GFX_USE_GDISP && GDISP_NEED_TEXT
	for (;;)
			{
		gfxSleepMilliseconds(500);
	}
}

void Image_cycler_thread(void const * argument) {
	(void) argument;
	for (;;){
		gfxSleepMilliseconds(500);
		HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin);

	}
}

 

main.c

main.h

gfxconf.h

RTOS_functions.h

RTOS_functions.c

MyGUI.h

MyGUI.c

Link to comment
Share on other sites

On 10/8/2016 at 19:19, Constantine said:

I'm not sure that you change file names for every new library release. On present moment it looks pretty stable.

It is a file that contains library-internal specific stuff. It can happen that we modify the file contents. Think of the simple example where we add a new module to the µGFX library: We'd have to modify the gfx_mk.c file.
The goal is that you can simply replace the µGFX library directory without any modifications to upgrade to a newer version. When copying library files like gfx_mk.c to your own project you prevent that from working. We strongly advice against doing that.

 

On 10/8/2016 at 19:19, Constantine said:

I successfully build GUI under FreeRTOS based on your library in Eclipse. Tomorrow I'll try to describe whole process on my site.

Glad to hear that you got everything working. We appreciate any kind of guide, tutorial, example project or similar. This can be helpful to many people.

 

On 10/8/2016 at 19:19, Constantine said:

I think this is useless:

#define CALC_PERIOD(w,b,f,p)                (p+b+w+f)
#define CALC_FPR(w,h,hb,hf,hp,vb,vf,vp,fps)    ((fps * CALC_PERIOD(w,hb,hf,hp) * CALC_PERIOD(h,vb,vf,vp) * 1048576)/100000000)

They are not useless. They are used to calculate the timings during compile-time which vary from display panel to display panel. Of course the users can do the calculations manually and enter the result instead but these calculations happen during compile time and therefore have zero run-time impact. The parameters supplied to those macros are the more natural information than supplying the result calculated by hand. In fact, the parameters passed to those macros is what you will find 1:1 in the display panel's datasheet.

Link to comment
Share on other sites

2 minutes ago, Joel Bodenmann said:

When copying library files like gfx_mk.c to your own project you prevent that from working. We strongly advice against doing that.

Sorry, but I couldn't find another solution how to include your library in Eclipse project. I tried many approaches.

 

4 minutes ago, Joel Bodenmann said:

They are not useless

Maybe. But in my case, I had found the required parameters before understood what these scripts are doing.

Link to comment
Share on other sites

To include it from outside create your own mygfx.c in your project directory that contains a single line

#include "../ugfx/gfx_mk.c"

Or similiar. Then if we upgrade the gfx_mk.c in ugfx you won't need to re-copy the file as your file will always refer to the ugfx official version.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...