Go Down

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

rainwulf

Hi David, i'm back again. No issue this time, however i'm wondering if there is a way to reduce the memory footprint of the lib. I have commented out every single board that ISN'T the one i'm using, and i also managed to save a good 2k just by simply not using ReadID.

Currently my fairly simple sketch of reading serial data, writing it back, clearing the screen and setting rotation is using 8610 bytes of flash. On a uno, thats a fair amount of flash i want to use for the actual graphics routines i plan on writing.

Only using 323 bytes of ram, and i know a chunk of that is the serial buffer. So, ok on the ram for now.

The source file is 120kb in length due to its huge support of various displays, just wondering if there is anything i can comment out to save some flash.

Thank you though for your excellent library. Do you have a donate link for some cash?


Edit: Managed to cut down from 8610 in my lib to 7360, and shaved .30 seconds of the graphics test as well.
Does the full test in 6.72 instead of 7.02.
Will continue to work on it, but basically i cut out any non UC8230 code out of the library, so its now only dedicated to my shield.


david_prentice

You can reduce Flash memory by avoiding the String class and avoiding f-p maths.

You can reduce library Flash memory by removing support for other controllers.

David.

rainwulf

Thanks David, i went through your cpp file and managed to take it from 120kb down to 23kb, and basically murdered your library heh.

I found a bit of speed and space saving in the setaddrwindow and setrotation routines.

Found a bug in your touchscreen example too.



Line 152 reads as:

ypos = map(tp.y, TS_LEFT, TS_RT, 0, tft.height());

it should be:

ypos = map(tp.x, TS_LEFT, TS_RT, 0, tft.height());


Thank you for your hard work, the library is an absolute behemoth of defines. I wouldn't even know how you manage that thing haha

david_prentice

Thanks David, i went through your cpp file and managed to take it from 120kb down to 23kb, and basically murdered your library heh.

I found a bit of speed and space saving in the setaddrwindow and setrotation routines.

Found a bug in your touchscreen example too.



Line 152 reads as:

ypos = map(tp.y, TS_LEFT, TS_RT, 0, tft.height());

The size of source code and the size of binary are two different things.
Yes,  you can strip out everything not required for UC8230.   I guess you can reduce it to about 2kB binary.    Note that Adafruit_GFX and Print have got lots of different methods.   Fonts, f-p maths and Graphics can use a lot of Flash.

The Linker is pretty clever.   It only links methods that are actually used.

Thanks for the bug report in Touch_Shield_new.ino
It has been fixed in the Beta on Dec 30, 2018

David.

JaKyl

Hello. I'm having difficulties with getting my TFT touchscreen to work. It is a shield type packaging, ordered from China, and there wasn't any documentation supplied.

The screen is fully white most of the time. Running graphics test sketches may cause some faint flickering, ie. going from fully white to very slightly less darker, but that's about it. There is no recognizable text, colors or patterns to speak of.

I've posted an image of my shield as an attachment. The print on it says the driver IC is HX8347G. Then running your diagnose sketch finds an ID of 0x5151. I've tried to Google such an ID, but found practically no mention of it anywhere, so I'm wondering. I've tried re-uploading sketches after uncommenting the relevant support line for HX8347-G  (SUPPORT_8347D) in MCUfriend_kbv.cpp, but that did not help.

The received product differs slightly from the image on the purchase page, for example, the driver IC on the shop image is ILI9341 while mine is HX8347G, and the product I received has a few additional SMD components. The screen model should be RM68090, I think, according to shop product title.
https://www.gearbest.com/lcd-led-display-module/pp_009457705069.html

I can tolerate the differences, if it's still possible to get this one to work.

Also, here is the ReadReg sketch output:
Quote
reg(0x0000) 00 00   ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 04 04 04 04   Manufacturer ID
reg(0x0009) 08 08 08 08 08   Status Register
reg(0x000A) 08 08   Get Power Mode
reg(0x000C) 0C 0C   Get Pixel Format
reg(0x0061) 20 20   RDID1 HX8347-G
reg(0x0062) 20 20   RDID2 HX8347-G
reg(0x0063) 20 20   RDID3 HX8347-G
reg(0x0064) 24 24   RDID1 HX8347-A
reg(0x0065) 24 24   RDID2 HX8347-A
reg(0x0066) 24 24   RDID3 HX8347-A
reg(0x0067) 24 24   RDID Himax HX8347-A
reg(0x0070) 20 20   Panel Himax HX8347-A
reg(0x00A1) 20 20 20 20 20   RD_DDB SSD1963
reg(0x00B0) 20 20   RGB Interface Signal Control
reg(0x00B4) 24 24   Inversion Control
reg(0x00B6) 24 24 24 24 24   Display Control
reg(0x00B7) 24 24   Entry Mode Set
reg(0x00BF) 2C 2C 2C 2C 2C 2C   ILI9481, HX8357-B
reg(0x00C0) 02 02 02 02 02 02 02 02 02   Panel Control
reg(0x00C8) 0A 0A 0A 0A 0A 0A 0A 0A 0A 0A 0A 0A 0A   GAMMA
reg(0x00CC) 0E 0E   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(0x00D4) 04 04 04 04   Novatek ID
reg(0x00DA) 08 08   RDID1
reg(0x00DB) 08 08   RDID2
reg(0x00DC) 0C 0C   RDID3
reg(0x00E0) 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30   GAMMA-P
reg(0x00E1) 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61   GAMMA-N
reg(0x00EF) 2C 2C 2C 2C 2C 2C   ILI9327
reg(0x00F2) 20 20 20 20 20 20 20 20 20 20 20 20   Adjust Control 2
reg(0x00F6) 24 24 24 24   Interface Control
I don't know if this is bogus, or if there are supposed to that many identical values on each line.

