Go Down

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

david_prentice

You have a 0x1602 controller.

From extras/mcufriend_how_to.txt
Code: [Select]

UNKNOWN  240x320  ID=0x1602 readGRAM() does not work


The v2.9.8 Library Release should work.   (i.e. what the Library Manager installs)
The Beta on GitHub might give you slightly better colours.

I have no idea who makes this controller.   If I could find a manufacturer and part number I migt be able to get a datasheet.

David.

tunikovski

I tried but it didn't work, do I need to change something in the library? I'm sending some specifications that I found, I bought it on a site that probably buy from Aliexpress


david_prentice

@tunikovski,
 
Please do not try to dismantle your shield.   You may damage it.

The shield has a screen on one side.   It has a Red pcb with male header pins on the other side.

The 0x1602 screen should "work" with Release v2.9.8 but it looks streaky.   VERTICAL SCROLL direction is wrong.

If you use the Beta from GitHub the streakiness is reduced.  The SCROLL direction is correct.

Whether you bought from Ebay, AliExpress, local website, ... you will have a link to the shop.
I would like to see the pcb.   I would like to see components and printed legends e.g. 74HC245, AMS1117, printed www.mcufriend.com

David.

tunikovski

Its ok, the components are the 2 TM74HC245 and a regulator AMS1117 H148

tunikovski

Every example  i tested with mcufriend library, stays with white screen

david_prentice

Thanks for the photo of part of your pcb.
That specific section of pcb matches the pcb on my desk exactly.   i.e. same components,  same copper traces.

Of course I can't see RP1 and the associated copper traces.
I can't see "www.mcufriend.com"
I can't see "2.4" TFT LCD  SHIELD"

I don't know what library version(s) you are using.
I don't know what ID was reported by the Library Manager

Seriously.   There are several diagnostic sketches in the examples.
Even if you only get a white screen,  the sketches often report to the Serial Terminal.

The good news is that you have an AMS1117 regulator.
You may have damaged the screen when you pulled it apart.
Reassemble carefully.   Use fresh double-sided sticky foam tape.

It looks as if 0x1602 has been supported since v2.9.2-Beta i.e. Jan 2017
I would expect you to see the display with tft.begin(0x9329)

David.

tunikovski

I use 2.98 version, sorry i thought it was sended to you the pcb, the display its ok, no damage, i opened the mcufriend.cpp and i uncommented the line 17 to try again, "#define SUPPORT_9326_5420"

