_Lib_TFT_Def library Question

General discussion on mikroPascal PRO for PIC32.
Post Reply
Author
Message
Rotary_Ed
Posts: 756
Joined: 26 Dec 2004 23:10
Location: Matthews, NC, USA
Contact:

_Lib_TFT_Def library Question

#1 Post by Rotary_Ed » 23 Nov 2013 01:04

Hi MikroTeam!


Thanks for making the source code for the TFT library available. I am trying to use it to drive a display that uses the ILI9341 display controller.
I have created the code for assignment of the correct pins to drive the display as called for in the HELP library documentation.

I am not having much success with the library - although with my own code, I managed to get rectangles on the display to light up and change colors - so fairly certain the display and connections are OK.

With the library code, the most I have gotten thus far is the screen to light up white (should be black - so suspect initialization is the problem).

However, I examine the library code and believe I understand most of it for that controller. However there are two variables/constants that are used that I can not find the definition for in the library. They are:

"Is_TFT_Set()" and "Is_TFT_Rotated_180". Of the two variables, the first is most important.

In the ILI9341 8 bit initialization routine - procedure TFT_init_ILI9341_8bit()
there is as a very important "if" statement

Code: Select all

   if (Is_TFT_Set()<>1 then
       begin

             TFT_Set_Index_Ptr := @TFT_Set_Index;
             TFT_Write_Command_Prt := @TFT_Write_Command;
              TFT_Write_Data_Ptr  := @TFT_Write_Data;
        end;
 
As you can see whether Is_TFT_Set() is or is not equal to 1 will make a big difference in the success as later intiatlization code - for the display uses those pointers. and I suspect that they not be assigned properly.

The problem is I don't know what the variable is associated with nor how it is set or not set.

Could you help me understand what these two variables do and why/how they are set?

Thanks
Rotary_Ed
Matthews, NC USA
Rv-6A N494BW Rotary Powered

Rotary_Ed
Posts: 756
Joined: 26 Dec 2004 23:10
Location: Matthews, NC, USA
Contact:

Re: _Lib_TFT_Def library Question

#2 Post by Rotary_Ed » 23 Nov 2013 01:47

Well, guess I sort of answered my own question to a degree.

I commented out the "if (Is_TFT_Set() <>1 then" line of code and now the display is displaying the colored rectangles from my own code - but it is now full screen display whereas my code only produced a smaller rectangle on the screen.

So what ever the variable is meant to be, it is clearly important to proper initialization..
Rotary_Ed
Matthews, NC USA
Rv-6A N494BW Rotary Powered

Malcolm_M
Posts: 184
Joined: 12 May 2007 13:01
Location: Bristol, UK

Re: _Lib_TFT_Def library Question

#3 Post by Malcolm_M » 23 Nov 2013 11:40

Rotary_Ed wrote:....... and now the display is displaying the colored rectangles from my own code - but it is now full screen display whereas my code only produced a smaller rectangle on the screen.
Hi Rotary_Ed,

It has been a while since I worked with TFT's but what I do remember is that even though a display uses a particular display controller,ILI9341 in your case, there are small differences in the initialization between different display manufacturers.

This, I think, is why your own code works correctly and mE's does not.

Now that the source code for the TFT library is available you can check the differences between your initialization and mE's TFT_init_ILI9341_8bit().

I am not sure of the operation of Is_TFT_Set().

Code: Select all

Keep in mind that an 8 bit interface is theoretically 1/3 the speed of a 16 bit interface:

Assuming TFT is 320x240 and 565 RGB: 320x240 = 76800 pixels

8 bit interface requires three 8 bit display writes per pixel: 76800 x 3 = 230400

16 bit interface requires one 16 bit display write per pixel:  76800 x 1 = 76800
Even with a fast processor and 8 bit interface, it may be that writing the whole display takes a noticeable time.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: _Lib_TFT_Def library Question

#4 Post by janni » 23 Nov 2013 13:11

Rotary_Ed wrote:So what ever the variable is meant to be, it is clearly important to proper initialization..
From notation, it's a function rather than a variable. I never used this library, but it seems that Is_TFT_Set() simply checks whether the basic communication functions have been defined as other than default (Set_Index, Write_Command, and Write_Data), i.e. respective function pointers were assigned with TFT_Set_Active.

Similarly, Is_TFT_Rotated_180 checks whether a call to TFT_Rotate_180 have preset screen rotation.

Rotary_Ed
Posts: 756
Joined: 26 Dec 2004 23:10
Location: Matthews, NC, USA
Contact:

Re: _Lib_TFT_Def library Question

#5 Post by Rotary_Ed » 23 Nov 2013 17:11

Thanks, Malcom and Janni

Appreciate your comments. The display I am using claims a 0.1msec response speed as compared to a typical 10msec response speed - whatever that may mean. But, the display paints fast enough using 8 bit transfer that my eyeball can not tell - so probably good enough.

Yes, Janni, I'm embarrassed to say that even though I recognized that with the "()" on the end of the "variable" means it was a function (not a variable), by the time my fingers got to the point of typing my comment - that knowledge had faded :( But, in any case, the function is apparently not being set properly - or at least the display only works when
I set the function := 0. Raises a question - can a value be assigned to a function???? Well, in any case this is what I did and the display now works:

Code: Select all

procedure TFT_Init_ILI9341_8bit(display_width : word; display_height : word);
begin
  Is_TFT_Set() := 0;  // Added by Rotary_Ed 22 Nov 2013
  if(Is_TFT_Set() <> 1) then
    begin
      TFT_Set_Index_Ptr := @TFT_Set_Index;
      TFT_Write_Command_Ptr := @TFT_Write_Command;
      TFT_Write_Data_Ptr := @TFT_Write_Data;
    end;
...
....


This TFT display (KD024FM-1(TP) using the ILI9341 display controller is suppose to have the viewing angle of an OLED type display (it does appear to do much better than the typical LCD on viewing angle). I am currently using an OLED in my products because of the wide viewing angle required, but can no longer find a 2.4" size OLED full color display on the market and still being produced - although there were some in the past and I am told will be in the future).

In any case, this controller is far more complex than the ones I am use to, but I am gaining ground on it. Right now I can get a colored area on the display and change its location, but for some reason I can not seem to get the TFT primitives such as drawing lines, rectangles, etc to work.

So I may end up having to write my own graphic primitives for this display, wish the TFT Source code for the primitives were disclosed. :lol:

Thanks again, guys
Rotary_Ed
Matthews, NC USA
Rv-6A N494BW Rotary Powered

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: _Lib_TFT_Def library Question

#6 Post by janni » 23 Nov 2013 19:07

Rotary_Ed wrote:...at least the display only works when
I set the function := 0. Raises a question - can a value be assigned to a function????
It should not be possible in Pascal. I've no idea how you've managed to compile this :wink: .

TFT_Set_Default_Mode is the function that, between others, clears the variable that a call to Is_TFT_Set returns (it clears the screen rotation flag, as well). Anyway, you could just remove the conditional in initialization procedure (leaving the assignments), instead of artificially forcing it.
...but for some reason I can not seem to get the TFT primitives such as drawing lines, rectangles, etc to work.
It may have the same source as your other trouble, i.e. wrong settings of internal flags. Use the TFT_Set_Default_Mode function before initializing your display. It also clears the default controller (SSD1963, I believe) flag that the drawing primitives check.

Rotary_Ed
Posts: 756
Joined: 26 Dec 2004 23:10
Location: Matthews, NC, USA
Contact:

Re: _Lib_TFT_Def library Question

#7 Post by Rotary_Ed » 23 Nov 2013 19:20

Thanks, janni

I agree, but was not certain - can you have a variable with "()" as part of the name? I'll have to try to compile such a variable and see if I get an error. Nope, won't compile. So must be a function. :oops:

In the meantime, I will simply eliminate that if statement condition.

Thanks for the tip on the TFT default setting, I'll give that a try and let you know the results.

It turns out that using my own code I can draw lines on the display, rotate the display and change colors - that's the other thing the colors do not match the RGB pallet - must not be shifting a byte sufficiently
Rotary_Ed
Matthews, NC USA
Rv-6A N494BW Rotary Powered

Post Reply

Return to “mikroPascal PRO for PIC32 General”