Arduino Forum

Using Arduino => Displays => Topic started by: david_prentice on Dec 17, 2015, 11:03 am

Title: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Dec 17, 2015, 11:03 am
#MCUFRIEND_kbv
Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend  Shields

1. The Arduino Library Manager should find and install MCUFRIEND_kbv library

2. Install the Adafruit_GFX library if not already in your User libraries.

3. Insert your Mcufriend style display shield into UNO.   Only 28-pin shields are supported.

4. Build any of the Examples from the File->Examples->Mcufriend_kbv menu.  e.g.

graphictest_kbv.ino: shows all the methods.

LCD_ID_readreg.ino:  diagnostic check to identify unsupported controllers.

MCUFRIEND_kbv inherits all the methods from
the Adafruit_GFX class: https://learn.adafruit.com/adafruit-gfx-graphics-library/overview
and Print class: https://www.arduino.cc/en/Serial/Print

The only "new" methods are hardware related:
vertScroll(), readGRAM(), readPixel(), setAddrWindow(), pushColors(), readID(), begin()

readReg(), pushCommand() access the controller registers

The File layout changed with v2.9.3.   If replacing a pre-v2.9.3 library:
Please leave IDE.  Delete the existing MCUFRIEND_kbv folder.  Start the IDE.  Install from Library Manager.

HOW TO INSTALL AND USE: is now in "mcufriend_how_to.txt"

CHANGE HISTORY:         is now in "mcufriend_history.txt"
Title: Re: MCUFRIEND_kbv Library for Uno Shields
Post by: david_prentice on Dec 17, 2015, 11:05 am
I have moved the library from there (http://forum.arduino.cc/index.php?topic=337473.msg2373456#msg2373456) to this new Thread.
 
Please post questions here.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Melandr on Dec 17, 2015, 03:05 pm
Good day. The text direction is not correct when using the library, what should be changed in the library to properly display text? The text prints right to left and have the left-to-right.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Dec 17, 2015, 03:17 pm
First off.    Is it an ILI9331 ?   What does graphictest_kbv say ?   What did the Serial Terminal say ?

I do not currently support a 9331 but do have 9320, 9325, 9335.   What did you use with tft.begin() ?

Yes,   it should be easy to add support for the 9331.

1. could you confirm whether the PORTRAIT, LANDSCAPE, PORTRAIT_REV, LANDSCAPE_REV are correct.
2. does Vertical scroll work?
3. does Software scroll work?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Melandr on Dec 17, 2015, 03:26 pm
I slightly changed Your library by adding the initialization code of the ILI9331 display that displays the serial port

TFT LCD test
Using Adafruit 2.8" TFT Breakout Board Pinout
TFT size is 240x320
Found ILI9331 LCD driver
Benchmark Time (microseconds)
Screen fill 1717572
Text 366476
Lines 2297612
Horiz/Vert Lines 177060
Rectangles (outline) 142544
Rectangles (filled) 3574852
Circles (filled) 2359488
Circles (outline) 1002960
Triangles (outline) 728860
Triangles (filled) 2385364
Rounded rects are (outline) 409180
Rounded rects are (filled) 4459388
Done!

Don't know how to attach Your modified source code.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Dec 17, 2015, 03:43 pm
You appear to be running "graphicstest" and not "graphictest_kbv".

Probably on a MEGA2560 because a UNO would be 2.5x faster.

Please could you answer (1), (2), (3).   Then I can add full support for the ILI9331 which would benefit other users.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Melandr on Dec 17, 2015, 07:56 pm
Code: [Select]
case 0x9331:
_lcd_capable = AUTO_READINC | REV_SCREEN;
static const uint16_t ILI9331_regValues[] PROGMEM = {
0x0001,0x0100,    
0x0002,0x0700,    
0x0003,0x8020,    
0x0008,0x0302,    
0x0009,0x0000,   
0x000A,0x0008,    
//*******POWER CONTROL REGISTER INITIAL*******//    
0x0010,0x0790,    
0x0011,0x0005,    
0x0012,0x0000,   
0x0013,0x0000,    
//delayms(50, 
//********POWER SUPPPLY STARTUP 1 SETTING*******//    
0x0010,0x12B0,    
// delayms(50,  
0x0011,0x0007,    
//delayms(50,  
//********POWER SUPPLY STARTUP 2 SETTING******//    
0x0012,0x008C,    
0x0013,0x1700,    
0x0029,0x0022,    
// delayms(50,   
//******GAMMA CLUSTER SETTING******//    
0x0030,0x0000,    
0x0031,0x0505,    
0x0032,0x0205,    
0x0035,0x0206,    
0x0036,0x0408,    
0x0037,0x0000,    
0x0038,0x0504,
0x0039,0x0206,    
0x003C,0x0206,    
0x003D,0x0408,    
// -----------DISPLAY WINDOWS 240*320-------------//    
0x0050,0x0000,
0x0051,0x00EF,   
0x0052,0x0000,   
0x0053,0x013F,   
//-----FRAME RATE SETTING-------//    
0x0060,0xA700,   
0x0061,0x0001,   
0x0090,0x0033, //RTNI setting
//-------DISPLAY ON------//    
0x0007,0x0133,    0x0001,0x0100,    
 0x0002,0x0700,    
0x0003,0x1030,    
0x0008,0x0302,    
0x0009,0x0000,   
0x000A,0x0008,    
//*******POWER CONTROL REGISTER INITIAL*******//    
0x0010,0x0790,    
0x0011,0x0005,    
0x0012,0x0000,   
0x0013,0x0000,    
//delayms(50, 
//********POWER SUPPPLY STARTUP 1 SETTING*******//    
0x0010,0x12B0,    
// delayms(50,  
0x0011,0x0007,    
// delayms(50,  
//********POWER SUPPLY STARTUP 2 SETTING******//    
0x0012,0x008C,    
0x0013,0x1700,    
0x0029,0x0022,    
// delayms(50,   
//******GAMMA CLUSTER SETTING******//    
0x0030,0x0000,    
0x0031,0x0505,    
0x0032,0x0205,    
0x0035,0x0206,    
0x0036,0x0408,    
0x0037,0x0000,    
0x0038,0x0504,
0x0039,0x0206,    
0x003C,0x0206,    
0x003D,0x0408,    
// -----------DISPLAY WINDOWS 240*320-------------//    
0x0050,0x0000,
0x0051,0x00EF,   
0x0052,0x0000,   
0x0053,0x013F, 
//-----FRAME RATE SETTING-------//    
0x0060,0xA700,   
0x0061,0x0001,   
0x0090,0x0033, //RTNI setting
//-------DISPLAY ON------//    
0x0007,0x0133,   
};
init_table16(ILI9331_regValues, sizeof(ILI9331_regValues));
        break;


Added a bit of code in the file MCUFRIEND_kbv, test "graphicstest". There is a video of the test though there is a bit much, don't know where to reset to show. Sorry for bad English, I write through Google translator.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Dec 17, 2015, 11:30 pm
Thanks for your post.    I see that the Power Control registers values are very different to the ILI9325.
The Entry Mode (0x03) is very unusual.

I would appreciate it if you could run the "graphictest_kbv" sketch and answer the 3 questions from message #3.

I manipulate the SS, GS, ORG bits to achieve Rotation in a consistent way.    With the I/D bits set at 11 (i.e. increment horizontal, increment vertical).

It looks as if your JPEG is displaying Portrait mode with GS in the wrong direction.
Note that the graphictest_kbv sketch states each direction and mode.

This should make it easy to say "PORTRAIT is reverse-vertical" to describe your photo.
From your earlier post,   you said "text was reverse-horizontal"

What happens if you simply force tft.begin(0x9320)  in the graphictest_kbv sketch?

I am sure that we can get your Shield displaying 100%.
Do not worry about English translation.    But it would help if you run graphictest_kbv.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Melandr on Dec 18, 2015, 08:59 am
Thanks for the answer. After recording "tft.begin (0x9320);" to sketch graphictest_kbv, text became displayed correctly. As for the answers to questions (1), (2), (3) after the change of the sketch:
1. Modes PORTRAIT, LANDSCAPE, PORTRAIT_REV, LANDSCAPE_REV were printed correctly.
2. Vertical scroll mode works properly.
3. Software scroll mode works only on EADB red letters in a small window
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Melandr on Dec 18, 2015, 09:16 am
I wanted to also ask, does this mean that my display ILI9331 is compatible with the display ILI9320?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Dec 18, 2015, 09:21 am
Thanks for your report.

The software scroll only works on that small rectangle.   At the end,   the EADB should still be in Red.   The broken  letters should still be in Yellow.     There should be no flashes of Blue during the scroll.

Please remove the plastic film from your screen.    It distorts the colours.
All the colours and printing should look very bright and clear.   There is a bit of blurring during the Vertical scroll.

Compare the 9320 screen with your 9331 code.
Which looks better?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Melandr on Dec 18, 2015, 09:37 am
Thanks for the reply. I now understand what is the difference in initializing the display 9320. Also wanted to ask why You said that the display on the UNO Board will run faster than on-Board MEGA 2560.
Also, this question is a bit off topic, but associated with the display. To display the images with the SD card uses the SPI library with hardware support. But since my display Pinout charge made under UNO, it is not the same SPI pins. For UNO - 10, 11, 12, 13, and MEGA - 50, 51, 52, 53. a question arises, is it possible to use software SPI, SPI by assigning findings on 10,11,12,13?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Dec 18, 2015, 10:14 am
These displays are designed for a Uno.    They work very well on a Uno.

If you use a Mega,   the TFT will be 2.5x slower than a Uno.   You must use Software SPI for the microSD.  e.g. with the SdFat library.

Personally,    I find the SdFat library is not as reliable to use as the regular SD library that comes with your Arduino.

Since Uno clones are so cheap,    I suggest that you use your display with a clone instead of a Mega2560.

From my point of view,    I look forward to hearing whether 0x9320 or 0x9331 gives a better picture.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: rahulmr on Dec 24, 2015, 07:37 am
I got the 3.95LCD from aliexpres which uses IL9488.

I am using the library given here . I am using MEGA as I need other GPIO to be used for other purposes. I can't use the UNO because of this limitation.I don't need touch screen .

I have other modules like the DS3231 ,and ESP8266 connected to the MEGA and this 3.95 LCD connected as well. ESP8266 is powered separately using a 12-5v converted supply. Mega is powered using another source.The normal grapichs test is working in the LCD. I am able to make it work with the nano,uno and mega. Even for mega I am able to write customized messages.

What I intend to do is to update the time in the LCD which is received from the DS3231. It updates the LCD but I see a flickering issue here.

Every update(LCD display function is from the loop which sets the text when there is a second/time/hour difference in the time.) seems like draining more current as the one of the LED connected to MEGA dims, the rx/tx leds also dims.

I am able to get the LCD refreshed but it shows a flickering.I powered the LCD 3.3 and 5v using another separate source but still the small flickering continues.
Moreover all these time I was connected to the MEGA through the USB from the laptop.Once I unplug the USB, LCD starts and shows some update and again become white. This continues and an not able to see anything on LCD there after.

I am not sure why only when the MEGA is connected to USB this LCD works and that too flickering but once the USB is removed the LCD is not working at all.

Can some one please do help me in this ?
 
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Dec 24, 2015, 10:25 am
So your shield works 100% on a Uno and Mega running the library examples.

If you have a problem with your own code,  please post your sketch and a schematic of your wiring.
A simple pencil drawing of your wiring is fine if you attach a good photo.

A written description of your wiring is fine too.   But check it VERY carefully.   The description in your message#13 is not accurate enough.   Put yourself in our shoes.   We do not know whether you have connected GND wires,  what kind of power supply,  what pins are connected  ...

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: rahulmr on Dec 24, 2015, 11:29 am
So your shield works 100% on a Uno and Mega running the library examples.

If you have a problem with your own code,  please post your sketch and a schematic of your wiring.
A simple pencil drawing of your wiring is fine if you attach a good photo.

A written description of your wiring is fine too.   But check it VERY carefully.   The description in your message#13 is not accurate enough.   Put yourself in our shoes.   We do not know whether you have connected GND wires,  what kind of power supply,  what pins are connected  ...

David.
Thanks David for looking into the issue. Sorry for not being clear on the text as these are my initial set of posts. I meant to mention about grounding but I forgot to.

I used 3 12V 2 amp adapters and powered 3 MB102 (http://www.amazon.com/gp/product/B010UJFVTU).One is used to power the ESp8266, One for Mega and one for the TFT LCD. All the grounds are connected together. From the Mega I have connected the DS3231. This is powered from the Mega.

Only when the USB connected to another USB power source(2AH phone charger) or to laptop(mac) the LCD starts working but not without flickering.

I doubt about the current consumed as there is on LED connected to GPIO in Mega and it dims along with TFT LCD.

I will shortly post the code and the sketch. If someone can help in between I would be thankful to them.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Dec 24, 2015, 12:29 pm
Why so complicated?
You could supply the ESP8266 from the 3.3V output on the Mega.    Of course the 3.95" shield obscures the 3.3V pin.

Likewise,   you could power the Mega from the 5V output of the MB102 and the ESP8266 from the 3.3V output.
I am very worried about a 12V wall-wart.   The MB102 regulator will get warm.    A 6V or 7.5V wall-wart would be safer.

The 3.95" shield takes about 200mA.    Most current goes to the backlight.

I have not heard anything about level-shifters for the ESP8266.    If you drive it from the 5V Mega pins,   you will back-feed voltage.    You must have a level-shifter chip or resistors.

We really do need to see a schematic as well as your code.

David.   
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: rahulmr on Dec 24, 2015, 12:59 pm
Why so complicated?
You could supply the ESP8266 from the 3.3V output on the Mega.    Of course the 3.95" shield obscures the 3.3V pin.

Likewise,   you could power the Mega from the 5V output of the MB102 and the ESP8266 from the 3.3V output.
I am very worried about a 12V wall-wart.   The MB102 regulator will get warm.    A 6V or 7.5V wall-wart would be safer.

The 3.95" shield takes about 200mA.    Most current goes to the backlight.

I have not heard anything about level-shifters for the ESP8266.    If you drive it from the 5V Mega pins,   you will back-feed voltage.    You must have a level-shifter chip or resistors.

We really do need to see a schematic as well as your code.

David.   
Thanks for the inputs . For the ESP8266 I have level shifter using the resistors. I powered the ESp8266 separately because I read in many blogs that the arduino boards wont be able to provide the sufficient current to the ESP8266 and better to have separate power supply. I have used level shifter for the ESp8266 as well .

I want to know a few more details of the TFT LCD. Is it really required to power up the 3.3v and 5v pins in LCD if I just want to use module excluding the SD card and the touch. I just want that to be a screen to display the data.

Now that I have connected the D0-D8  to the Mega PINS 2-9 . Connected the 5 and 3.3v and GND.
And the A0-A4 in Arduino MEGA for the LCD_RD - LCD_RST in LCD.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Dec 24, 2015, 01:17 pm
You really need to explain yourself.   Or post a schematic,  photo,  ...

I would assume that there is only one way that you can plug a shield into an Arduino.
Then there is no confusion about which pin is connected where.

Multiple different power supplies are very worrying.
Surely a single Mega would provide the 5V and 3.3V supplies.

If you are cavalier with voltages,   you will destroy chips.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zoomx on Dec 28, 2015, 09:45 pm
Arduino UNO can provide only 50mA on 3.3V, don't know Mega, absolutely insufficient to power an ESP8266 expecially during transmission.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: CrossRoads on Dec 28, 2015, 09:48 pm
"Arduino UNO can provide only 50mA on 3.3V"
150mA, Mega also. May not be enough for ESP8266 tho.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Dec 28, 2015, 10:06 pm
I know nothing about the ESP8266.    Looking at the data sheet,  it certainly can draw a lot of current during TX.   

We still have not received a schematic or accurate explanation of rahulmr's wiring.    Life can get complicated with different logic levels and power supplies.

It looks as if you need the external power supply for the ESP8266.    It seems an awful waste to drop 12V to 3.3V.   

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zoomx on Dec 29, 2015, 07:25 pm
"Arduino UNO can provide only 50mA on 3.3V"
150mA, Mega also. May not be enough for ESP8266 tho.
From https://www.arduino.cc/en/Main/ArduinoBoardUno (https://www.arduino.cc/en/Main/ArduinoBoardUno)
Quote
DC Current for 3.3V Pin

50 mA


Mega is the same.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ArcAiN6 on Jan 02, 2016, 09:23 am
Odd..

I ran the graphicstest_kbv sketch on an uno with a 2.4" mcufriend (marked st7789v)

The graphics appear, and scrolls and rotates and all that.. however, looking in the serial monitor just prints out
ID = 0x0

Not sure what's going on, or how to fix this. I've attempted to contact MCUFriend through their website, but have not heard back from them, since i ordered this on schmeeeebay, i contacted the seller, and haven't heard from them either.

I've tried several libraries, some get the graphics working, but the touch doesn't, other can't get anything to work.

I'm seriously at a loss with this thing.

Attached is a picture of the device

Any advice on how to proceed would be phenomenal, as I'm really at a loss on this.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 02, 2016, 10:01 am
I have never seen "st7789v".   Please run the LCD_ID_readreg.ino sketch and copy-paste the result from the Serial terminal.

If you get a response from either Mcufriend or your Ebay vendor,   you deserve a medal.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ArcAiN6 on Jan 02, 2016, 11:45 am
As stated, i have already tried that, and it shows me 0x0, or C0C0 depending on which "identifyer" sketch is used.

The really odd thing is, i can run the device with the 9341 drivers, but there are "some" issues.

the touch pins aren't the same as on other boards / examples i've seen.. on this board it appears they are:
Touch Pins
#define YP A1
#define YM 6
#define XM A2
#define XP 7

Also, according to ramtex.dk, the st7789 has similar internal configuration and graphic rendering features as the following driver IC's

HX8325, HX8347, HX8352, HX8353, HX8367, HX8369, ILI9340, ILI9341, ILI9163, NT39122, SPFD54126, SSD1355, ST7715, ST7628, ST7735, ST7773.

The driver IC appears to be made by Sitronix Technology, i've put in a request for datasheets etc from them, so hopefully that will give us some better idea of the IC, how it works etc, and we maybe able to go from there.. i wasn't able to find the device on their site, but there is listed another version (st7789S) http://www.sitronix.com.tw/en/index.html

I just find it odd, that there are so many variations of these mcufriend devices showing up everywhere, and no real rhyme or reason as to why each is almost unique in how it functions..

So currently i'm tinkering around with getting it to actually function.. i can get display, and touch to function, as i said, using the ILI9341 driver, but i've had to change the pin assignments within sketeches for the touch to work.

Truth be told.. i'm kind of stabbing at this thing in the dark, as i know very little about tft / display drivers etc..

If you need any specific information, i'll try to get it for you.



Also, when i recieved the device, the double-sided tape that holds down the screen to the shield was lifting up, i gently lifted the screen, and replaced the tape, while doing so i did manage to write down all the numbers etc i could see...

On the ribbon:
H24TH97A-V0
2014-7-26

On the Screen Itself:
BL24532C1
MY187E
14/08/26


Here are some serial monitor outputs from various sketches.. I've seen that some people see C0C0 is something to do with broken solder, or trace on a pin, but i've not been able to locate any such issue on the board, so i'm not sure what's going on there..

TFT Test Sketch info:
TFT LCD test
TFT size is 240x320
Unknown LCD driver chip: C0C0
I try use ILI9341 LCD driver If using the Adafruit 2.8" TFT Arduino shield, the line:
  #define USE_ADAFRUIT_SHIELD_PINOUT
should appear in the library header (Adafruit_TFT.h).
If using the breakout board, it should NOT be #defined!
Also if using the breakout, double-check that all wiring
matches the tutorial.
Benchmark                Time (microseconds)
Screen fill              1787080
Text                     746528
Lines                    7784232
Horiz/Vert Lines         220308
Rectangles (outline)     168556
Rectangles (filled)      4680132
Circles (filled)         2412900
Circles (outline)        3400776
Triangles (outline)      2469012
Triangles (filled)       2712324
Rounded rects (outline)  1113784
Rounded rects (filled)   5641876
Done!

TFT Sketch 2 Info (graphixtest_kbv)
ID = 0x0

Also.. the device was cheap as all...
I got it here: www.ebay.com/itm/-/261688643631

Seller however, has automated message saying he's away from computer whenever you try to contact them.

Still waiting on reply from MCUFriend.com i've sent them an email with all the information i could find on the board / lcd / ribbon, as well as image of the board.. so here's to hoping they have a clue.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 02, 2016, 11:52 am
After reading your earlier post,  I downloaded the ST7789 data sheet and "added support"  to (my private copy of) the library.

If you are not prepared to copy-paste the result from LCD_ID_readreg.ino,   I will wait until there is a cooperative reader.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ArcAiN6 on Jan 02, 2016, 06:04 pm
thought I did paste the result of LCD_ID_readreg.ino

Here's the complete result that shows up in serial monitor:

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) C0 C0   ILI9320, ILI9325, ILI9335, ...
reg(0x0004) C4 85 85 52   Manufacturer ID
reg(0x0009) C9 00 61 00 00   Status Register
reg(0x00BF) FF 00 00 00 06 0C   ILI9481
reg(0x00D0) D0 A4   HX8357
reg(0x00D2) D2 00 00   NVM Read
reg(0x00D3) D3 00 00 00   ILI9341, ILI9488
reg(0x00DA) DA 85 00   RDID1
reg(0x00DB) DB 85 00   RDID2
reg(0x00DC) DC 52 00   RDID3
reg(0x00EF) EF 00 00 00 00 00   ILI9327
reg(0x00B0) F0   RGB Interface Signal Control
reg(0x00B4) F4   Inversion Control
reg(0x00B6) F6 00 00 00   Display Control
reg(0x00B7) F7   Entry Mode Set
reg(0x00F6) F6 FF FF   Interface Control



Nothing else gets printed to serial monitor
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 02, 2016, 06:24 pm
Yes,   you have a ST7789V controller.

I am a little surprised by the "dummy" byte in your output.  e.g. C0 85 85 52
Since the sketch resets the controller in hardware,   I would expect to see 0x00 with a correctly inserted shield.

Are you sure that you have not edited the sketch?

If you PM me with your email,   I could email you an updated ZIP.
l would hope that you could report back with the results.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ArcAiN6 on Jan 02, 2016, 07:06 pm
per request, i've pm'd you my email address.
No, i've not attempted to alter the sketch.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ardcp on Jan 05, 2016, 07:50 am
Hi David,

I have now got a 3.5" mcufriend display with an ili9481 driver as a replacement for a bad display with ili9486.
However, I see that the ili9481 is not in the list of supported displays.
But as the display is marked www.mcufriend.com, for info here are the results of a few tests.
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(0x0000) 00 00 ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 00 00 00 Status Register
reg(0x00BF) 00 02 04 94 81 FF ILI9481
reg(0x00D0) 00 00 HX8357
reg(0x00D2) 00 01 22 NVM Read
reg(0x00D3) 00 01 22 00 ILI9341, ILI9488
reg(0x00DA) 00 00 00 RDID1
reg(0x00DB) 00 00 00 RDID2
reg(0x00DC) 00 00 00 RDID3
reg(0x00EF) 00 00 00 00 00 00 ILI9327
reg(0x00B0) 00 RGB Interface Signal Control
reg(0x00B4) 00 Inversion Control
reg(0x00B6) 00 00 00 00 Display Control
reg(0x00B7) 00 Entry Mode Set
reg(0x00F6) 00 80 80 Interface Control


Testing with a modified tftbmp ( adding #include <MCUFRIEND_kbv.h>), it returns an ID of 2200.
The tftbmp is also modified to show a still image (for photos to the supplier ;) ).
Forcing the id to 0x9341 it does show an overexposed woof.bmp image on a white background.
The image is aligned to the right, not left as on other diplays.
I have searched for an Arduino library, but have only found UTFT and libraries for Mega and STM32.
Guess I have to look deeper into the datasheet for the ili9481 to set it up for 8-bit mode.

And using TouchScreen_Calibr_kbv blindfolded on a white screen reveals through the serial output that the touch panel is working.

Other example sketches also only show a white screen.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 05, 2016, 08:48 am
No problem.    I have had a ILI9481 write-only target for a while.    So I just need some testing on a read-write display.    PM me with your email,   and I will email you the ZIP.

I am hoping to receive an ILI9327 read-write display soon.    I will release v2.5 when I have tested ILI9327.

How portable is your Gamma_Adjust sketch?
Do you have a "testcard" image to do the adjusting on?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: scanfff on Jan 09, 2016, 10:08 am
Is it possible to get this display into serial mode? I'm trying to figure out if we have access to the IM register pins and put it into 3 or 4 wire mode so I can send it 16bit color. 

My display has the ili9341 driver.

BTW, thanks for the hard work I thought the display was junk till I found this thread.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 09, 2016, 10:24 am
The library is designed for MCUFRIEND UNO shields.

What display do you have?
Very few have access to the IMn pins.

Which Arduino do you want to use?

For an AVR: 3-wire mode can only be done by bit-bashing.
4-wire mode can use SPI hardware and work very well.   Look at Marek's "ILI9341_due" library

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 11, 2016, 11:30 pm
I have just posted version 2.5 of the MCUFRIEND_kbv (http://forum.arduino.cc/index.php?topic=366304.msg2524865#msg2524865) library at message #1 of this thread.

The new test sketch should illustrate features (and problems).

I would appreciate feedback for the following controllers:

Code: [Select]

ILI9335  240x320  ID=0x9335 new ----- Edit ----- ok
ILI9481  320x480  ID=0x9481 new ----- Edit ---- ok
LGDP4535 240x320  ID=0x4535 new Untested
RM68090  240x320  ID=0x6809 new Untested
S6D0139  240x320  ID=0x0139 new Untested
ST7789V  240x320  ID=0x7789 new ----- Edit ---- ok


but any suggestions are welcome.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: JimmyHats on Jan 12, 2016, 02:13 pm
Corrected Version of 2.5 works perfectly with ST7789v!

Thanks again, thats the only way to use this display. Im so happy right now xD
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ardcp on Jan 12, 2016, 07:46 pm
With version 2.5 my ili9481 equipped display passes all tests without problems. Great.

I see the LCD_ID_readreg output has changed, here is the result:

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(0x0000) 00 00 ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 00 00 00 Status Register
reg(0x00BF) 00 02 04 94 81 FF ILI9481, HX8357-B
reg(0x00D0) 00 00 Power Control
reg(0x00D2) 00 01 22 NVM Read
reg(0x00D3) 00 01 22 00 ILI9341, ILI9488
reg(0x00DA) 00 00 00 RDID1
reg(0x00DB) 00 00 00 RDID2
reg(0x00DC) 00 00 00 RDID3
reg(0x00EF) 00 00 00 00 00 00 ILI9327
reg(0x00B0) 00 RGB Interface Signal Control
reg(0x00B4) 00 Inversion Control
reg(0x00B6) 00 00 00 00 Display Control
reg(0x00B7) 00 Entry Mode Set
reg(0x00F2) 00 00 33 00 00 00 00 00 00 00 00 00 Adjust Control 2
reg(0x00F6) 00 80 80 Interface Control
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 13, 2016, 01:00 am
Thanks for the feedback.

The readreg has changed slightly.   The rightmost "description" field is nothing more than a hint.

The "operational" registers tend to be the same for the "8-bit parameter" style of controllers.
But the "configuration" registers vary greatly for different models and manufacturers.

e.g. the controller ID register and format varies.
e.g. the "Manufacturer ID" is not always filled in.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: sthiy on Jan 13, 2016, 04:18 am
Hi, thank you for your work with the library, it is really appreciated!

I have a ILI9335, reported ID is 0x9335. I've been have to run "GLUE_Demo_320x240" but screen was inverted (not color wise, but mirrored).

I edited file "MCUFRIEND_kbv.cpp"

in "begin" function, I changed the GS bit for the scan line (at line 1182, for version 2.5 of the files):
this: 0x60, 0xA700,
became : 0x60, 0x2700,

But it didn't work. After some snooping around, I found GS gets changed in setRotation too.

so, I changed the following:
    case 0x9335:  // MOVING THIS A LITTLE LOWER
    case 0x4535:
    case 0x7783:
        val ^= 0x80;            //.kbv ILI9320 has NOT inverted logic on GS (MY)
    case 0x9320:
for
    case 0x4535:
    case 0x7783:
        val ^= 0x80;            //.kbv ILI9320 has NOT inverted logic on GS (MY)
    case 0x9335:   // <<-- THIS IS LINE 280
    case 0x9320:
... so GS won't get XOR'ed and will be set properly.

And it worked!

I've attached my version, search for STHIY for my modifications. Probably you should only keep my setRotation modification.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 13, 2016, 12:31 pm
Thanks for the feedback.    As I do not possess an ILI9335,   I have to rely on users.

Please run the "graphictest_kbv" sketch.   This should demonstrate every method.
The GLUE demos show the typical UTFT operation.   They do not exercise the hardware at all !!

Now that you have corrected the GS behaviour,  all the tests should work except for the "COLOR BAND SCROLL"
The whole screen will scroll when the modern controllers can scroll a variable number of rows.

Yes,   as you have seen,   I manipulate SS, GS, ORG and do not touch I/D or AM.
This makes the setRotation() complicated but means the "normal" operations work efficiently.

I will wait until I hear from you about the "graphictest_kbv" sketch.
Then I can update the "Untested" status.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: tlk888 on Jan 15, 2016, 02:06 am
Thank you all for the work on the library! Library works great!

Please tell me if there any function to enable / disable (on/off) the screen? Ready to listen to any advice and recommendations! I have 3.95 mcufriend shield... Thanks!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: sthiy on Jan 15, 2016, 03:58 am
I ran the graphictest_kbv and it seems to work fine on my ili9335. The benchmark runs in 6.93 seconds (see attached picture).

As you said, "color band scroll" doesn't work.

"Software scroll" scrolls only a rectangle under "Hello world" (again, see picture). Is this normal? If yes, mark it "tested"!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 15, 2016, 08:06 am
Thanks for your report.   Yes,   both JPEGs look correct.     I will update the "tested" list.

The reason for this odd window for "software scroll" is for compatibility. ( if the sketch is running on tiny 128x128 displays with different library)

If you change the #if in the sketch,   you can use a more intuitive demo of the scroll.
But it is out of view on a small screen.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 15, 2016, 08:35 am
Please tell me if there any function to enable / disable (on/off) the screen? Ready to listen to any advice and recommendations! I have 3.95 mcufriend shield... Thanks!
No,   I do not have a method for sending the controller to sleep or on/off.

It is easy to do with "modern" controllers like the ILI9488.    It will make little difference to the power consumption.

Most current goes to the backlight.     There is no way to turn this off without hacking the shield.
You would need to switch the 5V pin.

Most of these shields use the 5V pin from the Arduino to supply the backlight.
They use the 3.3V pin from the Arduino for the controller logic.

Cut the trace between 5V pin and the shield LDO regulator.
Place a 500mA PNP transistor between 5V and LDO.    
Control the transistor with the (unused) A5 pin via a resistor to the base.

UNTESTED.   Do any mods at your own risk.   The backlights take 100mA - 200mA.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: wolfrose on Jan 15, 2016, 04:37 pm
I have mcufriend 2.4" ST7781

I ran you code in the post #1

1st:
I got this error:

graphictest_kbv.ino:19:29: fatal error: Adafruit_TFTLCD.h: No such file or directory
compilation terminated.
Error compiling.

Then, I tried these modifications:



Uncommented:
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

Commented:
//#include <Adafruit_TFTLCD.h>
//Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);


And got this message:
Sketch uses 32,228 bytes (99%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,907 bytes (93%) of dynamic memory, leaving 141 bytes for local variables. Maximum is 2,048 bytes.


Low memory available, stability problems may occur.


And ...



:)

yaayee wow you are a hero

I'm really happy.

That's so nice.

Thank you so much,


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 15, 2016, 08:07 pm
Oops.   It looks as if I put the wrong "graphictest_kbv.ino" sketch into the ZIP.   
I have replaced the ZIP with a corrected version.   And put the "corrected" sketch as a separate attachment.   

I am a little worried by your JPEG.   It is displaying in PORTRAIT_REV mode but the directions are completely wrong.   Arduino v1.6.6 reports for a UNO:
Code: [Select]

Sketch uses 31,508 bytes (97%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,904 bytes (92%) of dynamic memory, leaving 144 bytes for local variables. Maximum is 2,048 bytes.
Low memory available, stability problems may occur.


Yes,  I have tried to squeeze as much as I can into the test sketch.   99.99% Flash is perfectly safe.  92% SRAM should be safe.   You definitely do not want to risk more.

That is the reason for the "graphictest_slim.ino" sketch.
The standard sketch will not fit in a Leonardo or even a Duemilanove.

You can remove Serial, Floating Point,  ... to reduce the Flash memory.
You can reduce the size of the software scroll buffer to reduce the SRAM memory.

Note that the ST7781 is the least powerful controller.    It has a bug in its "vertical scroll" hardware.
That is why the Scroll tests do not operate on your board.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: tlk888 on Jan 15, 2016, 11:07 pm
David, thanks for fast answer and sorry for my bad english. :)

Most current goes to the backlight.     There is no way to turn this off without hacking the shield.
I thought exactly the same, but I'm not versed in microelectronics.

You would need to switch the 5V pin.

Most of these shields use the 5V pin from the Arduino to supply the backlight.
They use the 3.3V pin from the Arduino for the controller logic.

Cut the trace between 5V pin and the shield LDO regulator.
Place a 500mA PNP transistor between 5V and LDO.   
Control the transistor with the (unused) A5 pin via a resistor to the base.
You can look at the attached photo, and tell how and what to do in my case?

I connect this shield to mega2560 with the wires, so I can insert an additional circuit with a transistor before 5V connection.

Which of the inexpensive transistor can you advise?

UNTESTED.   Do any mods at your own risk.   The backlights take 100mA - 200mA.
I completely understand. Thank you very much for your help!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 15, 2016, 11:45 pm
Any PNP transistor with a max collector current of 500mA or so will be fine.

I looked at what transistors I have.    I seem to have several BC212L that are probably 30 yrs old.

Looking up the data.   It is 300mA max.   With a min hFE of 50.   i.e. 4mA base current for 200mA.
So a 1k0 base resistor would switch it on.

If you are buying a new transistor,   look for a 500mA PNP with hFE > 100.    Look for a plastic case like TO92.

You can see the pcb trace that goes from 5V pin to U1.  It looks easy to cut.
You can get at A5 pin by soldering on to the top of the header pin.
Glue the transistor and base resistor to the pcb with some epoxy.

Connect up by soldering some fine wire from A5 to the base resistor.

If you do not understand this,   you should not attempt the mod.
I have not tried it.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: wolfrose on Jan 16, 2016, 07:36 am
Yes, of course I downloaded the new sketch, it works very beautiful.

Now, I want to start learning C++ :)


Regards,
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: tlk888 on Jan 16, 2016, 04:22 pm
Any PNP transistor .....
...

If you do not understand this...
I'm understand and try to mod shield next week! Thanks very much for your advise!

And I think, this instruction may be helpful for others... Thanks!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: wolfrose on Jan 17, 2016, 02:31 pm
What is the basic structures of programming a TFT display?

Such a big program, like this one which exceeds 30kb of flash memory.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 17, 2016, 03:38 pm
The example sketch is at the limit of a UNO's memory.   read message #45.

Regarding program structure,   the other examples are a lot smaller.
There are hundreds of "Adafruit-style" examples.   They should all work with this library.   The only important lines are:

Code: [Select]

#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

uint16_t ID;

void setup(void)
{
    ID = tft.readID();  // you must detect the correct controller
    tft.begin(ID);      // everything will start working
    tft.fillScreen(0x001F);    //BLUE
    tft.print("Hello World");
}

void loop(void)
{
}

This was 10744 bytes (on my current un-released version).   It may be different for you.

The purpose of "example" programs is to show you what you can do.   

You write your own applications.   When you are unsure how to draw a circle or print a message,  you look at the example to see what was done.

It should be possible to fit most regular apps into a UNO.
However you need to be aware that loading big Fonts or bitmaps will use lots of Flash memory.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: suchloop on Jan 20, 2016, 08:37 pm
Hi everyone

I'm trying to make the resistive touchscreen work with the arduino due, but I'm new to this arduino stuff so I'm having a hard time understanding what I need to do or even if its possible...

I have the 3.95'' TFT LCD ili9488 from mcufriend like this one:
http://www.aliexpress.com/item/3-5-inch-TFT-Touch-LCD-Screen-Display-Module-For-Arduino-UNO-R3-HIGH-QUALITY-Free/1854595985.html

I don't have any shield, just the lcd directly plugged into the due...

Anyone knows how to make the touchscreen work with the due?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 20, 2016, 09:53 pm
Your display is a shield.    You plug it directly into your UNO (or DUE).

The regular <TouchScreen.h> or <TouchScreen_due> library do not work with the shared pins.

One day I will write / publish a version that does work with the shield.

Meanwhile,   I suggest that you plug it into a UNO.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: suchloop on Jan 21, 2016, 10:24 am
I thought you called the "shield" those intermediate boards you plug between the display and the arduino... my bad...

Ok thanks, I only have the DUE so I'm gonna have to keep researching... hopefully you'll not keep waiting for too long hehe.

Will you publish the solution here?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 21, 2016, 10:36 am
The board that "plugs into" the Arduino is called a Shield.
The intermediate board is called an "Adapter Shield".   e.g. the ColdTears adapter shield for regular 40-pin TFT displays.

The Mcufriend MEGA2560 display shields have a separate Touch Controller chip and should work fine with UTFT and UTouch libraries.    Unfortunately,  the microSD does not work reliably.

No,  I have no plans for writing a Touch library for the Due.
Meanwhile,  you could buy a Uno clone.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Jan 22, 2016, 11:49 am
Hello, David,
Thanks for your great job!
Only owing to your topic i have started my LCD shield with chip ST7789V.
Finally i got a correct displaying in scketchs:
aspect_kbv
graphictest_kbv
LCD_ID_readreg
readpixel_kbv
scroll_kbv
testcard_kbv

But i still can not use touchscreen:
tftpaint_shield_kbv
TouchScreen_Calibr_kbv
UTouch_Calibr_kbv
are not working.
I suspect, that these sketchs are not optimized for ST7789V.

Could you give me information, where i can get correct library for touchscreen?

Thanks in advance!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 22, 2016, 12:17 pm
I presume that you have a regular 2.4" Red shield or a 2.8" Blue shield.

The Touch is nothing to do with the TFT controller.
It is just a resistive screen that shares some pins with the controller.

Most of these shields use A1, 7 and A2, 6.
Unplug your shield and test the resistance between A1 and 7.  It should be about 300 ohms.

If there is no resistance,   try A1 with other digital pins.  e.g. 6, 7, 8, 9.

When you have identified the actual pins used by the Resistive screen,   you edit the TouchScreen_Calibr_kbv.ino sketch.

Please report back with your results.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Jan 22, 2016, 01:34 pm
... try A1 with other digital pins.  e.g. 6, 7, 8, 9.
When you have identified the actual pins used by the Resistive screen,   you edit the TouchScreen_Calibr_kbv.ino sketch...
Ok. understood.

Do you mean this records:
#define YP A1   
#define YM 7
#define XM A2
#define XP 6
?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 22, 2016, 01:45 pm
Do you have a Red or Blue shield?

Yes,   you should read 300 ohms between YP and YM pins.    It may be 1000 ohms.

If your screen is cracked,   the resistance is broken too !

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Jan 22, 2016, 04:33 pm
I have a red shield.
I've got some reaction from touchscreen in tftpaint_shield_kbv with next pin assignment:

#define YP A1  
#define YM 6
#define XM A2
#define XP 7

Pin A1-6 resistance approx. 300Om,
Pin A2-7 resistance approx. 500Om,

But all movements on display are mirrored to central point of display: when i touch right upper corner of screen, picture appeared in the left bottom corner and so on.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 22, 2016, 04:52 pm
That is fine.    It just means that you adjust everything in software.

If you do the Calibration with the YP, YM XM, XP that you have found,   you will get a perfect result.

Meanwhile,   I suggest that you could just say:
Code: [Select]

#define YP A2 
#define YM 7
#define XM A1
#define XP 6


And I think that you will get everything correct in one go.

I presume you mean Pin A2-7 resistance approx. 500 Ohm.    That is just fine.   It is probably the longer dimension i.e. Y.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Jan 22, 2016, 05:25 pm
Touchscreen more less working correctly now:

"else if (identifier == 0x7789) {
       Serial.println(F("Found ST7789V LCD driver"));
       TS_LEFT = 128; TS_RT = 911; TS_TOP = 942; TS_BOT = 153;
       Landscape = 1;"
and

"#define YP A1  
#define YM 6
#define XM A2
#define XP 7"
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: JMe87 on Jan 22, 2016, 06:23 pm
Hi,

many thanks to david_prentice and to SHTIRLITZ, my ST7789V touchscreen is now working.

Good job !!

Regards from Belgium

Jacques
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 22, 2016, 07:04 pm
I am pleased that both of you have got the Resistive TouchScreens working on your ST7789V shields.

From examples/tftpaint_shield_kbv.ino:
Code: [Select]

// the regular Adafruit "TouchScreen.h" library only works on AVRs

// different mcufriend shields have Touchscreen on different pins
// and rotation.
// Run the UTouch_calibr_kbv sketch for calibration of your shield

...

// These are the pins for some typical shields!
// S6D0154: YP=A1, XM=A2, YM=7, XP=6
// ST7783 : YP=A2, XM=A1, YM=6, XP=7
// ILI9320: YP=A2, XM=A3, YM=8, XP=9
// ILI9325: YP=A1, XM=A2, YM=7, XP=6
// ILI9325BG: YP=A2, XM=A1, YM=6, XP=7
// ILI9341: YP=A2, XM=A1, YM=7, XP=6
// ILI9488: YP=A1, XM=A2, YM=7, XP=6
// R65109V: YP=A2, XM=A1, YM=6, XP=7

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

There are several articles about Touchscreens on Wikipedia etc.

I have tried to offer "advice" about how wiring might differ with these Mcufriend shields.
Most of the current ones use A1, 7, A2, 6.   They may have X, Y swapped.

In fact I only have one shield that uses different pins.   (an old ILI9320 display)
Now you have found a shield with the "normal" pins but connected cross-wise !!

I welcome suggestions for improving the sketch comments or the "readme.txt" file.
Several users seem to have difficulties with setting up the TouchScreen

I hope that the new examples/graphictest_kbv sketch is more "obvious" than previous versions.
e.g. you named colours, named rotations, and see messages move.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Jan 22, 2016, 10:18 pm
David, another step which I want to investigate:
How I can upload bmp files from SD to my screen?

In mcufriend_kbv library I did not found command for this....
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: petergomez on Jan 22, 2016, 11:02 pm
Hey there

best regard

I have a 2.8 TFT LCD screen shield on an Arduino UNO, the screen has a driver (61505V) which the library #include <MCUFRIEND_kbv.h> and tft.begin (0x9320) works well but I get this when I put the screen white with two tables. on the screen a few lines I have not programmed appear. I hope you can help me.

The code used is as follows:

#include <Adafruit_GFX.h>    // Core graphics library
#include <MCUFRIEND_kbv.h>


#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

// Assign human-readable names to some common 16-bit color 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


MCUFRIEND_kbv tft;    // Shield has hard-wired pins

int variable = 0 ;

void setup(void) {
 tft.begin(0x9320); // inicializacion de la pantalla con el driver

}

void loop(void) {

 tft.fillScreen(WHITE);

 tft.fillRect(0,0,240,160, 0xFFF);
 tft.fillRect(0,161,240,160,WHITE);

 tft.fillRect(100,50,50,50,RED);

 while (variable == 0) {
 }

}

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 22, 2016, 11:04 pm
I do not intend to have a library method() for reading BMP.   It is better to do this in a separate application.

Look at the Adafruit examples.    i.e. read data from the BMP,   convert with color565(),  write to TFT with pushColors()


Personally,   I find that <SD.h> works with any microSD that I have.    <sdFAT.h> gives lots of problems.

That is why I have not packaged a readBMP_kbv sketch.    I have one that renders 24bit, 16bit, 8bit, 1bit BMP files.    It is not very fast on an AVR.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 22, 2016, 11:11 pm
I have added support for a R61505V controller.    It will be in the next release (v2.6)

I do not have a R61505V controller.   Some months ago,   I was told that the ILI9320 code works with it.
Now that I have added specific code my new "R61505V tester" says that 0x9320 gives a bad picture.
The new code works fine.

PM me with your Email if you want a pre-release 2.6.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: sblanc on Jan 23, 2016, 04:15 pm
Hi all,


To have GLUE test running with ST7789V I have to modify the utftglue.h file.

if the void InitLCD(byte orientation=LANDSCAPE) method the test:

if ((ID & 0xFF) == 0x0089) ID = 0x1289; makes change the controle ID from 7789 to 1289.


Just comment the line to have UTFTGLUE object working well with ST7789V.


Regards
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 23, 2016, 04:57 pm
Thanks for this.   Yes,  it is wise to comment out that line.   A better solution might be:
Code: [Select]

uint16_t ID = MCUFRIEND_kbv::readID();
if (ID == 0) ID = 0x9341;        //DealExtreme with EXTC=0
// if (ID == 0x0089 || ID == 0x8989) ID = 0x1289;
if (ID == 0x00D3) ID = 0x9481;   //write-only controller
// if (ID == 0x00D3) ID = 0x9486;   //write-only controller
//         if (ID == 0x9327 && orientation == LANDSCAPE) orientation = 3;


UNO Shield owners will never normally see these IDs.    You get them from a write-only display.

Incidentally,   the GLUE programs do not always seem to work with a DUE and v1.6.6 of the IDE. 
However,  GLUE_Demo_480x320 worked on v1.6.6 and v1.7.8 just now !!

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: JMe87 on Jan 23, 2016, 06:32 pm
Hi David,

i try your modif but :

in : GLUE_Demo_320x240.ino
line 48 : extern uint8_t SmallFont[];

error : expected constructor, destructor, or type conversion before 'extern'

i used : SmallFont.c 6942bytes i found here : http://www.rinkydinkelectronics.com/r_fonts.php (http://www.rinkydinkelectronics.com/r_fonts.php)

i placed this font file in the same dir as GLUE_Demo_320x240.ino

Jacques
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 23, 2016, 07:13 pm
It really does not matter what you use.   It is a dummy that does not do anything.

The UTFTGLUE class simply complies with what a genuine UTFT class would expect.   e.g. a constructor like
Code: [Select]
UTFT(byte model, int RS, int WR,int CS, int RST, int RD)

Since the MCUFRIEND_kbv class ignores any arguments in its constructor,   you could write anything you like.

and a method like setFont()
Code: [Select]
void setFont(uint8_t* font) { MCUFRIEND_kbv::setTextSize(1);}
As you can see,  it does nothing more than reset the "Adafruit-Style" textsize to its default value.
It ignores the font argument completely.

The legacy Adafruit-Style GFX does not handle fonts at all.   It just has one 7x5 system that it can render in different (blocky) sizes.   i.e. via setTextSize()

Since I can build and run the GLUE_480x320 sketch without any errors,   the Compiler must be finding something called "SmallFont" or simply realising it is redundant argument and is optimised away.

Incidentally,   the new "Adafruit_GFX" library can handle fonts.    So you could modify the setFont() method to use the new Adafruit fonts.

The GLUE class is provided as a convenience.   It allows you to run many UTFT sketches with trivial modification.   e.g.
#include <UTFTGLUE.h>
UTFTGLUE myGLCD(0x1234 /*ITDB32WD*/ ,38,39,40,41);


If your compiler is unhappy,  just add your own dummy SmallFont e.g.
Code: [Select]
uint8_t SmallFont[1];

If you are having problems with Compiler or IDE version,   please say which IDE, Arduino, operating system,  ... you are using.

I currently use the IDE v1.6.6 which has definitely got some issues that are different to previous v1.5.x or v1.6.x versions.    Note that the v1.7.x IDE is best avoided but will probably work ok for some targets.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: mr_oldman on Jan 23, 2016, 09:36 pm
Thank you so much David !
I had the same issues like other customer (only a white screen),
as I tried to get a screen on my  2.8" TFT LCD Touch Shield UNO ILI9341.
I tried so many librarys, but I got only results like ' unknown lcd driver chip: 4141'.
Now it works on my MEGA 2560 board, without a change in the settings.
Great job !
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: sblanc on Jan 23, 2016, 09:46 pm
Hi again

I have done a lot of test today with the 2.4 touch lcd from MCUFriend with ST7789V.

What I have observed using ToucheScreen.h is that the Delta of the 2 axis are diferents. each set of test show that Delta min,max for A2A7 is bigger than delta A1A6

It should match the edge size of the screen.

according to this remarks, I take the LCD in portait with connector as bottom I setup the library as
//ST7789 portrait:
uint8_t YP = A2; uint8_t XM = A1; uint8_t YM = 7; uint8_t XP = 6;

the top left corner is around (300,190) and bottom right is around (550,650).
DeltaX 250
DeltaY 450

X axis is from left to right
Y axis is from Top to bottom

Steph
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 23, 2016, 11:04 pm
I do not have your Shield.   I do not have an ST7789V controller.

Your values sound unlikely.   SHTIRLITZ has a Red shield and measured 300R between A1, 6 and 500R between A2 , 7
Code: [Select]

      TS_LEFT = 128; TS_RT = 911; TS_TOP = 942; TS_BOT = 153;
       Landscape = 1;

Since it appears that A2, 7 are the Y connections,  and A1, 6 are the X connections.   (i.e. PORTRAIT)
I would expect something like:
Code: [Select]

      TS_LEFT = 153; TS_RT = 942; TS_TOP = 128; TS_BOT = 911;
       Landscape = 0;

i.e. more respectable deltaX, deltaY values than you have got.

Note that the Calibration times out pretty quickly.   If you do not press the cross-hairs when they are highlighted,   it goes on to the next one.

I think that I show the Touchscreen values at the start of the Paint sketch.    I really would expect a range from 150 to 900 for each axis.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: sblanc on Jan 24, 2016, 12:37 pm
Hi,

I just run the TouchScreen_Calibr_kbv.
With
  #define YP A1 
  #define YM 6
  #define XM A2
  #define XP 7

I get in return:

LEFT 187  RT    291     0.43
TOP  938  BOT  175     -2,38

touch pin Wiring is swapXY

With
#define YP A2
    #define YM 7
    #define XM A1
    #define XP 6

I get in return
LEFT 922  RT    816     -0.44
TOP  153  BOT  907     2,36

touch pin Wiring is PORTAIT

I also measure A1A6 330Ohm
                     A2A7 650Ohm
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 24, 2016, 12:53 pm
Your LEFT-RT values look wrong to me.   I would expect 922 and 150.

You do not say which shield or controller you are using.

Have you measured the resistance between different pins ?
660R sounds like two 330R in series.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Jan 24, 2016, 01:10 pm
I get in return:
LEFT 187  RT    291     0.43
TOP  938  BOT  175     -2,38
Hello, i also launch TouchScreen_Calibr_kbv and my result is:
LEFT 480 RT   524   0.18
TOP  771 BOT 616  -0/48
Portrait mode.

LEFT 256 RT   892   0.18
TOP  885 BOT 211  -0/48
SWAPXY mode.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 24, 2016, 01:58 pm
It looks like a problem.    I will have a think about it.

Meanwhile,  I suggest that you just use nominal values for LEFT and RT in the Paint sketch.

What values for LEFT and RT do you see when running the Paint program?


Note that I do not have a ST7789V display.   I am surprised by the "crossed" wiring but this should make no difference to the Adafruit TouchScreen library.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: sblanc on Jan 24, 2016, 02:21 pm
My shied is a MCUFriend 2.4 from china, controller is ST7789V. It looks like SHTIRLITZ's one. but value range seem to be different!

I'm recharging my multi meter batterie and i'll measure again the resistance.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: petergomez on Jan 24, 2016, 02:57 pm
Good morning
The library me it worked very well, the display is corrected, thank you very much for your help.
You have the library of tocuhscreem, I get an error TSpoint p undeclared scope. I am new to this and my English is not very good.
I have a question what is the difference between libraries and UTFTGUE adafruit_GFX?
Thank you so much for help me.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: sblanc on Jan 24, 2016, 03:08 pm
I have done some new test with ST7789V hardware.

I have change the Touchscreen.cpp to remove oversampling.

I have done 4 average of 300 samples (TL,TR,BL,BR). What I get is

    X     Y
TL 544  201
BL 381  676
TR 487  208
BR 356  661

We can see there that Y is consistant from R to L for low and high value delta around 10.
It is not the case for X there is large delta around 140.

X seems to not be linear.

I have measure A1A6 and get 2K2 Ohm
          measure A2A7 and get 580 Ohm

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: sblanc on Jan 24, 2016, 05:23 pm
Here is what I get while reading analogic value.

As you can see it is not linear at all, so difficult to manage correctly the X on this screen. I hope it is only my sample and not all the screens.





Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 24, 2016, 07:14 pm
I have no idea what your PNG is supposed to show.

Personally,   I have always used a very simple "Touchscreen_due" branch of the Adafruit library on Github.

I have just installed the latest version of the "Touch-Screen-Library-Master" from GitHub.

Sure enough,  it is pretty flaky in the Calibration sketch.   I suggest that you will get a more reliable response by altering "TouchScreen.h"
Code: [Select]
#define NUMSAMPLES 3

You may find that 4 or 5 is better.

I thought that I had included a new "Touch_shield_kbv" sketch in the v2.5 ZIP or perhaps I had attached it to another post.     You can see what your Touch is reporting.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Jan 31, 2016, 07:26 am
I just ordered a 3.6" MCUFRIEND LCD and an Uno clone.  I'd really prefer to run the screen on a Due (or at least a Mega) as the Uno has SO little memory.

They are probably 3 or 4 weeks away (coming from China to Western Australia) but I am looking forward to joining this thread.

Well, to be honest, I would prefer to download all the necessary libraries etc and not need to resort to this thread (hoping it all works) but I expect it won't all work. I'll keep an eye on this thread till then.

I have 3 BangGood 3.2" screens which don't have touch screens which I have been playing with.

I want to implement a digital clock so the touch screen will allow setting of the alarms etc.  My particular screen will NOT have an SD so I will attach and external SD reader.

I am prepared to bend pins to connect hardware SPI but not happy with cutting traces and delicate soldering etc  :(

Please keep this thread going   :D

Thanks to david_prentice for all your hard work....   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 31, 2016, 07:59 am
The yellow or blue style of Uno clone have A6, A7 and extra holes for header strip.
Attach right-angle headers,   and you can connect to the (scarce) unused pins with a shield mounted.

The Uno style shields can fit on a Mega or Due.     They will work but obviously slower than a Uno due to the PORT bit mangling for D2-D9 pins.

You can also use these Uno shields on NUCLEO or FRDM boards.    More Flash and powerful ARM processors.   

David.
 
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Jan 31, 2016, 10:25 am
My Uno clone has the extra holes for more headers but no A6 and A7. 

Wow, entered this message on my iPad and lost 80% of the message I typed! I don't think it liked the iPad smileys!????

I thought the Mega and Uno were compatible with the lower end pins!?  I know SPI is different.  :)

On another thread my Dues were still faster than my Mega even with soft SPI!

Not challenging, just asking. :)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 31, 2016, 11:23 am
As you know,  digital#2 is PD2 on a Uno,  PE4 on a Mega, PD1 on a Leonardo, PB25 on a Due, ...

I am expecting you to plug a shield into a standard Arduino.   So the shield's LCD_D2 mates with digital#2 on all Arduinos.

You can NOT change the data bus pins or the control pins.    MCUFRIEND_kbv uses the Shield pins and ignores any arguments in the constructor.

You just plug the shield into the Arduino,  build, upload and go.

If you want to use the microSD on a Mega or Due,  you have to use softSPI.   e.g. from the <SdFat.h> library

SdFat.h is a nightmare.   Which is why I have deliberately not included SD examples.

Of course,   SD examples work fine on a Uno with the hardware SPI.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Jan 31, 2016, 01:45 pm
As you know,  digital#2 is PD2 on a Uno,  PE4 on a Mega, PD1 on a Leonardo, PB25 on a Due, ...

<<<<snip>>>>

If you want to use the microSD on a Mega or Due,  you have to use softSPI.   e.g. from the <SdFat.h> library

SdFat.h is a nightmare.   Which is why I have deliberately not included SD examples.

David.
Sorry, I don't know ANYTHING about the control pins. I'm too afraid to even look   :(

Maybe ONE DAY, when I summon up the nerve. Hence I have to rely on others to write libraries.  Once someone else had "hit" the hardware I can "glue" the methods I need.

I have 12 Nanos, an Uno, a Mega and 2 Dues.  Until a couple of months ago I did EVERYTHING on my Nanos. Went from 0.9" screen to a 2.2" screen to 2 X2.4" to a 2.8" to 4X3.2"s and now to 3.6. I've used, and picked up methods, from U8glib to ILI9340 to ILI9341 to ILI9341_due to UTFT to my heavily modified UTFT library to Bodmer's HX8357 2 ILI9481 libraries.  Then I changed to my Dues along the way then went back to my Mega (to play with). The Nanos (and the Uno) are now neglected....   :(

I'd buy 5 more Dues tomorrow except I'm looking for the R3-E versions that are as rare as "hen's teeth".

I agree, SdFat IS a nightmare. But I want to use my Dues so I have to use Soft SPI so I have to use SdFat   :(

I have an SD SlideShow sketch that took DAYS of hard slog to convert from SD.h to SdFat.h. I abandoned 2 attempts before I eventually succeeded in the conversion.

I want to make clocks for my grand kids with changing "photo" backgrounds, birthday messages, holidays etc. One picture is 307Kb of PROGMEM, ONLY possible on a Due....   ;)

A sketch with a "screen" library, an SD library, an RTC library and a touch screen
library won't fit on a UNO   :(    :(    :(    :(

Thanks again for your library, I look forward to using it   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 31, 2016, 02:43 pm
The beauty of the Arduino is that you plug in a shield and go.

A library can look after the hardware happy in the knowledge that the user has not made any wiring mistakes.
The user can write simple sketches that just work.   If she has a problem,   she can post on this forum and get answers from people from the opposite side of the world.    Until today,   I did not realise that you are in Oz.

Yes,   there are some limits to compatibility over the Arduino range.    e.g. a shield designed for a Uno may expect SPI on 10, 11,12, 13.    A shield with SPI on the 3x2 ISP header will work on an Arduino but not on a NUCLEO.    So the cheap Mcufriend Uno shields need a Mega,  Leonardo,  Due to bit-bash SPI on 11, 12, 13.

I am not even going to think about a Nano or Pro Mini.    Users are hell bent on unconventional wiring.      It would be a nightmare to support them.     Mind you,   the 3.3V Pro Minis are ideal for using 3.3V sensors and displays.

You have been using purpose built Mega display shields.    And seen just how well Rowboteer's libraries can perform.     And you never needed to worry which pin was used for CS or WR or even which pins are used for the data bus.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Jan 31, 2016, 04:44 pm
A quick question?

Can someone not bend pins 10, 11, 12 & 13 and connect them to 53, 51, 50 & 52 on a Mega with Dupont wires? I don't know if it is a straight translation but MISO to MISO, SCK to SCK, MOSI to MOSI and SS to SS and avoid bit bashing? Same with the Due and the SPI header?

I suspect this will only effect the touch screen?  That would only leave D0 to D7 and a few power connections. The 3.6" I ordered doesn't have an SD card  so wouldn't need to be considered  :(

I downloaded your library off the second link. Is that the most current?  Is it on Github?

Did you know you can buy an adaptor you can mount a Nano on so the adaptor behaves like a Uno!?   :)  I have one in front of me....   :D

Thank you for your library, I will have a peek at it tomorrow. It is almost midnight so

Thank you and goodnight   :D

PS another question....    There is an RD connection?  Does that mean you can do a readPixel and hardware scrolling?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jan 31, 2016, 05:16 pm
I made an Adapter shield that receives Uno shields and sits on a Mega routing the data bus to PORTA and SPI bus to 50-53

I made an Adapter shield that receives Uno shields and sits on a Due routing the data bus to PD0-PD7 and SPI bus to PA25-PA27

This means that the 8-bit data bus runs at full speed on both Mega and Due.   Likewise the SPI bus.
They are both regular ProtoShields with kynar wire soldered connections.

I have no idea what 3.6" display that you have ordered.   All mcufriend-style shields have microSD sockets.    It is just a pity that the Mega version microSD does not work.   The Uno style shields work fine.

Yes,  a Uno shield adapter for a Nano sounds a good idea.   Mind you,   most Nano owners are too tight to buy one.

I would not be happy with bending shield pins.    If you want to re-route stuff,  make an adapter shield sandwich.   In terms of work,   a home-made shield takes quite some time.    Buying a $10 NUCLEO seems a lot easier.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Jan 31, 2016, 11:55 pm
SORRY David!

I'm blind as a bat! It HAS an SD card! This is IT....

http://www.ebay.com.au/itm/141656670946?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

Now you'll have to pardon me while I feel around for my white stick   :D

Wow! Just like that you made TWO shields!!!!  I have been THINKING of making a shield for my 2.8" for weeks!!!!!  And YOU made TWO overnight!   :D

I've never even heard of a NUCLEO  :(  But I will have a look for it on eBay....

It is only about 20 pins?  Couldn't I just wire it up (temporarily?) with Dupont wires?  Sorry, what do you mean PD0-PD7? And are PD25-PD27 the SPI header in the centre?  Could you please list which pin to which pin as per numbers (names?) on the Due and the shield?   NEWBIE alert!

Thanks again  :D

ONLY 2 listings on eBay.  Will the LCD plug straight into the NUCLEO and everything run at full speed?  Oops, lots more listings at the end of the search....  :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 01, 2016, 12:23 am
You can buy Mega Protoshields on Ebay.   My first one was a plain pcb.   Nowadays they come with headers mounted.

I snipped off the male pins that I was re-routing e.g. 11, 12, 13.   And soldered kynar wires to 50, 51, 52.
Likewise with the data bus pins on 2-9.

I made both "adapter shields" some months ago.    Although it is simple soldered wiring,   the whole job is a little fiddly.   It is far preferable to buy a ready-made pcb adapter like ColdTears.

Your selected Ebay shield is an example of mendacious advertising.

It shows a photo of a 400x240 ILI9327 shield mixed with photos of a 480x320 ILI9488 shield.
It carefully omits a photo of the pcb.   It quotes initialisation code for a ILI9327 with text saying "ILI9488".

With luck,  it has an ILI9486 or ILI9488.

Until the display arrives on your desk,  you just have to keep your fingers crossed.   At least my library can identify the controller.    UTFT users can only do guesswork.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Feb 01, 2016, 01:00 am
Thanks for your quick reply.

Happily I have no problems ordering anything. My problem is the 5 week (if I'm lucky) wait between ordering and receiving   :(

I have a Mega Protoshield on hand   :)  But I have at least another 3 week wait for the screen  :(  Will the Mega protoshield work on the Due?

I'm interested making the Due adaptor shield for this display NOW.  I MAY eventually make Mega ones for my clocks.

Simple list of connections please. Like....

Shield     Due
   10        4
   11        4 in SPI hddr
   12        1 in SPI hddr
   13        3 in SPI hddr
     2        ?
     3        ?
   etc       etc

TIA   :D

I thought all adapters were 40 pin ones?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Feb 01, 2016, 07:22 am
Hello, David.
I was faced with one problem.
I have tried to build Clock on RTC module, and to make indication in 3.2"LCD. In setup display working correctly, but in loop my dispaly loose connection (white screen).
The same RTC scetch working good with 128x64 dispaly (on u8glib).
It seems that LCD loose identification when call a internal function getDateDs1307 or get3231Temp(). However these functions returns to serial correct values, so i suppose that root cause in LCD library....

void loop(){
 byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
 //char week[8][10] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
 
  char timenow[10];
  char data[11];
 
  snprintf(timenow, sizeof(timenow),"%02d:%02d:%02d",hour, minute, second);
  snprintf(data, sizeof(data),"%02d/%02d/%02d", dayOfMonth, month, year);
 
 
  //Serial.println(timenow);
  //Serial.println(data);
  //Serial.println(get3231Temp());
  //Serial.print("C");

tft.setCursor(125, 50);
tft.print(timenow);
tft.print(data);
tft.fillScreen(0x001F);
tft.print(get3231Temp());
tft.print("C");
tft.fillScreen(0x0000);
 delay(1000);
}

What do you think, where can be conflict and how it can be fixed??
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 01, 2016, 08:14 am
As far as I know,  you have a red ST7789V display shield with a Uno.

The DS3231 is an I2C device.    So it will use A4, A5 pins for I2C.    The A4 pin is used by LCD_RST.

You will need to use different pins.   The program would look nicer if you overwrite the text rather than clearing the whole display.   (Which will flash screen)

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Feb 01, 2016, 11:34 am
David, thanks.

You are right, the wire.h library and LCD use the A4 pin in the in the same time.
But i have no idea, how i can reassign the A4 for I2C bus in UNO.

May it is possible somehow reassign A4 pin in the Mcufriend_kbv library?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 01, 2016, 11:43 am
You can snip off the A4 pin from your display shield.   Your I2C bus will work ok now..

My library should reset the controller in software.   So you do not need the LCD_RST pin at all for your ST7789V, ILI9341, ILI9488, ...

Note that users with the older style controllers like ST7781, ILI9325, ... do need the LCD_RST pin.    They should not snip off their LCD_RST pin.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Feb 01, 2016, 04:25 pm
You can snip off the A4 pin from your display shield...   
I have deleted A4 pin form LCD shield.
No visible changes - display anyway have conflict with I2C bus....:)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 01, 2016, 04:36 pm
The display should work perfectly.   Even without the LCD_RST pin.

Please run all the examples.   Report back with any problems with the examples.

I have a DS3231 module.   I can try it for myself.

David. 
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Feb 01, 2016, 06:03 pm
David,
I have checked examples from Mcufriend_kbv - all sketches are not working or working unstable without pin A4. After restoring pin A4 on the shield, LCD became operational like was before pin removing....
May be make sense remove pin and connect contact to GND or +3,3V?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Rigolo on Feb 01, 2016, 06:11 pm
Is somebody here has already worked well the SD card read on a mcufriend 3.5' screen?
  ::) the 3,5 for uno or the 3,5 for mega?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 01, 2016, 08:02 pm
David,
I have checked examples from Mcufriend_kbv - all sketches are not working or working unstable without pin A4. After restoring pin A4 on the shield, LCD became operational like was before pin removing....
May be make sense remove pin and connect contact to GND or +3,3V?
If example sketches did not work at all:   LCD_RST pin is low.   the controller is always in Reset.
If example sketches worked but unreliably:   LCD_RST pin is floating.   the controller occasionally resets.

Connect a 10k pull-up between LCD_RST and 3.3V.    This will keep the LCD_RST pin high.

If you want to use I2C, TFT, Touch, microSD and Serial port,  this would be your only solution.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 01, 2016, 08:05 pm
Is somebody here has already worked well the SD card read on a mcufriend 3.5' screen?
  ::) the 3,5 for uno or the 3,5 for mega?
Yes,  I have said MANY times.   The microSD on a 3.5" Uno Shield works fine.
The microSD on a 3.5" Mega Shield is unreliable.    (I do not support the 16-bit Mega shields)

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Feb 01, 2016, 09:25 pm
David, with resistor 10K between LCD_RST and 3,3V all working perfect!!
Many thanks!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 01, 2016, 10:31 pm
According to your profile,   your local time is 22.24.    So I guess that you are in central Europe.

Your RTC is displaying the wrong time !    And it is a lot warmer where you are.

It looks a pretty simple job to modify the shield.    This should be useful to many other users.    

You could have multiple I2C devices on the same bus.   And log readings to the microSD.    If you have a SMD mega328P,  you can read analog sensors on A6, A7.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Rigolo on Feb 02, 2016, 06:06 pm
Yes,  I have said MANY times.   The microSD on a 3.5" Uno Shield works fine.
The microSD on a 3.5" Mega Shield is unreliable.    (I do not support the 16-bit Mega shields)

David.
I never succeed to work the 16 bit with a mega. It should be better they test their products before sell.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Feb 04, 2016, 12:11 am
Hi David  :)

I have one of these and 3 more coming (on a slow boat from China....)

http://www.ebay.com.au/itm/371544614384?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

I have bid on another Mega and will order another Due. Could you please list the (cross) connections I have to make to make both run as fast as possible.

I WILL have a DS3231 connected too.

Thanks in anticipation.  :)

Thanks for your library....
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: b3n90 on Feb 10, 2016, 04:21 pm
Hi, i have executed LCD_ID_readreg.

I get it :

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) 00 00   ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 04 04 04 04   Manufacturer ID
reg(0x0009) 09 09 09 09 09   Status Register
reg(0x00BF) BF BF BF BF BF BF   ILI9481, HX8357-B
reg(0x00D0) D0 D0   Power Control
reg(0x00D2) D2 D2 D2   NVM Read
reg(0x00D3) D3 D3 D3 D3   ILI9341, ILI9488
reg(0x00DA) DA DA DA   RDID1
reg(0x00DB) DB DB DB   RDID2
reg(0x00DC) DC DC DC   RDID3
reg(0x00EF) EF EF EF EF EF EF   ILI9327
reg(0x00B0) B0   RGB Interface Signal Control
reg(0x00B4) B4   Inversion Control
reg(0x00B6) B6 B6 B6 B6   Display Control
reg(0x00B7) B7   Entry Mode Set
reg(0x00F2) F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2   Adjust Control 2
reg(0x00F6) F6 F6 F6   Interface Control

Thank you.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 10, 2016, 04:29 pm
Plug the Shield into the UNO.   Then run the sketch again.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 11, 2016, 12:04 pm
Plug the Shield into a UNO, MEGA2560, Leonardo, ...
It makes no difference if you run the LCD_ID_readreg sketch on a UNO, MEGA2560, Leonardo, ...

Your report shows that there is nothing being read from the controller.  
I suggest that you plug the Shield into a regular Uno.

If you get a good result,  your MEGA2560 is broken.    I suggest that you check the 3.3V pin with a multimeter.
If you get the same result,  your shield is broken.

I have attached an updated LCD_ID_readreg.ino to library download message (http://forum.arduino.cc/index.php?topic=366304.msg2524865#msg2524865)
There are some added tests for a HX8347-A controller.    Otherwise,   there is nothing new.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Uwe307 on Feb 14, 2016, 02:01 pm
Hi,

strange things happened to me. I have 2 UNO R3 clones from saintsmart and such a cheap 2,4" display from MCU friend. This shield has no reset button.

What I made:
I tested my UNO and it worked fine. Then I hooked up the TFT-shield and loaded up the sketch "graphictest_kbv"... it worked fine... but after this try my UNO doesn't work anymore. If I try to upload something it shows everytime:
"Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x01
avrdude: stk500_recv(): programmer is not responding..."

Then I tried the second UNO... and it's the same! After running flawlessly the graphictest, it shows the same error!

What did I wrong? Can someone help me to get the UNOs alive?

Thank you very much in advance

Uwe
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 14, 2016, 02:21 pm
You should never hook up a shield.    You should plug it securely into your Uno.

The Uno bootloader uses 115200 baud.   It does not use or need any of the pins that are used by the display shield.

The Arduino Upload wiggles the Reset pin to start the bootloader.    Or you can just Start a Serial Terminal.   This will wiggle the reset pin too.

Most Uno clones are well made.    I do not know about Sainsmart.
Likewise,   the 2.4"display shields work fine.    You do not say where you bought your shield.   It is always worth providing a link to the actual sale item.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Uwe307 on Feb 14, 2016, 02:52 pm
Hi David,

thank you very much for your quick answer!

Yes, I plugged the shield into the UNO. I wasn't aware that there is a difference between "hook up" and "plug in". Sorry.

I bought my UNO here:
http://www.ebay.de/itm/252104234854?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
And the TFT-shield here:
http://www.ebay.de/itm/262096229022?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

And both UNOs worked fine before playing around with graphictest_kbv. This sketch was running fine, too.

And after I recognized the problem, I tested the UNOs alone (withot the TFT shield connected). I only wanted to load up the little blink sketch.

Thank you, for telling me the UNO bootloader baudrate. I changed the setting to see more info about my problem. As you can see down here, the baudrate is correct. Maybe you can see more?

Is it possible to destroy the bootloader with uploading a sketch?
Or could it be that some settings have been changed by the sketch?

Uwe 

Here my troubleshooting report:

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM7
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xec
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xec
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 14, 2016, 04:28 pm
Well,  I enabled verbose Upload in Preferences:
Code: [Select]

C:\Program Files (x86)\Arduino-1.6.6\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino-1.6.6\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM11 -b115200 -D -Uflash:w:C:\Users\David Prentice\Documents\Atmel Studio\6.2\ZERO/graphictest_kbv.ino.hex:i

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino-1.6.6\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM11
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 3
         Firmware Version: 4.4
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e950f
avrdude: reading input file "C:\Users\David Prentice\Documents\Atmel Studio\6.2\ZERO/graphictest_kbv.ino.hex"
avrdude: writing flash (31948 bytes):

Writing | ################################################## | 100% 11.96s

avrdude: 31948 bytes of flash written
avrdude: verifying flash memory against C:\Users\David Prentice\Documents\Atmel Studio\6.2\ZERO/graphictest_kbv.ino.hex:
avrdude: load data flash data from input file C:\Users\David Prentice\Documents\Atmel Studio\6.2\ZERO/graphictest_kbv.ino.hex:
avrdude: input file C:\Users\David Prentice\Documents\Atmel Studio\6.2\ZERO/graphictest_kbv.ino.hex contains 31948 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 10.71s

avrdude: verifying ...
avrdude: 31948 bytes of flash verified

avrdude done.  Thank you.


It looks as if my output is similar to yours.   Except that mine succeeds and yours fails.

I even tried an identical blue clone to your one.   It has a regular bootloader and correct lockbits.

I can see no reason for your board failing to Upload.    There is no possibility of corrupting the Bootloader if it is installed correctly.    The IDE sets the lockbits to protect the bootloader.   The IDE checks your sketch size before it even tries to Upload.

I presume that you have restarted your IDE.    And even restarted Windows.

My only suggestion is that you re-burn the Bootloader via the IDE Tools->Burn Bootloader
Of course this requires an external programmer of some kind.    Although my blue clone has correct lockbits,   it is always possible that your one does not.    I am using v1.6.6 of the IDE.

David.

Edit.   I was being "pedantic" about the "hooking up" or "plugging in".   Believe it or not,  but there are punters who connect a shield with 28 separate flying leads.    This is unwise (tm).
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Uwe307 on Feb 14, 2016, 04:44 pm
Hi David,

again, thank you very much for your awesome service!
 
No, I didn`t reburn the bootloader. And yes, I restarted my PC without seeing a success. I even updatet from 1.6 to 1.67. I think I have to buy some original UNOs...

Uwe
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 14, 2016, 04:55 pm
The clones should give you fine service.   All the same,   it is worth checking that all the components are assembled.    e.g. carefully compare your boards with the Ebay photos.    The Quality Control is not as good a genuine Arduinos

Quite honestly,   there is NO way that you can corrupt a Bootloader via the Arduino IDE if it has the correct lockbits.

However,  if you ever upload via ISP,   you destroy the Bootloader and destroy the lockbits.
My advice is:   use ISP once to "Burn the Bootloader" then dig a deep hole and bury the ISP programmer.

If you do not own an ISP programmer or another Uno,   I am sure that a friend can "Burn the Bootloader" for you.    (do not bury your friend's programmer)

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Uwe307 on Feb 17, 2016, 12:28 pm
Hi,

as I assumed, the bootloaders of these two arduinos were wrong and they were destroyed by a large sketch. I built an ISP-programmer and flashed the boatloaders with the Arduino IDE... and now it works flawlessly without any problems.

Now I have to work out, if I have enough memory and enough free ports for my project: I want do build a RF-Generator with an AD9851...

Uwe
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 17, 2016, 01:41 pm
If you always burn the Bootloader via the IDE you will never go wrong.

Even if the lockbits had not been set,   the IDE Sketch Upload checks the Flash size first.

Third Party programs that just blindly use avrdude can corrupt the Bootloader.    You might get your "big" program into flash once but the bootloader will never work again.

The whole Arduino Bootloader arrangement is pretty foolproof.    It is when you try to "do things by hand" that mistakes happen.

I deliberately squeeze as much into the "graphictest_kbv.ino" sketch as I possibly can fit in a Uno.    If you use a Duemilanove or Leonardo,   you need to use the "graphictest_slim.ino" version.   

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Feb 19, 2016, 03:19 am
I've ordered a couple of these....

http://www.aliexpress.com/item/3-5-inch-TFT-Touch-LCD-Screen-Display-Module-For-Arduino-UNO-R3-HIGH-QUALITY-Free/1854630609.html

The link is misleading, the description reads

LCD Display Module TFT 3.95 inch TFT LCD screen for Arduino UNO R3 Board and the Mega 2560 R3

As you can see, it claims that it works on the Uno AND the Mega....

Does anyone know if it will work optimally on the Mega out of the box?

It has been 12 days and the item is STILL "Awaiting Shipment" so God alone knows when (if) I will receive them!?

I am also waiting for one of these....

http://www.ebay.com.au/itm/141656670946?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

This claims to work on the Uno only. Does anybody else know if this will also work (optimally) on a Mega (out of the box)?

Time goes so slowly when you are waiting..... waiting..... waiting..... waiting.....  :(
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zoomx on Feb 19, 2016, 08:21 am
Sometimes the claims are only claims. I got an SPI where the claim was that it was able to work at 5V levels but it doesn't work. It works well at 3.3V.

Sometimes the photo is wrong.

Don't worry about the delay on shipment, usually is written also the time that they have until they get a dispute

About the eBay item. The code published doesn't work alone, need more. But the pins are usually the same as the Aliexpress one.

And yes, we have to wait, wait, wait........
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 19, 2016, 10:32 am
Your first link shows a Uno-style shield that will have an ILI9488 controller.

Your second link shows what "looks like" a Uno shield.    Every other part of the link is mendacious from photos, text, code snippets, ...

When the goods arrive,   I would be 100% confident about (1) and 95% confident about (2) that they will work out of the box with MCUFRIEND_kbv library.

There is a similar mendacious "sale description" on Ebay.    Punters are entering a lottery.    It would be interesting to hear what you actually receive.     MCUFRIEND_kbv will tell you exactly which controller you have.

The differences between Uno, Mega, Due shields are pretty obvious.

1.   they all have Analog# 0-5 and Digital# 0-13 pins.
2.   they all use different pins for SPI.
3.   if your shield can connect to the 3x2 ICSP header,   you can get the hardware SPI of each board.
4.   you can bit-bash the functionality of most pins but the performance suffers.

5.   the Mega and Due have extra Analog pins,   extra comms / digital pins.
6.   the Mega was carefully designed to prevent you using USART_MSPI.

7.   a shield designed for the Uno will fit on all Arduinos.
8.   a shield designed for the Mega has got extra pins for the extra headers
9.   most importantly,   the Mega and Due double-row header is pretty incompatible with anything.
10.  you can bit-bash the Mega/Due incompatibilities but it is painful.

11.  As with anything "Arduino",  you need to check for 3.3V / 5V tolerance.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: jasperachtbaan on Feb 20, 2016, 12:31 pm
Hi,

Great library, thanks! Works a little slow on my due, but that's not so bad. Thanks anyway!

Jasper
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 20, 2016, 01:38 pm
You have chosen to run a Uno shield on a Due.    Every bit on the data bus has to be mapped separately to the particular Due Port bit.    This is what slows things down.

Your 84MHz Due will be a bit faster than a 16MHz Uno.

If you hand-wire a protoshield to map the display data bus to consecutive bits on a single Due Port,   you would see a dramatic increase of speed.

As far as I know,   there are no display shields that are specifically designed for the weird Due pin mapping.    Your only practical  choice is a 40-pin display with a ColdTears Due adapter shield.    This is expensive and not mechanically robust.

There are display shields that are designed for a Mega.    You can plug them into a Due but you still have all the pin-mangling from Mega to Due.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ghlawrence2000 on Feb 20, 2016, 02:59 pm
This is expensive and not mechanically robust.
£5 is hardly expensive............. mine is 3 years old, had LOTS of display plugging and unplugging, SD card insertions and removals, and shield plugging and unplugging from the DUE and still going strong!!!
Of course if you are heavy handed...........  ::)

Regards,

Graham
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: jasperachtbaan on Feb 20, 2016, 03:26 pm
Hi,

I'm considering tot solder a shield to increase speed, but to what port do the pins go? Is there a clear pin mapping table somewhere so I can be sure that I'm doing the right thing?

Thanks in advance,

Jasper
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ghlawrence2000 on Feb 20, 2016, 03:38 pm
Code: [Select]
LCD_RS     25
LCD_WR     26
LCD_CS     27
LCD_RST    28
DB0        33
DB1        34
DB2        35
DB3        36
DB4        37
DB5        38
DB6        39
DB7        40
DB8        51
DB9        50
DB10       49
DB11       48
DB12       47
DB13       46
DB14       45
DB15       44


Regards,

Graham
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: jasperachtbaan on Feb 20, 2016, 03:45 pm
Hi,

Thanks for your answer. I think that that table is suited for 16 bit displays, but mind's got 8 bits. I have this screen:

http://www.banggood.com/3_5-Inch-TFT-Color-Screen-Module-320-X-480-Support-Arduino-UNO-Mega2560-p-1022298.html

Instead of the db8 - db15 pins I've got a pin called LCD_RD. Where is that pin supposed to go then?

Jasper
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ghlawrence2000 on Feb 20, 2016, 03:50 pm
You better wait for David then. That is the standard pins for the Coldtears 16 bit shield. David has implemented Pin 24 for LCD_RD for me, but that was because I told him that's what I wanted. I don't know if he has a 'standard' setup for 8 bit displays.

Graham
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: jasperachtbaan on Feb 20, 2016, 04:23 pm
Hi,

Is this pin implemented in the standard library? If i'm going to make a shield it doesn't really matter what pin goes where.

Jasper
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 20, 2016, 04:46 pm
You have a Uno shield with an 8-bit bus.   As I said earlier,  the bit-mangling cripples performance.

As a comparison,  your 320x480 display shield running the "Adafruit Tests":
Code: [Select]

15.12 sec  on  16MHz Uno
37.98 sec  on  16MHz Mega
 8.71 sec  on  84MHz Due

Code: [Select]

 4.09 sec  on  84MHz Due with hand-wired 8-bit Protoshield.

I can tweak these figures if it really necessary but the whole idea behind the library is to cater for the "Mcufriend Uno-style" shields.
If you wanted to use a 16-bit 40-pin display with the ColdTears adapter,   Graham's 800x480 display takes 5.64 secs.    So I guess your smaller 320x480 would take 2.26 secs.

Yes,  you could make your own 16-bit adapter but £5 for ColdTears seems a wiser bet.    Especially since you can not use a Protoshield.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ghlawrence2000 on Feb 20, 2016, 04:55 pm
Point to mention here, if you do decide to go down the Coldtears shield route, LCD_RD is not implemented by default, you need to attach a wire, but it is trivial to do so.

Graham
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 20, 2016, 04:59 pm
Hi,

Is this pin implemented in the standard library? If i'm going to make a shield it doesn't really matter what pin goes where.

Jasper
My home-made Protoshield for the Due uses the regular control pins.   It maps the SPI pins to the Due SPI.   It maps the data bus to PD0-PD7.    In hindsight,   I would map the data bus to PC1-PC8.

If you really want to make your own adapter,  shout.   But think first.    There is a limit to how fast the controller can accept data.    It is probably about 1.50 secs for the ILI9488 with a 16-bit bus.

The Adafruit tests are representative of typical graphics tasks.    Your app might do a lot of text or angle lines.    This costs more than single colour rectangles.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: jasperachtbaan on Feb 20, 2016, 05:00 pm
Hi,

I can make my own pcb's, so that's no problem. Then I can add my own circuits on it without any extra effort. But it'll work when I connect the RD to pin 24?

Jasper
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 20, 2016, 05:20 pm
If you are making your own pcbs,    I suggest that you conform to the ColdTears pin-out.   i.e. data bus on PIOC1-PIOC8

As I said earlier,   think about what you want first.    From a software point of view,   I can supply a driver for any pin-out.    We can discuss pros and cons.    e.g. what header pins to connect and populate.    what is mechanically robust.

If you are making a batch of pcbs,   I would certainly buy one from you.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: jasperachtbaan on Feb 20, 2016, 05:37 pm
Hi,

I won't be making a batch of pcb's, because it's a lot of work to make one with etching and stuff like that. I'm planning to make pcb's with a laser cutter, and then I'll be able to make a bunch, but I'll have to find out if this is a good way to make them. I think that I'll stick with the coldtears layout in that case, the layout can be downloaded somewhere I guess??

Maybe the library is fast enough as it is at the moment for my application, and then I won't be making a PCB. I'll keep you updated.

Jasper
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ghlawrence2000 on Feb 20, 2016, 05:41 pm
If by 'layout' you mean Eagle files, then you are out of luck!!

Graham
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: jasperachtbaan on Feb 20, 2016, 05:53 pm
That's too bad. I'll make something myself then.

Jasper
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ghlawrence2000 on Feb 20, 2016, 06:03 pm
Good luck with that! I started to make an eagle layout of the CTE shield, until I realised just how well laid out it is........ I couldn't get all the tracks to route as well as they have.........

Graham
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ghlawrence2000 on Feb 20, 2016, 08:46 pm
I have done the BULK of the work, if you feel like doing the routing? The only thing I haven't done is the 2 caps........... everything else is there and placed correctly.

(http://forum.arduino.cc/index.php?action=dlattach;topic=366304.0;attach=155739)

Let me know.

Regards,

Graham

Edit: PS the autorouter gets stuck at 95.1% with 6 air wires remaining, but the board is covered in so many 'vias' there is no board left!!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Feb 21, 2016, 02:29 am
WOW! Unbelievable!

Way beyond my wildest dreams (nightmares?). I would just buy one and hope for the best.

Thank God Chinese New Year only comes once a year   ;)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: sysshad on Feb 23, 2016, 08:39 pm
Hi i must say i just love this library!!!
I have tested so many variants to my IL9486 ebay shield purchase and this one finally works and is quite fast on my Arduino UNO.

However i cant seem to get the Touch to work.
I have ran the Touchscreen_Calibr_kbv and got
LEFT 232
RT 672
TOP 262
BOT 959
Portrait 320x480
and the text SWAPXY

But i cant on earth get the tftpaint_shield_kbv to work.
i only get the text erase wherever i press my pen, and nothing is written on screen.
I have tried changing A2 to A1 and 6 to 7. i do know theese are the pins used because i managed to check it wil a multimeter between the ribbon cable and the pins.

Please advice, kind genious! :=)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 24, 2016, 12:38 am
Your calibration values do not look right.   I would expect values like 150 or 900.

If you measure the resistance between A1, 7 and A2, 6 you will see which is X and Y.
e.g. 300 ohms between XM, XP.   500 ohms between YP, YM.

When you are happy with the values,  please post them here.    Then others with the same shield as you will be able to use them.    I have a ILI9486 shield but the glass is cracked.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Expertsetup on Feb 24, 2016, 10:39 pm
Hello,
I have a 2.4" mcufriend shield with a rubber stamp 68090 and reports:

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(0x0000) 68 09 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 00 00 00 Status Register
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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(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 Panel Control
reg(0x00CC) 00 00 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 00 00 NVM Read
reg(0x00D3) 00 00 00 00 ILI9341, ILI9488
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
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 00 00 00 Interface Control


with LCD_ID_readreg in post#1.

The results of graphictest_kbv seem to show that it is working except for "only the color band" scroll which scrolls the entire screen and readPixel which always returns 0xC80C.

Im running this shield on an Duemilanove with Optiboot and seems to work very well. Let me know if you would like me to do any other tests. since I have the hardware and am willing to do so.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 24, 2016, 11:43 pm
You have an RA68090 controller.    The next release supports this device.   Software Scroll will work properly.   

This class of controller only scrolls the whole screen.

David.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Expertsetup on Feb 25, 2016, 07:09 am
Thanks for the confirmation David, I will study the data sheet I found( V4 april 27 2011) for details. may I ask which controller is the most capable hardware with the most features and which also support read/write?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 25, 2016, 08:09 am
The 2.4" shields are very good value and work well with the Uno.

There are a massive range of controllers used.   The modern types like ILI9341, ILI9329, ST7789V, ... are easier to use than the older ILI9320 style like your RA68090.   

You can rewire the LCD_RESET pin with the modern chips.    This gives you the I2C bus back on the Uno.

OTOH,   most apps will work fine with any of the supported controllers.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RoberSastre on Feb 25, 2016, 10:52 pm
Hello,

I have this display

ILI9335  240x320  ID=0x9335 new Untested

and it does not work.

In the file "MCUFRIEND_kbv.cpp" this line is correct

"return readReg(0);          //0154, 7783, 9320, 9325, 9335, B509"
 


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 25, 2016, 11:42 pm
I have tested most of the controllers.

I do not physically own a ILI9329, LGDP4535, RA68090, R61505V, SPFD5408.    Users report 100% success with the current pre-Release version.
 
I do not physically own a HX8347-A, ILI9335, S6D0139, SSD1963.    These devices need more testing.   Message #41 in this thread reported that the ILI9335 was working.

I can only rely on a user to test these devices for me.    If your ILI9335 does not work,  please copy-paste the output from the LCD_ID_readreg sketch and post it here.    Since the ILI9335 is very similar to the ILI9325,   I would assume it would behave similarly.

"and it does not work" is not very helpful to me.

"white screen", "streaky screen", "wrong colours", "horizontal mirror", "scroll error",  ... are meaningful reports.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RoberSastre on Feb 26, 2016, 12:18 am
Hello,

thanks for your quick response

The report read reg


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) C5 05   ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 01 00 01 00   Status Register
reg(0x00BF) 00 00 00 00 00 00   ILI9481, HX8357-B
reg(0x00D0) 00 00   Power Control
reg(0x00D2) 00 00 00   NVM Read
reg(0x00D3) 00 00 00 00   ILI9341, ILI9488
reg(0x00DA) 00 00 00   RDID1
reg(0x00DB) 00 00 00   RDID2
reg(0x00DC) 00 00 00   RDID3
reg(0x00EF) 00 02 00 02 00 02   ILI9327
reg(0x00B0) 00   RGB Interface Signal Control
reg(0x00B4) 00   Inversion Control
reg(0x00B6) 00 00 00 00   Display Control
reg(0x00B7) 00   Entry Mode Set
reg(0x00F2) 00 71 00 71 00 71 00 71 00 71 00 71   Adjust Control 2
reg(0x00F6) 00 52 00   Interface Control


The problem "white screen"

it has only worked with me https://dl.dropboxusercontent.com/u/46852225/PP_TFTLCD_v1.zip

Thanks,
Roberto

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 26, 2016, 12:32 am
You have a Renesas R61505 variant R61505W with ID=0xC505.   I support the R61505V in the next release.   ID=0xB505.

Where did you get the idea that it was an ILI9335?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RoberSastre on Feb 26, 2016, 12:55 am
Thanks,

In the back of the shield puts "(9335)".

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 26, 2016, 01:10 am
The (9335) is a good clue.   But you can never trust Ebay adverts or even the printed legends on the pcb.

This is why there is an LCD_ID_readreg sketch.    It removes all doubt.

When I post the next version (in the next day or two),  please use tft.begin(0xB505) and report whether the R61505W works exactly like the R61505V.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RoberSastre on Feb 26, 2016, 07:45 am
buy it on amazon

:(
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 26, 2016, 07:21 pm
buy it on amazon

:(
is not very helpful.

Please post the link to the actual Amazon sale.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 26, 2016, 07:26 pm
I have attached a new version 2.8 of the MCUFRIEND_kbv library (http://forum.arduino.cc/index.php?topic=366304.msg2524865#msg2524865)
to message #1 in this thread.

The most significant change is that LANDSCAPE is now 90 degrees instead of 270 degrees.

Please report back with the results from running the example: graphictest_kbv on your R61505W controller.

I have ordered a HX8347-A shield from DealExtreme.   When it arrives,  I will be able to test it myself.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Feb 27, 2016, 12:39 am
Thank you for your library David.

I'm sad to say I still can't use it as the 3.6" I ordered still hasn't arrived from eBay. I'm claiming on it on Monday.

The 2 X 3.95" I ordered from AliExpress were eventually posted after 2 full weeks so I can be waiting for THEM for another 2 months? (I will claim on them in a month as PayPal reckon 30 days is enough time for an item to arrive from China). I suspect the 60 days is so you can't claim after 45 day limit??

I am really looking forward to using your library   :)

Thank you again for all your efforts in providing us with your excellent library.   :smiley-cool:
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Feb 27, 2016, 01:19 pm
Hi, gays.
Anybody have idea, why power stab. AMS1117 3.3V placed on the shield?
I have checked connection of pints to the shield:

1 - GND;
3 - +5V from arduino;
2,4 (3,3V) - to nothing......!

No any tray on the shield, which connect 2 or 4 pin to other elements.....
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 27, 2016, 01:33 pm
Most of the shields use the AMS1117 for the Backlight LEDs.
This ensures that you have a consistent backlight.

The logic write levels are determined by the 3.3V pin on the Arduino.
And the logic read levels are determined by the LCD_RD pin.

In theory they should use 74VHC245 style of buffer which is tolerant of high input voltages.
In practice,   they use 74HC245 chips which are NOT happy with high input voltages.

Your display may vary.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RoberSastre on Feb 28, 2016, 01:49 am
Thank you for your interest, David,

if I probare it is possible tomorrow or Monday and surely will have news

link Amazon,

http://www.amazon.es/gp/product/B00Q6WN3PU?psc=1&redirect=true&ref_=oh_aui_detailpage_o02_s00


look at the photos
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RoberSastre on Feb 28, 2016, 10:47 am
good morning,

there is information

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) 04 04   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 09 09 09 09 09   Status Register
reg(0x0061) 65 65   RDID1 HX8347-G
reg(0x0062) 62 62   RDID2 HX8347-G
reg(0x0063) 67 67   RDID3 HX8347-G
reg(0x0064) 60 60   RDID1 HX8347-A
reg(0x0065) 61 61   RDID2 HX8347-A
reg(0x0066) 62 62   RDID3 HX8347-A
reg(0x0067) 63 63   RDID Himax HX8347-A
reg(0x00B0) A4 A4   RGB Interface Signal Control
reg(0x00B4) A0 A0   Inversion Control
reg(0x00B6) A2 A2 A2 A2 A2   Display Control
reg(0x00B7) A3 A3   Entry Mode Set
reg(0x00BF) A3 A3 A3 A3 A3 A3   ILI9481, HX8357-B
reg(0x00C0) C4 C4 C4 C4 C4 C4   Panel Control
reg(0x00CC) C0 C0   Panel Control
reg(0x00D0) C4 C4 C4   Power Control
reg(0x00D2) C2 C2 C2 C2 C2   NVM Read
reg(0x00D3) C7 C7 C7 C7   ILI9341, ILI9488
reg(0x00DA) C2 C2   RDID1
reg(0x00DB) C3 C3   RDID2
reg(0x00DC) C0 C0   RDID3
reg(0x00EF) E3 E3 E3 E3 E3 E3   ILI9327
reg(0x00F2) E6 E6 E6 E6 E6 E6 E6 E6 E6 E6 E6 E6   Adjust Control 2
reg(0x00F6) E2 E2 E2 E2   Interface Control

I hope it helps
Roberto
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 28, 2016, 11:17 am
Your Serial output from message #151 made complete sense to me.   i.e. a R61505W controller.

The version 2.7 of the library has been tested with a R61505V and I would guess that the R61505W model will be very similar.

The LCD_ID_readreg sketch has nothing to do with the library.    It simply reads registers according to the pins specified for LCD_D0, ..., LCD_RD,  LCD_CS, ... as printed on your pcb.

I can only guess that your Serial output in message #162 is from a different or a damaged shield.   It is very unwise (tm) to use trailing wires.     You should just plug the Shield into the Uno as nature intended.    Then plug the USB cable in.   Then upload and run the sketch.

Never plug or unplug a Shield when the Arduino is powered.

It is fine to plug and unplug USB from the complete Arduino/Shield assembly whether it has power or not..

Of course I may have introduced an error into v2.8 of the library.   But as I said earlier,   the readreg sketch is nothing to do with the library.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RoberSastre on Feb 28, 2016, 11:51 am
Sorry David
This is good

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) C5 05   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 01 00 01 00   Status Register
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(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   Panel Control
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 00   Power Control
reg(0x00D2) 00 00 00 00 00   NVM Read
reg(0x00D3) 00 00 00 00   ILI9341, ILI9488
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
reg(0x00EF) 00 02 00 02 00 02   ILI9327
reg(0x00F2) 00 71 00 71 00 71 00 71 00 71 00 71   Adjust Control 2
reg(0x00F6) 00 52 00 52   Interface Control
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 28, 2016, 11:58 am
The good news is that your Shield is returning the expected values.

Have you tried running "graphictest_kbv" from the library examples?
Does it say "ID = 0xC505" on the Serial Terminal?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RoberSastre on Feb 28, 2016, 12:18 pm
Hello david
thank you for your patience

the result of "graphictest_kbv" in the photo

I had to remove the serial

I was low memory
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RoberSastre on Feb 28, 2016, 12:33 pm
Hello David

if run tftpaint_shield_kbv

tftpaint_shield_kbv.ino: In function 'void loop()':
tftpaint_shield_kbv.ino:143:5: error: 'Point' was not declared in this scope
tftpaint_shield_kbv.ino:143:11: error: expected ';' before 'p'
tftpaint_shield_kbv.ino:151:9: error: 'p' was not declared in this scope

Error de compilación
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 28, 2016, 01:31 pm
Hello david
thank you for your patience

the result of "graphictest_kbv" in the photo

I had to remove the serial

I was low memory
The graphictest_kbv sketch should build just fine on a Uno.   On my Uno with v1.6.6 IDE I get:
Quote
Sketch uses 31,394 bytes (97%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,591 bytes (77%) of dynamic memory, leaving 457 bytes for local variables. Maximum is 2,048 bytes.
It is perfectly safe to have 99% or 100% program memory.
It is "safe" to have up to 92% dynamic memory with this sketch.

Yes,   with a Duemilanove or a Leonardo,  you must use graphictest_slim version.

It looks as if your display is working.   It will look better when you remove the plastic film with the tab.
Does the Vertical Scroll and Software Scroll work?

My apologies over the tftpaint_shield_kbv.ino.    You can correct it by saying TSPoint instead of Point.

It is better to use the Touch_shield_kbv.ino sketch

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Alexander_An4ous on Feb 28, 2016, 07:49 pm
hi, i need vertScroll to display the time, but for some reason the function does not work with standard fonts adafruit_gfx.
I connect text
#include <Font/FreeSerif Bold Italic 24pt7b.h>
tft.setFont(&FreeSerif Bold Italic 24pt7b);

Sorry for the bad English, I use Google translator
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 28, 2016, 07:59 pm
You do not say which controller is on your display.

The ST7781 has got a bug in the Vertical Scroll.   If you can put up with an uglly picture,   you could try it.     The manufacturer does not even document it because it knows ihat it does not work properly.

Likewise,  the older controllers can only scroll the whole screen.   Modern ones can scroll a small band.

You can always scroll in software.     But if you can use the hardware Vertical scroll,    it does give a very smart picture.

Whichever controller or whichever Arduino,   the font should not make any difference.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Alexander_An4ous on Feb 28, 2016, 08:23 pm
0x9488 controller. an example of the scroll_kbv works fine, but if I put a different font, and does not work
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 28, 2016, 08:35 pm
It sounds very unlikely.

Please attach the actual sketch that you are using.

Note that the Adafruit_GFX implementation is a bit of a mess ehen it comes to drawing position.
And different fonts hsve a different height.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Alexander_An4ous on Feb 28, 2016, 08:58 pm
can I do something wrong? but I have all the figures merge with standard typeface are all well
#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#include <Fonts/FreeMono9pt7b.h>

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

// work in line numbers.  Font height in ht
int16_t ht = 12, top = 3, line, lines = 15, scroll;

void setup()
{
    tft.setFont(&FreeMono9pt7b);
    tft.reset();
    uint16_t id = tft.readID();
    tft.begin(id);
    tft.setRotation(0);     //Portrait
    tft.fillScreen(BLACK);
    tft.setTextColor(CYAN, RED);
    tft.setTextSize(1);     // System font is 8 pixels.  ht = 8*2=16
    tft.setCursor(100, 12);
    tft.print("ID = 0x");
    tft.println(id, HEX);
    if (id == 0x9320 || id == 0x9325 || id == 0xB509) {
        top = 0;                      // these controllers scroll full screen
        lines = tft.height() / ht;    // we are in portrait mode
    }
    if (id == 0x7783) {
        tft.println("can NOT scroll");
        while (1);                    // die.
    }
    tft.setCursor(0, 12);
    for (line = 1; line < 21; line++) tft.println(String(line) + ": ");
}

void loop()
{
    tft.setCursor(0, (scroll + top) * ht);
    if (++scroll >= lines) scroll = 0;
    tft.vertScroll(top * ht, lines * ht, (scroll) * ht);
    tft.println(String(line) + ": [" + String(scroll) + "]  ");
    delay(100);
    line++;
}
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 28, 2016, 09:31 pm
The sketch is written for the standard 7x5 system font that uses a line spacing of 8.    Or 16 when in 2x size.

If you really want to use this particular font,    I suggest that you adjust the maths accordingly.

I can try it on your behalf but it would be more sensible to say exactly what you want to do.

Typically,   you might scroll a Portrait text screen upwards.
Or possibly a subwindow.

Or you want to scroll a Landscape picture or graphic to left or right.
Typically,   you scroll a heart monitor graph to the left while displaying other graphs or stationary text.

As I said earlier,   the 9320 style of controller can only scroll the whole screen.
The 9341 style can scroll a sub-range.

David. 
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RoberSastre on Feb 28, 2016, 09:35 pm
In my UNO

Sketch uses 31.422 bytes (97%) of program storage space. Maximum is 32.256 bytes.
Global variables use 1.587 bytes (77%) of dynamic memory, leaving 461 bytes for local variables. Maximum is 2.048 bytes.
Low memory available, stability problems may occur.
avrdude: verification error, first mismatch at byte 0x7800
        0xff != 0x5f
avrdude: verification error; content mismatch


see the video
https://www.dropbox.com/s/s2c4izhk8wcuaet/Archivo%2028-2-16%2022%2031%2036.mp4?dl=0
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Feb 29, 2016, 12:25 am
The video looks correct to me.    In real life the colours would be crisper and clearer.

Are you happy with the display?

I do not understand how you can get a verification error on your Uno.
It looks as if you have changed the fuses on your ATmega328P chip.

I suggest that you use the Arduino IDE to "Burn Bootloader" from the Tools menu.   This will install the bootloader and set the fuses and lockbits correctly.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zoomx on Mar 01, 2016, 11:20 am
Verification error can be an error between the flash content and the compiled file. Mean a flash error.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 01, 2016, 12:00 pm
Well it could be that the Flash pages have come to the end of their life.

The most obsessed Arduino enthusiast would need to be re-flashing their board 27 times every day for a year.
In practice,   the Flash memory has got better endurance.

My money is on hand-installation of the bootloader.   With the wrong fuses and lockbits.

Since the video seems to show the example running,   the AVR is probably in reasonable health.    Especially since the sketch uses almost 100% of the available Flash memory.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 01, 2016, 01:16 pm
After waiting 5 weeks my

http://www.ebay.com.au/itm/141656670946?_trksid=p2057872.m2748.l2649&ssPageName=STRK%3AMEBIDX%3AIT

screen eventually arrived. Instead of 3.6" it was 3.5", crisscrossed with hairline cracks and with bent pins.

Got my refund but thought I would check out the screen anyway....

Got the following response....

reg(0x0000) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 04 04 04 04   Manufacturer ID
reg(0x0009) 09 09 09 09 09   Status Register
reg(0x0061) 01 01   RDID1 HX8347-G
reg(0x0062) 02 02   RDID2 HX8347-G
reg(0x0063) 03 03   RDID3 HX8347-G
reg(0x0064) 04 04   RDID1 HX8347-A
reg(0x0065) 05 05   RDID2 HX8347-A
reg(0x0066) 06 06   RDID3 HX8347-A
reg(0x0067) 07 07   RDID Himax HX8347-A
reg(0x0070) 10 10   Panel Himax HX8347-A
reg(0x00A1) 01 01 01 01 01   RD_DDB SSD1963
reg(0x00B0) 10 10   RGB Interface Signal Control
reg(0x00B4) 14 14   Inversion Control
reg(0x00B6) 16 16 16 16 16   Display Control
reg(0x00B7) 17 17   Entry Mode Set
reg(0x00BF) 1F 1F 1F 1F 1F 1F   ILI9481, HX8357-B
reg(0x00C0) 00 00 00 00 00 00   Panel Control
reg(0x00CC) 0C 0C   Panel Control
reg(0x00D0) 10 10 10   Power Control
reg(0x00D2) 12 12 12 12 12   NVM Read
reg(0x00D3) 13 13 13 13   ILI9341, ILI9488
reg(0x00DA) 1A 1A   RDID1
reg(0x00DB) 1B 1B   RDID2
reg(0x00DC) 1C 1C   RDID3
reg(0x00EF) 0F 0F 0F 0F 0F 0F   ILI9327
reg(0x00F2) 12 12 12 12 12 12 12 12 12 12 12 12   Adjust Control 2
reg(0x00F6) 16 16 16 16   Interface Control

I assume this is a garbage response?

The screen on a Uno just displayed white with splodges of black around the cracks. Compiling & Uploading all the examples didn't change the display so I assume the screen is cactus!?  The Uno without the screen runs "Blink" okay   :D

Now waiting for TWO 3.95" screens from AliExpress (who have been disappointing so far)  :(
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 01, 2016, 01:49 pm
There are lots of displays that arrive with cracked Touch Panels.  The display often works.   Obviously the Touch will not work if the conductive glass is broken.

Your readreg() response does not make much sense.    I would conclude that the display is completely useless.

If the pcb says 3.5" it would have been ILI9481, 9486, 9488, ...
I would guess that it is the shape of the display showing random rounded rectangles at the bottom of the Ebay listing.

It will not match ANY of the other photos.    Wrong Touch panel, wrong shape,  ...

I often wonder about the Ebay vendors.    Do they ship broken items and just rely on the punter not complaining?    Or do they deliberately pack good items badly?    

After all one extra layer of bubblewrap would have saved most of these screens.    Their margins are very tight.    A single refund would pay for a lot of bubblewrap.

Before you chuck the screen away,   have you tried it on different Arduinos?
It is not unknown for clones to have missing or duff 3.3V chips.    

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 02, 2016, 01:23 am
I've bought  about 12 screens from 0.93" to 3.95" from eBay, AliExpress and BangGood.

NEVER know what will arrive (if it arrives?). One even arrived after 12 weeks (refunded and re-ordered in the meanwhile).

I got 3 (4 if I count the one I gave away) from BangGood. Functionally all the same but one of the three is different? Two switch on black screen and one white screen on switch on. The two have nice colours and the one a bit washed out colours. All 3 are running on clone Dues.

Awaiting 2 X 3.95" from Ali. If they prove okay (if they arrive that is) I will cross my fingers and order 4 more.  :)

The cracked screen plugs into my Uno perfectly but will not plug into my Mega? I have another Uno but in a 100 LED simulated starfield and I hate to disconnect it  :(

Oops, plugs into my second Mega okay (tight fit)   :)   But no backlight....   :(  Strange!?

Put it back on the Uno and uploaded "graphictest_kbv", screen stayed white with black splodges   :(

Serial Monitor says...
Serial took 0ms to start
ID = 0x0
Mean anything?

The screen is DEAD!?

Thanks for your continued support David   :D

To answer your "wonder", I suspect this one was shipped broken(?) as it didn't even have the screen protector film on it and the seller refunded my money immediately. I sent him a picture of the cracked screen and he has "promised" that he has put a "free" replacement into "Hongkong Airmail".

It was wrapped loosely and carelessly and I rewrapped it (in the same padded bag) about 3 times more securely.

I am curious if it WAS posted and if it will arrive and if it will be undamaged and if it will work out of the box?

I used your library (2.8 I think) without ANY changes whatsoever....   Is that right?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 02, 2016, 09:16 am
Any Uno shield should be able to plug into a Uno, Mega, Leonardo, Due, Zero
as well as many other third party boards e.g. FRDM, NUCLEO, ...

Depending on the quality of manufacture,   you might need to straighten the header pins and sockets.
The 3.3V, GND, RESET, 5V pins are always in the same place.    The Digital and Analog pins are in the same place.

I would expect your backlight to operate on any board.    Most display shields use the 5V, GND pin to feed the AMS1117 and backlight LED.

Since your display is so obviously damaged,  there is little point in spending much time on it.    However,  I would check out your Uno and Mega boards.   i.e. measure the voltage on the 3.3V pin and 5V pin with a DMM.    Make sure that all GND pins are well connected.

The v2.8 library should work straight out of the box on any Arduino.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 02, 2016, 04:19 pm
I'm probably being a bit premature as I won't have ANY (working) Uno/Mega shield/display for another 4 weeks   :(

The v2.8 library should work straight out of the box on any Arduino.
But what exactly do you mean? Forgive me if I'm being a bit slow  :(

With rowboteer's library I had to comment out a line and uncomment another line or else it wouldn't work. In fact there were two different versions of the library, one for the Mega and one for the Due.

Are you saying that it doesn't matter whether Uno, Mega or Due your v2.8 library (including ALL the examples) will work "out of the box" without any customization? Are you talking JUST about the video functions?

What about "hard" and "soft" SPI etc? Or is this just for the SD card?

Will I have to use the different SD and SdFat libraries for Uno/Mega and Due? What about the touch panel? What about the MANY different controllers?

I suppose I should get off my butt and look at the coding of the examples?  ;)
I have read and re-read ALL the forum threads I have found (about 4 or 5?).

I now have 3 Dues and 2 Megas with four more Megas on the way here from Hong Kong.

I'm off to bed   :)

As always, Thanks for your continued support   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 02, 2016, 05:18 pm
The whole point of the MCUFRIEND_kbv library is to run with any MCUFRIEND Uno Shield.  i.e. plug it in and go.
It detects which controller ID is present with tft.readID().    Then you start the tft with tft.begin(ID)

Yes,   you obviously build for Uno, Mega, Due, ... but the IDE looks after that.

Most Shields have the Touch panel on A1, 7, A2, 6.    Yes,  you might need to change the pins or swap directions.

The microSD card is on the Uno hardware SPI pins.    If you do not have a Uno,  you must bit-bash in software.

David.   
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: photoncatcher on Mar 02, 2016, 09:35 pm
The mcufriend.kbv 2.5 works also fine with a Nano that displays on my 320x480 3.5 inch nameless Chinese color TFT. (says ILI9341)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 02, 2016, 09:53 pm
If you have a 320x480 display that says "0x9341" ,    please run the LCD_ID_readreg sketch and paste it here.

It is very important to identify the correct controller.   

Yes, of course the library will work on a Nano but only IF you have wired it correctly.    The whole purpose of a Shield is to get known wiring connections.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: xxxlshark on Mar 03, 2016, 01:00 am
Hello David!



I use the 3.95 " ili9488 tft Display on a arduino mega board. i start a projekt first with a 3,2 tft and the utft library and it works fine. i use some pics converted to bmp.h !

Now i Change the Display to the larger 3.95" and nothing works fine. I use the librarys from the Forum and the mcu-example run fine, but if i try to use some utft code or the bmp.h (colored) nothing works.  just simple graphic. 

do you know a way to use this Display in a easy way with different Fonts and bmp´s like the other 3,2 tft Display with  utft library? I do not use the Touchscreen.


thanks for help?

Marc 
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 03, 2016, 10:07 am
I did not write the UTFT library.    If you want to use UTFT,   you should ask the UTFT author.

I provide a UTFTGLUE class with the MCUFRIEND_kbv library as a convenience to "run an existing UTFT sketch" with my library.   Nothing more.

If you are writing a new sketch,  you should write it for the "Adafruit_GFX" style of methods used by my library.
The new Adafruit_GFX library supports different Fonts.    Note that this works differently to UTFT Fonts.

If you have a particular problem that you cannot solve with MCUFRIEND_kbv,    attach your sketch,   ask your question.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: photoncatcher on Mar 03, 2016, 12:32 pm
The mcufriend.kbv 2.5 works also fine with a Nano that displays on my 320x480 3.5 inch nameless Chinese color TFT - continued

graphictest_kbv reports ID = 0x9341. Where can I acquire the LCD_ID_readreg sketch ?
 :)

mmmm - sorry to bother you, friends, I got the LCD_ID_readreg.ino. here is the serial output:
 -------------------------------------------------------
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) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 00 61 00 00   Status Register
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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(0x00B0) 00 00   RGB Interface Signal Control
reg(0x00B4) 00 02   Inversion Control
reg(0x00B6) 00 0A 82 27 04   Display Control
reg(0x00B7) 00 06   Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00   ILI9481, HX8357-B
reg(0x00C0) 00 21 00 00 00 00   Panel Control
reg(0x00CC) 00 71   Panel Control
reg(0x00D0) 00 00 00   Power Control
reg(0x00D2) 00 00 00 03 03   NVM Read
reg(0x00D3) 00 00 93 41   ILI9341, ILI9488
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
reg(0x00EF) 00 03 80 02 02 02   ILI9327
reg(0x00F2) 00 02 02 02 02 02 02 02 02 02 02 02   Adjust Control 2
reg(0x00F6) 00 01 00 00   Interface Control
-------------------------------------------------------
Now it come sto dienfying the device (looks to me a superclone!) we have reg(0x00D3) responding with:
reg(0x00D3) 00 00 93 41   ILI9341, ILI9488

correct?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ghlawrence2000 on Mar 03, 2016, 12:35 pm
Same place as all the others!
Quote
File->Examples->Mcufriend_kbv->LCD_ID_readreg
Regards,

Graham
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 03, 2016, 12:53 pm
Dear photoncatcher,

Your controller is clearly an ILI9341 as identified by reg(0xd3).

There is no way that an ILI9341 can control a 320x480 display.   And it is unlikely that you would ever have a 3.5" 240x320 display.   You do get 240x320 in 2.2", 2.4", 2.8", 3.2" sizes but the Mcufriend Uno shields tend to be 2.4", 2.8", 3.5", 3.6", 3.95"

If you want help,   it is essential to give accurate information  e.g. Ebay link,   controller registers from the LCD_ID_readreg sketch.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Expertsetup on Mar 03, 2016, 10:09 pm
I recently tested v2.8 graphictest_kbv with my 2.4" lcd shield as mentioned in my previous post #145. The graphictest_kbv still fails to read a pixel and so skips the software scroll.

Just wanted to let you know that the read pixel is not working.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 03, 2016, 10:38 pm
Thanks for your feedback.    If I do not own your particular controller,   I can only rely on user reports.

As far as I know,  someone reported that the RA68090 behaved 100% with begin(0x9325).
So begin(0x6809) is identical to the ILI9325.

What does the "Software Scroll" report?
It should give an error message if it cannot read the GRAM correctly.

David.

Edit.   I found the post that "said" everything was working with the RA68090.    I am not sure whether the poster really understood what should be displayed.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Expertsetup on Mar 04, 2016, 10:04 am
Not a problem, I am happy to work with you since I have the hardware, anything I can do to contribute would be my pleasure.

The graphictest_kbv readpixel is reporting 0xF89D and so skips the software scroll as a result. In version 2.5 it would return 0xC80C as a constant to readpixel.

Both display the same results with the readpixel_kbv sketch, v2.5 would return 0xC80C and version 2.8 now returns 0xF89D.

When I bypass the pixel color test to software scroll, it just fills the scroll window with a solid color, as I had expected.


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 04, 2016, 10:53 am
Code: [Select]

0xF89D is 0b11111000_10011101 which is rather a strange read value.

0xC80C is 0b11001000_00001100 which is rather a strange read value.


From the Raydium RM68090 data sheet:
Quote
9.7.4 Read Data from GRAM (R22h)
gives a similar flow chart to any ILI9320 style controller.  i.e. you read a dummy first.

Figure 16  clearly shows the 8-bit GRAM read.

I can only suggest that you try adding the READ_NODUMMY attribute to the begin(0x6809) method:
Code: [Select]

    case 0x6809:
        _lcd_capable = 0 | REV_SCREEN | INVERT_GS | READ_NODUMMY;
        goto common_93x5;
    case 0x9325:
        _lcd_capable = 0 | REV_SCREEN | INVERT_GS;
        goto common_93x5;


Please report back with the result.

The only other possibility is READ_8() but this would put the whole interface "out of step".    Everything else is done in 16-bit chunks.

Thanks again for your feedback.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Expertsetup on Mar 04, 2016, 10:31 pm
Hello,
I added the changes you posted but it seems to have had no effect. It seems that the value reported by readpixel is possibly random as it has changed when I remove power and repower the unit.

today I have seen 0xF80D, 0xE80C as well as 0xC80C.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 04, 2016, 11:20 pm
The READ_NODUMMY edit would most likely produce random results.

I presume that all the other tests in the graphictest_kbv sketch behave as expected.   You can clearly read the ID so the wiring must be correct.     What value is reported in the Software Scroll read error?

Quite honestly,   I would expect the original code to work.   READ_NODUMMY or READ8_DUMMY seem to contradict the data sheet and any common sense.

The only other possibility is a very SLOW read cycle.    I will go to my PC to check the data sheet timing.    It is very unlikely with a Uno or Mega.

David.

Edit.   Looking at the Datasheet,  minimum tRAT=100ns and tRC=300ns.    On a Uno,   I allow 375ns for tRAT and 750ns for tRC.   tRDH=250ns.  tRDL=500ns.   So I can't see any timing issues with an AVR.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 05, 2016, 01:30 pm
@Expertsetup:

Page 34 of the RM68090 data sheet has "i80 9/8-bit System Bus Interface Timing" that shows the Read from GRAM.    with auto-increment !

This contradicts the flowchart from "9.7.4 Read Data from GRAM (R22h)" on page 52.

So it is worth trying this instead:
Code: [Select]


    case 0x6809:
        _lcd_capable = 0 | REV_SCREEN | INVERT_GS | AUTO_READINC;
        goto common_93x5;
    case 0x9325:
        _lcd_capable = 0 | REV_SCREEN | INVERT_GS;
        goto common_93x5;


This will not correct the "Software Scroll" but it is worth seeing the effect on the "readpixel_kbv.ino" sketch.    If the RM68090 does support AUTO_READINC you will see different pixel values in the screen dump.    Either post one photo of PORTRAIT or type out the first two lines.

I presume that you have the Shield comfortably inserted into the Uno.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Expertsetup on Mar 07, 2016, 12:06 am
I have tested the new changes and am having the same results unfortunately. I verified proper mounting of shield, all seems well. The changes have been made to MCUFRIEND_kbv.cpp at lines 1429-1431.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 07, 2016, 09:29 am
Looking at your JPEG,   you appear to have CYAN (0x07FF) text on a BLUE (0x001F) background.
I would expect to see WHITE (0xFFFF) text on a BLUE (0x001F) background.

Do your colours from the graphictest_kbv sketch look the same as other people's videos and screenshots?
Most importantly,   the coloured bands should show a smooth gradation of BLUE, GREEN, RED, GRAY.

Clearly AUTO_READINC is not supported because you are reading a constant value.    It is not unknown for data sheets to have inaccurate information.

If you return to the original library distribution,   do you get F89D everywhere on the readpixel_kbv screen?
If you get different values,   a screenshot would be very helpful.

I am sure that the solution will be trivial.    Meanwhile,   I am very frustrated !

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 07, 2016, 11:00 am
Meanwhile,   I am very frustrated !

David.
You're frustrated!?

I see all this interesting stuff going on and all I have is a broken screen to play with! If I'm lucky, I'll have a couple of screens in a month!? If I'm unlucky, refund claim and another 6 week (or more!?) wait!?

eBay doesn't seem to have the Uno/Mega 3.95" screens and have to rely totally on AliX....   :(
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 07, 2016, 11:36 am
Yes,   the bigger Uno shields only seem to be on AliExpress.
Whether it is Ebay or AliExpress,   you need to be sceptical of their descriptions, photos,  ...
Even the printed legends on the pcb is sometimes wrong.

The Mcufriend Uno shields can be read.  So I know which controller is present.    Even if the controller is remote,   I can ask the owner to run a test,   read a register, ...

The Mcufriend Mega shields can NOT be read.   So it is complete guesswork.  Even if I have the controller on my desk.    I can attempt to look for inconsistent registers and observe the behaviour.  e.g. the ILI9481, HX8357-B, R61581 are "compatible" controllers from three different makers.

After all of this,   sometimes data sheets are not 100% accurate.    Mind you,   they are pretty good.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 07, 2016, 12:25 pm
Shows you how much I know! I didn't even realise there were different. The ones I have coming are described Uno and Mega so I imagine only heavens knows what is coming.
Probably testing you a bit but COULD they work optimally on both? I think I HAVE posted a link to them previously. I realise the SPI is different.
Sorry, have to put my youngest grandson to bed....
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 07, 2016, 12:37 pm
The Mega Shields have a double row of male pins to mate with the 18x2 female header on a Mega.
They use a 16-bit data bus and will work fast on the Mega because they map directly to PORTA, PORTC.
They are similar to the HX8557 shield that you have already got.   (but with a Touch controller)

The Uno shields have only got an 8-bit data bus.   They work pretty well on a Uno.    Not so well on a Mega because the digital D2-D9 pins are connected to random PORTs on a MEGA2560.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 07, 2016, 01:31 pm
Oh! You mean THOSE Mega screens!?  I have 3 of those, the 16bit 3.2" ones from BangGood. They are running on my heavily modified UTFT library. The mods are mainly the methods with the colour argument on the end. All 3 on Dues running a 400K pattern painting routine, a digital clock on a picture background and a Mandelbrot that runs to 100 trillion zoom....

I am curious how your GLUE will work wth MY moded UTFT?  ;)

I ordered 2 separate AliX 3.95" screens but they detected the orders and combined them. So I HOPE to have them in 2 to 4 weeks.  Hope!  Hope!  Hope!

I have visions of attaching one to a Uno and one to a Mega and loading the same examples on both and comparing run times. Eventually making up a shield to run one on a Due. I am NOT doing anything in the meanwhile as, as you suggest, heaven alone knows what will arrive (IF they arrive!)?  :(

As always, thank you for your continued support....   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Expertsetup on Mar 07, 2016, 08:18 pm
Looking at your JPEG,   you appear to have CYAN (0x07FF) text on a BLUE (0x001F) background.
I would expect to see WHITE (0xFFFF) text on a BLUE (0x001F) background.

Do your colours from the graphictest_kbv sketch look the same as other people's videos and screenshots?
Most importantly,   the coloured bands should show a smooth gradation of BLUE, GREEN, RED, GRAY.
The text on readpixel_kbv is in fact white but camera rgb moire filter seems to have given blue bias.
all colors appear normal and color bands are smooth.

Quote
Clearly AUTO_READINC is not supported because you are reading a constant value.    It is not unknown for data sheets to have inaccurate information.

If you return to the original library distribution,   do you get F89D everywhere on the readpixel_kbv screen?
If you get different values,   a screenshot would be very helpful.
when returning to the 2.5 library readpixel_kbv returns a constant C80C on first attempt, after power cycle D80C and then after third power cycle E80C, the value is fixed for entire screen.

Quote
I am sure that the solution will be trivial.    Meanwhile,   I am very frustrated !

David.
I agree, it should be reveled eventually and no doubt it will seem trivial.



Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 08, 2016, 11:16 am
I am completely flummoxed by this.    I can see NO reason why your RM68090 does not behave like all the other ILI9320 style controllers.

I suspect that there are several RM68090 "owners" out there in Arduino-land.
Do you get the same result as Expertsetup?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Mar 12, 2016, 04:52 pm
Hello, David,
Now I trying to run a tftpaint_shield.kbv scetch on the shield 3,95 inch display ILI9488, but painted area mismatched with touchscreen. Only limited triangle area can be painted when I push all surface step by step.
The picture and touchscreen calibration test results in attachment.

What do you think, it is touchscreen hardware defect?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 12, 2016, 06:00 pm
Your Calibration is wrong.    I would do the Calibration in PORTRAIT mode.    The Touch Panel is clearly wired for PORTRAIT mode.

And  I would expect LEFT=920, RT=160 or similar.
If you put in these "guess" values,    do you get a good response?

In fact,   it looks like you have a Shield exactly like mine.    So the Touch_kbv sketch probably gives you a pretty good guess.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Mar 12, 2016, 06:27 pm
I have tried  LEFT=920, RT=160, no results.
Also resistance XP(6)-XM(A2) 2,4kOm, YM(7)-YP(A1) 600Om.
Do you have similar values?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 12, 2016, 06:48 pm
Typical resistances are 300 ohm between XM, XP.  And 500 ohm between YP, YM.

My 3.95" shield has:
Code: [Select]

...
uint8_t YP = A1;  // must be an analog pin, use "An" notation!
uint8_t XM = A2;  // must be an analog pin, use "An" notation!
uint8_t YM = 7;   // can be a digital pin
uint8_t XP = 6;   // can be a digital pin
uint8_t SwapXY = 0;
...
   } else if (identifier == 0x9488) {
        name = "ILI9488";
        TS_LEFT = 904; TS_RT = 170; TS_TOP = 950; TS_BOT = 158;


I would be surprised if your Shield is different.    But 2k4 is not a good value for a touch screen.

There are lots of different 2.4" Shields.   Several 3.5" Shields.    I doubt if there is more than one 3.95" Shield.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: finchamp on Mar 17, 2016, 10:51 pm
I have just posted a thread on issues I am having using this screen and library with the MAX 6675 thermocouple amp and library to display temperature. Any insight would be greatly appreciated over here:

https://forum.arduino.cc/index.php?topic=387251.0
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: rattlin on Mar 18, 2016, 11:20 pm
Hi David, hi guys

I have to mcufriend 2.4" lcd screens from 2 different sources.
With MCUFRIEND_KBV I managed to see that screens are working. Awesome job, David! )Thanks!

However, I have a problem: touch panel is not working on both screens. Tried differen combinations of A1, A2, 6, 7 - no luck

LCD_ID reports

Rea
reg(0x00F2) 00 00 00 00 00 00 00 00 00 00 00 00   Adjust Control 2
reg(0x00F6) 00 00 00 00   Interface Control
 21 12 21   ILI9327
reg(0x00F2) 00 00 00 00 00 00 00 00 00 00 00 00   Adjust Control 2
reg(0x00F6) 00 00 00 00   Interface Control
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) 93 35   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 00 00 00 00   Status Register
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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   Panel Control
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 00   Power Control
reg(0x00D2) 00 00 00 00 00   NVM Read
reg(0x00D3) 00 00 00 00   ILI9341, ILI9488
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
reg(0x00EF) 12 21 12 21 12 21   ILI9327
reg(0x00F2) 00 00 00 00 00 00 00 00 00 00 00 00   Adjust Control 2
reg(0x00F6) 00 00 00 00   Interface Control

Any advise, guys? Much appreciated
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 18, 2016, 11:40 pm
You have an ILI9335 controller.

You can unplug the Shield from the Uno.
Measure the resistance between the shield pins.   
YP, YM about 500 ohms.
XM, XP about 300 ohms.

If you only have a Touch in one direction,   it can not work.
A broken glass Touch Panel will not work.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: meph328 on Mar 21, 2016, 10:14 pm


hi guys i have a blue tft 2.8 and cant make it work,i have tried the LCD_ID_readreg and this is what i get
any ideas what do i need to do?

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(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 54 80 66 Manufacturer ID
reg(0x0009) 08 08 08 08 08 Status Register
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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 02 Inversion Control
reg(0x00B6) 00 02 02 27 27 Display Control
reg(0x00B7) 00 06 Entry Mode Set
reg(0x00BF) 08 0E 0E 0E 0E 0E ILI9481, HX8357-B
reg(0x00C0) 00 21 01 01 01 01 Panel Control
reg(0x00CC) 08 3A Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 00 00 NVM Read
reg(0x00D3) 00 00 93 30 ILI9341, ILI9488
reg(0x00DA) 08 5C RDID1
reg(0x00DB) 08 08 RDID2
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 21, 2016, 11:45 pm
You have an ILI9330.   I have never heard of all these variants from Ilitek.
I suggest that you force tft.begin(0x9341) or tft.begin(0x9329) and report back with the results.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 22, 2016, 01:09 pm
EDIT: Sorry I had a dud copy of the example??????   I HAVE replaced it and uploaded it PERFECTLY.....

Hi David,

My screen eventually arrived. 3.95" ILI9488....

Plugged it into my Uno and powered on and, whatever sketch was in the Uno, started running.  WOW! I was blown AWAY.  It was MAGNIFICENT!!!!

Hardware scroll...  SOFTWARE SCROLL....  Colours....   W O W !

I was TOTALLY IMPRESSED. But, I spoke too soon.  While I wasn't looking the display white screened! Pressed reset - white screen. Switched the USB port off and one - still white screen.

Swapped Uno for Mega....

I suspected the sketch was "graphictest_kbv" but I loaded/compiled/uploaded "GLUE_Demo_480x320". Got a funny error/warning?

C:\Users\Louis\AppData\Local\Temp\arduino_modified_sketch_332034\GLUE_Demo_480x320.ino:17:38: warning: large integer implicitly truncated to unsigned type [-Woverflow]

 UTFTGLUE myGLCD(0x9488,A2,A1,A3,A4,A0);

                                                                             ^

But the sketch ran slowly (because Mega????) so I didn't think much of it.

Then I loaded "graphictest_kbv" into the IDE and tried to upload the sketch. Got a couple of errors here too....

Arduino: 1.6.8 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Build options changed, rebuilding all
graphictest_kbv:1: error: stray '\357' in program

 ï»¿// All the mcufriend.com UNO shields have the same pinout.

 ^

<<<<snip>>>>



Swapped back to Uno and got the same errors????

Here is the serial monitor from "LCD_ID_readreg"

<<<snip>>>

reg(0x0000) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 54 80 66   Manufacturer ID
reg(0x0009) 00 00 61 00 00   Status Register
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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 93 30 93 30   RD_DDB SSD1963
reg(0x00B0) 00 00   RGB Interface Signal Control
reg(0x00B4) 00 02   Inversion Control
reg(0x00B6) 00 02 02 3B 3B   Display Control
reg(0x00B7) 00 06   Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00   ILI9481, HX8357-B
reg(0x00C0) 00 0E 0E 0E 0E 0E   Panel Control
reg(0x00CC) 00 03   Panel Control
reg(0x00D0) 00 00 00   Power Control
reg(0x00D2) 00 00 00 00 05   NVM Read
reg(0x00D3) 00 00 94 88   ILI9341, ILI9488
reg(0x00DA) 00 54   RDID1
reg(0x00DB) 00 80   RDID2
reg(0x00DC) 00 66   RDID3
reg(0x00EF) 00 00 00 00 00 00   ILI9327
reg(0x00F2) 00 58 04 12 02 22 22 FF 0A 90 14 88   Adjust Control 2
reg(0x00F6) 00 00 00 00   Interface Control
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 22, 2016, 01:34 pm
You clearly have a real ILI9488.

I can't see any reason for getting a white screen.   I have the same display and have run it for days on end.
I presume that you have the Shield firmly inserted in the Uno.


I recommend that you use V1.6.x IDE for the Arduino.
The Build Warnings are nothing to worry about.

However you should never get any stray '\357' messages.
Arduino sketches use regular Ascii characters.   If you get a "stray" it probably means that you have corrupted a ZIP file or more likely,  opened the sketch with a Word Processor.

If you still have problems.   Delete the MCUFRIEND_kbv folder from your libraries folder.    Download and install a fresh copy.   Restart the IDE.

Check the 3.3V output pin on your Uno and Mega2560.    Is it providing 3.3V ?    Does it still provide 3.3V with a 330R resistor load?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: SHTIRLITZ on Mar 22, 2016, 02:39 pm
... While I wasn't looking the display white screened! Pressed reset - white screen. Switched the USB port off and one - still white screen.
I suppose you have a hardware problem. For my experience, these 3,95" shields has poor assembly quality.
On my sample the flex cable from display to PCB shield and when i have touching the visible flex surface, the display stop working (white screen) or background illumination switched off (black display).
Finally I had to soldered some trays in flex cable....
If you see the white screen, it means that power supply 3,3V present on the shield and may be some data lines are break off.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 22, 2016, 04:31 pm
Thank you both for your replies   :D

They were/are very re-assuring but you are definitely right about the quality....   :(    The screen is badly scratched and has 2 hairline cracks (like my 3.5") but it works so it is something to play with   :)  It didn't come with a protective screen.  :(  I may have to settle on the 3.6".  But it is a very NICE looking screen when I am used to the BangGood 3.2 with no touchscreen.  I am looking forward to playing with the touch.  :)   I'm particularly impressed by the Hardware scroll, never seen it before.   :D

The screen will run for a couple of hours then, untouched, will white screen. Trying to upload a sketch will result in a "port busy" (solid) error. Transfer to a Mega and it will work again. Transfer back to the Uno and it will run for a LONG time.  Unpredictable   :(

I can just tell the Uno is faster but not by much?  Would it speed up by much to move to PD0 - PD7 pins on the Mega?  Would the library have to change or will it automatically adjust itself?  I only bought the Uno for comparison. I also bought 6 Megas (my preferred board) for my digital clock(s) project.

At long last I can join in playing with your library, David.  Thanks....   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 22, 2016, 05:04 pm
I am gobsmacked by people's priorities.

If you have hairline cracks in the Touch Panel,  the Touch will not work at all.
If  you do not have a protective film over the screen,  it is not new.

Regarding assembly.   Touch Panels are sometimes slightly crooked.   The edge pixels can be obscured by the black border of the Touch Panel.   The soldering is generally ok.

I have a 3.5" ILI9486 screen with a hairline crack.   The TFT works fine.   The Touch is obviously bad.
Your display is clearly damaged.    Ask for a replacement.

I would not waste time on a damaged display.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: violetry on Mar 22, 2016, 05:47 pm
my ili9488 3.95 inch using r61581 controller working but not displaying whole screen ;how do i change the resolution
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 22, 2016, 06:38 pm
My library does not support the R61581.

Count the pins on your shield.    Are there enough girls on your Uno for all the boy pins on your shield.

If you do have a Uno shield,    what does the ID say?    Run LCD_ID_readreg sketch.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: meph328 on Mar 22, 2016, 07:29 pm
Hi David with force tft.begin(0x9341) or tft.begin(0x9329) works with both, what reports u ask to see?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 22, 2016, 07:41 pm
Most of the examples report the ID to the Serial Terminal.
Better still.   Run the LCD_ID_readreg sketch.

The R61581 is a 320x480 controller.    Very similar to the ILI9481.

I really can't believe that a 3.95" display would be 240x320.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: meph328 on Mar 22, 2016, 07:46 pm
i have set the 0x9341 and this is what i get

Code: [Select]
Found unknown LCD driver
ID=0x9338
Screen is 240x320
Calibration is:
LEFT = 920 RT  = 150
TOP  = 940 BOT = 120
Wiring is: PORTRAIT
YP=16 XM=15
YM=6 XP=7
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 22, 2016, 08:24 pm
You have an ILI9338.   I have a 2.8" Blue display with an ILI9338.    
I also have the ILI9338B data sheet:
Quote
240RGBx320 Resolution and 262K color
Are you sure that your pcb says 3.95"  ILI9488?
Where did you get the idea of R61581?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: finchamp on Mar 22, 2016, 08:32 pm
David,
My goodness, do you have a lot of help requests coming in! I just want to say that this library is fantastic, and I am glad to have found it. Worked beautifully once I figured out which controller I have. Thanks for all your hard work.

I do have a real puzzler as far as displaying a thermocouple temperature in a sketch I am working on. Would you mind taking a look at my symptoms in this thread? I'm sure it's some small collision between the libraries, but you may be the only one who would know based on the info:

https://forum.arduino.cc/index.php?topic=387251.0

Thanks.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 22, 2016, 08:43 pm
Life is much simpler with the regular Adafruit_GFX graphics and text.   i.e. using the MCUFRIEND_kbv class

The UTFTGLUE class does nothing that you could not have done with MCUFRIEND_kbv directly.

If you use setColor(foreground_colour, background_colour) method it will write a fresh background when you print.

If you use the fancy fonts that come with the new Adafruit_GFX,  you need to draw the background yourself.

Think about it.    You only draw a filled rectangle that is the size of your new text.

David.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 25, 2016, 10:08 am
I am gobsmacked by people's priorities.

If you have hairline cracks in the Touch Panel,  the Touch will not work at all.
If  you do not have a protective film over the screen,  it is not new.
<<<snip>>>
Your display is clearly damaged.    Ask for a replacement.

I would not waste time on a damaged display.

David.
I will do but that is a long and painful road. I always go for a refund THEN re-order. Otherwise "protection" will expire before the replacement arrives   :(

In the meanwhile the one with the hairline cracks is what I HAVE ATM to play with   :(

Surprisingly the display runs flawlessly on a Mega I bought a year ago but NOT on the (3) Megas I JUST bought   :(

It worked for a few minutes on my NEW Uno too. When I summon up the nerve I will unplug my OLD Uno and try THAT?

I plugged it into my Due and it ran flawlessly on THAT   :D

I changed the increment in "testLines(uint16_t color)" from 6 to 1 and display "rainbow" colours in your "graphictest_kbv" example. It runs for 299 seconds on my Mega and 114 seconds on my Due.

As you suggested I can't get the "touch" to work though    :(   I don't know if this is caused by the hairline cracks or incorrect pins for the "touch". When I touch the screen it "blinks" the whole display grey??

Thanks for your library   :)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 25, 2016, 10:28 am
Only you know if the Touch Panel is cracked.    Remove the protective film.   Are the "cracks" still there?    The backlight will show up a crack if you look at the right angle.    ANY crack will stop Touch working.

Regarding your "new" Megas.    Have you tested the 3.3V and 5V pins?
Then connect a modest load.  e.g. an LED with 100R resistor to the 3.3V and 5V pins.   
Do they still read 3.3V, 5.0V ?

You do seem to have bad luck with Ebay.

I would expect any of my examples to run forever.
Your old Mega and your old HX8357 display should run forever.   (you have a PM)

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 25, 2016, 04:02 pm
Just a quick response before bed....

I can see 2 hairline cracks but can't see any difference in the backlight etc....

I WILL check out the voltages etc tomorrow.

Thank you for your continuing support   :D

Edit: I hesitate using the BangGood HX8357 3.2" screens because of the absent "touch"   :(
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 25, 2016, 04:20 pm
A hairline crack is just a polite name for a broken Touch Panel.

You appear to have bad luck when shopping.
1.   Evaluate your  Mega boards.    Are they faulty too?
2.   There is no point in persevering with a broken Touch.
3.    Although many TFT screens "work" with a broken Touch on top,   the stress that broke the Touch would have stressed the TFT too.

Sweet Dreams.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: finchamp on Mar 25, 2016, 04:44 pm
Life is much simpler with the regular Adafruit_GFX graphics and text.   i.e. using the MCUFRIEND_kbv class

The UTFTGLUE class does nothing that you could not have done with MCUFRIEND_kbv directly.

If you use setColor(foreground_colour, background_colour) method it will write a fresh background when you print.

If you use the fancy fonts that come with the new Adafruit_GFX,  you need to draw the background yourself.

Think about it.    You only draw a filled rectangle that is the size of your new text.

David.


Both methods redraw a rectangular background behind the text with every print. My issue is not with drawing, I have some kind of conflict that is causing the thermocouple call to return the same starting temperature value any time the display is running (works fine without display). I have the same issue printing its value over serial.

I am using MCUFRIEND_kbv class now.

More details on what all I have tried in the other thread.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 26, 2016, 12:46 am
Everything looks pretty straightforward.   I suggest that you hardwire VCC, GND properly
Try this:
Code: [Select]

#include <max6675.h>
MAX6675 thermocouple(49, 51, 53);   //hardwire VCC, GND pins

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

void loop()
{
    Serial.print("Celsius temp = ");
    Serial.println(thermocouple.readCelsius());
    delay(1000);
}


The equivalent for the TFT would be:
Code: [Select]

#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <max6675.h>
MAX6675 thermocouple(49, 51, 53);   //hardwire VCC, GND pins

void setup()
{
    tft.begin(tft.readID());
    tft.fillScreen(0x0000);   //BLACK
}

void loop()
{
    tft.print("Celsius temp = ");
    tft.println(thermocouple.readCelsius());
    delay(1000);
}


Untested.  

I can see no conflicts between Serial and MAX6675.   Certainly with a Mega.    
I would avoid a constructor that calls pinMode() with an ARM target.   I prefer to have a specific thermocouple.begin() but your library is not organised that way.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 26, 2016, 07:28 am
Hi David

I have a heavily modified UTFT library and I'm trying to use your "UTFTGLUE.h" to "link?" to it. I notice that some methods don't work, for instance, "setBackColor" and "drawBitmap" etc.

In the GLUE "drawBitmap" has been commented out. Could you explain why to an old newbie?  :)

I'm trying to compile a digital clock sketch that used my modified UTFT library on the BG 3.2" screen to the AliX 3.95" screen. The original sketch worked well but with LOTS of compile warnings   :(

I appreciate that the "touch" won't work but the screen works well   :)

Edit: I have just ordered another one from a more expensive seller on AliX  :)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 26, 2016, 10:18 am
The GLUE class extends the MCUFRIEND_kbv class to support the "usual" UTFT methods.     You can build a legacy UTFT sketch by just changing the constructor.   

The  extended class means you can use every method that is uniquely named.    Not wise at all to mix methods from both classes.

It is simple enough to implement the less common methods.   Fonts are handled differently but drawing a circle, box, line,  ... are going to look the same.

I suggest that you stick to regular Adafruit style methods in any new sketches.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 26, 2016, 04:03 pm
Sorry David, I don't understand.  :(

I tried to use "setBackColor" and "drawBitmap" and the compile errors out.

UTFT (and my variant) doesn't support the 3.95" 9488 screens.  It seems to support 8bit but for 3 obscure types of screens?

How do I drive my hairline cracked 9488 AliX screen when neither UTFT nor your library fully support the methods I want to use? Like single argument (TRANSPARENT) background colour and Bitmaps?

I have read 10 different threads from top to bottom and sideways but I still don't know the answer. Forget re-wiring protoshields etc, I can't get any library working on my clock sketch (and the AliX 3.95" screen).

Besides my clock sketch I have a 2500 line sketch I would like to port to my AliX screen. UTFT doesn't support the 9488 and your library doesn't support bitmaps. I suspect rowboteer's libraries, excellent on my BangGood screens, won't drive the 9488 either?

I don't have the luxury of a new sketch....   :(

Quote
I suggest that you stick to regular Adafruit style methods in any new sketches.
Rampant newbie here   :(
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 26, 2016, 04:57 pm
Which UTFT example(s) do you want to build?

I have a 3.95" UNO shield.    So I can build any standard sketches.    I really do not feel like working with a hacked library.    But I am happy to build a sketch.   Just attach it here.    (the working UTFT sketch)

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Mar 27, 2016, 03:52 am
Thanks for the offer David.  :D

But it isn't an example. I have got ALL your examples working (except the "touch" ones) and I have modified them to my heart's content  :)

I'm happy to do the work myself I just want to know how? Do you have instructions somewhere or a tute that details how to use GLUEs etc?

I have played with your GLUE_Demo so I've copied the technique.  ;)

Very basic things....  For instance....

Code: [Select]

  tft.setBackColor(VGA_TRANSPARENT);

  tft.drawBitmap(0, 0, 480, 320, BackGround);

  tft.drawBitmap(340, 130, 128, 100, seconds);//Repaint BG behind transparent seconds

  tft.drawBitmap(176, 130, 128, 100, minutes);}//Repaint BG behind transparent Minutes

fail to compile  :(

Your library only seems to support "setBackColor(r, g, b)". Does it support TRANSPARENT? It is an integral part of my sketch so I need it. How do I get it to work? Do I have to modify your GLUE or do I write one of my own?

This is part of the original UTFT library (not my variant) but your GLUE doesn't cover it. Please don't think I am complaining  :(   You have provided SO much effort and I'm grateful. I just want to know how to action additional methods.

And "drawBitmap", do I uncomment it in your GLUE? If I "hack" your GLUE I will have to redo the "hack" should you release an update....

Apart from babysitting I have LOTS of time.....   I'm happy doing the work myself just how?  :D

Also with the touch. I know the cracks may effect it but the examples talk about YP, XM, YM and XP....   My AliX screen has none of these  :(

Then from the other side - A1, A2, 7 & 6....   These are LCD_WR, LCD_RS, LCD_D7 & LCD_D6. Aren't 7 & 6 part of the PD0 - PD7 data pin set?

My replacement 3.6" is due any day now so hopefully I can play with the touch again (with an uncracked screen). Are the examples meant to work with MCUFRIEND Uno/Mega shields out of the box? Do I have to change the pin numbers in the "touch" examples?

Is YOUR 3.95" UNO shield an AliX one (or similiar)? If so, does IT work out of the box?

LOTS of questions from a very confused newbie   :D

Thank you for all your help and support  :)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Sandy88 on Mar 27, 2016, 08:55 am
Hello to everybody

I am new here and I also start to do the Arduino, .... things.

The typical beginner things, like blink LED and BT with smart phone, I got allready run.

Now I wanted to start to try it with a touch display.

I bought a 3.6" TFT for Arduino UNO from mcufriend.
BUT I don´t use the Arduino board. I have the Teensy 3.1

A simple 4x20 LCD is no problem.

I am confused by the mcufriend_bkv libraries.
I can´t find the definition of the controller IOs and the connection table to the display.

The display uses the Ili9488 and the connectors... LCD_d0-d7, rst, cs, rs, wr, rd
Also included is a SD car reader and a touch function.

Please give me support like a stupid beginner  :smiley-cry:
thanks a lot

Andreas
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 27, 2016, 09:07 am
I do not own a Teensy 3.1

I have no intention of supporting a Teensy 3.1

If a Teensy had an Arduino footprint  (i.e. accepted Uno shields),    then I would buy one and support it with my library.

I suggest that you buy a Uno clone.     Your shield would fit that.    All the examples would work 100% straight out of the box.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Sandy88 on Mar 27, 2016, 09:18 am
For the other things, I can use the Arduino Libraries too.

So, I think it should work in this case too. But I need the connection table for the display. And where  I can find the adjustment in the library for the IOs

Andreas
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 27, 2016, 10:08 am
As far as I can see,   I would need to buy a Teensy 3.2 and an Adapter board.

Hobbytronics have a Sparkfun adapter board.    It looks as if the shield header sockets and the Teensy header socket are the same height.    So you could not fit your display shield on it without header 'extensions'.

If I can solder the Teensy directly to the adapter board,   would shields fit?    Would I get a neat arrangement like a Uno or FRDM board?

If this is practical,   I could buy Teensy and adapter from Hobbytronics.    Then test with the 3.2.    I presume 3.2 and 3.1 are similar.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Sandy88 on Mar 27, 2016, 03:25 pm
Hi

Good idear. But I use one of these attached laboratory thing. See photo (sorry, don´t know the enlgish name)

After I get everything run, display, bluetooth, battery charger, speed control, speed limiter, energy monitoring, ... I want to make a board which includes everything for a scooter.

The components are allready somewhere in my hobbyroom. Just waiting to be connected :-)

Now I start to learn and get one by one online.

best regards
Andreas
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: satad92 on Mar 29, 2016, 03:44 pm
Hi,

I have this shield:
LCD shield (http://www.banggood.com/2_8-Inch-TFT-LCD-Shield-Touch-Display-Module-For-Arduino-UNO-p-989697.html)
with this Reg-Code:
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 og 8-bit values
in special locations (first is dummy)

reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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 02 Inversion Control
reg(0x00B6) 00 0A 82 27 05 Display Control
reg(0x00B7) 00 06 Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
reg(0x00C0) 00 21 00 00 00 00 Panel Control
reg(0x00CC) 00 72 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 01 01 NVM Read
reg(0x00D3) 00 00 93 41 ILI9341, ILI9488
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00EF) 00 03 80 02 02 02 ILI9327
reg(0x00F2) 00 02 02 02 02 02 02 02 02 02 02 02 Adjust Control 2
reg(0x00F6) 00 01 00 00 Interface Control


The shield works with the UNO and Due fine, but I want to use it with the SPI- Bus.
Can I use this shield with SPI?

best regards
Samuel
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 29, 2016, 04:08 pm
Not with the regular "SD.h" library that comes with your Due.

You can bit-bang the SPI in software with some versions of "SdFat.h" but you will have to sort that out for yourself.    Yes,   the Due can do software SPI as fast as the Uno can do hardware SPI.

In an ideal world there would be friendly Italians,   one IDE and one "SD.h" library that could use both the native hardware SPI and software SPI.   And even better if it understood all the regular SD formats.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: xxxlshark on Mar 30, 2016, 02:23 am
Hello!

I try to use your Libs (adafruit_gfx and MCUFRIEND_kbv)  on a 3.5 Inch LCD (ILI9481) .

I try to print out simple Char and Values with different Fonts. What i figured out is, if i print some values out in the same line, the Output on the lcd tumbled up or down?!

for example:

w=480;
h=320;

  tft.setCursor(100, 150);
  tft.setTextSize(1);
  tft.setFont();
  tft.print("480");
  tft.print(";");
  tft.print("320");

  tft.setCursor(10, 150);
  tft.setTextSize(1);
  tft.setFont();
  tft.print(w);
  tft.print(";");
  tft.print(h);

the Output is!!                       
                           _____________480;320_______________//Line y=150
                            480;320

Right  must be in one Line?!   
                            __________________________________//Line y=150
                             480;320          480;320

Whats wrong?!

THX for Help
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: xxxlshark on Mar 30, 2016, 03:27 am
.....the next Problem is, if i print a changed variable (sec), the Values dont refresh. the new val overwrite the old one without clear the place.


.....what can i do without fillScreen, (clrScr does not work) ! On Utft the new value clear the place before write new value.

......thats a crasy lib?!


thx
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: satad92 on Mar 30, 2016, 07:55 am
Thanks for the help.

The Uno doesn't use the SPI in the Touch shield scetch. I can not see the clock with an oscilloscope.

I have to use the shield with a STM32, but I don't know how to configurate the SPI or which PIN is for chip select.

Which controller is in use? Is it a ILI9341 or a ILI9320?
The touch screen use the pins A3 and D9 and A2 and D8.

best regards
Samuel
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 30, 2016, 08:41 am
Hi,

I have this shield:
LCD shield (http://www.banggood.com/2_8-Inch-TFT-LCD-Shield-Touch-Display-Module-For-Arduino-UNO-p-989697.html)
with this Reg-Code:
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 og 8-bit values
in special locations (first is dummy)

reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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 02 Inversion Control
reg(0x00B6) 00 0A 82 27 05 Display Control
reg(0x00B7) 00 06 Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
reg(0x00C0) 00 21 00 00 00 00 Panel Control
reg(0x00CC) 00 72 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 01 01 NVM Read
reg(0x00D3) 00 00 93 41 ILI9341, ILI9488
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00EF) 00 03 80 02 02 02 ILI9327
reg(0x00F2) 00 02 02 02 02 02 02 02 02 02 02 02 Adjust Control 2
reg(0x00F6) 00 01 00 00 Interface Control


The shield works with the UNO and Due fine, but I want to use it with the SPI- Bus.
Can I use this shield with SPI?

best regards
Samuel
No,  you can NOT use this shield in any other way.   It uses the 8-bit parallel interface.   The shield is wired for 8-bit.  The ILI9341 controller is configured for 8-bit.

You can use it on an STM32 NUCLEO board but stiill with the 8-bit parallel bus.     Obviously my library is for Arduino.    You need MBED for a Nucleo.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: satad92 on Mar 30, 2016, 09:46 am
That makes sense...
The SPI connectors than only for the SD card?

Than I have to look up for a STM library or write my own...

Samuel
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 30, 2016, 10:09 am
Arduino boards are things like Uno, Mega2560, Zero, Due, ...

There is no official Arduino board that uses an STM32.
If there was an official board,   I would probably support it.

NUCLEO boards will accept your display.   

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: satad92 on Mar 30, 2016, 10:25 am
I know what Arduino boards are.
Maybe I wrote it bad in my broken english.

I know that my Nucleo will support my LCD, but I have to write the code for my LCD allone.
no ready function to control the lcd

Samuel
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 30, 2016, 01:21 pm
.....the next Problem is, if i print a changed variable (sec), the Values dont refresh. the new val overwrite the old one without clear the place.


.....what can i do without fillScreen, (clrScr does not work) ! On Utft the new value clear the place before write new value.

......thats a crasy lib?!


thx
First off.   I wrote MCUFRIEND_kbv before Adafruit_GFX added "fancy fonts"

I certainly would NOT have chosen "glyph" based drawing.    And would not embed pointers into the Font tables.  

However,  you have chosen to try out the Adafruit_GFX Fonts without reading the Adafruit Font docs.
They differ from the system font:
1.   the new fonts are drawn upwards from a baseline.   (and descenders will fall below)
2.   they draw transparently.   there is no "draw background colour" mode.  

Code: [Select]
#include <Adafruit_GFX.h>    // Core graphics library
#include <MCUFRIEND_kbv.h>   // Hardware-specific library
MCUFRIEND_kbv tft;

#include <Fonts/FreeSerifBold12pt7b.h>
#include <Fonts/FreeSerifBold24pt7b.h>

#define BLACK   0x0000
#define GREEN   0x07E0
#define CYAN    0x07FF

int w, h;     //global dimensions

void setup(void)
{
    uint16_t ID = tft.readID();
    if (ID == 0xD3D3) ID = 0x9481;
    tft.begin(ID);
    tft.setRotation(1);
    tft.setTextSize(1);
    w = tft.width();
    h = tft.height();
}

void showfont(const GFXfont *f1, char *name)
{
    tft.fillScreen(BLACK);
    tft.setTextColor(GREEN, BLACK);
    tft.setFont(NULL);    //System font
    tft.setCursor(0, 0);
    tft.println("Using font " + String(name));
    tft.setFont(f1);
    tft.setCursor(200, 100);
    tft.drawFastHLine(190, 100, 10, CYAN);
    tft.print("480;320");
    tft.setCursor(10, 100);
    tft.drawFastHLine(0, 100, 10, CYAN);
    tft.print("480;320");

    tft.setCursor(100, 150);  //set cursor in non-system font
    tft.setTextSize(1);
    tft.setFont();            //System Font
//    tft.setCursor(100, 150);  //set cursor AFTER setting font
    tft.drawFastHLine(90, 150, 10, CYAN);
    tft.print("480");
    tft.print(";");
    tft.print("320");
    tft.setCursor(10, 150);
    tft.drawFastHLine(0, 150, 10, CYAN);
    tft.setTextSize(1);
    tft.setFont();
    tft.print(w);
    tft.print(";");
    tft.print(h);
}

void printAt(String s, int x, int y, const GFXfont *f1)
{
    tft.setFont(f1);
    tft.setCursor(x, y);
    tft.drawFastHLine(x - 10, y, 10, CYAN);
    tft.print(s);
}

void showfont2(const GFXfont *f1, char *name)
{
    String msg;
    tft.fillScreen(BLACK);
    tft.setTextColor(GREEN, BLACK);
    msg = "Using font " + String(name);
    printAt(msg, 10, 0, NULL);           //System font
    printAt("480;320", 200, 100, f1);
    printAt("480;320", 10, 100, f1);
    printAt("480;320", 100, 150, NULL); //System font
    printAt(String(w) + ";" + String(h), 10, 150, NULL);
}

#define SHOWFONT(x) showfont(&x, (char*)#x)
//#define SHOWFONT(x) showfont2(&x, (char*)#x)
void loop()
{
    SHOWFONT(FreeSerifBold12pt7b);
    delay(4001);
    SHOWFONT(FreeSerifBold24pt7b);
    delay(4001);
}

  
This sketch shows you how the setCursor() mode alters because of the "Base line" drawn in CYAN.

Now change the SHOWFONT() macro to use the showfont2() function.    This looks a lot neater.   Mind you,   String methods are extremely memory hungry.

David.

p.s. in an ideal world,  I would use regular proportional fonts that use a fixed height / variable width box.    You can calculate the width of any string.   And draw a fresh background colour.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: alon24 on Mar 31, 2016, 12:36 pm
Can I use XPT2046 code with this device (ili9341 mcufriend)

Like this guy: http://nailbuster.com/?page_id=341

ead 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) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 00 61 00 00   Status Register
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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 02   Inversion Control
reg(0x00B6) 00 0A 82 27 04   Display Control
reg(0x00B7) 00 06   Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00   ILI9481, HX8357-B
reg(0x00C0) 00 21 00 00 00 00   Panel Control
reg(0x00CC) 00 71   Panel Control
reg(0x00D0) 00 00 00   Power Control
reg(0x00D2) 00 00 00 03 03   NVM Read
reg(0x00D3) 00 00 93 41   ILI9341, ILI9488
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
reg(0x00EF) 00 03 80 02 02 02   ILI9327
reg(0x00F2) 00 02 02 02 02 02 02 02 02 02 02 02   Adjust Control 2
reg(0x00F6) 00 01 00 00   Interface Control

I believe this is an ill9341 device with xpt2046 cotroller, and the reson i ask, is that i want to connect this to esp8266, which does NOT have many (only one) connectors which can read analog (analog pins) , and I see that the xpt2046 code, only uses digital pins.

So is this possible?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 31, 2016, 02:09 pm
If you produced this output,   you appear to have a Red or Blue MCUFRIEND shield.

These do not have an XPT2046 chip.   They simply have a Resistive Touch Panel that shares pins with the TFT controller.

Of course,   you may have a "special" shield.   The Uno does not have enough pins for a XPT2046 and microSD.    Your link shows a 3.3V display that is NOT a Uno shield.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Greg682 on Mar 31, 2016, 03:09 pm
does anybody know why I get this error while downloading any of the exaples to the arduino?

avr-g++: error: missing filename after '-o'

how can I correct it?

Greg
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Mar 31, 2016, 03:53 pm
Which IDE version?
Which library, example, ...?

In the IDE->File menu:   select Preferences->show verbose output for compilation.


Copy-Paste the error message.    Put it within CODE tags.    Then it is confined to a box and is easy to read.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Greg682 on Apr 01, 2016, 12:09 am
Hi david,
      thanks for your help!

The IDE version is 1.6.6
the example is File->examples->Mcufriend_kbv->aspect_kbv

the libraies are

<CODE>

#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

</CODE>

Sorry I don't know how to put it within code tags... hope it works

the error message is:

<CODE>

Arduino:1.6.6 (Windows 10), Scheda:"Arduino/Genuino Uno"

avr-g++: error: missing filename after '-o'

exit status 1
Errore durante la compilazione

 Questo report potrebbe essere più ricco di informazioni con
 "Mostra un output dettagliato durante la compilazione"
 abilitato in "File > Impostazioni"

</CODE>

thanks again for your help
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 01, 2016, 12:21 am
The "CODE-tags" is the icon at the top left of your Edit window.

You can type your message and experiment with CODE, quotes, italics ... and use the [Preview] button to see what the message will look like.

The Forum has full instructions for "how" to post a message.    I presume that you will be able to read them in your own language.    Or perhaps you need to ask Google to translate.

I just tried "aspect.ino".   It built just fine with v1.6.6 onto a Uno target.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Greg682 on Apr 01, 2016, 03:41 pm
There must be a problem with my edit window because there's nothing at the top lef of it. Actually the edit window I use is "Quick Reply", I don't know if it's a different one.

Anyway I realized it gives the same error with all the sketches I try. It must be a library or a ide problem I suppose.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 01, 2016, 03:59 pm
I am on a Samsung Tablet.  Portrait mode.

As I type into the "Quick Reply" window,   I see some yellow emoticon icons directly above the typing area.
Above these are a selection of editing icons for code </>,  bold B,  italic I, ...

But I can equally well type these by hand.   i.e. with the square brackets.  just like HTML.

I am sure that the Forum tutorials explain things better than I can.

But the best feature of all is that you can use the [Preview] button to see what your message looks like.  Or even tidy it up after posting.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Greg682 on Apr 01, 2016, 05:00 pm
Thanks David,
          I'll do it next time

Greg

P.S. in the preview frame I can see the icons you referred to!

Now it's all more clear
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: GermanGerman on Apr 03, 2016, 04:37 pm
Hello, I used Mcufriend_kbv library, Adafruit-GFX-Library-master, Touch-Screen-Library-master. Faced with the problem of which is shown in the video https://www.youtube.com/watch?v=VtcVZrgfC2M
Can anyone encountered this problem and suggests why the sensor works well? Powered by an example from this video and did everything in the same way https://www.youtube.com/watch?v=VnRVbxQESnY
Sorry for my bad English.(http://my-files.ru/m49i2t)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 03, 2016, 04:56 pm
Both of your videos seemed to show a TouchScreen that did not follow the stylus very well.

They also showed a screen with inverted colours.   All "Paint" examples that I have ever seen,  use a BLACK background.

If your display does not show BLACK, RED, CYAN, ... properly,   say so.
I can write a "graphictest_kbv" program that says RED, GREEN, INVERT, ... but if no one reports a problem,   how do you expect me to fix it?    i.e.   if it says RED then you should see RED.

The Resistive Touch screens work fairly well.    A cracked glass means that the Touch is broken.   A broken Touch will never work.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: GermanGerman on Apr 03, 2016, 07:19 pm
Thank you for your response, David! Indeed, I noticed that the colors do not match, but I'm just starting to explore the world, and Arduino is difficult for me to immediately understand why the colors are wrong. I bought a screen on Aliexpress. Externally, the whole screen, not damaged, but I suspect that faulty touch screen coating. I want to ask, do you think that in my case, a sensor malfunction? Or follow the wrong screen stylus because of the wrong code?
Display defined number ID 9486 http://my-files.ru/m49i2t
The video shows that at the end of an instant the screen background is black and the color change, it can be interesting: https://www.youtube.com/watch?v=9jZ8XKw6GPk
http://my-files.ru/34jp63
http://my-files.ru/xy5ddy

Example GLUE_DEMO_480x320 does not work, a white screen , sometimes changes color the brighter the darker but still white.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 03, 2016, 11:29 pm
You have an ILI9486 controller but the colours are all inverted.

In the Mcufriend_kbv.cpp file,   edit the begin() method:

Code: [Select]

    case 0x9486:
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS;  // remove the REV_SCREEN attribute
        static const uint8_t ILI9486_regValues[] PROGMEM = {
        ...


My ILI9486 shield is 3.5" and needs the REV_SCREEN attribute.   Your 3.95" shield obviously does not need REV_SCREEN.

I am horrified by your wiring.    The shield should plug into your Due as Nature intended.

You can still access all the unused Due headers.   just use some angle-header strip.

Look very carefully at your Touch Screen.   Are you sure that the glass is not cracked?

Everything should work 100%.    It is very important that you report any problems.   The "edit" is very simple.
Alternatively,   you call tft.invert(true) or tft.invert(false)

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: alon24 on Apr 05, 2016, 12:43 pm
David,

Thanks for your answer.
I have another question, I want to use the mcufriend 2.4 shield (with ili9341) on an Uno, and also use I2C.

As I understand it, i2c requires pin A4 (SDA), A5 (SCL), which are taken by LCD_RST, LCD_CS.

In code I see

MCUFRIEND_kbv(int CS=A3, int RS=A2, int WR=A1, int RD=A0, int RST=A4);

In another post I saw that you could snip the A$ pin from the shield, but you said there not to do it in ili9345 i think.
Can I snip it here?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 05, 2016, 12:58 pm
LCD_CS is on A3.   A5 is unused.

Solder a 10k pull-up from LCD_RESET pin to the 5V pin on the shield.   You should be able to solder to the top of the pcb pins safely.

Now you can snip off the A4 pin from the shield.

You fit a 2-pin angle header into the Uno's I2C socket.   You can steal 5V, 0V from the ICSP headers.

Personally,  I like the Uno clones that have holes for spare headers.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: alon24 on Apr 05, 2016, 01:03 pm
I have that clone which has extra holes :)

I will solder the 10k.

another q:
i want a good library for creating a menu and buttons with touch, that would work with this and on an uno (which does NOT have much memory), any suggestions
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 05, 2016, 01:14 pm
Buttons are pretty easy with the "Adafruit_GFX_Button" class.

If you want a pull-down menu arrangement,   it becomes difficult.    i.e. reading and storing the underlying screen contents.

There is a nice Frenchman who was showing his Karaclass library (http://forum.arduino.cc/index.php?topic=384109.msg2647723#msg2647723).
 working with Marek's TFT library

It should work with your display if you change it to use TouchScreen.h

I have not tried it myself.   I might have a go later.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: alon24 on Apr 05, 2016, 01:15 pm
do u have a link to that french mens work ?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 05, 2016, 01:23 pm
Yes,  I have edited message#272.    It was Marek's TFT library.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: alon24 on Apr 05, 2016, 04:38 pm
david:

The lib u recommended uses duotimer, I have an Uno, so ofcourse no good,
Can you recommend a different lib instead of duotimer? I am this close to compling :)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 05, 2016, 05:05 pm
Well,   I tried building the demo for a Due.    It required some mystery libraries.  I gave up.

I doubt if the Karaclass class will be practical on a Uno.

What do you want to do? 
Have you tried the Adafruit_GFX_Button class ?

Regular buttons are easy.    I suggest that you do not clutter the screen with too many buttons.   Draw a fresh screen with fresh buttons that reflect the current state.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: alon24 on Apr 05, 2016, 05:08 pm
1. I want to build a display lib, to connect to my esp8266
2. I can compile most of his code, just need to replace duetimer - maybe with schedular

3. I might go the buttons only route, I want to first see what is possible, with what is out there.

4. my ultimate goal was to have this working on esp8266 only, but I chose the wrong display, because this does not have xpt206 that I thought it would (I did not know much about displays when I bought it cheap)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 05, 2016, 05:30 pm
It is a difficult choice.

Either you provide several simple examples that demonstrate one method at a time.
Or you provide a complex Demo that shows off every method.

As people have noticed,   my "demo" only just fits on a Uno.    A Duemilanove, Leonardo, ... has insufficient memory.

Likewise,   my library requires "Adafruit_GFX.h" and sometimes "TouchScreen.h"
If you need non-standard headers,   they can be local to the sketch folder.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: GermanGerman on Apr 10, 2016, 08:55 am
Thank you very much , David ! Removing REV_SCREEN attribute for my 3.95 inch screen help to correct color, all colors are now displayed as intended.
About the touch screen . I contacted people that they, too, met the same problem with a touchscreen , I am inclined to the version that this factory marriage , since those people , too, is completely a screen without physical defects , but the touch screen behaves just like mine .
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 10, 2016, 09:45 am
As I said earlier,  my ILI9486 is on a 3.5" panel.

Your 3.95" panel is physically different to mine.
Are you happy with the colours?
Does the picture look steady?
Do you get smearing?

The colours are easy to change with a different Gamma curve setting.
Your panel might need different "Power" settings.

Regarding Touch.   Measure the resistance.   I would expect about 300R in the X direction and 500R in the Y direction.
If the Touch glass is cracked,  it will not work at all.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: GermanGerman on Apr 10, 2016, 09:20 pm
Thank you very much , David ! At first glance, the colors look good and I was happy with everything , everything is clear and moves smoothly when scrolling text.
Resistance on the x and y axes 400 ohms and 780 ohms, respectively . Cracks not. Touch screen works, but not correctly .
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 10, 2016, 09:33 pm
400R and 780R sounds good.

It also sounds like you have a similar shield to my 3.95" ILI9488 shield.
So my calibration  might be good for you too.

I would put the DMM on A1,D7 and touch the screen.     Does the resistance change?
Do the same with A2,D6.

If you get steady 400R and 780R,   plug the shield back on the Uno and try the Touch sketch again.
It should show you the coordinates of the stylus.    Does it make sense?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: brandonLA on Apr 11, 2016, 07:57 am
Hi I have an Kadei taobao china brand link below lcd and wish to connect to arduino MEGA, does anyone know the proper connection of the tft lcd to the arduino MEGA pin and the required library?

https://world.taobao.com/item/522120177327.htm?fromSite=main&spm=a1z09.2.0.0.v12usI&_u=62cigp59c023

I tried many library without much success except for the white screen and  tft model 0x303

thx in advance
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 11, 2016, 09:50 am
I can't read Chinese.   I can't read the legends corresponding to Analog#0 - 4 pins.
Please read your pcb and report what you see.  e.g. please correct this:
Code: [Select]

// Does the Blue pcb have these control signals
#define RST A4
#define CS A0
#define RS A1
#define WR A2
#define RD A3


//does the Blue pcb have this LCD_DATA bus?
#define D0 2
#define D1 3
#define D2 4
#define D3 5
#define D4 6
#define D5 7
#define D6 8
#define D7 9



// regular MCUFRIEND UNO shields have this wiring
#define RST A4
#define CS A3
#define RS A2
#define WR A1
#define RD A0
#define D0 8
#define D1 9
#define D2 2
#define D3 3
#define D4 4
#define D5 5
#define D6 6
#define D7 7

If your wiring has different wiring to the regular MCUFRIEND shields,  you need to edit the LCD_ID_readreg.ino sketch and copy-paste the output from Serial Terminal.

Nature designed male pins to mate with female sockets.   You should plug your shield into a Uno or a Mega or whatever.    Never use trailing wires with a shield.


Incidentally,  you can always enter "kedei" into the Search box at the top-right of your screen.
Previous kedei had Red or Green pcbs.    Your link shows a Blue pcb.   
Do they not provide you with a library?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: brandonLA on Apr 11, 2016, 10:13 am
Hi thx for the reply
The tft lcd is as attachment below, when i connected the tft lcd directly onto the arduino MEGA an error knows as timeout error occur.
Then when I connect via jumper wire, there was an successful uploading but the screen remain white. I tried many library but not much luck.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 11, 2016, 10:37 am
Please answer the questions in message #284.

It is pointless attaching the same photo of the pcb with the legends in shadow.   We can see this on the Chinese website.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: brandonLA on Apr 11, 2016, 11:08 am
I run LCD_ID_readreg by attaching the LCD onto arduino MEGA the following error appear

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

When I run the LCD_ID_readreg using jumper wire below is the following output from serial monitor
reg(0x0000) 03 03   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 07 07 07 07   Manufacturer ID
reg(0x0009) 0B 0B 0B 0B 0B   Status Register
reg(0x0061) 63 63   RDID1 HX8347-G
reg(0x0062) 63 63   RDID2 HX8347-G
reg(0x0063) 63 63   RDID3 HX8347-G
reg(0x0064) 67 67   RDID1 HX8347-A
reg(0x0065) 67 67   RDID2 HX8347-A
reg(0x0066) 67 67   RDID3 HX8347-A
reg(0x0067) 67 67   RDID Himax HX8347-A
reg(0x0070) 73 73   Panel Himax HX8347-A
reg(0x00A1) A3 A3 A3 A3 A3   RD_DDB SSD1963
reg(0x00B0) B3 B3   RGB Interface Signal Control
reg(0x00B4) B7 B7   Inversion Control
reg(0x00B6) B7 B7 B7 B7 B7   Display Control
reg(0x00B7) B7 B7   Entry Mode Set
reg(0x00BF) BF BF BF BF BF BF   ILI9481, HX8357-B
reg(0x00C0) C3 C3 C3 C3 C3 C3   Panel Control
reg(0x00CC) CF CF   Panel Control
reg(0x00D0) D3 D3 D3   Power Control
reg(0x00D2) D3 D3 D3 D3 D3   NVM Read
reg(0x00D3) D3 D3 D3 D3   ILI9341, ILI9488
reg(0x00DA) DB DB   RDID1
reg(0x00DB) DB DB   RDID2
reg(0x00DC) DF DF   RDID3
reg(0x00EF) EF EF EF EF EF EF   ILI9327
reg(0x00F2) F3 F3 F3 F3 F3 F3 F3 F3 F3 F3 F3 F3   Adjust Control 2
reg(0x00F6) F7 F7 F7 F7   Interface Control

Thx for the reply
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Apr 13, 2016, 07:05 am
My replacement 3.5" TFT LCD has arrived and, it too, is smashed beyond belief   :(  More hairline cracks than the first and 9 pins bent flat   :(

Even "Blink" won't upload with it connected to a Uno   :(

Not my lucky year   :(   :(   :(
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Tahp on Apr 13, 2016, 10:37 am
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) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 00 00 00 00   Status Register
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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(0x00B0) 00 03   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   Panel Control
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 00   Power Control
reg(0x00D2) 00 00 00 00 00   NVM Read
reg(0x00D3) 00 00 00 00   ILI9341, ILI9488
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
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 00 00 00   Interface Control

Getting double screen/ split screen/ divided screen need help
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 13, 2016, 10:56 am
That seems very odd.    Please post a link to your actual shield.   e.g. Ebay sale.

It does not look like the response from a Red 2.4" mcufriend display.

Do all the male pins mate nicely with the female sockets on the Uno?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Tahp on Apr 13, 2016, 11:15 am
That seems very odd.    Please post a link to your actual shield.   e.g. Ebay sale.

It does not look like the response from a Red 2.4" mcufriend display.

Do all the male pins mate nicely with the female sockets on the Uno?

David.
http://www.ebay.com/itm/201448097156?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

As far as I know the pins are sitting correctly.

thanks
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 13, 2016, 11:57 am
Your link shows a regular 2.4" shield with legend (9340) which implies an ILI9340.

I would expect a normal output from the readreg sketch.
If you are sure that your Uno is 100% and the shield fits nicely,   I would ask for your money back.

If your display actually has an ILI9340C controller,   it should work with tft.begin(0x9341) or with tft.begin(0x9329).    But it would still give you realistic values from the readreg sketch.

David.   
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bianchifan on Apr 13, 2016, 03:31 pm
Thank you so much for this lib, it's so funny!!

I found this thread last weekend when searching for a lib supporting $7 3.95" ILI9488.
Your lib supports all my parallel Uno shields, 2.4 and 2.8, ILI9341, ILI9335 and ILI9325.
I remember my trouble with the ILI9335, it was ordered by mistake, i thought of an ILI9341 with touch.
None of my installed libs was working until I found a hint for extra wait cycles at init time.
and then ..mirrored screen, swapped touch..

Mcufriend_kbv is runnin' them all in the right way and faster than all other, amazingly!

One curious point, on a MEGA2560 the tests are running a little slower, 10-30%.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Flying_David on Apr 15, 2016, 09:51 am
Hey,

I do not understand how this works ore what I'm doing wrong.
I ran the LCD_ID_readreg code

this is the out coming:

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) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0Read 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) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 54 00 00 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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(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 35 00 00 01 Panel Control
reg(0x00CC) 00 00 Panel Control
reg(0x00D0) 00 07 04 Power Control
reg(0x00D2) 00 01 44 44 44 NVM Read
reg(0x00D3) 00 01 44 44 ILI9341, ILI9488
reg(0x00DA) 00 54 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00EF) 00 02 04 93 27 FF ILI9327
reg(0x00F2) 00 00 00 00 00 00 00 00 00 00 00 00 Adjust Control 2
reg(0x00F6) 00 00 00 00 Interface Control

this is done on a mega 1280, I can also perform this code on an uno if necessary.
But what do i have to do next?
If I open an sample, what do I have do change, I saw I have tot  choose a line for mega of uno.
but still the code does not compile or upload.
I get:

compilation terminated
exit status 1
fault by compiling  (in dutch)


Hop you guys can help me out and explain it a little bit to me

already thanks allot!!

David
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 15, 2016, 10:43 am
I was not aware that anyone had or used an ATmega1280.
I support Uno, Mega2560, Leonardo, Due, Zero, M0 Pro.

The LCD_ID_readreg sketch should work on any Arduino.    You clearly have a Uno shield with an ILI9327 controller with 240x400 resolution.

Plug the shield into a Uno and everything should work.
If you have a genuine Mega1280 board and have plugged in the shield,   I will add support.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Flying_David on Apr 15, 2016, 10:56 am
Thank you very much!
I got an arduino uno off another project to test.

But how about the fault with compiling?
If i can't compile the code in de arduino ide, i can't upload it to the uno
I got this within my library folder:

MCUFRIEND_kbv.     this one also appear in the sample's tab.
<Adafruit_GFX.h>   downloaded this in from github, this does not appear in the sample's tab.

Did i something wrong with the libraries?
or do I have to add something in the code to choose the wright chip?

david
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 15, 2016, 10:59 am
I have no idea what your error is.   You have not "copy-pasted" the error.  Or even said what sketch you are using.

Everything should build and run on a Uno.
If you own a genuine MEGA1280 instead of the common MEGA2560,   I will add support.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Flying_David on Apr 15, 2016, 11:21 am
I got the error with all the samples of that library.
see the images.
it is in dutch, but i think you understand. (fout = fault) (bij = by)


david



Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 15, 2016, 11:26 am
My eyesight is not that good.

Holland may not be that far from England but I still can't read your PC screen from here.   (my window faces North)

No,  I can't read Dutch.   However I can recognise error messages , line numbers,  file names ...

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Flying_David on Apr 15, 2016, 11:55 am
sorry, had some problems with the images.
here the most important one
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 15, 2016, 12:26 pm
Thanks for the PNG.   It shows that you are using an "unofficial IDE" with a Uno on Linux without verbose Compilation messages.

I use v1.6.6 IDE and v1.7.8 IDE.
The "GLUE_Demo_400x240" sketch builds and runs just fine with an ILI9327 shield on both IDEs.

If anyone else has a problem with building on the official v1.6.8,   I would like to know.

Meanwhile,  please select File->Preferences->Show verbose output during Compilation.

Then copy-paste the Error text not a screen dump.    If you paste it to a CODE window,   many people can read it directly from your message.    But attaching a .txt file is fine too.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Flying_David on Apr 15, 2016, 12:33 pm
oke thanks allot for your help and tips!!
it works now on the uno!!
i'm going to try it on de mega 1280 to

david
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 15, 2016, 12:44 pm
No it will not work on the 1280.   

Do you really have an obsolete Mega (http://www.arduino.cc/en/Main/ArduinoBoardMega) ?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Flying_David on Apr 15, 2016, 01:24 pm
yes I have, it says on the chip.
but just for me is not necessary. you've helped me already.


David
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ylph on Apr 17, 2016, 08:10 am
Hi,

I have a 2.4" mcufriend UNO shield that returns the following when running LCD_ID_readreg :

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) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 00 00 00 00   Status Register
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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 FF FF 00 00   RD_DDB SSD1963
reg(0x00B0) 00 03   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   Panel Control
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 00   Power Control
reg(0x00D2) 00 00 00 00 00   NVM Read
reg(0x00D3) 00 00 00 00   ILI9341, ILI9488
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
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 00 00 00   Interface Control

Most of the examples I tried sort of work, however everything is displayed in 1/2 size, and shown twice (see attached image for example) - sounds similar to the double/split screen issue someone described above.

Is there any way from this to tell which controller my board has ?  Any idea what could be causing the split screen ?

I peeled the LCD off the board, and there are a few places stamped with 2013 dates in there, so this could be a pretty old board, if that makes any difference.

Thanks !
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 17, 2016, 08:34 am
Please read my reply to message #292 (https://forum.arduino.cc/index.php?topic=366304.msg2709501#msg2709501)

Then run the graphictest_kbv sketch with the modified ID.   e.g. tft.begin(0x9329)
Please let me know how you get on.

The whole idea behind MCUFRIEND_kbv is to detect the actual controller ID.    Then it can use the correct configuration.     Prior to the Tahp's recent post,   I had only found one shield that would not report its ID (0x9341).     Your one is obviously not 0x9341.

The GLUE demo sketches are not a suitable diagnostic.    Make sure that things are working properly with the regular library first.    Then try GLUE if you have some legacy sketches.    New sketches are best written for the regular library.

David.  
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ylph on Apr 17, 2016, 05:16 pm
I tried running graphictest_kbv and forcing different IDs, with the following results:

no graphics, black or flashing only :

0x5407, 0x1289, 0x8347, 0x1963, 0x9327, 0x9328, 0x7789, 0x9340 - black screen
0x0154, 0x9325, 0x9335, 0xB505 - both halves of the split screen flash white, then black
0xB509 - split screen flashes 3 times, then black - flashing repeats occasionally
0x9488 - 1 half the split screen flashes white, then black
0x7783 - screen not split this time, visibly flickering, and occasionally changing to light grey then slowly fading back to black

graphics does appear :

0x9329 - split screen, blue and red colors look swapped in the grades
0x9341 - split screen, everything looks mirrored, colors totally wrong/inverted
0x9481 - split screen, things not aligned properly, colors same as 0x9329
0x9486 - split screen, things not aligned properly like 0x9481, but colors inverted like 0x9341

0x9320 - split screen flashes on briefly with some green text, then remains black

Basically anytime there is anything actually drawn on the screen, it is split in half.  I believe this board came from eBay (http://www.ebay.com/itm/172088465109) and the listing did not specify type of controller.

The soldering job looks pretty shoddy where the LCD is attached to the board - there are globs of solder all over the place.  Is it possible the board itself is defective or is this more likely an unknown and unsupported controller ?

Thanks !
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 17, 2016, 05:38 pm
Please post a photo, video of the "best" one.

Blue/Red swap,  colour inversion, mirroring, ... are all trivial to fix.

I am gobsmacked that 0x9320 could ever show any text.
0x9302 or 0x9329 should display something.
There is little point in trying the "big-geometry" controllers like 9327, 9481, 9486, 9488, ...

Since both ylph and Tahp seem to have similar results,   it is likely to be a "new" controller but I would expect to read "some" registers.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ylph on Apr 17, 2016, 07:43 pm
Looks like 0x9320 is flashing whatever is left over in the LCD buffer/memory from previous run.  If I power the shield off then boot with 0x9320 sketch loaded, it flashes "noise" - random colored pixels.  If I run one of the "working" sketches first, for example 0x9329, then load the 0x9320 it then flashes whatever was on the screen when the old sketch stopped running - could be some text, or if I catch it on a blank screen it just flashes a black screen.   It flashes the same thing whenever I hit reset, so that memory is not being cleared - if I actually disconnect power in between, then it goes back to flashing noise.

0x9302 is completely black, 0x9329 I tried before too - it is probably the "best" one - still split screen, and red/blue are swapped, but otherwise it looks good.

Here is a video of 0x9329 : https://www.youtube.com/watch?v=ajl73ePncXY (https://www.youtube.com/watch?v=ajl73ePncXY)

Thanks !
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 17, 2016, 08:55 pm
You just have a non-interlaced display.

I will look up the necessary registers later.
Having just returned from the pub,   I do not feel like it at the moment.

Has anyone any idea what make of controller is used?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 18, 2016, 01:11 am
Please find the begin() method in the MCUFRIEND_kbv.cpp file:
Code: [Select]

    case 0x9329:
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS;
        static const uint8_t ILI9329_regValues[] PROGMEM = {
            0x01, 0,            //Soft Reset
            TFTLCD_DELAY8, 50,  // .kbv will power up with ONLY reset, sleep out, display on
            0x28, 0,            //Display Off
            //            0xF6, 3, 0x01, 0x01, 0x00,  //Interface Control needs EXTC=1 MX_EOR=1, TM=0, RIM=0
            0xB6, 3, 0x0A, 0x22, 0x27,  //Display Function [0A 82 27] ILI9329: REV=0, SS=1
            0x11, 0,            //Sleep Out
            TFTLCD_DELAY8, 150,
            0x29, 0,            //Display On
            0x3A, 1, 0x55,      //Pixel read=565, write=565
        };
        init_table(ILI9329_regValues, sizeof(ILI9329_regValues));
        break;

and change the 0xB6 line to:
Code: [Select]

            0xB6, 3, 0x0A, 0x32, 0x27,  //Display Function [0A 82 27] ILI9329: REV=0, SS=1, SM=1

if you do not get any difference,  try this :
Code: [Select]

            0xB6, 3, 0x0A, 0x02, 0x27,  //Display Function [0A 82 27] ILI9329: REV=0, SS=0, SM=0

does the text become mirrored?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ylph on Apr 18, 2016, 03:15 am
Thanks for trying to figure this out btw.

I tried 0x22, 0x32 and 0x02 on that line, but don't see any difference - text is not mirrored in either case.

As a test I also tried interlacing the y coordinate in the drawPixel method, and that did make all the tests that rely on drawPixel work correctly across the whole screen - so the shield could be somewhat usable already - although drawing everything pixel by pixel might not be optimal.  Not sure if such approach would work for fillRect or for writing text, etc.

I assume if the controller could be identified, there should be some interlacing/de-interlacing support built in ?

Thanks again !
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 18, 2016, 08:39 am
Since you get no reaction to changes in the 0xB6 register it means.
1.   it is an Ilitek controller with EXTC=0 i.e. extended commands disabled in hardware.
2.   it is NOT an Ilitek controller.    Other makers use different Panel Configuration registers.

If I knew the make and ID,   I could find the necessary information from its data sheet.

Since there seems to be little response from reading registers it could be another make with a different method of disabling/enabling extended commands.

Where are you in the world?   Where did you get your shield?   Could you mail it to me?   (I could mail you a known working shield)

There is no guarantee that an Ebay seller would send me the same item that you received.  
It is a lottery.    I am happy to buy one but I do not know what I get until it arrives through my front door.
Very often it has a different pcb, colour,  shape,  controller, ... to the Ebay photo, description.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: mnaddeo on Apr 19, 2016, 03:41 pm
Hi David, great library, it works perfect on my Arduino Mega and TFT ili9488.

I would like to ask you if there is any info about the library functions and a description of each function, like in this link of an lcd display http://www.arduino.cc/en/Reference/LiquidCrystal.

Thanks a lot!!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 19, 2016, 05:02 pm
No,   I have never written any docs.   Most method()s are pretty obvious.
MCUFRIEND_kbv extends the Adafruit_GFX class which itself extends Print class.

So you can print anything that any other Arduino class can print.  e.g. float, int, char, String, ...
Print transparently or overwrite with a fresh background.    Format in hex,  float precision.
Set cursor position,  text colours,  text size, text fonts, ...

Lines,  rectangles, circles, triangles, ... and other graphic shapes.

My class adds very few new methods e.g. readID(), readReg(), setAddrWindow(), pushColors(), readGRAM(), vertScroll()

I suggest that you look carefully at the graphictest_kbv Demo.  Then study how a rounded rectangle or software scroll is programmed.  Or how an icon is drawn from a table in Flash memory.

These controllers all have the ability to specify an "Address Window".    You can then fill this window with a single colour or different coloured pixels from a photo or bitmap.    This is about 6x faster than drawing each pixel at its own x,y location.

David.

p.s. the new Adafruit_GFX library supports Adafruit_GFX_Button class and variable glyph Fonts.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zgoda on Apr 20, 2016, 11:15 am
Mine has "ili9481 for Mega2560" printed on pcb, Aliexpress seller advertized it as "ili9486 for UNO" and it identifies itself as ID = 0x404 in graphictest_kbv output. ReadReg:

reg(0x0000) 0C 0C   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 0C 0C 0C 0C   Manufacturer ID
reg(0x0009) 0D 0D 0D 0C 0C   Status Register
reg(0x0061) 65 45   RDID1 HX8347-G
reg(0x0062) 66 66   RDID2 HX8347-G
reg(0x0063) 67 67   RDID3 HX8347-G
reg(0x0064) 64 64   RDID1 HX8347-A
reg(0x0065) 65 65   RDID2 HX8347-A
reg(0x0066) 66 66   RDID3 HX8347-A
reg(0x0067) 67 67   RDID Himax HX8347-A
reg(0x00B0) B4 B4   RGB Interface Signal Control
reg(0x00B4) B4 B4   Inversion Control
reg(0x00B6) B6 B6 B6 B6 BF   Display Control
reg(0x00B7) B7 B7   Entry Mode Set
reg(0x00BF) BF BF BF BF BF BF   ILI9481, HX8357-B
reg(0x00C0) 4C 4C 4C 0C 04 04   Panel Control
reg(0x00CC) 4C 4C   Panel Control
reg(0x00D0) 54 54 54   Power Control
reg(0x00D2) 56 56 56 56 0C   NVM Read
reg(0x00D3) 5F 5F 5F 5F   ILI9341, ILI9488
reg(0x00DA) 5E 5E   RDID1
reg(0x00DB) 5F 5E   RDID2
reg(0x00DC) 54 54   RDID3
reg(0x00EF) EF EF EF 85 04 04   ILI9327
reg(0x00F2) F6 F6 F6 04 04 04 07 77 77 57 04 04   Adjust Control 2
reg(0x00F6) F6 F6 F6 F6   Interface Control


graphictest_kbv does not display anything, display is all gray/white (this means uninitializded I guess?), nothing is printed on serial except ID.

Typical Chinese business, advertize one, sell another, take money and hit the road. I would be mad if it did cost any penny more than random cheeseburger.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 20, 2016, 12:03 pm
It is quite simple.    You count up the male pins on your shield and you count up the female sockets on a Uno.

If you have got more males than females,   the shield can not work with a Uno.

If the Sale photos showed a MEGA2560 shield,   it is your own fault.
If the Sale photo showed a Uno shield and you received a completely different Mega shield,    ask AliExpress for your money back.

The library and the readreg sketch clearly say that they are for a UNO.
You can run a Uno shield on a Mega but you can't run a Mega shield on a Uno.

I am sure that your MEGA shield will work just fine with TFT_HX8357 or UTFT libraries.
Post a link to the actual Sale item.   Explain which pictures are accurate and what text is inaccurate.

Many of these Chinese vendors have no idea what they are selling when it comes to Electronics.   They may be very knowledgeable about Lingerie.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: mnaddeo on Apr 21, 2016, 05:34 pm
Thanks for your answer, I will look this file to lear how to use the library.

Thanks a lot for this library!!

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: usmanabdul128 on Apr 24, 2016, 09:30 am
please help me, where i can found 3,95 Inch TFT Lcd FOr Arduino??
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Apr 24, 2016, 06:09 pm
This is a link to a 3.95" TFT LCD from Ali Express.  I am having heaps of trouble with Ali Express so take care.... The 3.95" is NOT available from eBay   :(

http://www.aliexpress.com/item/Free-shipping-LCD-Display-Module-TFT-3-5-inch-TFT-LCD-screen-for-Arduino-UNO-R3/1883183749.html

The link works even though it says "3-5-inch"
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RCTractorGuy on Apr 25, 2016, 08:19 pm
Hi David,

I have the red PCB 2.4" touchscreen TFT with mcufriend written on it and I'm using an Arduino UNO with your library. I have used your library with other versions of this TFT no problem but I got some new ones today which give exactly the same results as user ylph was getting in post #305 and #307. I too tried your suggestions from post #311 and did not see any change.

I was just wondering if you had any ideas since?

Also the bags my modules came in have two numbers on them ZC13500 which I think is just the part number of the screen and 20630218 which I assume is just a reference number the seller uses. I'm just telling you in case they are useful but I'd guess they are no help.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 25, 2016, 08:42 pm
Ylph has mailed me a shield.    I am expecting it to arrive tomorrow or Wednesday.    ( if California to England works ok)

No,   I have no ideas at the moment but at least it will be a lot easier with the real thing on my desk.

I am gobsmacked by the sheer range of 2.4" controllers.    I am convinced that this is due to different panels becoming surplus in China.    They just use whatever is available and it appears on Ebay.   

I would be a lot happier if they used 74VHC245 chips and not 74HC245.    But hey-ho,    the shields work and they are certainly cheap!!

The 2.4" shields seem to survive China Post better than the bigger 3.5 or 3.95 panels.    Cracked Touch Panels will never work.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RCTractorGuy on Apr 25, 2016, 09:15 pm
That's great, hopefully it gets there okay. If not I have a few and I could send one over from Ireland which should get there okay.

I actually just took apart a cracked one which didn't survive the journey here to see if there was any identifying numbers behind the screen. Again doubt these numbers are useful but printed on the shielding behind the screen there is XYL824572-2201Yl, TX02400304-00 and also a date 2013/09/25. I actually taught they'd have been much older than that. Also on the pcb beneath the screen was 02323E_P139-14.

I'll keep an eye on the thread to see if you have any progress, fingers crossed you can crack it. Thanks for all the work you've done already by the way, your library has already been a great help to me with other screens in the past.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Apr 26, 2016, 02:22 am
Hi David

I'm glad to say I eventually changed my slideshow to use

Code: [Select]
#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

The sketch was using Bodmer's libraries on my BangGood 3.2" screens.

It was the most difficult library replacement I have done. The sketch has used about 6 different libraries in its' travells....  :)

I kept getting errors I couldn't explain. Eventually I got some "printing" to work.

The final stumbling block was realising that most of my problems were Hard & Soft SPI!!!!!!!!!!!!!

Once I changed MOSI, MISO, CLK & CS in SdFat everything fell in place.

I still can't display JPG pictures as there are 3 "pushColors" and one STILL gets rejected by the compiler as "ambiguous"   :(

Code: [Select]
tft.pushColors(pImg[2] >> 3 | (pImg[1] & 0xFC) << 3 | (pImg[0] & 0xF8) << 8, 1, 0);

I will slowly work it out   ;)    C++ newbie   :)

I will now attempt the change/replacement in my main sketch   :D

I thought I would try to point out the problem for anyone else who is going from a BangGood 3.2" ILI9481 display to and Ali Express 3.95" ILI9488   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Cololeo on Apr 28, 2016, 04:21 am
Apparently I have the same display as Ylph.  The resisters match perfectly.  All of the graphics test programs that I have run, run perfectly except for the two landscape screens on a portrait display.  The paint program uses the whole screen properly, but displays on the smaller parts.  I also tried the changes to MCu***.cpp with no effect.  I will continue to watch this thread.

I originally bought the UNO to set up a system to photograph water drops, which works much better than I expected.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Apr 28, 2016, 02:27 pm
I wonder if I can get some help here?   ;)

I want to copy 2 rectangles off a displayed screen....  They are the background behind the MM (minutes) and the SS (seconds) digits of a digital clock display.

I want to use "transparent" printing so I have to handle my own repainting of the background.  I assume I can copy from GRAM to SRAM with the readGRAM method and put it back with the pushColors after a setAddrWindow. So that is what I coded but the display remains BLACK after the pushColors????

I extracted the skeleton of my sketch from "readpixel_kbv" then paint random pixels in a rectangular format then "copy" readGRAM then clear the screen then setAddrWindow then pushColors but the screen remains blank after the clearScreen.

Have I misunderstood readGRAM or pushColors or setAddrWindow?

Thanks in anticipation

Here is my full "TEST" sketch....
Code: [Select]

/* Skeleton from readpixel_kbv */

#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

unsigned short minutes[12800];//different definitions
uint16_t seconds[12800];      //in case it mattered?

uint16_t g_identifier;

void setup(void) {
  tft.reset();
  g_identifier = tft.readID();
  tft.begin(g_identifier);
  tft.setRotation(1);
  tft.fillScreen(0x0000);
}

void loop() {
  int cy = 479;
  for(int z = 0; z < 160; z++) {
    for(int c = 0; c < cy; c++) {
      tft.drawPixel(z + c, z, random(0xFFFF)); //Top LHS
      if (c < (cy - 160)) tft.drawPixel(479 - z, z + c, random(0xFFFF)); //Top RHS
      tft.drawPixel(479 - z - c, 319 - z, random(0xFFFF)); //Bottom RHS
      if (c < (cy - 160)) tft.drawPixel(z, 319 - z - c, random(0xFFFF)); //Bottom RHS
    }
    cy -= 2;
  }
  delay(500);
  tft.readGRAM(176, 130, minutes, 128, 100);//copy rectangle behind "minutes"
  tft.readGRAM(340, 130, seconds, 128, 100);//copy rectangle behind "seconds"
  tft.fillScreen(0x0000);
  tft.setAddrWindow(176, 130, 128, 100);
  tft.pushColors(minutes, 12800, 0);//copy minutes rectangle back?
  tft.setAddrWindow(340, 130, 128, 100);
  tft.pushColors(seconds, 12800, 0); delay(2000);//copy seconds rectangle back?
}

I tried ",0" & ",1" as the 3rd argument  :)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 28, 2016, 02:43 pm
The Adafruit pushColors() method uses 3 arguments.     The last argument signifies that it is the first call.
Normally you would be filling up a rectangle in several stages.  e.g. when reading blocks from an SD card.

Look at the software scroll example in the demo sketch.

You seem to be very profligate with memory.   You cannot afford a 25kB SRAM buffer on a MEGA2560.    It is tight on a Zero.     I know that you have a Due,   but not everyone is so lucky.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Apr 28, 2016, 03:57 pm
Thanks for your reply   :D

I could be wrong (newbie!) but there are three pushColors in "MCUFRIEND_kbv.cpp" and one in "Adafruit_TFTLCD.cpp" and none in "Adafruit_GFX.cpp" so which one is being "called"?

Did you mean example "scroll_kbv", no pushColors?

But I tried first = 0 and first =1 neither painted anything  :(  What's "up"?  ;)

I HAVE looked at pushColors in "graphictest_kbv" (is that the one you mean?) but no shoes dropped?  :(

It is actually 51Kb, 25,600 shorts/unit16_t. I wanted to use PROGMEM till I found out I can't write to PROGMEM   :(

BTW I also store the backgrounds under the semi colons too  ;)  But they are 128 bytes each so negligible....

I tried * and & but they didn't compile....   I told you!  NEWBIE!

The sketch I posted should run if you have and AliX (MCU 9488) screen and a Due.

Put me out of my misery. Please tell me what I'm doing wrong?  :)

I had one Mega, ordered 5 more, 4 arrived, one got refunded   :(

I have 3 Dues and I'm ready to order 6 more if I could find the R3-E variant.... because I think the background is so important to me   :)  For the 6 clocks I HOPE to make....
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 28, 2016, 05:13 pm
Sorry Louis,    I should really document the methods formally.

Here is your sketch as you intended:
Code: [Select]

/* Skeleton from readpixel_kbv */

#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

unsigned short minutes[12800];//different definitions
uint16_t seconds[12800];      //in case it mattered?

uint16_t g_identifier;

void setup(void)
{
    tft.reset();
    g_identifier = tft.readID();
    tft.begin(g_identifier);
    tft.setRotation(1);
    tft.fillScreen(0x0000);
}

void loop() {
    int cy = 479;
    for (int z = 0; z < 160; z++) {
        for (int c = 0; c < cy; c++) {
            tft.drawPixel(z + c, z, random(0xFFFF)); //Top LHS
            if (c < (cy - 160))
                tft.drawPixel(479 - z, z + c, random(0xFFFF)); //Top RHS
            tft.drawPixel(479 - z - c, 319 - z, random(0xFFFF)); //Bottom RHS
            if (c < (cy - 160))
                tft.drawPixel(z, 319 - z - c, random(0xFFFF)); //Bottom RHS
        }
        cy -= 2;
    }
    delay(500);
    tft.readGRAM(176, 130, minutes, 128, 100);//copy rectangle behind "minutes"
    tft.readGRAM(340, 130, seconds, 128, 100);//copy rectangle behind "seconds"
    tft.fillScreen(0x0000);
    tft.setAddrWindow(176, 130, 176 + 128, 130 + 100);
    tft.pushColors(minutes, 12800, 1);//copy minutes rectangle back?
    tft.setAddrWindow(340, 130, 340 + 128, 130 + 100);
    tft.pushColors(seconds, 12800, 1);
    delay(2000);//copy seconds rectangle back?
}

Note that the H file gives you some pretty good clues.    But I should be more explicit
x, y expect coordinates of a pixel location.   w, h expect a width and height of a rectangle.   
The compiler will use the pushColors(uint16_t *block, ...) variant because you have a block of uint16_t colours in SRAM.
Code: [Select]

 int16_t  readGRAM(int16_t x, int16_t y, uint16_t *block, int16_t w, int16_t h);
 void     setAddrWindow(int16_t x, int16_t y, int16_t x1, int16_t y1);
 void     pushColors(uint16_t *block, int16_t n, bool first);


I am following the Adafruit conventions.    I am sure that you could make a good argument for setAddrWindow() using width and height rather than coordinates.    Hey-ho,   I am stuck with this syntax.
Personally,   I find the Adafruit methods() more intuitive than UTFT methods()

Bodmer's pushColors() works differently.   His setWindow() sends the WriteGRAM command.   Hence he does not need a "first" argument.    I could have followed his style and used a setReadWindow() which sends the readGRAM command.   But this would be incompatible with other Adafruit libraries.

Regarding examples.   If you want to experiment with reading blocks of memory,   put something interesting in them.   Then draw them in a different place.

I am guessing that you intend to draw a MandelBrot as a background.    Once you have saved the rectangle(s),   you simply draw the saved rectangle before drawing the fresh Number on top.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Apr 28, 2016, 06:09 pm
Thanks David....

My fault (newbie) I assumed (x,y,w,h) instead of (x1,y1,x2,y2)  :)

I overwrote my sketch with yours and, of course, it worked   :D

No, the Mandelbrot is just one of the backgrounds....  I mainly intend to use family pictures stored on the micro SD card.  Pictures change every half hour or whatever?  :)

I can also do this copying when the picture is actually drawn by modifying the "bmpDraw"? But I would have to do this for "drawSdJpeg" and "rawDraw" routines too and I have to check which logic is faster?  readGRAM or "bmpDraw"?  Is readGRAM fast?  I suppose I can check myself?  :D

Thanks for your help   :D

All I have to do now is get the touch panel working, it'll be the way to control/change alarm etc of the clock.  The clock will also be personalized with birthdays and event days etc....  I know, every iPad, iPhone or Android can do this....   :)

After midnight so bed....

Thanks
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Snout on Apr 28, 2016, 07:12 pm
10. It currently supports UNO shields with "mcufriend.com" pcbs with controllers:
----- HX8347-A 240x320  ID=0x8347 new Untested
ILI9320  240x320  ID=0x9320
ILI9325  240x320  ID=0x9325
ILI9327  240x400  ID=0x9327
ILI9329  240x320  ID=0x9329
ILI9335  240x320  ID=0x9335
ILI9341  240x320  ID=0x9341
ILI9481  320x480  ID=0x9481 
ILI9486  320x480  ID=0x9486
ILI9488  320x480  ID=0x9488
LGDP4535 240x320  ID=0x4535
RM68090  240x320  ID=0x6809
R61505V  240x320  ID=0xB505
R61505W  240x320  ID=0xC505 new Untested
R61509V  240x400  ID=0xB509
----- S6D0139  240x320  ID=0x0139 removed due to lack of tester
S6D0154  240x320  ID=0x0154
SPFD5408 240x320  ID=0x5408
----- SSD1963  800x480  ID=0x1963 new Untested
SSD1289  240x320  ID=0x1289
ST7781   240x320  ID=0x7783
ST7789V  240x320  ID=0x7789


12. These Mcufriend-style shields tend to have a resistive TouchScreen on A1, 7, A2, 6 but are not always the same rotation of direction.
Run the TouchScreen_Calibr_kbv.ino sketch to diagnose your model and then scale the result from TouchScreen.h methods()

Question about weird colors:
I have an Mcufriend 3,6" display, 320x480 resolution, and touchscreen works when set to
#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

Some background: When using Adafruit's TFTLCD library, the tftpaint2 program _only_ shows white background and yellow pixels for everything, regardless of what color is supposed to be shown.
Also the Y axis (0-480) of the touchscreen is inverted. But the icons marked 1 through 8 show up okay (though yellow). To get around that I just added 'p.y = 480 - p.y;' after the mapping.

When I replaced
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
with
MCUFRIEND_kbv tft;
the screen looked a bit better, in that it now shows black background and blue foreground.
However all the icons 1 through 8 are inverted, also the touchscreen X _and_ Y axes are both inverted. (So that if I draw towards the lower-left, the drawn pixels move towards the upper-right.)
tftpaint2 (with MCUFRIEND_kbv) says it doesn't recognize the chip, so I force it to init with 0x9481.

graphicstest_kbv, now there's the interesting bit. It recognizes the 9481 chip, but the colors are messed up or missing. See the attached image. Blue seems to work okay, since it wants to draw a _lot_ of blue. But the pictures 'GREEN BARS' and 'RED BARS' are both greenish-blue in the beginning, and then go towards blue. So it's not the photo that's off, the colors on screen are actually all shades of mostly blue.

In the image is also a photo of the display itself, seen from the underside where "mcufriend" and "(9481)" is shown.
In the ebay listing, they said that it was another chip, and in the listing itself some test code was listed, like so:
Tftlcd 3.6-inch touch screen with uno r3
3.6-inch LCD touch screen
Resolution : 480x320
Controller : ili9488
Test code:
ILI9327:
LCD_Write_COM(0xE9);
LCD_Write_DATA(0x20);
LCD_Write_COM(0x11); //Exit Sleep
[...]
(from the item listing http://www.ebay.com/itm/111687922300?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT)

Telling the mcufriend_kbv library to use chip 9488 didn't work at all though. And it's odd that their 'test code' is marked ILI9327. gaaah.

Any input on how come this display is so very happy in showing either yellow-on-white (with Adafruit TFTLCD) or blue-on-black (with mcufriend_kbv)?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 28, 2016, 07:44 pm
Please run the LCD_ID_readreg sketch and paste the Serial output to your message.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Snout on Apr 28, 2016, 07:50 pm
Doh! Certainly, here it is:

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) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 00 00 00 00   Status Register
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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 02 04 94 81 FF   ILI9481, HX8357-B
reg(0x00C0) 00 10 3B 00 02 11   Panel Control
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 43   Power Control
reg(0x00D2) 00 01 22 00 00   NVM Read
reg(0x00D3) 00 01 22 00   ILI9341, ILI9488
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
reg(0x00EF) 00 00 00 00 00 00   ILI9327
reg(0x00F2) 00 00 33 00 00 00 00 00 00 00 00 00   Adjust Control 2
reg(0x00F6) 00 80 80 80   Interface Control

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Snout on Apr 28, 2016, 08:00 pm
As a quick comment, like so many others have said, great library you've done! It's the only one that lets me use my display usefully.

Footnote: Since I'm only going to use it to draw symbols that can be pushed, working touch and blue-on-black really -is- good enough for me, but, y'know.. it's always neat to have things fully working. And I've only had it a day so far, so I don't know if it'll do like a couple of Sainsmart displays and stop working with white screen after a couple of days - I blame crappy soldering on those. (One also had a broken touch resistor connector, that could be fixed with conductive glue carefully pressed in between the top layers of the screen, using a ceramic knife edge to veeeery carefully opening up enough to get the thin glue-syringe needle in.)

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Snout on Apr 28, 2016, 08:19 pm
Another picture to attach: This shows the screen -just- after the 'grey' (well, blue) bars have scrolled upside down on the screen, and after this yellow-on-white the graphics demo restarts. So whatever it does in that final about two seconds long pause shows off that it's capable of displaying white and yellow (with some slightly reddish-pink text, that has me thinking that the "red" portion of the display is working aswell, technically. Just not the way the software expects it.)

Also of note is how the icon looks, I'm fairly sure that's not how it's inteded to be. If so, perhaps related to Adafruit's tftpaint2, where the 'chip so and so' text shows up okay, but the 1-8 icons were flipped. I'm out of my depth here, so I'll just throw out the guess that it's got something to do with how a memory chunk (the image) is transferred to the display, that somewhere in there is a misunderstanding between software and controller.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 28, 2016, 08:33 pm
You clearly have a genuine ILI9481 controller.
Yes,  I would like to get this working for you.

The first step is to delete the current library and re-install a fresh download copy.
You seem to have no RED at all.

Does anyone else have a problem with this Shield?
I only own a 16-bit write-only ILI9481.   So I have to rely on remote reporting.

The brief "yellow on white" is COLOUR INVERSION.    i.e. tft.invertDisplay(true)

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Snout on Apr 28, 2016, 08:42 pm
I think I already had the latest, but now I've re-downloaded mcufriend_kbv and re-opened graphictest from it. Still the same blue on black, but now with being sure that it's the latest library. :)

I use the arduino-1.6.6 official linux IDE, if that helps. Are there other libraries I should reinstall that can be of importance, like Adafruit stuff or suchlike.. anything that the program uses that isn't already in mcufriend_kbv?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 28, 2016, 09:40 pm
I think that Bodmer's TFT_HX8357 library supports the 8-bit data bus now.    You will need to read the configuration instructions.

I am not at my PC to check.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Snout on Apr 28, 2016, 10:25 pm
I'll have a look at it, thanks! So far, the compiler gives a ton of errors on the form DDRA, PORTC, PORTG etc "not declared in this scope". *reads* Ahh. In User_Setup.h it says "This library supports the Mega and HX8357B/C display drivers only", but it has a define for ILI9481. Luckily I have a Mega, so I can try connecting that, once I find in the code what Mega pins go to what Uno-display pins.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Apr 29, 2016, 01:58 am
My fault (newbie) I assumed (x,y,w,h) instead of (x1,y1,x2,y2)  :)

I overwrote my sketch with yours and, of course, it worked   :D
JFYI David, The co-ordinates in the setAddrWindow have to be inverted (x2,y2,x1,y1) otherwise the cutouts are inverted when put back.

The 2 readGRAMs took 88832 microseconds  :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Raprap on Apr 29, 2016, 02:31 am
Hi guys! I need some help, I bought a 3.95" TFT LCD from aliexpress the one that says ILI9488. Its a shield for the Mega. But none of the drivers I try work.

I already bought one of these before and got it working smoothly with the UTFT library, so I was confident I could get another to work. But what arrived was different from before, I don't know if the pins are different or its just broken.

I've tried almost all the ILI drivers, as well as the R61581, for UTFT with pins (38,39,40,41), tried the MCUFRIEND_kbv library, the TFT_HX8357-master. All seem to give me white screens. There are no physical deformations as far as I can see.

I've attached the image of the lcd (the one I currently have is the one on the right).

And here's the dump from the test readreg

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) 04 04   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 04 04 04 04   Manufacturer ID
reg(0x0009) 05 05 05 05 05   Status Register
reg(0x0061) 65 65   RDID1 HX8347-G
reg(0x0062) 66 66   RDID2 HX8347-G
reg(0x0063) 67 67   RDID3 HX8347-G
reg(0x0064) 64 64   RDID1 HX8347-A
reg(0x0065) 65 65   RDID2 HX8347-A
reg(0x0066) 66 66   RDID3 HX8347-A
reg(0x0067) 67 67   RDID Himax HX8347-A
reg(0x0070) 74 74   Panel Himax HX8347-A
reg(0x00A1) A5 A5 A5 A5 A5   RD_DDB SSD1963
reg(0x00B0) B4 B4   RGB Interface Signal Control
reg(0x00B4) B4 B4   Inversion Control
reg(0x00B6) B6 B6 B6 B6 B6   Display Control
reg(0x00B7) B7 B7   Entry Mode Set
reg(0x00BF) BF BF BF BF BF BF   ILI9481, HX8357-B
reg(0x00C0) 4C 4C 4C 4C 4C 4C   Panel Control
reg(0x00CC) 44 44   Panel Control
reg(0x00D0) 5C 5C 5C   Power Control
reg(0x00D2) 56 56 56 56 56   NVM Read
reg(0x00D3) 57 57 57 57   ILI9341, ILI9488
reg(0x00DA) 5E 5E   RDID1
reg(0x00DB) 5F 5F   RDID2
reg(0x00DC) 54 54   RDID3
reg(0x00EF) EF EF EF EF EF EF   ILI9327
reg(0x00F2) F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6   Adjust Control 2
reg(0x00F6) F6 F6 F6 F6   Interface Control

Any help is greatly appreciated. I was up all night trying to find the right drivers and scrounging aliexpress for comments on which drivers worked for it.

Thanks!


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 29, 2016, 07:44 am
When did a Uno get pins 22-53 ?

Your shield could NEVER fit on a Uno.    So your readreg output is meaningless.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Rendisha on Apr 29, 2016, 05:04 pm
Hello David, thanks for your great work.

I've bought 3.5" mcufriend for UNO that says 9481 at the back but tests reveal that it's actually 9486. Right from the start it looked weird and I realized that (among other things) colors were inverted but found your advice how to fix it and it's OK now. Managed to get touchscreen working too.

What's wrong is that output is always a bit screwed up and if you know is it bad display / controller or maybe UNO clone acting up... Background renders solid but "overlays" like fonts, lines... always have some pixels missing or at the wrong place and after screen refreshes it's always a bit different. For example, in your sample test, filled circles overlaid over each other have streaks of vertical lines displaced, rectangles inside rectangles have some sides missing etc... Does it look familiar, some timing issues or simply bad luck with TFT shield :)

Forgot to mention - readpixel_kbv.ino gives away mostly 0000's with some FFFF's at random places and they don't look like repeating in the same manner when output rotates.

Thanks again!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 29, 2016, 06:16 pm
It sounds as if there are timing problems if you get some missing pixels.    Very possible with Due or Xmega.    Almost impossible with a Uno.

There are two "types" of writing to the TFT.  
1. drawPixel() which sets x, y, color every time.   e.g. Fonts,  circles, angle lines.
2. fillRect() which sets a window and only colors are sent.

A horizontal or vertical line is simply a "thin" fillRect().
Your glitches are in the type (1) writes.

Please watch your screen and report whether you have any problems with (2).

Oh,   look carefully at readpixel_kbv display e.g. at an oblique angle.    Those FFFF are the white pixels that show the 4 in ID=0x9486, followed by the 0, 1, 2 that appear directly below that 4.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Rendisha on Apr 29, 2016, 07:50 pm
Damn, I barely wrapped my head around that readpixel stuff :) Well, even those numbers most of the time look somewhat broken - smeared. 4 probably looks the best, 0 and 1 are sometimes unreckognizable with "pixels" moved to the left or right. And small fonts that these big images are made of are also with quite a bit of "pixel defects" with some rendered OK. Background sometimes gets partially updated so screen gets divided on two black & blue fields...

With graphictest_kvb for example, in scroll test, it draws fonts a bit crooked and color grading bar usually with some bands missing, icon looks OK (but sometimes only a single or couple lines of it get drawn) and all content of that screen scrolls unchanged (with all the defects made from the start) and with no glitches. But when it stops and you have single line scroll - that one turns in just a stream of pixels. Also getting message: readpixel should be 24-bit. Sometimes text after rapid background color changes stays on and "rays" start drawing over it.. So, completely erratic behaviour.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 30, 2016, 12:49 pm
Seriously,   I think that your controller is defective.   Or perhaps there is a bad soldered joint.

I really can't see how a Uno can have timing problems.   The WR_STROBE takes 4 cycles = 250ns.

The Write Cycle tWC=66ns for ILI9486 and tWC=50ns for ILI9486L.    tWC=100ns for a ILI9481.   tWC=30ns for a ILI9488.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 30, 2016, 12:56 pm
I think I already had the latest, but now I've re-downloaded mcufriend_kbv and re-opened graphictest from it. Still the same blue on black, but now with being sure that it's the latest library. :)

I use the arduino-1.6.6 official linux IDE, if that helps. Are there other libraries I should reinstall that can be of importance, like Adafruit stuff or suchlike.. anything that the program uses that isn't already in mcufriend_kbv?
I suspect that you have a defective controller.    I can't think of any reason for "blue" display.
Of course,   if someone else has the same symptoms,  then it is likely to be a problem with my library code.

I use the v1.6.6 IDE on Windows.   The library will not compile for "older" than v1.6.5.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Apr 30, 2016, 04:54 pm
Pardon my interruption  :(

I have a funny one with printing text with MCUFRIEND_kbv and Adafruit_GFX and the "print" class(?) with fonts. I THINK there is a bug but I haven't a clue with which library?

If I print text using the default font with a setCursor it goes on the screen.

If I then print text with a nominated font and the same setCursor value it goes somewhere else?

Please see (and run) the attached code below....

Code: [Select]
/* Skeleton from readpixel_kbv */

#include <Adafruit_GFX.h>
#include <Fonts\FreeMonoBold24pt7b.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

// Color set
#define BLACK           0x0000
#define WHITE           0xFFFF

void setup() {
  static uint16_t g_identifier;
  tft.reset();
  g_identifier = tft.readID();
  tft.begin(g_identifier);
  tft.setRotation(1);
  tft.setTextColor(WHITE, WHITE);
}

void loop() {
  tft.fillScreen(BLACK);
  tft.setFont();//Default font
  tft.setTextSize(10);

  tft.setCursor(2,130);
  tft.print("Text");

  delay(1000);
 
  tft.setFont(&FreeMonoBold24pt7b);
  tft.setTextSize(2);
 
  tft.setCursor(2,130);
  tft.print("More");
 
  delay(2000);
}

I am using an AliX 9488 screen on a Due. Granted I'm using different text sizes but that shouldn't make a difference?

I hope it isn't a misunderstanding on my part (newbie!)....   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Apr 30, 2016, 06:10 pm
Louis,

The Adafruit_GFX site explains how the legacy "system" font is drawn from the top line.
The Free Fonts are drawn from the base line.    And descenders will project below the base line.

They are drawn as Glyphs which means that one letter might be made up from several rectangles.    This makes it a nightmare to calculate where to re-draw some background.    If you have a W followed by an A,   the letters can move closer together.

Most Fonts used by other libraries have a fixed height and variable width.    One letter fits in a single rectangle.    Regular fonts look good.  Ok,   this style is not so good for italics.

UTFT supports multiple fonts but they are all monospaced.    (and I think have restrictions on the width)

Quite honestly,    Fonts should be a no-brainer.   e.g. we could all use the same format to describe and render variable width fonts.  
Unfortunately everyone seems to do things differently.

I am loath to alter the Adafruit conventions.    But I cerainly wish that Adafruit had thought things through properly.     Perhaps they will improve in the future.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 01, 2016, 01:20 am
Thanks for your response David   :)

As usual it (the response) was very informative and complete.  :D

I did further experiment by drawing a line at (0,130) (using drawRect, no drawLine method as such?) and saw it went between the two sets of text.

I also did check the Adafruit GFX description document, html and pdf, (the only one I found) but it was very vague about bitmaps and fonts   :(   Maybe there is a better explanation but I didn't find it   :(

I was also surprised that even with three variants of drawBitmap there wasn't one I was used to (in UTFT)?  :(  I can't quite wrap my head around pushColors :(  My usual puzzlement with "*" and "&" in C++    :smiley-roll-sweat:

As I mentioned before, there is a "pushColor" "call" I can't seem to convert to "pushColors". It is in rendering a JPG....

Code: [Select]
      while (count--) {// Push all MCU pixels to the TFT window
        // The pImg [B]lue, [G]reen and [R]ed  8 bit array values are converted to 5+6+5 [B]+[G]+[R] 16 bit format)
        tft.pushColor(pImg[2] >> 3 | (pImg[1] & 0xFC) << 3 | (pImg[0] & 0xF8) << 8);
        pImg += JpegDec.comps;// Fetch the next decoded pixel
      }


It is just a snippet of code, not intended for running, just an explanation please. It is NOT my code, just a routine I found in an example somewhere  :)

As always, thanks for your help   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 03, 2016, 01:36 pm
I don't want to push but any response David?

I've worked out how much (background) I have to save   :)

If I change the picture every minute then I'll only have to save the "seconds" background 6528 "short" but still too much for a Mega   :(  So I might as well save the "minutes" background too. The Due will have more than enough SRAM.

Almost everything works with "BMP's" but I would prefer JPGs as there is less to transfer from the micro SD card. The same picture as a BMP is 450Kb and as a JPG is 35Kb so it is WAY more efficient as a JPG.

So it would be nice to get the "pushColors" in the JPG rendering routine working   :D

Will also have to work out what to do with the I2C RTC needing A4   :(
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 03, 2016, 03:07 pm
Louis,

I do not see a problem.   The two libraries have slightly different syntax.    That is all.
Bodmer's code in TFT_flash_jpeg_v2:
Code: [Select]

        if ((mcu_x + mcu_w) <= tft.width() && (mcu_y + mcu_h) <= tft.height())
        {
            // Now set a MCU bounding window on the TFT to push pixels into (x, y, x + width - 1, y + height - 1)
            tft.setWindow(mcu_x, mcu_y, mcu_x + mcu_w - 1, mcu_y + mcu_h - 1);

            // Push all MCU pixels to the TFT window
            uint32_t count = mcu_pixels;
            while (count--) {
                // Push each pixel to the TFT MCU area
                tft.pushColor(*pImg++);
            }
        }
        else if ((mcu_y + mcu_h) >= tft.height()) JpegDec.abort(); // Image has run off bottom of screen so abort decoding

xxxx_kbv code:
Code: [Select]

        if ((mcu_x + mcu_w) <= tft.width() && (mcu_y + mcu_h) <= tft.height())
        {
            // Now set a MCU bounding window on the TFT to push pixels into (x, y, x + width - 1, y + height - 1)
            tft.setAddrWindow(mcu_x, mcu_y, mcu_x + mcu_w - 1, mcu_y + mcu_h - 1);  //.kbv
            bool first = true;                    //.kbv flag to send the cmd(0x2C) as a one-off
            // Push all MCU pixels to the TFT window
            uint32_t count = mcu_pixels;
            while (count--) {
                // Push each pixel to the TFT MCU area
                uint16_t color = *pImg++;         //.kbv single buffer
                tft.pushColors(&color, 1, first); //.kbv diff syntax
                first = false;                    //.kbv reset the flag
            }
        }
        else if ((mcu_y + mcu_h) >= tft.height()) JpegDec.abort(); // Image has run off bottom of screen so abort decoding


I have asked you many times.    If you want to see how to do something,   just say which Bodmer example you want to see.    Likewise,   you might want to see how to adapt a UTFT example.

Your earlier question asked about reading a block of memory.   I can assure you that reading a RAW image from SD card or Flash memory will be faster than doing a JPEG.     And think about it.    No one has shown you how to read a Mandelbrot area,   compress it into a JPEG file.    Then read and uncompress whenever you write to your clock display.

Incidentally,   there is a primitive "TFT_HX8367GLUE.h" class in the v2.8 library.
Many of Bodmer's examples will run if you just replace his include and constructor with the GLUE.
No,  it is NOT perfect.   But if you quote a Bodmer example,   I am happy to test it.

Why should an I2C RTC need the A4 pin with a Due or Mega?
You will just use the regular SCL, SDA header pins.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 03, 2016, 04:02 pm
Thanks David

Hope to catch you before you retire (to bed I mean)

I'm trying to use PURE MCUFRIEND_kbv and Adafruit_GFX avoiding any GLUEs   :D

I see your solution uses BOTH "*" AND "&"  I never tried THAT  ;)

I thought A4 & A5 WERE I2C pins!?  I used them with the BangGood screens happily so I assumed A4 & A5 are universal??  On ALL Arduinos??

Oops, You're in the afternoon   :D

Are you saying that rendering a 450Kb BMP would be faster than rendering the SAME but 35Kb JPG??  I THOUGHT it would be quicker to read less from the SD card??
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 03, 2016, 04:17 pm
I haven't attempted to write my mandelbrots OUT because of the sheer time it takes a Due to draw one (about 700 seconds) plus I have no idea of the logic of writing a JPG from an Arduino (Due or otherwise).

I actually took my Mandelbrot sketch and ported it to VS2015 on my desktop, changed the 480x320 to 1920x1080 and changed the libraries etc. It runs (upscaled) on the desktop in 6 seconds   :D  and is VERY impressive on Full HD. I was thinking of doing it on a UHD 4K display but never got down to doing it   :(

Okay, I'm now going to embody your change and see if the JPG rendering works for me   ;)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 03, 2016, 04:56 pm
I'm sorry, I copied your modification and the resultant JPGs are blues & black   :(

This is MY starting code (Bodmer's??)

Code: [Select]
   if((mcu_x + mcu_w) <= tft.width() && (mcu_y + mcu_h) <= tft.height()) {
      // Now set a MCU bounding window on the TFT to push pixels into (x, y, x + width - 1, y + height - 1)
      tft.setWindow(mcu_x, mcu_y, mcu_x + mcu_w - 1, mcu_y + mcu_h - 1);
      uint32_t count = mcu_pixels;
      while (count--) {// Push all MCU pixels to the TFT window
        // The pImg [B]lue, [G]reen and [R]ed  8 bit array values are converted to 5+6+5 [B]+[G]+[R] 16 bit format)
        tft.pushColor(pImg[2] >> 3 | (pImg[1] & 0xFC) << 3 | (pImg[0] & 0xF8) << 8);
        pImg += JpegDec.comps;// Fetch the next decoded pixel
      }
    }
    else if ((mcu_y + mcu_h) >= tft.height()) JpegDec.abort(); // Image has run off bottom of screen so abort decoding
  }

whereas your starting code is....

Code: [Select]

        if ((mcu_x + mcu_w) <= tft.width() && (mcu_y + mcu_h) <= tft.height())
        {
            // Now set a MCU bounding window on the TFT to push pixels into (x, y, x + width - 1, y + height - 1)
            tft.setWindow(mcu_x, mcu_y, mcu_x + mcu_w - 1, mcu_y + mcu_h - 1);

            // Push all MCU pixels to the TFT window
            uint32_t count = mcu_pixels;
            while (count--) {
                // Push each pixel to the TFT MCU area
                tft.pushColor(*pImg++);
            }
        }
        else if ((mcu_y + mcu_h) >= tft.height()) JpegDec.abort(); // Image has run off bottom of screen so abort decoding


the MAIN difference is....

Code: [Select]
tft.pushColor(pImg[2] >> 3 | (pImg[1] & 0xFC) << 3 | (pImg[0] & 0xF8) << 8);
AND
tft.pushColor(*pImg++);


So I thought I should just go to the latest drawBitmap.ino but I couldn't find it anywhere   :(

Sorry, I hope I'm making sense?  Trying to get it done before I fall asleep at the keyboard   ;)

Edit: Okay I found where MY copied original routine came from....

c:\Program Files (x86)\Arduino\libraries\JPEGDecoder\examples\TFT_draw_jpg_v4\

Edit AGAIN:-  Panic over....   I put the "bool first = true;" and "first = false;" into my working version and it is NOW working

Conclusion....  Rendering a JPG and the same picture as a BMP - JPG is about 4 times faster   :D  Impressive   :D

Thanks for your help  :D

Bed   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 05, 2016, 08:16 am
Got another AliX 3.95" screen, completely undamaged this time   :)

BUT it is darker and flickers AND, surprisingly, it is upside down when compared with my previous AliX screen. That is, the new one Rotation(1) is equal to the other screen Rotation(3). How good is THAT!? NOT!

Will test the touch screen after babysitting   :D

BTW, Have seen that I2C is pins 20 & 21 (on Due AND Mega)   :D   :D   :D  So no clash with A4 (& A5)   :D

My RTC was happy using A4 & A5 though So I hope it takes to 20 & 21??
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 05, 2016, 08:47 am
Louis,

We have no idea which 3.95" shield(s) you have.

If it is a Uno shield,   the ID can be read.     The Vendor often provides wrong information.    The ID does not lie.    I am keen to support  as many Uno shields as I can.

If it is a Mega shield (lots more pins),   they are write-only.    You just have to guess which controller it might be.   e.g. ILI9481, ILI9486, ILI9488, ...
Yes,   I can do some diagnosis by writing to a manufacturer register that is different.    Since these might be hardware protected,    it is not quite so easy.

I am pleased that you have finally found a Vendor that supplies unbroken screens.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 05, 2016, 10:11 am
These ones....

http://www.aliexpress.com/item/3-5-inch-TFT-Touch-LCD-Screen-Display-Module-For-Arduino-UNO-R3-HIGH-QUALITY-Free/1854630609.html

Even though the link says "3-5 inch" they are, in fact, 3.95" 9488?

I never thought to test it out, I just assumed it was the same but different? I suppose that is the point of your library. Just plug it in and the library identifies the controller and accesses it correctly. 

Did you see that these AUD11 screens are NOW available on eBay for AUD173!?  Why do they bother!?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 05, 2016, 11:45 am
I opened your link.   The photos show exactly the same shield that I have.
Does your shield match the photos?

I have no idea what "AUD173" you are talking about.
The link says $8.50 US dollars.    Do the Australians have a currency crash?

Since your panel "looks" identical to mine,   I would expect it to behave like mine.   i.e. reports ID=0x9488,  steady picture with correct colours and no mirroring.

If something is different,  please describe what is different.   You should view PORTRAIT with the USB cable coming out of the top.

I am happy to fix an "accurately described" problem.
Likewise,  I am happy to help with any "official" example sketch.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 05, 2016, 12:32 pm
AUD = Australian Dollar.... The point was eBay was selling the A$11 screen for A$173.

If you have the same screen, did yours work "out of the box" with the touch screen examples. Because, try as I might, I could not get my touch to work. This is my 3rd screen so I hope it's touch works!? The first was a bit scratched but, otherwise, un damaged but the touch didn't work. The second had A hairline crack and it didn't work. The third is yet to be tested. 

Oops, I lost most of this reply because the forum doesn't recognise the smilies from my iPad....

Have shower a three year old now....   :D

YEAH! It IS a 9488 AND the touch screen works    :D   :D   :D

AND the rotation IS different to the other TWO AliX screens which are also 9488's   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 05, 2016, 01:47 pm
In which case,    please show the AliXpress link to the other shields.
Do the photos match real life?

The 2.4" shields have an almost infinite number of variations.    I am not aware of many 3.95" shields.
I would expect them to come from the same batch of surplus panels.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 05, 2016, 05:43 pm
I have attached a new MCUFRIEND_kbv v2.90 (http://forum.arduino.cc/index.php?topic=366304.msg2524865#msg2524865) library to message #1.
I have also updated the LCD_ID_readreg.ino sketch

The library should detect the R61520 controller in the recent "Split Screen" messages.
Please let me know if it creates any problems for existing controllers.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 05, 2016, 06:21 pm
Last link (repeated above)

http://www.aliexpress.com/item/3-5-inch-TFT-Touch-LCD-Screen-Display-Module-For-Arduino-UNO-R3-HIGH-QUALITY-Free/1854649569.html

First link....

http://www.aliexpress.com/item/3-5-inch-TFT-Touch-LCD-Screen-Display-Module-For-Arduino-UNO-R3-HIGH-QUALITY-Free/1854630609.html

Second link....

http://www.aliexpress.com/item/3-5-inch-TFT-Touch-LCD-Screen-Display-Module-For-Arduino-UNO-R3-HIGH-QUALITY-Free/1854630609.html

The first and second links appear to be the same as are the actual screens. They also have the touch panel inlet/outlet wires on the double 18 pin side.
They have LD101 and Q.F. 04104 on them, otherwise they look identical.

The last link (arrived yesterday but picked up today) also has the number LD101 on it but appears completely inverted. The touch panel inlet/outlet wires are on the USBs side (away from the dual 18 pin side). This probably is the reason for inversion of rotation.

ALL three have the micro SD slot away from the dual 18 pin side.

ALL three have identical  LCD_ID_readreg (below)

reg(0x0000) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 54 80 66   Manufacturer ID
reg(0x0009) 00 00 61 00 00   Status Register
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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 93 30 93 30   RD_DDB SSD1963
reg(0x00B0) 00 00   RGB Interface Signal Control
reg(0x00B4) 00 02   Inversion Control
reg(0x00B6) 00 02 02 3B 3B   Display Control
reg(0x00B7) 00 06   Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00   ILI9481, HX8357-B
reg(0x00C0) 00 0E 0E 0E 0E 0E   Panel Control
reg(0x00CC) 00 03   Panel Control
reg(0x00D0) 00 00 00   Power Control
reg(0x00D2) 00 00 00 00 0D   NVM Read
reg(0x00D3) 00 00 94 88   ILI9341, ILI9488
reg(0x00DA) 00 54   RDID1
reg(0x00DB) 00 80   RDID2
reg(0x00DC) 00 66   RDID3
reg(0x00EF) 00 00 00 00 00 00   ILI9327
reg(0x00F2) 00 58 04 12 02 22 22 FF 0A 90 14 88   Adjust Control 2
reg(0x00F6) 00 00 00 00   Interface Control

Once they are plugged into Dues they look identical (except for the rotation) and the third screen being noticeably darker....

Curious. I'm intrigued, don't know about you. HOPEFULLY I have another like no 3 coming but you can't tell with China Post.

Anything else I can tell you just shout   :D

Another post is waiting so I may have something else to say?

Edit:- The message was yours with a new library V2.90. I'll download it and have a quick look but it is half past midnight so I will have to give in and get some sleep. Till tomorrow   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: RCTractorGuy on May 05, 2016, 07:08 pm
The new library works for my screen on both an Arduino UNO and an Arduino Mega.

Are the pins marked LCD_D0 to LCD_D7 on the screen used by the library? I have an Arduino mega in a project with these pins and the SD pins wired differently which doesn't work with the library. I tried to find where they were defined in the library but didn't find any reference to them. LCD_RST, LCD_CS, LCD_RS, LCD_WR and LCD_RD are wired normally and I had this set up working with a different 0154 driver screen and the library I used before I found yours.

Screen -> UNO -> My Wiring
LCD_D0 -> 8 -> 22
LCD_D1 -> 9 -> 23
LCD_D2 -> 2 -> 24
LCD_D3 -> 3 -> 25
LCD_D4 -> 4 -> 26
LCD_D5 -> 5 -> 27
LCD_D6 -> 6 -> 28
LCD_D7 -> 7 -> 29

SD_SS -> 10 -> 48
SD_DI -> 11 -> 51
SD_D0 -> 12 -> 50
SD_SCK -> 13 -> 52
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 05, 2016, 07:17 pm
The library is designed for Shields.   You plug a shield into an Arduino and it goes.

Yes,  the Uno shields have SPI on 10-13.   If you plug into a Mega,  you must use <SdFat.h> bit-banged SPI on 10-13.

Does your display use a S6D0154 controller?   That should be able to do everythig a modern controller does.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bogdan68 on May 06, 2016, 09:45 am

david_prentice thanks for R61520 library , helped me a lot .
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 06, 2016, 10:04 am
It is fellow member ylph that you must thank.

He mailed the Shield to me from the US.

I could only find a datasheet for a R61526.    If anyone finds the correct R61520 datasheet,    I would be very grateful.
The 1526 can not Vertical Scroll.   It would be nice if the 1520 could do it.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 07, 2016, 03:46 pm
Hi David,

I tried to use the technique you replied with in message #329 and I couldn't get it to work so I went back to your solution, changed the pattern to a regular one rather than the random coloured pixels I WAS using and realised the solution doesn't work   :(

The "cut out" under the "minutes" is ALMOST the same when put back but the pattern under the "seconds" is completely wrong. I tried to debug it (your readGRAM method as the sketch LOOKS okay!?) but the logic is beyond my newbie C++ brain.

The solution is exactly as in message #329 with the change of pattern to make the error more obvious. I include it below....

Code: [Select]

/* Skeleton from readpixel_kbv */

#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

unsigned short minutes[12800];
unsigned short seconds[12800];

uint16_t g_identifier;

void setup(void)
{
    tft.reset();
    g_identifier = tft.readID();
    tft.begin(g_identifier);
    tft.setRotation(1);
    tft.fillScreen(0x0000);
}

void loop()
{
    int cy = 479;
    for (int z = 0; z < 160; z++) {
        uint16_t colour = random(0xFFFF);
        for (int c = 0; c < cy; c++) {
            tft.drawPixel(z + c, z, colour); //Top LHS
            if (c < (cy - 160))
                tft.drawPixel(479 - z, z + c, colour); //Top RHS
            tft.drawPixel(479 - z - c, 319 - z, colour); //Bottom RHS
            if (c < (cy - 160))
                tft.drawPixel(z, 319 - z - c, colour); //Bottom RHS
        }
        cy -= 2;
    }
    delay(500);
    tft.readGRAM(176, 130, minutes, 128, 100);//copy rectangle behind "minutes"
    tft.readGRAM(340, 130, seconds, 128, 100);//copy rectangle behind "seconds"

    tft.setAddrWindow(176, 130, 176 + 128, 130 + 100);
    tft.pushColors(minutes, 12800, 1);//copy minutes rectangle back?
    tft.setAddrWindow(340, 130, 340 + 128, 130 + 100);
    tft.pushColors(seconds, 12800, 1);//copy seconds rectangle back?
    delay(2000);
}


Thanks in anticipation   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 07, 2016, 06:42 pm
My apologies.    setAddrWindow(x1, y1, x2, y2) uses limit values not height and width.   e.g. (0, 0, 479, 319)

Here is an example program.   Note that my rectangle drawing will be about 10x faster than your code.

Code: [Select]


/* Skeleton from readpixel_kbv */

#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

unsigned short minutes[12800];
unsigned short seconds[12800];

uint16_t g_identifier;

void setup(void)
{
    tft.reset();
    g_identifier = tft.readID();
    tft.begin(g_identifier);
    tft.setRotation(1);
    tft.fillScreen(0x0000);
    // draw really irritating rectangles
    int h = 320, w = 480;
    for (int x = 0; h > 0; x++, h -= 2, w -= 2) {
        uint16_t colour = random(0xFFFF);
        tft.drawRect(x, x, w, h, colour);
    }
    // save the areas where digits get printed.
    tft.readGRAM(176, 130, minutes, 128, 100);//copy rectangle behind "minutes"
    tft.readGRAM(340, 130, seconds, 128, 100);//copy rectangle behind "seconds"
    tft.setTextSize(10);        //digit is 80 high, 60 wide
    tft.setTextColor(0xFFFF);   //WHITE transparent
}

void print_xy_2dig(int x, int y, int val)
{
    tft.setCursor(x, y);
    val %= 100;
    if (val < 10) tft.print("0");
    tft.print(val);
}

void loop()
{
    delay(500);
    //redraw the saved rectasngles.  note that this is x1, y1, x2, y2
    tft.setAddrWindow(176, 130, 176 + 128 - 1, 130 + 100 - 1);
    tft.pushColors(minutes, 12800, 1);//copy minutes rectangle back?
    tft.setAddrWindow(340, 130, 340 + 128 - 1, 130 + 100 - 1);
    tft.pushColors(seconds, 12800, 1);//copy seconds rectangle back?
    //draw the time
    uint32_t elapsed = millis() / 1000;
    print_xy_2dig(176, 130, elapsed / 60);
    print_xy_2dig(340, 130, elapsed % 60);
    delay(500);
}


I am sure that you could invent some less irritating random graphics.   mind you,  it did illustrate your point.

In practice,  you only redraw the background when necessary.   i.e. only when a digit changes.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 08, 2016, 01:52 am
Thanks David  :)

Lying sleepless in bed I concluded it was a bug  :(   I didn't think it was THAT simple   ;)

I have drawn that "irritating" rectangular pattern many times and have progressed to using drawRect rather than drawPixel, I copied the first one I found, but, as you said "it did illustrate my point"   :D

I HAVE investigated the concept of just redrawing the background behind each changing digit. In fact I had already computed the bounds for "minutes1 & minutes2" etc.

I noticed you activated "drawBitmap" in the UTFTGLUE (thanks). Did you ever consider putting it IN MCUFRIEND_kbv? I have almost completely moved from using UTFT (and MY version of it) to MCUFRIEND_kbv & Adafruit_GFX.

Anyway, Thanks for your response  :)

PS A quick question  ;)

Code: [Select]
tft.setAddrWindow(176, 130, 176 + 128 - 1, 130 + 100 - 1);

Does the compiler evaluate "130 + 100 - 1" and replace it with "229" or does it generate code to do it? I suspect/expect the former  :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 08, 2016, 08:21 am
Just write straightforward statements e.g. the distinct - 1.   The Compiler will generate the optimum code.

You can always inspect the ASM code if you are sceptical.

Any "intelligence" is best from a human level e.g. you know that only the seconds lsd changes frequently.    So you can save each individual digit background.

Implement intelligent redrawing and the result will be visually pleasing.

You could also automate this intelligent redraw much like Unix Curses.

Note that Adafruit text drawing could be done faster.  In practice the individual letter redraw will always look better.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Tahp on May 08, 2016, 12:06 pm
I have attached a new MCUFRIEND_kbv v2.90 (http://forum.arduino.cc/index.php?topic=366304.msg2524865#msg2524865) library to message #1.
I have also updated the LCD_ID_readreg.ino sketch

The library should detect the R61520 controller in the recent "Split Screen" messages.
Please let me know if it creates any problems for existing controllers.

David.
Can't thank you enough. great work
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 09, 2016, 02:54 am
Couple of questions not directly related to your library if you don't mind?  ;)

Is there anyway (in software) one can make a display brighter? My new screen is much darker than my other two screens (AliX 3.95").

Second question....   Is there a system variable (like __DATE__) in a sketch that can differentiate between 2 connected Dues? This will be temporarily while the sketch is being developed only.  I have 2 setups with Rotation(1) and the new screen - Rotation(3)  :(

Is there something like....
Code: [Select]

if(__USB__==7) {
  tft.setRotation(3);
} else{
  tft.setRotation(1);
}

Do you know if there is "Help" information about system variables available.

Thanks in anticipation   :)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 09, 2016, 07:38 am
Not that I can think of.    I distinguish different Uno clones by the pcb colour,   header colours, ...

A sticky label on the side of the headers can distinguish Dues when there are shields in place.   Write the COM#.
I write the controller part number on the bottom of a Shield with a Sharpie.

I use different colour USB cables.

I am sure that you or your grandchildren can think of several other ways to identify shields or Arduinos.

I would be interested in links to "identical looking" shields that have different Panel settings.
There are many 2.4" shields with an ILI9341.
I would be surprised if one 3.95" ILI9488 is different to another 3.95" ILI9488.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 09, 2016, 09:48 am
I have all three plugged into a hub so I have the line number (1, 2, 3) written on their stands. Then I have the port numbers (COM#) written on them - 8, 7, 11.

I know the "new" screen is on physical line 1 and port 8.

To me, there are 2 different screens. It looks like the new one is made from identical parts just the screen is flipped before being glued on with double sided sticky tape. Hence the Rotations 1 and 3.

By looking at the "gcc.exe" compiler I found a few more (six) environment variables but nothing that differentiates the uploaded sketch ports connected   :(

I normally work with Rotation(1) but to achieve the same display I have to physically change the 1 to 3 on the Due with the "new" screen before "Upload" otherwise the display is upside down.   :(

To do what they have done they must have twisted the soft linkage between the pcb and the screen!? Maybe that is why it is darker.  :(

The "new" one is the only one that "touch" works but when I draw a line with a stylus it appears about 5mm away from the actual touch. Yes, I have run "calibration" and entered the values in the example....

Thanks for your response   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 09, 2016, 10:45 am
Physical Panels differ.   Which is why the manufacturer can configure them.

Since the 3.95" shields are not very common,   I would expect them to all use the same components.
i.e.   I am surprised that one is flipped.   Do the Panels look identical?  Ribbons look the same? Any numbers?

I am surprised that you get anything reliable from a Due Touchscreen.
It should be ok on the Mega.   You can tweak the Touch values.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 09, 2016, 03:45 pm
I took a couple of pictures of them side by side.  The designs in their pcbs ARE different and their screen are set different but functionally they are identical EXCEPT for their Rotations.

If I can work out how to get the pictures off my iPad and into the forum then you can see.

I'm stuck with my Due touchscreen as the Mega doesn't have 13Kb of SRAM.
Believe me I would be happy to use my Megas as I have 5 of them pre bought and they don't have the trouble with pressing reset after a power interruption.

Is there nothing I can do about the accuracy of "touch" on my Dues?   :(

I suppose, at the end of the day, I can live with the inaccuracy   ;)  I'm only going to use it as a means to set the Alarm....  Just a couple of PLUS and MINUS boxes to set the Alarm....   Not rocket science   ;)

Okay, I have attached the pictures....   Now to see if they go UP....
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 09, 2016, 04:44 pm
Well,  the pcbs are completely different.
The front views look similar.   Except that one Touch panel is 180 degrees.

It would have been helpful if you had taken the photos with them plugged into Megas.   Then we could see the USB cable.   Your pcb photos show the microSD.   The front photos do not show any microSD.    So we have no idea which way round the shields are.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 09, 2016, 05:27 pm
As you can(?) see the picture is from the cable side of the screens plugged into Dues. Both micro SD are over the micro USB ports.

The first one doesn't show the touch connectors whereas the rear one (the "new" screen) has the touch connector over the cable entry....

Sorry, off to bed   :)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: hawk7890 on May 10, 2016, 03:12 am
I am sure this is covered in parts in this thread, but I can't seem to find what I am looking for.

I purchased an arduino Mega 2560 + 3.95" TFTLCD ili9488 (mcufriend) from aliexpress.

I see the first thread has some steps to follow, but since I am new at this I seem to be having some difficulty adding the libraries listed. ADAFruit lib.zip and mcufriend_kbv_2.90.zip

When doing include library from zip I get this:

Invalid library found in c:\users\myprofile\documents\arduino\libraries\mcufriend_kbv and I am unable to uninstall the library

The library ADAFruit lib cannot be used: Library must contain only basic letters and numbers.

I need to test this ASAP so I can confirm I have received the item and it works.

Thank you
Marc
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 11, 2016, 03:47 pm
This probably isn't the forum to raise this but there a few smart people here so I thought I'd ask.

Since updating IDE early this afternoon I am now getting this error....   :(

bossac.exe: extra arguments found
Try 'bossac.exe -h' or 'bossac.exe --help' for more information

One of my Dues I was trying to upload a sketch to (the new LCD_ID_readreg actually) is now cactus (non responsive)  :(

Any ideas?  :)

Panic over - I updated to 1.6.9 and all is good   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Ppuk on May 11, 2016, 08:30 pm
I am using a 3.6 inch arduino uno 61509 lcd shield with your library on an uno and it works perfectly! But i need about 20 more io pins and so i have to use a mega with this lcd instead, but unfortunately it is a bit slow then . What do i need to change in code and what do i need to solder the lcd pins to to have the highest display speed?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 11, 2016, 09:09 pm
If you want to use a MEGA2560,   why not buy a Mega Shield instead of a Uno Shield?

A 400x240 display shield costs about the same for Mega or Uno.
The smaller 320x240 Uno shields are incredibly cheap.

Unfortunately some of the Mega shields have crap microSD.   It looks as if you can get Mega 320x480 shields with good SD but no Touch.   Or with Touch but crap microSD.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Cololeo on May 12, 2016, 01:31 am
Well, it looks like the smart people have done it again.  I am no longer tearing my hair out.  My shield id came out 0x1520, and with the 2.9 library, it all works perfectly.

Eternal praises to all that figured this out.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Ppuk on May 12, 2016, 08:14 am
Good point :-) It is what i have at the moment.. The display will be built in a case and the avr is actually a bare pcb with the chip on it. So the shield format doesn't matter at all and i'll have to solder it anyway. But as i was testing with a normal mega2560 pcb i found out it was really quite slow.

I only use the touch screen (besides the lcd of course :-)

Is it enough for optimal speed to only use a sequential port pinseries like (eg) PK0-7 ? Where in the code do i change those assignments?

Same story for the lcd_rd, lcd_wr, lcd_rs, lcd_cs and lcd_rst: pinseries PF0-5 ? Where in the code can i change this? In this display module (3.6 inch mcufriend with 61509) SPI is only used for the sd card is it?

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 12, 2016, 08:37 am
If you are intending to solder pins directly,    you can put the data bus on PORTA (digital #22-29).
Put the microSD on 50-53.    Leave the TFT control pins on analog #0-4.

I made a special "HOME_MADE_MEGA_SHIELD" Adapter from a Protoshield to do the above wiring.
It works faster than a Uno.   The SD uses hardware SPI.   The Touch works.

If you want to do something different,   PM me.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Ppuk on May 12, 2016, 03:04 pm
Great! I'll try those pins. To change the code to start using the correct pins: I suppose there a reference in your mcufriend library to 'HOME_MADE_MEGA_SHIELD'?

Will try and can have a look tonight :-)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Ppuk on May 12, 2016, 10:34 pm
Thanks! It works perfectly! And much much quicker indeed! Only things i had to do was:
- Rewire according to Davids advice
- uncomment the defines USE_SPECIAL and USE_MEGA_8BIT_PROTOSHIELD
- change two touchscreen pinvalues to:
uint8_t YM = 29;   
uint8_t XP = 28;   
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: BenFranklinIII on May 13, 2016, 12:30 am
Hallo Ppunk

I have the exakt same setup as you do.

An Adafruit touch 2,4" running on an UNO: Nice and fats. Since I need AD ports I have to use a mega. / I want to.

The Display ist very slow on the Mega. So slow tha I cant display my recorded analog velues properly.

So I have to make it run faster.

Could you explain in more detail what you did to get it run faster? I also use the mcufried_kbv Library.

Thanks a lot.

Best regards.

Benjamin

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Ppuk on May 13, 2016, 11:09 am
I did not connect the sd card. Connect the pinout as the following:
lcd_d0 -> D22
lcd_d1 -> D23
lcd_d2 -> D24
lcd_d3 -> D25
lcd_d4 -> D26
lcd_d5 -> D27
lcd_d6 -> D28
lcd_d7 -> D29

lcd_rd -> A0
lcd_wr -> A1
lcd_rs -> A2
lcd_cs -> A3
lcs_rst -> A4

Change the following files in the mcufriend library:
- mcufriend_special.h
change '//#define USE_MEGA_8BIT_PROTOSHIELD' to '#define USE_MEGA_8BIT_PROTOSHIELD'
change '#define USE_MEGA_16BIT_SHIELD' to '//#define USE_MEGA_16BIT_SHIELD'
- mcufriend_shield.h
change '//#define USE_SPECIAL' to '#define USE_SPECIAL'

Change the following in your code:
uint8_t YM = 29;   (was originally 7)
uint8_t XP = 28;   (was originally 6)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: BenFranklinIII on May 14, 2016, 11:55 am
Hi,

thank you very very much.

It works exactly as on an uno.

Now I can continue with my project.

Since I have to mount my display in a case at the end I wanted to make a adapter for the dsiplay anyway. SO nor I just have to reroute the wiring.

Tanks again.

Best regards.

Benjamin
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: radeen on May 14, 2016, 04:29 pm
Hi, please I need a big help and I'm still a newbie so not sure how to solve it. Hope you can help me with that. :)

I plugged the 3.95" display into arduino UNO. I was able to get everything working ok (SD card, TouchScreen, draw Bitmaps and so on).

Now I need to move from arduino UNO to arduino DUE. So I plugged the 3.95" display into arduino DUE as I did with ONE. I'm still being able to get everything working ok, EXCEPT drawing Bitmaps. Apparently I'm failing in initializing the SD card, but I can't understand why!

Do I have to use a different library from SD.h? Is there a valid demo that shows how to draw Images using the 3.95" from the SD card with arduino DUE?

Thanks in advance for your time, 'm really desperate :p

Martin
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ghlawrence2000 on May 14, 2016, 05:20 pm
Radeen,

I am not sure which 3.95 shield you have, but my first guess is that there is no connection to the 6 pin header? SPI on the DUE is routed through the 6 Pin header in the middle of the board. My first suggestion would be to use SdFat, and software SPI, but it will be slow.

Regards,

Graham
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 14, 2016, 05:36 pm
It is obviously a genuine Uno Shield because the display works with a Uno.

You have to do Software SPI with the SdFat.h library on pins 10, 11, 12, 13.

Note that there are several hacked SdFat libraries.
Note that you have to configure SdFat to accept SoftwareSpi.

Note that SdFat.h has slightly different methods to SD.h

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bodmer on May 14, 2016, 09:04 pm
The SdFat library will work.

You need to edit the SdFatConfig.h file inside the library to set the library to use software SPI and to set the pins to use, in the following excerpt from that file the correct settings of the lines are marked // <===<<<<

Code: [Select]

#define SD_SPI_CONFIGURATION 2  // <===<<<<
//------------------------------------------------------------------------------
/**
 * If SD_SPI_CONFIGURATION is defined to be two, these definitions
 * will define the pins used for software SPI.
 *
 * The default definition allows Uno shields to be used on other boards.
 */
/** Software SPI Master Out Slave In pin */
uint8_t const SOFT_SPI_MOSI_PIN = 11;  // <===<<<<
/** Software SPI Master In Slave Out pin */
uint8_t const SOFT_SPI_MISO_PIN = 12;  // <===<<<<
/** Software SPI Clock pin */
uint8_t const SOFT_SPI_SCK_PIN = 13;   // <===<<<<
//------------------------------------------------------------------------------


To test the interface run the SdInfo example with one line changed as follows:

Code: [Select]

const uint8_t SD_CHIP_SELECT = 10;  // <===<<<<


To achieve a level of compatibility with the SD library you can add this to the start of your TFT sketch:

Code: [Select]

  // #include <SD.h>   // Commented out SD library
  #include <SdFat.h>             // Use the SdFat library for the Due
  SdFat SD;                         // Permit SD function call for the Due

// Chip Select Pin for SD card
#define SD_CS 10




Then in setup() use code such as this:

Code: [Select]

  Serial.print("Initialising SD card...");

  if (!SD.begin(SD_CS)) {
    Serial.println("initialisation failed!");
    return;
  }

  Serial.println("initialisation done.");


Then you just need to adapt any other SD library function calls to those supported by the SdFat library...

The SdFat software SPI works quite well.  On the Due it also supports SPI DMA, but you would need to hack the boards to connect up the hardware SPI lines.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 15, 2016, 04:44 am
The SdFat library will work.
<<<<snip>>>>>
On the Due it also supports SPI DMA, but you would need to hack the boards to connect up the hardware SPI lines.
Do you have an idea how much of an improvement SPI DMA would be with your JPG routine?   ;)

I'm considering it with JPG backgrounds for a digital clock, changing the background picture every minute? Currently it takes about 2 seconds to display a picture on my 480*320 screen. :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: radeen on May 15, 2016, 09:39 am
Thanks guys!! That was amazing!! Problem solved with the SD... like you said, SPI Software and SDFat library made my day. After that I had a little problem with recognizing the BMP files but I managed to fix it as well in the code.

Again thanks so much, now I'm able to move on with my project :)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 15, 2016, 09:41 am
Think about it.     480x320 is about 307kB of RAW pixel data.     @8MHz SPI it will take at least 307ms.
Many microSD cards will work at 21MHz SPI.

Connect a microSD to the Due's native 3x2 header.    See what you actually achieve in real life with the Arduino libraries.

Be realistic.    You can have low resolution JPEG files that are smaller on disk.   But require processing before displaying.
Or you have RAW files that you pull off the disk and transfer immediately to the display.

You can create lots of Mandelbrot images with your PC and store them on SD card.   An intricate Mandelbrot will not compress much with JPEG.
Or copy lots of family photos and store on SD card.    These might compress well.

Then it comes down to the appearance of your "clock" as it changes the background.    e.g. overpaint from the top down or scroll the old picture sideways while the new picture emerges.

Most of these things can be thought about / designed in plain English.

Just do some experiments.

From memory,   the Due can bit-bang the SD faster than the Mega can use hardware SPI.   It is certainly comparable.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 15, 2016, 10:40 am
Thanks David, VERY informative as always.  :D

Wow! I wouldn't even attempt scrolling the picture in.  The logic would horrendous. :)   Not to consider the time!

On further consideration, it wouldn't be possible would it!? Even the Due wouldn't have enough SRAM to read the whole picture in and scroll it onto the display!?

Also considering the picture loads horizontally and the scroll vertically, in landscape mode?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 15, 2016, 11:19 am
You would use "Vertical Scroll" for a portrait.   This appears as sideways if you are in a Landscape mode.
It costs absolutely nothing in time or software.

Just a regular repaint with new picture looks ok if you don't clear the display.

As I said earlier,   think about what you would like to see.   What would be attractive?

In practical terms,   you want a microSD card full of ready-made RAW, JPG or BMP files.
Having decided what you want your Due to do,  you would prepare the RAW, JPG, BMP files accordingly on the PC.

Please can anyone tell me why I have started to receive Emails when a Topic has a new message?
Has the Forum software changed in the last 2 days?

Have I inadvertently ticked a box somewhere?
The box for [Receive Emails] is near the [Go] box.

Is there any way to stop receiving these unwanted Emails?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 15, 2016, 12:50 pm
Yes, I have a micro SD with about 2000 pictures in jpg and raw formats. The jpgs looking identical to the raws except generally twice as fast (At least). There was 1000 of each for comparison.  They were batch resized with Irfanview to 480 across. I have decided on landscape and jpgs so scrolling is not really an option.  :(

I will use a family album finally.

Thanks for your suggestions.  :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ghlawrence2000 on May 15, 2016, 03:15 pm
Curiously, I too have started getting lots of emails mainly from this thread.... It is certainly nothing I have changed my end. 

Regards,

Graham
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bodmer on May 16, 2016, 12:56 am
@louwin

The best I get with a 28MHz SPI clock reading an SD Card with the Due and SdFat is about 3MBytes/s this translates to ~100ms to pull a 480x320 pixel 16 bit raw image off the card. With the 16 bit TFT boards I use the pins are not well mapped to the Due port bits so it takes 280ms to then paint the image to the screen. Thus the best speed is about 380ms for a raw image.

Jpegs are much smaller so can be loaded fast but they take a lot of mathematical operations to decompress them, so this takes typically 600ms on a Due plus the render time of 280ms.

Thus it is a catch 22.

A while ago I created a sketch that left windows in the jpeg image unplotted on the screen so that any text or sensor readings never got wiped in that area, perhaps that approach would help with your clock over an image problem?

P.S. Notifications come and go and have been broken for a while (https://github.com/arduino/forum-issues/issues/83), it looks like it has been fixed now, so it is a case of changing and saving the notification settings in your forum profile.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 16, 2016, 03:23 am
Thanks for the above info bodmer.  :)

I would have been able to work some of it out myself except I'm away from home babysitting a sick grand daughter.  :(   And haven't been home for a couple of days.

I miss my other babies (Dues and 3.95" screens).

I am probably wrong but aren't jpgs just setWindows and pushColors in 16x16 or 32x32 blocks and changing 888 to 565!? Sorry, I can't see the code in front of me so using the doubtful memory.  ;)   On my iPad....

I think I mentioned I extract and store the backgrounds behind the MM and SS digits of my clock using readGRAM. I had considered duplicating these bits during the decoding of the jpgs but the logic escaped me plus I worried about increasing the jpg decoding time!?  The readGRAMs takes about a tenth of a millisecond? If I change the background every minute then I won't have to store the MM bit!? Either way it won't fit on a Mega.  :(

Also that is why the timing and reading of the picture off the microSD card is so important. If I can get under a second with SPI DMA I am interested.  :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: malsi1 on May 16, 2016, 11:40 am
DS3231 does not work and TFT Schild 2.4 R61520 to Arduino Leonardo. Why?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 16, 2016, 12:03 pm
Be more specific.   The 2.4"  Shields use up almost all of the Uno GPIO pins.   e.g. the SDA pin from I2C.
The Leonardo has separate pins for I2C.   (I think)

I am not at a PC.    I will plug a R61520 shield into a Leonardo and try it for myself.

Meanwhile,   please can you post your problem sketch.

David.

Edit.  Ah-ha.  Just looked at the Leonardo pin-out.   I2C shares digital #2, #3 pins with the TFT.
However,  the 3x2 SPI header is not used by the TFT shield.   You can bit-bang I2C on those pins.
Note that you also have to bit-bang the microSD if you use a Leonardo.
And the Leonardo performance is pretty atrocious for the TFT.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: malsi1 on May 16, 2016, 12:17 pm
#include <RtcDS3231.h>
#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

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

// Assign human-readable names to some common 16-bit color 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

#define MINPRESSURE 10
#define MAXPRESSURE 1000


RtcDS3231 Rtc;

void setup ()
{
    Serial.begin(57600);
    tft.reset();
    uint16_t id = tft.readID();
    tft.begin(id);
    tft.setRotation(2);
    tft.fillScreen(BLACK);
   
    //--------RTC SETUP ------------
    Rtc.Begin();

    // if you are using ESP-01 then uncomment the line below to reset the pins to
    // the available pins for SDA, SCL
    // Wire.begin(0, 2); // due to limited pins, use pin 0 and 2 for SDA, SCL

    RtcDateTime compiled = RtcDateTime(__DATE__, __TIME__);
    printDateTime(compiled);
   
    if (!Rtc.IsDateTimeValid())
    {
        // Common Cuases:
        //    1) first time you ran and the device wasn't running yet
        //    2) the battery on the device is low or even missing

        tft.println("RTC lost confidence in the DateTime!");

        // following line sets the RTC to the date & time this sketch was compiled
        // it will also reset the valid flag internally unless the Rtc device is
        // having an issue

        Rtc.SetDateTime(compiled);
    }

    if (!Rtc.GetIsRunning())
    {
        tft.println("RTC was not actively running, starting now");
        Rtc.SetIsRunning(true);
    }

    RtcDateTime now = Rtc.GetDateTime();
    if (now < compiled)
    {
        tft.println("RTC is older than compile time!  (Updating DateTime)");
        Rtc.SetDateTime(compiled);
    }
    else if (now > compiled)
    {
        tft.println("RTC is newer than compile time. (this is expected)");
    }
    else if (now == compiled)
    {
        tft.println("RTC is the same as compile time! (not expected but all is fine)");
    }

    // never assume the Rtc was last configured by you, so
    // just clear them to your needed state
    Rtc.Enable32kHzPin(false);
    Rtc.SetSquareWavePin(DS3231SquareWavePin_ModeNone);
   
}

void loop ()
{
    if (!Rtc.IsDateTimeValid())
    {
        // Common Cuases:
        //    1) the battery on the device is low or even missing and the power line was disconnected
        tft.println("RTC lost confidence in the DateTime!");
    }

    RtcDateTime now = Rtc.GetDateTime();
    printDateTime(now);
    tft.println();

    delay(10000); // ten seconds
}

#define countof(a) (sizeof(a) / sizeof(a[0]))

void printDateTime(const RtcDateTime& dt)
{
    char datestring[20];

    snprintf_P(datestring,
            countof(datestring),
            PSTR("%02u/%02u/%04u %02u:%02u:%02u"),
            dt.Month(),
            dt.Day(),
            dt.Year(),
            dt.Hour(),
            dt.Minute(),
            dt.Second() );
            tft.setCursor(10, 10);
            tft.setTextColor(YELLOW);
            tft.setTextSize(2);
            tft.print(datestring);
}
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 16, 2016, 12:29 pm
As I said in my (edited) reply,  you will have to bit-bang I2C.

I am not aware of an Arduino bit-bang I2C library,   but it is simple enough to port the Fleury i2cmaster.S file to your project.

Controlling the DS3231 is very straightforward.    Obviously this is not as easy as using the ready-made <Wire.h> library.

Have you considered buying a Uno clone?    The R61520 should work ok with a snipped A4 pin (and 10k pull-up).
Everything works properly on a Uno:    Sensible TFT speed, Touch, microSD.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bodmer on May 16, 2016, 03:35 pm
I am not aware of an Arduino bit-bang I2C library,   but it is simple enough to port the Fleury i2cmaster.S file to your project.

Porting has been done here (https://github.com/felias-fogg/SoftI2CMaster), more info here (http://playground.arduino.cc/Main/SoftwareI2CLibrary).

However you then have to write write your own code to access the DS3231 so that is likely to be the main problem area unless your are familiar with I2C comms, and hence as suggested a UNO or clone would be the lowest hassle route.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: isra_zam on May 17, 2016, 02:39 am
I'm using the touchscreen mcufriend 2.8" on arduino DUE and  the problem is that after touching it, it  doesn't continue to draw a button but before touching I can draw whatever I want. Can someone help me?. I have read something about sharing pins but I reestablish the  pins like outputs but it still doesn't work. The problem starts when I do an analogRead(YP);
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 17, 2016, 06:52 am
The SdFat library will work.
<<<snip>>
On the Due it also supports SPI DMA, but you would need to hack the boards to connect up the hardware SPI lines.
Thanks for that bodmer   :D

I've had Soft SPI working on my Due/AliX 3.95" working for a while   :D

I JUST used 28 Dupont wires and connected my Due to my AliX 3.95" 9488 screen with MISO, SCK and MOSI connected to the Due's SPI header.

Powered on and (of course) SD card initialization failed as everything was still set to Soft SPI on 10/11/12/13.

I've read all I could find about DMA on SdFat and am none the wiser.  :(

What changes must I make to get DMA working in SdFat on my Due?

I did read the html doc that came with SdFat  :(

I also have a couple of Mega proto boards I am considering wiring up not to use all those Dupont wires.

Some of the 28 pins aren't labelled, do you think they need connecting? I HAVE connected them but am curious if they are needed?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bodmer on May 17, 2016, 11:43 am
You need to change a line in SdFatConfig.h to select the faster SPI, it is around line 80, change to:

#define SD_SPI_CONFIGURATION 0  // <===<<<<

Also you might need to change the SD_CS line pin in your sketch, e.g.:

// Chip Select Pin for SD card
#define SD_CS 10

You also need to define the DUE SPI clock divider, I set it to 3 (i.e. 84MHz/3):

  if (!SD.begin(SD_CS, 3)) { // <===<<<<
    Serial.println("initialisation failed!");
    return;
  }
  Serial.println("initialisation done.");

It might work with the divider set to 2 but that is too fast for my SD Card.

In practice you might not get much performance improvement for JPEGs because of the decompression time.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 17, 2016, 01:35 pm
Thanks bodmer  :)

Sorry to say I don't think it made any(/much?) difference    :(  Can't say as I didn't make notes before.

I'll reverse the changes and do some timings with the same microSD card on another Due and compare....

Thanks anyway. I'll also do some checks on BMPs as, with their larger files, there might be a greater difference.

Thanks anyway....   Something good to know   :)

Edit:   Some timings (in milliseconds)
        Soft SPI     DMA Div2     DMA Div3
     BMP  JPG    BMP  JPG    BMP  JPG
1.  4040 2409   2803 2197   2855  2109
2.  4040 1730   2803 1595   2855  1592
3.  4040 1736   2803 1597   2855  1600

Basically, with BMPs improvement from Soft to Divider 2 - 1237ms
                   ''      ''              ''                ''  Divider 2 to Divider 3 - 52ms
                 with JPGs         ''                ''   Soft to Divider 2 - 250 to 300ms
                    ''      ''              ''               ''  Divider 2 to Divider 3 - 2 to 80ms
(Sorry, I don't know what your chosen font will do to my tables)

Conclusion, the exercise was worth it for BMPs and just about so with JPGs too.
The diufference between Divisor 2 & 3 was negligible  :(

I tried Divisor 1 but it was totally unsuccessful  :(
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bodmer on May 17, 2016, 03:29 pm
Sorry to say I don't think it made any(/much?) difference
OK, I should have thought this through. The JPEG files are only small anyway so probably load into Due memory in less than 50ms even with software SPI, hence the small time savings. So most of the time the Due is doing the decompression Maths.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 17, 2016, 03:35 pm
Don't give it a second thought. I spent a little time playing and proved a point   :D

You didn't make any promises   :D

Thank you for you help and interest   :D   :D   :D

Plus 1 Karma    :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: malsi1 on May 19, 2016, 12:08 pm
Inverted X into TouchScreen. By clicking on the upper left corner coordinates of 320, 0. What to do?

#define TOUCH_ORIENTATION  LANDSCAPE
#define USE_UTOUCH         0

#if !(USE_UTOUCH)
#define TITLE "TouchScreen.h Calibration"
#include <Adafruit_GFX.h>
#include <UTFTGLUE.h>            //we are using UTFT display methods
UTFTGLUE myGLCD(0x9341, A2, A1, A3, A4, A0);

#include <TouchScreen.h>

// MCUFRIEND UNO shield shares pins with the TFT.   Due does NOT work
#define YP A1   //A3 for ILI9320
#define YM 7    //9
#define XM A2
#define XP 6    //8 
#define SWAP(a, b) {uint16_t tmp = a; a = b; b = tmp;}
uint16_t TS_LEFT = 920;
uint16_t TS_RT  = 150;
uint16_t TS_TOP = 940;
uint16_t TS_BOT = 120;

TouchScreen myTouch(XP, YP, XM, YM, 300);
TSPoint tp;                      //Touchscreen_due branch uses Point

void readResistiveTouch(void)
{
    tp = myTouch.getPoint();
    pinMode(YP, OUTPUT);      //restore shared pins
    pinMode(XM, OUTPUT);
    digitalWrite(YP, HIGH);
    digitalWrite(XM, HIGH);
}

bool ISPRESSED(void)
{
    readResistiveTouch();
    return tp.z > 20 && tp.z < 1000;
}

void showpoint(void)
{
   uint16_t xpos, ypos;  //screen coordinates
 
                  xpos = map(tp.x, TS_LEFT, TS_RT, 0, myGLCD.width());
                ypos = map(tp.y, TS_TOP, TS_BOT, 0, myGLCD.height());
    Serial.print("\r\nx="); Serial.print(xpos);
    Serial.print(" y="); Serial.print(ypos);
    Serial.print(" z="); Serial.print(tp.z);
  }
#else
#define TITLE "UTouch.h Calibration"
#include <SPI.h>
#include <UTFT.h>
#include <UTouch.h>
UTFT    myGLCD(ILI9486, 38, 39, 40, 41);
UTouch  myTouch( 6, 5, 4, 3, 2);
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: malsi1 on May 19, 2016, 02:55 pm
UTFTGLUE.h
void setFont(uint8_t* font) { MCUFRIEND_kbv::setTextSize(1);}

It does not change the font size
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: malsi1 on May 20, 2016, 08:44 am
What you need to do to add the Russian font?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 20, 2016, 09:09 am
What Russian font?

The Adafruit_GFX library has a standard 7x5 Latin font.    There are several 'special' letters in the 128-255 range.    My UTFTGLUE class does not use any UTFT fonts.    It simply uses the standard 7x5 but in different sizes.

The Free fonts are also Latin.     The Adafruit library comes with a utility to create a new font.     But the glyph style is not very popular.

I am not Russian.    I presume that you are quite happy with C and C++ programming languages that use only Latin characters in the Ansi 0-126 range.   Of course you can display Cyrilic text via custom methods.

Which display do you have?   Please post a link.   My library supports most mcufriend shields.    But I have never even considered Cyrillic.     If you want to collaborate,    I could add fonts.    This would depend on your English.    I do not know Russian.

Other libraries may already have Russian fonts.   e.g. UTFT.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: m1l3n on May 21, 2016, 10:47 am
Hi David,

I used your MCUFRIEND_kbv library (ver 2.90) with 3.95" TFT LCD with ILI9488 driver.
All examples work fine. Great job!
I wanted to display some BMP files on the screen (size 480x320) stored on SD card.
I use Arduino UNO board and Adrduino IDE ver 1.6.3.
To display the pictures I tried to modify the attached sketch, which I compile without problems.
The problem starts when I replace the included ADAFRUIT libraries with yours and modify the
statements tft.XXXXXXX with myGLCD.XXXXXXXX.
Here are the error messages:
Arduino: 1.6.3 (Windows XP), Board: "Arduino Uno"


ShowBMP.ino:10:14: error: variable or field 'bmpdraw' declared void

ShowBMP.ino:10:14: error: 'File' was not declared in this scope

ShowBMP.ino:10:22: error: expected primary-expression before 'int'

ShowBMP.ino:10:29: error: expected primary-expression before 'int'

ShowBMP.ino:11:23: error: 'File' was not declared in this scope

ShowBMP.ino:12:17: error: 'File' was not declared in this scope

ShowBMP.ino:13:17: error: 'File' was not declared in this scope

ShowBMP.ino:45:1: error: 'Adafruit_TFTLCD' does not name a type

ShowBMP.ino: In function 'void bmpdraw(File, int, int)':

ShowBMP.ino:105:15: error: 'tft' was not declared in this scope

ShowBMP.ino: In function 'boolean bmpReadHeader(File)':

ShowBMP.ino:114:29: error: 'boolean bmpReadHeader(File)' redeclared as different kind of symbol

ShowBMP.ino:11:9: error: previous declaration of 'boolean bmpReadHeader'

ShowBMP.ino:120:17: error: 'read16' cannot be used as a function

ShowBMP.ino:126:19: error: 'read32' cannot be used as a function

ShowBMP.ino:131:13: error: 'read32' cannot be used as a function

ShowBMP.ino:133:36: error: 'read32' cannot be used as a function

ShowBMP.ino:138:19: error: 'read32' cannot be used as a function

ShowBMP.ino:142:29: error: 'read32' cannot be used as a function

ShowBMP.ino:143:30: error: 'read32' cannot be used as a function

ShowBMP.ino:149:17: error: 'read16' cannot be used as a function

ShowBMP.ino:152:24: error: 'read16' cannot be used as a function

ShowBMP.ino:156:17: error: 'read32' cannot be used as a function

ShowBMP.ino: In function 'uint16_t read16(File)':

ShowBMP.ino:172:23: error: 'uint16_t read16(File)' redeclared as different kind of symbol

ShowBMP.ino:12:10: error: previous declaration of 'uint16_t read16'

ShowBMP.ino: In function 'uint32_t read32(File)':

ShowBMP.ino:184:23: error: 'uint32_t read32(File)' redeclared as different kind of symbol

ShowBMP.ino:13:10: error: previous declaration of 'uint32_t read32'

ShowBMP.ino:189:17: error: 'read16' cannot be used as a function

ShowBMP.ino:190:17: error: 'read16' cannot be used as a function

ShowBMP.ino: In function 'void setup()':

ShowBMP.ino:206:46: error: 'tft' was not declared in this scope

ShowBMP.ino: In function 'void loop()':

ShowBMP.ino:264:13: error: 'tft' was not declared in this scope

ShowBMP.ino:269:35: error: 'bmpReadHeader' cannot be used as a function

ShowBMP.ino:271:13: error: 'tft' was not declared in this scope

Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.


Remark : here I did not modify fully the sketch (replacement tft with myGLCD), only to show you the main problem, which I think exist. It is reported in the first 8 messages.

Please, help me to make this working.

Regards

m1l3n







Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 21, 2016, 12:04 pm
I am fairly certain that MCUFRIEND_kbv will complain if you are using IDE v1.6.3
It expects v1.6.5 or higher.

I compiled the sketch in your attachment.  It built with v1.6.6.

I then edited it for MCUFRIEND_kbv:

Code: [Select]

...
//#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
...
//Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
MCUFRIEND_kbv tft;
...


This built fine.   It ran ok with "flower.bmp".   I did not have the other BMP files.   Your sketch is very fussy about BMP format.    The images are drawn upside down.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: m1l3n on May 21, 2016, 09:16 pm
Hi David,

Thank you for your fast response.
I have installed the Arduino IDE 1.6.9 and the mentioned problem disappeared.
I succeeded to read the files from the SD card and to display them on the screen,
but I face problem with the colors.
In your library drawPixel requires 3 parameters (r,g,b), but in the original sketch it uses only one (it is not my creation - i took it as example from some library). I am trying to find a way to convert the 16 bit color data to 3 r,g,b values. You answered that you could display a bitmap file on your screen.
May you attach your sketch - I would like to test it and based on it to optimize mine. (Sorry, I am not so advanced in the programming  :smiley-confuse: )

Regards
m1l3n
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 21, 2016, 10:52 pm
Adafruit libraries already have a method for creating a packed 5-6-5 colour in an uint16_t

From MCUFRIEND_kbv.h
Code: [Select]

uint16_t color565(uint8_t r, uint8_t g, uint8_t b) { return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | ((b & 0xF8) >> 3); }


I  don't see what you are talking about.   The OP was asking about drawPixel requires 3 parameters (r,g,b)

This seems rather a misleading choice of parameter names.   The Library has:
Code: [Select]

virtual void     drawPixel(int16_t x, int16_t y, uint16_t color);  // and these three


It looks pretty obvious to me that you are going to draw a Pixel at coordinates: x,y with colour: color.
If you use names like r,g,b most humans would think red, green, blue.

Ah-ha.   I looked at the code in your ShowBMP.ino sketch.    It is not very intelligent.

You normally :
1.  set a Window to receive the pixels with setAddrWindow()
2.  read the 24-bit colour data from the BMP file on the SD Card.   Convert it to uint16_t colour.
3.  fill a small buffer with the colours.
4.  blit the buffer to the screen with  pushColors()

If the BMP does not fit in your screen,   you probably set a Window for each row.   So you can clip the image.
If the BMP does fit,   you just fill the whole rectangle in one go.

Your sketch sets x,y for every pixel.    This is about 6x slower than setAddrWindow() and pushColors()

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 21, 2016, 11:22 pm
I am not too sure what ml13n actually wants.    Every library has some form of color565(r, g, b)
Even UTFT would just say:
Code: [Select]

     myGLCD.setColor(r, g, b);
     uint16_t color = myGLCD.getColor();

I agree that the OP appeared to ask for:  I am trying to find a way to convert the 16 bit color data to 3 r,g,b values

Code: [Select]

     uint16_t color = MAGENTA;
     uint8_t r = (color >> 8) & 0xF8;    //5 significant bits
     uint8_t g = (color >> 3) & 0xFC;    //6 significant bits
     uint8_t b = (color << 3) & 0xF8;    //5 significant bits


The convention is to normalise r, g, b values 0-255.

David.  
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: karl1993 on May 26, 2016, 03:45 pm
IS there any guide or tutorial on how to use this library?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 26, 2016, 04:14 pm
Not really.   Any volunteers?

I have concentrated on compatibility with multiple hardware controllers.
In the process,   the "Demo" sketch tests everything (graphictest_kbv.ino).    It is big and difficult to follow.

I have worried more about a single sketch that will show a problem with a new controller.
The "other" approach is to publish 40 simple sketches that just show one thing at a time.

Even though I say that the GLUE demos are just a way to show a "foreign" class,   people seem to try them first !!

I can only suggest that you run the Demo.   Recognise something that you want.   Study the sketch code.
Then ask.

1. All text is handled by <Print.h> i.e. just like Serial.print() can do strings, floats, numbers, ...
2. All graphics shapes are handled by <Adafruit_GFX.h> e.g. lines, rectangles, circles
3. All Buttons  handled by <Adafruit_GFX.h> e.g. drawButton(), isPressed(), ...
4. Most Red 2.4" shields have resistive Touch handled by <TouchScreen.h>

All my libraries attempt to readID() and vertScroll().    If you only have one screen,   you just need to known what its ID is.   

If there is a volunteer out there who is prepared to write a Tutorial,   I am happy to provide the Test sketches.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on May 30, 2016, 03:35 am
Hi David,

Sorry if this is off topic but I wondered if your library (or anybody else's) would drive this screen?

http://www.ebay.com.au/itm/360991621623?_trksid=p2060353.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT

What it attracts me is its' 800*480 resolution.  I suspect even the Due would be hard pressed to drive it!? The screen is capable of full video functions (movies?) so another attraction.  Maybe I should consider a Raspberry Pi!?

I seem to remember a driver (in the back of my mind) but it was abysmally slow (on the RCA interface).

Again, I apologize if I'm off topic but could you modify your library to support it?

Thanks for your library.

I eventually converted my master sketch to use MCUFRIEND_kbv/Adafruit_GFX. It took hours converting all the "tft.print(whatever, x, y)" to "tft.setCursor(x, y) & tft.print(whatever)". I still haven't converted the "drawBitmaps". Yes, I know you have added the method to UTFTGLUE   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on May 30, 2016, 09:46 am
Louis,

Just look at the screen and then look at your Due.    I do not see any Male members that could mate with any Female members.

Even if you did manage to join them,   the Arduino would never be able to generate worthwhile video content.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Vrail99 on Jun 02, 2016, 11:22 pm
Hi David,

I used your libraries in one of your earliest posts, and it doesn't seem to find the right controller.
I used the library from adafruit and it recognized that I got an ILI9341 Chip.

The Display works fine, even with the adafruit libraries, edited like the guy on this post: http://forum.arduino.cc/index.php?topic=292777.msg2055721#msg2055721
I use the 2.8" touchscreen with an arduino uno.

My problem is, that the coordinates are wrong.
I can read X and Y also Z, but
X is says ~983, when I touch it says 1020.
Y is normally at 495, when I touch it displays ~507.
Z is negative at -266 and doesn't change on touch action.
I used the adafruit touchscreendemo.

I used various libraries, but they also didn't work.
I also tried your libraries and .ino files, but they couldn't recognize the ILI9341...
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 02, 2016, 11:40 pm
Are you using v2.90 of my MCUFRIEND_kbv library?
Do you have a Blue 2.8" shield like in message#1 of your link?

The library should work fine.   It should recognise ILI9341.   Please let me know what you get from the LCD_ID_readreg.ino sketch.

If you look in the "Touch_shield_kbv.ino" sketch,  it even has a setting for a "Blue ILI9341" shield.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zgoda on Jun 07, 2016, 10:27 am
It is quite simple.    You count up the male pins on your shield and you count up the female sockets on a Uno.

If you have got more males than females,   the shield can not work with a Uno.
The pcb has pin layout for MEGA, that's for sure. I just want to figure out the control chip and pins for communication with (any) MCU, preferably using SPI.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 07, 2016, 11:18 am
I replied to your earlier message.   The library is designed for UNO shields.

Most MEGA shields are not possible to read.   i.e. the /RD pin is not available.
This means that I can not read the controller ID.

Most Mega shields are 16-bit parallel.    I am not aware of any Mega shield that can use SPI.
Most Adapter shields are 16-bit parallel.

EastRising (buydisplay.com) produce Adapter Shields for both Mega and Uno.   However they only accept EastRising Displays (most of which can use SPI).

As you have discovered,   Ebay and AliExpress vendors have no idea what they are selling.    
Like UTFT users,   you just have to guess:   e.g. try ILI9481, ILI9486, ILI9488, ...

If you are in the UK,   I could possibly help with your guesswork.
If you are on the other side of the world,   it is not very practical.   Especially if English is not your first language.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Jun 10, 2016, 11:19 am
Hi David,

Like I said I have converted my sketch to use your library and the Adafruit extension.

I have used SetAddrWindow and pushColors but I prefer drawBitmap as I find it more intuitive with (x, y, w, h, data) format.

Code: [Select]
#include <Adafruit_GFX.h>
#include <Fonts\FreeMonoBold12pt7b.h>
#include <Fonts\FreeMonoBold24pt7b.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <UTFTGLUE.h>
UTFTGLUE lcd(0x9488,A2,A1,A3,A4,A0);

.............

    //tft.setAddrWindow(344, 154, 446, 213);
    //tft.pushColors(seconds, 6120, 1);
    lcd.drawBitmap(344, 154, 102, 60, seconds);


So basically I address ALL my commands to "tft..." except the lcd.drawBitmap(...).

Is this the correct way to do it.  :)

Why can I access the "Print" class with "tft" prefix but I can't the GLUE methods and have to use the "lcd" prefix?

Sorry, if this is a real "newbie" question....   ;)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 10, 2016, 08:54 pm
Louis,

First off,   it is very unwise  (tm) to have a tft object and an lcd object.
If you are adamant that you want an lcd object,  omit the tft object.   The lcd object will know how to do everything that any MCUFRIEND_kbv can do.

I strongly advise that you stick with the MCUFRIEND_kbv class.
If you feel happier with     lcd.drawBitmap(344, 154, 102, 60, seconds); just write a helper function:

Code: [Select]

void drawBitmap(int x, int y, int sx, int sy, uint8_t *bitmap)
{
    tft.setAddrWindow(x, y, x + sx - 1, y + sy - 1);
    tft.pushColors(bitmap, sx * sy, 1);
}

and call it with:
Code: [Select]

    drawBitmap(344, 154, 102, 60, seconds);


This means that you have a friendly function and there is no need to add a UTFTGLUE class.

Regarding accessing GLUE methods from tft.   tft knows nothing about lcd.
However,  lcd knows about the MCUFRIEND_kbv class (and the Adafruit_GFX class and the Print class ...)

It is all a question of inheritance.   
You inherited your good looks from Atilla the Hun.   A DNA test can confirm it.   
Atilla the Hun never knew that Louis the Australian would be descended from him.

UTFTGLUE inherits from MCUFRIEND_kbv
MCUFRIEND_kbv never knew that UTFTGLUE might "be descended" from her.

You should always try to write programs that are easy to understand.    If the regular class methods() do not seem intuitive,   write a helper function.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Jun 11, 2016, 04:11 am
First off,   it is very unwise  (tm) to have a tft object and an lcd object.
If you are adamant that you want an lcd object,  omit the tft object.   The lcd object will know how to do everything that any MCUFRIEND_kbv can do.

I strongly advise that you stick with the MCUFRIEND_kbv class.
If you feel happier with     lcd.drawBitmap(344, 154, 102, 60, seconds); just write a helper function:

<<<snip>>>

This means that you have a friendly function and there is no need to add a UTFTGLUE class.
Thanks for your very informative response   :D

I admit I didn't know about "helper" functions even though I DID consider copying into my sketch the "drawBitmap" method out of "UTFTGLUE.h". Your helper function is much neater   :D

I must also admit my final resistance to "pushColors" is that "sx * sy" must be less that 65,536 (the 16 bit limit)   :(

In other sketches I "drawBitmap" with a full screens worth from PROGMEM. In my "clock" sketch I am only overwriting small rectangles of the background so the "pushColors" limitation isn't a problem.

MY computations suggest that a full 480*320 screen would take 3 linked "pushColors" "calls", an unappealing construct/scenario(to my ADHD outlook)   :(

I WILL use your "helper" in my clock though, thanks.   :D

Edit:  Just quickly....

I get these errors with the "helper"  :(

AliXSketch:1834: error: cannot convert 'short unsigned int*' to 'uint8_t* {aka unsigned char*}' for argument '5' to 'void drawBitmap(int, int, int, int, uint8_t*)'

     drawBitmap(344, 154, 102, 60, seconds);

Will investigate in the meanwhile  :)

Edit Again:

Okay changed the uint8_t to uint16_t and it has compiled....

Checking an upload now....   :D

Final Edit:  Okay now, thanks
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 11, 2016, 10:18 am
Sorry,  I just typed the helper function from scratch.
Looking at the UTFT drawBitmap() method,  it expects (uint16_t *)

And yes,   my pushColors() expects int16_t for the number of colors to push.
I make no excuse.    I would never expect anyone to write more than 32767 colors (from SRAM) in one go.

That is why pushColors() has a "first" argument.   i.e. so you can write a big block in smaller chunks.

I have tried to copy the Adafruit API at all times.   e.g. the pushColors() syntax.
There is a good argument for adding a specific drawRectanglularBitmap() method that copies a large block from Flash memory.    I don't think that many people would use it.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Jun 12, 2016, 06:37 am
Thanks for your response   :D

Just quickly is there a way I can use a font from UTFT?

I particularly like the "SevenSeg_XXXL_Num" font and when I tried to use it with your library and Adafruit I got compile errors.

Another newbie question I'm afraid   :(
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: koganei on Jun 12, 2016, 03:35 pm
Hi David,
Just start playing with my mcufriend 2.4" red ST7781 shield today and found your library. Great stuff, only library I could get my TFT working with.
I have a couple of questions:

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 12, 2016, 04:44 pm
The only unused pin is A5.

D10-D13 is used by the microSD
D0-D1 is used by Serial.

Modern controllers can work without A4 (LCD_RESET) if you solder an external pull-up.   Your one can't.

The TFT generally goes out at some stage during the Bootload process.   So what?

Your video has a lousy angle.   Some TFTs need 80 degrees.   Others are viewable at 45 degrees.    Obviously 90 degrees is the best.   I can't see scan lines.   Just an oblique angle.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: koganei on Jun 13, 2016, 02:58 pm
The TFT generally goes out at some stage during the Bootload process.   So what?
What I meant was the display actually looks better in the one second the scan lines disappear when I'm uploading a new sketch, right before the screen goes white, blacks are blacker and text is clearer.
As mentioned previously, you can see it in the video at 0:03. The video may not be very good, but you can see a white hue from the beginning of the video, which disappears slightly after 0:03. After the new sketch is done uploading, the white hue is back.

When I powered my Uno up just now, the scan lines were gone. But after I power cycled it a couple of times, they came back.

I've attached photos which better shows what I'm talking about.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 13, 2016, 03:23 pm
I don't understand.    That particular sketch should show white text on a black background.

When the sketch is being uploaded you generally see white screen until the sketch is fully loaded and has started to run.

Likewise,  you will see white when you power cycle the Uno.   i.e. while it is checking the bootloader and until the sketch runs.

My ST7781 board is the version without a reset button.
I just uploaded the aspect_kbv sketch from the examples.   I get a white screen for about one second when uploading.    And for about 5 seconds from power-cycling.

Quite honestly,  the ST7781 behaves exactly like any other 2.4" shield.   i.e. sharp text,  vibrant colours, steady display.   The graphictest_kbv sketch exercises pretty much everything.

Of course your one may be different.   What country are you in?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: koganei on Jun 13, 2016, 03:43 pm
It's not dependent on the sketch.
When I run a sketch, you see the scan lines, another way to describe it is blacks have low contrast I guess? It's not fully black. While the sketch is running, if I upload another sketch, for roughly 1-2 seconds, the screen will freeze (whatever is on the screen stays there) and the TFT looks better, black becomes fully black, and then you get the white screen and the new sketch starts running, but then the scan lines come back.

I bought it a while ago from Banggood. I'm in Australia. Maybe I just got a dodgy one.

Also, if I don't use the microSD and don't output anything to serial, then I can use D0-D1 and D10-D13?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: koganei on Jun 13, 2016, 04:00 pm
I just found that if I press the reset button quickly, the screen resets and has scan lines. But if I hold the reset button down for more than about 3 seconds, the screen resets and most of the time has no scan lines.
It's probably just a dodgy screen...
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 13, 2016, 04:07 pm
Yes,  you can use A5, D0, D1, D10-D13

If you are unhappy with the display,  buy another one.
If recent,   ask BangGood for a refund.

These boards all tend to have 74HC245 chips.
They should really have 74VHC245 chips (or similar) which are tolerant of input voltage levels.

Having said that,   the displays seem to work ok with HC chips.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: koganei on Jun 13, 2016, 04:14 pm
Nevermind my last post, the behaviour's not consistent.
However, I can press the reset button on the Uno itself and get the scan lines to disappear. Here's a better video: https://youtu.be/JoDcSLXpQMM
The clicks you hear is me pressing and holding the Uno's reset button.

I thought it might have been backlight related, but it doesn't seem like it.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Jmartens1114 on Jun 13, 2016, 06:17 pm
hi david_prentice,
ive had great luck with your work. I would love to follow other projects. I have received some info from my seller about my 2.4 mcufriend red TS and would like to pass it on.
 
https://www.4shared.com/zip/k5oJtSrGce/ZC113200ENmanual.html

Theres quite a bit of it not transfering to english but still useful. I hope the sharing part works
I'm not computer savvy. LOL. thank you for your hard work and time!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 13, 2016, 06:49 pm
Heaven knows what your "downloading site" is or what damage it does.

If you can attach a ZIP to your Forum post,  I will have a look at it.
I am not going to risk your link.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 13, 2016, 07:02 pm
Nevermind my last post, the behaviour's not consistent.
However, I can press the reset button on the Uno itself and get the scan lines to disappear. Here's a better video: https://youtu.be/JoDcSLXpQMM
The clicks you hear is me pressing and holding the Uno's reset button.

I thought it might have been backlight related, but it doesn't seem like it.
Code: [Select]

0-2s shimmers
2-6s you wave it in and out of focus
6-9s white screen
9-11s scan lines
11-15s clear display

If you tell me what you are actually doing at these points,  it might help.

Normally you upload a sketch.   And it runs.   You don't go waving the board in the air.

The only acceptable display is 11-15 seconds.   Is that the "running" program?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Jmartens1114 on Jun 13, 2016, 09:18 pm
Hi Im very sorry but some files to large to attach. :o
I will break down futher.
Here are some that fit
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Jmartens1114 on Jun 13, 2016, 09:26 pm
sorry site wont accept 7z format.
can i email somewhere?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: koganei on Jun 14, 2016, 08:36 am
Code: [Select]

0-2s shimmers
2-6s you wave it in and out of focus
6-9s white screen
9-11s scan lines
11-15s clear display

If you tell me what you are actually doing at these points,  it might help.
The sketch is already running when the video starts. What you're calling shimmers are the scan lines I'm referring to.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 14, 2016, 09:28 am
Look at the chip numbers on the back of your display.   Are they 74HC245 ?

Attach a DMM between the 3.3V pin and 0V pin.    I suggest that you solder some fine wires to the top of the display header pins so that your hands are free to press the Reset button.

When a TFT sketch is running,  I suspect that you will see about 4.0V instead of 3.3V.   This is because the HC chips are not input voltage tolerant.

When the Arduino is reset,   the GPIO pins are all 3-state.   You will see 3.3V on the 3.3V pin.

Quite honestly,   most displays seem to put up with the 4.0V.   I suspect that your display does not.

Plug the display into a Due or Zero.    Since these two boards have 3.3V logic,   they do not have a problem with the 74HC chips.   I bet that the 3.3V pin registers a steady 3.3V at all times.

The solution?  Any one of these:
1.  replace the 74HC245 with 74LV245 or 74AHC245 or 74VHC245 chips.  
2.  use a Due
3.  replace the display

(3) is the easiest solution.
(1) is the cheapest ($0.30) but you would need a rework station to remove the old chips.

Please let me know the result of the DMM tests.
You could solder a 330R between the 3.3V and 0V pins on your display.   This might keep the 3.3V regulator happier.    Please let me know what the DMM says.

An electronics expert may suggest a better chip.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: koganei on Jun 14, 2016, 02:39 pm
Photo of chips attached. They don't have the 74 only the HC245.

Now this is interesting - when I reset the Uno, voltage is 3.25V. When there are scan lines, the voltage is between 3.6-3.9V depending on what it's displaying. On the rare occasion I can get the display working normally with no scan lines, the voltage is actually higher at 3.95-4.15V, and flickers down to 3.9V every now and then.

I don't have a Due or Zero to test with.

I may try the resistor, failing that, I'll probably just go with the easiest solution. =P
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 14, 2016, 05:07 pm
Hello David,

First I would like to thank you for your extensive work on the MCUFriend shileds library. The coverage and support is awesome!

I was reviewing your recommendations to get the MCUFriend shields to work and have run a lot of tests with the one I have but still I get no results. My shield (a 3.5" TFT LCD for Arduino UNO)  uses a ILI9486 Chip. When I run the graphicstest_kbv I only get the first two lines on the Serial window:

" Serial took 0ms to start
ID = 0x9486

"

Nothing else happens and the screen on the TFT is garbled (C:\Program Files\Arduino\20160614_101427.jpg). I have tried to run the LCD_ID_readreg sketch but it does not compile on my laptop. It shows the following error:

"Arduino: 1.6.8 (Windows XP), Board: "Arduino/Genuino Uno"

WARNING: Spurious .github folder in 'DHT sensor library' library
Build options changed, rebuilding all
collect2.exe: error: ld returned 5 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.
"

What could the problem be with this shield? I currently have an Arduino UNO R3 board. Are the pinouts aligned between the UNO and the TFT Shield? Is this a driver problem? I am not sure if I should try forcing a different board. The  ILI9486 seems to be covered by many of the UTFT library versions but the display does not work with any of them. What do you recommend I try next?

Your help is very appreciated.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 14, 2016, 06:02 pm
You have read the only information on the Serial.   i.e. that it has  ID = 0x9486
Your connections must be good.  

The LCD_ID_readreg.ino sketch should compile and run on anything.
I would try again.   And copy-paste the output from the Serial terminal.

Always make sure that the male pins are connecting with the female sockets.    Ebay items often arrive in the mail with bent pins.

The graphictest_kbv sketch should run on any Uno.

Quote
Nothing else happens and the screen on the TFT is garbled (C:\Program Files\Arduino\20160614_101427.jpg).
this JPEG is on your PC.  Not on the internet !!

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 14, 2016, 09:06 pm
Thaks david for your quick response.

Sorry, the attached pics were too big at first and then they were rejected by the webpage. Here they are.

I have checked the pins  alignment and sequence with the LCD_ID_readreg several times. Pins are all lined-up male to female and the board rests flat on top of the UNO. 

The LCD_ID_readreg.ino sketch just fails to compile even without connecting the board to the pc. I have the latest version of the Arduino IDE (1.6.9). I am not sure what is the problem with the sketch/IDE nor what that error means (excuse my ignorance  :( ). I have attached also the verbose output of the failed sketch compilation.

It seems I have v 2.9 of the MCUFRIEND-kbv.h library

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 14, 2016, 09:15 pm
You have read the only information on the Serial.   i.e. that it has  ID = 0x9486
Your connections must be good. 

The LCD_ID_readreg.ino sketch should compile and run on anything.
I would try again.   And copy-paste the output from the Serial terminal.

Always make sure that the male pins are connecting with the female sockets.    Ebay items often arrive in the mail with bent pins.

The graphictest_kbv sketch should run on any Uno.
this JPEG is on your PC.  Not on the internet !!

David.

David,

It seems there is something wrong with my .jpg attachments. The site keeps blocking them for upload. Not sure how I can get them uploaded or shown to you....
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 14, 2016, 09:29 pm
Your build log shows no error messages at all.

If you have errors or warnings,  these are generally printed in orange.
Of course you need to turn on compiler [verbose]

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 14, 2016, 09:34 pm
I have the compiler on verbose. The last three lines of the .txt file have the error. Yes the compiler shows those in orange:

"collect2.exe: error: ld returned 5 exit status

exit status 1
Error compiling for board Arduino/Genuino Uno.
"

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: CrossRoads on Jun 14, 2016, 09:36 pm
.jpg's too large perhaps? 1M limit on size?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 14, 2016, 09:46 pm
No. I shrank them to about 50K each. The forum says they were blocked for security reasons...not sure what may cause that. they are standard .jpg files
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 15, 2016, 01:09 am
Thanks for your response   :D

Just quickly is there a way I can use a font from UTFT?

I particularly like the "SevenSeg_XXXL_Num" font and when I tried to use it with your library and Adafruit I got compile errors.

Another newbie question I'm afraid   :(
I have written a sketch that takes a UTFT-style font and creates a Free_xxxxx.h style.
So you could end up using the same ugly UTFT fonts that you know and  love.

Even though the tables are  lot more complex,  the Free_xxx style only stores the minimal bitmap.   So a Free_xxx version of a UTFT font actually uses less Flash memory.

Re drawBitmap() method.    Actually this is part of the Adafruit_GFX class.   The arguments are different to the UTFT method.   Since it is GFx rather than MCUFRIEND_kbv,  it does not make use of the hardware speed like pushColors().

I have attached your "big" seven segment font.   Either put it with the other Free_xxxx fonts or in a local Tab.

Code: [Select]

#include "Fonts/FreeSansBold18pt7b.h"
#include "FreeSevenSeg_XXXL_Num.h"
    ...
    tft.setFont(&FreeSansBold18pt7b);
    tft.setCursor(20, 20);
    tft.println("Happy days are here again");
    ...
    tft.setFont(&FreeSevenSeg_XXXL_Num);
    tft.setCursor(0, 315);
    tft.println("0123");
    ...


Someone asked the other day about how to use GFX methods.
There is an Adafruit Tutorial (https://learn.adafruit.com/adafruit-gfx-graphics-library/overview) that you might find useful.

I will post the font conversion sketch later.

David.  
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Jun 15, 2016, 02:28 am
Thanks ever so much David   :D

I'm on my way to play badminton so am looking forward to enjoying your help after I have exercised the old body. My mind is okay, just ensuring the body keeps up   :D

Thanks   :D

That font is absolutely ideal for the HH MM SS part of the display of a digital clock (to my funny mind). As you know it is only digits 0 to 9, nothing else. Perfect   :D

Edit: I was using "FreeMonoBold24pt7b" with size 2 before and changed to your converted font "FreeSevenSeg_XXXL_Num". BEAUTIFUL!!!!

Obviously the exact positioning etc has to be re-tweaked but otherwise it is PERFECT!  Thank You   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ardcp on Jun 15, 2016, 07:16 am
Regarding the security problem with .jpg files, I have had the same problem with images taken with a compact camera.
The solution was to remove all exif information.
On linux,  the information can be removed by e.g exiftool or jpegtran. On Windows, I do not know.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 15, 2016, 06:42 pm
David,

Regarding post #454:

I was able to get the LCD_ID_readreg to work  ;)  . It seems there is an issue with the ld.exe and WinXP. Here is the Serial window dump from that sketch. (Hopefully this time it uploads the image)

I also re-ran the graphicstest_kbv but it only outputs the first two lines on the Serial window. I have also attached the Serial window contents for your reference.

The TFT screen is still garbled :smiley-confuse: . Do you think this could be a driver or hardware issue? Your help is greatly appreciated....
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 15, 2016, 07:01 pm
Regarding the security problem with .jpg files, I have had the same problem with images taken with a compact camera.
The solution was to remove all exif information.
On linux,  the information can be removed by e.g exiftool or jpegtran. On Windows, I do not know.

ardcp, you were right. As soon as I removed the exif information it finally worked! I did it  the crude way: Print Screen into another image.

Thanks a bunch!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 15, 2016, 07:51 pm
So you have posted two JPEGs that are totally inappropriate.    You should have copy-pasted from the Serial Terminal.    Equally well,  you could have just said "it reports an ID = 0x9486

The third JPEG is "almost useful".   It shows a garbled screen.    If you had photographed it from 90 degrees,  I could see what pattern was actually displayed.    I would have also seen if you had some stray wires going into the Arduino.

Please try to look at a problem from "someone else's point of view".   i.e. informative photos.  accurate information.   After all,  the "someone else" is in a different country.

Yes,  your LCD_ID_readreg is slightly different to my ILI9486.   Life would be so much simpler if you had copy-pasted.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 15, 2016, 09:37 pm
Well, excuse my ignorance. I don't really know the meaning of all the text shown in the Serial screen. Last time I just said it reports an ID = 0x9486 you prompted me to disclose the full Serial output of the LCD_ID_readreg (#455). In this light, I chose to show you both the sketch and the output.

As far as the picture of the screen, it was to show you what it is actually displaying. There is movement in the garbled image as I can see the bars in the image sliding every now and then. My bad I did not include any images of the connections, etc. At the time I was not sure if it was too much information.

Here are the pics from 90 deg angle and I have removed all the wires from the breadboard. They were never connected to the arduino or the TFT module, but removed them to show the cleanest pictures.

Not sure what additional information you might need as I am not fully versed on the troubleshooting process of these shields much less what might seem to be the cause of the problem.

Thanks,


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 15, 2016, 09:46 pm
Here are the other two sides of the board.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 15, 2016, 10:22 pm
90 degrees means look at the board from directly above.  i.e. how a human would look at a screen.
After the four extra JPEGs,  I still can't see what the screen is displaying i.e. random pixels,  lines, stripes, circles, ...

Running LCD_ID_readreg and copy-pasting the output would be helpful.   i.e. machine readable. 
But a proper photo of what the screen is displaying is most important.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 15, 2016, 10:34 pm
Ok. Thanks a bunch for the clarification.

Here is the LCD_IO_readreg output and the 90deg Pic.:

"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) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 54 54 80 66   Manufacturer ID
reg(0x0009) 00 00 61 00 00   Status Register
reg(0x000A) 08 08   Get Powsr Mode
reg(0x000C) 66 66   Get Pixel Format
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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) 02 02 02 3B 00   Display Control
reg(0x00B7) 06 06   Entry Mode Set
reg(0x00BF) FF FF 68 14 00 FF   ILI9481, HX8357-B
reg(0x00C0) 0E 0E 0E 00 00 00 00 00 00   Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 00   Power Control
reg(0x00D2) 00 00 00 00 00   NVM Read
reg(0x00D3) 00 00 94 86   ILI9341, ILI9488
reg(0x00DA) 54 54   RDID1
reg(0x00DB) 80 80   RDID2
reg(0x00DC) 66 66   RDID3
reg(0x00E0) 00 00 54 07 44 05 08 00 54 07 44 05 08 44 44 00   GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   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 00 00 00   Interface Control
"

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 16, 2016, 09:37 am
The LCD_ID_readreg program shows the "hard reset" values contained in the registers.

Several of your registers are not the "reset values" that are written in the data sheet.

I suspect that you have a duff controller.   Let's face it Ebay vendors will sell anything.
Ask for your money back.

I could initialise all the registers to the datasheet values.    And this might get you operational.   But for something so seriously wrong,   I would not expect the chip to be reliable.

Which country are you in?
How much experimenting are you prepared to do?
So far,  we have had communications problems.   e.g. we do not understand each other.
Can you try the shield with a different Arduino?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: makoshatu on Jun 16, 2016, 10:38 am
Hi David and Afarina2.

I have exactly the same display and I faced the same issue. If I run the "LCD_ID_readreg" sketch I get the same log output which was inserted in post #471 by Afarina2.
If I upload the "graphictest_kbv" sketch it displays garbled image, it looks like random color pixels are shown. I found, that tft.drawPixel() function does not work properly. I tried the following code:

tft.drawPixel(0, 0, YELLOW);
pixel = tft.readPixel(0, 0);
Serial.println(YELLOW, HEX);
Serial.println(pixel, HEX);

The result:

Serial took 0ms to start
ID = 0x9486
FFE0
1613

It does not matter if I change the color of the given pixel, the tft.readPixel() returns with the same 0x1613 value. Is it possible that the tft.drawPixel() function writes wrong area of the graphics memory? The scroll function works fine, at least it scrolls the garbled image up and down.

Thank you indeed.

Have a nice day.
Attila.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 16, 2016, 11:02 am
Well,  the good news is that it is a shield / library problem and not just Afarina.

So it is worth investigating.  Where are you, Attila ?

I have always assumed that an ID of 0x9486 must mean an Ilitek ILI9486 chip.
Several different makes will return an ID of 0x9325 for their versions of the Ilitek ILI9325 chip.  e.g. a Himax HX8352-B

When you have two different makes,   they may have different "Manufacturer registers"
This makes life very difficult.   Unless you can find which other chip returns 0x9486.    And I can find its datasheet.

Perhaps you could ask the vendor that sold you the display.   It is in their interest to have satisfied customers.   Otherwise they have to do a lot of refunds.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: makoshatu on Jun 16, 2016, 11:32 am
I am from Hungary. I ordered this shield from Ebay and I am not sure if the Seller is able to answer deeper technical questions like this. Anyhow, I am going to ask them about the manufacturer of the driver IC and maybe they can send me the datasheet, too. It can be easily a counterfeit driver IC, since the display was dirty cheap, it came from Hong Kong.

I forget to mention, but I get several data conversion related Warning messages when I compile the graphictest_kbv sketch. Maybe it is important, I insert them here:

Code: [Select]
C:\Program Files (x86)\Arduino\libraries\Mcufriend_kbv\examples\graphictest_kbv\graphictest_kbv.ino: In function 'void loop()':

C:\Program Files (x86)\Arduino\libraries\Mcufriend_kbv\examples\graphictest_kbv\graphictest_kbv.ino:141:5: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     };

     ^

C:\Program Files (x86)\Arduino\libraries\Mcufriend_kbv\examples\graphictest_kbv\graphictest_kbv.ino:141:5: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

C:\Program Files (x86)\Arduino\libraries\Mcufriend_kbv\examples\graphictest_kbv\graphictest_kbv.ino:141:5: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

C:\Program Files (x86)\Arduino\libraries\Mcufriend_kbv\examples\graphictest_kbv\graphictest_kbv.ino:141:5: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

C:\Program Files (x86)\Arduino\libraries\Mcufriend_kbv\examples\graphictest_kbv\graphictest_kbv.ino:142:58: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     char *colorname[] = { "BLUE", "GREEN", "RED", "GRAY" };

                                                          ^

C:\Program Files (x86)\Arduino\libraries\Mcufriend_kbv\examples\graphictest_kbv\graphictest_kbv.ino:142:58: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

C:\Program Files (x86)\Arduino\libraries\Mcufriend_kbv\examples\graphictest_kbv\graphictest_kbv.ino:142:58: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

C:\Program Files (x86)\Arduino\libraries\Mcufriend_kbv\examples\graphictest_kbv\graphictest_kbv.ino:142:58: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]


Sketch uses 31,050 bytes (96%) of program storage space. Maximum is 32,256 bytes.
Global variables use 1,591 bytes (77%) of dynamic memory, leaving 457 bytes for local variables. Maximum is 2,048 bytes.
Low memory available, stability problems may occur.



Thank you for your help.

Best regards.
Attila.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Levy on Jun 16, 2016, 12:38 pm
Hello!
I got a screen from ebay, and have some problems with it. On display it says Mcufriend 3.5 TFT for arduino UNO. I connected it to Arduino Nano, run ID sketch but didn't get any ID. I tried setting the LCD manually and got it working with ILI9481. The problem is that in portrait mode it works perfectly, but in landscape text is mirrored and still in portrait mode but just on half of the screen. I tried looking for solution but didn't find any. Can you please help? Thank you.

   
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(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 83 88 68 Manufacturer ID
reg(0x0009) 00 80 63 00 80 Status Register
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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) BF BF 0F 11 FF 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) 41 00 Entry Mode Set
reg(0x00BF) 00 02 04 15 11 FF ILI9481, HX8357-B
reg(0x00C0) 00 3B 00 00 07 01 Panel Control
reg(0x00CC) 2A 2A Panel Control
reg(0x00D0) 00 05 08 Power Control
reg(0x00D2) 04 62 00 00 00 NVM Read
reg(0x00D3) 00 00 00 00 ILI9341, ILI9488
reg(0x00DA) 00 83 RDID1
reg(0x00DB) 83 8F RDID2
reg(0x00DC) 8F 22 RDID3
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 00 00 00 Interface Control
   
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 16, 2016, 01:00 pm
First off.   God designed Male pins and Female sockets for a reason.   e.g. inserting a Shield into a Uno.    A Nano requires too many suspect wires.

I presume the library just says ID = 0x0000 and tries to use a ILI9341

I do not recognise the ID.   From register 0xBF,  you have MIPI Alliance Code for ILITEK,  Device ID 0x1511.

I suggest that you force tft.begin(0x9481) and report back what happens.
Oops.  I see that you have tried that.

Please make detailed notes of every "wrong" behaviour.   And in each aspect.   e.g.
Blue Portrait:  No software scroll
Green Landscape:  still in Portrait, ...
Red ...
Gray ...

Or a video of the sketch.     

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Levy on Jun 16, 2016, 01:43 pm
First off.   God designed Male pins and Female sockets for a reason.   e.g. inserting a Shield into a Uno.    A Nano requires too many suspect wires.

I presume the library just says ID = 0x0000 and tries to use a ILI9341

I do not recognise the ID.   From register 0xBF,  you have MIPI Alliance Code for ILITEK,  Device ID 0x1511.

I suggest that you force tft.begin(0x9481) and report back what happens.
Oops.  I see that you have tried that.

Please make detailed notes of every "wrong" behaviour.   And in each aspect.   e.g.
Blue Portrait:  No software scroll
Green Landscape:  still in Portrait, ...
Red ...
Gray ...

Or a video of the sketch.     

David.
I checked the wiring few times, everything is connected with female-female cables. I wouldn't bother you if i wasn't sure I did everything ok :)

Im using ILI9481 driver, in portrait mode everything works perfect.
Landscape and landscape_rev mode isn't rotated just mirrored. Sketch runs, text and colors show, it is just not rotated 90° and it's mirrored.

here is a aspect_kbv sketch, shortened a little because I'm on a slow network right now, but you can see the problem.

https://www.youtube.com/watch?v=bvmsH913ooY
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 16, 2016, 03:13 pm
David/Attila,

Thank you very much for your responses. I am very eager to experiment with the board. I have very little other options. I have noticed that these cheap shields come with very little instructions and a lot of hidden stuff. I figure that if I buy another one I might end up in a similar position.  I am in the US (thus the time-lag in the communications).

I purchased the shield on Ebay (http://www.ebay.com/itm/361538912387?euid=a8338ef0b5e64d3fa98ba0282ca0e9d1&bu=43489470258&cp=1&sojTags=bu=bu) and the vendor, just as Attila mentioned, don't think will be able to answer deep technical questions. I asked for help already and they sent me an email with an arduino sketch (attached) and what seems to be a video file (an .avi; not sure what would be the usefulness of that). I asked the seller about the second attachment yesterday but they have not responded yet. I will ask them again and inquire about the specifics of the issue.
The sketch provided by the seller does not change the outcome on the tft. :smiley-confuse:

Also, on the ebay page where I bought the shield, they have some register values for the shield. I am not sure if the information is useful for you but I have included them below just in case.

BTW, just like Attila, I get the same conversion warnings during compilation of the graphicstest_kbv.

Adrian

Ebay Item Description:

    100% brand new and high quality
    Tftlcd 3.6-inch touch screen with uno r3
    3.6-inch LCD touch screen
    Resolution : 480x320
    Controller : ili9488
    Test code:
    ILI9327:
    LCD_Write_COM(0xE9);
    LCD_Write_DATA(0x20);
    LCD_Write_COM(0x11); //Exit Sleep
    delay(100);
    LCD_Write_COM(0xD1);
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x71);
    LCD_Write_DATA(0x19);
    LCD_Write_COM(0xD0);
    LCD_Write_DATA(0x07);
    LCD_Write_DATA(0x01);
    LCD_Write_DATA(0x8);
    LCD_Write_COM(0x36);
    LCD_Write_DATA(0x48);
    LCD_Write_COM(0x3A);
    LCD_Write_DATA(0x05);
    LCD_Write_COM(0xC1);
    LCD_Write_DATA(0x10);
    LCD_Write_DATA(0x10);
    LCD_Write_DATA(0x02);
    LCD_Write_DATA(0x02);
    LCD_Write_COM(0xC0); //Set Default Gamma
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x35);
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x01);
    LCD_Write_DATA(0x02);
    LCD_Write_COM(0xC5); //Set frame rate
    LCD_Write_DATA(0x04);
    LCD_Write_COM(0xD2); //power setting
    LCD_Write_DATA(0x01);
    LCD_Write_COM(0x44);
    LCD_Write_COM(0xC8); //Set Gamma
    LCD_Write_DATA(0x04);
    LCD_Write_DATA(0x67);
    LCD_Write_DATA(0x35);
    LCD_Write_DATA(0x04);
    LCD_Write_DATA(0x08);
    LCD_Write_DATA(0x06);
    LCD_Write_DATA(0x24);
    LCD_Write_DATA(0x1);
    LCD_Write_DATA(0x37);
    LCD_Write_DATA(0x40);
    LCD_Write_DATA(0x03);
    LCD_Write_DATA(0x10);
    LCD_Write_DATA(0x8);
    LCD_Write_DATA(0x80);
    LCD_Write_DATA(0x0);
    LCD_Write_COM(0x2A);
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0xeF);
    LCD_Write_COM(0x2B);
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x00);
    LCD_Write_DATA(0x01);
    LCD_Write_DATA(0x3F);
    LCD_Write_COM(0x29); //display on
    LCD_Write_COM(0x2C); //display on
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 16, 2016, 03:28 pm
Thanks for the Ebay link
Thanks for the sketch

Does the sketch work?

Does the video file work?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 16, 2016, 04:13 pm
The sketch does not work. The tft is still scrambled.

The video file does not work either.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Levy on Jun 16, 2016, 04:51 pm
My lcd looks the same, even the item descrition is the same, but the chip is ili9481 and in seller description is 9488.

http://m.ebay.com/itm/3-6-inch-TFT-LCD-Display-Touch-Screen-Module-Arduino-UNO-R3-Board-Plug-and-Play-/141647130960
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 18, 2016, 10:11 am
@Levy,

I can certainly get your display working in all aspects.   Please PM me with your Email if you are prepared to do some tests.

@Makoshatu, Afarina2,

I am doubtful about getting your display working.   Please PM me with your Email if you are prepared to do some tests.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Farzad321554 on Jun 18, 2016, 10:36 pm
Dear David
I've attached the back & front .jpg of my display (2.8-(ft1509)- mcufriend- Red) and I'm using it with uno
When I uoload "graphictest_kbv" nothing happens & a white screen is displayed but when I change the force ID to 9320 or 9325 some unclear and pale pictures are shown. It seems that all functions are working well; like scroll, rotation ...; bud unclearly! I even can hardly see the penguin!  :)

graphictest info:

Serial took 0ms to start
ID = 0x6090


The LCD_ID_readreg info:

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) 60 90 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 00 00 00 Status Register
reg(0x000A) 00 00 Get Powsr Mode
reg(0x000C) 00 00 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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) 02 00 02 00 02 00 02 00 02 Panel Control
reg(0x00C8) 00 FF 00 FF 00 FF 00 FF 00 FF 00 FF 00 GAMMA
reg(0x00CC) 00 00 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 00 00 NVM Read
reg(0x00D3) 00 00 00 00 ILI9341, ILI9488
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 00 00 00 Interface Control




Thanks in advance for your help David
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 18, 2016, 11:29 pm
From your photos,  it looks like a 400x240 display.
It uses 16-bit style of registers like ILI9320
I do not recognise the ID which is 0x6090

Your colours are inverted.   That is easy to solve.  Likewise the Geometry.
However without a Manufacturer,  part number or datasheet I really have no idea how to initialise it properly.

It should be simple enough to display when initialised.   i.e. it uses the same display registers as an ILI9320.

Where did you get this shield?   Email the vendor.  Ask for the controller part number.

David. 
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Vior95 on Jun 19, 2016, 11:51 am
Hello I got MEGA 2560 and TFT board which looks exactly like this DX board (photos attached) from aliexpress plugged in like a shield.


I spent more than 20 hours trying to get my lcd panel to work by googling, soldering and trying all types of libraries but all with no success.

I got really frustrated and I think I lost all of my hope for happy end. This is my last chance.

Things that work:

- When I run touch-screen-library-master touchscreendemoshield  from adafruit it shows correct x y positions on touch.
-LCD backlight since the screen is always white
- Thats about it. Maybe SD card works too, I haven't checked yet.


When i run
LCD_ID_readreg this is the output i get:

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(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 08 08 08 08 08 Status Register
reg(0x000A) 08 08 Get Powsr Mode
reg(0x000C) 08 08 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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) 08 08 08 08 08 08 ILI9481, HX8357-B
reg(0x00C0) 00 00 00 00 00 00 00 00 00 Panel Control
reg(0x00C8) 08 08 08 08 08 08 08 08 08 08 08 08 08 GAMMA
reg(0x00CC) 08 08 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 00 00 NVM Read
reg(0x00D3) 00 00 00 00 ILI9341, ILI9488
reg(0x00DA) 08 08 RDID1
reg(0x00DB) 08 08 RDID2
reg(0x00DC) 08 08 RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-N
reg(0x00EF) 08 08 08 08 08 08 ILI9327
reg(0x00F2) 20 94 0B 08 08 18 08 1D 48 08 0F 08 Adjust Control 2
reg(0x00F6) 01 01 03 00 Interface Control


I also tried forcing the identifier, but again, no success.

Is there something I'm missing? Or maybe the board is just damaged?

Thank you in advance for any help, it will be appreciated .
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 19, 2016, 12:27 pm
Your shield looks like a regular 2.4" 240x320 display.   Do the pcb traces in the photo match exactly?

I have no idea what controller you have.   I can not see any clues from the LCD_ID_readreg report.

Please post a link to the actual AliExpress sale.    It might give some clues.

Otherwise,  just ask AliExpress about the controller or your money back.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Vior95 on Jun 19, 2016, 01:23 pm
Yes they match exactly.

This is product description from Dx.com

Code: [Select]
- 4-wire resistive touchscreen
 - 240 x 320 resolution
 - spfd5408 controller with built in video RAM buffer
 - 8 bit digital interface, plus 4 control lines
 - Uses digital pins 5-13 and analog 0-3. That means you can use digital pins 2, 3 and analog 4 and 5. Pin 12 is available if not using the micro SD - 5V compatible, use with 3.3V or 5V logic
 - On-board 3.3V 300mA LDO regulator - Support 2GB micro SD TF card

Link: http://www.dx.com/p/diy-2-4-tft-lcd-touch-screen-shield-expansion-board-for-arduino-uno-350121#.V2ZnB7h9670



And this is link to aliexpress:

http://www.aliexpress.com/item/Free-Shipping-1pcs-2-4-inch-TFT-touch-LCD-Screen-Module-For-Arduino-UNO-R3/2034511569.html

I got different board though, and there is no info on the page.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Jun 22, 2016, 02:56 pm
Hi David,

Did I hear you say (in an earlier response) That I couldn't expect very good results for the "touch" with a Due?

Anyway, I ran "TouchScreen_Calibr_kbv" and noted and transfered the calibration values into "Touch_shield_kbv" and got really bad touch response.

I couldn't quantify the responses so I added
Code: [Select]

    tft.drawRect(100, 200, 100, 200, WHITE);//draw a white box
    tft.drawPixel(50, 150, WHITE);
    tft.drawPixel(250, 450, WHITE);

at the end of "setup".

I then traced the white box (with a ruler) and touched the 2 white dots. The results are in the attached picture.

As you can see the bottom white dot is almost right. The top dot is way out and the box is also pretty bad.

Is this the best I can hope for?

The exercise was with an AliX 3.95" display and a Due.

The response on the bottom right hand side was almost perfect.

The results aren't linear but there seems to be method in the madness?

Thanks in anticipation....   :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 22, 2016, 03:03 pm
A Touch Panel is typically 300R in the X direction.  500R in Y direction.
This is a hefty load for a 3.3V Due.   i.e. 11mA is out of spec for the Due GPIO.

The Mega style of Shield has its own XPT2046 Touch Controller chip.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bak_009 on Jun 24, 2016, 06:03 pm
I have a TFT round display like this one:

http://www.aliexpress.com/item/2-2-inch-39PIN-TFT-LCD-LCM-color-round-touch-screen-R61505V-drive-IC-320xRGBx240-phone/1614994856.html

The ID that I get from this LCD is 0xC505. I want to run it on Arduino Due but the Glue_Demo example in it does not work. Other examples like aspect_kbv and graphictest_kbv works on it but the Glue_Demo does not work. The Glue_Demo works on Uno but on Due its not working. Actually my project uses Glue_demo example commands such as the commands in this example uses myGLCD.setColor but in graphictest_kbv example the commands are like tft.setTextColor. I want to ask if I use the tft.-- commands how much will I be changing the code, are all commands available on it?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 24, 2016, 06:39 pm
The Library is really intended for proper Uno Shields.
Yes,  your bare module will work if you have 3.3V logic e.g. from a Due.

Yes,  it has identified a R61505V controller.   And that is what your Aliexpress advert actually says!

The GLUE class should work on a Due e.g. with the GLUE_Demo_320x240.
The UTFTGLUE class is only for running a legacy UTFT sketch.

I can see little point in writing anything new with the UTFTGLUE methods().   Just use the native GFX methods() as Adafruit intended.   They are more intuitive.

Mixing GLUE and native methods is pretty messy.   They will work but you have a maintenance nightmare.

I make no attempt to write text at 45 degrees like UTFT.   Otherwise,   MCUFRIEND_kbv can do everything that UTFT does and more.

If you have a build problem with Due and Glue,  please say which IDE version,  which Library version.   I am sure that I can get you going.    Explain what you want to do.  Preferably with working UTFT code.   UTFTGLUE generally does it transparently.   I can show you how to use the cleaner native GFX methods.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 24, 2016, 09:14 pm
I have just tried GLUE_Demo_320x240 on a Due with a ILI9341 Shield.

Sure enough,  my current private version of MCUFRIEND_kbv compiled but produced a White Screen.  I presume you are using the v2.9.0 Release posted on message#0 of this thread.

I had to make changes:
Code: [Select]

// Declare which fonts we will be using
extern uint8_t SmallFont[];        //comment this out if you have <FreeDefaultFonts,h>

void setup()
{
    randomSeed(analogRead(5));     //create seed from A5 instead of A0
    pinMode(A0, OUTPUT);           //RD pin must be made output high
    digitalWrite(A0, HIGH);        //UTFT has no concept of a RD pin
  
// Setup the LCD
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
}


I have no explanation for why the Due does not like the analogRead(0)
The Demo does not need a fresh Random seed anyway.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: siriusbg on Jun 25, 2016, 05:02 pm
Hi Guys!
I need help with one of the mcufriend 3.5inch displays. I'm trying to get him working all day on arduino nano(as a uno shield config) without any success. I'm getting only screen blinking and colored pixels...
The display link is: http://www.ebay.co.uk/itm/251933449255?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

And this is the readreg info:
Code: [Select]
reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 54 54 80 66 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 08 08 Get Powsr Mode
reg(0x000C) 66 66 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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) 02 02 02 3B 00 Display Control
reg(0x00B7) 06 06 Entry Mode Set
reg(0x00BF) FF FF 68 14 00 FF ILI9481, HX8357-B
reg(0x00C0) 0E 0E 0E 00 00 00 00 00 00 Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA
reg(0x00CC) 00 00 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 00 00 NVM Read
reg(0x00D3) 00 00 94 86 ILI9341, ILI9488
reg(0x00DA) 54 54 RDID1
reg(0x00DB) 80 80 RDID2
reg(0x00DC) 66 66 RDID3
reg(0x00E0) 00 00 54 07 44 05 08 00 54 07 44 05 08 44 44 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 00 00 00 Interface Control


ili9486?!
Any help will be appreciated!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 25, 2016, 05:31 pm
You are not alone.   afarina2 and makoshatu have exactly the same Shield.

I am 99% certain that it is not a genuine Ilitek ILI9486 chip because it does not read the power-up default values in the registers.

Please could you run the attached sketch.   It reads more registers than the LCD_ID_readreg sketch.

Please copy-paste the output to your message.

If as I suspect,  the controller is not made by Ilitek,   I am not very hopeful.
The "User" registers will always be the same,   but the "Manufacturer registers" might be completely different and live at different addresses.   

Without a part number or even a Manufacturer name,  I am completely in the dark.   If I can see your readreg output,  it might help me guess.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: siriusbg on Jun 25, 2016, 05:40 pm
Here is the output, David. Thanks.

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)

ILI9486 / 1LI9488
reg(0x0004) 54 54 80 66 Manufacturer ID
reg(0x0005) 00 00 DSI errors
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 08 08 Get Powsr Mode
reg(0x000B) 00 00 Get Address Mode
reg(0x000C) 66 66 Get Pixel Format
reg(0x000D) 00 00 Get Display Mode
reg(0x000E) 00 00 Get Signal Mode
reg(0x000F) 00 00 Get Diagnostic Result
reg(0x00B0) 00 00 Interface Mode
reg(0x00B1) B0 B0 11 Frame Rate Normal
reg(0x00B2) 00 00 11 Frame Rate Idle
reg(0x00B3) 00 00 11 Frame Rate Partial
reg(0x00B4) 00 00 Inversion Control
reg(0x00B5) 02 02 02 0A 04 Blanking Porch
reg(0x00B6) 02 02 02 3B Display Control
reg(0x00B7) 06 06 Entry Mode Set
reg(0x00C0) 0E 0E 0E Power Control 1
reg(0x00C1) 04 04 00 Power Control 2
reg(0x00C2) 33 33 Power Control 3
reg(0x00C3) 33 33 Power Control 4
reg(0x00C4) 33 33 Power Control 5
reg(0x00C5) 00 00 60 00 00 VCOM Control 1
reg(0x00D3) 00 00 94 86 RDID4
reg(0x00DA) 54 54 RDID1
reg(0x00DB) 80 80 RDID2
reg(0x00DC) 66 66 RDID3
reg(0x00E0) 00 00 54 07 44 05 08 00 54 07 44 05 08 44 44 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-N
reg(0x00F2) 00 00 00 00 00 00 00 00 00 00 Adjust 2
reg(0x00F7) 00 00 00 00 00 Adjust 3
reg(0x00F8) 00 00 00 Adjust 4
reg(0x00F9) 00 00 00 Adjust 5
reg(0x00FB) 00 00 SPI Read
reg(0x00FC) 00 00 00 Adjust 6
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 25, 2016, 06:49 pm
Thanks very much.  A genuine Ilitek ILI9486 report is in the "output_9486.h"

You will notice that your device gives a non-zero dummy byte.  
Also you have a (0xBF) register.   A genuine ILI9486 does not.
Your 0xE0, E1 Gamma registers are "unusual"
Your 0xFx Adjust registers are all zeros.

I suspect that your other "Manufacturer registers" live in 0xE0 - 0xEF.
Quite honestly,   there is little point in writing "Ilitek default" values into registers that probably do not correspond at all with Ilitek addresses.

You can try reading every register from 0xC0 to 0xFF.   However I think your best bet is to email your Chinese supplier.   Ask if she knows the controller Manufacturer or part number.   Even better if she has a datasheet.

David.

Edit.   I think that you have a Raydium RM68140 controller.   I can NOT find a datasheet.   Are there any Chinese speakers out there who can help?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 26, 2016, 11:15 am
Is anyone with good Google skills able to find a Raydium RM68140 datasheet?

Since your screen actually powers up,  perhaps it only accepts default 18-bit colour format.
Most controllers default to 18bit 6-6-6 but can display 16bit 5-6-5 format.

Please try this little sketch.   Does it show anything at all?
Code: [Select]

#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

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

const char *colornames[] = {
    "BLACK", "BLUE", "RED", "GREEN", "CYAN", "MAGENTA", "YELLOW", "GRAY"
};
uint16_t colors[] = {
    BLACK, BLUE, RED, GREEN, CYAN, MAGENTA, YELLOW, GRAY
};

void setup()
{
    Serial.begin(9600);
    uint16_t ID = tft.readID();
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    tft.begin(ID);
    uint8_t pixfmt = 0x66;
    tft.pushCommand(0x3A, &pixfmt, 1);   //use default 18-bit mode
    tft.fillScreen(0x0000);
    tft.setTextColor(0xFFFF, 0x0000);
    tft.setTextSize(3);
    tft.setCursor(0, 0);
    tft.println("RM64180");
    tft.print("ID = 0x");
    tft.println(ID, HEX);
    delay(1000);
}

void loop()
{
    static uint8_t n;

    if (++n >= 8) n = 0;
    tft.setCursor(0, 0);
    tft.fillScreen(colors[n]);
    tft.println(colornames[n]);
    delay(1000);
}


You could also try forcing tft.begin(0x9329).

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 27, 2016, 06:51 pm
David,

I tried the little code you listed below just as you indicated and EUREKA!!!!! It works :D I did not have to force the tft.begin to 0x9329.

The Serial monitor only shows a line of text ID = 0x9486. Nothing else. Colors and names are mismatched and the text is mirrored (Inverted) but all that is fixable.

I updated the code to list the color names and colors in a list and noticed that the black is missing in the list.
 AFARINA2 EDITED CODE
Code: [Select]

#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

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


const char *colornames[] = {
   "BLACK", "BLUE", "RED", "GREEN", "CYAN", "MAGENTA", "YELLOW",  "GRAY"

};
uint16_t colors[] = {
    BLACK, BLUE, RED, GREEN, CYAN, MAGENTA, YELLOW, GRAY
   };

void setup()
{
    Serial.begin(9600);
    uint16_t ID = tft.readID();
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    tft.begin(ID);
    uint8_t pixfmt = 0x66;
    tft.pushCommand(0x3A, &pixfmt, 1);   //use default 18-bit mode
    tft.fillScreen(0x0000);
    tft.setTextColor(0xFFFF, 0x0000);
    tft.setTextSize(3);
    tft.setCursor(0, 0);
    tft.println("RM64180");
    tft.print("ID = 0x");
    tft.println(ID, HEX);
    delay(1000);
}

void loop()
{
    static uint8_t n;
   //tft.fillScreen(0x0000);
    if (++n >= 8) n = 0;
    tft.setTextColor(colors[n], 0x0000);
    tft.println(colornames[n]);
    delay (5000);
 /*  if (++n >= 8) n = 0;
    tft.setCursor(0, 0);
    tft.fillScreen(colors[n]);
    tft.println(colornames[n]);
    delay(1000); */
}



I have attached pictures of the results with your original and my updated code for your reference.

Adrian

PS.
not use if it is a necessary by now, but I have searched and I can not find any reference to the Raydium RM68140. I see on an earlier post that you list RM64180 but I was not able to find any reference to that one either. I was able to find a datasheet for the RM68041 (Single Chip Driver with 262K color for 320RGBx480 a-Si TFT LCD). Not sure if it is the one we are looking for but it resembles the screen resolution and type.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 27, 2016, 07:10 pm
I will post a branch for 6-6-6 format for you.    Please try it and let me know.

I am not at a PC.   It sounds as if I have a typo with one or another part number.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 28, 2016, 01:05 am
David, Thanks for the updated library. I tried the new library (666) and it does work. The Serial window (an the TFT) both show the ID = 0x6814.

I ran the graphics test and it runs well with the exception of the colors. Those are all in a purplish hue. Everything else runs great.

Just to isolate for the sketch I re-ran the previous sketch I showed you with the list of color names in their respective color and you can see the purplish hue on all of them. Attached is an image of that. I was able to correct the screen orientation in the code :) .

(code shown below)

Code: [Select]

#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

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


const char *colornames[] = {
   "BLACK", "BLUE", "RED", "GREEN", "CYAN", "MAGENTA", "YELLOW",  "WHITE", "GRAY"

};
uint16_t colors[] = {
    BLACK, BLUE, RED, GREEN, CYAN, MAGENTA, YELLOW, WHITE, GRAY
   };

void setup()
{
    Serial.begin(9600);
    uint16_t ID = tft.readID();
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    tft.begin(ID);
    uint8_t pixfmt = 0x66;
    tft.pushCommand(0x3A, &pixfmt, 1);   //use default 18-bit mode
    tft.fillScreen(0x0000);
    tft.setTextColor(BLACK, WHITE);
    tft.setTextSize(3);
    tft.setRotation(1);
    tft.setCursor(0, 0);
    tft.println("RM64180");
    tft.print("ID = 0x");
    tft.println(ID, HEX);
    delay(1000);
}

void loop()
{
    static uint8_t n;
    if (++n >= 8) n = 0;
    tft.setTextColor(colors[n], 0x0000);
    tft.println(colornames[n]);
    delay (5000);
 
}



Also, I noticed that if I try to run the GLUE_DEMO_480x320 demo I get an error during compile. Seems like a datatype issue. Error  is listed below and the full verbose compile output is attached in a text file.


GLUE_Demo_480x320:18: error: declaration of 'FreeSmallFont' as array of references

 extern uint8_t SmallFont[];

                          ^

Using library Adafruit_GFX at version 1.1.5 in folder: C:\Program Files\Arduino\libraries\Adafruit_GFX
Using library MCUFRIEND_kbv-Afarina2_test_6-6-6 at version 2.9.1 in folder: D:\My Documents\Arduino\libraries\MCUFRIEND_kbv-Afarina2_test_6-6-6
exit status 1
declaration of 'FreeSmallFont' as array of references


Adrian
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 28, 2016, 01:35 am
Are the directions correct.  e.g. horizontal or vertical mirror?

You have INVERTED colours.  Just add the REV_SCREEN attribute:
Code: [Select]

#ifdef SUPPORT_68140
    case 0x6814:
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | READ_24BITS | REV_SCREEN;


Please look carefully at the Colour Band in Portrait, Landscape,  etc.
And is the Penguin correct?   His scarf is on your left.  (his right)

On your GLUE_Demo.   Comment out the SmallFont declaration.   The UTFTGLUE header declares it as a GFXFont reference now.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 28, 2016, 01:57 am
Sorry,   I did not see your JPEG.

Please post a new JPEG when you have the colours un-INVERTed.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 28, 2016, 02:03 am
Got it. Now the GLUE demo works!

I added the line of code you suggested on the graphicstest but the colors are still mismatched. I can not see the penguin either before or after making the correction. I uploaded a video and image to my github account. too big to attach in the forum...

Adrian

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jun 28, 2016, 07:13 am
What is your GitHub account?   

I tried searching for farinas, afarina2, ...
With no success.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jun 29, 2016, 06:44 pm
David,

I updated to the new library in Github. The Landscape and Landscape_Rev are showing up correctly but the Portrait and Portrait_Rev are flipped. Colors are now on a reddish hue. I have attached some pics of the different screenshots showing the colors and orientation.

I have the shield mated to the board appropriately. In these pics I show the connector for the 9V battery for better reference.

Thanks a bunch!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Einoo_Mustafa on Jul 02, 2016, 06:04 am
hey david,
first of all excuse me for my bad English ,
i am working on a college project & i need a code that works with Mcufriend_kbv library and my tft screen (9335) to display image saved on the sd card .... so can i get any help
i tried all the examples and they worked fine .... but non of them deal with bmp image    
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ladicek on Jul 02, 2016, 03:09 pm
HI, I have an lcd tft 3.5" display from ebay LINK (http://www.ebay.com/itm/162074823642?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT). And I couldn't get it to work with MCUFRIEND_kbv library. I found out it has an ILI9481 chip and 8-bit parallel interface. So I contacted the seller and he posted me library and examples.

Library was a little bit modified Adafruit LCDTFT library, and it half-worked!.

But than there was the second problem. I ran graphicstest and the only thing that worked was filling screen, and all colours worked except BLACK. When I tried to fill screen black it stayed white.

Here is the picture of my shield.
(https://s31.postimg.org/r3o1mo2g7/20160702_144130.jpg) (https://postimg.org/image/r3o1mo2g7/)
(https://s31.postimg.org/g5cs4hduv/20160702_144146.jpg) (https://postimg.org/image/g5cs4hduv/)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 02, 2016, 04:27 pm
My shield "looks" exactly like the photo in your Ebay link.    The pcb copper traces are identical,  the legends are the same.  the header pins are yellow,  ...

Your photo is less detailed but I am sure that you have compared your shield with the Ebay photo.

Since the vendor has given you a library,  your screen is obviously in working order.
Attach the library that the vendor sent you.   Or better still,  a download link.

Have you run the LCD_ID_readreg sketch?
Have you tried tft.begin(0x9481) ?

There are several "makes" of "ILI9481" style controller.    I would put money on your shield using the Ilitek one.  However HX8357-B, R61581, ... will give a different ID.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 02, 2016, 07:14 pm
David,

I tried the little code you listed below just as you indicated and EUREKA!!!!! It works :D I did not have to force the tft.begin to 0x9329.

The Serial monitor only shows a line of text ID = 0x9486. Nothing else. Colors and names are mismatched and the text is mirrored (Inverted) but all that is fixable.

I updated the code to list the color names and colors in a list and noticed that the black is missing in the list.
 AFARINA2 EDITED CODE
Code: [Select]

#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

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


const char *colornames[] = {
   "BLACK", "BLUE", "RED", "GREEN", "CYAN", "MAGENTA", "YELLOW",  "GRAY"

};
uint16_t colors[] = {
    BLACK, BLUE, RED, GREEN, CYAN, MAGENTA, YELLOW, GRAY
   };

void setup()
{
    Serial.begin(9600);
    uint16_t ID = tft.readID();
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    tft.begin(ID);
    uint8_t pixfmt = 0x66;
    tft.pushCommand(0x3A, &pixfmt, 1);   //use default 18-bit mode
    tft.fillScreen(0x0000);
    tft.setTextColor(0xFFFF, 0x0000);
    tft.setTextSize(3);
    tft.setCursor(0, 0);
    tft.println("RM64180");
    tft.print("ID = 0x");
    tft.println(ID, HEX);
    delay(1000);
}

void loop()
{
    static uint8_t n;
   //tft.fillScreen(0x0000);
    if (++n >= 8) n = 0;
    tft.setTextColor(colors[n], 0x0000);
    tft.println(colornames[n]);
    delay (5000);
 /*  if (++n >= 8) n = 0;
    tft.setCursor(0, 0);
    tft.fillScreen(colors[n]);
    tft.println(colornames[n]);
    delay(1000); */
}

 


I have attached pictures of the results with your original and my updated code for your reference.

Adrian

PS.
not use if it is a necessary by now, but I have searched and I can not find any reference to the Raydium RM68140. I see on an earlier post that you list RM64180 but I was not able to find any reference to that one either. I was able to find a datasheet for the RM68041 (Single Chip Driver with 262K color for 320RGBx480 a-Si TFT LCD). Not sure if it is the one we are looking for but it resembles the screen resolution and type.


Oops.   I owe you an apology.   I re-read your message #499 from 27 June.   Rotated and flipped your JPEGs.

The Original has BGR instead of RGB.   Your afarina2_sketch has the colours showing correctly.   But against a WHITE background.    Your sketch is simply doing:

Code: [Select]

void setup()
{
    ...
    tft.fillScreen(BLACK);       //screen should be BLACK
    ...
}

void loop()
{
    static uint8_t n;
    if (++n >= 8) n = 0;
    tft.setTextColor(colors[n], BLACK);  //coloured letters, black background
    tft.println(colornames[n]);   // names should be coloured
}


Looking closely at your JPEG,  the 16-bit 565 colours are correct.   Each 3x3 pixel in the font is drawn.
So I don't need to write 24-bits.   But I do need to know why BLACK (0x0000) is showing as white screen.

My original sketch was drawing WHITE text on a coloured screen.
I know how to swap BGR to RGB.   How did you do it?   Did you alter the library code?

The sun has come out and I am going out to mow the churchyard now.   (if the grass is dry)

I will post you a new CPP later (probably this evening)

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ladicek on Jul 03, 2016, 09:45 am
So, this is the download link he gave me LINK (http://www.electrodragon.com/w/images/3/3d/3.5_LCD_library_and_SD_example.zip)

and yes I did run LCD_ID_readreg, andthis is the result (https://s32.postimg.org/8pkhwdoxt/reg.png) (https://postimg.org/image/8pkhwdoxt/)

Sorry that is is a picture, but I don't know how to copy it from serial monitor.

And I tried forcing the indentifier(ID) but no result. I tried graphicstest_kvb but it hangs on ID=0x0,
eventhough I right after that ( before tft.begin=() ) force the indentifier to be 0x9481 or 0x9341

Ladicek

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ladicek on Jul 03, 2016, 09:57 am
And since I don't have experience with lcd is it normal that when I run the sellers library and example, only the fill screen works and the black doesn't and when the code does fillScreen it fills the screen slowly from left to right.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 03, 2016, 10:26 am
You can simply place your mouse over the Serial Terminal.   Press ctrl-A to select the whole output.  Press ctrl-C to copy.   Press ctr-V to paste this to your message (in a code-tag block) e.g.

this is my private version which has correct names and sizes specifically for the ILI9481
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)

ILI9481 / HX8357 / R61581
reg(0x000A) 00 08    Get Powsr Mode
reg(0x000B) 00 00   Get Address Mode
reg(0x000C) 00 66   Get Pixel Format
reg(0x000D) 00 00   Get Display Mode
reg(0x000E) 00 00   Get Signal Mode
reg(0x000F) 00 00   Get Diagnostic Result
reg(0x00A1) 00 00 00 00 00 FF   RD_DDB Start
reg(0x00B0) 00 00   Command Access Protect
reg(0x00B3) 00 02 00 00 00  Frame Memory
reg(0x00B4) 00 00   Frame Mode
reg(0x00BF) 00 02 04 94 81 FF   Device Code Read
reg(0x00C0) 00 10 3B 00 02 11   Panel Control
reg(0x00C1) 00 10 10 88 Display Timing Normal
reg(0x00C2) 00 10 10 88 Display Timing Partial
reg(0x00C3) 00 10 10 88 Display Timing Idle
reg(0x00C5) 00 03   Frame Rate
reg(0x00C6) 00 02   Interface Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00  GAMMA
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 43 18 Power Control
reg(0x00D1) 00 00 00 00 VCOM Control
reg(0x00D2) 00 01 22    Power Normal
reg(0x00D3) 00 01 22    Power Partial
reg(0x00D4) 00 01 22    Power Idle
reg(0x00E4) 00 20 00 00 ? SETCABC(HX) (f.k. ILI)
reg(0x00E9) 00 00 00 00 ? Set Panel Related(HX)
reg(0x00EE) 00 00 00 00 00  ? Set EQ Function(HX)
reg(0x00F0) 00 01 34 00 f.k (ILI)
reg(0x00F1) 00 0B   f.k
reg(0x00F2) 00 00 33 00 f.k
reg(0x00F3) 00 00 1A 00 f.k (ILI)
reg(0x00F4) 00 4D 2C 00 f.k
reg(0x00F5) 00 35   f.k
reg(0x00F6) 00 80   f.k
reg(0x00F7) 00 C0 01 00 f.k
reg(0x00F8) 00 00 00    f.k
reg(0x00F9) 00 33   f.k

Note that this is from a genuine Ilitek ILI9481.  In fact it is exactly the same Blue 3.5" shield that you have.   Don't worry about the different format.   I have matched all the ILI9481-specific registers from your output.   Your controller is identical to mine.

So I would expect all the MCUFRIEND_kbv examples would obtain the correct ID (0x9481).
And all would work straight out of the box.    The ILI9481 has been supported since 11 January (v2.5).
I presume that you are using v2.90 from message#0 of this thread.

I will look at the link that you gave me.   It seems to be a hacked Adafruit_TFTLCD.   This should work just fine (if done correctly).    I will try it with my Shield.

David.

Edit.  Just tried your "Adafruit_TFTLCD" with my standard demo program.
drawPixel() does not work.   Hence no x1 text, circles, angled lines.
fillRect(), drawLine(), ... all work.
Portrai needs horiz-flip.
Landscape is correct
Portrait_Rev needs vert-flip
Landscape_Rev needs horiz-flip AND vert-flip.
readPixel() is wrong.
invertdisplay() does not work.
The Adafruit Tests take 41.17 seconds on a Uno.   (MCUFRIEND_kbv takes 14.72 seconds)
Obviously I can't test vertical scrolling because Adafruit_TFTLCD does not support it.

So your Library "works" but not 100%.

Edit some more.  Using setRotation(3) you can get drawPixel() to work.   It gives you Landscape instead of Landscape_Rev but hey-ho,  you can live with that.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ladicek on Jul 03, 2016, 02:24 pm
Yes, I am using 2.90 version (I double checked) and any example I run I get
Code: [Select]
readID = 0x0
Unknown ID


and nothing happens, screen stays white no flickering or anything.

Ladicek

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 03, 2016, 03:48 pm
Well,  you probably understand that I have a working Beta copy of the library on my PC.
I removed this.   And installed the v2.9 release library.

It worked just fine with my Shield.

Are you using a Uno?
Have you been altering any of the Library files?   e.g. mcufriend_shield.h
Just inspect the file dates in Explorer.   they should all be dated before 11 January.
If you have been editing them,  the dates will be recent.

Do you have verbose Compilation?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ladicek on Jul 04, 2016, 09:52 pm
HI,
I'm using arduino MEGA 2560 and I freshly installed libraries so none of them are corupted.

And what is verbose Compilation and where to see the status of it?
(Sorry I'm still a beginner).

Ladicek
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ladicek on Jul 06, 2016, 02:19 pm
I have enabled verbose Compilation. Is that OK?

Ladicek
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 06, 2016, 02:49 pm
I suspect that you have edited the mcufriend_shield.h file and enabled "specials".

Stop the IDE.
Delete the libraries/mcufriend_kbv durectory.
Start the IDE.
Download a fresh copy of the ZIP from the link in message #0 i.e. with Install from ZIP.

The library and its examples should work straight out of the box.   Whether on a Uno, Mega, Leonardo, Zero, Due.   It will work best on a Uno.

Obviously there are some shields that I do not possess.   However,   I do have your model.    And it works.

David.

p.s. when you have verbose compilation,   any warnings are printed in orange.   To ensure that a  library is freshly built,   change the board,  compile,  change the board back to your actual board.   The next build / upload will compile the library again.   Note any messages.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Florante on Jul 07, 2016, 01:51 pm
Hi

I recently purchased a 3.5" TFT LCD from ebay

http://www.ebay.com/itm/121996829791?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

I tried to use MCUFRIEND_kbv lib but the screen is showing me dots of RGB. I can not get this to work.

I am attaching the screen output

The  serial monitor says that this is ID = 0x9486



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(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 54 54 80 66 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 08 08 Get Powsr Mode
reg(0x000C) 66 66 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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) 02 02 02 3B 00 Display Control
reg(0x00B7) 06 06 Entry Mode Set
reg(0x00BF) FF FF 68 14 00 FF ILI9481, HX8357-B
reg(0x00C0) 0E 0E 0E 00 00 00 00 00 00 Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA
reg(0x00CC) 00 00 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 00 00 NVM Read
reg(0x00D3) 00 00 94 86 ILI9341, ILI9488
reg(0x00DA) 54 54 RDID1
reg(0x00DB) 80 80 RDID2
reg(0x00DC) 66 66 RDID3
reg(0x00E0) 00 00 54 07 44 05 08 00 54 07 44 05 08 44 44 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 00 00 00 Interface Control



Anybody can help me please?

Thanks





Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 07, 2016, 03:04 pm
This is NOT a genuine Ilitek ILI9486 controller.    It might be a Raydium RM68140 controller but I can not find a datasheet.

I have sent you a PM with instructions on what to try.
Note that I do not have this shield.    Several other readers have them but it needs cooperation to test things remotely.   I can send you code.   You have to report back with the results.

Of course this is a lot more complicated that normal Arduino.   Please just say if you can help or not.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: siriusbg on Jul 07, 2016, 08:19 pm
Hi, David! Sorry I was away for a while. I tested the first sketch for the Raydum and it works. Found these datasheets if they can help you:
https://www.crystalfontz.com/controllers/Raydium_RM68120_V0.0_May_2011.pdf
https://www.crystalfontz.com/products/document/3212/CFAF480800T07043TTS_Datasheet_2013-12-12.pdf

If you want I can help with testing.

Best regards!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 07, 2016, 09:18 pm
Thanks for your reply.   I have the RM68120 datasheet.   And it was this that makes me think that there is a RM68140 device and it might be what you and the others have.

I will send you a PM with instructions.

I presume that you ran the sketch in Afarina2's message.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Jul 08, 2016, 03:04 am
Sorry for interrupting but has anyone else noticed a new format of screen available?

http://www.aliexpress.com/item/Free-shipping-LCD-Display-Module-TFT-3-95-inch-TFT-LCD-screen-for-Arduino-MEGA-2560/32689910844.html

I've ordered one but only heaven knows what will arrive as the item shows the Mega and the Uno formats?

I'm looking forward to trying it with the libraries available. Since it is not Uno form(?) I expect MCUFRIEND_kbv won't work with it!?

Just ordered it from AliX so it COULD be two months away!? I have ordered 7 things (6 screens and a Due) from AliX - 3 haven't/didn't arrive, one was faulty and 2 worked.  
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 08, 2016, 09:19 am
Your AliExpress link looks like an 8-bit interface on a Mega2560 shield.

Very few libraries support this.    The TFT should work fine.   I suspect that the microSD will be unreliable.

Until you receive the shield,  you have no idea whether the pcb matches the photos.
It probably has an ILI9488 but adverts often lie.

All Uno shields will work out of the box with the MCUFRIEND_kbv library.
Your 8-bit Mega shield can NOT read its ID register.   The library will only work as a "special".    You would have to disable the "special" to work with the proper Uno shields.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: makoshatu on Jul 08, 2016, 05:29 pm
Hi Florante!

Your TFT shield has to be modified in order to get it work. Unfortunatelly, the FPC connector (it is that flexible, thin "PCB" which connects the ILI9486 controller to the PCB shield) incorrectly configures the controller's IM[2:0] pins. It sets "8080 9-bit bus interface" instead of "8080 8-bit bus interface" and it is hardwired on the flexible PCB (see attached "MCU_system_interface.JPG").
I (and Afarina2) have the same display and David suggested to use the following command:

uint8_t pixfmt = 0x66;
tft.pushCommand(0x3A, &pixfmt, 1);

With the above command, both the "RGB pixel format" and the "CPU interface format" will be set to 18 bits/pixel and David's library will work with this shield, too. And the "Display inversion on" command (21h) is also needed in order to get nearly acceptable color accuracy . David, thank you for your help, again!

Since the bus interface is still configured to 9-bit, but we use 8-bit to set the colors of the pixels, two bits (the 5th of the red and the 2nd of the green) are missing. These two bits from the 18 bits will be always 0 (see "9bit_data_bus_for_18bitperpixel.JPG"). As the 5th bit of the red is the MSB, full white color can not be displayed, the screen will be blueish.

I was not able to modify the IM[2:0] pins on my FPC PCB, I had to green wire the 9th bit on the TFT shield (see "modified_shield.JPG"). I did not use the onboard 74HC245 bus-transceiver, since I use 3.3V atmega. Before I "green-wired" the 22nd pin of the FPC connector to the A5 arduino pin (the free pin next to the "LCD_RST" pin of the TFT shield) I had to elevate the flexible FPC PCB and I had to isolate that 22nd pin from the pad of the TFT shield since that pad is hardwired to GND on the TFT shield. I isolated them with a narrow stripe of heat resistant kapton tape. As a result, all of the 262k colors can be displayed, including full white ("ILI9486_262k_color.JPG").

As a downside, there is no arduino library outside for 9-bit bus interface displays. If you want to make the above modifications, you can use this code to verify the result:

Code: [Select]

void PushTFTCommand(unsigned short command, unsigned short data[15], unsigned short count)
{
  PORTC = B00010011;       // command is comming - b4-reset, b3-CS, b2-RS, b1-WR, b0-RD
  PORTD = ( PORTD & B00000011 ) | ( command & B11111100 );         // Masked port (2...7)
  PORTB = ( PORTB & B11111100 ) | ( command & B00000011 );         // Masked port (8,9)
  PORTC = B00010001;
  PORTC = B00010011;       // write command - WR to HIGH
  PORTC = B00010111;       // data is comming - RS to HIGH
 
  if(count!=0)
    {
      for(unsigned short n=0; n!=count; n++)
        {
          PORTD = ( PORTD & B00000011 ) | ( data[n] & B11111100 );         // data is on port, masked (2...7)
          PORTB = ( PORTB & B11111100 ) | ( data[n] & B00000011 );         // data is on port, masked (8,9)
          PORTC = B00010101;
          PORTC = B00010111;       // toggle WR, HIGH -> LOW
        }
    }

  PORTC = B00011011;       // release CS
}

void putpixel(unsigned short red, unsigned short green, unsigned short blue)
{
  PORTC = B00010011;       // command is comming - b4-reset, b3-CS, b2-RS, b1-WR, b0-RD
  PORTD = ( PORTD & B00000011 ) | ( 0x3C & B11111100 );         // Masked port (2...7)
  PORTB = ( PORTB & B11111100 ) | ( 0x3C & B00000011 );         // Masked port (8,9)
  PORTC = ( PORTC & B11111101 ) | ( B00000000 & B00000010 );    // toggle WR
  PORTC = ( PORTC & B11111101 ) | ( B00000010 & B00000010 );
  PORTC = B00010111;       // data is comming - RS to HIGH

  PORTC = ( PORTC & B11011111 ) | ( red>>2 & B00100000 );
  PORTD = ( PORTD & B00000111 ) | ( red<<1 & B11111000 );
  PORTD = ( PORTD & B11111011 ) | ( green>>5 & B00000100 );
  PORTB = ( PORTB & B11111100 ) | ( green>>5 & B00000011 );
 
  PORTC = ( PORTC & B11111101 ) | ( B00000000 & B00000010 );    // toggle WR
  PORTC = ( PORTC & B11111101 ) | ( B00000010 & B00000010 );

  PORTC = ( PORTC & B11011111 ) | ( green<<1 & B00100000 );
  PORTD = ( PORTD & B00111111 ) | ( green<<4 & B11000000 );
  PORTD = ( PORTD & B11000011 ) | ( blue>>2 & B00111100 );
  PORTB = ( PORTB & B11111100 ) | ( blue>>2 & B00000011 );
 
  PORTC = ( PORTC & B11111101 ) | ( B00000000 & B00000010 );    // toggle WR
  PORTC = ( PORTC & B11111101 ) | ( B00000010 & B00000010 );
 
  PORTC = B00011011;       // release CS 
}

void TFTInit(void)
{
  unsigned short param[15];
  DDRB = DDRB | B00000011; // digital pins 8 and 9 are outputs
  DDRD = DDRD | B11111100; // digital pins 2 to 7 are outputs, 0&1 (RX/TX) do not change
  DDRC = DDRC | B00111111; // analog pins 0 to 5 are outputs
  PORTC = B00000000;       // reset TFT
  delay(50);
  PORTC = B00011011;
  delay(150);

  PushTFTCommand(0x01, param, 0);     // soft reset
  delay(300);
  PushTFTCommand(0x28, param, 0);     // display off
  param[0]=0x0D;                      // Power Control 1
  param[1]=0x0D;
  PushTFTCommand(0xC0, param, 2);
  param[0]=0x43;                      // Power Control 2
  param[1]=0x00;
  PushTFTCommand(0xC1, param, 2);
  param[0]=0x00;                      // Power Control 3
  PushTFTCommand(0xC2, param, 1);
  param[0]=0x00;                      // VCOM Control 1
  param[1]=0x48;
  param[2]=0x00;
  param[3]=0x48;
  PushTFTCommand(0xC5, param, 4);
  param[0]=0xD0;                      // Frame rate control B0
  param[1]=0x11;                      // 11
  PushTFTCommand(0xB1, param, 2);



  param[0]=0x0F;                      // Positive Gamma Control
  param[1]=0x1B;
  param[2]=0x18;
  param[3]=0x0B;
  param[4]=0x0E;
  param[5]=0x09;
  param[6]=0x47;
  param[7]=0x94;
  param[8]=0x35;
  param[9]=0x0A;
  param[10]=0x13;
  param[11]=0x05;
  param[12]=0x08;
  param[13]=0x03;
  param[14]=0x00;
  PushTFTCommand(0xE0, param, 15);

  param[0]=0x0F;                      // Negative Gamma Control
  param[1]=0x3A;
  param[2]=0x37;
  param[3]=0x0B;
  param[4]=0x0C;
  param[5]=0x05;
  param[6]=0x4A;
  param[7]=0x24;
  param[8]=0x39;
  param[9]=0x07;
  param[10]=0x10;
  param[11]=0x04;
  param[12]=0x27;
  param[13]=0x25;
  param[14]=0x00;
  PushTFTCommand(0xE1, param, 15);
 
  param[0]=0x00;                      // Inversion control
  PushTFTCommand(0xB4, param, 1);
  param[0]=0x02;                      // Display Function control 0x02, 0x02, 0x3B
  param[1]=0x02;
  param[2]=0x3B;
  PushTFTCommand(0xB6, param, 3);
  param[0]=0x0A;                      // Memory Access
  PushTFTCommand(0x36, param, 1);
  param[0]=0x00;                      // Column Address Set 320
  param[1]=0x00;
  param[2]=0x01;
  param[3]=0x3f;
  PushTFTCommand(0x2A, param, 4);
  param[0]=0x00;                      // Page Address Set 480
  param[1]=0x00;
  param[2]=0x01;
  param[3]=0xdf;
  PushTFTCommand(0x2B, param, 4);
  PushTFTCommand(0x38, param, 0);     // Idle Mode off

  PushTFTCommand(0x11, param, 0);     // Sleep out
  delay(150);
  PushTFTCommand(0x29, param, 0);     // Display on

  param[0]=0x66;                      // set 18bit mode
  PushTFTCommand(0x3A, param, 1);
  PushTFTCommand(0x20, param, 0);     // inversion off
}

void setup()
{
  TFTInit();
       
  for(unsigned long cyc=0; cyc!=153600; cyc++)
     putpixel(0xff, 0x7f, 0x3f);  // red, green, blue
}

void loop()
{
}




After the changes, David's library still handle this display, but the 9-bit MCU interface causes that some of the colors are off. The designer of this shield really messed it up.

I hope it helps.
Attila.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 08, 2016, 11:31 pm
@Attila,

I am 100% certain that this is not an Ilitek ILI9486.    The power-up register values are different.
Afarina2, siriusbg and Florante have got the same shield as you.   i.e. with
Code: [Select]
reg(0x00BF) FF FF 68 14 00 FF   ILI9481, HX8357-B

Since you have dismantled your panel,  can you get any clues about the controller from the printed legends?

It also appears that this controller only accepts 0x66 for PixFmt.   However,   it seems to actually use 16-bit 565 colors just like any other controller (with PixFmt = 0x55)

If you use the "Afarina2_test_6-6-6" Branch on GitHub,  you should get the correct colours (as 565).
I have to sort out the correct Portrait aspect,  penguin direction,  ...
i.e. another indication that this is not a genuine Ilitek ILI9486 controller.

A real ILI9486 has got MY, MX, MV, ML, RGB, MH in reg(0x36)  with no horiz-flip or vert-flip.
I suspect that this ?RM68140 controller does have some flips.
If not,  I can invert SS, GS via the 0xB6 register.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: robji on Jul 12, 2016, 01:56 am
Hi,

I recently bought an Uno and a mcufriend shield off of craigslist and I can't quite get it to work.

Here's my output from readreg:

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(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 83 88 68 Manufacturer ID
reg(0x0009) 00 80 63 00 80 Status Register
reg(0x000A) 98 98 Get Powsr Mode
reg(0x000C) 06 06 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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) BF BF 0F 11 FF 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) 41 00 Entry Mode Set
reg(0x00BF) 00 02 04 15 11 FF ILI9481, HX8357-B
reg(0x00C0) 00 3B 00 00 07 01 00 00 00 Panel Control
reg(0x00C8) 12 01 11 08 01 00 04 0C 0E 0C 05 03 00 GAMMA
reg(0x00CC) 2A 2A Panel Control
reg(0x00D0) 00 05 08 Power Control
reg(0x00D2) 04 62 00 00 00 NVM Read
reg(0x00D3) 00 00 00 00 ILI9341, ILI9488
reg(0x00DA) 00 83 RDID1
reg(0x00DB) 83 8F RDID2
reg(0x00DC) 8F 22 RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 00 00 00 Interface Control



When running an unmodified graphictest_kbv I get ID = 0x0 and it displays glitchy graphics. Manually overriding the id to 0x9481 everything seems to work right except landscape is mirrored portrait and likewise for rev, and there's a row or 2 of random pixels at the looping edge between the frames when scrolling. Vertical scroll works, software scroll goes up but then snaps back to the original spot. I've tried forcing all of the ID's shown in the output but 9481 is by far the closest. Thanks in advance.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 12, 2016, 03:39 pm
I have sent you a PM.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jul 13, 2016, 05:43 pm
David,

You did it!!!  :D The last update to your mcufriend_kbv library was a success! I can get the colors and animations perfectly in my 3.5" TFT Touchscreen for Uno.

Attached are the pics of the screen

Thank you so much for your help on getting the screen to work properly!

Adrian
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 13, 2016, 07:38 pm
@Adrian, Attila, Mathew277,

The "0x6814" controller has got several errors:

1.  Portrait, Landscape_Rev have got horizontal mirroring.   i.e. SS direction
2.  Portrait_Rev has no Band scroll
3.  Portrait_Rev, Landscape_Rev scroll direction is wrong.

On most controllers there are several ways to deal with SS mirroring.
4.  bit #1 in MADCTL (0x36)
5.  bit #7 MY or bit #6 MX i. MADCTL (0x36)
6.  bit #5 in the second byte of Display Function Control (0xB6)

Your controller's MADCTL does not work like a regular ILI4686.   So I suggest that you run your "colours" sketch.   And toggle bits in (0x36) and (0xB6) accordingly.   And report back which ones work.

Code: [Select]


#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

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


const char *colornames[] = {
   "BLACK", "BLUE", "RED", "GREEN", "CYAN", "MAGENTA", "YELLOW",  "WHITE", "GRAY"

};
uint16_t colors[] = {
    BLACK, BLUE, RED, GREEN, CYAN, MAGENTA, YELLOW, WHITE, GRAY
   };

void setup()
{
    Serial.begin(9600);
    uint16_t ID = tft.readID();
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    tft.begin(ID);
    tft.fillScreen(0x0000);
    tft.setTextColor(BLACK, WHITE);
    tft.setTextSize(3);
    tft.setRotation(0);    //Portrait
    tft.setCursor(0, 0);
    tft.println("RM64180");
    tft.print("ID = 0x");
    tft.println(ID, HEX);
    delay(1000);
}

void loop()
{
    uint8_t n, d[3], madctl;
    tft.fillScreen(0x0000);
    tft.setCursor(0, 0);
    for (n = 0; n < 8; n++) {
        tft.setTextColor(colors[n], 0x0000);
        tft.println(colornames[n]);
    }
    tft.println("MX = 0, RGB = 1, SS = 0");
    madctl = 0x08;    //RGB
    tft.pushCommand(0x36, &madctl, 1);   //madctl
    delay (5000);
    tft.println("MX = 1, RGB = 1, SS = 0");
    madctl = 0x48;    // MX | RGB  ##### EDIT ####
    tft.pushCommand(0x36, &madctl, 1);   //madctl
    delay (5000);
    tft.println("MX = 0, RGB = 1, SS = 1");
    madctl = 0x0A;    //RGB | SS
    tft.pushCommand(0x36, &madctl, 1);   //madctl
    delay (5000);
    tft.println("Panel SS on");
    d[0] = 0x02;
    d[1] = 0x22;       //Panel_SS = 1
    d[2] = 0x3B;
    tft.pushCommand(0xB6, d, 3);   // panel control
    delay (5000);
    tft.println("Panel SS off");
    d[0] = 0x02;
    d[1] = 0x02;       //Panel_SS = 0
    d[2] = 0x3B;
    tft.pushCommand(0xB6, d, 3);   // panel control
    delay (5000);
}


Some settings will make difference.  Others will have no effect.

David.

Edit.   Oops.  I have corrected the MX bit in the above sketch.   The original version was changing the ML bit.   

I just typed this sketch straight into the Forum untested.   My apologies.
I have just posted a better diagnostic sketch in message #538
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jul 14, 2016, 03:09 am
Got it. I am going to test it right now and report results...

thanks david
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: afarina2 on Jul 14, 2016, 03:41 am
David,

I tried the colour sketch on my board and here are my findings:



Seems that the command for the SS ON is the one that fixes the mirroring effect. Not sure about the scrolling though. Hope that the results are easy to follow...
Adrian
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: makoshatu on Jul 15, 2016, 07:05 am
@Attila,

I am 100% certain that this is not an Ilitek ILI9486.    The power-up register values are different.
Afarina2, siriusbg and Florante have got the same shield as you.   i.e. with
Code: [Select]
reg(0x00BF) FF FF 68 14 00 FF   ILI9481, HX8357-B

Since you have dismantled your panel,  can you get any clues about the controller from the printed legends?

It also appears that this controller only accepts 0x66 for PixFmt.   However,   it seems to actually use 16-bit 565 colors just like any other controller (with PixFmt = 0x55)

If you use the "Afarina2_test_6-6-6" Branch on GitHub,  you should get the correct colours (as 565).
I have to sort out the correct Portrait aspect,  penguin direction,  ...
i.e. another indication that this is not a genuine Ilitek ILI9486 controller.

A real ILI9486 has got MY, MX, MV, ML, RGB, MH in reg(0x36)  with no horiz-flip or vert-flip.
I suspect that this ?RM68140 controller does have some flips.
If not,  I can invert SS, GS via the 0xB6 register.

David.
Hi David,

I agree, it is possible that it is a counterfeit ILI9486. Unfortunatelly, the legends on the TFT panel do not tell anything about the part number. I saw these texts on the bottom of the TFT panel:

BL035H6M-FNGM
835M 130619/C1

ST035H6M-FNGM
JD131108A040002

The manufacturer of the FPC panel is JUSTDO, it's part number is FPC035H0M-FNGM-A.

By the way, the controller uses 18-bit 666 color format, I can confirm it. I run your latest library, and I set white background. It still blueish. Then I made a quick test. I modified your graphicstest_kbv sketch: my modified shield uses the "A5" pin of the UNO board, as 9th bit. I set this pin to high and after that the WHITE became real white, it is not blueish.

Afarina, can you check the color grades again?
- Blue grades are perfect, there are smooth transitions between the intensity-grades.
- There are intensity-jumps on the green grades, which is caused by the missing 2nd bit of the green intensity.
- On the red grades, everything looks fine, except that the whole grade is dark. Maximum intensity of the red color can not be reached because the 5th bit of the red intensity is missing.
- The gray grade looks greenish and there are grading-jumps on it, the intensity transition is not smooth.

I tried to take some pictures about it, but it do not return the true colors of the display. Maybe the grading-jumps can be seen.

It is not a complain. I just want to share what I experienced. I am still confident that this display uses 9bit MCU bus and the last bit of the bus is incorrectly grounded on the shield.


Thanks.
Attila.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: megomes on Jul 17, 2016, 06:55 am
Firstly, thank you for this amazing library!
Thank you very much!  :D

Is there a way to change the screen brightness? I have the same screen as afarina2.

Which, by the way, thank you again for adapting your library for this screen to work!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: redion1992 on Jul 18, 2016, 05:51 pm
Hi,

I recently bought an Uno and a mcufriend shield off of craigslist and I can't quite get it to work.

Here's my output from readreg:

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(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 83 88 68 Manufacturer ID
reg(0x0009) 00 80 63 00 80 Status Register
reg(0x000A) 98 98 Get Powsr Mode
reg(0x000C) 06 06 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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) BF BF 0F 11 FF 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) 41 00 Entry Mode Set
reg(0x00BF) 00 02 04 15 11 FF ILI9481, HX8357-B
reg(0x00C0) 00 3B 00 00 07 01 00 00 00 Panel Control
reg(0x00C8) 12 01 11 08 01 00 04 0C 0E 0C 05 03 00 GAMMA
reg(0x00CC) 2A 2A Panel Control
reg(0x00D0) 00 05 08 Power Control
reg(0x00D2) 04 62 00 00 00 NVM Read
reg(0x00D3) 00 00 00 00 ILI9341, ILI9488
reg(0x00DA) 00 83 RDID1
reg(0x00DB) 83 8F RDID2
reg(0x00DC) 8F 22 RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 00 00 00 Interface Control



When running an unmodified graphictest_kbv I get ID = 0x0 and it displays glitchy graphics. Manually overriding the id to 0x9481 everything seems to work right except landscape is mirrored portrait and likewise for rev, and there's a row or 2 of random pixels at the looping edge between the frames when scrolling. Vertical scroll works, software scroll goes up but then snaps back to the original spot. I've tried forcing all of the ID's shown in the output but 9481 is by far the closest. Thanks in advance.
I also recently purchased a 3.5" shield which reports, byte-for-byte, the same information. I'd previously purchased a shield from the same vendor, which I got working with ID 0x9486, but this one seems a little different.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 18, 2016, 09:15 pm
I also recently purchased a 3.5" shield which reports, byte-for-byte, the same information. I'd previously purchased a shield from the same vendor, which I got working with ID 0x9486, but this one seems a little different.
You seem to have a 0x1511 controller.   There are a couple of problems to resolve but the v2.9.1-Beta on GitHub should be "usable".

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 18, 2016, 09:16 pm
Firstly, thank you for this amazing library!
Thank you very much!  :D

Is there a way to change the screen brightness? I have the same screen as afarina2.

Which, by the way, thank you again for adapting your library for this screen to work!
No,  you can't change the screen brightness.   It is from the backlight LEDs.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 18, 2016, 09:31 pm
@Attila, Afarina2, siriusbg, Florante, megomes and other 0x6814 owners

@Levy, redion1992, robji and other 0x1511 owners

I have written a sketch that should show how all the MADCTL bits work on a MIPI-style controller.
For all the "MIPI conformance",   ILI9481-style of controllers use the MY, MX, MV, ML, RGB, MH, SS, GS bits in a different way to the standard 9341/9486/9488 style.


TextRotation_diagnose.ino:
Code: [Select]

#include <SPI.h>          // f.k. for Arduino-1.5.2
#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#define MODETYPE 0

// Assign human-readable names to some common 16-bit color 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

#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif

void setup(void);
void loop(void);
uint16_t g_identifier;
uint8_t initval;
extern const uint8_t penguin[];  // icons.c from graphictest_kbv.ino
extern const uint8_t letter_F[];
extern const unsigned char mystery40x32[];

void setup(void)
{
    uint16_t ID;                 //what we actually read
    Serial.begin(9600);
    uint32_t when = millis();
    if (!Serial) delay(5000);    //allow some time for Leonardo
    ID = tft.readID();           //valid for Uno shields
    Serial.print("read ID = 0x");
    Serial.println(ID, HEX);
    g_identifier = ID;
    if (ID == 0xD3D3) g_identifier = 0x6814; // write-only shield
    //    if (ID == 0x9481) g_identifier = 0x1511; // force for test
    tft.begin(g_identifier);
    tft.setRotation(0);
    Serial.print("begin ID = 0x");
    Serial.println(g_identifier, HEX);
    initval = tft.readReg(0x0B);     //what is in your initlcd.h for 0x36
    Serial.print("read MADCTL = 0x");
    if (initval < 0x10) Serial.print("0");
    Serial.println(initval, HEX);
    if (g_identifier == 0x9481 || g_identifier == 0x1511)
        initval |= (1 << 1); //force Flip Horiz
    if (ID == 0xD3D3) initval = (1 << 3); //force RGB for write-only
    Serial.print("using MADCTL = 0x");
    if (initval < 0x10) Serial.print("0");
    Serial.println(initval, HEX);
    Serial.print("showing MODETYPE = ");
    Serial.println(MODETYPE, DEC);
    Serial.println("This program should show the active bits");
    Serial.println("in the MADCTL register");
    Serial.println("You should see a big 4 and a penguin / F");
    Serial.println("");
    Serial.println("The default is in white");
    Serial.println("Each toggled bit shows in colour");
    Serial.println("Please note which bits do something");
    Serial.println("and which do not");
    Serial.println("");
    Serial.println("You can determine which bits");
    Serial.println("change the 4 direction (and text)");
    Serial.println("and which change the penguin / F");
    Serial.println("");
    Serial.println("You can try different MODETYPE values");
    Serial.println("and get the rotatations correct");
    Serial.println("then test scroll directions");
}

char *msgs[] = {
    "0:Flip Vert",
    "1:Flip Horiz",
    "2:Horiz refresh",
    "3:RGB-BGR order",
    "4:Vert refresh",
    "5:Row Col Xchange",
    "6:Column Order",
    "7:Row Order",
};

uint8_t modes[] = {
#if MODETYPE == 0
    0b00000001,     //Regular bit tests
    0b00000010,
    0b00000100,
    0b00001000,
    0b00010000,
    0b00100000,
    0b01000000,
    0b10000000,
#elif MODETYPE == 1
    0b00000000,     //PORT 9486-style
    0b01100000,     //LAND
    0b11010000,     //PORT_REV
    0b10110000,     //LAND_REV
#elif MODETYPE == 2
    0b00000000,     //PORT 9481-style
    0b00100010,     //LAND
    0b00000011,     //PORT_REV
    0b00100001,     //LAND_REV
#elif MODETYPE == 3
    0b00000000,     //PORT SSD1963-style
    0b00100010,     //LAND
    0b00010011,     //PORT_REV
    0b00110001,     //LAND_REV
#elif MODETYPE == 4
    0b11000000,     //PORT ?R61511-style
    0b11100010,     //LAND  MV does not work
    0b11000010,     //PORT_REV
    0b11100000,     //LAND_REV
#elif MODETYPE == 5
    0b00000000,     //PORT ?RM68140-style
    0b00100000,     //LAND     needs SS in (0xB6)
    0b00010000,     //PORT_REV needs SS in (0xB6)
    0b00110000,     //LAND_REV
#endif
};

const uint8_t letter_F[] PROGMEM = {
    /* Code: 0x46, ASCII Character: 'F' */
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF,
    0x1F, 0xF8, 0xFF, 0x1F, 0xF8, 0xFF, 0x1F, 0xF8,
    0xFF, 0x1F, 0xF8, 0x00, 0x00, 0xF8, 0x00, 0x00,
    0xF8, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xF8, 0x00,
    0x00, 0xF8, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xF8,
    0x00, 0x00, 0xF8, 0xFF, 0x07, 0xF8, 0xFF, 0x07,
    0xF8, 0xFF, 0x07, 0xF8, 0xFF, 0x07, 0xF8, 0x00,
    0x00, 0xF8, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xF8,
    0x00, 0x00, 0xF8, 0x00, 0x00, 0xF8, 0x00, 0x00,
    0xF8, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xF8, 0x00,
    0x00, 0xF8, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00,
};

void show(uint8_t val, uint8_t xorval, uint16_t color)
{
    uint8_t i, mask;
    tft.pushCommand(0x36, &val, 1);
    tft.fillScreen(BLACK);
    if (color != WHITE) val ^= xorval;
    tft.pushCommand(0x36, &val, 1);
    tft.setTextColor(color);
    tft.setCursor(0, 0);
    tft.setTextSize(1);
    tft.println("4");
    tft.setCursor(32, 32);
    tft.setTextSize(6);
    tft.println("4");
    tft.setTextSize(2);
    tft.print("MADCTL = ");
    tft.setTextColor(WHITE);
    tft.print("0b");
    for (mask = 0x80; mask != 0; mask >>= 1) {
        tft.setTextColor((xorval & mask) ? color : WHITE);
        tft.print(val & mask ? "1" : "0");
    }
    tft.setTextColor(color);
    tft.println("");
    for (i = 0; i < 8; i++) {
        mask = (1 << i);
        if (xorval & mask) {
            tft.print(msgs[i]);
            tft.println(val & mask ? "=1" : "=0");
        }
    }
    int w = tft.width(), h = tft.height();
    showletter(letter_F, w - 80, 32, 24, 32, color);
    /*
        tft.setAddrWindow(w - 40 - 40, 20 + 0, w - 1 - 40, 20 + 39);
        tft.pushColors(penguin, 1600, 1);
        tft.setAddrWindow(0, 0, w - 1, h - 1);
    */
    delay(5000);
    if (color == RED) {
        tft.println("Scroll UP 32");
        tft.vertScroll(0, h, 32);
        delay(5000);
        tft.vertScroll(0, h, 0);
    }
}

void loop()
{
    int w = tft.width(), h = tft.height();
    uint8_t i = 0, madctl, mode;
    for (i = 0; i < sizeof(modes); i++) {
        mode = modes[i];
        show(initval, mode, WHITE);  //WHITE means default
        //        show(initval, mode, BLUE);   //regular
        show(initval, mode, RED);    //test scroll
    }
}

void showletter(const uint8_t *f, int x, int y, int w, int h, uint16_t textcolor)
{
    uint8_t i, j, c, first = 1;
    uint8_t *temp = (uint8_t*)f;
    uint16_t color;
    tft.setAddrWindow(x, y, x + w - 1, y + h - 1); //设置区域
    for (j = 0; j < (w * h + 7) / 8; j++)
    {
        c = pgm_read_byte(temp);
        for (i = 0; i < 8; i++)
        {
            if ((c & (1 << i)) != 0)
            {
                color = textcolor;
            }
            else
            {
                color = BLACK;
            }
            tft.pushColors(&color, 1, first);
            first = 0;
        }
        temp++;
    }
}


 
I think you will find the 0x1511 and 0x6814 controller might flip the display with bit#2, #4.

David.

Edit.   I have updated the test sketch.    I hope that it displays the default (white) settings in PORTRAIT mode.    There is useful information displayed on the Serial Terminal.    It should work with any MIPI-style controller.   e.g. ILI9327, ILI9341, ILI9486, ...
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 18, 2016, 11:26 pm
Afarina, can you check the color grades again?
- Blue grades are perfect, there are smooth transitions between the intensity-grades.
- There are intensity-jumps on the green grades, which is caused by the missing 2nd bit of the green intensity.
- On the red grades, everything looks fine, except that the whole grade is dark. Maximum intensity of the red color can not be reached because the 5th bit of the red intensity is missing.
- The gray grade looks greenish and there are grading-jumps on it, the intensity transition is not smooth.

I tried to take some pictures about it, but it do not return the true colors of the display. Maybe the grading-jumps can be seen.

It is not a complain. I just want to share what I experienced. I am still confident that this display uses 9bit MCU bus and the last bit of the bus is incorrectly grounded on the shield.
The videos that I have seen look "normal".  i.e. colours are not easy to distinguish but the Red Gradations look about right to me.

Obviously real-life is the best judge of the colours.   And yes,  all controllers have a "dither LSB" bit for Blue and Red.   Likewise,   most GAMMA  registers can tweak the transfer curve.    Admittedly,  it looks as if the "0x6814" might not use 0xE0 or 0xE1 for GAMMA.

The first step is to get all the directions correct.    Then we can try to get a good colour rendering for the standard "pretty girl" photo.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: redion1992 on Jul 19, 2016, 12:30 pm
You seem to have a 0x1511 controller.   There are a couple of problems to resolve but the v2.9.1-Beta on GitHub should be "usable".

David.
Thanks, tried that out with that ID and it works fine for it.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ddwasil on Jul 19, 2016, 10:09 pm
Hi David :
                  Sorry for bother to you. I have a display TFT ili9488  3.95"  and arduino uno (or due)
I`m using MCUFRIEND_kbv.h librery . I`m needing to do a gauge for read a analog  signal .
Can you help me ? , have you  a example ?
thank you
best regards
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: makoshatu on Jul 19, 2016, 10:31 pm
The first step is to get all the directions correct.    Then we can try to get a good colour rendering for the standard "pretty girl" photo.

David.
Hi David,

"Pretty girl" looks good in all aspects on my display :) and the others, too :D .
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 19, 2016, 11:25 pm
@Attila,

Your JPEGs look fine.   However,  I am not familiar with any of those photos / graphics.
The Hosford Chart looks like a fairly good test.

Have you been adjusting the GAMMA curves?

Have you tried my diagnostic sketch?

On an ILI9341 only MY, MX, MV, RGB show any response.    ML affects the vertical scroll direction.
On an ILI9481 MY, MX, MV affect the orientation of the letter F.   SS, GS affect the position of the big 4.

On the mystery 0x1511 and 0x6814 displays I suspect that ML, MH do something completely different.   e.g. GS and SS i.e. the main panel scan directions.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: makoshatu on Jul 20, 2016, 12:27 am
I have been adjusted the GAMMA curves in the TFTinit() function. I stole it from your library, I hope you do not mind it. I used this code to display the pictures:


Code: [Select]

#include <SPI.h>
#include <SD.h>

File fhandle;

void PushTFTCommand(unsigned short command, unsigned short data[15], unsigned short count)
{
  PORTC = B00010011;       // command is comming - b4-reset, b3-CS, b2-RS, b1-WR, b0-RD
  PORTD = ( PORTD & B00000011 ) | ( command & B11111100 );         // Masked port (2...7)
  PORTB = ( PORTB & B11111100 ) | ( command & B00000011 );         // Masked port (8,9)
  PORTC = B00010001;
  PORTC = B00010011;       // write command - WR to HIGH
  PORTC = B00010111;       // data is comming - RS to HIGH
 
  if(count!=0)
    {
      for(unsigned short n=0; n!=count; n++)
        {
          PORTD = ( PORTD & B00000011 ) | ( data[n] & B11111100 );         // data is on port, masked (2...7)
          PORTB = ( PORTB & B11111100 ) | ( data[n] & B00000011 );         // data is on port, masked (8,9)
          PORTC = B00010101;
          PORTC = B00010111;       // toggle WR, HIGH -> LOW
        }
    }

  PORTC = B00011011;       // release CS
}

void putpixel(unsigned short red, unsigned short green, unsigned short blue)
{
  PORTC = B00010011;       // command is comming - b4-reset, b3-CS, b2-RS, b1-WR, b0-RD
  PORTD = ( PORTD & B00000011 ) | ( 0x3C & B11111100 );         // Masked port (2...7)
  PORTB = ( PORTB & B11111100 ) | ( 0x3C & B00000011 );         // Masked port (8,9)
  PORTC = ( PORTC & B11111101 ) | ( B00000000 & B00000010 );    // toggle WR
  PORTC = ( PORTC & B11111101 ) | ( B00000010 & B00000010 );
  PORTC = B00010111;       // data is comming - RS to HIGH

  PORTC = ( PORTC & B11011111 ) | ( red>>2 & B00100000 );   // Red data 1bit
  PORTD = ( PORTD & B00000111 ) | ( red<<1 & B11111000 );   // Red data 5bits
  PORTD = ( PORTD & B11111011 ) | ( green>>5 & B00000100 );  // Green data 1bit
  PORTB = ( PORTB & B11111100 ) | ( green>>5 & B00000011 );  // Green data 2bits
 
  PORTC = ( PORTC & B11111101 ) | ( B00000000 & B00000010 );    // toggle WR, MCU sends 1st 9bits
  PORTC = ( PORTC & B11111101 ) | ( B00000010 & B00000010 );

  PORTC = ( PORTC & B11011111 ) | ( green<<1 & B00100000 );  // Green data 1bit
  PORTD = ( PORTD & B00111111 ) | ( green<<4 & B11000000 );  // Green data 2bits
  PORTD = ( PORTD & B11000011 ) | ( blue>>2 & B00111100 );   // Blue data 4bits
  PORTB = ( PORTB & B11111100 ) | ( blue>>2 & B00000011 );   // Blue data 2bits
 
  PORTC = ( PORTC & B11111101 ) | ( B00000000 & B00000010 );    // toggle WR, MCU sends 2nd 9bits
  PORTC = ( PORTC & B11111101 ) | ( B00000010 & B00000010 );
 
  PORTC = B00011011;       // release CS
}

void TFTInit(void)
{
  unsigned short param[15];
  DDRB = DDRB | B00000011; // digital pins 8 and 9 are outputs
  DDRD = DDRD | B11111100; // digital pins 2 to 7 are outputs, 0&1 (RX/TX) do not change
  DDRC = DDRC | B00111111; // analog pins 0 to 5 are outputs
  PORTC = B00000000;       // reset TFT
  delay(50);
  PORTC = B00011011;
  delay(150);

  PushTFTCommand(0x01, param, 0);     // soft reset
  delay(300);
  PushTFTCommand(0x28, param, 0);     // display off
  param[0]=0x0D;                      // Power Control 1
  param[1]=0x0D;
  PushTFTCommand(0xC0, param, 2);
  param[0]=0x43;                      // Power Control 2
  param[1]=0x00;
  PushTFTCommand(0xC1, param, 2);
  param[0]=0x00;                      // Power Control 3
  PushTFTCommand(0xC2, param, 1);
  param[0]=0x00;                      // VCOM Control 1
  param[1]=0x48;
  param[2]=0x00;
  param[3]=0x48;
  PushTFTCommand(0xC5, param, 4);
  param[0]=0xD0;                      // Frame rate control B0
  param[1]=0x11;                      // 11
  PushTFTCommand(0xB1, param, 2);



  param[0]=0x0F;                      // Positive Gamma Control
  param[1]=0x1B;
  param[2]=0x18;
  param[3]=0x0B;
  param[4]=0x0E;
  param[5]=0x09;
  param[6]=0x47;
  param[7]=0x94;
  param[8]=0x35;
  param[9]=0x0A;
  param[10]=0x13;
  param[11]=0x05;
  param[12]=0x08;
  param[13]=0x03;
  param[14]=0x00;
  PushTFTCommand(0xE0, param, 15);

  param[0]=0x0F;                      // Negative Gamma Control
  param[1]=0x3A;
  param[2]=0x37;
  param[3]=0x0B;
  param[4]=0x0C;
  param[5]=0x05;
  param[6]=0x4A;
  param[7]=0x24;
  param[8]=0x39;
  param[9]=0x07;
  param[10]=0x10;
  param[11]=0x04;
  param[12]=0x27;
  param[13]=0x25;
  param[14]=0x00;
  PushTFTCommand(0xE1, param, 15);
 
  param[0]=0x00;                      // Inversion control
  PushTFTCommand(0xB4, param, 1);
  param[0]=0x02;                      // Display Function control 0x02, 0x02, 0x3B
  param[1]=0x02;
  param[2]=0x3B;
  PushTFTCommand(0xB6, param, 3);
  param[0]=0x0A;                      // Memory Access
  PushTFTCommand(0x36, param, 1);
  param[0]=0x00;                      // Column Address Set 320
  param[1]=0x00;
  param[2]=0x01;
  param[3]=0x3f;
  PushTFTCommand(0x2A, param, 4);
  param[0]=0x00;                      // Page Address Set 480
  param[1]=0x00;
  param[2]=0x01;
  param[3]=0xdf;
  PushTFTCommand(0x2B, param, 4);
  PushTFTCommand(0x38, param, 0);     // Idle Mode off

  PushTFTCommand(0x11, param, 0);     // Sleep out
  delay(150);
  PushTFTCommand(0x29, param, 0);     // Display on

  param[0]=0x66;                      // set 9bit MCU communication mode and 18bit/pixel pixelformat
  PushTFTCommand(0x3A, param, 1);
  PushTFTCommand(0x20, param, 0);     // inversion off
}

void putBMP()
{
  fhandle.seek(54);
  byte bgrdata[3];
  for(unsigned long cyc=0; cyc!=153600; cyc++)
     {
        fhandle.read( bgrdata,3);
        putpixel(bgrdata[2], bgrdata[1], bgrdata[0]);  // red, green, blue
     }
  fhandle.close();    
}

void setup()
{
  TFTInit();    
  SD.begin(10);
}

void loop()
{
  fhandle=SD.open("kepek/adobe.bmp", FILE_READ);    
  putBMP();    
  delay(5000);
  
  fhandle=SD.open("kepek/beamer.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/cal.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/chicken.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/creative.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/doni.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/filet.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/gryrgb.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/homer.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/hosford.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/hqdflt.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/icecrm.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/Linrty.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/mcrft.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/Prettyg.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/prntr.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/rgbgrls.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/scale.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/Steak.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/triangl.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/tst.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

  fhandle=SD.open("kepek/xbox360.bmp", FILE_READ);    
  putBMP();    
  delay(5000);

}


I am not proud of this code, as I just quickly threw it together to see how real RGB666 pictures look like on my modified screen. It reads uncompressed 24bit format BMP files, and it converts the raw RGB888 to RGB666 (actually BGR888 to RGB666) and sequentially shows the pixel data on the screen (every pixel is sent as 2x9bit, the color depth is 262k). Previously, I converted every pictures into 320x480, 24bit format and saved it on the SD card, which is mounted on the TFT shield. Since the BMP standard stores the picture "upside down", I did not need to change the scanning direction of the display. Only one thing was needed: every BMP picture has to be portrait, as just for this quick test I did not want toil on handling the picture alignment by software.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: makoshatu on Jul 20, 2016, 12:33 am
Today I wrote a mail to Raydium Semiconductor Corporation and I asked them to send the datasheet of the RM68140 to me. I hope they will address my request... if so, I am going to share the datasheet with you.

Now it is late night here. Tomorrow morning I am going to try your diagnostic sketch and maybe that datasheet will not be so necessary anymore:). Thank you for your hard work on the library, honestly, it is great job!

Attila
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: makoshatu on Jul 20, 2016, 07:19 am
David,

I tried your diagnostic sketch. Two settings were successful:

- 4:Vert refresh=1, with MADCTL=0b00011000 -> Portrait mode, no flipp
- 5:Row Col Xchange=1, with MADCTL=0b00101000 -> Landscape mode, no flipp

I attached the two JPGs.

"RGB-BGR order" works, text color changed from Light Blue/Blue to Yellow/Red. This JPG is also attached.

I can not see the penguin and any other settings caused flipped screen.

Attila.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 20, 2016, 10:40 am
Your 0b00011000 shows PORTRAIT_REV
Your 0b00101000 shows LANDSCAPE_REV

I am surprised that bit 7 did not change the orientation of the F (upside-down)
Or bit 6 would make the F mirrored (right-left)

bit 4 seems to change the Gate Scan GS.   (vert-flip)

I was hoping that bit#2 or bit#1 of (0x36) would change SS (horiz-flip)

I can always change SS via the 0xB6 register.    I will post a special branch on GitHub for you later this morning.   

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: makoshatu on Jul 20, 2016, 10:56 am
Thank you for your time.


Attila.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 20, 2016, 02:08 pm
Attila,   I love you !!

It appears that my "weird Mega shield" behaves like your "0x6814".

I have already put the changes into Master on GitHub.   And tested on my "weird 16-bit write-only Mega Shield".   So I am well pleased.
It performs all my directions perfectly in graphictest_kbv sketch.
Please can you check that the Software Scroll works ok.   My shield is write-only.  

If you do not want to use the GitHub changes yet,  please add this to setup() in your "textrotation_diagnose.ino" sketch e.g.
Code: [Select]

if (g_identifier == 0x6814) {
    uint8_t d[3];
    d[0] = 0x02;
    d[1] = 0x22;       //Panel_SS = 1
    d[2] = 0x3B;
    tft.pushCommand(0xB6, d, 3);   // panel control
}


This should give you correct PORTRAIT and LANDSCAPE_REV

And you could change the test modes if you want:
Code: [Select]

#elif MODETYPE == 5
    0b00000000,     //PORT ?RM68140-style
    0b00100000,     //LAND     needs SS in (0xB6)
    0b00010000,     //PORT_REV needs SS in (0xB6)
    0b00110000,     //LAND_REV
#endif


What country are you in?   When can I buy you a beer?   Or several beers?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: stokni on Jul 20, 2016, 05:01 pm
Hi David,

Awesome work, thanks!

Got everything to work, but ran into an issue when i tried to execute an action on screen release, not on screen press.

To test it made a simple routine:

Code: [Select]

void loop()
{
 readResistiveTouch();
 Serial.print("tp.z = "); Serial.println(tp.z);
}

void readResistiveTouch(void)
{
   tp = ts.getPoint();
   pinMode(YP, OUTPUT);      //restore shared pins
   pinMode(XM, OUTPUT);
   digitalWrite(YP, HIGH);   //because TFT control pins
   digitalWrite(XM, HIGH);
}


In Serial monitor, output is as followed, even when the screen is kept pressed:

tp.z = 205
tp.z = 204
tp.z = 0
tp.z = 194
tp.z = 0
tp.z = 210
tp.z = 201
tp.z = 0
tp.z = 211
tp.z = 202
tp.z = 0
tp.z = 209

Is this my screen acting up? any idea how to approach this?

Many thanks in advance.

Stokni.


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: makoshatu on Jul 20, 2016, 08:27 pm
Hello David,

This is a great news. I updated my MCUFRIEND_kbv library to your latest version and after that my screen-directions became correct. Software scroll also works well. Nice job!

Beer? Anytime! :D :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: dunozf on Jul 22, 2016, 10:00 am
Hi David,
I bought a 3.5 display with Arduino DUE.
http://www.aliexpress.com/item/KOOKYE-5-LCD-Touch-Screen-Display-Monitor-Module-DUE-Board-for-Arduino/32651759441.html
There should be a controller ILI9481, but the display is still black.
I use IDE 1.6.9.

Output from graphictest_kbv:

Serial took 0ms to start
ID = 0x414

Output from LCD_ID_readreg:

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) 1C 1C   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 1C 1C 1C 1C   Manufacturer ID
reg(0x0009) 1D 1D 1D 1D 1D   Status Register
reg(0x000A) 1E 1E   Get Powsr Mode
reg(0x000C) 1C 1C   Get Pixel Format
reg(0x0061) 75 75   RDID1 HX8347-G
reg(0x0062) 76 76   RDID2 HX8347-G
reg(0x0063) 77 77   RDID3 HX8347-G
reg(0x0064) 74 74   RDID1 HX8347-A
reg(0x0065) 75 75   RDID2 HX8347-A
reg(0x0066) 76 76   RDID3 HX8347-A
reg(0x0067) 77 77   RDID Himax HX8347-A
reg(0x0070) 74 74   Panel Himax HX8347-A
reg(0x00A1) B5 B5 B5 B5 B5   RD_DDB SSD1963
reg(0x00B0) B4 B4   RGB Interface Signal Control
reg(0x00B4) B4 B4   Inversion Control
reg(0x00B6) B6 B6 B6 B6 B6   Display Control
reg(0x00B7) B7 B7   Entry Mode Set
reg(0x00BF) BF BF BF BF BF BF   ILI9481, HX8357-B
reg(0x00C0) 5C 5C 5C 5C 5C 5C 5C 5C 5C   Panel Control
reg(0x00C8) 5C 5C 5C 5C 5C 5C 5C 5C 5C 5C 5C 5C 5C   GAMMA
reg(0x00CC) 5C 5C   Panel Control
reg(0x00D0) 5C 5C 5C   Power Control
reg(0x00D2) 5E 5E 5E 5E 5E   NVM Read
reg(0x00D3) 5F 5F 5F 5F   ILI9341, ILI9488
reg(0x00DA) 5E 5E   RDID1
reg(0x00DB) 5F 5F   RDID2
reg(0x00DC) 5C 5C   RDID3
reg(0x00E0) F4 F4 F4 F4 F4 F4 F4 F4 F4 F4 F4 F4 F4 F4 F4 F4   GAMMA-P
reg(0x00E1) F5 F5 F5 F5 F5 F5 F5 F5 F5 F5 F5 F5 F5 F5 F5 F5   GAMMA-N
reg(0x00EF) FF FF FF FF FF FF   ILI9327
reg(0x00F2) F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6   Adjust Control 2
reg(0x00F6) F6 F6 F6 F6   Interface Control

Thanks for the help.

Zdeno
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 22, 2016, 10:49 am
I don't know how good you are at counting pins but this
(http://g03.a.alicdn.com/kf/HTB1Uqv4MXXXXXXyXXXXq6xXFXXXT/201146412/HTB1Uqv4MXXXXXXyXXXXq6xXFXXXT.jpg?size=151136&height=1000&width=1000&hash=3199f570caf48c9e1215ace40c935b2e)

does NOT look like a Uno shield.  It even says "arduino mega 2560"

David.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: dunozf on Jul 22, 2016, 11:00 am
Yes, I know that this is not a display for UNO.
I plugged it with DUE.
I do not know if I need to make some changes to the code for DUE.

Zdeno
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: spoums on Jul 23, 2016, 04:46 pm
Hello,

I need some help with a tft lcd shield I bought from ebay.
I bought this one  (http://www.ebay.com/itm/111687922300?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT).
and I have some trouble figuring out what I have to do to make it work properly.
I downloaded the libraries and examples you have in this thread but my screen doesn't run properly in any of the resoution examples.
I tried running graphictest_kbv but I had an error about low memory for my arduino UNO.
(http://i.imgur.com/oLe22x7.png)
Are there any settings I should change so I don't get the error?
The error happens while it is uploading on the board.

Running GLUE demo 800x480 I got some weird results.
The demo runs in 1/4 of the screen in black and white.
Here are some pictures that may help you understand.

(http://i.imgur.com/zBwovf8.jpg) (http://i.imgur.com/B0X7cUh.jpg) (http://i.imgur.com/PTN5N5H.jpg) (http://i.imgur.com/FEak2oV.jpg)

My problem is that I don't understand how I can start troubleshooting since there are so many commands in every demo and example you have posted.

Any help would be much appreciated.

I attach you the results from serial monitor when I run LCD_ID_readreg in txt file format although I don't get how I can check the results I get.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 23, 2016, 05:46 pm
There is no "error".  It simply warns that memory is "tight".
It is always safe to use 99.999% Flash memory.
This particular sketch is safe to use up to 93% SRAM.

It is simple to copy-paste your results from LCD_ID_readreg:
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(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 83 88 68 Manufacturer ID
reg(0x0009) 00 80 63 00 80 Status Register
reg(0x000A) 98 98 Get Powsr Mode
reg(0x000C) 06 06 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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) BF BF 0F 11 FF 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) 41 00 Entry Mode Set
reg(0x00BF) 00 02 04 15 11 FF ILI9481, HX8357-B
reg(0x00C0) 00 3B 00 00 07 01 00 00 00 Panel Control
reg(0x00C8) 12 01 11 08 01 00 04 0C 0E 0C 05 03 00 GAMMA
reg(0x00CC) 2A 2A Panel Control
reg(0x00D0) 00 05 08 Power Control
reg(0x00D2) 04 62 00 00 00 NVM Read
reg(0x00D3) 00 00 00 00 ILI9341, ILI9488
reg(0x00DA) 00 83 RDID1
reg(0x00DB) 83 8F RDID2
reg(0x00DC) 8F 22 RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 00 00 00 Interface Control

You have an "0x1511" controller.   No,  I have not got a datasheet.   I am guessing that it is a Renesas R61511.   I do not own this display.   I hope that I have got it working 100% in the Beta library with help from Levy, redion1992, robji and other 0x1511 owners.

I would like to know if the Band Scroll works in Portrait (Blue) and Portrait_Rev (Red).
And whether Software Scroll works in all 4 aspects.

Please delete your current library directory.    Then use the IDE Library Manager to install v2.9.1-Beta from GitHub.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: spoums on Jul 23, 2016, 07:06 pm
There is no "error".  It simply warns that memory is "tight".
It is always safe to use 99.999% Flash memory.
This particular sketch is safe to use up to 93% SRAM.

It is simple to copy-paste your results from LCD_ID_readreg:
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(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 83 88 68 Manufacturer ID
reg(0x0009) 00 80 63 00 80 Status Register
reg(0x000A) 98 98 Get Powsr Mode
reg(0x000C) 06 06 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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) BF BF 0F 11 FF 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) 41 00 Entry Mode Set
reg(0x00BF) 00 02 04 15 11 FF ILI9481, HX8357-B
reg(0x00C0) 00 3B 00 00 07 01 00 00 00 Panel Control
reg(0x00C8) 12 01 11 08 01 00 04 0C 0E 0C 05 03 00 GAMMA
reg(0x00CC) 2A 2A Panel Control
reg(0x00D0) 00 05 08 Power Control
reg(0x00D2) 04 62 00 00 00 NVM Read
reg(0x00D3) 00 00 00 00 ILI9341, ILI9488
reg(0x00DA) 00 83 RDID1
reg(0x00DB) 83 8F RDID2
reg(0x00DC) 8F 22 RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 00 00 00 Interface Control

You have an "0x1511" controller.   No,  I have not got a datasheet.   I am guessing that it is a Renesas R61511.   I do not own this display.   I hope that I have got it working 100% in the Beta library with help from Levy, redion1992, robji and other 0x1511 owners.

I would like to know if the Band Scroll works in Portrait (Blue) and Portrait_Rev (Red).
And whether Software Scroll works in all 4 aspects.

Please delete your current library directory.    Then use the IDE Library Manager to install v2.9.1-Beta from GitHub.

David.
Hello David,
thank you for replying.

If you check the photo it says that there was a problem uploading to board.

You got the number for the controller from the line I quote below?
"reg(0x00BF) 00 02 04 15 11 FF ILI9481, HX8357-B"

Should I delete the Adafruit library too or the mcufriend only?
What's the name of the beta library you mention I didn't find it at GitHub after some searching.

I'll be happy to give you some feedback although as you can tell I'm pretty new to this therefore some dumb questions.

Spiros
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 23, 2016, 09:10 pm
The library in the ZIP from message#0 is v2.9.0 Release.   This does not know 0x1511.

If you goto the Library Manager in your IDE,  it should find MCUFRIEND_kbv v2.9.1-Beta version.     Just type mcufriend or kbv.

Delete your current MCUFRIEND_kbv directory  or it will just say 'Installed".
You can keep the Adafruit_GFX Library.    Mind you,   the Library Manager installs an old version.    The current GFX version on GitHub supports multiple Fonts and Buttons.

Ask if you have a problem.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: spoums on Jul 23, 2016, 09:54 pm
I didn't get any results in Library Manager of Arduino IDE so I searched and found your library (https://github.com/prenticedavid/MCUFRIEND_kbv) in GitHub.
Is this the correct version?
It probably is cause GLUE Demo 800x480 worked.
I had an error with the extern uint8_t SmallFont[]; command. Maybe I don't have the newest Adafruit library?

Do you want me to run any other examples and get back to you with the results?

Spiros
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 23, 2016, 10:17 pm
You should run the graphictest_kbv sketch.  Try it.

When you have tested this you can try the GLUE_demo_480x320.

There is no point in trying to run a demo for a 800x480 when you have a 480x320 display.

Most of my examples adjust to the screen size.   UTFT examples simply use the GLUE class.    I have not tidied up the UTFT code.    

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: fiete_02 on Jul 24, 2016, 09:50 am
it seems to be, that I bought the identical mcufriend 3.5" TFT LCD from aliexpress as spoums bought because the LCD_ID_readreg output is absolutely identical and the photo of the PCB looks identical (at least for me).

And .. identical to david_prentice's experience in a post of this thread, my touch glass was broken as well, when I received the TFT. Sure I got refunded, but I can not understand as well, why they package the TFTs so bad, that a lot of them arrive with broken glases. So the touch functionality doesn't work but the TFT works fine.

My IDE is 1.6.8 and I have the latest Adafruit_GFX.h as well as MCUFRIEND_kbv.h library.

The graphictest_kvb.ino example, comming with the MCUFRIEND_kbv library works fine on a Uno R3 clone with this little change :

Code: [Select]
void setup(void) {
    Serial.begin(9600);
    uint32_t when = millis();
    //    while (!Serial) ;   //hangs a Leonardo until you connect a Serial
    if (!Serial) delay(5000);           //allow some time for Leonardo
    Serial.println("Serial took " + String((millis() - when)) + "ms to start");
    static uint16_t identifier;
    //    tft.reset();                 //we can't read ID on 9341 until begin()
    g_identifier = tft.readID(); //
    Serial.print("ID = 0x");
    Serial.println(g_identifier, HEX);
    if (g_identifier == 0x00D3 || g_identifier == 0xD3D3) g_identifier = 0x9481; // write-only shield
    if (g_identifier == 0xFFFF) g_identifier = 0x9341; // serial
//    g_identifier = 0x9329;                             // force ID
    g_identifier = 0x9481;  // <===CHANGE !! force ID to ILI9481 !!!!
    tft.begin(g_identifier);
}


The change is only in one line, to force the g-identifier to 0x9481. To better find the location of change, I inserted the complete setup() section.

Hope, it will work for spoums as well as for me.

Maro
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 24, 2016, 10:16 am
If you are using the v2.9.1-Beta it should detect an ID=0x1511.
The Library Manager should find and install this Beta version.   Please tell me if you have a problem.

And the examples should run without any changes.

Yes,  the 0x1511 is "similar" to the ILI9481 but it does not respond to MV in the MADCTL register.

I would appreciate it if you use the Library as intended.    And report any problems.
Occasionally I might suggest a "kludge" while I am trying to add support for a new controller.

Please do not introduce "blind guesswork" for the Uno-style shields.   You can read the ID and run them on Uno, Zero, Due, ...

Mega-style shields have more pins and are write-only.    These can NOT read the ID.   The library is not intended for these shields.   

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: fiete_02 on Jul 24, 2016, 12:46 pm
Hi David,

first of all I would like to thank you for your incredible nice library - you really make these chinese Uno TFT shields work !

I fully agree, that my testing was not professional, even if I could manage to run the graphictest_kvb.ino example with the ILI9481 ID .. AND ... I was wrong, as I didn't run the latest release of your MCUFRIEND_kbv library, but version 2.9.0.

With the Beta Version 2.9.1, the graphictest_kvb.ino example runs without any changes and prints the following to the IDE monitor :

"Serial took 0ms to start
 ID = 0x1511"

If you are still interested in the outcome of your graphictest_kvb.ino example with an Uno R3 clone :

* all graphics displaying work ok
* the first line of your summary after all the graphics is truncated by half and may mean "MCUFRIEND .....", the next line is "Fill screen .....", the next "Text...." and so on until it ends with F_CPU:16.00MHz -0s
* portrait vertical scroll : scrolls up and down ok
* portrait software scroll is ok
* scrolling only the color band does not work with red color
* scrolling only the color band scrolls up and takes the text below up as well with blue color
* landscape vertical scroll is, in my eyes, a horizontal scroll
* landscape software scroll uses only approx. half of the display width
* there is no mirroring as it was with ID9481

Same library version 2.9.1 and same graphictest_kvb.ino example BUT with forced ID9481 makes mirroring but fails with Software scroll as well as with
landscape orientation.

Hope, this is of any help for you.

Maro


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 24, 2016, 02:18 pm
Thankyou Maro.

Look at description of scroll tests (http://forum.arduino.cc/index.php?topic=379074.msg2838088#msg2838088) from another thread.   Obviously your ID=0x1511

It sounds as if the Blue Band scroll is "almost" correct.   
The Red Band scroll is missing.   Probably because the Red Vertical Scroll UP is in the wrong direction.

It would be nice if you could confirm this.

I posted a textRotation_diagnose sketch (http://forum.arduino.cc/index.php?topic=366304.msg2846339#msg2846339) in message #538.
If you edit setup() this will give you un-mirrored text:
Code: [Select]

    if (g_identifier == 0x9481 || g_identifier == 0x1511) initval |= (1 << 1); //Flip Horiz

And if you edit loop() this will test the scroll directions.
Code: [Select]

        //        show(initval, mode, BLUE);   //regular
        show(initval, mode, RED);    //test scroll


A video would be nice but you can describe which bits make a difference.   I am most interested in bit#4.    This should determine the scroll UP direction.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: fiete_02 on Jul 24, 2016, 06:07 pm
It sounds as if the Blue Band scroll is "almost" correct.  
The Red Band scroll is missing.   Probably because the Red Vertical Scroll UP is in the wrong direction.
It would be nice if you could confirm this.
I'm currently running grahictest_kbv without any alteration :
In Portrait (USB cable comming out of the top) the blue band scroll goes up and takes the green text with it upwards until yellow Software scroll starts.

I will test the other sketch in a few minutes and will let you know.

maro
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 24, 2016, 06:21 pm
The Blue Band scroll is slightly wrong.

My "edit" suggestions referred to the "TextRotation_diagnose.ino" sketch posted in message #538.
Nothing to do with the "graphictest_kbv.ino" from the examples.

Don't worry if you do not understand my sketch.  There are several "0x1511" owners out there.
I am sure that one of them will try those edits and I can determine how the MADCTL bits are working.

Please realise that I do not own this controller.   All that I can do is post sketches and ask owners to report back.    They have their own lives.    I can only test "remotely".

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: fiete_02 on Jul 24, 2016, 06:35 pm
I found out immediately after posting and deleted this stupid part of the post. I'm currently running your TextRotation_diagnose.ino sketch, changed it according to your inputs and increased the delay, as I'm little older and can't write all the changes within 5 seconds :-)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 24, 2016, 06:43 pm
Run it regular first.   I think you will only see bit#0, #1, #3, #6,#7 affecting the display.

Then try the RED version that tests the scroll.
I want to know if #2, #4 do anything.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: fiete_02 on Jul 24, 2016, 07:42 pm
Hi David,

I did it with the following configuration :

* if (g_identifier == 0x9481 || g_identifier == 0x1511) initval |= (1 << 1); //Flip Horiz
* show(initval, mode, BLUE);

result is as follows :

 1: 4 F white Or:  0 Dir:RtL 0b11001100 - 0:Flip Vert=0
 2: 4 F blue  Or:180 Dir:LtR 0b11001101 0 0:Flip vert=1
 3: 4 F white Or:  0 Dir:RtL 0b11001100 - 1:Flip Horiz = 0
 4: 4 F blue  Or:  0 Dir:LtR 0b11001110 1 1:Flip Horiz = 1
 5: 4 F white Or:  0 Dir:RtL 0b11001100 - 2:Horiz refresh = 1
 6: 4 F blue  Or:  0 Dir:RtL 0b11001000 2 2:Horiz refresh = 0
 7: 4 F white Or:  0 Dir:RtL 0b11001100 - 3:RBG-BGR order = 1
 8: 4 F red   Or:  0 Dir:RtL 0b11000100 3 3:RBG-BGR order = 0
 9: 4 F white Or:  0 Dir:RtL 0b11001100 - 4:vert refresh = 0
10: 4 F blue  Or:180 Dir:LtR 0b11011100 4 4:vert refresh = 1
11: 4 F white Or:  0 Dir:RtL 0b11001100 - 5:Row Col Xchange=0
12: 4 X blue  Or:  0 Dir:RtL 0b11101100 5 5:Row Col Xchange=1
13: 4 F white Or:  0 Dir:RtL 0b11001100 - 6:Column order = 1
14: 4 F blue  Or:  0 Dir:RtL 0b10001100 6 6:Column order = 0
15: 4 F white Or:  0 Dir:RtL 0b11001100 - 7:Row order = 1
16: 4 f blue  Or:  0 Dir:RtL 0b01001100 7 7:Row order = 0

Ann.: 1.row is number of different displays (1 to 16)
      2.row number on display in big letters
      3.row letter in big letters (normally F), X means whipped F, almost not readable, f means flipped F top to bottom
      4.row is color of text
      5.row is Orientation. 0 means text is readable, when USB cable is on top. 180 degree means text is readable, when USB cable is on bottom.
      6.row is text direction. RtL means, the text is mirrored (goes right to left), LtR means, text is readable without mirror
      7.row binary information from display
      8.row Bit, which is turned in the color of row 4, where Bit 0 is the LSB and Bit 7 the MSB
      9.row Text information on display

For better reading copy/past it to an editor and use proportional font like Courier.

Does this help in any way ?

Maro
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: fiete_02 on Jul 24, 2016, 08:30 pm
same as with last posting but with "show(initval, mode, RED);"

 1: 4 F white O:  0 D:RtL 0b11001100 - - 0:Flip Vert=0
 2: 4 F red   O:180 D:LtR 0b11001101 0 D 0:Flip vert=1
 3: 4 F white O:  0 D:RtL 0b11001100 - - 1:Flip Horiz = 0
 4: 4 F red   O:  0 D:LtR 0b11001110 1 U 1:Flip Horiz = 1
 5: 4 F white O:  0 D:RtL 0b11001100 - - 2:Horiz refresh = 1
 6: 4 F red   O:  0 D:RtL 0b11001000 2 U 2:Horiz refresh = 0
 7: 4 F white O:  0 D:RtL 0b11001100 - - 3:RBG-BGR order = 1
 8: 4 F blue  O:  0 D:RtL 0b11000100 3 U 3:RBG-BGR order = 0
 9: 4 F white O:  0 D:RtL 0b11001100 - - 4:vert refresh = 0
10: 4 F red   O:180 D:LtR 0b11011100 4 U 4:vert refresh = 1
11: 4 F white O:  0 D:RtL 0b11001100 - - 5:Row Col Xchange=0
12: 4 X red   O:  0 D:RtL 0b11101100 5 U 5:Row Col Xchange=1
13: 4 F white O:  0 D:RtL 0b11001100 - - 6:Column order = 1
14: 4 x red   O:  0 D:RtL 0b10001100 6 U 6:Column order = 0
15: 4 F white O:  0 D:RtL 0b11001100 - - 7:Row order = 1
16: 4 y red   O:  0 D:RtL 0b01001100 7 U 7:Row order = 0

Ann.: 1.row is number of different displays (1 to 16)
      2.row number on display in big letters
      3.row letter in big letters (normally F), X means whipped F, almost not readable, x means flipped F right to left, y means flipped twice right to left AND top to bottom
      4.row is color of text
      5.row is Orientation. 0 means text is readable, when USB cable is on top. 180 degree means text is readable, when USB cable is on bottom.
      6.row is text direction. RtL means, the text is mirrored (goes right to left), LtR means, text is readable without mirror
      7.row binary information from display
      8.row Bit, which is turned in the color of row 4, where Bit 0 is the LSB and Bit 7 the MSB
      9.row slight scrolling at the end of the delay either U=up, D=down or no scrolling = "-"
     10.row Text information on display
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 24, 2016, 10:25 pm
I would expect:
0:  4 and F are vertically flipped
1:  4 and F are horizontally flipped
2:  f.k.
3:  Red and Blue are swapped.
4:  I hope that vert scroll goes UP or DOWN
5:  nothing happens with 0x1511
6.  F is mirrored
7:  F is upside-down

Scroll UP would always work in the same logical direction.

Unfortunately,   I am not sure about your report(s).   Perhaps you can compare with my "expectations".

You might choose to try MODETYPE 4 that shows different aspects.   Obviously this works better with an implemented MV (bit#5).

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: fiete_02 on Jul 25, 2016, 01:20 am
Hi David,

mabe I was not clear enough in my annotations. If orientation is 180 degree in my list, I had to rotate the display, so that I could read it either unaided (LtR) or with a mirror on the right side of the display (RtL). All information in each line refers to the orientation, where I could read the display.

The results have been double checked and are correct, so far as I can say.

I've tried to make pictures of the outcome, but the display is so shiny, that it mirrors the camera and thus you can't see a lot.

To compare it with our expectations, I need some help to assign my 16 different displays to the list of your 8 different expectations.

If you are only interested in the 8 colored samples, where the different bit 0 to 7 are highlighted with the relevant color, I can confirm the folloing with show(initval, mode, RED) :

Bit 0 : 4 and F are horizontally AND vertically flipped, thus display has to be turned by 180 to read the text unaided
Bit 1 : 4 and F are NOT flipped, neither horizontally nor ventically
Bit 2 : 4 and F is vertically flipped, you have to use a mirror at the right side to read the text
Bit 3 : Red and blue are swapped and 4 and F is vertically flipped
Bit 4 : 4 and F are horizontally AND vertically flipped, there is a slight scrolling up (as with bit 0 to 7  relativ to the orientation)
Bit 5: 4 and F are vertically flipped, F ist almost whiped out (almost not readable)
Bit 6: 4 is vertically flipped, F is readable in a normal way
Bit 7: 4 is vertically flipped, F is horizontally flipped


David, I agree, this is abviously easier to understand :-)

So, can you work with this information or is it still confusing ?

Maro
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 25, 2016, 01:45 am
Thanks for your reply.   No,   I can not make any sense out of it at all.

The default (white) should be in Portrait.   i.e. USB lead comes out of the top.   Printed legend on the Touch Panel at the bottom.     MADCTL=0b11001010.

It is my bedtime.   I will think in the morning.

David.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: fiete_02 on Jul 25, 2016, 08:42 am
Hi David,

all the frames (white and colored) were portrait and no print legend was at the bottom of the screen.  In testframe 2 and 10, you could only read the text, if you turned the display by 180 degree (USB connector at the bottom). All other testframes were portrait with USB connector at the top.

Sorry for the unexpected results, but I can only report, what I see.
Maro
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: fiete_02 on Jul 25, 2016, 08:54 am
Hi David,

I just double checked my display with the pictures from spoums (post #555) and can confirm, that all IC locations, IC mounting, wiring, vias, silkscreening on the pcb are identical. Maybe spoums can run the same test to verify my results, in case there is not only the touch glass broken with mine.

Maro
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 25, 2016, 12:22 pm
The 1st photo in #555 show the pcb in Portrait mode.  USB  / microSD at top.
The 2nd photo shows the Touch Panel upside-down.   You can see the 4 X, Y Touch terminals but there is no printed model number on the fron of the Touch Panel.

A Touch Panel is normally mounted with its ribbon at the bottom.
A TFT Panel is normally mounted with its ribbon at the bottom.

It amazes me how people post very high-res photos without the distinguishing features that show the orientation.

As far as I know,  I have got the PORTRAIT (Blue) and PORTRAIT_REV (Red) physically correct on your display.
So I am surprised that the TextRotation_diagnose sketch is not displaying the default (white) in Portrait.

If it is displaying in Portrait_Rev you can still report the effect of each bit.    Just twist the Arduino around by 180 degrees.   Then you can read the text.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: fiete_02 on Jul 25, 2016, 01:23 pm
Hi David,

The 1st photo in #555 show the pcb in Portrait mode.  USB  / microSD at top.
correct

The 2nd photo shows the Touch Panel upside-down.   You can see the 4 X, Y Touch terminals but there is no printed model number on the front of the Touch Panel.
correct. There is also no printed model number on the front of the touch panel with my display. I don't want to lift the display from the PCB (it sticks with a bilateral adhesive tape on the PCB) as the touch glass is already broken.

A Touch Panel is normally mounted with its ribbon at the bottom.
A TFT Panel is normally mounted with its ribbon at the bottom.
correct, both the touch 4-wire ribbon and the display black multi-wire ribbon is at the bottom.

As far as I know,  I have got the PORTRAIT (Blue) and PORTRAIT_REV (Red) physically correct on your display.
So I am surprised that the TextRotation_diagnose sketch is not displaying the default (white) in Portrait.
As I have written before, ALL of the 16 different frames were in Portrait (the white ones and the color ones). Assuming you accept, that Portrait is also, if the displayed frame is turned by 180 degree. At least there was not a single landscape frame.

If it is displaying in Portrait_Rev you can still report the effect of each bit.    Just twist the Arduino around by 180 degrees.   Then you can read the text.
Thats exactly what i did. I'm not so good in reading text, turned around by 180 degree, therefor I turned the display by 180 degree, so that I could read the text. In both of these cases (#2 and #10, the text was readable unaided, that means without a mirror on the right side and the USB connector and SD-card holder was at the bottom). The frames in case of #2 and #10 have been reported in this turned orientation. Therefore the slight scroll moved down. In respect of the standard orientation (USB and SD-card holder up) the slight scroll went up with #2 but in this standard orientation I can't read the text.

If it is still confusing for you, maybe we have to work with other tests or you tell me, how to film the display without reflection and how to send the film to you.

Maro
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: fiete_02 on Jul 25, 2016, 04:26 pm
Hi David,

I recognized, that it is quite difficult to explain complex things in writing. Therefore I build a blackbox with the display and a camera and filmed the outcome of your TextRotation_diagnose.ino sketch. I only reduced the delay to 3 seconds in the sketch, this should not influence the result in any way.

If you write me a PM with your E-Mail address, I will release the dropbox folder with the mpg4 file (56MB) for you and send you the link.

What do you think about that ?

Maro

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: spoums on Jul 26, 2016, 09:21 pm
Hello Maro,
I still cant get the graphictest_kbv to run.
I keep getting a "avrdude: stk500_recv(): programmer is not responding" when I try to uploaded to my UNO.
Can you or David confirm I have the correct library?
I couldn't find it through Library Manager so I found library at github (https://github.com/prenticedavid/MCUFRIEND_kbv).

Any ideas why I get this error? I googled but didn't find any reliable answer.

Spiros
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 26, 2016, 10:18 pm
You should be able to see my library (v2.9.1-Beta) via the Library Manager.    Install it with the Library Manager.
If anyone else has a problem,  please tell me.   Please quote which IDE version.

If you just downloaded the ZIP from GitHub and saved on your PC.
You should be able to "Add ZIP Library" from the IDE.

The graphictest_kbv example should fit on a Uno.    It probably says 97% of program memory and 79% of dynamic memory.    This is OK.

The bootloader should work just as well with the example sketches as with any other Arduino sketches.

Whether you have a genuine Uno or a Chinese clone,  they should all work exactly the same.
If you have ever used "Upload using Programmer",  you must "Burn Bootloader" again to restore the bootloader.

Note that v1.6.5 and v1.6.6 have got a duff Uno bootloader.    I use v1.6.6.
I do not know if the later v1.6.x versions have corrected this.   The v1.7.x IDEs have got good Uno bootloader files.

If you have never connected a Programmer,   you do not have to worry.   Your Uno always works out of the box.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: varvik85 on Jul 27, 2016, 06:47 pm
Hi.I use a 3.5 display and arduino uno. No one example from the library is not working.What's the problem?What needs to be set in the code?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: fiete_02 on Jul 28, 2016, 07:58 pm
Hi varvik85,

as no one of us is really good in clairvoyance, it's really tough to give you an answer. If you can't give us some hints, which one of the tons of different 3,5inch displays you are using, which version of what library doesn't work and what sketch failed to work with what error message ... I assume, you won't get a lot of answers.

Maro
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: one3rdnerd on Jul 29, 2016, 10:14 am
Thanks, tried that out with that ID and it works fine for it.
I can't seem to find this version? on github I check the history file and it says 2.9 not 2.9.1 beta. IS there a different location for this? I have the same shield I believe and can't seem to get it working at the moment.

I randomly had the screen working with the graphicstest earlier and then when I attempted to repeat after unplugging it didn't work though I don't think I did anything different.

When I use the serial monitor I get ID 0x9481 the screen flickers after uploading the graphicstest_kbv but that's it.

Link: http://www.ebay.co.uk/itm/231978929794?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

and below is my serial output from running LCD_ID_readreg

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) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 00 00 00 00   Status Register
reg(0x000A) 00 08   Get Powsr Mode
reg(0x000C) 00 66   Get Pixel Format
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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 02 04 94 81 FF   ILI9481, HX8357-B
reg(0x00C0) 00 10 3B 00 02 11 00 00 00   Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 43   Power Control
reg(0x00D2) 00 01 22 00 00   NVM Read
reg(0x00D3) 00 01 22 00   ILI9341, ILI9488
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA-N
reg(0x00EF) 00 00 00 00 00 00   ILI9327
reg(0x00F2) 00 00 33 00 00 00 00 00 00 00 00 00   Adjust Control 2
reg(0x00F6) 00 80 80 80   Interface Control


You clearly have a genuine ILI9481 controller.
Yes,  I would like to get this working for you.

The first step is to delete the current library and re-install a fresh download copy.
You seem to have no RED at all.

Does anyone else have a problem with this Shield?
I only own a 16-bit write-only ILI9481.   So I have to rely on remote reporting.

The brief "yellow on white" is COLOUR INVERSION.    i.e. tft.invertDisplay(true)

David.
I think I may have this shied. I have posted my LCD_ID_readreg output in the comment above.

Thanks, appreciate any guidance, I am new here.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 29, 2016, 10:46 am
1.  post a link to your actual display.   e.g. the Ebay sale item
2.  say which library version you are using.   e.g. a link to where you got it from
3.  run the LCD_ID_readreg.ino sketch and paste the output from the Serial Terminal.

The v2.9.0 library (Release) attached to message #0 of this thread should work for most 240x320 controllers.
The 320x480 ILI9481 should work fine with v2.9.0

There have been some unknown 320x480 displays appearing on Ebay / AliExpress.   You need the Beta version on GitHub for these.    e.g. 0x1511 and 0x6814 (appears as 0x9486 on v2.9.0)

The v2.9.1-beta on https://github.com/prenticedavid/MCUFRIEND_kbv (https://github.com/prenticedavid/MCUFRIEND_kbv) should be accessible via the Library Manager in the IDE.

If you have a problem with GitHub,  please explain.   e.g. write down numbered steps for what you have done.   And say which one(s) have gone wrong.

The 0x1511 is "usable" but I am not 100% happy with the scrolling.   I have ordered one of the culprit displays.   When it arrives,  I will put a new Release on GitHub and on message #0.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 29, 2016, 11:04 am
Link: http://www.ebay.co.uk/itm/231978929794?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

and below is my serial output from running LCD_ID_readreg 
You have a genuine ILI9481.   I have a shield exactly like the one in your link.
I am always a little suspicious of Chinese vendors that claim to have a "UK location"
Even more so when the sale numbers are "1" and "ended".

I presume that you have mated the shield with a regular Uno.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: one3rdnerd on Jul 29, 2016, 11:36 am
Hi David,

I think it is an Uno R3 however it was part of a learning kit you might be able to see at the following link http://www.ebay.co.uk/itm/201516824654?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

That said the brand on the board is GEEKCREIT and I am pretty sure can be best seen in this photo http://img.banggood.com/images/oaupload/banggood/images/84/47/1bf7aa19-0ac8-4a35-8dfa-46fd51332032.jpg

I checked the library manager and it showed I have the beta installed. I took a download from your github and used that copy. I am wondering if it could be issues with any of the dependancy libraries? I can strip all other folders from the libraries folder and maybe re-source the files I need to accompany your library?

You will have to excuse me, I am new to this, I am a web designer/developer with HTML/CSS and a little PHP background so just finding my feet with this. Could it be that I need a different arduino for best results? I can take and send a photo of my arduino and shield pairing.

Thanks for your information and your dedication to this library from one David to another.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 29, 2016, 12:46 pm
I love Ebay "sale information".    Image #1, #4 of the item photo show a Uno clone with DIP-28.    Image #2, #3 show a Uno clone with TQFP-32 AVR.
Your BangGood photo shows a different brand with TQFP-32.

Check that U5 is actually mounted.   (and soldered properly).   If you have a DMM,  check that you actually get 3.3V from the Arduino's 3.3V header socket.


As a general rule,   clones are assembled pretty well.    I received one with missing U5 once.    Otherwise all other Unos have worked ok.

I have received shields with shorted tracks,  bad soldering, ...
And most "dirt-cheap" modules probably use "QC failure" components.   i.e. they work but are not 100% in spec.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: spoums on Jul 29, 2016, 03:14 pm
You should be able to see my library (v2.9.1-Beta) via the Library Manager.    Install it with the Library Manager.
If anyone else has a problem,  please tell me.   Please quote which IDE version.

If you just downloaded the ZIP from GitHub and saved on your PC.
You should be able to "Add ZIP Library" from the IDE.

The graphictest_kbv example should fit on a Uno.    It probably says 97% of program memory and 79% of dynamic memory.    This is OK.

The bootloader should work just as well with the example sketches as with any other Arduino sketches.

Whether you have a genuine Uno or a Chinese clone,  they should all work exactly the same.
If you have ever used "Upload using Programmer",  you must "Burn Bootloader" again to restore the bootloader.

Note that v1.6.5 and v1.6.6 have got a duff Uno bootloader.    I use v1.6.6.
I do not know if the later v1.6.x versions have corrected this.   The v1.7.x IDEs have got good Uno bootloader files.

If you have never connected a Programmer,   you do not have to worry.   Your Uno always works out of the box.

David.
Hello David,
I'm not able to see your library when I haven't install it. If I install it from github and then type mcu at Library Manager it shows up.
I used Arduino IDE 1.6.9.
I unistalled and installed 1.6.6 like you but it was the same.
Now I installed 1.6.10 version.

screenshot before installation
(http://i.imgur.com/c0Vdo0m.jpg)

screenshot after zip installation
(http://i.imgur.com/URaJEuE.jpg)


Anyway I managed to run graphictest_kbv after I burnt Bootloader as you said.
Seems to be running ok. I post the results the screen shows at the end.

(http://i.imgur.com/Xq4f3If.jpg)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 29, 2016, 04:09 pm
So you have it running ok now.   And the Library Manager of v1.6.10 recognises it.

I have ordered the same display from your link.    When it arrives,  I hope that it is a 0x1511 type,  and that I can clear up the scrolling issues.

Two questions:
1. did the Library Manager allow you to search for kbv ?   And [Install] from the Manager ?
2. did v1.6.10 have the correct Uno bootloader ?  i.e. did Tools->Burn Bootloader work from the IDE ?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: spoums on Jul 29, 2016, 04:56 pm
So you have it running ok now.   And the Library Manager of v1.6.10 recognises it.

I have ordered the same display from your link.    When it arrives,  I hope that it is a 0x1511 type,  and that I can clear up the scrolling issues.

Two questions:
1. did the Library Manager allow you to search for kbv ?   And [Install] from the Manager ?
2. did v1.6.10 have the correct Uno bootloader ?  i.e. did Tools->Burn Bootloader work from the IDE ?

David.
1. No as I said I had to add .zip library in order to find the library in the library manager and then it was already installed ofcourse.
2.I had to burn bootloader in order to make graphics_kbv work. I did it from IDE yes so I guess it worked.

I'm now having some trouble figuring out how to display things on my own.
I'll try to figure it out reading your examples.

Spiros
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: one3rdnerd on Jul 30, 2016, 03:17 am
I love Ebay "sale information".    Image #1, #4 of the item photo show a Uno clone with DIP-28.    Image #2, #3 show a Uno clone with TQFP-32 AVR.
Your BangGood photo shows a different brand with TQFP-32.

Check that U5 is actually mounted.   (and soldered properly).   If you have a DMM,  check that you actually get 3.3V from the Arduino's 3.3V header socket.


As a general rule,   clones are assembled pretty well.    I received one with missing U5 once.    Otherwise all other Unos have worked ok.

I have received shields with shorted tracks,  bad soldering, ...
And most "dirt-cheap" modules probably use "QC failure" components.   i.e. they work but are not 100% in spec.

David.
Thanks for your response David.

To be sure I have taken some photos of the arduino and the shield and added to imgur for you to see.

http://imgur.com/a/Pp3h2

Does that help you better determine what I have? As for poor soldering it doesn't look too bad, I have had a look around and it looks fairly well manufactured though I have little basis for comparison, maybe you can tell me.

What is odd is that once i did randomly get the graphics test to work and loop around nicely but after turning off and coming back when I tried the same example sketch (the graphics_test kbv) it didn't work. I do get a warning about low memory as it takes up 88% and not sure if that happened first time around when it did work.

What in your opinion is the best arduino and 3.5"(ish) screen combination? This is eventually for an increasingly advanced terrarium project.

Thanks
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 30, 2016, 08:34 am
1.  Does your Uno upload and run other sketches ok?
2.  Have you measured the 3.3V terminal?
3.  Do you get a white screen?  Or anything readable?

Your clone looks well constructed.   If the example programs worked ok once,   your electrical connections should be ok.

I could change the power settings on the controller.   
Which Library version?   The Library Manager will tell you.   Or just read mcufriend_kbv.h file.
From #586 I presume it is v2.9.1-beta

I will post a test sketch for you later today.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: one3rdnerd on Jul 30, 2016, 09:59 am
1) I believe so, at least for non TFT screen related stuff.
2) I haven't, what would I use to do this? I was using USB power. I have a power adapter also but its at a friends.
3) When turning on it a kind of blue screen once turned on. When I load sketches like the graphicstest sometimes I get a flicker and that's it, one time I got coloured lines repeat for a while then back to original blue screen and the one time I managed to get the graphicstest to run in full.

Yes I am using 2.9.1-beta in IDE version 1.6.10

Thanks David :)

David
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 30, 2016, 10:23 am
USB power is fine.    Borrow a DMM (multimeter) to read the 3.3V pin.    But since your photo shows good soldering,   I bet that this is working just fine.

Only you can really see the soldering.   Mated shields give very good electrical connections but a broken trace or dry joint could give you intermittent results.

Since the LCD_ID_readreg sketch tests every pin,   you could run this sketch while flexing the board / shield.
If you get consistent results the TFT should work too.

The example sketches should all work on the Uno.    The memory warnings can be ignored.
Note that a Duemilanove or Leonardo do not have enough memory for the graphictest_kbv sketch but should be fine for all the others.

Your shield does NOT have a Touch panel.    So these sketches will not work.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ardumino24 on Jul 30, 2016, 12:03 pm
Hi, Please help me :(
I cant find any Library, that work with my Display correctly.
Display      3.5 inch with 480x320
Controller   ILI 9488
Board         Arduino Uno REV3

The Glue demo sketch work, but the TouchScreen_Calibr_kbv still not work, No touch and the text is mirrored:( (See pic).


i bought the Display here:
http://www.aliexpress.com/item/1pcs-3-97-inch-LCD-Display-Module-TFT-LCD-screen-for-Arduino-UNO-R3-Board-ili9488/32699955292.html?spm=2114.01010208.3.2.2S3e07&ws_ab_test=searchweb201556_0,searchweb201602_3_10057_10056_10055_10037_10049_10033_10059_10058_10032_10017_405_404_10060_10061_10062_412,searchweb201603_6&btsid=a3d3bf29-6b79-4257-832f-75fa98f331a7 (http://www.aliexpress.com/item/1pcs-3-97-inch-LCD-Display-Module-TFT-LCD-screen-for-Arduino-UNO-R3-Board-ili9488/32699955292.html?spm=2114.01010208.3.2.2S3e07&ws_ab_test=searchweb201556_0,searchweb201602_3_10057_10056_10055_10037_10049_10033_10059_10058_10032_10017_405_404_10060_10061_10062_412,searchweb201603_6&btsid=a3d3bf29-6b79-4257-832f-75fa98f331a7)




LCD_ID_Reader sketch :
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(0x0000) C0 C0 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 80 00 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 00 08 Get Powsr Mode
reg(0x000C) 00 06 Get Pixel Format
reg(0x0061) E1 E1 RDID1 HX8347-G
reg(0x0062) E2 E2 RDID2 HX8347-G
reg(0x0063) E3 E3 RDID3 HX8347-G
reg(0x0064) E4 E4 RDID1 HX8347-A
reg(0x0065) E5 E5 RDID2 HX8347-A
reg(0x0066) E6 E6 RDID3 HX8347-A
reg(0x0067) E7 E7 RDID Himax HX8347-A
reg(0x0070) 00 BF Panel Himax HX8347-A
reg(0x00A1) 00 00 00 00 00 RD_DDB SSD1963
reg(0x00B0) F0 F0 RGB Interface Signal Control
reg(0x00B4) F4 F4 Inversion Control
reg(0x00B6) F6 F6 F6 F6 F6 Display Control
reg(0x00B7) F7 F7 Entry Mode Set
reg(0x00BF) FF FF FF FF FF FF ILI9481, HX8357-B
reg(0x00C0) C0 C0 C0 C0 C0 C0 C0 C0 C0 Panel Control
reg(0x00C8) C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 GAMMA
reg(0x00CC) CC CC Panel Control
reg(0x00D0) D0 D0 D0 Power Control
reg(0x00D2) D2 D2 D2 D2 D2 NVM Read
reg(0x00D3) D3 D3 D3 D3 ILI9341, ILI9488
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 80 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00E0) E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 GAMMA-P
reg(0x00E1) E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 GAMMA-N
reg(0x00EF) EF EF EF EF EF EF ILI9327
reg(0x00F2) F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 Adjust Control 2
reg(0x00F6) F6 F6 F6 F6 Interface Control


I don´t know what is wrong.

Thank you!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 30, 2016, 12:31 pm
I think that you have an HX8357-D controller.   I do not specifically support this.   The nearest would be 0x9486 or 0x9488.

It is definitely NOT an Ilitek ILI9488.    Hey-ho,  you did not really believe that Chinese vendors might be truthful !!!

Edit setup() in the graphictest_kbv.ino sketch to force an ID of 0x9488.   e.g. where it says
Code: [Select]
tft.begin(0x9488);

Please let me know the result.   If you are prepared to do some tests,   I will add support.
If you find the nearest controller,   please either describe results or post a video.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ardumino24 on Jul 30, 2016, 01:46 pm
hehe I believed it :)

Ok thank you for support.
Code: [Select]
tft.begin(0x9488) worked in  graphictest_kbv.ino. (See pic).

The Touchscreen works with the UTouch_Calibr_kbv, but the text is also mirrored.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 30, 2016, 02:11 pm
Did you try 0x9486 ?

The colours will not be inverted.   i.e. you should get GREEN text on a BLACK background.

If you want to do some testing,   please say so.   I will PM you with instructions.

David.

Edit.   Oops,   just looked at your JPEG.   You are using an old version (2.8.0) of the Library.   Please delete your mcufriend_kbv library directory and download v2.9.1-beta from GitHub.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ardumino24 on Jul 30, 2016, 02:31 pm
Hallo David,
Yes lets do it:)

Ok with 0x9486, the Display Show Black background with Green Text.

Thank you

Edith: updated to v2.9.1 Beta
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Jul 30, 2016, 03:13 pm
I have sent you a PM.    Sorry,  it tells you how to install a special test branch.    (after your effort to install the default Master branch)

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 01, 2016, 07:43 pm
1) I believe so, at least for non TFT screen related stuff.
2) I haven't, what would I use to do this? I was using USB power. I have a power adapter also but its at a friends.
3) When turning on it a kind of blue screen once turned on. When I load sketches like the graphicstest sometimes I get a flicker and that's it, one time I got coloured lines repeat for a while then back to original blue screen and the one time I managed to get the graphicstest to run in full.

Yes I am using 2.9.1-beta in IDE version 1.6.10

Thanks David :)

David
I suspect that you have a bad connection somewhere if sketches worked in the past.   i.e. examine pcb with magnifying glass.

Here is the test sketch that I promised on Saturday:   My Shield works best with configuration #0.

Code: [Select]

#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

// Assign human-readable names to some common 16-bit color 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()
{
    Serial.begin(9600);
    uint16_t ID;
    ID = tft.readID(); //
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    if (ID == 0xD3D3) ID = 0x9481; // write-only shield
    tft.begin(ID);
    tft.setRotation(1); //LANDSCAPE
    tft.fillScreen(BLACK);
    tft.setTextSize(2);
    tft.setTextColor(YELLOW, BLACK);
    tft.setCursor(0, 0);
    tft.println("This program will step through");
    tft.println("different power settings for an ILI9481");
    tft.println("Please do not run this if not ILI9481");
    Serial.println("This program will step through");
    Serial.println("different power settings for an ILI9481");
    Serial.println("Please do not run this if not ILI9481");
    const char *colorname[] = { "BLUE", "GREEN", "RED", "GRAY" };
    uint16_t colormask[] = { 0x001F, 0x07E0, 0xF800, 0xFFFF };
    uint16_t dx, rgb, n, wid = tft.width(), ht = 40, y = 100;
    dx = wid / 32;
    for (uint8_t aspect = 0; aspect < 4; aspect++ ) {
        for (n = 0; n < 32; n++) {
            rgb = n * 8;
            rgb = tft.color565(rgb, rgb, rgb);
            tft.fillRect(n * dx, y, dx, ht, rgb & colormask[aspect]);
        }
        tft.setTextColor(colormask[aspect], BLACK);
        tft.setCursor(0, y + 12);
        tft.print(colorname[aspect]);
        y += ht;
    }
}

// every entry MUST be the same size
uint8_t ILI9481_regValues[] = {
    0xD0, 3, 0x07, 0x42, 0x18,  // Set Power [00 43 18] x1.00, x6, x3
    0xD1, 3, 0x00, 0x07, 0x10,  // Set VCOM  [00 00 00] x0.72, x1.02
    0xD2, 2, 0x01, 0x02,        // Set Power for Normal Mode [01 22]
    0xC5, 1, 0x03,      //Frame Rate [03]
};
uint8_t ILI9481_PVI35_regValues[] = {
    0xD0, 3, 0x07, 0x41, 0x1D,  // Set Power [00 43 18]
    0xD1, 3, 0x00, 0x2B, 0x1F,  // Set VCOM  [00 00 00] x0.900, x1.32
    0xD2, 2, 0x01, 0x11,        // Set Power for Normal Mode [01 22]
    0xC5, 1, 0x03,      //Frame Rate [03]
};
uint8_t ILI9481_CPT29_regValues[] = {
    0xD0, 3, 0x07, 0x42, 0x1C,  // Set Power [00 43 18]
    0xD1, 3, 0x00, 0x02, 0x0F,  // Set VCOM  [00 00 00] x0.695, x1.00
    0xD2, 2, 0x01, 0x11,        // Set Power for Normal Mode [01 22]
    0xC5, 1, 0x03,      //Frame Rate [03]
};
uint8_t ILI9481_AUO317_regValues[] = {
    0xD0, 3, 0x07, 0x40, 0x1D,  // Set Power [00 43 18]
    0xD1, 3, 0x00, 0x18, 0x13,  // Set VCOM  [00 00 00] x0.805, x1.08
    0xD2, 2, 0x01, 0x11,        // Set Power for Normal Mode [01 22]
    0xC5, 1, 0x03,      //Frame Rate [03]
};
uint8_t ILI9481_CMO35_regValues[] = {
    0xD0, 3, 0x07, 0x41, 0x1D,  // Set Power [00 43 18] 07,41,1D
    0xD1, 3, 0x00, 0x1C, 0x1F,  // Set VCOM  [00 00 00] x0.825, x1.32 1C,1F
    0xD2, 2, 0x01, 0x11,        // Set Power for Normal Mode [01 22]
    0xC5, 1, 0x03,      //Frame Rate [03]
};
uint8_t ILI9481_RGB_regValues[] = {
    0xD0, 3, 0x07, 0x41, 0x1D,  // SETPOWER [00 43 18]
    0xD1, 3, 0x00, 0x2B, 0x1F,  // SETVCOM  [00 00 00] x0.900, x1.32
    0xD2, 2, 0x01, 0x11,        // SETNORPOW for Normal Mode [01 22]
    0xC5, 1, 0x03,      //SETOSC Frame Rate [03]
};
uint8_t ILI9481_RESET_regValues[] = {
    0xD0, 3, 0x00, 0x43, 0x18,  // SETPOWER [00 43 18]
    0xD1, 3, 0x00, 0x00, 0x0,  // SETVCOM  [00 00 00] x0.900, x1.32
    0xD2, 2, 0x01, 0x22,        // SETNORPOW for Normal Mode [01 22]
    0xC5, 1, 0x03,      //SETOSC Frame Rate [03]
};

uint8_t *configs[] = {
    ILI9481_regValues,
    ILI9481_CPT29_regValues,
    ILI9481_PVI35_regValues,
    ILI9481_AUO317_regValues,
    ILI9481_CMO35_regValues,
    ILI9481_RGB_regValues,
    ILI9481_RESET_regValues,
};

#define TFTLCD_DELAY8 0xFF
void init_table(uint8_t *table, int16_t size)
{
    uint8_t *p = (uint8_t *) table, dat[16];
    while (size > 0) {
        uint8_t cmd = *(p++);
        uint8_t len = *(p++);
        if (cmd == TFTLCD_DELAY8) {
            delay(len);
            len = 0;
        } else {
            for (uint8_t i = 0; i < len; i++)
                dat[i] = *(p++);
            tft.pushCommand(cmd, dat, len);
        }
        size -= len + 2;
    }
}

void loop()
{
    static uint8_t n = 0;
    uint8_t *p;
    uint8_t unlock = 0;
    if (++n >= sizeof(configs) / sizeof(*configs)) n = 0;
    p = configs[n];
    tft.setCursor(0, 300);
    tft.println("Using configuration :" + String(n) );
    Serial.println("Using configuration :" + String(n) );
    tft.pushCommand(0xB0, &unlock, 1);    //allow changes
    tft.pushCommand(0x28, NULL, 0);    //display off
    delay(100);
    init_table(configs[n], sizeof(ILI9481_regValues));
    delay(100);
    tft.pushCommand(0x29, NULL, 0);    //display on
    delay(5000);
}


David.

Edit.   Run this sketch for a few minutes to determine the "best" configuration.      Then switch off.    The screen becomes noticeably hot.   The backlight takes about 100mA.    The controller probably takes about 30mA i.e. 100mW.    This does not seem excessive.    And I am surprised that I can feel any heat at all.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Breakah on Aug 02, 2016, 03:12 am
hello,
I bought a screen and connect to DUE, work fine with this library, but i need change the pinmaps, for now,I changed the pins analog to digital pins 22 23 24 25 26 and work fine, but how change de pins 2 3 4 5 6 7 8 9 to 27 forwards.

mcufriend_shield.h
Code: [Select]

#define RD_PORT PIOB            //PIOA
#define RD_PIN  26                //16
#define WR_PORT PIOA
#define WR_PIN  14               //24
#define CD_PORT PIOA
#define CD_PIN  15               //23
#define CS_PORT PIOD          //PIOA
#define CS_PIN  0                //22
#define RESET_PORT PIOD    //PIOA
#define RESET_PIN  1          //6
 // configure macros for data bus
#define BMASK         (1<<25)
#define CMASK         (0xBF << 21)
#define write_8(x)   {  PIOB->PIO_CODR = BMASK; PIOC->PIO_CODR = CMASK; \
                        PIOC->PIO_SODR = (((x) & (1<<0)) << 22); \
                        PIOC->PIO_SODR = (((x) & (1<<1)) << 20); \
                        PIOB->PIO_SODR = (((x) & (1<<2)) << 23); \
                        PIOC->PIO_SODR = (((x) & (1<<3)) << 25); \
                        PIOC->PIO_SODR = (((x) & (1<<4)) << 22); \
                        PIOC->PIO_SODR = (((x) & (1<<5)) << 20); \
                        PIOC->PIO_SODR = (((x) & (1<<6)) << 18); \
                        PIOC->PIO_SODR = (((x) & (1<<7)) << 16); \
}

#define read_8()      ( ((PIOC->PIO_PDSR & (1<<22)) >> 22)\
                      | ((PIOC->PIO_PDSR & (1<<21)) >> 20)\
                      | ((PIOB->PIO_PDSR & (1<<25)) >> 23)\
                      | ((PIOC->PIO_PDSR & (1<<28)) >> 25)\
                      | ((PIOC->PIO_PDSR & (1<<26)) >> 22)\
                      | ((PIOC->PIO_PDSR & (1<<25)) >> 20)\
                      | ((PIOC->PIO_PDSR & (1<<24)) >> 18)\
                      | ((PIOC->PIO_PDSR & (1<<23)) >> 16)\
                      )
#define setWriteDir() { PIOB->PIO_OER = BMASK; PIOC->PIO_OER = CMASK; }
#define setReadDir()  { \
                          PMC->PMC_PCER0 = (1 << ID_PIOB)|(1 << ID_PIOC);\
  PIOB->PIO_ODR = BMASK; PIOC->PIO_ODR = CMASK;\
}
#define write8(x)     { write_8(x); WR_ACTIVE; WR_STROBE; }


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 02, 2016, 04:35 am
A shield has got fixed wiring.    It just plugs in to your Due and I know that LCD_D1 is on digital#9 and LCD_CS is on Analog#3.

Do you intend to change all the pcb tracks on the shield?

If you tell me which pins you want to rewire,  I will PM you with the changes.
i.e. do you want LCD_D2 on digital#27?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: one3rdnerd on Aug 02, 2016, 10:41 am
Hi David,

Still not having much joy so I had an idea...

1) Can you recommend to me a) The best 3.5 inch non-touchscreen TFT I should get which is most compatible and supported by libraries and specifically your library and b) Same as A but a touchscreen version. I am in the UK so I suppose perhaps that factors into where I order it online.

2) If you want, since you are so helpful and contributing to the community I would happily post you this semi functional screen I have for free which you can keep, perhaps it will help you discover what is unique about it to help others in the future. You can private message me your details if you want me to do that. My email is david@pixelloop.org

Thanks
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 02, 2016, 11:22 am
Ebay is a bit of a lottery.

There are Red 3.5" Uno shields that contain ILI9481, ILI9486, ... as well as the new "mystery controllers": 0x1511, 0x6814.   These have a Resistive Touch Panel

The Blue 3.5" displays do not have a Touch Panel.

There are Red 3.5" Mega2560 shields that have a XPT2046 Touch controller.
The Blue 3.5" Mega2560 shields do not have a Touch Panel.

The Mega2560 shields are write-only.   The Red ones have unreliable microSD due to massive series resistors.

The Blue microSD probably work fine.

The biggest problem is that you can never trust the Ebay Vendors.    They post photos that do not match the items.   They post inaccurate information.   If I try to buy the exact same item from a punter's Ebay link,   I often receive a different item.    The same applies to BangGood or DealExtreme.

So I am not going to recommend anything.   You will just have to hope and pray like everyone else.

There are also bare 3.3V modules,  or 3.3V modules mounted on a pcb that require an Adapter Shield before you can use with an Arduino.    I suggest that you avoid these.

In an ideal world,   they could make both Uno and Mega2560 shields that work properly.   i.e. using LV245 buffers instead of HC245 buffers.   Access RD pin on both Uno and Mega2560.     It would cost the Chinese an extra $0.20 to use the correct buffers.    It would cost them nothing to provide honest information about which controllers are mounted.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Aug 03, 2016, 07:27 am
Okay, after 3 weeks my AliX 3.95" MCUFRIEND has been picked up....   :)

I HAD a slideshow sketch running on Bodmer's library (HX8357B) with my BangGood 3.2" 9481 screen so I just swapped screens and crossed my fingers.

It didn't work even when I reuploaded the sketch. So I tried a sketch for the Uno format 3.95" and (as expected) that didn't work either   :(

It is NOT an "MCUFRIEND on a Uno" so I don't know if to post here or start a new thread "MCUFRIEND on a Mega"?

Somewhere in this thread I think I read that the library CAN(?) be made to work on a Mega format? ? ? ?

Maybe I should have avoided buying the new format altogether!? But I couldn't resist  ;)  It was AUD12 so no big deal   :D

I might bite my tongue and contact the seller (Ha! Ha!)   (LOL)

Here is the link if anyone is interested?

http://www.aliexpress.com/item/Free-shipping-LCD-Display-Module-TFT-3-95-inch-TFT-LCD-screen-for-Arduino-MEGA-2560/32689910844.html

I got what I ordered - the Mega format but, unlike the BangGood screen it has a 6 bank(the power bank) and an 8 bank (0 to 7?) of pins instead of just the two pins for power....

Please indicate if I should start a new thread or continue here?

The link DOES claim it is an ILI9488? ? ? ? but we all know how reliable AliX is....

I'm in your hands....   :)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 03, 2016, 10:08 am
You have bought a Mega2560 shield with an 8-bit interface.

Q. How to distinguish Mega shield from a Uno shield:
A: the Mega shield has more pins.

Q. How to distinguish an 8-bit Mega shield from a regular 16-bit Mega shield:  
A: either the 8-bit shield has fewer resistor packs or the 8-bit shield has fewer buffer chips.

You do not need to be an electronics expert to count pins or "major components" on a pcb.

The $64000 question is:  Does the shield in your hand match the photos on the Aliexpress link?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Aug 03, 2016, 02:22 pm
Is that US$ or AU$?   :D

I confirm, what I have in my hot little hands is EXACTLY what is displayed in the link....   :)

I assume this means I continue in this thread?

The back of the shield, unusually has NO legends on the pins.  :(
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 03, 2016, 10:58 pm
The "link" has a photo of a Uno Shield and a photo of a Mega Shield under the Product Description.

The Uno Shield has got legends on the pins e.g. SD_SCK

Both pcbs have got legends next to the components.  e.g. U1 or RP2.

You certainly seem to choose Vendors with the most conflicting photos, text, ...

Have you really compared the number of Resistor Packs on your pcb with the Mega photos?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Aug 04, 2016, 02:12 am
Yes David,

I have looked at it, with my old eyes and a magnifying glass. There are 6 banks(?) (RP1 to RP6) of 4 labelled 103 and a single 103 (R1).

There is a missing capacitor C1. A regulator(?) U1 labelled AMS1117 3.3 DN628.  A missing 8 legged chip U5. A 16 legged chip U2 labelled XPT2046 1609. And, of course, the microSD reader.

I haven't cut the stays holding the display to the PCB but will if it is any help.

The seller responded with an initialisation sequence but no driver Lcd_write_data or Lcd_write_com methods, just an Address_set method.  The sequence doesn't match the style of UTFT, Adafruit, HX8357 or your libraries. The sequence is much like (if not exactly like) the ones I have seen on other AliX screens!?

I can post the coding or PM it to you if you wish.  :)

Thanks for you interest.  :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Shayeb on Aug 10, 2016, 03:04 pm
Can you show me some clear example, please?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 10, 2016, 04:21 pm
Some clear example of what?

The library comes with several examples.
It is best to run the graphictest_kbv.ino sketch and look for what sort of thing you want to draw.
e.g. circles, text, rectangles, colours, ...

Then look at the relevant testCircles(), testText(), ... functions.
Or just ask here.

Here is a simple sketch:
Code: [Select]

#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#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()
{
    uint16_t ID = tft.readID();
    tft.begin(ID);        //must use correct ID
    tft.setRotation(1);   //Landscape
    tft.fillScreen(RED);
    tft.setTextSize(2);
    tft.setTextColor(WHITE, MAGENTA);
    tft.setCursor(0, 100);
    tft.println("Print with background");
    tft.setTextColor(YELLOW);
    tft.setCursor(0, 200);
    tft.println("Transparent print");
}

void loop()
{
}


David.

Edit.  added the simple sketch
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 10, 2016, 08:48 pm
Why do you want to change anything?   A shield plugs into your Due with every male finding its appropriate female.

A Due has got plenty of spare pins.
A Due operates the microSD perfectly in software.   And almost as fast as regular hardware SPI on a Uno.

If you really need to create a non-standard interface,   you should put it in the mcufriend_special.h file.

Yes,   I can show you how to do that but first off,   you should think about why you want to hack a ready-made shield.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 10, 2016, 09:26 pm
Oops.  I misread you.   I see that you have a Uno and not a Due.

mcufriend_shield.h:
Code: [Select]

#define USE_SPECIAL

mcufriend_special.h:
Code: [Select]

#define USE_JACKHMCD
...
#elif defined(__AVR_ATmega328P__)  && defined(USE_JACKHMCD)
#define RD_PORT PORTC
#define RD_PIN  0
#define WR_PORT PORTC
#define WR_PIN  1
#define CD_PORT PORTC
#define CD_PIN  2
#define CS_PORT PORTC
#define CS_PIN  3
#define RESET_PORT PORTC
#define RESET_PIN  4

#define BMASK    ((1<<0)|(1<<3))       //D8, D11
#define DMASK    (0xFC)
#define write8(x)     { \
                        PORTD = (PORTD & ~DMASK) | (x & DMASK);\
                        PORTB = (PORTB & ~BMASK) | ((x & 1) | ((x & 2) << 2)); WR_STROBE; }
#define read_8()      ( ((PIND & DMASK)|(PINB & 1)|((PINB & 8)>>2) )
#define setWriteDir() { DDRD |=  DMASK; DDRB |=  BMASK; }
#define setReadDir()  { DDRD &= ~DMASK; DDRB &= ~BMASK; }
#define write8(x)     { write_8(x); WR_STROBE; }
#define write16(x)    { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
#define READ_8(dst)   { RD_STROBE; dst = read_8(); RD_IDLE; }
#define READ_16(dst)  { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }

#define PIN_LOW(p, b)        (p) &= ~(1<<(b))
#define PIN_HIGH(p, b)       (p) |= (1<<(b))
#define PIN_OUTPUT(p, b)     *(&p-1) |= (1<<(b))

...



Untested.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 10, 2016, 10:36 pm
Instead of using D8, D9 you are using D8, D11.   i.e. you are using PB3 instead of PB1.   PB0 is unchanged.

You can always test your hardware with the LCD_ID_readreg sketch.   
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: lefti696 on Aug 11, 2016, 10:52 am
Hello, first of all i want to sat that everything works in my case :) (thank you for this awesome libray david_pentice!! good job) but Im wondering how A5 pin works.

Im using tft lcd 0x9481 (it is broken but it is prototype for now) and arduino nano connected as you see by wires. It is because i want to use RTC on I2C that usesA4(SDA) and A5(SCL). Im not using Sdcard or touch. A5 pin is free but A4 is used for lcd reset. When i disconnect this wire lcd goes white. Only way to get it back to working is to connect it to +5V as you advised earlier in this thread.
But im wondering if A4 pin is ready to use for I2C communication or I have to reconfigure it somewhere ? When I connect lcd reset wire to D12, D11, D10 pin wich is unused lcd does not work. How different is A4 from D12 ? I think it must be software configured somewhere. In your code I found something like int RST=A4 or #define RESET_OUTPUT  PIN_OUTPUT(RESET_PORT, RESET_PIN) but i cannot find where RESET_PIN is defined.
Could you explain me how this mysterious A4 pin works ?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 11, 2016, 11:24 am
Snip off the LCD_RESET pin (A4) from the shield header.
Solder a 10k resistor from the top of the snipped shield header pin to the top of the 5V shield header pin.

The display should work just fine with "Software Reset" (0x01) command.   You do not need to make any changes to sketches.

Plug the shield into a Uno or Mega.
Connect your I2C devices to the SDA, SCL pins.

I do not recommend using a Nano.   What is the point of buying a shield if you do not use its male-female connectability?

Obviously you can just connect LCD_RESET pin to 5V via a 10k resistor without snipping a pin.    But the snip and solder method makes your shield good for any proper Arduino.

Do you have a Red or Blue shield?    The blue shields sometimes overheat.    I am not sure why.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: lefti696 on Aug 11, 2016, 12:02 pm
Thank you for reply ! I attached picture. I have red board, and this violet cable is for lcd reset. But after some time bottom of lcd gets hot. Should i use 3V3 or 5V for lcd ?

So you suggest using tft on breakout board for arduino nano ? This is my first tft so i searched ebay for tft for arduino uno. I thought by doing this I will be sure that it works with my nano. Also i decided to connect some more things to arduino and using it as a shield would use all the free pins. But using it with uno and snipping off lcd reset pin is also a good idea :)

But anyway, ok i tried with 10k resistor yesterday and it works. Ahh, software reset with 0x01. So lcd reset wire just needs pull up restor for working (to have precise logic state)? A4 pin is working with lcd and D12 is not because of internal pull up resistor or in/out software configuration?
I do not have to make changes for sketches even though i found this #define RESET_IDLE    PIN_HIGH(RESET_PORT, RESET_PIN) ? Why is it defined and used although software reset is used ?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 11, 2016, 12:58 pm
You should connect every pin from the shield to the corresponding pin on your Nano.   i.e. if the shield says 3V3 you connect it to the Nano's 3V3 pin.   Likewise the 5V shield pin to the Nano's shield pin.

Why?

Uno clones are so cheap.   A shield is always going to mate correctly.   You always get good electrical connections.

I use Software Reset for the modern MIPI controllers.   Old controllers like ILI9320 do not have Software Reset command.   They all get the Hardware Reset.   You do not need to change any library software.

You probably need to call Wire.begin() after tft.begin().    Try it for yourself.   Then swap the order and see if it upsets TWI.

Oh,  some new Uno clones come with SMD AVR and extra holes for header pins.   And access to A6, A7 and extra headers for I2C

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 11, 2016, 06:00 pm
Oops.   I did say Untested !
I just wrote it straight into the Forum editor.   Your edits sound correct.

I will build and test the code later this evening.

As you have gathered,    I am happy to cater for existing shields.   Even esoteric ones.
When it comes to individuals with "unusual" mapping,   I expect them to do their own editing.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 11, 2016, 09:44 pm
I am going to the pub.   I will test the special tomorrow.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 12, 2016, 10:16 am
@JackHMcD,

Please use this.   Obviously,  it is untested on my part.   But the macros compile and should work.

Code: [Select]

#elif defined(__AVR_ATmega328P__)  && defined(USE_JACKHMCD)
#define RD_PORT PORTC
#define RD_PIN  0
#define WR_PORT PORTC
#define WR_PIN  1
#define CD_PORT PORTC
#define CD_PIN  2
#define CS_PORT PORTC
#define CS_PIN  3
#define RESET_PORT PORTC
#define RESET_PIN  4

#define BMASK    ((1<<0)|(1<<3))       //D8, D11
#define DMASK    (0xFC)
#define write_8(x)     { \
                        PORTD = (PORTD & ~DMASK) | ((x) & DMASK);\
                        PORTB = (PORTB & ~BMASK) | ((x) & (1<<0)) | (((x) & (1<<1)) << 2);\
                       }
#define read_8()      ( ((PIND & DMASK)|(PINB & (1<<0))|((PINB & (1<<3)) >> 2)) )
#define setWriteDir() { DDRD |=  DMASK; DDRB |=  BMASK; }
#define setReadDir()  { DDRD &= ~DMASK; DDRB &= ~BMASK; }
#define write8(x)     { write_8(x); WR_STROBE; }
#define write16(x)    { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
#define READ_8(dst)   { RD_STROBE; dst = read_8(); RD_IDLE; }
#define READ_16(dst)  { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }

#define PIN_LOW(p, b)        (p) &= ~(1<<(b))
#define PIN_HIGH(p, b)       (p) |= (1<<(b))
#define PIN_OUTPUT(p, b)     *(&p-1) |= (1<<(b))

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 12, 2016, 11:12 am
Can anyone help?

Has anyone received a 0x1511 controller recently?
Please could you provide a link so that I can buy one for myself.

I attempted to buy from Spoum's Ebay vendor "accecity2006".    I received a HX8357 Display that had NO bubblewrap or protective packing at all.   It had a broken Touch screen.   
Ebay has refunded the purchase but I would be much happier if I could be certain that the 0x1511 type had arrived (even with a broken Touch Glass)

Incidentally,   the HX8357D controller worked 100%

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: linux_author on Aug 12, 2016, 01:02 pm
i'd like to thank Mr. Prentice for his efforts... i just acquired this little TFT (blue w/SD card slot):

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(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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 02 Inversion Control
reg(0x00B6) 00 0A 82 27 04 Display Control
reg(0x00B7) 00 06 Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
reg(0x00C0) 00 21 00 00 00 00 Panel Control
reg(0x00CC) 00 72 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 03 03 NVM Read
reg(0x00D3) 00 00 93 41 ILI9341, ILI9488
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00EF) 00 03 80 02 02 02 ILI9327
reg(0x00F2) 00 02 02 02 02 02 02 02 02 02 02 02 Adjust Control 2
reg(0x00F6) 00 01 00 00 Interface Control



and using his Utouch_Calibr_kbv with these pin settings:

Code: [Select]
#define YP A3   //A3 for ILI9320
#define YM 9    //9
#define XM A2
#define XP 8    //8 


i was able to get some rudimentary calibration settings... after that, i was able to modify the original tftpaint and get it working... this gets me on the path to building a couple useful programs for my Uno clone(s)

regards,

willie
on the hot and humid Gulf of Mexico
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 12, 2016, 01:20 pm
You have an ILI9341 controller.    And you have identified the Touch pins with a multimeter.


You will probably find that the TouchScreen_Calibr.ino is a better sketch.   Make sure that you adjust the NUMSAMPLES in the TouchScreen.h library.

And the Touch_shield_kbv.ino is easier to check the functionality.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: BloodDonor89 on Aug 13, 2016, 06:57 pm
Hello,
i try the showBMP_kbv_as7 but dont work! The display appear green color.

the root directory is bitmaps folder with the photo from your project (miniwoof, woof, test)

my display is 480x320 resolution 0x9488

I used Arduino Uno!

Can you help me?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 13, 2016, 10:02 pm
There is a showBMP_kbv_as7.ino in the examples on GitHub.    This prints messages to the Serial Terminal.

Where did you get the sketch from? 
What appears on your Serial Terminal?

Note that you need to have the correct directory path.  e.g.
Code: [Select]

char namebuf[32] = "/";


and make a suitable name test e.g.
Code: [Select]

        strlwr(nm);
        if (strstr(nm, ".bmp") != NULL && strstr(nm, "woof") != NULL) {


You also need a "good" SdFat.h library.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: BloodDonor89 on Aug 13, 2016, 10:37 pm
its ok now...

fix with that:  if (strstr(nm, ".bmp") != NULL && strstr(nm, "woof") != NULL) {

Now, i have problem with colors!

How to fix it?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 13, 2016, 10:44 pm
Surely,  you ran the graphictest_kbv.ino sketch from the examples.
And when it said RED you got CYAN.    When it should be BLACK,  you got WHITE.

Would you not notice?
Would you not say?   

Your colours are inverted.   You can add this to setup()
Code: [Select]

    tft.invertDisplay(true);


David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: BloodDonor89 on Aug 14, 2016, 01:09 am
its ok work all now thx bro!!!

with tha code, it search all image name to found woof in name!

Code: [Select]
if (strstr(nm, ".bmp") != NULL && strstr(nm, "woof") != NULL) {


with that dont search and appear all image.

Code: [Select]
if (strstr(nm, ".bmp") != NULL && strstr(nm, "") != NULL) {

Really thx my friend for the help!! :)

I will hope to help and other people.

Goodnigth from Greece! :)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 14, 2016, 01:49 am
I am worried about your inverted colours.    My ILI9488 shield is 3.95 inch and Red and gives correct colours.

It is easy to fix.   i.e. just issue a tft.invertDisplay()

David
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: lefti696 on Aug 14, 2016, 02:52 pm
@david_prentice I just checked. I2C rtc clock works fine with tft lcd using A5 pin. As you mentioned It is important to call wire.begin() before tft.begin() otherwise lcd wont work. And I ordered uno with shields :) thanks for advice and help.

You should connect every pin from the shield to the corresponding pin on your Nano.   i.e. if the shield says 3V3 you connect it to the Nano's 3V3 pin.   Likewise the 5V shield pin to the Nano's shield pin.

Why?

Uno clones are so cheap.   A shield is always going to mate correctly.   You always get good electrical connections.

I use Software Reset for the modern MIPI controllers.   Old controllers like ILI9320 do not have Software Reset command.   They all get the Hardware Reset.   You do not need to change any library software.

You probably need to call Wire.begin() after tft.begin().    Try it for yourself.   Then swap the order and see if it upsets TWI.

Oh,  some new Uno clones come with SMD AVR and extra holes for header pins.   And access to A6, A7 and extra headers for I2C

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: diger67 on Aug 14, 2016, 09:27 pm
Hi.
I do not know, maybe it's already done for me. In the derivation of the letters and Digits had to first write a rectangle on the font size, leading to the effect of flicker. I added the function of recording and now occurs immediately Menou erasing the old character.

Code: [Select]

void Adafruit_GFX::drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size)
{
 int8_t i, j;
  if((x >= _width)            || // Clip right
     (y >= _height)           || // Clip bottom
     ((x + 6 * size - 1) < 0) || // Clip left
     ((y + 8 * size - 1) < 0))   // Clip top
    return;

  //if(!_cp437 && (c >= 176)) c++; // Handle 'classic' charset behavior

  for (i=0; i<6; i++ )
  {
    uint8_t line;
    if (i == 5)
      line = 0x0;
    else
      line = pgm_read_byte(font+(c*5)+i);
    for (j = 0; j<8; j++)
    {
      if (line & 0x1)
      {
        if (size == 1) // default size
          drawPixel(x+i, y+j, color);
        else {  // big size
          fillRect(x+(i*size), y+(j*size), size, size, color);
        }
      } else if (bg != color) {
        if (size == 1) // default size
          drawPixel(x+i, y+j, bg);
        else {  // big size
          fillRect(x+i*size, y+j*size, size, size, bg);
        }
      }
 if (line & 0)   //add
 {
 if (size == 1)
 drawPixel(x+i, y+j, bg);
 else {  // big size
          fillRect(x+(i*size), y+(j*size), size, size, bg);
        }
 }   //end add
      line >>= 1;
    }
  }
}

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 14, 2016, 09:49 pm
I don't see your problem.

The default 7x5 system font will just be rendered.   Possibly in a larger size with blocks of pixels e.g. 1x1, 2x2, 3x3, 4x4, ...

If the foreground colour is the same as the background,    the letters are tranparent.
If you use setColor(foreground, background) with different values,   the background is drawn too.   i.e. the letters will 'overwrite'.  There is no flicker.

Unfortunately,  the new FreeFonts do not behave like this.   They are always transparent.   So you must rub out manually by drawing a background colour first.   This will flicker if you rub out a very big rectangle before printing its replacement.   If this is a problem,   rub out a small rectangle at a time.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ashkansed on Aug 15, 2016, 08:34 pm
I have bought the 3.95" TFT LCD for arduino Uno that I attached the shield below.
After installing "UTFT" , "Adafruit_TFTLCD " , "Adafruit_GFX" and " MCUfriend_kbv" library, and also updating them with the manage libraries option in arduino IDE ( my version is 1.6.9), I tried all of the mcufriend and adafruit_tftlcd examples on my arduino mega 2560 but none of the works! all I see is a white screen  :smiley-cry:

I have uploaded touchscreendemo from touch_screen library , it works somehow fine , but it seems sometimes freezing, ( different number of data per a second when I'm sliding my finger on it )   :)

I have attached my LCD_ID_Reading result ( the only Mcufriend example works ).

PS : my arduino mega gets really hot after about 2 minutes when the shield is on the board and the board supplies its power from the USB port. ( I have tried with an 8volt regulator to power arduino board but the problem hasn't solved yet. :smiley-confuse: )

PS ll : I can't program arduino mega when the shield is on my board ( after about ten times the programmer sends " Time out error " .
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: netdudeuk on Aug 17, 2016, 06:40 pm
Hi

I have one of these displays -

http://www.ebay.co.uk/itm/371313204164?_trksid=p2055119.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT (http://www.ebay.co.uk/itm/371313204164?_trksid=p2055119.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT)

It came with a crack along the screen but it is still basically working.

However, everything is not good with it.

I have the libraries linked to from this video installed -

https://www.youtube.com/watch?v=VnRVbxQESnY (https://www.youtube.com/watch?v=VnRVbxQESnY)

It is plugged into an Uno R3.

I see the text on the calibration routine but there's virtually no response to touch.

When I run the UTFT_Demo_480x320 sketch, yet again, it mostly works.  However, going by the video linked to above, the colours look wrong and there's some 'dithering' as opposed to pure colours.  For example, the filled squares look like this and the end screen looks like this.


Any ideas please ?

Thanks


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: netdudeuk on Aug 17, 2016, 06:46 pm
I'll just add that the Touch_shield_kbv sketch gives this output -

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: netdudeuk on Aug 17, 2016, 06:54 pm
And, assuming that this will help, my registers -

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 17, 2016, 08:44 pm
Your video link does not work.

Quote
It came with a crack along the screen but it is still basically working.
Did they make any effort to use bubblewrap or any protective packing?
I hope that they have refunded your money.

If the Touch Panel is cracked,  there is absolutely NO chance of Touch working.   

It is far more convenient to copy-paste the Serial Terminal output.  JPEGs are a pain to load and read.   And of course,   I can not copy-paste.

You have a regular ILI9488 controller.

I provide you with a standard test program: graphictest_kbv.ino

Please run graphictest_kbv.ino and post a link to the video.   Or stationary photos.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: netdudeuk on Aug 17, 2016, 11:17 pm
David


Thanks for your prompt and helpful reply.

I've corrected the video link in the previous post.

Understood regarding the copy and paste.  I did in fact try that but nothing was being pasted (or was it copied ?  :) ).  I'll give it another go if there's a next time.

The item was not packed well.  It was quite a while ago so I don't recall the specifics.  To be fair to the seller though, they immediately refunded the money.  I put the display out of the way until today, when I thought that I'd see if it worked at all.

I have ran the test as you suggested.  The video can be found here -

https://www.youtube.com/watch?v=YZYUux_P1nY (https://www.youtube.com/watch?v=YZYUux_P1nY)

It would be great to hear what you think.

Thanks


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 18, 2016, 12:48 am
Thanks for the video.  The new link is fine.

Your controller is expecting an 18-bit interface.
The library is configuring for 5-6-5 and sending 16-bit colours.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: netdudeuk on Aug 18, 2016, 05:23 am
Thanks for the reply but I've no idea what that means.  Is there a simple fix ?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: netdudeuk on Aug 18, 2016, 11:00 am
I followed up with a sketch that you provided on page 34 -

Code: [Select]
#include <Adafruit_GFX.h>
#include <gfxfont.h>



#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

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

const char *colornames[] = {
    "BLACK", "BLUE", "RED", "GREEN", "CYAN", "MAGENTA", "YELLOW", "GRAY"
};
uint16_t colors[] = {
    BLACK, BLUE, RED, GREEN, CYAN, MAGENTA, YELLOW, GRAY
};

void setup()
{
    Serial.begin(9600);
    uint16_t ID = tft.readID();
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    tft.begin(ID);
    uint8_t pixfmt = 0x66;
    tft.pushCommand(0x3A, &pixfmt, 1);   //use default 18-bit mode
    tft.fillScreen(0x0000);
    tft.setTextColor(0xFFFF, 0x0000);
    tft.setTextSize(3);
    tft.setCursor(0, 0);
    tft.println("RM64180");
    tft.print("ID = 0x");
    tft.println(ID, HEX);
    delay(1000);
}

void loop()
{
    static uint8_t n;

    if (++n >= 8) n = 0;
    tft.setCursor(0, 0);
    tft.fillScreen(colors[n]);
    tft.println(colornames[n]);
    delay(1000);
}



The colours are pretty decent and pure.

Am I going in the right direction ?

Thanks
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 18, 2016, 11:14 am
All the library examples should work out of the box.

The sketch that you have just run is telling the controller to use 6-6-6 colours even though the library sends 5-6-5 colours.    This was "special" for a RM68140 controller that seemed to have a strange hardware configuration.

I have never encountered an ILI9488 that has this "strange hardware configuration".
A "fix" is to add this to every sketch:
Code: [Select]

    tft.begin(ID);
    if (ID == 0x9488) {
        uint8_t pixfmt = 0x66;
        tft.pushCommand(0x3A, &pixfmt, 1);   //use default 18-bit mode
    }


I have no intention of changing the library unless other readers have the same "issue"
Add that clause to the UTFTGLUE class and the fix will work for any UTFTGLUE programs.

Please let me know if everything works in the graphictest_kbv sketch.   i.e. all colours, hardware and software scrolls, ...

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: netdudeuk on Aug 18, 2016, 12:33 pm
I'd say that it all looks ok now.

The colours look pure, there is full and part screen scrolling and I can see Tux, which I didn't even know about before.

Thanks
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: netdudeuk on Aug 18, 2016, 06:17 pm
David

Ignoring the cracked screen / touch issue, I'm now in a pretty good place using the display with the Uno.

Thanks for that.

What I'd really like to be able to do now though is use the display with either a standalone ATMEGA 328P (running as an Arduino, of course) or even a ESP8266  ESP-12F.  I guess that there may be library challenges with the latter though ?

In order to do at least the 328P, I'll need to know which pins need to be connected from the LCD to the microcontroller.  I've not been able to find this information.  Please do you know where I could find it ?

Thanks again.


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 18, 2016, 07:37 pm
The pcb has got all the pins marked.   You need 0V, 3.3V, 5V plus all the pins marked LCD_xx.

Seriously.   A shield is designed to mate with an Arduino.    Why introduce suspect wiring?

Size is no problem.    A Uno is the same size as a 2.8" screen.    And smaller than a 3.5".   The Uno clones are very cheap.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: netdudeuk on Aug 18, 2016, 08:38 pm
The pcb has got all the pins marked.   You need 0V, 3.3V, 5V plus all the pins marked LCD_xx.

Seriously.   A shield is designed to mate with an Arduino.    Why introduce suspect wiring?

Size is no problem.    A Uno is the same size as a 2.8" screen.    And smaller than a 3.5".   The Uno clones are very cheap.

David.
Thanks.

I can make it smaller / thinner and if I'm adding additional custom hardware, I may as well keep it all on the one additional board.

Here are a couple of my other (own design) projects.  There's a Z80 system and a 6502 system.  The first runs the same BBC BASIC as supplied with many 80's computers.  I just linked the various source modules with my own custom drivers.  The 6502 system runs the BBC BASIC ROM image straight out of the BBC Model B.  It has a VGA colour display and a PS2 keyboard interface.  They both have SD cards too.  As you can imagine, there's much more complex wiring on the back of those boards so I'll be fine with this project.

I also like LED matrix displays.  Here's a pair being driven by a Parallax Propeller.  I've had to write the code is in assembly as SPIN is not fast enough.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 18, 2016, 09:37 pm
I am impressed by your 6502 project.   I have always been very fond of 6502.
Of course the Uno / Nano / Mega2560 have got far more processing power.

I see little point in a TFT with parallel interface and "anything else" with a Uno.
The microSD uses the SPI pins.   You could use A5 as a second chip-select.   And A4 (with a little hardware mod)

Alternatively,   you can have many I2C devices if you do the A4 mod.

If you use an SPI Display,   you have plenty of spare GPIO, I2C, SPI, ...

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Muurman on Aug 22, 2016, 09:51 pm
I have a 2.4 screen id 0x9328 this works if i use as id 0x9325
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 22, 2016, 10:54 pm
I think you will find that 0x9328 is supported by the Beta on GitHub.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Aug 23, 2016, 01:47 am
Hi David,

I am still playing around with my new Mega format 9488 shield. With the two uncommented lines the display works perfectly (on a Mega but not on a Due).

For the moment I'm trying to get it working on my Mega.

I have been trying to get the microSD card and the touchscreen working but have been unsuccessful   :(


I realise you don't have this shield so any suggestions will be based on theory.

Can I expect this shield to work with the microSD? I have tried

Code: [Select]
#define SD_SPI_CONFIGURATION 2
...
#define SD_SPI_CONFIGURATION 0

with the pin numbers 51, 50 & 52.

In desperation I tried 11, 12 & 13 too but, as expected THAT didn't work   :(

I've also tried tracing the lines on the pcb but can't see what happens when they disappear under the headers   :(

Thank you for getting it (the display) to work on the Mega....   :)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 23, 2016, 02:00 am
Your Mega shield uses Resistor Packs for level conversion.

The values are too high for reliable operation of the microSD.

The Touchscreen should work ok.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Aug 24, 2016, 09:59 am
Thanks David....   I might give up on the microSD reader and try the touchscreen again. Just confirmed another display works, to a fashion, on one of my Dues....

Will try the same working sketch on the new screen and my Mega after babysitting.  :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: makoshatu on Aug 24, 2016, 12:42 pm
Hi David,

Finally, I've got an answer from Raydium Semiconductor Corporation. They sent me the datasheet of the RM68140 TFT controller. Please, let me know if you are still interested and I can send it to You.

Attila.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Aug 24, 2016, 02:29 pm
Yes, please.  I will send you a PM.

I have asked Himax for datasheets.   Response within 12 hours.   Datasheet supplied.   Very helpful.
I have asked Sitronix for datasheets.   Response within 12 hours.   Datasheet supplied.   Very helpful.

I had assumed that Raydium were not going to reply to you !!

I would like to buy a "0x1511" display.    If anyone has bought one recently,  please could they supply a link.

My last attempt to buy a "0x1511" resulted in a HX8357-D display with cracked Touch Panel.
Ebay vendors are a bit of a lottery.   There is a good chance of getting the same display if someone has received this type in the last week or two.    I am happy to risk it.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumaliw on Sep 04, 2016, 01:38 pm
Hi david_prentice,
I have ordered and got tft 3.6 touch pad through ebay. the link is,

http://www.ebay.com/itm/LCD-Display-Plug-and-Play-3-6-inch-TFT-Touch-Screen-Module-Arduino-UNO-R3-Board-/281672772523?hash=item4195016bab:g:mSEAAOSwBahVOvzR

It's Resolution : 480x320, Controller : ili9488

As you said i instilled MCUFRIEND_kbv Library. Im using  arduino uno board. But my touch pad is not working. just showing white screen. please can you help me to get it work. please any body can you help me. It will be a big help to me. please any one help me.  :(  :(  :(  :(  :(
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 04, 2016, 01:52 pm
I posted a sketch in another thread (http://forum.arduino.cc/index.php?topic=418569.msg2905110#msg2905110)

This should tell you what the pins are if you do not have a DMM.

Please let me know how you get on.   And I will add it to the examples.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ddwasil on Sep 05, 2016, 02:39 am
HI David you used SD card from ILI 9488  for show a  image
thank you
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumaliw on Sep 05, 2016, 10:50 am
Dear david,

I have got tft 3.5 touch pad. It's Resolution : 480x320, Controller : ili9488. graphictest is working. but touch screen caliber is not working. i have attached the working graphictest_kbv code and image. please help me to get touch screen please.

Thank you..!!

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 05, 2016, 11:10 am
What makes you think it is an ILI9488 ?

What does the Serial Terminal say?
What does the Adafruits_Test results screen say?

Please run the LCD_ID_readreg.ino sketch and paste the output from the Serial Terminal.

Have you run the sketch that I linked to in message #663 ?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumaliw on Sep 07, 2016, 10:33 am
Thank you very much for the quick reply David. The seller page says it uses ILI9488. Is there any method to identify it?? I have no good knowledge about these things.

when i run the example code, touch screen_calibr_kbv serial monitor says "touch screen calibration" and i have attached the image of output.

ok i have run the LCD_ID_readreg.ino and attach the out put of serial monitor below as text file and touch screen out put is white screen only.

yeah i have copy and past the code you had shown in #11 and have run it. i attached the serial monitor reading output here and when run it its touch pad out put was white screen.

Thank you. please help me !!  :(  :( 
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 07, 2016, 11:02 am
You have a Renesas R61581 controller.   This is similar to a ILI9481.   The R61581 is not currently supported.  You should be able to run the library if you force
Code: [Select]
tft.begin(0x9481);

The R61581 / ILI9481 is very different to the ILI9488.    Registers are different,  behaviour is different.

Most of my examples will show the ID on the Serial Terminal.    The library will probably just report 0x0000 for the unsupported R61581.   0x0000 will default to ILI9341.   Your JPEG shows this (unsuitable)  behaviour on your screen.

If you report back with the result of forcing tft.begin(0x9481) in the graphictest_kbv.ino sketch,  I will add the necessary support.

Please note that it is very easy to Copy-paste from the Serial Terminal.    Just add it to a CODE "window" in your message.

It looks as if your Touch Panel is broken.   You have only got a XM, XP pair.   I would expect YP, YM to be on A2, D6.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumaliw on Sep 07, 2016, 11:26 am
where i have to type tft.begin(0x9481); ??

yeah my touch pad is broken like follow image. Do i want buy another touch pad?? please can you tell me and send me a link to buy low cost uno or due compatible best touch pad. My project is pressure sensitive signature detection system. for that I have get pressure output from the touch pad. Please tell me what i have to do now. Do i want to buy another touch pad.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 07, 2016, 11:40 am
First off.   Ask for your money back from Ebay / Aliexpress.   Report the Vendor for bad packaging.

Secondly,  post a link to your actual sale item.   Then we will know that this Vendor packs the item badly.

The 2.4" 240x320 shields are pretty robust and are perfectly good for Touch button applications.
I doubt that you will ever be able to distinguish handwriting signatures.

Be realistic.   When a Courier asks you to "sign" their hand-held computer,   it never looks good.   Many people just draw a big X.    If you have a dispute with a Courier company,   you might be able to claim that a "signature" was counterfeit.    I doubt that anything would stand up in court.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumaliw on Sep 07, 2016, 12:02 pm
ok then I will complain and ask for my money.  :(  and I will buy 2.4 touch pad from here. Please help if it is also not work.

Can I get pressure output from touch pad??
Is signature recognition system using pressure impossible to do.??
Im going to make this for students in the university to take their attendance. so is it realistic ??
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 07, 2016, 01:03 pm
I am more interested in you testing the R61581.    Then I can support it.
It would take 5 minutes out of your life to do the test.   It would take me 30 seconds to add the necessary support to the library.    The "display" would work even though you have a broken Touch glass.

If you are expecting to validate your students,   this seems crazy.    50 students all writing a big "X" will not be easy to tell apart.

50 students with a 4-digit PIN number to enter via Touch "buttons" is practical.    But most students will sign in their sleeping friends.

Fingerprint recognition might work.    But if a student is too lazy to attend,  she will probably fail her exams anyway.    If you are a regular teacher,  you will notice whether the classroom is full or empty.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumaliw on Sep 07, 2016, 01:39 pm
What is the test i have to do to test R61581 and to get display. Can i load image to this touch pad.


Our project is automated attendance system for class room. one group is doing it using finer print. and my group doing it using RFID card and signature detection. I finished my part using RFID. My friend doing signature detection using image processing. Now my supervisor told me to detect signature using pressure profile.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 07, 2016, 02:27 pm
Load the graphictest_kbv.ino sketch from the library examples.

Search for setup().   Find the tft.begin().   Edit to say tft.begin(0x9481)

Compile and Upload.    Watch the results.   Are the colours correct?  Do the scroll tests work?

Yes,  you can ask students to sign their names.   You can use my library to read the signature.    It will be very hard to do "image recognition".   
You normally look at a touch as being on or off.   I would not trust the "pressure" value at all.    Yes,  some students might press harder than others.    All you will get is a broken glass if you press too hard.

But if that is what your teacher wants you to do,   the Paint example could change colour with pressure.   Or change the size of the dot.    You still have to analyse a student's X.

David.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumaliw on Sep 07, 2016, 06:38 pm

ohh seriously David you are genius. You are awesome. graphictest worked correctly. I got correct output. But still cant do paint example like those things.  Tomorrow I will buy 2.4 touch pad. From this I will hope to get pressure output then.  ok i will try to recognize by changing the size of the dot. what is the library i want to use to read the signature??

And i hope to use this touch pad with RFID as LCD display.

Thank you soo much. Thank you again.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 07, 2016, 10:51 pm
I will add R61581 to the library.    So all the scrolling worked ok.   And with correct colours.

The Touch should work with Touchscreen.h library from Adafruit.   Change NUMSAMPLES to 3.

Note that Touch screens are not very accurate.    It is always wise to process the results.  e.g. check that a press is stable for a sensible time.

I am typing on a small Tablet with a dibber.   I do not always hit the correct button.   Sometimes the Samsung returns the wrong key.    Bare fingers would be completely hopeless.   The "keypad" on an IPAD has human sized keys.    Small IPHONEs require ladies fingers.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: spoums on Sep 08, 2016, 11:16 am
Question:
Does the LCD shield use all pins?
I want to use arduino's SPI so I can get data from an A2D so I can display the results on to the LCD screen.

Are SPI's pins being used or can I use it without affecting the LCD?

I'm talking about Arduino UNO where pins 10, 11, 12 and 13 are connected to the SPI.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 08, 2016, 12:09 pm
Just use A5 for the CS pin.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: spoums on Sep 08, 2016, 01:45 pm
Thank you for your quick answer David.

So pins 11,12 and 13 are not being used since they are shortcircuited with the ICSP pins.
Is that correct?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 08, 2016, 02:10 pm
You use 11, 12, 13 for SPI i.e. MOSI, MISO, SCK
And 10 for SD_CS   (microSD card)
And A5 for A2D_CS

Quite honestly,   it would be simpler to just A5 for regular 10-bit ADC
Do you really need an external ADC chip?

If you have a TQFP32 "Uno",   you also have A6, A7 for two more regular ADC channels.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: spoums on Sep 08, 2016, 03:30 pm
I use a chip that has an ADC and I want its output using SPI.
I don't use an external ADC.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: andy_k on Sep 10, 2016, 07:41 am
Hi,
I got a 3.5 tft touch module where the vendor says the Controller is one of these: ili9481, ili9468, ili9488, hx8357, r61581

this is the output of LCD_ID_readreg

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(0x0000) C0 C0 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 80 00 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 00 08 Get Powsr Mode
reg(0x000C) 00 06 Get Pixel Format
reg(0x0061) E1 E1 RDID1 HX8347-G
reg(0x0062) E2 E2 RDID2 HX8347-G
reg(0x0063) E3 E3 RDID3 HX8347-G
reg(0x0064) E4 E4 RDID1 HX8347-A
reg(0x0065) E5 E5 RDID2 HX8347-A
reg(0x0066) E6 E6 RDID3 HX8347-A
reg(0x0067) E7 E7 RDID Himax HX8347-A
reg(0x0070) 00 4A Panel Himax HX8347-A
reg(0x00A1) 00 00 00 00 00 RD_DDB SSD1963
reg(0x00B0) F0 F0 RGB Interface Signal Control
reg(0x00B4) F4 F4 Inversion Control
reg(0x00B6) F6 F6 F6 F6 F6 Display Control
reg(0x00B7) F7 F7 Entry Mode Set
reg(0x00BF) FF FF FF FF FF FF ILI9481, HX8357-B
reg(0x00C0) C0 C0 C0 C0 C0 C0 C0 C0 C0 Panel Control
reg(0x00C8) C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 GAMMA
reg(0x00CC) CC CC Panel Control
reg(0x00D0) D0 D0 D0 Power Control
reg(0x00D2) D2 D2 D2 D2 D2 NVM Read
reg(0x00D3) D3 D3 D3 D3 ILI9341, ILI9488
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 80 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00E0) E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 GAMMA-P
reg(0x00E1) E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 E1 GAMMA-N
reg(0x00EF) EF EF EF EF EF EF ILI9327
reg(0x00F2) F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 F2 Adjust Control 2
reg(0x00F6) F6 F6 F6 F6 Interface Control


graphictest_kbv works fine with tft.begin(0x9486) but I can't get the touch to work
please help
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 10, 2016, 07:58 am
You have a HX8357-D controller.   The Beta on GitHub should detect and support this device.

If you are using an older version of the library,   force tft.begin(0x9486)

Re Touch pins.   Run the sketch that I linked to in #663.

I would appreciate some feedback about the diagnostic sketch.

David.

Edit. the HX8357-D is "similar" to the ILI9486. the HX8357-B is "similar" to the ILI9481.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: andy_k on Sep 10, 2016, 03:29 pm
Quote
Making all control and bus pins INPUT_PULLUP
Typical 30k Analog pullup with corresponding pin
would read low when digital is written LOW
e.g. reads ~25 for 300R X direction
e.g. reads ~30 for 500R Y direction

Testing : (A1, D7) = 30
Testing : (A2, D6) = 35
Diagnosing as:-
XM,XP:  (A1, D7) = 30
YP,YM:  (A2, D6) = 35
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: andy_k on Sep 10, 2016, 03:41 pm
which Beta do you mean? this  (https://github.com/adafruit/Adafruit_HX8357_Library)doesn't work
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 10, 2016, 03:49 pm
Quote
graphictest_kbv works fine with tft.begin(0x9486) but I can't get the touch to work
The HX8357-D will not work very well as a "0x9486"

You have identified your Touch pins.   Use these pins in the Touchscreen constructor with a Touch example e.g. Touch_shield_kbv.ino

Does everything work ok?
Do you need to "improve" the calibration?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 10, 2016, 04:05 pm
which Beta do you mean? this  (https://github.com/adafruit/Adafruit_HX8357_Library)doesn't work
I mean the Beta for MCUFRIEND_kbv (https://github.com/prenticedavid/MCUFRIEND_kbv) library on GitHub.
You have found an Adafruit library on GitHub.

I said earlier,   old versions of MCUFRIEND_kbv library should work with begin(0x9481).  This is wrong.   0x9486 is a "closer" match.

I was confusing the HX8357-D (that you have) with the HX8357-B (which is like an ILI9481)
I will edit my previous messages.

Yes,   Himax have the strangest way of numbering controllers.   The suffix specifies completely different behaviour.    Normally a model number specifies a controller and the suffix indicates a revision (or minor variant).

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumaliw on Sep 10, 2016, 06:39 pm
hi david_prentice,

I got 2.4 touch screen as you said. All your library examples clearly loaded without any errors. Graphictest worked well. Paint worked but when touched it touch as mirror.  when i run TouchScreen_Calibr example it didnt touch. When i run UTouch_Calibr example program loaded and say touch screen to continue. then after i touch the screen said press and hold. after i press and hold it says unable to read the position of the press. Please help me. Im using Touchscreen.h library from Adafruit as you said.   and i cant find where is NUMSAMPLES to change 3.

Thank you !!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 10, 2016, 06:51 pm
NUMSAMPLES is in Touchscreen.cpp (I think)

Run the sketch that I linked to in #663  to determine the pins used by the Touch screen.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumaliw on Sep 10, 2016, 06:58 pm
when i run the sketch serial monitor out put is ;

Making all control and bus pins INPUT_PULLUP
Typical 30k Analog pullup with corresponding pin
would read low when digital is written LOW
e.g. reads ~25 for 300R X direction
e.g. reads ~30 for 500R Y direction

Testing : (A1, D7) = 24
Testing : (A2, D6) = 25
Diagnosing as:-
XM,XP:  (A1, D7) = 24
YP,YM:  (A2, D6) = 25


Ohh ok i found NUMSAMPLES :o
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumaliw on Sep 10, 2016, 07:10 pm
When i changed

#define XP D7

Program not compile. error message coming "D7 was not declared in this scope"
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 10, 2016, 07:14 pm
Use 7 for D7 i.e. Digital#7.   But you can use A3 for Analog#3.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumaliw on Sep 10, 2016, 07:18 pm
I corrected is as this,

#define XP 7

Now it is compiling. But same thing happening it didn't touch. then I changed NUMSAMPLE to 3. Now it is not uploaded. error message says Error compiling for board Arduino/Genuino Uno  
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 10, 2016, 07:24 pm
Copy-paste the line that you edited for NUMSAMPLES

Or paste the error message from the Compiler.   Note that there are a lot of messages.   Only paste the specific Error message.   It is probably in orange text.
You might need to select verbose compiler in File->Preferences

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumaliw on Sep 10, 2016, 07:40 pm
Thank you load sir,

Now it is working. I did touchscreen calibration and all works because of you. Thank you very much.  There is another one problem to me. When I run touchscreendemoshield example im always getting above 700 values to X axis and Y axis. It never get 0,0 coordinates.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: andy_k on Sep 12, 2016, 06:41 am
I tried the Beta but I get the same results than before but nevermind.
tft.begin(0x9486) works and the touch pins thanks to your sketch also work!
Great work - thank you :)

The HX8357-D will not work very well as a "0x9486"

You have identified your Touch pins.   Use these pins in the Touchscreen constructor with a Touch example e.g. Touch_shield_kbv.ino

Does everything work ok?
Do you need to "improve" the calibration?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 12, 2016, 08:30 am
Same results as "what".

If something is not working correctly,   I would like to know.   Then I can fix it.

The Beta should recognise the HX8357-D controller.   The diagnose_Touchpins sketch should identify which way your Touch Panel is connected.    Or even if you have a broken glass.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: andy_k on Sep 12, 2016, 01:11 pm
Beta gets me identifier D3D3
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Melandr on Sep 12, 2016, 01:47 pm
Good afternoon. I wanted to ask , with your library got to start display of 2.8 inches mcufriend. A UTFT decided to use the library , but it does not work . Completely reworked the function of transmitting commands and data . But the display is still silent . Most likely , it is necessary to alter the designer . Do you use the library designer from Adafruit,really I do not know how to alter it . Can someone tell me .
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 12, 2016, 01:52 pm
I possess a HX8357-D controller.   My LCD_ID_readreg output matches your output.

The Beta library recognises the ID (by reading reg(0x04) ) and reports 0x8357
Older library versions will report the ID as 0xD3D3.   begin(0x8357) will probably give you a white (or black) screen

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 12, 2016, 01:56 pm
Good afternoon. I wanted to ask , with your library got to start display of 2.8 inches mcufriend. A UTFT decided to use the library , but it does not work . Completely reworked the function of transmitting commands and data . But the display is still silent . Most likely , it is necessary to alter the designer . Do you use the library designer from Adafruit,really I do not know how to alter it . Can someone tell me .
This Topic is about the MCUFRIEND_kbv library and UNO-style shields.

Please post a link to your actual display.
And / or paste the output from LCD_ID_readreg sketch

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Melandr on Sep 12, 2016, 02:56 pm
With MCUFRIEND_kbv library is operating normally . Just really wanted to adapt UTFT library under your display . I'm in the last year you talked about the display connection on UNO board. All turned out to do . Just recently found UTFT library for LCD. and I decided to try . Created in the forum topic, but has not received aid .That's what gives LCD_ID_readreg sketch

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) 93 31   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 00 00 00 00   Status Register
reg(0x000A) 00 00   Get Powsr Mode
reg(0x000C) 00 00   Get Pixel Format
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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 0A 00 0A 00 0A 00 0A 00 0A 00 0A 00   GAMMA
reg(0x00CC) 00 04   Panel Control
reg(0x00D0) 00 33 00   Power Control
reg(0x00D2) 00 FF 00 FF 00   NVM Read
reg(0x00D3) 00 3F 00 3F   ILI9341, ILI9488
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA-N
reg(0x00EF) 12 21 12 21 12 21   ILI9327
reg(0x00F2) 00 00 00 00 00 00 00 00 00 00 00 00   Adjust Control 2
reg(0x00F6) 00 00 00 00   Interface Control
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 12, 2016, 03:43 pm
You have an ILI9331 controller.   It is very similar to an ILI9325 controller which is supported by many other libraries.   I do not think that the official UTFT library supports an ILI9325 with this specific 8-bit databus.

You can always use the UTFTGLUE class if you want to run an old UTFT program on your display.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: andy_k on Sep 12, 2016, 06:52 pm
david are there any changes to the drawBitmap function? I loaded a pic in Progmem but cannot call it?!?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 12, 2016, 09:11 pm
What drawBitmap() function?

UTFT has two drawBitmap() methods
Code: [Select]

 void drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int scale=1);
 void drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int deg, int rox, int roy);


UTFTGLUE has only got one drawBitmap() method:
Code: [Select]

 void drawBitmap(int x, int y, int sx, int sy, uint16_t *data, int scale=1);


It would probably be wiser to declare it as:
Code: [Select]

 void drawBitmap(int x, int y, int sx, int sy, const uint16_t *data, int scale=1);

because it is using PROGMEM.

On my v1.6.9 IDE,  it works quite happily with or without the const.
I have never bothered to implement drawing a rotated bitmap.  

What problem do you have?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ddwasil on Sep 12, 2016, 11:00 pm
Hi David :
       I have a problem I can`t read pictures from sd card .I can`t compile  .becouse show me  "bmpDraw was not declared in this scope"


I put the next libreries


Code: [Select]
#include <Adafruit_GFX.h>    // Core graphics library
#include <MCUFRIEND_kbv.h>
#include <TouchScreen.h>
#include <SPI.h>
#include <SD.h>
MCUFRIEND_kbv tft;


#define YP A1 
#define XM A2
#define YM 7   
#define XP 6   
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);


#define MINPRESSURE 10      //sensibilidad al hacer clic en el toque
#define MAXPRESSURE 1000
#define LCDROTATION 0



const int chipSlect=10;


void setup(void)
{
                        Serial.begin(9600);
                        tft.reset();
                        tft.begin(0x9488);
                        tft.fillScreen(BLACK);
                        tft.setRotation(1);

                           
                      Serial.begin (9600);
                     while (!Serial) {  }
                               
                  Serial.println("leyendo sd");
           
                      pinMode (chipSlect,OUTPUT);//configuro salida de seleccion d esclavo
   
     if (!SD.begin(chipSlect))//si no inicio la SD  muestro error
        {
           Serial.println("fallo lectura de  sd");
           delay(2000);
           return;
        }
        Serial.println(" SD iniciada ");
        delay(2000);
       
                       
}

void loop()
 {
           
               TSPoint p = ts.getPoint();
               pinMode(XP, OUTPUT);
               pinMode(XM, OUTPUT);
               pinMode(YP, OUTPUT);
               pinMode(YM, OUTPUT);
                          tft.setRotation(0);
 
 bmpDraw ("woof.bmp", 0, 0);        //THE PROBLEM
                           delay(1000);
 
                   tft.setRotation(3);
 bmpDraw ("test.bmp",0,0);
               delay(1000);
                 
 }


 
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 12, 2016, 11:15 pm
There are examples of bmpDraw() functions in the Beta.
And most Adafruit libraries have code.

It is always wise to start with an example.   Then modify it to suit your requirements.
This will mean you are never more than one step away from a working project.

You will probably find that the bmpDraw() function is in a separate tab.

Incidentally,  if you press the ctrl-T key,   your sketch will get indented nicely.   It makes everything easier to read.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: andy_k on Sep 13, 2016, 08:24 am
ok thanks I've managed to compile it but I always get the exception that the sketch is too big. I'm trying to load a converted 50x50 icon. Do I have to put it on the SD slot?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 13, 2016, 08:43 am
A full colour 50x50 icon will need 50x50x2 = 5000 bytes of flash.

Life would be much simpler if you quoted some real numbers.   e.g. turn on verbose compilation in Preferences.   Copy-paste only the Error message.    Please do not post the complete output.

Look at the graphictest_kbv example.   Tux the penguin is a 40x40 icon.
Write a simple sketch that clears the screen and displays a single Tux.

Then add your icon and display it too.

David.

Edit. corrected Tux's vital statistics.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: andy_k on Sep 13, 2016, 10:40 am
In graphictest_kbv you are using pushcolor not drawBitmap
I don't understand the pushcolor function
you say the penguin has 32x32
the penguin shows fine on my 480x320 screen with this
Code: [Select]
tft.setAddrWindow(20, 20, 59, 59);
tft.pushColors(penguin, 1600, 1)


So x(y)-start is 20 and x(y)-end is 59. That's 39, why not 32? if I try with 32 the image is not good. what is the 1600 in pushcolors for?
how do I have to adjust these values for my 50x50 icon?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 13, 2016, 10:57 am
Sorry,  I was typing from a Tablet.   I could not remember what size the penguin was.   It looks like it must be 40x40.

I have followed the Adafruit conventions:

The setAddrWindow(x1, y1, x2, y2) takes the coordinate limits.   e.g. from x1=20 to x2=59 which is 40 pixels inclusive.

Most other methods use (x, y, w, h) which is more intuitive.   

Obviously your 50x50 icon would need:
Code: [Select]

    tft.setAddrWindow(x, y, x - 1 + 50, y - 1 + 50);
    tft.pushColors(icon_50x50, 50 * 50, 1)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: andy_k on Sep 13, 2016, 11:14 am
 :)  thanks!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: ddwasil on Sep 13, 2016, 08:02 pm
I david
            You have an example for read pictures from sd card because there are a lot of post.
And I don't understand  a lot of point .I have tft IL9488 that is working ok ,I have 8 screen and  I can change  between screen .I need  put a picture
thank you
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: jcmojj on Sep 14, 2016, 03:05 am
Hi David,

First of all I want to thank you for all effort you have done helping everybody! I also have a problem and I need some help. I can't read anything from the touchscreen that is 2.4" tft red shield. When I use the TouchScreen_Calibr_kbv the serial monitor returns only "TouchScreen.h Calibration". When I touch the screen nothing happens. When I run the LCD_ID_readreg returns at the serial monitor:
Quote
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) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 00 00 00 00   Status Register
reg(0x000A) 00 08   Get Powsr Mode
reg(0x000C) 00 66   Get Pixel Format
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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 FF FF 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 01 22 15 20 02   ILI9481, HX8357-B
reg(0x00C0) 00 00 4F 00 00 02 00 01 00   Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 07 C3   Power Control
reg(0x00D2) 00 63 24 00 00   NVM Read
reg(0x00D3) 00 00 00 00   ILI9341, ILI9488
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   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 00 00 00   Interface Control
At the aspect_kbv file the serial monitor returned ID = 0x1520.
The graphic_test_kbv said the same thing.
I installed the Fat library from greiman github and when I run it I received the message:
Show BMP files on TFT with ID:0x1520
cannot start SD
and the screen of the lcd is blue. I had two files at the SD with 320x240 called image1 and image2
With the touch_shield_kbv the screen changed values as I touch and at the SM I had:
Quote
Found unknown LCD driver
ID=0x1520
Screen is 240x320
Calibration is:
LEFT = 920 RT  = 150
TOP  = 940 BOT = 120
Wiring is: PORTRAIT
YP=55 XM=56
YM=7 XP=6
With the TouchScreen_Calibr_kbv the Serial Monitor had TouchScreen.h Calibration and the display shows "#define NUMSAMPLES 3" in Library and some instructions. It doesn't recognize any touch. I didn't understand what you mean by what is written inside "".
With the UTouch_Calibr_kbv I received this error message:

Quote
Arduino: 1.6.7 (Windows 10), Placa:"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:27:43: warning: large integer implicitly truncated to unsigned type [-Woverflow]

 UTFTGLUE myGLCD(0x9341, A2, A1, A3, A4, A0);

                                           ^

UTouch_Calibr_kbv:79: error: declaration of 'FreeSmallFont' as array of references

 extern uint8_t SmallFont[];

                          ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino: In function 'void done()':

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:286:52: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("LEFT ", (calx >> 14) & 0x3FFF, 0, 186);

                                                    ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:287:48: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("RT   ", (calx) & 0x3FFF, 100, 186);

                                                ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:289:52: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("TOP  ", (caly >> 14) & 0x3FFF, 0, 198);

                                                    ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:290:48: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("BOT  ", (caly) & 0x3FFF, 100, 198);

                                                ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:292:50: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("WID ", (cals >> 12) & 0xFFF, 0, 210);

                                                  ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:293:46: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("HT  ", (cals) & 0xFFF, 100, 210);

                                              ^

exit status 1
declaration of 'FreeSmallFont' as array of references
So the main problem is set the touchscreen and the sd card to work.
Thanks a lot and any extra info, just ask!


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 14, 2016, 11:25 am
Hi David,

First of all I want to thank you for all effort you have done helping everybody! I also have a problem and I need some help. I can't read anything from the touchscreen that is 2.4" tft red shield. When I use the TouchScreen_Calibr_kbv the serial monitor returns only "TouchScreen.h Calibration". When I touch the screen nothing happens. When I run the LCD_ID_readreg returns at the serial monitor:

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(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 00 00 00 Status Register
reg(0x000A) 00 08 Get Powsr Mode
reg(0x000C) 00 66 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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 FF FF 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 01 22 15 20 02 ILI9481, HX8357-B
reg(0x00C0) 00 00 4F 00 00 02 00 01 00 Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA
reg(0x00CC) 00 00 Panel Control
reg(0x00D0) 00 07 C3 Power Control
reg(0x00D2) 00 63 24 00 00 NVM Read
reg(0x00D3) 00 00 00 00 ILI9341, ILI9488
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 00 00 00 Interface Control

At the aspect_kbv file the serial monitor returned ID = 0x1520.
The graphic_test_kbv said the same thing.
I installed the Fat library from greiman github and when I run it I received the message:
Show BMP files on TFT with ID:0x1520
cannot start SD
and the screen of the lcd is blue. I had two files at the SD with 320x240 called image1 and image2
With the touch_shield_kbv the screen changed values as I touch and at the SM I had:

Code: [Select]
Found unknown LCD driver
ID=0x1520
Screen is 240x320
Calibration is:
LEFT = 920 RT  = 150
TOP  = 940 BOT = 120
Wiring is: PORTRAIT
YP=55 XM=56
YM=7 XP=6


With the TouchScreen_Calibr_kbv the Serial Monitor had TouchScreen.h Calibration and the display shows "#define NUMSAMPLES 3" in Library and some instructions. It doesn't recognize any touch. I didn't understand what you mean by what is written inside "".
With the UTouch_Calibr_kbv I received this error message:

Code: [Select]
"
Arduino: 1.6.7 (Windows 10), Placa:"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:27:43: warning: large integer implicitly truncated to unsigned type [-Woverflow]

 UTFTGLUE myGLCD(0x9341, A2, A1, A3, A4, A0);

                                           ^

UTouch_Calibr_kbv:79: error: declaration of 'FreeSmallFont' as array of references

 extern uint8_t SmallFont[];

                          ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino: In function 'void done()':

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:286:52: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("LEFT ", (calx >> 14) & 0x3FFF, 0, 186);

                                                    ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:287:48: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("RT   ", (calx) & 0x3FFF, 100, 186);

                                                ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:289:52: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("TOP  ", (caly >> 14) & 0x3FFF, 0, 198);

                                                    ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:290:48: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("BOT  ", (caly) & 0x3FFF, 100, 198);

                                                ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:292:50: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("WID ", (cals >> 12) & 0xFFF, 0, 210);

                                                  ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\UTouch_Calibr_kbv\UTouch_Calibr_kbv.ino:293:46: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("HT  ", (cals) & 0xFFF, 100, 210);

                                              ^

exit status 1
declaration of 'FreeSmallFont' as array of references
"

So the main problem is set the touchscreen and the sd card to work.
Thanks a lot and any extra info, just ask!
First off.   Thanks for the feedback.   Secondly,  please note that I have edited your quoted post to use CODE tags.   This makes a message far more readable.    I suggest that you edit your original post for the benefit of other readers.   And I can then remove my quoted copy.

1.  you have a Renesas R61520 controller with ID = 0x1520.   Note that this controller can NOT do Vertical Scroll.

2.  the Beta on GitHub has got an example called showBMP_kbv_as7.ino
    Arduino SD.h library or third party SdFat.h library are pretty flaky.
    They should both work fine with a Uno which has its hardware SPI on 10, 11, 12, 13
    When you want to bit-bang SPI on a Mega2560 on 10, 11, 12, 13 you need to edit special values.
    If you do this correctly,   a Mega or Due will work just fine

3.  The showBMP example is looking for genuine BMP file called /bitmaps/tiger*.bmp
4.  If your BMP files do not have pictures of tigers,  you probably want to look for *.bmp in the root directory.  e.g.
Code: [Select]

...
char namebuf[32] = "/";
...
        if (strstr(nm, ".bmp") != NULL && strstr(nm, "") != NULL) {
        ...


5.   I ran the diagnose_Touchpins.ino sketch:
Code: [Select]

Making all control and bus pins INPUT_PULLUP
Typical 30k Analog pullup with corresponding pin
would read low when digital is written LOW
e.g. reads ~25 for 300R X direction
e.g. reads ~30 for 500R Y direction

Testing : (A1, D7) = 31
Testing : (A2, D6) = 26
Diagnosing as:-
YP,YM:  (A1, D7) = 31
XM,XP:  (A2, D6) = 26


6.   Compilation errors.   The code on GitHub is Beta.   I will edit the UTFTGLUE.h file to ignore UTFT fonts as a default.   e.g. by undef the GFX support for FreeFonts
Code: [Select]

#include <Adafruit_GFX.h>

#undef _GFXFONT_H_     //comment this line to enable FreeFonts
#if defined(_GFXFONT_H_)
#include <FreeDefaultFonts.h>
#define SmallFont &FreeSmallFont
#define BigFont   &FreeBigFont
#define SevenSegNumFont &FreeSevenSegNumFont
#else
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
extern uint8_t SevenSegNumFont[];
#endif


7.   The warning: deprecated conversion from string constant to 'char*' messages can be "cured" by expecting those strings as "const" e.g.
Code: [Select]

void showNumI(const char *msg, uint32_t val, int x, int y)


8.   I have no idea why you have chosen Utouch_Calibr_kbv instead of the TouchScreen_Calibr_kbv.ino sketch.

It is very useful to get your feedback.   e.g. disabling Fonts in UTFTGLUE.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: jcmojj on Sep 14, 2016, 08:01 pm
Hi again David,

I quoted the post here, that is also my first post at that forum. I read that forum for almost an year, but I never posted since we can easily find all info we need for almost every part we need. The problem is that those tft shield have lots of controllers that make quite confusing to find the info and the correct library to use. We are lucky that you made that library that try to work with almost every type of tft. To start with how could I put the slide bar at the quotes? The way you did at some quotes is better.

Lets come back to the TLT.
1) First test: I create a folder called bitmaps at my SD card and named my 320x240 file as tiger.bmp
I had a blue color at the screem.

Serial Monitor returns:
Quote
Show BMP files on TFT with ID:0x1520
cannot start SD
The compiler returned:
Quote
C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\showBMP_kbv_as7\showBMP_kbv_as7.ino: In function 'void loop()':

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\showBMP_kbv_as7\showBMP_kbv_as7.ino:54:14: warning: converting to non-pointer type 'int' from NULL [-Wconversion-null]

     if (f != NULL) {

              ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\showBMP_kbv_as7\showBMP_kbv_as7.ino: In function 'uint32_t read32(File&)':

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\showBMP_kbv_as7\showBMP_kbv_as7.ino:111:27: warning: left shift count >= width of type [enabled by default]

     result |= f.read() << 16;

                           ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\showBMP_kbv_as7\showBMP_kbv_as7.ino:112:27: warning: left shift count >= width of type [enabled by default]

     result |= f.read() << 24; // MSB
2) Second Test: I did as you said and changed the namebuf to "/" and corrected the if for my file:
Code: [Select]
if (strstr(nm, ".bmp") != NULL && strstr(nm, "imagem1") != NULL) {. I received the same message at the Serial Monitor and at the compiler and the same blue screen.


3) I didn't understand what should I change regarding the SPI, if you have any post or site I could check to do it.

4) I don't have the file diagnose_Touchpins.ino to run here

5) I run the TouchScreen_Calibr_kbv and the compiler had
Code: [Select]
C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_kbv\TouchScreen_Calibr_kbv.ino:23:43: warning: large integer implicitly truncated to unsigned type [-Woverflow]

 UTFTGLUE myGLCD(0x9341, A2, A1, A3, A4, A0);

                                           ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_kbv\TouchScreen_Calibr_kbv.ino: In function 'void done()':

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_kbv\TouchScreen_Calibr_kbv.ino:263:42: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

         showNumI("LEFT ", TS_LEFT, 0, 138);

                                          ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_kbv\TouchScreen_Calibr_kbv.ino:264:42: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

         showNumI("RT   ", TS_RT, 100, 138);

                                          ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_kbv\TouchScreen_Calibr_kbv.ino:265:41: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

         showNumI("TOP  ", TS_TOP, 0, 150);

                                         ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_kbv\TouchScreen_Calibr_kbv.ino:266:43: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

         showNumI("BOT  ", TS_BOT, 100, 150);

                                           ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_kbv\TouchScreen_Calibr_kbv.ino:278:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("LEFT ", TS_LEFT, 0, 186);

                                      ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_kbv\TouchScreen_Calibr_kbv.ino:279:38: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("RT   ", TS_RT, 100, 186);

                                      ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_kbv\TouchScreen_Calibr_kbv.ino:281:37: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("TOP  ", TS_TOP, 0, 198);

                                     ^

C:\Program Files (x86)\Arduino\libraries\MCUFRIEND_kbv-master\examples\TouchScreen_Calibr_kbv\TouchScreen_Calibr_kbv.ino:282:39: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

     showNumI("BOT  ", TS_BOT, 100, 198);

                                       ^

C:\Program Files (x86)\Arduino\libraries\TouchScreen\TouchScreen.cpp:17:0: warning: "NUMSAMPLES" redefined [enabled by default]

 #define NUMSAMPLES 2

 ^

In file included from C:\Program Files (x86)\Arduino\libraries\TouchScreen\TouchScreen.cpp:9:0:

C:\Program Files (x86)\Arduino\libraries\TouchScreen\TouchScreen.h:9:0: note: this is the location of the previous definition

 #define NUMSAMPLES 3

 ^


The SM has
Quote
TouchScreen.h Calibration
I touched the display screen and nothing happened. It has some stuff written that tells me to touch the screen.

6) Running the GLUE Demo 320x240
Lots of images shows up. The touch doesn't change anything and I suppose they should not at this file. The deprecated conversion is just a warning so I didn't fix it.

7) How can I disable the Fonts in UTFTGLUE  as you suggested. Will it unable all the fonts library from Adafruit? I think it is really nice to have all those fonts available to use in the projects. We can include only the Fonts we are using to don't use all flash memory.

8) At my project I need to make a menu at the screen and use it as the buttons. As the person click at the menu the buttons changes. I have files as the UTFT glue that shows me examples of how can I print at the screen The problem now is to use the Touch and the SD card as it would be nice to put some images to use together with the buttons at the screen.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 14, 2016, 11:21 pm
You have not realised the difference between QUOTE tags and CODE tags.

If your showBMP sketch said
Quote
cannot start SD
then it can never read your SD card.

The SD.h library expects to use pins 10, 11, 12, 13 on a Uno (like your Shield)
But it expects to use 50, 51, 52, 53 on a MEGA2560.

The only way for you to use SD.h with the "wrong pins" on a MEGA2560 is by setting a special SYMBOL value in the library.    The whole SD.h arrangement is pretty flaky.   On my v1.6.9 IDE,  you edit utility/Sd2Card.h:
Code: [Select]
#define MEGA_SOFT_SPI 1

Note that you probably need to run your Editor as administrator before Windows will let you edit
C:\Program Files (x86)\Arduino-1.6.9\libraries\SD\src\utility\Sd2Card.h

If you try this "fix",  you hould test the SD.h examples to make sure tat it works (when you use SD.begin(10); )

There is a similar arrangement with the third party SdFat.h library.  Edit
C:\Users\David Prentice\Documents\Arduino\libraries\SdFat\SdFatConfig.h:
Code: [Select]
#define SD_SPI_CONFIGURATION 3


I suggest that you write any new programs for Arduino_GFX.   i.e. use FreeFonts, GFX_Buttons, print() etc.

I am very reluctant to publish anything that involves SD.h or SdFat.h.
It is up to the punter to navigate these particular minefields.

Remember that you have chosen to buy a Uno Shield and then plug it into a non-Uno Arduino.

David.

p.s. the Sd2Card.h "fix" creates other Compilation problems.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: AZ82 on Sep 23, 2016, 04:41 pm
Is it possible to use cyrillic fonts?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 23, 2016, 04:46 pm
You can use whatever fonts you like.   However,   Adafruit_GFX is only expecting 8-bit character values.  (I think)

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: leonardojc on Sep 25, 2016, 04:31 pm
David, thanks for your time and work!

I have the 0x6814 driver with a '' LCD 3,97 (480x272), the problem is the origin (0,0) moved to 24 pixels outside the screen.
It is working as a 480x320 screen.

as I can move the origin inside the screen?

my code:

tft.fillRect(1,1,20,20,Blue);
tft.fillRect(1,252,20,20,Blue);
tft.fillRect(460,252,20,20,Blue);
tft.fillRect(460,1,20,20,Blue);

480x272.jpg shows the problem

thanks in advance!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 25, 2016, 05:40 pm
Yes,  it is hard coded as 320x480.  You can alter it in the CPP file.

I have never seen a 480x272.  I do have a 400x272.
Since you are using a 272x480 screen with a 320x480 controller,  Portrait and Landscape should look ok.    Portrait_Rev and Landscape_Rev will have a missing band.

Hint.  If you are producing a demo JPEG,  please add some text or draw your filled rectangles in different colours.   Or just paste your sketch in a CODE window.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: leonardojc on Sep 25, 2016, 06:10 pm
Thanks David.

Here is my code

Code: [Select]

#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;


/* some RGB color definitions                                                 */
#define Black           0x0000      /*   0,   0,   0 */
#define Navy            0x000F      /*   0,   0, 128 */
#define DarkGreen       0x03E0      /*   0, 128,   0 */
#define DarkCyan        0x03EF      /*   0, 128, 128 */
#define Maroon          0x7800      /* 128,   0,   0 */
#define Purple          0x780F      /* 128,   0, 128 */
#define Olive           0x7BE0      /* 128, 128,   0 */
#define LightGrey       0xC618      /* 192, 192, 192 */
#define DarkGrey        0x7BEF      /* 128, 128, 128 */
#define Blue            0x001F      /*   0,   0, 255 */
#define Green           0x07E0      /*   0, 255,   0 */
#define Cyan            0x07FF      /*   0, 255, 255 */
#define Red             0xF800      /* 255,   0,   0 */
#define Magenta         0xF81F      /* 255,   0, 255 */
#define Yellow          0xFFE0      /* 255, 255,   0 */
#define White           0xFFFF      /* 255, 255, 255 */
#define Orange          0xFD20      /* 255, 165,   0 */
#define GreenYellow     0xAFE5      /* 173, 255,  47 */
#define Pink            0xF81F



void setup() {
   Serial.begin(9600);
    tft.begin(0x6814);
    tft.setRotation(1);   
    tft.fillScreen(White);
    tft.setTextColor(White, Black);
    tft.setTextSize(2);   

tft.fillRect(0,0,20,20,Green); //OUTSIDE OF THE SCREEN
tft.fillRect(460,0,20,20,Green);  //OUTSIDE OF THE SCREEN

tft.fillRect(230,129,20,20,Blue); //CENTER
tft.fillRect(0,252,20,20,Blue); //INSIDE
tft.fillRect(460,252,20,20,Blue);//INSIDE

tft.fillRect(0,24,20,20,Red);//INSIDE
tft.fillRect(460,24,20,20,Red);//INSIDE

tft.setCursor(21,0);tft.println("MYTEXT1");
tft.setCursor(21,24);tft.println("MYTEXT1");
tft.setCursor(21,254);tft.println("MYTEXT1");
   
}

void loop() {
  // put your main code here, to run repeatedly:

}
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 26, 2016, 12:22 pm
First off.   You are forcing 0x6814.   What does tft.readID() say ?

I ran your sketch on a 320x480 display with HX8357D controller.   Obviously by changing.
Code: [Select]

    tft.begin(tft.readID());


I can see that your panel is 272x480.   Please confirm the controller type.
I will think about how to fix it.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: leonardojc on Sep 26, 2016, 01:46 pm
David,

these are the results with LCD_ID_Reader Sketch

reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 54 54 80 66 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 08 08 Get Powsr Mode
reg(0x000C) 66 66 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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) 02 02 02 3B 00 Display Control
reg(0x00B7) 06 06 Entry Mode Set
reg(0x00BF) FF FF 68 14 00 FF ILI9481, HX8357-B
reg(0x00C0) 0E 0E 0E 00 00 00 00 00 00 Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA
reg(0x00CC) 00 00 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 00 00 NVM Read
reg(0x00D3) 00 00 94 86 ILI9341, ILI9488
reg(0x00DA) 54 54 RDID1
reg(0x00DB) 80 80 RDID2
reg(0x00DC) 66 66 RDID3
reg(0x00E0) 00 00 54 07 44 05 08 00 54 07 44 05 08 44 44 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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 00 00 00 Interface Control


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Sep 26, 2016, 05:35 pm
Hi,

I am trying to use this lib with ILI9488 3.5" TFT from mcufriend, sitting on top of Uno clone. All I get is white screen, with toucscreen_calibr_kbv and glue demo.

#include <Adafruit_GFX.h>
#include <UTFTGLUE.h>            //we are using UTFT display methods
UTFTGLUE myGLCD(0x9488, A2, A1, A3, A4, A0);

Anything else I need to set?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 26, 2016, 06:58 pm
Yes.  Please say what ID is reported by graphictest_kbv.ino sketch.

Does everything work correctly?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Sep 26, 2016, 10:12 pm
Nothing works, no examples produce anything on the screen.

ID = 0x1520
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: leonardojc on Sep 26, 2016, 10:14 pm
i think that its not a ILI9488, its a "R61520   240x320  ID=0x1520"
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Sep 26, 2016, 10:18 pm
This is the one on ebay:

http://www.befr.ebay.be/itm/282012561334?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: leonardojc on Sep 26, 2016, 10:25 pm
many sellers put in their description ILI9488 / ILI9486 / etc. but actually it has another driver inside.
In your case, a R61520.

You must change the 0x9488 to 0x1520. you should try and mention the results.

And paste your sketch in a code window.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Sep 26, 2016, 10:30 pm
Tried with GLUE_demo_320X240, I still have white screen.

#include <Adafruit_GFX.h>
//#include <Adafruit_TFTLCD.h>
#include <UTFTGLUE.h>
//UTFTGLUE myGLCD;                         // use for default shield
UTFTGLUE myGLCD(0x1520,A2,A1,A3,A4,A0);
extern uint8_t SmallFont[];

I am still stuck trying to run examples.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 26, 2016, 10:33 pm
@leonardojc,
You have a Raydium RM68140.   Your screen is probably 320x480.    However you seem to have 272x480.

@zdravke,
You probably have a Renesas R61520.  2.4" 240x320.   If it is not working please paste the output from LCD_ID_readreg sketch.

Looking at your Ebay link,   it is the classic "Mendacious Vendor".   The photos are not even the same shape i.e. 240x400 and 320x480.   It is unlikely that anything is truthful.

Please compare the link with the item on your desk.   Say what photos are accurate and/or what any differences.   Especially the wording on the pcb.

David.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Sep 26, 2016, 10:36 pm
My display is definitely 3.5", not 2.4". Not sure about the resolution:

http://www.befr.ebay.be/itm/282012561334

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) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00   Manufacturer ID
reg(0x0009) 00 00 00 00 00   Status Register
reg(0x000A) 08 08   Get Powsr Mode
reg(0x000C) 66 66   Get Pixel Format
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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) 01 01 22 15 81 00   ILI9481, HX8357-B
reg(0x00C0) 00 00 3B 00 02 00 01 00 43   Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 00   Power Control
reg(0x00D2) 03 03 24 04 00   NVM Read
reg(0x00D3) 03 03 24 04   ILI9341, ILI9488
reg(0x00DA) 00 00   RDID1
reg(0x00DB) 00 00   RDID2
reg(0x00DC) 00 00   RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA-N
reg(0x00EF) 00 00 00 00 00 00   ILI9327
reg(0x00F2) 07 07 00 00 00 00 00 00 00 00 00 00   Adjust Control 2
reg(0x00F6) 00 00 00 00   Interface Control
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: leonardojc on Sep 26, 2016, 10:47 pm
there any way to change the screen size in the cpp file?
and I tried using it in 480x320, but the edges are lost
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 26, 2016, 11:02 pm
@leonardojc,

What do you get in Landcape_rev and other modes?
I suspect some will be ok.

It should be simple to solve.  i.e. invert SS direction and invert write direction.
It is my bedtime.   I will post something tomorrow.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Sep 26, 2016, 11:12 pm
Sorry, what is landscape_rev? I don't see it in the examples. I tried most of the examples, none are working.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: leonardojc on Sep 26, 2016, 11:42 pm
Zdravke, the last message was for me
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 26, 2016, 11:44 pm
@zdravke,

You have a Renesas R61581 controller.   Almost certainly 320x480.    And you should detect which photos in your link are truthful.

You need the Beta on GitHub for R61581.
You can force it to work with older libraries by tft.begin(0x9481)

However I would like to get a report for R61581 from the Beta.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: leonardojc on Sep 27, 2016, 03:13 am
@david_prentice,
this is what I get in all four modes.
the gray part is that I can not see. I only see the white part.

It is like a wide screen TFT


(https://drive.google.com/uc?export=download&id=0B37jGJB6dUwTYXFoZGMtU1ZQQjg)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Sep 27, 2016, 08:25 am
@zdravke,

You have a Renesas R61581 controller.   Almost certainly 320x480.    And you should detect which photos in your link are truthful.

You need the Beta on GitHub for R61581.
You can force it to work with older libraries by tft.begin(0x9481)

However I would like to get a report for R61581 from the Beta.

David.
Where can I find this beta?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 27, 2016, 08:52 am
The Beta is on Github (https://github.com/prenticedavid/MCUFRIEND_kbv)

Click on [Clone or Download] button.   Save ZIP on your PC.
Delete your existing MCUFRIEND_kbv library folder.

From the IDE:  Sketch->Include Library->Add ZIP Library...

Run the graphictest_kbv sketch.   Report back for the result with ID= 0x1581
Then edit the sketch to force tft.begin(0x9481).   Report back for the result with ID=0x9481

When you get everything working,  please compare the photos and information on your Ebay link.
Then you can explain what is true and what is a lie for the benefit of all the other Ebay customers.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bikingbadger on Sep 27, 2016, 12:00 pm
Firstly I want to say thanks for the effort and the great help you have given us lesser mortals. With enough smoke blown I'd like to find out whether you ever got around to adding the ILI9331. I saw a few posts early on and after going through 20 pages of this post didn't see it come up again. I'm currently using the 9320 hardcoded which works great and the 9335 also seems to work. I'd just like to be able to use the code without hard coding if I were to use different LCD shields with the same code. If there is anything I should supply please let me know.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 27, 2016, 12:13 pm
Surely it already recognises ILI9331 with readID() and works with tft.begin(0x9331)

The 9331 and 9335 are more similar to ILI9325 than ILI9320.

Please run graphictest_kbv and tell me whether the colours are correct and Software Scroll is correct.
You can force 0x9320, 0x9325, 0x9331, 0x9335.

If you have a very old library,  replace it with the Beta as described in message #741

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Sep 27, 2016, 12:18 pm
The Beta is on Github (https://github.com/prenticedavid/MCUFRIEND_kbv)

Click on [Clone or Download] button.   Save ZIP on your PC.
Delete your existing MCUFRIEND_kbv library folder.

From the IDE:  Sketch->Include Library->Add ZIP Library...

Run the graphictest_kbv sketch.   Report back for the result with ID= 0x1581
Then edit the sketch to force tft.begin(0x9481).   Report back for the result with ID=0x9481

When you get everything working,  please compare the photos and information on your Ebay link.
Then you can explain what is true and what is a lie for the benefit of all the other Ebay customers.

David.
Finaly, something is moving on the LCD with ID 0x1581 and beta, thanks;)

Problems that I could see:

Colors are reversed
Few pixels truncated on top in portrait (left in landscape)
portrait and landscape_rev  are printing mirrored fonts
scrolling is always working in portrait mode only - up and down.

Looks like very close to a working lib.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bikingbadger on Sep 27, 2016, 12:24 pm
Surely it already recognises ILI9331 with readID() and works with tft.begin(0x9331)

The 9331 and 9335 are more similar to ILI9325 than ILI9320.

Please run graphictest_kbv and tell me whether the colours are correct and Software Scroll is correct.
You can force 0x9320, 0x9325, 0x9331, 0x9335.

If you have a very old library,  replace it with the Beta as described in message #741

David.
Hi David,
It does recognise the ILI9331 and I can am currently using tft.begin(0x9320) to get it working. I was just wondering whether this couldn't be worked into the library. I will try the latest library I used the library that was in post #1
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 27, 2016, 04:40 pm
@leonardojc,

Please run this sketch:
Code: [Select]

#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

// Assign human-readable names to some common 16-bit color 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 drawboxatxy(int x, int y, int w, int h, uint16_t color)
{
    tft.drawRect(x, y, w, h, WHITE);
    tft.fillRect(x + 1, y + 1, w - 2, h - 2, color);
    tft.setTextSize(1);
    tft.setCursor(x + 3, y + 3);
    tft.print(x);
    tft.print(",");
    tft.print(y);
    tft.setTextSize(4);
    tft.setCursor(x + 3, y + 12);
    tft.print("F");
}

void setmadctl(uint8_t val, const char *msg)
{
    tft.pushCommand(0x36, &val, 1);
    tft.println(msg);
    delay(5000);
}

void setup()
{
    uint8_t pixfmt = 0x55;
    Serial.begin(9600);
    uint16_t ID = tft.readID();
    //    tft.begin(0x6814);
    tft.begin(ID);
    if (ID != 0x6814) tft.pushCommand(0x3A, &pixfmt, 1);
    tft.setTextColor(WHITE);
}

int aspect = 0;
const char *aspectname[] = {
    "PORTRAIT", "LANDSCAPE", "PORTRAIT_REV", "LANDSCAPE_REV"
};

void loop()
{
    if (++aspect > 3) aspect = 0;
    tft.setRotation(aspect);
    uint8_t current = tft.readReg(0x0B);   //RDMADCTL
    uint8_t a[6];   //buffer for data arguments
    int wid = tft.width();
    int ht = tft.height();
    tft.fillScreen(BLACK);
    drawboxatxy(0 + 48, 0 + 48, 48, 48, RED);   //tlhc
    drawboxatxy(wid - 96, 0 + 48, 48, 48, GREEN);   //trhc
    drawboxatxy(0 + 48, ht - 96, 48, 48, BLUE);   //blhc
    drawboxatxy(wid - 96, ht - 96, 48, 48, MAGENTA);   //brhc
    tft.setTextSize(2);
    tft.setCursor(0, 100);
    tft.println(aspectname[aspect]);
    delay(5000);
    setmadctl(current | 0x01, "Vertical Flip");
    setmadctl(current | 0x02, "Horizontal Flip");
    setmadctl(current ^ 0x40, "Invert MX");
    setmadctl(current ^ 0x80, "Invert MY");
}


You should either see coloured boxes move and/or text appear mirrored.
If you can take video it would be helpful but JPEGs are ok.    If you do a video,  you can reduce the delays down to a few milliseconds to make a "short" video.   I can single step the video on the PC.

Please understand that I do not own a readable RM68140.  So any code can only be written with the help of a remote owner.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: leonardojc on Sep 28, 2016, 12:54 am
David, I appreciate your dedication.

This is the result of the code that you sent me.


VIDEO (https://drive.google.com/file/d/0B37jGJB6dUwTUDIyeWtoZnpMMmc/view?usp=sharing)


you have the data sheet of RM68140?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 28, 2016, 11:33 am
@leonardojc,

Thanks for the Video.   It shows you have a visible 272x480 area from a virtual 320x480 panel

Yes,  I have the datasheet for a RM68140.   I am 99.99% certain that this is the controller that I identify by the 68 14 in the undocumented reg(0xBF).

In many other ways,   the RM68140 looks like an ILI9486.  e.g reg(0x04), reg(0xD3)
And this is why the older library versions identified it as an ILI9486.

However the behaviour of reg(0x36) is very different.  
The RM68140 datasheet says there is Horizontal Flip and Vertical Flip.   Your video confirms that they do NOT work.  
The RM68140 datasheet says there is MX and MY.   Your video confirms that they do NOT work.

The ILI9486 has working MX, MY but no Flip capability.

Anyway,  you probably do not understand any of this.

My conclusion is that you will just have to put up with what you have got.
1. the panel has 24 pixels missing on both sides.
2. in Portrait modes,  you will just have to add 24 pixels to every X coordinate.  
3. in Landscape modes,  add 24 to every Y coordinate.

In practice,   this will be painful for writing text in Portrait mode.   Text wrap will occur at the wrong place (320) and println() will set the cursor to 0.
Landscape will be fine for wrap and println().   Just as long as you setCursor() to the visible top of the screen when you start.

I could kludge the pixel maths in the library but I don't really want to add extra size especially if you are the only owner.   The examples are already very tight on a Uno.      

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: leonardojc on Sep 28, 2016, 12:10 pm
@david_prentice, thanks for the explanation, I understand perfectly.
after trying several things, I have come to the same conclusion as you.
and I'm using it, moving things so that they are within the screen.

at least we have more experience for next time !!

I really appreciate your time

Thanks
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 28, 2016, 12:53 pm
Why did you choose 272x480?    There are plenty of 320x480 displays.

What surprises me is the sheer range of different controllers.    Especially in the 240x320 class.
I guess that batches come onto the Chinese surplus market.   They get placed on a mcufriend shield pcb. 

And Chinese lingerie merchants sell them on Ebay.

It is rather odd that 0x36 does not work.    After all,   I am sure that the Silicon designs have been around for several years.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: leonardojc on Sep 28, 2016, 02:04 pm
David, unfortunately I did not choose this screen, brought me to do a job.
and the seller did not clarify much about the screen.
But hey, I can use it anyway.
Only that is costing me quite calibrate the touchscreen with the example
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 28, 2016, 03:00 pm
Identify the Touch pins with the diagnostic sketch that I posted somewhere.
Or just use a DMM.

The 2.4" screens are quite robust.    The 3.5" screens are often cracked after their journey from China.

Good luck.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: leonardojc on Sep 28, 2016, 03:05 pm
I already modify the Touchscreen_Calibr_kbv sketch so that everything fits on the screen. and I could get good reference values.

Thank you again for everything.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: safari1 on Sep 28, 2016, 03:10 pm
Hi.
I've bought a 3.95" screen (https://ru.aliexpress.com/item/Free-shipping-LCD-Display-Module-TFT-3-5-inch-TFT-LCD-screen-for-Arduino-UNO-R3/1989269466.html?http_swift_null=) (snapshot (https://www.aliexpress.com/snapshot/8040030130.html?orderId=77865295564153)). Description ili9488.

I'm trying to get to work with UNO.

But LCD_ID_readreg returns ID=0 (https://www.dropbox.com/s/geurp756lgvmc40/output.txt?dl=0).

I've tried different libraries. Most working version was yours. The graphictest_kbd is drawn as it should if I hardcode tft.begin(0x9488)
So Touch_shield_kbv results: graphics are OK, but touchscreen is wrong (https://youtu.be/gotg6lMrPz8).

But there are problem with touchscreen calibrations. TouchScreen_Calibr_kbv works in 320*240 mode  (https://youtu.be/_LHf8dy4G3A)even if I hardcode: UTFTGLUE myGLCD(0x9488, A2, A1, A3, A4, A0);
What should I change in TouchScreen_Calibr_kbv sketch or libraries to correct the calibration?

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 28, 2016, 03:15 pm
The Touchscreen library will return values for left, right, top, bottom.

In your application,  you use the map() function to turn them into your actual screen coordinates.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 28, 2016, 03:39 pm
@safari1,

Thanks for the clickable link to the AliExpress item.
It is far easier to paste the output from LCD_ID_readreg. e.g.
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(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 FF FF FF Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 08 08 Get Powsr Mode
reg(0x000C) 66 66 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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) 01 01 Inversion Control
reg(0x00B6) 80 02 3B 00 00 Display Control
reg(0x00B7) 06 06 Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
reg(0x00C0) 80 25 00 00 00 00 00 00 80 Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA
reg(0x00CC) 00 00 Panel Control
reg(0x00D0) 00 00 FF Power Control
reg(0x00D2) 00 00 00 01 00 NVM Read
reg(0x00D3) 00 00 77 96 ILI9341, ILI9488
reg(0x00DA) FF FF RDID1
reg(0x00DB) FF FF RDID2
reg(0x00DC) FF FF RDID3
reg(0x00E0) F0 03 05 09 0C 0F 3E 77 4F 0F 17 17 21 23 00 00 GAMMA-P
reg(0x00E1) F0 03 05 09 0C 0F 3E 77 4F 0F 17 17 21 23 00 00 GAMMA-N
reg(0x00EF) 00 00 00 00 00 00 ILI9327
reg(0x00F2) C9 C9 C9 C9 C9 C9 C9 C9 C9 C9 C9 C9 Adjust Control 2
reg(0x00F6) 1F 1F 1F 1F Interface Control


You have a Sitronix ST7796 controller.    I possess a ST7796S datasheet but I don't think it is specifically supported by the library.   It looks very similar to an ILI9488.

Please force tft.begin(0x9488) in the graphictest_kbv sketch.
Please report back if the colours are correct,  all scrolling should work.

What does it say for ID ?   (look in the Adafruit Tests Report screen)

The UTFTGLUE class simply reads your ID and begins MCUFRIEND_kbv with that ID.
You can edit UTFTGLUE.h to force 0x9488.   It will then know to use 320x480.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: safari1 on Sep 28, 2016, 06:53 pm
Please force tft.begin(0x9488) in the graphictest_kbv sketch.
Please report back if the colours are correct,  all scrolling should work.

What does it say for ID ?   (look in the Adafruit Tests Report screen)

The UTFTGLUE class simply reads your ID and begins MCUFRIEND_kbv with that ID.
You can edit UTFTGLUE.h to force 0x9488.   It will then know to use 320x480.

David.
I've  wrote earlier that I forced 0x9488 in all tests. There are no problem with graphics, there are problem with touch screen calibration. This is graphictest_kbv (https://youtu.be/w1XNoqz0UNY).
All tests report ID=0.
This is Adafruit graphictest  (https://github.com/adafruit/TFTLCD-Library/blob/master/examples/graphicstest/graphicstest.pde)console output:
Code: [Select]

TFT LCD test
Using Adafruit 2.8" TFT Breakout Board Pinout
TFT size is 240x320
Unknown LCD driver chip: 0
If using the Adafruit 2.8" TFT Arduino shield, the line:
  #define USE_ADAFRUIT_SHIELD_PINOUT
should appear in the library header (Adafruit_TFT.h).
If using the breakout board, it should NOT be #defined!
Also if using the breakout, double-check that all wiring
matches the tutorial.


I've runned TouchScreen_Calibr_kbv in 320*480 mode. (https://youtu.be/EwAtUmT3hk4) Yahoo!!!
And I've corrected Touch_shield_kbv:
uint16_t TS_LEFT = 872;
uint16_t TS_RT  = 200;
uint16_t TS_TOP = 869;
uint16_t TS_BOT = 156;

But all touchings in Touch_shield_kbv seems to be mirrored  (https://youtu.be/j3_DBbB2OOM) :(

What should I do to correct?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 28, 2016, 07:03 pm
You have a Sitronix ST7796 controller.    I possess a ST7796S datasheet but I don't think it is specifically supported by the library.   It looks very similar to an ILI9488.

Please force tft.begin(0x9488) in the graphictest_kbv sketch.
Please report back if the colours are correct,  all scrolling should work.

What does it say for ID ?   (look in the Adafruit Tests Report screen)

The UTFTGLUE class simply reads your ID and begins MCUFRIEND_kbv with that ID.
You can edit UTFTGLUE.h to force 0x9488.   It will then know to use 320x480.

David.
I can't see a private video.   Surely you can just answer my questions with regular yes/no/number.

Then I can show you what to do.

David.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: safari1 on Sep 28, 2016, 08:01 pm
Quote
Please force tft.begin(0x9488) in the graphictest_kbv sketch.
Please report back if the colours are correct,  all scrolling should work.
yes, all colors and sizes and scrolls are correct.
Quote
What does it say for ID ?   (look in the Adafruit Tests Report screen)
ID=0
Quote
The UTFTGLUE class simply reads your ID and begins MCUFRIEND_kbv with that ID.
You can edit UTFTGLUE.h to force 0x9488.   It will then know to use 320x480.
done, thanks!

I've added
TS_LEFT = 869  ;
TS_RT = 193;
TS_TOP = 861;
TS_BOT = 141 ;
before Serial.begin() and deleted switch code with swappind modes (all of it's not working for me).

Now ALL IS GOOD, THANKS A LOT!!! (https://youtu.be/sudbjvcXgZI)  :)

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 28, 2016, 08:57 pm
The videos became non-private!   I saw your graphictest_kbv run.   The Software Scroll was not working.

Please edit your mcufriend_kbv.cpp file:
Code: [Select]

    case 0x9488:
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | READ_24BITS | READ_LOWHIGH;

Run the sketch again with tft.begin(0x9488) and see if the Software Scroll works.
The video did not show the Inverted Screen.   I presume this was ok.

If all is ok,  I will add support for the 0x7796 ID  with READ_LOWHIGH attribute.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bvlet on Sep 29, 2016, 11:43 am
Thank you, your library helped me getting some 'unknown' TFT's to work!

Now I was wondering if it would be possible to edit the library so that I can use a "WeMos D1" ESP8266-based arduino uno-clone to control the display. This clone is much faster and has onboard WiFi, but it lacks some analog pins. It only has A0.
Could we program the library in a way that it supports the esp8266-MCU (Arduino IDE compatible), and that we move A1 to A3 to, for example, D0, D1, D14 and D15? Those are still free....

If this would work, it would be very easy to have a small, WiFI connected standalone display! :D:D
(and for less than 10 dollars :|)

Please let me know your thoughts.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 29, 2016, 12:22 pm
I have no idea what the WeMos D1 does or what pins it has available.

The TFT uses 8 pins for its data bus and 5 control pins.   You don't have many spare pins on a Uno.

Yes,  you can rearrange the pins on a Uno.   Just add your custom wiring to the mcufriend_special.h file.    You can see how this is done for different hardware e.g. Due, Zero, Xmega, Teensy3.2, ...

If you have enough fingers and toes you should be able to see how practical this might be on your strange hardware.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: safari1 on Sep 30, 2016, 01:23 pm
The videos became non-private!   I saw your graphictest_kbv run.   The Software Scroll was not working.

Please edit your mcufriend_kbv.cpp file:

    case 0x9488:
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | READ_24BITS | READ_LOWHIGH;

Run the sketch again with tft.begin(0x9488) and see if the Software Scroll works.
The video did not show the Inverted Screen.   I presume this was ok.

If all is ok,  I will add support for the 0x7796 ID  with READ_LOWHIGH attribute.

David.
Hi David.
I've edited _lcd_capable and made a full (as I suppose ~2 min) video, please check (https://youtu.be/5RH6-bV0wY8) is now Software Scroll and Inverted Screen are correct?
Thank you very much again for supporting our screens.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 30, 2016, 01:50 pm
I have updated the Beta on GitHub to support the ST7796 controller.  
Delete your current library directory, download ZIP,  and install from ZIP.

It should now report ID=0x7796.   So you do not need to kludge any begin(ID) in the examples.

Your video shows only two problems:
1.  ID=0x0000  
2.  Software Scroll is NOT working.   readPixel() = 0xFF1F

I am not 100% confident about whether I have corrected readPixel().
When it works,  you see a Yellow "Software Scroll" text move on the screen.

I am gobsmacked by the quality of your video.   It is brilliant!

If you are good at videos.   Please run the readpixel_kbv sketch.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: safari1 on Sep 30, 2016, 03:59 pm
Simple trick is good web-cam (Logitech 910) + scotch + simple office lamp as a holder (https://dl.dropboxusercontent.com/u/8635482/img/2016-09-30%2016.00.36.jpg) :)
I tried some tests, it reports 0x7796
But LCD_ID_readreg still reports ID=0.

This is readpixel_kbd (https://youtu.be/327YUJglQls). Hope numbers will be visible in youtube after. If not, I'll paste original clip in dropbox in FullHD.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 30, 2016, 04:17 pm
An excellent video.   Please edit the mcufriend_kbv.cpp

Code: [Select]

    case 0x7796:
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | READ_BGR;  // changed line
        goto common_9488;
    case 0x9488:
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | READ_24BITS;
      common_9488:


This should give you a proper readpixel sketch.   The Blue backround dump should say 001F.   If it says F800 you need to remove the READ_BGR attribute.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Sep 30, 2016, 05:16 pm
@zdravke,

You have a Renesas R61581 controller.   Almost certainly 320x480.    And you should detect which photos in your link are truthful.

You need the Beta on GitHub for R61581.
You can force it to work with older libraries by tft.begin(0x9481)

However I would like to get a report for R61581 from the Beta.

David.
David, I got this working all the way. Some pixel rows are missing at the edge and colors seem inverted, but I can work all that out in the code. If you need anything from me to update the lib, le me know. I am happy as it is already.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 30, 2016, 05:35 pm
The new Beta on GitHub that I updated yesterday should fix the Inverted Colours.

The graphictest_kbv sketch should look exactly like Safari1's video from #763.   
i.e. if it says BLUE,  it should be blue.
"Software Scroll" in yellow should move across the screen.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: safari1 on Sep 30, 2016, 05:46 pm
This should give you a proper readpixel sketch.   The Blue backround dump should say 001F.   If it says F800 you need to remove the READ_BGR attribute.
David.
readpixel_kbv (https://youtu.be/FvTV8_pSZz0) with this params:
      _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS;

READ_BGR gives F800 as you supposed.

Now software scrolling seems to works (https://youtu.be/CIVDfjL9RDk). There are some sync artifacts, but I think it's not critical.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 30, 2016, 06:02 pm
Yes,  everything looks fine now.    Thanks for the excellent videos.
It all works quite swiftly.   Even quicker with a Teensy or Due.

It looks as if the ST7796 is very similar to the ILI9486/ILI9488.
I am pleased that we have tidied up the readPixel() niceties.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: safari1 on Sep 30, 2016, 06:35 pm
David, thank you very much for your patience!
Without your support we would be left alone with an "unknown manufacturer".

Please don't forget to correct LCD_ID_readreg (still reports ID=0 for ST7796).
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Sep 30, 2016, 06:46 pm
The new Beta on GitHub that I updated yesterday should fix the Inverted Colours.

The graphictest_kbv sketch should look exactly like Safari1's video from #763.   
i.e. if it says BLUE,  it should be blue.
"Software Scroll" in yellow should move across the screen.

David.
Here you go David, almost there;)

https://www.youtube.com/watch?v=ZhNYkrSne_g
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Sep 30, 2016, 08:39 pm
@zdravke,

The directions and aspects are correct.

I just need to change BGR colour and get the readPixel() correct.
Not tonight.   Probably tomorrow.

If you feel like posting a single screenshot of readpixel_kbv.ino it would be handy.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Oct 01, 2016, 08:29 am
Here you go David.

(https://c5.staticflickr.com/9/8694/29923542212_dc1fdf0a62_z.jpg) (https://flic.kr/p/MAeYzA)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 01, 2016, 09:35 am
Thanks for the photo.   Please make two edits in mcufriend_kbv.cpp:

This should fix the colours:
Code: [Select]

            if (_lcd_ID == 0x1581) { // no Horizontal Flip
                d[0] = (val & 0x40) ? 0x13 : 0x12; //REV | BGR | SS

This should fix the readPixel().   
Code: [Select]

    case 0x1581:
        _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | READ_BGR | READ_24BITS;

If the Blue background reads as 0xF800 please remove the READ_BGR attribute.

Please let me know the results.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Oct 01, 2016, 03:49 pm
Colors fixed, thanks! Remains only a truncation of the pixels in upper left corner.

(https://c2.staticflickr.com/6/5748/29959326321_3724b6df2c_z.jpg) (https://flic.kr/p/MDpnWZ)

(https://c8.staticflickr.com/9/8082/29416071583_baf1104f16_k.jpg) (https://flic.kr/p/LPp4eZ)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 01, 2016, 04:11 pm
I don't think that I can do anything about your top left hand corner.   I suspect that the Touch Panel and the TFT Panel are not aligned perfectly.   Think about it.   These displays are incredibly cheap.   Several displays that I have encountered are not "perfect".   Generally due to the Touch Panel.

You can do
Code: [Select]

    tft.fillRect(0, 0, tft.width(), tft.height(), RED);
    tft.drawRect(0, 0, tft.width(), tft.height(), WHITE);


This will show you whether you have an alignment problem.   Your PORTRAIT_REV photo (readpixel_kbv.ino) displays ok on the outer pixels.

Thanks for your help.   Without it,  I could never be sure of the R61581.   I will update GitHub later today.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Oct 01, 2016, 04:49 pm
Thanks a lot David, thanks to you this is now a very usable display.

I am just wondering, are there any available pins in Uno, since this TFT plugs in all of them? Are they all used?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Viliam on Oct 01, 2016, 05:01 pm
David, could you please identify if following TFT board is supported by MCUFRIEND_kbv library due to  
white screen issue.

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) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 61 61 AC 11 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 08 08 Get Powsr Mode
reg(0x000C) 66 66 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 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 AC 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 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA
reg(0x00CC) 00 00 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 00 00 NVM Read
reg(0x00D3) 00 61 AC 11 ILI9341, ILI9488
reg(0x00DA) 61 61 RDID1
reg(0x00DB) AC AC RDID2
reg(0x00DC) 11 11 RDID3
reg(0x00E0) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-P
reg(0x00E1) 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA-N
reg(0x00EF) 00 00 00 00 00 00 ILI9327
reg(0x00F2) 28 94 03 08 08 10 00 15 48 00 07 00 Adjust Control 2
reg(0x00F6) 01 01 03 00 Interface Control

Thank you in advance.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 01, 2016, 05:05 pm
You have a R61581 which has a Software Reset command.   So you do not need the hardware LCD_RESET pin.

1.  snip off LCD_RESET pin (A4).   Solder a 10k pullup between the top of the snipped pin and 5V pin.

2.  You can use A4, A5 for I2C bus

3.  You can use D10-D13 for SPI bus (if you do not use the microSD)

4.  If you have a TQFP-32 mcu,  you also have A6, A7 Analog pins.

In practice, you have to choose between I2C or SPI.   If you want more than one SPI slave,  you have to use A4, A5 pins for Chip-Selects.   The Library will still shake the A4 pin but only at begin() or reset().   So you should call tft.begin() before Wire.begin()

The Uno clones with SMD give you a very good platform.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 01, 2016, 05:18 pm
David, could you please identify if following TFT board is supported by MCUFRIEND_kbv library due to  
white screen issue.

reg(0x0004) 61 61 AC 11 Manufacturer ID

reg(0x00D3) 00 61 AC 11 ILI9341, ILI9488

reg(0x00DA) 61 61 RDID1
reg(0x00DB) AC AC RDID2
reg(0x00DC) 11 11 RDID3

Thank you in advance.
I have no idea what make or model you have.   Is it 240x320 or 320x480 or 240x400 or ... ?

I can only suggest that you try forcing tft.begin(0x9329),  0x9481, 0x9486 ...

I am gobsmacked by all these strange controllers appearing on the Ebay market.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Viliam on Oct 01, 2016, 06:58 pm
My mistake, please find attached missing photo. TFT model is 2.4" which is directly connected to UNO board. Interesting thing is that the both boards are from "stone" shop. Do you have an idea which driver/lib solve  white screen issue I am not familiar with such kind of stuff. Thank you for your patience.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 01, 2016, 07:34 pm
Upload the graphictest_kbv sketch from the library examples.

Normally you identify the controller with tft.readID()
Edit the tft.begin(ID) statement in setup() to use tft.begin(0x9329)

You will probably find that colours are wrong or text is mirrored.
A good video is in #769.

Take notes.   Let me know what is wrong.   We will get you going properly.
What is a stone shop?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Viliam on Oct 01, 2016, 08:32 pm
#1 the issue with white screen has been solved (good job)
#2 the text is really mirrored (pls. have a look at attached file)

"stone shop" is traditional store with shop assistants it is oposite of e-shop

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 01, 2016, 09:36 pm
Please try 0x9341, 0x9338, 0x9302, 0x7789

With luck,  one might match your controller.   I suspect you will get inverted colours with most of them.

Yes,  you have chosen a good screen to photograph.   When you find the "best" ID match,  post another photo.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Viliam on Oct 01, 2016, 10:17 pm
0x9341 white screen
0x9338, 0x9302, 0x7789 now the text is properly oriented but with inverted colours (identity mapping)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 01, 2016, 10:32 pm
Don't worry about the inverted colours.   Just add this line to the start of loop()
Code: [Select]

     tft.invertDisplay(1);



Just watch the scrolling.   
Does the screen do Vertical Scroll, Band Scroll, Software Scroll?

If none of them Software Scroll,   please say what the problem is i.e. readPixel()= ????

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Viliam on Oct 01, 2016, 11:03 pm
David thank you so much for your assistance.

Now it seems perfect text orientation, alignment and colours are OK, Vertical Scroll, Band Scroll, Software Scroll works fine as well. The next step will be touch screen test.

Viliam
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 01, 2016, 11:27 pm
So would 0x9338 be the "best" ID ?

If you tell me,  I can add your controller with correct attributes.   Then it will work 100% via readID().

I guess that your shop will be selling this "stone" display to other customers.

DAvid.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Viliam on Oct 01, 2016, 11:49 pm
It seems that each of ID 0x9338, 0x9302, 0x7789 gives the equal good results.

Another interesting thing is TouchScreen_Calibr_kbv brings white screen despite of changed ID to the correct value.

You are absolutely right probability that the "stone" was the last in line approaching zero, proper ID  helps another people.

Viliam
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 02, 2016, 12:01 am
0x9338, 7789 mght give correct Software Scroll.
I would expect 0x9302 to give a readPixel() error.

Please confirm this.

Then we can see about the Touchscreen.   Have you identified XM, XP, YM, YP pins correctly?

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Viliam on Oct 02, 2016, 08:24 am
Correct, 0x9338, 0x7789 give readPixel() value "BGR" against what 0x9302 gives value "0xFC".


Regarding XM, XP, YM, YP pins TouchScreen_Calibr_kbv talking about UNO shield sharing pins with the TFT
ST7789V but I am not sure if my TFT shield exactly uses mentioned ID/controler and following assignment
is correct: YP A2, YM 7, XM A1, XP 6.   

Viliam
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: vagos21 on Oct 02, 2016, 11:56 am
David,

i've been trying to load some UTFT created RGB565 raw images on my SSD1963, i studied the whole drawbmp example, though the code is somewhat complex for my needs since it covers bmps of different formats.
so right now i try to read a buffer directly and pushColor it to the tft. is this the way to do it? right now all i get on the screen is some purplish colors while it should be a really dark grey (27,27,27). the bytes in the file are correct as their 16bit value is 0x18C3

this is a test code so i don't handle any misaligned buffers etc. my tft size is 480x272 so i try to load a line length buffer at a time.

Code: [Select]
void loadRaw(char *nm, int x, int y, int w, int h, int bufferSize){
  File rawFile;

  rawFile = SD.open(nm);
  bool first = true;

  uint16_t lcdbuffer[bufferSize];

  //if ((x + w) >= tft.width())  w = tft.width() - x;
  //if ((y + h) >= tft.height()) h = tft.height() - y;

  int numBlocks = (w*h)/bufferSize;
  int leftoverPixels = (w*h)%numBlocks;

  tft.setAddrWindow(0, 0, tft.width() - 1, tft.height() - 1);
  for (int i=0; i<numBlocks; i++) {
    rawFile.read(lcdbuffer, bufferSize);
    tft.pushColors(lcdbuffer, i, first);
    first = false;
  }
 
  rawFile.close();
}



and i call it like this:

Code: [Select]
loadRaw("main/main.raw", 0, 0, 480, 272, 480);

apparently i don't know how pushColors works, even though i got a hunch about how setAddrWindow works (it just sets the bounds where pushColors takes place?)

so are there any hints how to make this work? i can supply the .raw file if needed for testing... this is what i get after running it (i set the color to red before loading so i can clearly see the loaded lines)

shot (https://www.dropbox.com/s/o86hiqv6k9kjlna/loadRaw.jpg?dl=0)

thank you!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 02, 2016, 12:18 pm
I have updated the Beta on GitHub (https://github.com/prenticedavid/MCUFRIEND_kbv)

1. corrected 320x480 ST7796 with thanks to safari1
2. corrected 320x480 R61581 with thanks to zdravke
3. added support for an unknown 240x320 controller ID=0xAC11 with thanks to viliam
4. added (disabled) special for SSD1963 480x272 with thanks to vagos21
5. all Uno Shields should work (very fast) with Teensy3.2 but not many have been tested
6. added a diagnose_Touchpins.ino sketch to examples

If anyone knows a reliable supplier of a 0x1511 display,  please let me know.
I would like to buy a 0x1511 display.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 02, 2016, 12:32 pm
@vagos21,

Code: [Select]

void loadRaw(char *nm, int x, int y, int w, int h, int bufferSize){
  File rawFile;

  rawFile = SD.open(nm);
  bool first = true;

  uint16_t lcdbuffer[bufferSize];

  int numBlocks = (w*h)/bufferSize;
  int leftoverPixels = (w*h)%numBlocks;

  tft.setAddrWindow(x, y, x + w - 1, y + h - 1); //only you know your dimensions
  for (int i=0; i<numBlocks; i++) {
    rawFile.read(lcdbuffer, bufferSize);
    tft.pushColors(lcdbuffer, bufferSize, first);
    first = false;
  }
    rawFile.read(lcdbuffer, leftoverPixels);
    tft.pushColors(lcdbuffer, leftoverPixels, first);
 
  rawFile.close();
}


You must check whether the File.read() function can read uint16_t or whether it expects bytes.
You must also check whether rawFile is not NULL from the open().

Personally,  I would use a different loop structure.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: KitaPro on Oct 02, 2016, 01:28 pm
Hi, this library is suitable for this 3.97 (https://ru.aliexpress.com/item/3-95-inch-TFTLCD-touch-screen-with-Arduino-uno-R3-self-produced-self-marketing-private-custom/32698925330.html?spm=2114.14010208.99999999.264.HCduiL) display?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 02, 2016, 01:54 pm
It looks like a 240x400 display.   At 3.97" the pixels will be visible.

A 320x480 3.5" display will have a higher resolution.
 
Yes,   I am 99% confident that the 240x400 is already supported:
ILI9326, ILI9327, R61509, ST7793, SPFD5420

Likewise,  I already support many 320x480 controllers.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: KitaPro on Oct 02, 2016, 03:57 pm
Okay, but I can not find 3.5 inch display. This 3.6 inch (http://www.ebay.com/itm/LCD-Display-Plug-and-Play-3-6-inch-TFT-Touch-Screen-Module-Arduino-UNO-R3-Board-/281672772523?hash=item4195016bab:g:mSEAAOSwBahVOvzR) better than 3.97?
It will work on the Arduino Mega?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 02, 2016, 04:28 pm
Look at the main photo in your Ebay link.  
It shows a UTFT sketch running on a 320x480 display on the left.
It shows a 240x400 screen on the bottom right.

Now look at the other five photos in the group.   They all show a 240x400 display.

Now look at the text.
Quote
Tftlcd 3.6-inch touch screen with uno r3
3.6-inch LCD touch screen
Resolution : 480x320
Controller : ili9488
Test code:
ILI9327:
There are several Ebay and AliExpress vendors that use exactly the same mendacious description.

I would not trust any vendor that lies like this.

Find a vendor that has consistent information.  e.g. photos of a screen of the correct shape.
Ask on this site.  You may find a customer that can recommend your vendor.

Be wary of the "Positive feedback" from Ebay.    Never believe the "customer rating" from Aliexpress.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: vagos21 on Oct 02, 2016, 05:49 pm
David you were right, it was a uint16_t read problem. i also had a mistake about the "remaining pixels" so it's now all fixed.

So if anyone has an up and running sdFat and wants to load RAW images created from the UTFT tool (or any other online RGB565 conversion tool) here is my function to do it:

Code: [Select]
void loadRaw(char *nm, int x, int y, int w, int h, int bufferSize){
  File rawFile = SD.open(nm);
  if(rawFile){
    bool first = true;

    if (bufferSize>w*h) bufferSize = w*h; //clamp buffer size if bigger than total pixels

    int numBlocks = (w*h)/bufferSize; //calculate number of blocks
    int leftoverPixels = (w*h)%(numBlocks*bufferSize); //calculate remaining pixels to read

    byte lcdbuffer[2*bufferSize];

    tft.setAddrWindow(x, y, x+w-1, y+h-1); //set action area
   
    for (int i=0; i<numBlocks; i++) { //loop trough number of blocks
      rawFile.read(lcdbuffer, 2*bufferSize);
      tft.pushColors(lcdbuffer, bufferSize, first);
      first = false;
    }
    rawFile.read(lcdbuffer, 2*leftoverPixels); //read and...
    tft.pushColors(lcdbuffer, leftoverPixels, first); //...write rest of pixels
 
    rawFile.close();
  }
}



and you can easily call it like this:

Code: [Select]
loadRaw("patchEdit/spill9off.raw", 240, 100, 70, 27, 16);

arguments are in the order: filename, X and Y coords to draw bitmap, width and height of bitmap, buffer size (number of pixels). buffer size can be set to do the trick between small available memory and big available memory (DUE beasts) :) for example, a 480x272 raw file loads on my screen (hardware SPI and DUE) in 430ms when buffer size is 960, but in just 250 ms when buffer size is 3840 (twice as fast!) always think about your free memory when loading files :)

Vangelis
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: zdravke on Oct 03, 2016, 01:47 pm
You have a R61581 which has a Software Reset command.   So you do not need the hardware LCD_RESET pin.

1.  snip off LCD_RESET pin (A4).   Solder a 10k pullup between the top of the snipped pin and 5V pin.

2.  You can use A4, A5 for I2C bus

3.  You can use D10-D13 for SPI bus (if you do not use the microSD)

4.  If you have a TQFP-32 mcu,  you also have A6, A7 Analog pins.

In practice, you have to choose between I2C or SPI.   If you want more than one SPI slave,  you have to use A4, A5 pins for Chip-Selects.   The Library will still shake the A4 pin but only at begin() or reset().   So you should call tft.begin() before Wire.begin()

The Uno clones with SMD give you a very good platform.

David.
Thanks! Is there a way to turn off backlight or put the entire TFT to sleep (to be awaken by touch)?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 03, 2016, 02:04 pm
Most of the Uno shields Use:
1.  5V pin to power the backlight via the 3.3V LDO mounted on shield.
2.  3.3V pin for the '245 buffers to provide 3V logc to the controller
3.  RD pin for the '245 buffers to provide logic level to the Arduino when reading the bus.
4.  Most shields use HC245 buffers which is not correct.   They should use LV245 (or similar) voltage-tolerant buffers.   

No.   You would need to cut the pcb trace to the LEDs.   Hand-wire a transistor or MOSFET to switch the 5V line.

You can send the controller to sleep,  saving 20mA or so.
If you could switch the Backlight,  you would save 100mA-300mA.

Arduinos are not intended for low-power operation.   TFT backlights are power hungry.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bvlet on Oct 04, 2016, 03:47 pm
I have no idea what the WeMos D1 does or what pins it has available.

The TFT uses 8 pins for its data bus and 5 control pins.   You don't have many spare pins on a Uno.

Yes,  you can rearrange the pins on a Uno.   Just add your custom wiring to the mcufriend_special.h file.    You can see how this is done for different hardware e.g. Due, Zero, Xmega, Teensy3.2, ...

If you have enough fingers and toes you should be able to see how practical this might be on your strange hardware.

David.
I spent part of the weekend to figure this out, but I struggle to understand the variables in the special.h file and I don't see how this library is called from the MCUFRIEND_kbv.cpp...?

I know I need to define the MCU somewhere. It's found in the ESP8266 package and is called  with

Code: [Select]
#ifdef  ARDUINO_ESP8266_WEMOS_D1MINI

There is a nice overview of the board here: https://www.youtube.com/watch?v=IQVKGAU8jcA

(https://s-media-cache-ak0.pinimg.com/originals/63/77/e5/6377e545719d6dc0d699e3330f15f30e.jpg)

I think we should be able to remap A1, A2 and A3 to 3 of the 4 remaining digital pins, and then attach A4/RST to the RST of the MCU board...

Could you give me some tips regarding this?

Thanks in advance, really appreciate it!




Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 04, 2016, 04:55 pm
Well,  it looks fun.   I can buy this from Amazon UK (https://www.amazon.co.uk/LinkNode-D1-ESP8266-Arduino-compatible-WiFi/dp/B01DD641G6/ref=sr_1_1?ie=UTF8&qid=1475591728&sr=8-1&keywords=arduino+esp8266) for £10
or this from UK Ebay seller (http://www.ebay.co.uk/itm/WeMos-D1-R2-CH340-WiFi-OTA-Development-Board-ESP8266-ESP-12E-Arduino-IDE-UNO-R3-/252521291671?hash=item3acb711f97:g:fm0AAOSwGtRXzx4f) for £9

I might just as well buy one for myself.

If there are ports and data direction registers,  it should be straightforward to support it.   I just want direct access to the pins.   I really do not want to use digitalWrite().

It is probably easier for me to buy the WeMos or LinkNode and implement it myself.   

David.

p.s. if A1-A3 pins are not available,  you can't plug the Shield into the WeMos board.   There is little point in messing with a shield that can't be plugged in.   (modern controllers can work without the LCD_RESET pin)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: bvlet on Oct 04, 2016, 05:29 pm
If you check AliExpress you can get them for as low as 3 Pounds or 4 Pounds for the R2 version...  :)


On the ESP8266 is a very extensive manual available:
https://espressif.com/sites/default/files/documentation/esp8266-technical_reference_en.pdf (https://espressif.com/sites/default/files/documentation/esp8266-technical_reference_en.pdf)

I realized that you can't plugin the shield when the A1 to A3 is not available, but personally I don't mind soldering three wires if I can prevent having a separate Arduino and doing all wireless operations over the serial port... (That's what I'm doing now).

You could even bend out the headers and use standard dupont female-male wires on them....
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 04, 2016, 07:35 pm
You need 8 GPIO for the data bus.   Plus 4 control signals.

As far as I can see,  the board has only got 11 digital and 1 analog pin.

If you want to use a TFT,   I would choose an SPI ILI9341 or ST7735S display.   This would mean you have enough pins AND even have spare GPIO and the 1 Analog.

And best of all,  you already have 3.3V logic.   So the cheap Chinese modules work straightaway.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Viliam on Oct 04, 2016, 09:43 pm
David, touch screen now works with 0x7789 (0x9338) and YP A1, YM 7, XM A2, XP 6 but it seems like mirrored movement pls. see attached video https://www.youtube.com/watch?v=mOtmQFh_DSg&feature=youtu.be

Viliam
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 04, 2016, 10:05 pm
It is your responsibilty to identify which are the Touch Pins i.e. XP, XM, YP, YM.
And to determine which values are returned for TS_LEFT and TS_RIGHT.

Then you can map them to your cursor x,y position.

If your X direction is wrong,  you swap left and right.

I have no idea what your particular Touch wiring is.    I just included my own values from displays that I own.   And even then,  not all ILI9341 displays are the same.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: anand_tiwary on Oct 06, 2016, 08:58 am
hey David,
 
   i have recently bought a 3.95" tft LCD display with mcufriend.com printed on the back.... there is a SD card slot at the back.....I m new wid it so please help me wid some codes to display image on the screen from sd card

Thank you,

Anand.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: kiloWATT on Oct 11, 2016, 02:12 pm
Hi,

Shows the ID on Serial but no picture.

I recently bought NHD-2.4_240320cf-CTXI and it uses ST7789.

i'm not using a shield but i use the same pins as the shield does.

When i upload LCD_ID_Reader.ino on to the UNO i get this:

reg(0x0000) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 04 85 85 52   Manufacturer ID
reg(0x0009) 09 09 09 09 09   Status Register
reg(0x000A) 0A 0A   Get Powsr Mode
reg(0x000C) 0C 8D   Get Pixel Format
reg(0x0061) 61 61   RDID1 HX8347-G
reg(0x0062) 62 62   RDID2 HX8347-G
reg(0x0063) 63 63   RDID3 HX8347-G
reg(0x0064) 64 64   RDID1 HX8347-A
reg(0x0065) 65 65   RDID2 HX8347-A
reg(0x0066) 66 66   RDID3 HX8347-A
reg(0x0067) 67 67   RDID Himax HX8347-A
reg(0x0070) 70 70   Panel Himax HX8347-A
reg(0x00A1) A1 A1 A1 A1 A1   RD_DDB SSD1963
reg(0x00B0) B0 00   RGB Interface Signal Control
reg(0x00B4) B4 03   Inversion Control
reg(0x00B6) B6 00 00 00 00   Display Control
reg(0x00B7) B7 35   Entry Mode Set
reg(0x00BF) BF 3D 00 00 00 00   ILI9481, HX8357-B
reg(0x00C0) C0 24 00 00 00 00 00 00 00   Panel Control
reg(0x00C8) C8 2C 08 08 08 08 08 08 08 08 08 08 08   GAMMA
reg(0x00CC) CC 28   Panel Control
reg(0x00D0) D0 A4 A1   Power Control
reg(0x00D2) D2 00 00 00 00   NVM Read
reg(0x00D3) D3 00 00 00   ILI9341, ILI9488
reg(0x00DA) DA 08   RDID1
reg(0x00DB) DB 08   RDID2
reg(0x00DC) DC 00   RDID3
reg(0x00E0) E0 D0 00 02 07 03 12 31 54 40 21 12 12 12 17 00   GAMMA-P
reg(0x00E1) E1 D0 00 02 07 05 25 25 44 45 14 10 16 14 15 00   GAMMA-N
reg(0x00EF) EF 08 08 08 08 08   ILI9327
reg(0x00F2) F2 07 00 00 00 00 00 00 00 00 00 00   Adjust Control 2
reg(0x00F6) F6 F7 F7 33   Interface Control



When i upload the graphicaltest_kbv.ino Serial shows:

Serial took 0ms to start
ID = 0x7789
 
the screen for a while stays white but after some time shows something weird like this: (https://s11.postimg.org/qw11jl38j/IMG_4214.jpg)

and after a few seconds screen goes white again.

I use Arduino 1.6.8 and library is V2.90.

Sorry for my english and thanks in advance.

Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 11, 2016, 03:30 pm
I am surprised that your display ever worked at all!

These modules are 3.3V and you must use level converters with a 5V Arduino.

I found a datasheet for your NHD-2.4_240320cf-CTXI and it describes the pinout on the micro-ribbon.

Yes,  you can configure IM0 for 8-bit parallel.
Yes,  you can connect the data bus and control signals directly to a 3.3V Arduino like a Due, Zero, ...

And I would be 100% confident that my library would work fine with an undamaged display module.

Life is a mystery.   God invented the Arduino Shield and it was good.

Ebay sells the Shields very cheaply.   They mate with Uno, Mega, Leonardo, Due, Zero, ...
All the logic signals are correctly shifted to 3.3V.    The shields work well.

So why would anyone use a bare display module?

David.     
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: kiloWATT on Oct 12, 2016, 09:50 am
I'm not really surprised at all that it worked, because i do use level shifting on it (with 74act245 chips), i supply it with 3V3 and i do pull IM0 up for 8bit parallel control.
I use bare screen because i want to integrate it into a handheld device that i'm making.
I'm not using a shield because every time i order any type of TFT shield it turns out to be different driver, different ribbon connector and so on, also genuine NewHaven displays are better quality and without opening the box you know what kind of display driver, flat flex connector and display dimensions you will get.

So i really don't think that i damaged the screen in any way (especially cuz it shows the driver id).

Do you have any other possible reasons why it would not show anything?

Thanks for your time.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 12, 2016, 10:54 am
As far as I can see, the 74act245  chips are not input voltage tolerant.
Most of the Ebay shields contain 74HC245 which are also wrong.   (not input voltage tolerant)

If you want to use with a 5V AVR,  you need a 74LCX245 or similar tolerant version.
Mind you,  the Ebay shields do "work ok" with the HC245.

I have many different "Mcufriend Uno" shields with many different controllers.    The library code works with all of them.

I would like to see your actual schematic before I make any comment on your display.

David.
Title: Re: MCUFRIEND_kbv Library for Uno Shields
Post by: lana726 on Oct 13, 2016, 12:29 pm
Hi there,

Firstly I'd like to thank you for this library! I have been trying to get my 3.5" TFT LCD shield to work for days but nothing was working. Finally the examples and graphics test's are being displayed.

However all I want is to display .bmp files and when I try the example code it doesn't work. The photos are on the SD card.

- I am using Arduino Uno
- ILI9481  320x480  ID=0x9481  this LCD shield that plugs directly into the Uno.
- the code is just the same as the example code 'showBMP_kbv_as7'

The screen shots attached below are of my serial monitor and red messages when uploading.

The LCD screen goes white and then blue when uploaded.

Please help me fix this. Thanks
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Oct 18, 2016, 03:36 pm
Hi David,

I got a new 3.95" AliX display. It was cracked so I quickly got a full refund so I'm happy.

It is a 480*320 display but only paints 320*240 (top left hand side in each rotation).

Even though it paints 320*240 it scrolls 480*320   :(

I've had a play and could happily forget it but am happy to pursue it if you wish.

The LCD_ID_readreg is... (more follows)

reg(0x0000) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 FF FF FF   Manufacturer ID
reg(0x0009) 00 00 61 00 00   Status Register
reg(0x000A) 08 08   Get Powsr Mode
reg(0x000C) 66 66   Get Pixel Format
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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) 01 01   Inversion Control
reg(0x00B6) 80 02 3B 00 00   Display Control
reg(0x00B7) 06 06   Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00   ILI9481, HX8357-B
reg(0x00C0) 80 25 00 00 00 00 00 00 80   Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00   GAMMA
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 FF   Power Control
reg(0x00D2) 00 00 00 01 00   NVM Read
reg(0x00D3) 00 00 77 96   ILI9341, ILI9488
reg(0x00DA) FF FF   RDID1
reg(0x00DB) FF FF   RDID2
reg(0x00DC) FF FF   RDID3
reg(0x00E0) F0 03 05 09 0C 0F 3E 77 4F 0F 17 17 21 23 00 00   GAMMA-P
reg(0x00E1) F0 03 05 09 0C 0F 3E 77 4F 0F 17 17 21 23 00 00   GAMMA-N
reg(0x00EF) 00 00 00 00 00 00   ILI9327
reg(0x00F2) CB CB CB CB CB CB CB CB CB CB CB CB   Adjust Control 2
reg(0x00F6) 1F 1F 1F 1F   Interface Control

The link (for what it is worth!?)....

https://www.aliexpress.com/item/3-95-inch-uno-R3-TFT-LCD-touch-screen/32690879856.html

I added the following lines to GLUE_Demo_480x320 to prove the point....

Code: [Select]

  for(rotate = 0; rotate <4; rotate++) {
    myGLCD.setRotation(rotate);
    myGLCD.clrScr();
  }
  myGLCD.setColor(255, 255, 255);
  myGLCD.setRotation(0);
  myGLCD.clrScr();

  myGLCD.setRotation(1);
  myGLCD.fillScreen(RED);

  myGLCD.setRotation(2);
  myGLCD.fillScreen(GREEN);

  myGLCD.setRotation(3);
  myGLCD.fillScreen(BLUE);


I'm happy to make a video(s) if you want me to?  ;D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 18, 2016, 03:55 pm
I suspect that the readID() is returning 0.   This will default to a 240x320  ILI9341.

You actually have a ST7796 controller.   The current Beta library should recognise it.   And every example should work 100%.

If the glass is broken,  the Touch will NEVER work.
If the glass is broken,  you should buy from better Vendors.    And think about giving your postman a Christmas bonus.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Oct 18, 2016, 04:57 pm
Okay, I'll go looking for the beta. The GLUE_Demo_480x320 does....

Code: [Select]
UTFTGLUE myGLCD(0x9488,A2,A1,A3,A4,A0);

Shouldn't that call in the 9488 logic?

Thanks for your library   :D

Edit: Just downloaded from Github....  Is this the beta?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 18, 2016, 05:06 pm
Yes,   download the ZIP from the Master branch.

UTFTGLUE will detect and use the correct controller automatically.
The constructor arguments are just dummies.    You could use anything you want.   It will be ignored.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: louwin on Oct 18, 2016, 05:13 pm
Yes, that worked   :D

Just tried to put a second Edit into my response but it got lost????

Your library never ceases to amaze me   :D   :D   :D

Thanks Again  :D
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumper on Oct 19, 2016, 10:37 pm
Hi, I can not use the library. From ebay seller page is one ILI9341 shield.

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) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 38 80 00   Manufacturer ID
reg(0x0009) 00 00 61 00 00   Status Register
reg(0x000A) 08 08   Get Powsr Mode
reg(0x000C) 06 06   Get Pixel Format
reg(0x0061) 00 00   RDID1 HX8347-G
reg(0x0062) 00 00   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 A6   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 02   Inversion Control
reg(0x00B6) 00 24 02 00 00   Display Control
reg(0x00B7) 00 00   Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00   ILI9481, HX8357-B
reg(0x00C0) 0A 0A 0A 0A 0A 0A 0A 0A 0A   Panel Control
reg(0x00C8) 40 40 40 40 40 40 40 40 40 40 40 40 40   GAMMA
reg(0x00CC) 00 00   Panel Control
reg(0x00D0) 00 00 00   Power Control
reg(0x00D2) 00 00 00 00 00   NVM Read
reg(0x00D3) 00 01 16 02   ILI9341, ILI9488
reg(0x00DA) 38 38   RDID1
reg(0x00DB) 80 80   RDID2
reg(0x00DC) 00 00   RDID3
reg(0x00E0) 00 22 23 25 08 10 14 40 7B 50 0B 1B 22 20 2F 37   GAMMA-P
reg(0x00E1) 00 0C 14 23 0E 14 15 36 59 46 0B 1F 27 1F 20 22   GAMMA-N
reg(0x00EF) 00 00 00 00 00 00   ILI9327
reg(0x00F2) 00 24 04 04 1E 00 00 00 00 00 00 00   Adjust Control 2
reg(0x00F6) 00 00 00 00   Interface Control
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 19, 2016, 11:09 pm
I have no idea what make or model this is.   It certainly is not an ILI9341.   
It looks as if it might be 240x296 instead of 240x320.

Is it 2.4", 2.6" or 2.8" ?
I suggest that you force tft.begin(0x9329) and report back.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumper on Oct 20, 2016, 10:16 pm
I have no idea what make or model this is.   It certainly is not an ILI9341.   
It looks as if it might be 240x296 instead of 240x320.

Is it 2.4", 2.6" or 2.8" ?
I suggest that you force tft.begin(0x9329) and report back.

David.
Thanks David, the "red" display is a 2.4 "of mcufriend. I used the library for SPFD5408 seems to work. I am a newbie in the world of arudino how can I force tft.begin (0x9329)? I would like to use your library.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 20, 2016, 11:03 pm
Well,  you managed to find the LCD_ID_readreg.ino sketch.

You can install the MCUFRIEND_kbv library either from the ZIP attached to message#0
Or directly from the Beta on GitHub.

All examples will do ID = tft.readID() in setup().   Then use the result to tft.begin(ID)
You simply use tft.begin(0x9329)

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumper on Oct 20, 2016, 11:11 pm
Well,  you managed to find the LCD_ID_readreg.ino sketch.

You can install the MCUFRIEND_kbv library either from the ZIP attached to message#0
Or directly from the Beta on GitHub.

All examples will do ID = tft.readID() in setup().   Then use the result to tft.begin(ID)
You simply use tft.begin(0x9329)

David.
Ok I managed to force the tft.begin (0x9329) with the graphictest_kbv sketch now works! thanks david!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 20, 2016, 11:41 pm
Your colours are inverted.  Call tft.invertDisplay(1) at the start of loop()

Please look at the colours, rotations, scrolling, etc.

It is reporting an ID of 0x8357.   I will correct this when I hear about colours etc.

David.   
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumper on Oct 21, 2016, 12:17 am
Your colours are inverted.  Call tft.invertDisplay(1) at the start of loop()

Please look at the colours, rotations, scrolling, etc.

It is reporting an ID of 0x8357.   I will correct this when I hear about colours etc.

David.   
I'm sorry, I reversed the colors, but it is normal that I see a vibration of lines on the display? and I noticed that it's the wrong rotation. I used setRotation to solve the right problem?
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 21, 2016, 12:30 am
No,   you just make a note of all the Problems.
e.g. Portrait is upside down
e.g. Landscape is wrong.
e.g. Red is painted Blue.
e.g. Software Scroll has error.
e.g. Text is mirrored
...

I can fix most problems.   I just want to know what they are.   So I can fix in one go.
I just suggested the invertDisplay() because everything looks horrible.   And Red definitely does not show as Red.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumper on Oct 21, 2016, 12:51 am

everything works except for the "vibrations" of the lines of the display and flip vertically. The colors are perfect.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 21, 2016, 08:55 am
That is why I asked for an accurate report.  e.g.
Portrait displays as Portrait_rev.  (I saw from your inverted JPEG)
Landscape is vertical mirror
... is horizontal mirror.

It would take you 5 minutes of your life.
A video would be ideal.  Words are not that difficult to type.

Yes,   we could sort out any display jitter.    Again,   this requires your effort to type accurately or video.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumper on Oct 21, 2016, 02:39 pm
Hello David, I made the video of graphictest. I modified the sketch using tft.invertDisplay (1).

https://www.youtube.com/watch?v=WM6qzcEW8dk (https://www.youtube.com/watch?v=WM6qzcEW8dk)
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 22, 2016, 01:50 pm
Thanks for the video.   The problems are:
1.  all aspects are wrong by 180 degrees
2.  No Software Scroll because readPixel() = 0
3.  Inverted Colours (you have corrected with invertDisplay() )

4.  the display is streaky.  Difficult to see with the plastic film in place.

Please go to GitHub.  
Replace your mcufriend_kbv.cpp with the one in the "test_3880" branch.
The library should recognise ID of 0x3880
Remove your "forced" ID.   Remove your invertDisplay() call.
Remove the plastic film.

Please confirm whether the aspects are corrected.   Does Software Scroll work?

If you got a better display with your other library:
Which "SPFD5408" library?   Please post a link.   There are several "hacked" versions of Adafruit_TFTLCD.    Your controller would definitely NOT work with SPFD5408 commands.

I would like to see what Power settings were used.

Otherwise,  I will post a sketch that tries several settings for you to judge the "best".

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumper on Oct 22, 2016, 03:24 pm
I replaced mcufriend_kbv.cpp with test_3880. I removed ID, invertDisplay (), plastic film. Now ID is ok. the display is ok now the colors are now ok but the readPixel () = 0 and remain the "vibration" of the lines.

video test2 (https://www.youtube.com/watch?v=17GM1_cTMgs)

The SPFD5408 library is located here (https://github.com/JoaoLopesF/SPFD5408) but it is slower and remain the "vibration" of the lines. Can not see the Scroll Software.

I use for this display an Arduino clone with USB power.

It remains to solve the "vibration" if you can.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 22, 2016, 04:10 pm
The aspects are correct.   The Scroll directions are wrong.  The Band Scroll is in the wrong place.    ReadPixel() is still wrong.

I will post something later.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumper on Oct 22, 2016, 08:08 pm
Ok David.  Thanks
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 23, 2016, 12:05 am
Your readreg report seems to use different Power, VCOM, Display registers to Ilitek.

Please can you edit the LCD_ID_readreg.ino sketch setup()
Code: [Select]

    ...
    lcdInit();
    lcdReset();      //ensures that controller is in default state
    for (uint16_t i = 0xB0; i < 256; i++) readReg(i, 7, "f.k");
    ...

This might give me a clearer idea of the Manufacturer's registers.   (0xB0 .. 0xFF)

Please can you also run the readPixel_kbv.ino sketch.
Take a photo of one Blue screen and one Black screen.   There is no need for a video.

You must understand that guessing without a datasheet is difficult.   Guessing remotely is even harder.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumper on Oct 23, 2016, 08:15 pm
Thanks David! . Always with the MCUFRIEND_kbv test_3880.


Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: vagos21 on Oct 24, 2016, 05:31 pm
Hello david,

i've used the pushColors function before, and i know it takes a buffer of bytes. i decided to write my own sd card driver since i couldn't use any GPL libraries for a commercial product. the driver itself is a success till now, i made my own filesystem and can succesfully read all entries and block offsets in it, the problem is:

each block on the SD card is 512 bytes (so i guess 256 pixels of RAW565 format?)

if i just read block by block(this is how the cards work) into a 512 byte buffer and then

Code: [Select]
tft.pushColors(blockBuffer, 512, first);

it theoretically loads the first 256 pixels of the image to my LCD, right?  but somehow it draws 512 pixels... am i missing something double somewhere?

thank you!
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 24, 2016, 05:52 pm
Look at the prototypes of the different (overloaded) methods e.g.
Code: [Select]

void     pushColors(uint16_t *block, int16_t n, bool first);
void     pushColors(uint8_t *block, int16_t n, bool first);
void     pushColors(const uint8_t *block, int16_t n, bool first);


So if blockBuffer is declared as:
Code: [Select]

uint16_t blockBuffer[];

it will use the first method.

So if blockBuffer is declared as:
Code: [Select]

uint8_t blockBuffer[];

it will use the second method.

So if blockBuffer is declared as:
Code: [Select]

const uint8_t blockBuffer[] PROGMEM;

it will use the third method.

Since the second argument in the tft.pushColors() method is the count of array elements,   it would be 512 uInt16_t or 512 uint8_t depending on which overloaded method is used.

This is all regular C++ that you can read in the textbooks.

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: vagos21 on Oct 24, 2016, 06:31 pm
shhhh man what can i say... i used the 2nd overload, so i switched 512 to 256 elements and... it works like a charm!!! i owe you a STATUE my friend thank you! :))))
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: anand_tiwary on Oct 25, 2016, 09:11 am
i want to connect an led with arduino so that if i send some message from the serial monitor it displays on the screen and the led glows at te same time...which pin can i use ...plz help me..

Thank You
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 25, 2016, 09:46 am
You already have an LED on digital #13 of most Arduinos.

If you are not using the SD,  you can use #10-#13, #A5 on a Uno.
A Mega2560 has obviously got plenty of spare pins.

Quite honestly,  you would be better off with the TFT.   e.g.  draw a different coloured disk or square when you receive a character.

Think about what is convenient for the User.    If she is reading the text that is beng printed on the TFT screen,   she does not want to go looking for an LED (that is underneath the Shield).

David.
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: Dumper on Oct 26, 2016, 07:05 pm
hello david what's new for my display? I would not bother ... otherwise use the library with the latest changes
Title: Re: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields
Post by: david_prentice on Oct 26, 2016, 09:03 pm