Go Down

Topic: I need help to adapt tft library (Read 401 times) previous topic - next topic

tutivabene

Hello,

I have a 320 x 480 px TFT display.
Where I want put it, material window is only 240 x 480 px size.
I copy paste TFT_HX8357 library and remane (and change name in files) to my_hx8357.
Example file and my squetch work fine.

I think do this :  change value 320 by 240 in User_Setup.h at line 24 #define HX8357_TFTWIDTH  320

Is it all I need to do ?


I have an other problem, it is about "center" my frame in the screen to be in front of material windows.
The top of my frame is not y = 0 , but y = 49.
I think I need to write this in my config file, but I do not know ...

Thank you

tutivabene

Nobody can help me ?

Some thing you do not understand in my very bad english ?

david_prentice

#2
Sep 13, 2017, 01:00 pm Last Edit: Sep 13, 2017, 01:01 pm by david_prentice
Do not alter the size in User_Setup.h.
setRotation(0) for Portrait.
Just fillScreen(BLACK) and then drawRect(50, 50, 100, 100, WHITE)

See where the rectangle is drawn.
Then alter the x, y to get to the top left hand corner of your screen.
And alter the w, h to get the white rectangle at the full size of your screen.

I have never heard of 240x480.   240x320, 240x400, 272x480, 320x480, ... are common sizes.

Report back with the values of x, y, w, h that worked.
It should be easy to get your display working.   But only when we have accurate information.

David.

tutivabene

#3
Sep 13, 2017, 04:22 pm Last Edit: Sep 13, 2017, 04:31 pm by tutivabene
Thank you for your answer.

Original display, it is only a AM/PM clock.


I want change it by an 320x480px screen, but it is highter than windows possibility.

The exact size I need is 240 x 480 to display nice clock, but also other information from can bus.



Now, I do not know how many pixel I will hide on top and bottom, but sum is 80 pixels ...

tutivabene

Do not alter the size in User_Setup.h.
setRotation(0) for Portrait.
Just fillScreen(BLACK) and then drawRect(50, 50, 100, 100, WHITE)

See where the rectangle is drawn.
Then alter the x, y to get to the top left hand corner of your screen.
And alter the w, h to get the white rectangle at the full size of your screen.

I have never heard of 240x480.   240x320, 240x400, 272x480, 320x480, ... are common sizes.

Report back with the values of x, y, w, h that worked.
It should be easy to get your display working.   But only when we have accurate information.

David.
X = 0,
Y = is not define today, (value between 0 to 80).
H = 240,
W = 480.

david_prentice

Go on.  The photo shows a 320x480 display.   Just look at the shape i.e. 3:4
If you had a 240x480 the shape would be 1:2 i.e like vertical letterbox.

We can only guess from the screen side.   But it does "look" like a HX8357 or ILI9481 display shield that mates with a Mega2560.
It is always better to show a photo of the pcb side.   It often has text printed on it.   e.g. pin names and model number.

Quote
Y = is not define today, (value between 0 to 80).
makes absolutely no sense.

If you can post photos,   what does tft.drawRect(0, 0, 240, 480, WHITE);  look like?

David.

tutivabene

#6
Sep 13, 2017, 06:14 pm Last Edit: Sep 13, 2017, 06:19 pm by tutivabene
I have a 320 x 480 px TFT display. it screen is a HX8357 with mega.

Where I want put it, material window is only 240 x 480 px size.

this is what I want to do ...



Later I will close each side of the screen.

david_prentice

It is all very simple.   Select Landscape mode: tft.setRotation(1);   i.e.480x320

Then draw everything  starting at (0, 50) or wherever.  And keep within your 480x240 letterbox window.

David.

tutivabene

Landscape mode, I know it.

But rewrite existing sketch specialy for my screen it is very long.

I prefer copy and rename TFT_HX8357 library to my_hx8357 and change name in files.
Examples files for 240px height  and my squetch work fine, I only change name of library in each file.

I think it is better and faster to adapt a new library.
It is title of my post




david_prentice

Rubbish.    You print text by using tft.setCursor() first.  Just start with y+50.

And any graphics have x,y as the first argument.   Change to x, y+50

It is probably wise to use a global variable for the 50.   Then it is easy to adjust the position.

TFT_HX8357 is not my library.   Yes,  you could write a library to use a XOFFSET, YOFFSET.   But the library would be slower for 99.99% of users.

David.

tutivabene

I do not think other guy want my specific library for my specific use.
Maybe someone have same problem : need use bigger screen than material windows allow and create a "frame".

Thank you for yours answers


ZinggJM

I do not think other guy want my specific library for my specific use.
Maybe someone have same problem : need use bigger screen than material windows allow and create a "frame".

Thank you for yours answers


Use a bridge pattern.

Create a class with the same methods as the class of your previous display and make each method call the appropriate method of the class for the new display, with the needed parameter conversions.

Or create this class as a subclass of the class for the new display.

This may sound cryptic for a Newbie.
No personal message please; any question may be useful for other users. Use code tags for code. Make links clickable with URL tags. Provide links to the product in question.

tutivabene

Use a bridge pattern.

Create a class with the same methods as the class of your previous display and make each method call the appropriate method of the class for the new display, with the needed parameter conversions.

Or create this class as a subclass of the class for the new display.

This may sound cryptic for a Newbie.
This is what I wish to do not knowing well to say it.
And since I do not know how to "do well", I wrote this post explating my tests.

mybrain_iq55

Maybe you can try this 240 x 400 px display screen

3.2' Nextion Intelligent Smart Serial Touch TFT LCD Screen Module For Arduino

or search about Nextion NX4832T035_011



tutivabene

Maybe you can try this 240 x 400 px display screen

3.2' Nextion Intelligent Smart Serial Touch TFT LCD Screen Module For Arduino

or search about Nextion NX4832T035_011

Thank you !
I do not know this
Maybe it is a good idea...

Go Up