Problem with TFT LCD screen

Well I got problem with my TFT shield.
I'm running it on arduino mega, it got ILI9341 driver.
Here is how its look like:


And this is code:

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

#include <SPI.h>
#include "Adafruit_GFX.h"
#include <MCUFRIEND_kbv.h>
#include "RTClib.h"

MCUFRIEND_kbv tft;
RTC_DS1307 rtc;

#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

int i;
void setup(void){
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.fillScreen(BLACK);
  tft.setTextSize(1);

  if(! rtc.begin()) {
    tft.setCursor(0,5);
    tft.print("cant fing RTC");
  }
  while(! rtc.begin()){
    tft.setCursor(i,20);
    tft.print(".");
    i=i+5;
    delay(1000);
  }
  if (! rtc.isrunning()) {
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
  
  tft.fillScreen(BLACK);;
}
void loop(void){
  tft.setTextSize(WHITE,BLACK);
  tft.setCursor(2,2);
  tft.setTextSize(2);
  tft.print("date:");
  DateTime now = rtc.now();

  tft.print(now.year(), DEC);
  tft.print('/');
  tft.print(now.month(), DEC);
  tft.print('/');
  tft.print(now.day(), DEC);
  tft.print(" (");
  tft.print(daysOfTheWeek[now.dayOfTheWeek()]);
  tft.print(") ");

  tft.setCursor(2,18);
  tft.print("time:");
  tft.print(now.hour(), DEC);
  tft.print(':');
  tft.print(now.minute(), DEC);
  tft.print(':');
  tft.print(now.second(), DEC);
  tft.println();
}

Anyone have idea what is a problem and how to fix it?
Ask if you need some more info about it.
Thanks.

I would try to examine pin header soldering.
did you try to fill whole screen?

yes, but i think its library problem because graphics test from MCUFRIEND_kbv works normally and i get from it
tft.setTextSize(WHITE,BLACK);
and it worked

from Adafuit_GFX.h

  void setTextSize(uint8_t s);
  void setTextSize(uint8_t sx, uint8_t sy);

So there is a two-argument signature. I am not too sure when you would ever want different sx, sy.
You certainly don't want BLACK or WHITE

If you want to set foreground and background colour.

  /*!
    @brief   Set text font color with custom background color
    @param   c   16-bit 5-6-5 Color to draw text with
    @param   bg  16-bit 5-6-5 Color to draw background/fill with
  */
  /**********************************************************************/
  void setTextColor(uint16_t c, uint16_t bg) {
    textcolor = c;
    textbgcolor = bg;
  }

But seriously, think about the number of pixels in your text.
Surely you want Landscape rotation ?

David.

Thanks David it worked.
and i corrected forom setTextSize to setTextColor after i make this discussion
and anyways thanks

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.