but doens't works, i tested with another library and force tft.begin (0x9329) and still white, i think when i bought came with display damage, on serial shows like it's working, thank you for your support, i will try again and again :(, if you have the idea what i do, i attach the pcb

david_prentice

Thanks for the full photo.   That was easy.   Your pcb is exactly the same as the one on my desk.
A picture is worth a 1000 words !!!

Your readreg report looks the same as mine.

I presume you have tried the shield on different Arduinos e.g. Uno, Mega, Due, ...


If you still get a White screen I suspect you just have a damaged shield.   And it is too late to ask for your money back.   Just buy a new one (which will probably omit the AMS1117)

David.

DaveHammers

Hello David,

I very much enjoy the use of your "diagnose_tft_support" program. It works great for me with a "2.4 mcufriend" tft shield I have and I can plink around with your testing examples.

 Now, I would like to use an ESP32 module because it has 3.3v . I want to do testing of 8-bit i8080, 3.3v-only lcd panels. Your program is the best one out there I've found for 8-bit mcu interface, so I'd like to use your code, but I'm not in the shield form factor any more. Is there an easy way to setup my own custom pins? I have enough pins, and can control them with Blink, but they're numbered different.

I have pins 2, 4, 5, 12, 13, 14, 18, 19, 21, 22, 23, 25, 26, 27,  silkscreened and easily available to me as a user. I've verified pin 2 (built-in led), 5, and 27 with a blink program, that is, i did digitalWrite(5, HIGH) and pin 5 lit up, etc.

The board itself is one of those little 30-pin ESP32-WROOM devkit boards that are commonly available these days.  This website has some info: https://circuits4you.com/2018/12/31/esp32-devkit-esp32-wroom-gpio-pinout/ , I have the 30-pin variant.

I tried to modify the sketch but couldn't figure out where exactly those default pins were set...

I suppose basically a big brick of commented out //#defines at the start of "diagnose_TFT_support.ino" would solve my problem.

Thanks for the free software!
PUBLIC DOMAIN

david_prentice

I strongly advise you to use the TTGO D1 R32 board (and make the minor hardware mods)

Shields will mate with the Arduino headers on the TTGO D1 R32 board.
It will use the default pinout from mcufriend_shield.h

If you want to use a bare display module ( with just a flexi-ribbon ) you must connect all the signals correctly.

David.

 

DaveHammers

>mcufriend_shield.h

Okay, I got it working. Clean register dumps now with that same shield, just omitted the 5v supply. Now I'm ready for the fun stuff. If you use that pinout you don't have to modify the code at all.

Public Domain
PUBLIC DOMAIN

DaveHammers

Project success!

I routed "strongly advise to buy additional bulky hardware with long shipping time" to /dev/null, but from reading the other types of posts you get I can understand why you'd say that to a new account and it's no problem. (Actually I did take your advice and ordered one, but I wasn't willing to stop working in the meantime.)

I deeply appreciate the many levels of user-friendliness you built into the serial terminal outputs, giving suggestions on which ID to try to force next, as well as the general, heavily commented nature of your code. Taken together, these aspects were very helpful for someone who's more used to "programming" with a soldering iron.

In case you were wondering, I was able to use your code to diagnose two panels pulled from mysterious Aliexpress electronics. They are both write-only panels compatible with the 0x7789 codepath.


Great software with a great license!
PUBLIC DOMAIN

mnik

Hi, I am new in C++ and my English not so good, so I apologize in advance. I am using your library for TFT 2.8" with HX8347G, 3.2" with ILI9327 and 3.5" with ILI9486 on Mega. First two have different pin configuration then last one, so I made correcion in your code (mcufriend_shield.h) to accept ports B, G and H instead of E, G and H (usiing #ifdef), to make all of them works. Next correction I made is modify readReg40 function so it returns only lower 16 bits, because readID function tests only 16 bits values. Now it recognise all my graphic controlers. Another correciton is in function fillRect. In my oppinion, there is small error when testing (w<0) and (h<0):
if (w < 0) {
        w = -w;
        x -= w - 1;        // MN: old equation: x -= w;
    }
and
if (h < 0) {
        h = -h;
        y -= h - 1;        // MN: old equation: y -= h;
    }
Without adding -1, for negative length, start and end position are moved 1 pixel in negative direction and in that case, starting point is excluded. This made me many problems trying to make fast line and circle drawing. With this correction, starting point is always included, and length is not changed. On example, in positive direction, for length of 5, first point is 0 and last is 4, and for negative direction, first point is also 0 and last is -4 (in original, negative length gives points in range -1 to -5).
Now, I made my version of writeLine (non H/V). Any such line is composed of small H or V parts with length of minimum 1 (or single pixel). In my version of writeLine, I didn't draw every pixel one by one, but counting how many pixels has current direction (H or V). Only when X and Y are both changed, then I call drawFastHLine, or drawFastVLine (depending on direction). In this way, I get almost two time faster writeLine exceution. The same I used in drawCircle function, so I have much faster drawing then original function. The same I used in fillCircle, drawRoundRect, fill RoundRect etc. Now, I made my class based on MCUFRIEND_kbv, with additional functions drawEllipse, fillEllipse,k drawPie and fillPie.
Here is some tests:

TFT 3.2"
ID = 0x9327                      MCUFRIEND_kbv     my version

Test: FillScreen                 1.208512 s       1.208512 s
Test: Text                        0.241844 s       0.242124 s
Test: Lines                      12.522761 s       6.372436 s
Test: Horiz/Vert Lines          0.108264 s       0.108360 s
Test: Rectangles (outline)    0.063036 s       0.063092 s
Test: Rectangles (filled)       1.526200 s       1.526228 s
Test: Circles (filled)             0.690836 s       0.511844 s
Test: Circles (outline)          1.306424 s       0.645500 s
Test: Circles 2 (outline)        0.568408 s      0.254412 s
Test: Circles 2 (filled)           0.680088 s      0.610644 s
Test: Triangles (outline)        0.523948 s      0.290940 s
Test: Triangles (filled)           1.137668 s      1.134044 s
Test: Rounded rects (outline) 0.640492 s      0.301240 s
Test: Rounded rects (filled)    2.132796 s      2.078888 s
------------------                                 
Ellipse (outline)  - skiped                            0.345344 s
Ellipse (filled)   - skiped                              0.758544 s
Arc (outline)      - skiped                            0.390500 s
Pie (outline)      - skiped                             2.052564 s
Pie (filled)       - skiped                               2.340308 s
------------------
I have never work with GitHub, so if this is usable, I would preffer to send my code to somebody who knows what to do with it.

david_prentice

Thanks for your comments.    I have always assumed that w and h are positive in any valid code.
The sign change was to catch "mistakes"

Please can you post your readReg40 function

I would put any "non-standard" wiring into mcufriend_special.h
mcufriend_shield.h is for regular shields.
Which screens are you using?   e.g. post links to Ebay sale(s)

These technical issues are best posted on GitHub "Issues" but it is fine to post on this Forum if you find it easier.

Yes,  there are several graphics functions that can be speeded up.    I just inherit Adafruit_GFX class.
Are you using the Beta from GitHub?
Or the v2.9.8 Release installed by the IDE Library Manager?

David.

mnik

I am using version 2.99 from GitHub. My displays are (from wish.com):
3.2" (ILI9327), with TouchScren
https://www.wish.com/product/5b066ce79fad4248c8dad194

3.5" (ILI9486)
https://www.wish.com/product/58768fc06dd28e28363b5ac5

2.8" (HX8347G), with TouchScren
https://www.wish.com/product/5b3608e17beacb052637efe6

My modifications in mcufriend_shield.h are in section for Mega 2560/1280, and it is used for 2.8" and 3.2" TFT:

#ifdef UNO_PINS                                 // I put #define UNO_PINS in MCUFRIEND_kbv.h
#define RD_PORT PORTF
#define RD_PIN  0
#define WR_PORT PORTF
#define WR_PIN  1
#define CD_PORT PORTF
#define CD_PIN  2
#define CS_PORT PORTF
#define CS_PIN  3
#define RESET_PORT PORTF
#define RESET_PIN  4

#define BMASK         0xB0
#define GMASK         0x20
#define HMASK         0x78
#define write_8(x)    { PORTH = (PORTH & ~HMASK) | (((x)&B11000000)>>3) | (((x)&B00000011)<<5); \
                        PORTB = (PORTB & ~BMASK) | (((x)&B00101100)<<2);                        \
                        PORTG = (PORTG & ~GMASK) | (((x)&B00010000)<<1);                        \
                           }

#define read_8()      ( ((PINH & B00011000) << 3) | ((PINB & B10110000) >> 2) | \
                        ((PING & B00100000) >> 1) | ((PINH & B01100000) >> 5)   \
                      )
#define setWriteDir() { DDRH |=  HMASK; DDRG |=  GMASK; DDRB |=  BMASK;  }
#define setReadDir()  { DDRH &= ~HMASK; DDRG &= ~GMASK; DDRB &= ~BMASK;  }
#else
// now, here is your original code, with ports E, G and H
#endif

For function readReg40, I just modified what it returns:
return (((uint32_t) h << 24) | (m << 8) | (l >> 8)) & 0xffff;  // only lower 16 bits

(I don't know why smiley instead of eight!)

Milan

Go Up