Go Down

Topic: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields (Read 335639 times) previous topic - next topic

oneis

Actual photo of the LCD panel is attached!

Thanks for drawing attention to my lazy spelling I have corrected that single post, we Aussies have a very bad habit of truncating words really it's not good enough!
U2 & U3 are: SN74LVC245A tri-state octal bus transceiver ICs used here to interface Arduino 5V logic with the ILI9486 controller.

And confirmed that the 3.3V shield pin is not connected to the display panel in any way. Which makes switching the 5V display feed impossible to recover the GRAM.

R1 is 2 ohms, I cannot trace its other end from the LDO output. It may be the back-light series resistor although rather low value. Do you happen to know its function? It is present in many ebay pictures of these shields.

Update

Problem solved! R1 is the back-light feed, to control the back-light one only has to put a switch in series with R1. Either a P-channel FET or PNP transistor brightness can be made variable by controlling the switch from Arduino PWM logic or a logic 0/1 to turn back-light on/off. Obviously make sure the transistor/FET can handle the current.

Thanks again David, that's thrown important light on the shield wiring and back-light feed.





imatan

I have this

Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 15 80   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 01 00 01   Manufacturer ID
reg(0x0009) 00 01 00 01 00   Status Register
reg(0x000A) 00 00   Get Power Mode
reg(0x000C) 00 00   Get Pixel Format
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 01   RDID2 HX8347-G
reg(0x0063) 00 00   RDID3 HX8347-G
reg(0x0064) 00 00   RDID1 HX8347-A
reg(0x0065) 00 00   RDID2 HX8347-A
reg(0x0066) 00 00   RDID3 HX8347-A
reg(0x0067) 00 00   RDID Himax HX8347-A
reg(0x0070) 00 00   Panel Himax HX8347-A
reg(0x00A1) 00 00 00 00 00   RD_DDB SSD1963
reg(0x00B0) 00 00   RGB Interface Signal Control
reg(0x00B4) 00 00   Inversion Control
reg(0x00B6) 00 00 00 00 00   Display Control
reg(0x00B7) 00 00   Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00   ILI9481, HX8357-B
reg(0x00C0) 00 00 00 00 00 00 00 00 00   Panel Control
reg(0x00C8) 00 14 00 14 00 14 00 14 00 14 00 14 00   GAMMA
reg(0x00CC) 00 02   Panel Control
reg(0x00D0) 00 5A 00   Power Control
reg(0x00D2) 00 BE 00 BE 00   NVM Read
reg(0x00D3) 00 FF 00 FF   ILI9341, ILI9488
reg(0x00D4) 00 00 00 00   Novatek ID
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
reg(0x00E0) 16 06 16 06 16 06 16 06 16 06 16 06 16 06 16 06   GAMMA-P
reg(0x00E1) 07 88 07 88 07 88 07 88 07 88 07 88 07 88 07 88   GAMMA-N
reg(0x00EF) 00 00 00 00 00 00   ILI9327
reg(0x00F2) 00 00 00 00 00 00 00 00 00 00 00 00   Adjust Control 2
reg(0x00F6) 00 54 00 54   Interface Control


When I try showBMP i have many "bad position"

david_prentice

You have a Renesas R61580.   You have to enable SUPPORT_1580 in MCUFRIEND_kbv.cpp as explained in the how_to file.

I have never seen an R61580.   I rely on feedback from owners.   e.g. which example sketch,  what problem.

David.

Ahsan_Aslam

Hello David,

Hope you are fine and doing well,

Actually I just purchased the TFT module for mega2560 with mcufriend.com branding on it. Now It has no connection to analog pinout of mega, could you please tell me how can I change the code for my shield.

attached are the pictures of shield with mega2560.

Thanks in advance.

david_prentice

Go on.   You have posted five JPEGs when you just need 152922.jpg i.e. a photo of the pcb.

It says quite clearly: 3.5" TFTLCD for arduino mega 2560
and it obviously has too many pins to be a Uno Shield.

From the how_to file:
Code: [Select]

17. If you do not have a standard Uno Shield, you can add a SPECIAL to the mcufriend_special.h
    Edit mcufriend_shield.h:  #define USE_SPECIAL
    Edit mcufriend_special.h: e.g. #define USE_MEGA_16BIT_SHIELD
    If your "special" is write-only,  the library can not read the ID.  It always returns 0xD3D3


Since you have a 320x480 display,  you might have to try all the 320x480 controllers in the how_to file.

Please let me know how you get on.

If you post a link to the Ebay sale with your result,  other buyers benefit from your work.

David.

azimsyamil

Hello David, do have any info or example for touch screen feature for an Arduino mega that connected with a 3.5" TFT LCD  Shield? I'm stuck on how to function the touch screen.

Thank you in advance.

ianjeffery

Hi Everyone - david_prentice

I have a McuFriend 3.5 inch tft touch screen. it has an ID of ID = 0x6814

The MCULibrary works great, along with the AdaFruit GFX library...

however i have a drawing issue i cant figure out...

Here is my test sketch

