Jump to content

stm32f103 + Ra8875 driver


ronan_rt

Recommended Posts

Good day!

im newbie at UGFX. I want to know how can we manage to show imagens on my tft 4.3" screen through SPI? (driver RA8875). Im using STM32F103CBT6 and compiling with Eclipse Mars.

Im not sure how to implement all the libraries to work in my display, such as showing images through SPI.

Regards,

:)

Link to comment
Share on other sites

Hello and welcome to the community! :) 

Your STM32F103 + RA8875 is a very common combo that is known to work well with µGFX. You should be able to get everything up and running without facing any issues or having to implement something yourself (except for the board file).

Can you tell us what underlying system you'd like to use (ChibiOS, FreeRTOS, BareMetal, ... )?

Link to comment
Share on other sites

  • 1 month later...

Hello Joel!

Sorry for late response! Now I finally set up my environment. Im using KEIL MDK5 to compile my stuff. I generated all the code with CubeMX. Excluded Eclipse from my life hehehehe.

Now I still having problem to work with my tft dissplay, controlled with RA8875. Can you help me?

Cheers!

Link to comment
Share on other sites

9 minutes ago, ronan_rt said:

Now I still having problem to work with my tft dissplay, controlled with RA8875. Can you help me?

We're happy to help wherever we can but you gotta tell us what problems you're facing ;)

Did you manage to include the µGFX library successfully in your Keil µVision project as shown in the guide here?

Link to comment
Share on other sites

Hello Joel!

So, I compiled the example and everything went well. Now Im trying to paste the lines of C code before create some screen at uGfx studio. I import all driver files (ra8875) too. So..Where my driver calls some function to WRITE SPI commands? Where do I manage this functions? I can see the writereg, writedata, writeindex in the gdisp_lld_RA8875.c file but i couldnt find the functions that uses SPI of my STM32.

 

Cheers!!!

Link to comment
Share on other sites

3 hours ago, ronan_rt said:

but i couldnt find the functions that uses SPI of my STM32.

That's because they don't exist. That's up to you to implement them. µGFX doesn't care how you talk to the display (eg. what interface you use, which HAL you use and so on).

It's the task of the board files to do exactly that. Each driver comes with a board file template (in your case /drivers/gdisp/RA8874/board_RA8875_template.h that you copy to your project and rename to board_RA8875.h) accordingly to the documentation ([1] and [2]). It contains the functions that you can/must implement.

You can find plenty of example implementations of board files in the /boards directory. Especially the /boards/addons directory might be interesting.

I hope that helps.

Link to comment
Share on other sites

The error messages say that you have configured a mouse/touch and a keyboard. In the same way you added a display driver yiu will need to add a mouse/touch driver and a keyboard driver or turn them off.

I suspect you will want to turn off the keyboard (GINPUT_NEED_KEYBOARD set to FALSE) but want to add your touchscreen driver to your project build.

Link to comment
Share on other sites

15 hours ago, ronan_rt said:

I have one of this, but SPI of the HAL is not like other libraries.

You can have a look at the many existing board files that you find under /board to get an idea how to use the CubeHAL to communicate over SPI. Personally I can recommend having a look at ugfx/boards/addons/ginput/touch/ADS7843/stm32f4cube_hal.h as that's the most recent one I added myself a couple of days ago. It's made for a touchscreen controller but the concept is the same.
At the end it's always the same. One can't really reinvent the HAL API. There are a few different concepts but it all boils down to the same thing.

 

15 hours ago, ronan_rt said:

OS that I have to use, what would it be? OS_KEIL? OS_CMSIS? FREE RTOS???

You use whatever OS you want. Usually it's the application/project specifications (the requirements) that dictate what underlying system will be used. µGFX has been designed to run on any underlying system. Baremetal, ChibiOS/RT and FreeRTOS are definitely the most used ones though.
If you're working with Keil and you're having access to Keil RTX then using Keil RTX definitely makes sense. It's known to work very well.

