I need help to adapt tft library

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[/b]
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

Nobody can help me ?

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

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.

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

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.

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

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.

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.

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.

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.

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

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.

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

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

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.

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

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

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

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

You have the TFT_HX8357 library. It comes with many examples. Including a Digital Clock.

Run the example. Make careful notes on paper e.g. do you want to: 1. Move the digits up or down? 2. Change size of digits? 3. Change colour? 4. Change Font?

Type your requests carefully into your next message. Someone might post the solution. Possibly within minutes.

The library comes with lots of examples. If you say which example sketch you want to adapt and how you want it to change, people will often help. Or tell you if it is possible.

Note that this requires you to describe your project or problem carefully. This means effort on your side. e.g. your post #3 showed us what you wanted.

David.

.

david_prentice: You have the TFT_HX8357 library. It comes with many examples. Including a Digital Clock.

The library comes with lots of examples.

I know TFT_HX8357 library and I want modify it for my use. I read many examples from libraries. They help me to do what I want Your examples are very well for me because hight is 240px.

david_prentice: e.g. your post #3 showed us what you wanted.

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

I want do it mythelf and understand what I do/write. Of course, if I have problem, I come here and ask help to resolve.

Now my problem is "how create my_library from TFT_HX8357 library to have a frame or a windows 240x480 px with screen 320x480px ?"

If I write tft.fillScreen(YELLOW); with my_library, I want same result if I write tft.drawRect(0, 50, 240, 480, YELLOW); with TFT_HX8357 library.

How can I modify TFT_HX8357 library to have y begining at 50px and not at 0px AND having 240px height and not 320px ?