Code: [Select]
#include <SPI.h>
#include "Adafruit_GFX.h"
#include <MCUFRIEND_kbv.h>
//#include <Fonts/FreeSans9pt7b.h>
#include <TouchScreen.h>


// TOUCH SCREEN STUFF


// most mcufriend shields use these pins and Portrait mode:
#define YP  A2  // must be an analog pin, use "An" notation!
#define XM  A1  // must be an analog pin, use "An" notation!
#define YM  6   // can be a digital pin
#define XP  7   // can be a digital pin

// This is calibration data for the raw touch data to the screen coordinates
#define TS_MINX 110
#define TS_MINY 80
#define TS_MAXX 900
#define TS_MAXY 940

#define MINPRESSURE 10
#define MAXPRESSURE 1000

MCUFRIEND_kbv tft;

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

#define BUTTON_TEXTSIZE 2

#define ST7735_BLACK   0x0000
#define ST7735_WHITE   0xFFFF
#define ST7735_AQUA    0x04FF
#define ST7735_BLUE    0x001F


Adafruit_GFX_Button buttons[2];

void drawScreen()
{
tft.setRotation(2);
// tft.setFont(&FreeSans9pt7b);

tft.fillScreen(ST7735_BLACK);

// reset the font
tft.setFont();

buttons[0].initButtonUL(&tft, 50, 100, 150, 50, ST7735_WHITE, ST7735_BLUE, ST7735_WHITE, "Test 1", BUTTON_TEXTSIZE);
buttons[0].drawButton();

buttons[1].initButtonUL(&tft, 50, 170, 150, 50, ST7735_WHITE, ST7735_BLUE, ST7735_WHITE, "Test 2", BUTTON_TEXTSIZE);
buttons[1].drawButton();
}

void setup()
{
Serial.begin(9600);

//tft.begin(HX8357D);
uint16_t ID = tft.readID(); //
Serial.print("ID = 0x");
Serial.println(ID, HEX);
if (ID == 0xD3D3) ID = 0x9481; // write-only shield
tft.begin(ID);

drawScreen();
}

void loop(void)
{
// Retrieve a point 
TSPoint p = ts.getPoint();

// we have some minimum pressure we consider 'valid'
// pressure of 0 means no pressing!
if (p.z < MINPRESSURE || p.z > MAXPRESSURE) {
return;
}

// For McuFriend
p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);

// go thru all the buttons, checking if they were pressed
for (uint8_t b = 0; b<2; b++)
{
if (buttons[b].contains(p.x, p.y))
{
{
buttons[b].press(true);  // tell the button it is pressed
Serial.print("Pressing ");
Serial.println(buttons[b].Id());
tft.fillRect(50, 250, 150, 50, ST7735_AQUA);
buttons[b].drawButton(true);
}
}
else
{
{
Serial.print("Released ");
buttons[b].press(false);  // tell the button it is pressed
buttons[b].drawButton();
}
}
}
}


What it should do is draw the button inverted when its being pressed, and normal when its been released.....

and to help test, i want it to draw a rect when i am pressing.

It seems to totally ignore any draw commands within the loop() function, so that it will not draw the buttons inverted.

What am i doing wrong ?

david_prentice

I have just issued a new Release of the library.     I have updated / added / removed several examples.

Please can you try the Touch Calibration and Button examples.    Are they helpful?
Code: [Select]

// copy-paste results from TouchScreen_Calibr_native.ino
const int XP = 6, XM = A2, YP = A1, YM = 7; //ID=0x9341
const int TS_LEFT = 907, TS_RT = 136, TS_TOP = 942, TS_BOT = 139;



I would appreciate some feedback.   Or any suggestions how to improve the examples.

David.

ianjeffery

Hi David,

does this relate to my issue, or should i start a new thread for this?

david_prentice

I was just suggesting that you run the Calibration sketch and copy-paste the result into your sketch.

i.e. replace the eight #defines with the two const lines pasted from the Calibration.

You have got multiple things wrong in your sketch.   I just think you will be better off making a fresh start with correct X, Y directions and values.

Yes,  you can start a fresh thread if you want.    I could point out every "anomoly" one at a time.

If you post your Calibration result,   I could tidy the sketch up for you i.e. run and test it on my hardware.

It is your choice.   Somehow I suspect that you would learn better by yourself than being handed a solution on a plate.    It is actually easier for me to write a solution than to type up every "anomoly" and wait for a response.

David.

ianjeffery

Hi David,

Thank you for your reply. I didnt know if it was directed at myself or not.

I would appreciate you giving me the answer ( I learn best by example ), but i will run through the calibration and post a response too.

Ian.

imatan

You have a Renesas R61580.   You have to enable SUPPORT_1580 in MCUFRIEND_kbv.cpp as explained in the how_to file.

I have never seen an R61580.   I rely on feedback from owners.   e.g. which example sketch,  what problem.

David.
Perfect. Thanks.

vph

Hi,
can somebody provide a link to a wiring example, specifically  STM32F103C8T6 to a 3.5 inch MCUFRIEND lcd display.

