UTFT library with R61581 and 3.6" TFT 400x270

Empty as prior draft was posted as well as latest draft that follows.

I recently purchased a 400x270 3.6" TFT display shield for Mega2560.
It uses a R61581 driver chip. Be aware that others have found different driver chips installed.

After reading many threads, and trying many settings, it became obvious that the UTFT library was not setup for this board. The screen was mirror inverted, and flickered horribly.
I have managed to get the display to work properly… except it is not bright enough.
The hardware brightness using PWM is not used on this display shield.

When I upload new code to my mega2560, the white screen presented during reset is about four times brighter. This leads me to believe there is something not right with the UTFT myGLCD.clrScr(); and or the RGB layers added to a base brightness value.

Anyone have similar experience?

I found a data sheet for the R61581 here, and used it to modify the r61581/initlcd.h file.
This link to Dropbox is the modified UTF Library.

// UTFT_Demo

// This demo was made for modules with a screen resolution 
// of 400x270 pixels.
//
// This program requires the attached UTFT library.
//


#include <Arduino.h>
#include <Streaming.h>   // Serial.print alternative

#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];
// extern uint8_t LargeFont[];
// extern uint8_t hallfetica_normal[];

// Set the pins to the correct ones for your development shield
// ------------------------------------------------------------

// Arduino Mega:
// -------------------
// Standard Arduino Mega/Due shield            : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Mega      : <display model>,38,39,40,41
//
// Remember to change the model parameter to suit your display module!
UTFT myGLCD(R61581,38,39,40,41);

//Don't need these
#define DISABLE_HX8347A
#define DISABLE_HX8352A
#define DISABLE_ILI9327
#define DISABLE_SSD1289
#define DISABLE_ILI9325C
#define DISABLE_ILI9325D
#define DISABLE_ILI9325D_ALT
#define DISABLE_HX8340B_8
#define DISABLE_HX8340B_S
#define DISABLE_ST7735
#define DISABLE_ST7735_ALT
#define DISABLE_S1D19122
#define DISABLE_PCF8833
#define DISABLE_SSD1963_480
#define DISABLE_SSD1963_800
#define DISABLE_SSD1963_800_ALT
#define DISABLE_S6D1121
#define DISABLE_ILI9481
#define DISABLE_S6D0164
#define DISABLE_ST7735S
#define DISABLE_ILI9341_S4P
#define DISABLE_ILI9341_S5P
#define DISABLE_ILI9486
#define DISABLE_CPLD
#define DISABLE_HX8353C

void setup()
{
  randomSeed(analogRead(0));
  
    Serial.begin(115200);
    
// Setup the LCD
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);

  //Serial <<  R61581_ALT << endl;
  //Serial <<  myGLCD.getDisplayXSize() << endl;
  //Serial <<  myGLCD.getDisplayYSize() << endl;
 // Serial <<  myGLCD.getxFerMode() << endl;
 
 // Clear the screen and draw the frame

  
//  myGLCD.lcdOff();
//  myGLCD.setBrightness(255);
//  myGLCD.lcdOn();
      
myGLCD.clrScr();
myGLCD.setColor(255,0,0);
myGLCD.fillRect(0,0,399,269);
  
  
  myGLCD.setBackColor(VGA_RED);
  myGLCD.setColor(VGA_WHITE);
  myGLCD.print("1234567890123456789012345", LEFT, 224);
 
}

void loop()
{
  // Do nothing
}

What leads you to believe is is 400x270? I'd bet it is anything but.

400x240 or 480x320 are the two different resolutions that board has appeared in. The R61581 version is typically 480x320 and can usually be identified by counting the resistor sip packs on the back of the board - IIRC it has 8 10k sips. The 400x240 has an ili9327 chip with 6 each 10k resistor sip packages on the back of the board.

The 480x320 display is setup with a 16 bit data path, the 400x240 is 8 bit which explains why the 480x320 board needs two extra resistor packs as there are 4 resistors per pack, all in series with the data lines. In either case UTFT will need mods to work correctly with the boards. I have a modified version of UTFT that works with the 400x240 board, you can find a copy on a previous thread about these boards. http://forum.arduino.cc/index.php?topic=282144.msg1982590#msg1982590

