Issue with Open-Smart 3.2" ILI9327 TFT printing out of margins [SOLVED]

Hi. I have an OPEN-SMART 3.2" ILI9327 TFT shield with Ardiuino MEGA 2560

I am using Adafriuit GFX and TFT-LCD libraries

Picture:

It is printing out of margins and uncentered in all the 4 rotation positions.

Can I correct this issue by modifying the libraries? I would appreciate if someone could indicate where to start.

Thank you

Here is my testing code:

//Rotation test for 3.2" TFT LCD ILI9327
#include <Adafruit_GFX.h>    // https://github.com/adafruit/Adafruit-GFX-Library
#include <Adafruit_TFTLCD.h> // https://github.com/adafruit/TFTLCD-Library

#define LCD_CS A3 // Chip Select
#define LCD_CD A2 // Command/Data
#define LCD_WR A1 // LCD Write
#define LCD_RD A0 // LCD Read
#define LCD_RESET A4

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

Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

void setup(void) {
  Serial.begin(9600);
  tft.reset();
  uint16_t identifier = tft.readID(); // returns 0x9327 for ILI9327 LCD driver
  tft.begin(identifier);
}

void testLines() {
  tft.setRotation(rotation);
  tft.fillScreen(BLACK);
  int           x1, y1, x2, y2,
                w = tft.width(),
                h = tft.height();
  Serial.print("w="); Serial.print(w); Serial.print(", h="); Serial.println(h);

  tft.setCursor(0, 0);
  tft.setTextColor(WHITE);  tft.setTextSize(3);
  tft.println("Rotation test");
  tft.print("Rotation = "); tft.println(rotation);

  //Draw a rectangle around the screen
  tft.drawRect(0, 0, w, h, BLUE);
  //Draw crossing lines
  tft.drawLine(0, 0, w, h, GREEN);
  tft.drawLine(0, w, h, 0, YELLOW);
  //Draw a circle at the screen center
  tft.fillCircle(w / 2, h / 2, 5, RED);

  //Draw a triangle at the screen center
  int cx = w / 2, cy = h / 2, i = 30;
  tft.drawTriangle(
    cx    , cy - i, // peak
    cx - i, cy + i, // bottom left
    cx + i, cy + i, // bottom right
    MAGENTA);
}

void loop(void) {
  for (rotation = 0; rotation <= 3; rotation++) {
    testLines();
    delay (10000);
  }
}

And the results in all the rotating positions:

Sorry. The crossing lines in that code were not correctly defined. They should go like this:

  //Draw crossing lines
  tft.drawLine(0, 0, w, h, GREEN);
  tft.drawLine(0, h, w, 0, YELLOW);

Still printing out of margins, anyway.

Got it! :slight_smile:

I've found the correct library at Banggood (I bought my display on Ebay without any information)

http://files.banggood.com/2018/09/SKU948385.zip

http://files.banggood.com/2018/09/SKU948385.zip //OPEN-SMART 3.2 Inch TFT LCD Display Module Touch Screen Shield Onboard Temperatu Sale - Banggood Southeast Asia sold out-arrival notice-arrival notice

The working code:

//Rotation test for 3.2" TFT LCD ILI9327
// Libraries: http://files.banggood.com/2018/09/SKU948385.zip
//https://sea.banggood.com/3_2-Inch-TFT-LCD-Display-Module-Touch-Screen-Shield-Onboard-Temperature-SensorPen-p-1334094.html?cur_warehouse=CN
#include <Adafruit_GFX.h>    
//#include <Adafruit_TFTLCD.h> 
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

#define LCD_CS A3 // Chip Select
#define LCD_CD A2 // Command/Data
#define LCD_WR A1 // LCD Write
#define LCD_RD A0 // LCD Read
#define LCD_RESET A4

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

//Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

void setup(void) {
  Serial.begin(9600);
  tft.reset();
  uint16_t identifier = tft.readID(); // returns 0x9327 for ILI9327 LCD driver
  tft.begin(identifier);
}

void testLines() {
  tft.setRotation(rotation);
  tft.fillScreen(BLACK);
  int           x1, y1, x2, y2,
                w = tft.width(),
                h = tft.height();
  Serial.print("w="); Serial.print(w); Serial.print(", h="); Serial.println(h);

  tft.setCursor(0, 0);
  tft.setTextColor(WHITE);  tft.setTextSize(3);
  tft.println("Rotation test");
  tft.print("Rotation = "); tft.println(rotation);

  //Draw a rectangle around the screen
  tft.drawRect(0, 0, w, h, BLUE);
  //Draw crossing lines
  tft.drawLine(0, 0, w, h, GREEN);
  tft.drawLine(0, h, w, 0, YELLOW);
  //Draw a circle at the screen center
  tft.fillCircle(w / 2, h / 2, 5, RED);

  //Draw a triangle at the screen center
  int cx = w / 2, cy = h / 2, i = 30;
  tft.drawTriangle(
    cx    , cy - i, // peak
    cx - i, cy + i, // bottom left
    cx + i, cy + i, // bottom right
    MAGENTA);
}