Thanks

david_prentice

From mcufriend_shield.h:
Code: [Select]

#warning Uno Shield on BLUEPILL
#define RD_PORT GPIOB
//#define RD_PIN  5
#define RD_PIN  0  //hardware mod to Adapter.  Allows use of PB5 for SD Card
#define WR_PORT GPIOB
#define WR_PIN  6
#define CD_PORT GPIOB
#define CD_PIN  7
#define CS_PORT GPIOB
#define CS_PIN  8
#define RESET_PORT GPIOB
#define RESET_PIN  9

// configure macros for the data pins
#define write_8(d)    { GPIOA->REGS(BSRR) = 0x00FF << 16; GPIOA->REGS(BSRR) = (d) & 0xFF; }
#define read_8()      (GPIOA->REGS(IDR) & 0xFF)
//                                         PA7 ..PA0
#define setWriteDir() {GP_OUT(GPIOA, CRL, 0xFFFFFFFF); }
#define setReadDir()  {GP_INP(GPIOA, CRL, 0xFFFFFFFF); }

Choose whether you put LCD_RD on PB5 or PB0.   The Adapter was designed for PB5.
Code: [Select]

3.3V   3.3V
5V     5V
GND    GND
LCD_RD  PB0
LCD_WR  PB6
LCD_RS  PB7
LCD_CS  PB8
LCD_RST PB9
LCD_D0 PA0
LCD_D1 PA1
LCD_D2 PA2
LCD_D3 PA3
LCD_D4 PA4
LCD_D5 PA5
LCD_D6 PA6
LCD_D7 PA7


David.

tongbajiel

Hello david.
I got lcd from Blackberry 8520. it has 240x320 res as in spec.

here result from read id. HIGHLIGHTED only on fillable value

Code: [Select]
Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

...
reg(0x0004) 29 29 10 F0 F0 F0 F0 f.k
reg(0x0009) 00 00 71 00 00 00 00 f.k
reg(0x000A) 08 08 08 08 08 08 08 f.k
reg(0x000B) 00 00 00 00 00 00 00 f.k
reg(0x000C) 07 07 07 07 07 07 07 f.k
reg(0x000D) 00 00 00 00 00 00 00 f.k
reg(0x000E) 00 00 00 00 00 00 00 f.k
reg(0x000F) 00 00 00 00 00 00 00 f.k
reg(0x002E) 9B 04 13 9B 04 13 9B f.k
reg(0x00DA) 29 29 29 29 29 29 29 f.k
reg(0x00DB) 10 10 10 10 10 10 10 f.k
reg(0x00DC) F0 F0 F0 F0 F0 F0 F0 f.k
.....


reg(0x0000) FF FF FF FF ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 29 29 10 F0 Manufacturer ID
reg(0x0009) 00 00 71 00 00 Status Register
reg(0x000A) 08 08 08 08 Get Power Mode
reg(0x000C) 07 07 07 07 Get Pixel Format
reg(0x0061) FF FF FF FF RDID1 HX8347-G
reg(0x0062) FF FF FF FF RDID2 HX8347-G
reg(0x0063) FF FF FF FF RDID3 HX8347-G
reg(0x0064) FF FF FF FF RDID1 HX8347-A
reg(0x0065) FF FF FF FF RDID2 HX8347-A
reg(0x0066) FF FF FF FF RDID3 HX8347-A
reg(0x0067) FF FF FF FF RDID Himax HX8347-A
reg(0x0070) FF FF FF FF Panel Himax HX8347-A
reg(0x00A1) FF FF FF FF FF RD_DDB SSD1963
reg(0x00B0) FF FF FF FF RGB Interface Signal Control
reg(0x00B4) FF FF FF FF Inversion Control
reg(0x00B6) FF FF FF FF FF Display Control
reg(0x00B7) FF FF FF FF Entry Mode Set
reg(0x00BF) FF FF FF FF FF FF ILI9481, HX8357-B
reg(0x00C0) FF FF FF FF FF FF FF FF FF Panel Control
reg(0x00C8) FF FF FF FF FF FF FF FF FF FF FF FF FF GAMMA
reg(0x00CC) FF FF FF FF Panel Control
reg(0x00D0) FF FF FF Power Control
reg(0x00D2) FF FF FF FF FF NVM Read
reg(0x00D3) FF FF FF FF ILI9341, ILI9488
reg(0x00D4) FF FF FF FF Novatek ID
reg(0x00DA) 29 29 29 29 RDID1
reg(0x00DB) 10 10 10 10 RDID2
reg(0x00DC) F0 F0 F0 F0 RDID3
reg(0x00E0) FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF GAMMA-P
reg(0x00E1) FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF GAMMA-N
reg(0x00EF) FF FF FF FF FF FF ILI9327
reg(0x00F2) FF FF FF FF FF FF FF FF FF FF FF FF Adjust Control 2
reg(0x00F6) FF FF FF FF Interface Control



if i test with graphics_kbv, read ID found 0x1526
LCD got display but wrong parameter i think.


Go Up