Link to comment
Share on other sites

So I was "using" CMSIS. Then I saw in several posts here in community that people might use NON OS to compile. Even because I added CMSIS in my keil project and my system just didnt work! So, Ive attached the image of what happened. I removed CMSIS from my project, commented the line that define the OS, and No success.

Sorry about bunch of questions, trying to make this work like a charm.

Cheers!

cmsis error.png

Link to comment
Share on other sites

CMSIS is not an underlying system / operating system. CMSIS is the Cortex Microcontroller Software Interface Standard and it's basically a library that contains functions to use the processor in your STM32 microcontroller. You definitely do want to use CMSIS. Without CMSIS there's not much going to happen. So even if you want to use µGFX without an underlying operating system you still want to use CMSIS. I guess it's fair to say that 99.99% of every Cortex-M related thing you will ever come across uses CMSIS.

Have you read the guide which explains how to run µGFX on a bare-metal platform (without any underlying operating system)? The port that allows running µGFX bare-metal on a 32-bit platform is called RAW32. You have to set GFX_USE_OS_RAW32 to TRUE in your configuration file.

Link to comment
Share on other sites

Ok! Now I Understood! (used to work with PIC, very different programming). I followed your steps, use RAW32 as OS, paste my "initial screen" (create on studio), and put some debugs with PRINTF (implemented on top, not showed but working). As you see on the attached picture, the programm is stucked on gfxInit(); . I paste the example functions (explained on the GUIDE) on gfx.c, and include gfx.h and stm32f1xx_hall.h. What could it be wrong??

 

 

systeic.png

Link to comment
Share on other sites

Please show us your configuration file (attach it as a text file!).

There's a known bug with the latest version of the task scheduling code of the Raw32 port when using ARMCC (the compiler that Keil µVision uses by default). @inmarket is currently working on resolving this issue. You might get past it by setting GFX_CPU to GFX_CPU_UNKNOWN in the configuration file.
Other common issues are insufficient heap and stack sizes.

We'd strongly recommend you not adding your GUI straight away but making sure that your display is working first. Disable every module except for GDISP, call gfxInit() and then just gfxClear() to change the color of the display, nothing else. Build up from there. There's simply no point in adding everything at the first time directly - too much that can go wrong - too hard to debug.

Link to comment
Share on other sites

Hello!! Ive attached the configuration file now. 

Just to remind you that I pasted this on gfx.c:


systemticks_t gfxSystemTicks(void)
{
    return HAL_GetTick();
}
 
systemticks_t gfxMillisecondsToTicks(delaytime_t ms)
{
    return ms;
}

I will be on my business vacation till 3 january 2017. but I will see your answer here (if the configuration file is wrong) and will try a simple screen. You are saying that: I dont need to do ANYTHING on Studio right now? Only init and clear?

configuration file.txt

Link to comment
Share on other sites

1. Please don't modify the µGFX library source files. The moment you modify one of the source files from the µGFX library that is not part of your own project directory/code you are doing something horribly wrong. The µGFX library direction is created and maintained in a fashion that allows using the same directory on any system and upgrading at any time by simply replacing the directory. Changing the code if gfx.c or any other µGFX library directory file is completely destroying all of these things.
Keep your project specific stuff in your project. Do never ever modify µGFX code unless you know what you're doing. You will face issues in the future otherwise and every time you ask something we will loose a lot of time because you are not using the version of the library that we provide.
Seriously, I cannot stress this enough: Never ever modify µGFX library files. Everything inside the /ugfx directory is off-limits.
The Raw32 implementation code for the systicks is totally application/platform/target specific - hence you want to put that code somewhere in your own project scope.

2. Please use code-boxes if you want to paste code as part of your forum post (like I will below). That helps not only to keep everything nice, clean & easy to read but also allows optimizing search engine results.

