How to get text correct displayed on a TFT?

General discussion on mikroPascal PRO for AVR.
Post Reply
Author
Message
mikroSeven
Posts: 154
Joined: 14 Mar 2016 10:24
Contact:

How to get text correct displayed on a TFT?

#1 Post by mikroSeven » 04 Dec 2023 19:47

Hi,

after lots of try and do, now this topic.

To start, here the issue clearly showed in a video:

https://www.youtube.com/watch?v=hbZANGlGnB0

The 'previous' text is not overwritten

This problem doesn't occur when using LCD's or GLCD's.

Tnx in advance. Marcel
To DIY or not to DIY

mikroSeven
Posts: 154
Joined: 14 Mar 2016 10:24
Contact:

Re: How to get text correct displayed on a TFT?

#2 Post by mikroSeven » 04 Dec 2023 19:55

The code shown:


program quickTestADX335L;
uses
myILI9341,
myADX335L;
{ Declarations section }
{ Main program }
var
wCntr: word;
stCntr: array[5] of char;

wXin, wYin, wZin: word;
stX, stY, stZ: array[5] of char;

begin
delay_ms(100);
TFT_Init_ILI9341_8bit(240, 320);
delay_ms(100);

initADC;

TFT_Fill_Screen(cl_white);

tft_write_text('- cobaltBlueCloud ADX335L -', 10,10);

tft_write_text('ADC incs', 45, 50);
tft_write_text('x', 50, 60);
tft_write_text('y', 50, 80);
tft_write_text('z', 50, 100);

//main loop
while true do
begin

for wCntr:= 1 to 255 do
begin
wordToStr(wCntr, stCntr);
tft_write_text( stCntr, 100, 150);

wXin:= adc_get_sample(4);
wYin:= adc_get_sample(5);
wZin:= adc_get_sample(6);
{
wordToStr( wXin-390, stX );
wordToStr( wYin-382, stY );
wordToStr( wZin-462, stZ );
}
wordToStr( wXin, stX );
wordToStr( wYin, stY );
wordToStr( wZin, stZ );

tft_write_text(stX, 60, 60);
tft_write_text(stY, 60, 80);
tft_write_text(stZ, 60, 100);

delay_ms(250);
end;
end;
end.



