A kind of 3.2Inch display, mirrored [SOLVED, check post #12]

Hello!
I have this display from 3D printer parts. I've used a 16x2 LCD and a 7seg display before, but nothing like this one:


I searched the internet for some info and managed to discover its pinout:
5V ---LCD_CS
BTN_EN0 ---LCD_RESET
BTN_EN1 ---LCD_RS
BTN_EN2 ---SCLK
PUSH_PIN ---MOSI
GND ---MISO
GND ---BUZZER
Then I looked for examples with Arduino and finally I got here: http://www.lcdwiki.com/3.2inch_SPI_Module_ILI9341_SKU:MSP3218#How_to_use_on_Arduino

Hardware connection are these:

Where you see the red lines are unused pins because there are none on my display.
One of the sketches looks something like this:

 // IMPORTANT: LCDWIKI_SPI LIBRARY MUST BE SPECIFICALLY
// CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD.

//This program is a demo of displaying string

//when using the BREAKOUT BOARD only and using these hardware spi lines to the LCD,
//the SDA pin and SCK pin is defined by the system and can't be modified.
//if you don't need to control the LED pin,you can set it to 3.3V and set the pin definition to -1.
//other pins can be defined by youself,for example
//pin usage as follow:
//             CS  DC/RS  RESET  SDI/MOSI  SDO/MISO  SCK  LED    VCC     GND    
//Arduino Uno  A5   A3     A4      11        12      13   A0   5V/3.3V   GND

//Remember to set the pins to suit your display module!

/***********************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, QD electronic SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
**********************************************************************************/
#include <LCDWIKI_GUI.h> //Core graphics library
#include <LCDWIKI_SPI.h> //Hardware-specific library

//paramters define
#define MODEL ILI9341
#define CS   A5    
#define CD   A3
#define RST  A4
#define LED  A0   //if you don't need to control the LED pin,you should set it to -1 and set it to 3.3V

//the definiens of hardware spi mode as follow:
//if the IC model is known or the modules is unreadable,you can use this constructed function
LCDWIKI_SPI mylcd(MODEL,CS,CD,RST,LED); //model,cs,dc,reset,led
//if the IC model is not known and the modules is readable,you can use this constructed function
//LCDWIKI_SPI mylcd(240,320,CS,CD,RST,LED); //model,cs,dc,reset,led

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

void setup() 
{
  mylcd.Init_LCD();
  mylcd.Fill_Screen(BLACK);
}

void loop() 
{
  mylcd.Set_Text_Mode(0);
  //display 1 times string
  mylcd.Fill_Screen(0x0000);
  mylcd.Set_Text_colour(RED);
  mylcd.Set_Text_Back_colour(BLACK);
  mylcd.Set_Text_Size(1);
  mylcd.Print_String("Hello World!", 0, 0);
  mylcd.Print_Number_Float(01234.56789, 2, 0, 8, '.', 0, ' ');  
  mylcd.Print_Number_Int(0xDEADBEF, 0, 16, 0, ' ',16);
  //mylcd.Print_String("DEADBEF", 0, 16);

  //display 2 times string
  mylcd.Set_Text_colour(GREEN);
  mylcd.Set_Text_Size(2);
  mylcd.Print_String("Hello World!", 0, 40);
  mylcd.Print_Number_Float(01234.56789, 2, 0, 56, '.', 0, ' ');  
  mylcd.Print_Number_Int(0xDEADBEF, 0, 72, 0, ' ',16);
  //mylcd.Print_String("DEADBEEF", 0, 72);

  //display 3 times string
  mylcd.Set_Text_colour(BLUE);
  mylcd.Set_Text_Size(3);
  mylcd.Print_String("Hello World!", 0, 104);
  mylcd.Print_Number_Float(01234.56789, 2, 0, 128, '.', 0, ' ');  
  mylcd.Print_Number_Int(0xDEADBEF, 0, 152, 0, ' ',16);
 // mylcd.Print_String("DEADBEEF", 0, 152);

  //display 4 times string
  mylcd.Set_Text_colour(WHITE);
  mylcd.Set_Text_Size(4);
  mylcd.Print_String("Hello!", 0, 192);

  //display 5 times string
  mylcd.Set_Text_colour(YELLOW);
  mylcd.Set_Text_Size(5);
  mylcd.Print_String("Hello!", 0, 224);

  //display 6 times string
  mylcd.Set_Text_colour(RED);
  mylcd.Set_Text_Size(6);
  mylcd.Print_String("Hello!", 0, 266);

  delay(3000);
}

To my surprise, I managed to make it display something, a text, but it is mirrored. Do you have any idea why it behaves like this?

No idea, but if you switch to the Bodmer TFT_eSPI library you'll be working with something that's a lot more popular and well documented.

I have an ILI9341 display next to me with that library and by default it's normally oriented text. I think you'll spend more time trying to figure out why this is mirrored than switching to another library. Adafruit_GFX also supports it.

So this would be a more common library.
I downloaded it in the Arduino IDE, I saw that I have to make some changes in my circuit (according to the library), but what would be the model of this display? I see sketches for 320x240, 480x320. Also, I noticed that the sketches in this library take up a lot of memory, and I have an Arduino Nano. Maybe I should switch to Mega.

I don't know for sure what driver this display uses, but I followed the setup from the library and it doesn't work at all, the display stays on and doesn't show anything.

#define TFT_CS PIN_D8 // Chip select control pin D8
#define TFT_DC PIN_D3 // Data Command control pin
#define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line)
//#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V

I have an Arduino Nano

Crap! I forgot to ask you that. TFT_eSPI doesn't work well with Nano. Sorry about that.

Is there anything else to mention? Regarding the setup, because I made the connections as I said above, the pins for SPI are the ones in the middle of the board (Arduino Mega), I really don't see anything else.

How do you know it's an ILI9341?

Also, this thread: mirror display - #20 shows others with the same problem. /u/david_prentice has passed away, but you may be able to find an update library. As I noted, TFT_eSPI isn't really supported on the Uno, but checkout the Adafruit GFX library. It also supports the 9341 and it should work for you.

Unfortunately I have no clue, you just saw the pictures above. Only the manufacturer can know this.

See the update I just made to my post.

Looking at other displays from this manufacturer (which actually produces parts for 3D printers), I saw that it has the ST7567 driver for some displays in the list.

Hello I had experienced a mirrored text too using an ILI9341 2.8" TFT V1.1 with the LCDWIKI_SPI Library.
I've managed to fix it by changing the LCDWIKI_SPI.cpp file in two places:
in void LCDWIKI_SPI::Set_Rotation(uint8_t r) method
in last "else" I've rotated cases from 0,1,2,3 into 1,2,3,0 that is

else
	{
		uint8_t val;
		switch (rotation) 
		{
		   	case 1:
		     	val = ILI9341_MADCTL_MX | ILI9341_MADCTL_BGR; //0 degree 
				break;
		   	case 2:
		     	val = ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR; //90 degree 
		     	break;
		 	case 3:
		    	val = ILI9341_MADCTL_MY | ILI9341_MADCTL_ML |ILI9341_MADCTL_BGR; //180 degree 
		    	break;
		   	case 0:
		     	val = ILI9341_MADCTL_MX | ILI9341_MADCTL_MY| ILI9341_MADCTL_ML | ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR; //270 degree 
		     	break;
		 }

The second modification is at
void LCDWIKI_SPI::Set_Addr_Window(int16_t x1, int16_t y1, int16_t x2, int16_t y2)
in the last else I've swapped t_x_buf and t_y buf in this way:

else
	{
		uint8_t y_buf[] = {x1>>8,x1&0xFF,x2>>8,x2&0xFF};
		uint8_t x_buf[] = {y1>>8,y1&0xFF,y2>>8,y2&0xFF};
		Push_Command(XC, x_buf, 4);
		Push_Command(YC, y_buf, 4);
	}

In order to have the touch function working properly, I had to modify the LCDWIKI_TOUCH.cpp module as well in this way:

uint8_t LCDWIKI_TOUCH::TP_Scan(uint8_t mode)
{
	if(TIRQ_STATE==0) 
	{
		if(mode) //Physical coordinates
		{
			TP_Read_Coordinate2(&x,&y);
		}
		else if(TP_Read_Coordinate2(&x,&y)) //screen coordinate
		{
		/*
			long temp;
			temp = (long)XFAC*x/10000;
			x=temp+XOFFSET;
			temp = (long)YFAC*y/10000;
		    y=temp+YOFFSET;
	   */
			x=((long)XFAC*x)/10000+XOFFSET;
		    y=((long)YFAC*y)/10000+YOFFSET;
			switch(touch_rotation)
			{
				case 0:
					if(lcd_rotation == 2)
					{
						break;
					}
					else if(lcd_rotation == 3)
					{
						uint16_t tmp;
						tmp = x;
						x=y;
						y=tmp;
						y = heig - y;
					}
					else if(lcd_rotation == 0)
					{
						x = wid-x;
						y = heig - y;
					}
					else if(lcd_rotation == 1)
					{
						uint16_t tmp;
						tmp = x;
						x=y;
						y=tmp;
						x = wid-x;
					}
					break;
				case 1:
					if(lcd_rotation == 2)
					{
						x = wid-x;
					}
					else if(lcd_rotation == 3)
					{
						uint16_t tmp;
						tmp = x;
						x=y;
						y=tmp;
					}
					else if(lcd_rotation == 0)
					{
						y = heig - y;
					}
					else if(lcd_rotation == 1)
					{
						uint16_t tmp;
						tmp = x;
						x=y;
						y=tmp;
						x = wid-x;
						y = heig - y;
					}
					break;
				case 2:
					if(lcd_rotation == 2)
					{
						x = wid-x;
						y = heig - y;
					}
					else if(lcd_rotation == 3)
					{
						uint16_t tmp;
						tmp = x;
						x=y;
						y=tmp;
						x = wid-x;
					}
					else if(lcd_rotation == 0)
					{
						break;
					}
					else if(lcd_rotation == 1)
					{
						uint16_t tmp;
						tmp = x;
						x=y;
						y=tmp;
						y = heig - y;
					}
					break;
				case 3:
					if(lcd_rotation == 2)
					{
						y = heig - y;
					}
					else if(lcd_rotation == 3)
					{
						uint16_t tmp;
						tmp = x;
						x=y;
						y=tmp;
						x = wid-x;
						y = heig - y;
					}
					else if(lcd_rotation == 0)
					{
						x = wid-x;;
					}
					else if(lcd_rotation == 1)
					{
						uint16_t tmp;
						tmp = x;
						x=y;
						y=tmp;
					}
					break;
				default:
					break;
			}
	 	}
		if((touch_statue&TP_PRES_DOWN)==0)
		{		 
			touch_statue=TP_PRES_DOWN|TP_CATH_PRES; 
			x0=x;
			y0=y;  	   			 
		}			   
	}
	else
	{
		if(touch_statue&TP_PRES_DOWN)
		{
			touch_statue&=~(1<<7);
		}
		else
		{
			x0=0;
			y0=0;
			x=0xffff;
			y=0xffff;
		}	    
	}
	return touch_statue&TP_PRES_DOWN;
}
1 Like

Hi!
I did not go any further with this display, it remained in a box. But as winter came, maybe I'll give it another chance.
Thanks for the reply.
I'll be back shortly.

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