My board has 7 10k packs in a row and two others off to the side. The seller says it is 400x270, but I now know from drawing rectangles it is definitely 400x240.

I definitely have the R61581 chip and 16 bit. It is the only init that would work at all. I initially tried your modified UTFT but as I said it is not a ILI93278.

My remaining problem is a very dim display.

Also bought the same board lately. I tested with some libraries available on the internet, however I did not succeed with any of them.

rdinallo Did you try the library I linked to in my second message?

I tried, however also did not work. The screen is all white.

1 Like

Some display problems were caused by insufficient power supply, probably you've tried that already?

George Matthews! I bought R61581 and 3.6" 400x270 TFT LCD from this link http://www.aliexpress.com/item/Free-shipping-LCD-module-TFT-3-5-inch-TFT-LCD-screen-for-Arduino-MEGA2560-Board/1766509567.html?spm=0.0.0.0.PRP0P5

It was developed by www.mcufriend.com It's not officially supported by UTFT. It arrives at home in 24 hours. I will test it tommorow. I will test it soon.

In my case when I run example code with "UTFT myGLCD(R61581,38,39,40,41); //modified code", it flickers too much. I read some threads and I use "UTFT myGLCD(ILI9327,38,39,40,41); //modified code", it never flickers. works perfact . I used origial UTFT library from http://www.RinkyDinkElectronics.com/

it seems that my lcd's controller is ILI9327 not R61581. Screen no more flickers, background is black, not white.

I ignored seller's spec, and believed manufacturer's spec. It's resolution was 400,240.

The attached libraries may be worth trying.

Examples are in the ‚ÄúAdafruit_R61581_AS‚ÄĚ library.

Both libraries are needed, Adafruit_GFX_AS is a support library that provides the graphics functions and fonts.

There may be some bugs but the examples all run OK.

As the display is 16 bit parallel access the graphics can be drawn quite quickly so animated graphics are possible, (see ‚ÄúMeter_demo_R61581‚ÄĚ example sketch).

More details on the library (for different TFT displays but otherwise valid) here.

The library name is a bit misleading as I initially created it for the R61581 as this was the advertised driver chip…, then found the driver chip is actually a ILI9327 so I just hacked the initialisation code without renaming it… so this library is actually for the ILI9327 based 400 x 240 (advertised as 400 x 270!) displays…

TFT_400x240.zip (51.3 KB)

OR, buy an ACTUAL R61581 480*320 display with font ic made by Coldtears which DOES work with the UTFT libraries by Henning. Sadly it appears the CTE supplied library to drive the Font functions does not work, but I am on the case developing it so it does right now, naturally including all of the enhancements mentioned in my thread relating to Coldtears Font IC development.

The photo below shows what the Coldtears R61581 display with Font IC looks like :wink: :stuck_out_tongue:

100_0593.JPG

Regards,

Graham

biablo: George Matthews! I bought R61581 and 3.6" 400x270 TFT LCD from this link http://www.aliexpress.com/item/Free-shipping-LCD-module-TFT-3-5-inch-TFT-LCD-screen-for-Arduino-MEGA2560-Board/1766509567.html?spm=0.0.0.0.PRP0P5

It was developed by www.mcufriend.com It's not officially supported by UTFT. It arrives at home in 24 hours. I will test it tommorow. I will test it soon.

That is the same one I have based on the pictures. Quite a reasonable price at $8.55.

Anyone got the touch screen working?

The touch display works! (Almost...)

I thought I would try UTFT and the UTouch library with this display, despite the fact that is was advertised as having an R61581 driver (actually ILI9327) and 400 x 270 (actually 400 x 240), The advert made no mention of a touch screen, yet it clearly has one with the 2040 controller soldered to the board and ribbon pigtail that indicates a touch screen is fitted.

To cut a long story short, I tried the UTouch_Calibration sketch and guessed at the touch pin connections.

To my surprise it worked first time, printed instructions to the screen and accepted the calibration point presses!

Here are the relevant settings I used in the UTouch_Calibration sketch:

UTFT myGLCD(ILI9327,38,39,40,41);