The code shows the use of 'words' but I've also tried 'integers' and bytes'
( in combination with the correct '-ToStr' conversions, these gave the same isseu.

Using 'string' instead of 'array' gave also same isseu!

Kind regards.
To DIY or not to DIY

Thomas.Pahl@t-online.de
Posts: 158
Joined: 24 May 2008 15:55
Location: Germany

Re: How to get text correct displayed on a TFT?

#3 Post by Thomas.Pahl@t-online.de » 04 Mar 2024 15:08

Hi,
delete the display space where you want to write the next characters with a filled rectangle with the background color.
alternativly you can rewrite the old text with background color again (at the same pixel place) and then write the new text.

mikroSeven
Posts: 154
Joined: 14 Mar 2016 10:24
Contact:

Re: How to get text correct displayed on a TFT?

#4 Post by mikroSeven » 27 Mar 2024 21:27

Hi, tnx for reply!

Sounds good!

But whenever I put a rectangle-command in my code, things get locked up.
Nothing at all on the TFT: also NO text from before the rectangle-command and screens stays dark, no fill-white!

When disable the rectangle-command and uploading again: nothingon screen again, but the
code has been uploades succesfully. After remover power from my 2560 and the tft, wait a minute and conencting/startup again, there's
text on my tft again.

Here's my code:

Code: Select all

program core2560ili9341_8bit;
var
  TFT_DataPort : byte at PORTC;
  TFT_WR : sbit at PORTG0_bit;
  TFT_RD : sbit at PORTG1_bit;
  TFT_CS : sbit at PORTD6_bit;
  TFT_RS : sbit at PORTD7_bit;
  TFT_RST: sbit at PORTD5_bit;

  TFT_DataPort_Direction : byte at DDRC;
  TFT_WR_Direction : sbit at DDG0_bit;
  TFT_RD_Direction : sbit at DDG1_bit;
  TFT_CS_Direction : sbit at DDD6_bit;
  TFT_RS_Direction : sbit at DDD7_bit;
  TFT_RST_Direction: sbit at DDD5_bit;

begin
  { Main program }
  //TFT_Init_ILI9341_8bit(240, 320);  portrait
  TFT_Init_ILI9341_8bit(320, 240);
  delay_ms(100);
  TFT_Fill_Screen(cl_white);
  delay_ms(100);
  TFT_Circle(0, 0, 15);
  TFT_Circle(0, 0, 25);
  TFT_Circle(320, 240, 15);
  TFT_Circle(320, 240, 25);
  tft_write_text('(0,0)   BLEU CORE 2560 ILI9341_8bit',30,10); // (0,0) left/up
  tft_write_text('CobaltBlueCloud',10,50);
  tft_write_text('ILI9341_8bit 320x240',10,70);
  tft_write_text('(320,240)',220,220);                   // (320,240) right/down
  
  tft_set_font(@tft_defaultfont, cl_red, fo_horizontal);
  tft_write_text('UART3 initializing...',10,110);

  // initRxTx();
  delay_ms(1000);
  //tft_rectangle(10, 110, 20, 120);

  tft_set_font(@tft_defaultfont, cl_green, fo_horizontal);
  tft_write_text('UART3 Ready for transmission!',10,110);

end.

Without rectangle-command, screen ok:
20240327_212245b.jpg
20240327_212245b.jpg (35.3 KiB) Viewed 687 times

Tnx in advance! Marcel
To DIY or not to DIY

Thomas.Pahl@t-online.de
Posts: 158
Joined: 24 May 2008 15:55
Location: Germany

Re: How to get text correct displayed on a TFT?

#5 Post by Thomas.Pahl@t-online.de » 28 Mar 2024 08:00

you forgot to set the brush with the TFT_Set_Brush() function (with filled option set and background color set (white) without gradient)

right before the rectangle

Thomas

mikroSeven
Posts: 154
Joined: 14 Mar 2016 10:24
Contact:

Re: How to get text correct displayed on a TFT?

#6 Post by mikroSeven » 28 Mar 2024 10:28

Hi, tnx for reply.

Placed the set/brush in the code.
Again, whole setup get locked up after programming. Even when power off the whole setup.
Can't get the setup running properly even after uploading code without the rectangle and without set/brush.

After some struggle there's picture on the tft again ( without rectangle and set-brush code).

I enabled the set/brush and kept the rectange disabled: Upload gooes ok and have picture.
As soon I implement rectangle, the whole setup gets locked.

Did some tests: placed the ILI9341 on antoher 2560-board and thing go fine!
Can upload fifferen codes ( I stay away from rectangle code! ).
Now I'm sure the ILI9341 is ok.

Next thing I did I took my 'first' 2560-board again and placed ILI9341.
Works fine with non-rectangle code. But when placing rectangle the whole 2560 get's bad.

Again it's surprices me that even after power cable and programm cable disconnected, so no voltage for a while
the 2560 keeps messed up somehow. But programming the 2560 gives no error.
Also suprise me that the code BEFORE the rectangle doesn't do anything. I would expect at least the screen filling white
as this is the first command in my code.

Kind regards.
To DIY or not to DIY

Thomas.Pahl@t-online.de
Posts: 158
Joined: 24 May 2008 15:55
Location: Germany

Re: How to get text correct displayed on a TFT?

#7 Post by Thomas.Pahl@t-online.de » 28 Mar 2024 15:57

I do'nt know what's going on on your hardware. I can asure you, the rectangle function works very well. i use mikrobasic but the basic library is identical to mikropascal library.

Your problem reminds me on a problem with the ili9481 i had. There is a bug in the library (TFT_Set_Address routine only sets start_address). I changed that routine and now it works.

But with ili9341 i do not remember a problem.

mikroSeven
Posts: 154
Joined: 14 Mar 2016 10:24
Contact:

Re: How to get text correct displayed on a TFT?

#8 Post by mikroSeven » 28 Mar 2024 20:55

Tnx!

You must be right, there's strange hings going on!

This morning I did other stuf with the 2560's ( without the ILI9341 ) everyting ok.

Now just started again with the same 2560' and connected the ILI9341's and uploaded the code:
now there's no screen at all, just solid white...

Just for the 'whatever' I changed the

TFT_Init_ILI9341_8bit(320, 240);

into TFT_Init_ILI9340_8bit(320, 240);

Suprisly: I have text and circles on the screen. Left and right mirrorred...
But ok..there's something!

Changed back to 9341 and again, solid white only...

( Between everystep , for sure: disconencted all power. )

Did a test, just for the 'whatever':
connected ILI9481 480x320 ( have exact same pinning/ports as 9341 ) on my 2560.
power on: ( with stil the ILI9341 code in it) got the text and circles correctly on the ILI9481
Just the 320x240 part of the 480x320.

Next uploaded ILI9481 code and got correctly the whole screen fileld, of caurse!

Have to decide what to do. Find out what's wrong or other use other screen.

First I gonna do is to check if the rectangle work on the ILI9481.

Have a nice evening.
To DIY or not to DIY

mikroSeven
Posts: 154
Joined: 14 Mar 2016 10:24
Contact:

Re: How to get text correct displayed on a TFT?

#9 Post by mikroSeven » 28 Mar 2024 21:10

Happy to announce that the rectangle is working on the 2560-ILI9481 combi! :D

( gotta find out how to get away of the border of the rectangle. inside is nice filled white, text gone! )

Found on the forum some ILI9341 stuf. When I'm right, HX8347 lib should work on the ILI9341.

To be continued...
To DIY or not to DIY

mikroSeven
Posts: 154
Joined: 14 Mar 2016 10:24
Contact:

Re: How to get text correct displayed on a TFT?

#10 Post by mikroSeven » 28 Mar 2024 21:56

==== PROBLEM SOLVED ===

See:
https://www.youtube.com/watch?v=Lr8nj1cn-t0

( have exact same pinning/ports as 9341 )
Oops...it was NOT! :cry:

ILI9341 and ILI9481 the same pinning, that's true!
But, on the ILI9341 boards I HAD connected the F_CS pin to the 2560 on portD/bit4.
( the disconnected green wires as you can see in the video )


Even after having disconnected the green wires, power off etc I had difficulty to get away of 'something that still was messing up one of my 2560's!
Loaded other code ( ili9481), connected other tft ( ili9481 ) and this was working fine!
Next connected and uploading ILI9431, things were still locked even that as I wrote in previous line, the ILI9481 setup did work!
After a while the second ILI9341 did work!



The rest was ok:
TFT_DataPort : byte at PORTC;
TFT_WR : sbit at PORTG0_bit;
TFT_RD : sbit at PORTG1_bit;
TFT_CS : sbit at PORTD6_bit;
TFT_RS : sbit at PORTD7_bit;
TFT_RST: sbit at PORTD5_bit;



Tnx for you corporation!

Marcel
To DIY or not to DIY

mikroSeven
Posts: 154
Joined: 14 Mar 2016 10:24
Contact:

Re: How to get text correct displayed on a TFT?

#11 Post by mikroSeven » 28 Mar 2024 22:08

( gotta find out how to get away of the border of the rectangle. inside is nice filled white, text gone! )
Done by

Code: Select all

tft_set_pen( cl_white, 1);
 
To DIY or not to DIY

mikroSeven
Posts: 154
Joined: 14 Mar 2016 10:24
Contact:

Re: How to get text correct displayed on a TFT?

#12 Post by mikroSeven » 29 Mar 2024 09:30

Unfortunately, this morging powered on both 2560-ILI9341 setup's and wrong again.
( the working code and setup of yesterday, wat was working properly )

Now:
- uploaded ILI9341 code again: uploading ok but no picture.
- uploaded ILI9341 code: uploading again ok, some action visible ( ofcaurse: wrong driver )
- uploaded ILI9341 code: everything suddenly fine!
pcb.jpg
pcb.jpg (89.4 KiB) Viewed 494 times
'Recovering' now goes much easier now!

Next to do:
- take an arduino mega2560's.
- test with this 'clean' board.
To DIY or not to DIY

mikroSeven
Posts: 154
Joined: 14 Mar 2016 10:24
Contact:

Re: How to get text correct displayed on a TFT?

#13 Post by mikroSeven » 29 Mar 2024 18:12

Got enough of all at the moment...
I will continue my current ( rc truck and excavetor ) projects with (graphic)-LCD's.

https://www.youtube.com/watch?v=5QkKqW1I6FY

It isn't THAT importent to have TFT/RGB screens ( touch not needed, by the way ).
To DIY or not to DIY

Thomas.Pahl@t-online.de
Posts: 158
Joined: 24 May 2008 15:55
Location: Germany

Re: How to get text correct displayed on a TFT?

#14 Post by Thomas.Pahl@t-online.de » 30 Mar 2024 09:09

I didn't think you give up that fast... :D

Have fun with electronics!

mikroSeven
Posts: 154
Joined: 14 Mar 2016 10:24
Contact:

Re: How to get text correct displayed on a TFT?

#15 Post by mikroSeven » 31 Mar 2024 10:31

Give it a pause, get a deep breath and dive in it again!

To be continued...
To DIY or not to DIY

Post Reply

Return to “mikroPascal PRO for AVR General”