3. The primary goal of you right now is to get your display up and running. Trying to directly run a full blown GUI, complex demo or µGFX-Studio project is simply a bad idea if you don't know that your display is working already. Build up from simple things. There's absolutely no reason why you would want to try rendering texts, images, widgets and other things if you can even change the color of the entire display.

Just run something like this to make sure that your display stuff is working properly:

#include "gfx.h"
  
void main(void)
{
  gfxInit();
  
  while (1) {
    gfxClear(Blue);
    gfxSleepMilliseconds(500);
    gfxClear(Red);
    gfxSleepMilliseconds(500);
  }
}

Alternatively you can run any of the demos in the /demos directory. Again, start with the simple stuff. In that case we'd recommend getting /demos/modules/gdisp/basics up and running first.

Please don't hesitate to ask if you have any other questions.

Link to comment
Share on other sites

  • 3 weeks later...

Good day! And happy new Year ;)

So, I was able to make my display work, finally! BUUUT: I couldnt work with gfxClear(); it says that this function doesnt exist. So I implement gdispClear(Blue);

There is a big problem: It is TOO MUCH SLOW! The change of the screen colors are slow, slow, slow! too much slow! And btw, the RED color become yellow.

Is there anything wrong with my code?

  while (1)
  {
        gdispClear(Blue);
      //gfxClear(Blue);
   gfxSleepMilliseconds(500);
        gdispClear(Red);
    //gfxClear(Red);
   gfxSleepMilliseconds(500);
}

gfxconf.h

/******************************************************************************/
/* This file has been generated by the uGFX-Studio                            */
/*                                                                            */
/* http://ugfx.org                                                            */
/******************************************************************************/

#ifndef _GFXCONF_H
#define _GFXCONF_H

//#define GFX_USE_OS_KEIL                                  TRUE
#define  GFX_USE_OS_RAW32                                                            TRUE
/********************************************************/
/* GDISP stuff                                          */
/********************************************************/
#define GFX_USE_GDISP TRUE

#define GDISP_NEED_CONTROL TRUE
#define GDISP_NEED_VALIDATION TRUE
#define GDISP_NEED_CLIP TRUE
#define GDISP_NEED_ARC TRUE
#define GDISP_NEED_CONVEX_POLYGON FALSE
#define GDISP_NEED_IMAGE FALSE
#define GDISP_NEED_STARTUP_LOGO FALSE
#define GDISP_NEED_CIRCLE TRUE
#define GDISP_NEED_MULTITHREAD TRUE
#define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_0
#define GDISP_STARTUP_COLOR HTML2COLOR(0xFFFFFF)


/********************************************************/
/* Font stuff                                           */
/********************************************************/
#define GDISP_NEED_TEXT TRUE
#define GDISP_NEED_ANTIALIAS FALSE
#define GDISP_NEED_TEXT_KERNING FALSE
#define GDISP_NEED_UTF8 FALSE
#define GDISP_INCLUDE_USER_FONTS TRUE


/********************************************************/
/* GWIN stuff                                           */
/********************************************************/
#define GFX_USE_GWIN TRUE

#define GWIN_NEED_WINDOWMANAGER TRUE
    #define GWIN_REDRAW_IMMEDIATE TRUE
    #define GWIN_REDRAW_SINGLEOP TRUE

#define GWIN_NEED_WIDGET TRUE
    #define GWIN_NEED_BUTTON TRUE
        #define GWIN_BUTTON_LAZY_RELEASE FALSE
    #define GWIN_FLAT_STYLING FALSE

#define GWIN_NEED_CONTAINERS TRUE
    #define GWIN_NEED_CONTAINER TRUE
    #define GWIN_NEED_FRAME FALSE
    #define GWIN_NEED_TABSET FALSE


/********************************************************/
/* GTIMER stuff                                         */
/********************************************************/
#define GFX_USE_GTIMER TRUE

#define GTIMER_THREAD_PRIORITY NORMAL_PRIORITY
#define GTIMER_THREAD_WORKAREA_SIZE 2048