UTouch myTouch( 6, 5, 4, 3, 2);

BUT the UTouch_QuickPaint and UTouch_QuickDraw do not then work correctly even when the calibration values are placed in the .h file. If this touch feature can be made to work of even if the touch screen is not used I think the screen is still good value at $8.55 - $8.70 (if it the same one biablo and I have, see post 8 above).

My second one arrived today from China (Aliexpress), much better wrapped and in antistatic foam for once! It also works the same and so has the ILI9327 fitted. I have not tested the micro SD Card interface yet...

In the UTFT library the UTFT_Demo_400x240 sketch also works fine with the following constructor:

UTFT myGLCD(ILI9327,38,39,40,41);

The UTFT demo ran in 12,540 ms when the delays between tests had been removed and the last 10,000 random pixel test changed to:

// Draw 10,000 pixels but not using random numbers as that wastes time (3 seconds) byte i = 100; while (i--) { byte j = 100; while (j--) { myGLCD.setColor(0, 0, i+j); myGLCD.drawPixel(i+110,j+70); } }

The equivalent test ran in 3,291 ms using my adapted Adafruit_GFX based library above i.e. ~4 times faster, so it you do not need all the (very nice) fonts and features available in UTFT, but do need graphics plotting speed then it would be worth trying the library attached to post #10 above.

rowboteer: The advert made no mention of a touch screen, yet it clearly has one with the 2040 controller soldered to the board and ribbon pigtail that indicates a touch screen is fitted.

Probably 2046 actually, just a guess.

rowboteer: To cut a long story short

Go on then, because otherwise it would have been a long post :P

rowboteer: I tried the UTouch_Calibration sketch and guessed at the touch pin connections.

Not too much of a stretch really, since 6,5,4,3,2 is pretty standard.

rowboteer: To my surprise it worked first time

Strictly speaking, not true, you later said it don't.

rowboteer: BUT the UTouch_QuickPaint and UTouch_QuickDraw do not then work correctly even when the calibration values are placed in the .h file. If this touch feature can be made to work

Well here by hangs the problem, after all your other in depth waffle and rambling, the part of any actual interest receives only a few words.... 'do not then work correctly' with zero explanation or specifics detailing exactly what doesn't work, or why it is not working.....

Usually we would have useful information such as 'the y axis appears flipped' or 'the scale is all wrong' or SOME meaningful description as to WHY touch appears not to be working as expected......

Regards,

Graham

Update of using the touch screen…

I have come to the conclusion that Utouch has multiple problems with this particular display, the more complex problem being the return of very erratic coordinate values. I think this is down to interface timing problems so is not so easy to solve. The library also has quite a large memory footprint. So I have scrapped the idea of using UTouch with this particular display.

After a quick search on the web I found a compact library called ‚ÄúHCTFT_Touch‚ÄĚ that can be easily adapted. This library works with the 2046 controller and operates very reliably with the 400 x 240 touch screen on this thread.

I have made changes this evening specifically to suit my needs and re-named the library Touch_AS, this can be used as a companion library with any graphics library you like.

An example of use is provided, note that this does NOT draw anything on the screen, so open up a Serial Monitor window at 38400 baud to see the coordinates reported from screen touch contacts. The example has the correct control pins defined for this display.

The new/adapted functions permit an area to be set up that is smaller than the screen and divide this up into a matrix of numbered touch zones, for example a 3 x 4 grid. Presses of buttons/keys in each zone can then be easily recognised via a single number (0 to 11 for a 3 x 4 grid).

I have not had the time this evening to fully document the library but I will add more examples with some screen graphics if there is sufficient interest.

Enjoy… should you feel so inclined :wink:

Report any bugs here…

Touch_AS.zip (6.55 KB)

Here is an update to the touch library for these 400 x 240 screens. The library has had some tweaks to filter spurious touch values by double sampling and comparing.

I have added a graphics example that is a simple draw program which works with the driver and graphics libraries that are also included for convenience.

Report any bugs here. No more updates are otherwise planned as the libraries meet all my needs.

Touch_ASv3.zip (59.9 KB)

rowboteer Tanks from Chile! finally works