how to change LCD part of progam into TFT

HI everyone, i have a program using adafruit_GFX and Adafruit_PCD8544 for LCD screen and i would like to change the program by using tft 1.8. My libraries are Adafruit_GFX and Adafruit_ST7735. I put in the attachments the origin program named Variometer_MS5611 and my program test is named "test". If someone know why my program test doesn't work.. thank you in advance

Variometer_MS5611.ino (27.5 KB)

test.ino (27.7 KB)

If someone know why my program test doesn't work..

It does work. It just doesn't do what you expect. So, why are you expecting it to do something other than what it is doing?

If you want help here, you will COMPLETELY avoid the useless phrase "it doesn't work". The program does something. You MUST tell us what it ACTUALLY does. You must tell us how that differs from what you expect.

Alright I understand. This is also my first post and I apologize in advance if I make syntax errors because I speak French and my English is not perfect.
The program is uploaded correctly but when I plug in my 1.8 "TFT screen to my arduino card I do not have anything displayed. The screen is black. This is exactly my problem. The code is compiled without error but nothing appears on the screen. I do not see where the problem is..

I do not see where the problem is..

Did you try any of the examples that came with the touch screen library? With the same results or different results?

If you didn't try the examples, do so now.

I would agree with Paul, forget trying to fix the problem using the large program you posted, try one of the library examples first.

This should be standard practice with any project. When you add something new and it does not work you either have the program wrong or the hardware wrong. You can of course flounder around trying to work out whether its your program thats wrong or the hardware (display) is just not wired right.

Much easier to use a known working demo program to check if you have the hardware wired correctly.

Hello, thank you for your answers. I used this program to test if my screen was properly wired. I can see "hello" on my screen so I deduce that it is well wired.
In my test program, I tried to use the program's libraries below. Everything compiles properly but I still have nothing on my screen.

#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>

#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8

#define TFT_SCLK 13
#define TFT_MOSI 11

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void) {
tft.initR(INITR_BLACKTAB);
tft.fillScreen(ST7735_BLACK);

//tft print function!
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(0);

}

void loop() {
// tft.invertDisplay(true);
tft.setCursor(35,80);
tft.println("Hello!");
delay(1000);
//delay(500);
tft.fillScreen(ST7735_BLACK);
delay(1000);
// tft.invertDisplay(false);
// delay(500);
}

These calls:

tft.initR(INITR_BLACKTAB);  
 tft.fillScreen(ST7735_BLACK);


 //tft print function!
 tft.setTextColor(ST7735_WHITE);
 tft.setTextSize(0);

are made, in setup(), in the code that works. They are made, conditionally, in loop() in the code that doesn't. Why?

Indeed why ?

After all if one program works, what is different (as far as the display and its setup is concerned) with the one that does not ?

I tried to set the screen initialization in the setup and the rest of the program in the loop and the program works. I replaced the lines of code of the LCD with those I use for the TFT screen in the program "test". Same thing as before I have code that is uploaded without problem but the screen stays white. In my opinion my connection is good since I can display "hello" on my screen. The "test" program compiles well so I do not see where my problem is .. Is it possible that my program is not correct even if it is easily uploaded on my arduino card? Or is the connection of my screen good for running a program but not another?

Yes. If it compiles and uploads it may not do what you intended.

No. If it works for one program then the wiring is not the fault. (Unless the non-working program is using a wire that the test doesn't use.)

Post #2 The program is uploaded correctly but when I plug in my 1.8 "TFT screen to my arduino card I do not have anything displayed. The screen is black.

Post #8 Same thing as before I have code that is uploaded without problem but the screen stays white.

Do you see the inconsistancy ?

Yes, excuse me srnet. I tried other things in the meantime and replaced the tft.fillScreen (ST7735_BLACK); By tft.fillScreen (ST7735_WHITE); But that does not change the functionality of the program in my opinion.

MorganS I plugged only the pins needed to operate the screen. I defined the same pin in the program "test" and the one I put higher.

Thank you all

Then the problem is in the code. Please post your current code with a description of the observed behavior.

a tft is basicly a color lcd but also has a clear touch pad over the top of it.. so there is two seperate things you need to account for

depending on your screen the touch part may be inverted in X,Y compaired to the lcd's X,Y

also there may be some numbers you need to find out for your model i found a good paint scetch that had lots of different models so to get it to work had to use the model number to find out which to chose in the code

"TFT" is just a description of the arrangement of the transistors in an LCD. It may or may not have a touchscreen overlay.

So far, the problem doesn't seem to be related to the touch function.

Here is the code I use and that I have modified. Initially, the MS5611 code is designed to work with a nokia LCD screen. I modified this code into "test". I want to replace the LCD to the TFT to have a color display and it is more visible under the sun.

First -I used the libraries for the TFT screen (line 9 and 10)
-Then I redefined the pins that correspond to my screen. (line 98 to 104)
-I replaced the "display" with "tft" because I replaced Adafruit_PCD8544 display = Adafruit_PCD8544 (PIN_SCLK, PIN_SDIN, PIN_DC, PIN_SCE, PIN_RESET); by Adafruit_ST7735 tft = Adafruit_ST7735 (tft_CS, tft_DC, tft_RST);
-To clear the screen I replaced the command display.clearDisplay (); By tft.fillScreen (ST7735_BLACK);
-To set the color (black for example) I replaced BLACK by ST7735_BLACK
-I have put in commented the command that control the contrast because I have not found how it works for the TFT screen yet. (line 572 and 573)

Variometer_MS5611.ino (27.5 KB)

test.ino (27.7 KB)

My screen is a SPI TFT LCD 1.8. It is not a touchscreen. I bought on ebay. The link is SPI TFT LCD 1.8" Serial Module Display PCB Adapter Power IC SD Socket 128x160 | Achetez sur eBay

The words tft and display in your code are just the names for variables. They are rather complex variables because they're classes with lots of functions and properties inside them but at the level of your program, they're just names.

So you could have kept the name display and only changed the declaration at the top. Plus anything else that's different, like changing the clearDisplay() method.

The TFT doesn't have a contrast control. If you want brighter or darker letters, use brighter or darker colours.

You still have the screen initialization in the loop which you were told not to do.

I was actually hoping that you would post your small test program. You know that the very small demo works. Try to work up from there instead of working backwards from your big program which is so much more complex.

clem64000:
I want to replace the LCD to the TFT to have a color display and it is more visible under the sun.

Your wasting your time then.

The ST7735 TFT will be just about invisible under the sun, they are useless for such applications.

The Nokia 5110 are great displays for outdoor use, very easy to read in the brightest of sun.

I put the initialization of the screen in the setup and I now have something else that appears. I try to change the color of the text or the background but nothing makes it. I put the picture in the attachments

I had seen that it was possible to control the backlight on this site : Controlling the Backlight | 2.8" TFT Touch Shield | Adafruit Learning System. But that's another problem. I have to first succeed in posting something on my screen.

I will try to use the small program (The part that works) and add pieces of code little by little.

ecran_tft.ino (877 Bytes)

IMG_1820.pdf (580 KB)