/********************************************************/
/* GINPUT stuff                                         */
/********************************************************/
#define GFX_USE_GINPUT TRUE

#define GINPUT_NEED_MOUSE FALSE //TRUE
#define GINPUT_TOUCH_USER_CALIBRATION_LOAD FALSE
#define GINPUT_NEED_KEYBOARD FALSE


/********************************************************/
/* GEVENT stuff                                         */
/********************************************************/
#define GFX_USE_GEVENT TRUE

#define GEVENT_ASSERT_NO_RESOURCE FALSE
#define GEVENT_MAXIMUM_SIZE 32
#define GEVENT_MAX_SOURCE_LISTENERS 32


/********************************************************/
/* GEVENT stuff                                         */
/********************************************************/
#define GFX_USE_GQUEUE TRUE

#define GQUEUE_NEED_ASYNC TRUE


/********************************************************/
/* GFILE stuff                                          */
/********************************************************/
#define GFX_USE_GFILE FALSE

#define GFILE_NEED_NATIVEFS FALSE
#define GFILE_NEED_ROMFS TRUE
#define GFILE_MAX_GFILES 1

#endif /* _GFXCONF_H */

 

Link to comment
Share on other sites

3 minutes ago, ronan_rt said:

Good day! And happy new Year ;)

A happy new year to you as well :)

 

4 minutes ago, ronan_rt said:

I couldnt work with gfxClear(); it says that this function doesnt exist. So I implement gdispClear(Blue);

My bad, gfxClear() indeed doesn't exist. It's gdispClear() (that takes a color parameter) that I was referring to. It's simply a typo due to writing on the phone and not re-reading the text afterwards.

 

5 minutes ago, ronan_rt said:

There is a big problem: It is TOO MUCH SLOW! The change of the screen colors are slow, slow, slow! too much slow!

That's expected when using a serial interface. However, you still want to make sure that your SPI peripheral is set up correctly to use the highest possible clock frequency and so on.
But the real game changer is called hardware acceleration: The RA8875 display controller provides certain hardware accelerated drawing operations. For example, you can tell it the coordinates, dimensions and color of a rectangle and it will automatically draw it for you. This means that you only have to sent a couple of bytes via SPI instead of one or multiple bytes for each pixel. You really want to implement hardware acceleration. Unfortunately the current driver that comes with the µGFX library doesn't implement these. We implemented them but that was for a commercial customer with a support contract that paid us to do it without giving us the permission to include it into the library afterwards. It's really easy and you can have a look at the other drivers that implement hardware acceleration. The available interfaces are defined in /src/gdisp/gdisp_driver.h. Most notably you want to implement hardware clears, hardware fills and similar.

 

14 minutes ago, ronan_rt said:

And btw, the RED color become yellow.

That sounds like you're not sending the proper color format to the display controller. Have a look at the display controller datasheet. They usually support different color formats and the color format you choose comes with a definition of how the colors have to be packed when sent over each interface. Make sure that you set up the display controller to use the correct color format and that you sent them correctly. The driver configuration file contains a macro that specifies the color format that uGFX will use as well. Everything has to match up or you'll have to translate the colors. Usually you want to wrap everything in HTML2COLOR() anyway.

Please don't hesitate to ask if you have any additional questions. We're happy to help wherever we can.

Link to comment
Share on other sites

Hello! I understood now! Everything is going right except for this slow transition of the colors. I read about the acceleration and search for the gdisp_driver.h. Can you give me an exemple of how I use this stuff to CLEAR the screen?

I believe after this, i will be abble to succeed in my apps :) 

Link to comment
Share on other sites

  • 10 months later...

Good day!

I also try to use SPI  for Ra8875. But my experience is too small.

Chibios on STM32F103 MapleMini board.

I can not find a ready driver, only template drivers/gdisp/RA8875/board_RA8875_template.h  or  FSMC paralel mode boards/base/Marlin/board_RA8875.h

Create from a template, is this the only solution?

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...