Any insight is much appreciated.


david_prentice

Thanks for the JPG.   It shows an Open-Smart board.

From extras/mcufriend_how_to.txt
Code: [Select]

19. OPEN-SMART Shields have different wiring to regular Uno Shields:
    Edit utility/mcufriend_shield.h:  #define USE_SPECIAL
    Edit utility/mcufriend_special.h: #define USE_OPENSMART_SHIELD_PINOUT
    Edit MCUFRIEND_kbv.cpp:           #define SUPPORT_8352B


In your case you have HX8347G.   So you would do
Code: [Select]

    Edit MCUFRIEND_kbv.cpp:           #define SUPPORT_8347D



Open-Smart do print the controller model name on the pcb.
Mcufriend pcbs often contain a different controller regardless of any printing.

Please let us know how you get on.

Incidentally,   I think that the diagnose_TFT_controller example would advise about Open-Smart wiring.

David.

JaKyl

The additions in your first quote worked indeed! The #define SUPPORT_8347D I had already enabled previously.

Thank you very much David, and I'm sorry; I now realize should have been able solve this as the instructions were already there (the textfile just didn't catch my eye).

JaKyl

I've been testing the GFX functions on my intended project, and now I have a small follow-up question:

I've noticed the backlight level seems to fluctuate when the display contents are being modified (the write commands consuming some of the available power, I think). For example, drawing fillCircles somewhere in the display dims the entire display area somewhat.

While this obviously isn't a huge issue, I thought I'd ask if there's a way to reduce this.

david_prentice

Look at the part numbers on the buffer chips.   The 8352 schematic says 74HC245.  Your photo shows 74HC245.

They should really be 74LVC245 but very few shields use the correct chips.
At least your board has AMS1117-3.3 regulator of adequate size (U3).

David.

Mode30

Hi,I'm using : MCUFRIEND_kbv Library from a while to my uno 3.5" display and works really nice.
Now,I'm using  stm32 bluepill but I want PA0,PA1,PC14,PC15,PB6,PB7,PA9 &PA10 for other things.
Finding hard time to change the 8 data pins .please help.

david_prentice

I recommend that you use the standard BLUEPILL wiring:   (it works out of the box)
Code: [Select]

//LCD pins  |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |RD |WR |RS |CS |RST| |SD_SS|SD_DI|SD_DO|SD_SCK|
//STM32 pin |PA7|PA6|PA5|PA4|PA3|PA2|PA1|PA0| |PB0|PB6|PB7|PB8|PB9| |PA15 |PB5  |PB4  |PB3   | **ALT-SPI1**

Or the MY_BLUEPILL wiring in mcufriend_special.h (requires editing files e.g. deleting two slashes)
Code: [Select]

//LCD pins  |D7  |D6  |D5 |D4 |D3 |D2 |D1  |D0 | |RD |WR |RS |CS |RST| |SD_SS|SD_DI|SD_DO|SD_SCK| |SDA|SCL|
//STM32 pin |PA3 |PA2 |PA1|PA0|PB7|PB6|PA10|PA9| |PB1|PB0|PA7|PA6|PA5| |PB12 |PB15 |PB14 |PB13  | |PB9|PB8|

Or choose one of the custom wirings in extras/unused/mcufriend_special2.h

If you have a valid reason for something different.     
1. Edit the defines in LCD_ID_readreg.ino for your custom wiring.
2. Connect according to your plan. 
3. Verify that   LCD_ID_readreg.ino reports correctly.
4. Paste the LCD_ID defines to your message.   
5. Paste one or two lines from LCD_ID report to show that you actually verified it.
6. If you complete (1) to (5) I will write the appropriate SPECIAL for you.

David.

Mode30

Yes  David,standard BLUEPILL works out of the box.I tried that.
But I'm doing abit different.
I'm working with a 3.5" ips display 40 pin .
I tried 8bit. Working fine.it seems a lot faster then spi,but it uses all the analog pins.
I want at least 2 analog pins for the touchscreen because I want to use totally separate pins for xp,xm,yp,ym..
I also need i2c for Rtc or BME280.
I want rx,tx free .

I don't know how to Verify that   LCD_ID_readreg.ion
But my lcd is ili9481


Ill try today let's see how it goes.

Regards

david_prentice

I'm working with a 3.5" ips display 40 pin .
Most of these have 8080-16 parallel interface for the TFT.
And have an XPT2046 SPI Touch controller chip.

Post a link to the actual display.    With photo of pcb.

David.

Mode30

David, display with no pcb and no touch driver.
I' tried everything with mcufriend works everything.
Just need to change the pin for the 8bit .

Regards

david_prentice

You have a ribbon to SIL Adapter.    So you know the ribbon pinout.    The Ribbon SMD links must be configured for 8080-8 interface.

I gave you a clear list in #2725.

You complete your part of the bargain.
I will complete my part.

David.

Go Up