void loop(void) {
  for (rotation = 0; rotation <= 3; rotation++) {
    testLines();
    delay (10000);
  }
}

I was confused by your Original Post. Your sketch seems to use Adafruit_TFTLCD library (and has a link to GitHub - adafruit/TFTLCD-Library: Arduino library for 8-bit TFT LCDs such as ILI9325, ILI9328, etc )

As far as I know, Adafruit have never supported ILI9327. And Adafruit have certainly NEVER supported Open-Smart databus wiring.

Where did you get your "Adafruit_TFTLCD.h" ?
Your later post shows a ZIP which contains a hacked version of my MCUFRIEND_kbv library

I strongly recommend that you remove the hacked Adafruit_TFTLCD, Adafruit_GFX, MCUFRIEND_kbv libraries.

Then install the proper Adafruit_GFX, MCUFRIEND_kbv via the IDE Library Manager.

Yes, you must do some minor edits to configure the genuine MCUFRIEND_kbv library for your Open-Smart wiring.

Using the Library Manager ensures that you install / update bona-fide libraries from a known source.

David.

Hi. David.
I didn't know that the library was pirated. I will follow your advice and install it via the IDE Library Manager
Thank you for the advice

It is not "pirated". Open Source software can be used by anyone.

It would be nice if Open-Smart had asked or at least they could have changed the class name.

Co-operation would have been preferable. Then there would be a single supported library.

David.

Hi Guys
Sorry to tack onto your thread. I wondered if you solved this and have any code and libraries to help me. I have the identical board and am trying to add it to my Due. I got a test running but lost the library and source it worked with.

Any help much appreciated.
Steve

I strongly recommend that you follow #3

Ask if you have a problem.

David.

Hardware:

1: OPEN-SMART 3.2" ILI9327 TFT
2: Arduino Mega 2560 V3

I feel obligated to post what I found, after several Ours of getting no where fast;

1: Go to: GitHub - prenticedavid/MCUFRIEND_kbv: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields, download the git. v2.9.3.
2: Paste the folder "MCUFRIEND_kbv" into your directory: "C:\Program Files (x86)\Arduino\libraries" or as David recommends: "C:\Users<Username>\Documents\Arduino\libraries" Directory, if the default path is selected.

Open the IDE, select the example: graphictest_opensmart

Your'e good to go!

Thanks to "prenticedavid" for the github library, working quickly and easily! Thank You!

bigchriso:
I feel obligated to post what I found, after several Ours of getting no where fast;

1: Go to: GitHub - prenticedavid/MCUFRIEND_kbv: MCUFRIEND_kbv Library for Uno 2.4, 2.8, 3.5, 3.6, 3.95 inch mcufriend Shields, download the git.
2: Paste the folder "MCUFRIEND_kbv" into your directory: "C:\Program Files (x86)\Arduino\libraries" Directory

NEVER put USER libraries in Program Files.
Always use the Library Manager unless advised by the author.

bigchriso:
Open the IDE, select the example: graphictest_opensmart

Youre good to go!

Thanks to "prenticedavid" for the github library, working quickly and easily! Thank You!

graphictest_opensmart.ino is not part of the official v2.9.8 Release

Install the Beta at your own risk. Yes, the OPENSMART_kbv class might make your life easier.
You are the first person who has ever noticed the OPENSMART_kbv example.
I would appreciate feedback. Using a OPENSMART_kbv constructor instead of MCUFRIEND_kbv constructor might be simpler than editing USE_SPECIAL, USE_OPENSMART_SHIELD_PINOUT defines.

David.

Thank You David,

Yes, the "OPENSMART_kbv" class is extremely simple to use compared to all the other methods I tried, all of which were just Painful!

Anyone recently purchased the Arduino Mega and the ILI9327 Shield, dont waste your time, try this method first, you will save yourself a ton of time!

Best wishes,
BigChrisO

I strongly recommend that you store with your User libraries and not in Program Files.

e.g. download ZIP. install from ZIP.

Please keep in touch. Every example should work by "Using a OPENSMART_kbv constructor instead of MCUFRIEND_kbv constructor"

David.