Sainsmart 5 inch display, Compile errors

Hello All,

Any Pointers or Help would be greatly appreciated. I hope it is a simple overlook since I'm new to the Arduino environment.

I'm stumped! I ordered this display from SainSmart about a year ago and just now tried to use it. I've used Arduino a little, and thought this would be a breeze, NOPE!

I'm using a;

  • Genuine Arduino MEGA 2560.
  • GeekTech TFT LCD shield v2.0 with SD slot.
  • Hannstar HSD050IDW1-A20 5" touchscreen display, with a SSD1963 controller.

I originally tried with the older 1.8.2 Arduino IDE and the 5.0Fb software which came with the display from Sainsmart!

When I compile the unedited Sketch, I get numerous Errors. I have tried loading the whole UTFT folder into the "C:\Program Files (x86)\Arduino\libraries\UTFT" directory. I've used the "Sketch -> Include Library" to download a fresh UTFT library. I have completely uninstalled Arduino and installed the latest version. I have gone to http://www.rinkydinkelectronics.com/ and downloaded the latest thing I could find, including a UTFT_RAW version. All attempts result in compile errors.

Thank You Paul DeMint

Arduino: 1.8.15 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\User\Desktop\0_Sainsmart_Display\5.0Fb\5.0 TFT\MEGA\display\UTFT\examples\Arduino (AVR)\UTFT_Demo_800x480\UTFT_Demo_800x480.ino: In function 'void loop()':

C:\Users\User\Desktop\0_Sainsmart_Display\5.0Fb\5.0 TFT\MEGA\display\UTFT\examples\Arduino (AVR)\UTFT_Demo_800x480\UTFT_Demo_800x480.ino:49:68: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] myGLCD.print("* Universal Color TFT Display Library ", CENTER, 1);

C:\Users\User\Desktop\0_Sainsmart_Display\5.0Fb\5.0 TFT\MEGA\display\UTFT\examples\Arduino (AVR)\UTFT_Demo_800x480\UTFT_Demo_800x480.ino:52:70: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] myGLCD.print("http://electronics.henningkarlsen.com", CENTER, 467);*

C:\Users\User\Desktop\0_Sainsmart_Display\5.0Fb\5.0 TFT\MEGA\display\UTFT\examples\Arduino (AVR)\UTFT_Demo_800x480\UTFT_Demo_800x480.ino:69:28: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] myGLCD.print("Sin", 5, 15);*

C:\Users\User\Desktop\0_Sainsmart_Display\5.0Fb\5.0 TFT\MEGA\display\UTFT\examples\Arduino (AVR)\UTFT_Demo_800x480\UTFT_Demo_800x480.ino:76:28: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] myGLCD.print("Cos", 5, 27);*

C:\Users\User\Desktop\0_Sainsmart_Display\5.0Fb\5.0 TFT\MEGA\display\UTFT\examples\Arduino (AVR)\UTFT_Demo_800x480\UTFT_Demo_800x480.ino:83:28: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] myGLCD.print("Tan", 5, 39);*

C:\Users\User\Desktop\0_Sainsmart_Display\5.0Fb\5.0 TFT\MEGA\display\UTFT\examples\Arduino (AVR)\UTFT_Demo_800x480\UTFT_Demo_800x480.ino:273:41: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] myGLCD.print("That's it!", CENTER, 213);*

C:\Users\User\Desktop\0_Sainsmart_Display\5.0Fb\5.0 TFT\MEGA\display\UTFT\examples\Arduino (AVR)\UTFT_Demo_800x480\UTFT_Demo_800x480.ino:274:46: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] myGLCD.print("Restarting in a", CENTER, 239);*

C:\Users\User\Desktop\0_Sainsmart_Display\5.0Fb\5.0 TFT\MEGA\display\UTFT\examples\Arduino (AVR)\UTFT_Demo_800x480\UTFT_Demo_800x480.ino:275:45: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] myGLCD.print("few seconds...", CENTER, 252);*

C:\Users\User\Desktop\0_Sainsmart_Display\5.0Fb\5.0 TFT\MEGA\display\UTFT\examples\Arduino (AVR)\UTFT_Demo_800x480\UTFT_Demo_800x480.ino:279:47: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] myGLCD.print("Runtime: (msecs)", CENTER, 450);*

In file included from C:\Program Files (x86)\Arduino\libraries\UTFT\UTFT.cpp:41:0: C:\Program Files (x86)\Arduino\libraries\UTFT\hardware/avr/HW_ATmega1280.h:118:35: error: no 'void UTFT::LCD_Write_Bus_8(char)' member function declared in class 'UTFT'void UTFT::LCD_Write_Bus_8(char VL)

In file included from C:\Program Files (x86)\Arduino\libraries\UTFT\UTFT.cpp:47:0: C:\Program Files (x86)\Arduino\libraries\UTFT\hardware/avr/HW_ATmega1280.h:2:6: error: redefinition of 'void UTFT::_hw_special_init()' void UTFT::_hw_special_init()

In file included from C:\Program Files (x86)\Arduino\libraries\UTFT\UTFT.cpp:41:0: C:\Program Files (x86)\Arduino\libraries\UTFT\hardware/avr/HW_ATmega1280.h:2:6: note: 'void UTFT::_hw_special_init()' previously defined here void UTFT::_hw_special_init()

In file included from C:\Program Files (x86)\Arduino\libraries\UTFT\UTFT.cpp:47:0: C:\Program Files (x86)\Arduino\libraries\UTFT\hardware/avr/HW_ATmega1280.h:6:6: error: redefinition of 'void UTFT::LCD_Writ_Bus(char, char, byte)' void UTFT::LCD_Writ_Bus(char VH,char VL, byte mode)

In file included from C:\Program Files (x86)\Arduino\libraries\UTFT\UTFT.cpp:41:0: C:\Program Files (x86)\Arduino\libraries\UTFT\hardware/avr/HW_ATmega1280.h:6:6: note: 'void UTFT::LCD_Writ_Bus(char, char, byte)' previously defined here void UTFT::LCD_Writ_Bus(char VH,char VL, byte mode)

In file included from C:\Program Files (x86)\Arduino\libraries\UTFT\UTFT.cpp:47:0: C:\Program Files (x86)\Arduino\libraries\UTFT\hardware/avr/HW_ATmega1280.h:118:35: error: no 'void UTFT::LCD_Write_Bus_8(char)' member function declared in class 'UTFT' void UTFT::LCD_Write_Bus_8(char VL)

C:\Program Files (x86)\Arduino\libraries\UTFT\hardware/avr/HW_ATmega1280.h:134:6: error: redefinition of 'void UTFT::_set_direction_registers(byte)' void UTFT::_set_direction_registers(byte mode)

In file included from C:\Program Files (x86)\Arduino\libraries\UTFT\UTFT.cpp:41:0: C:\Program Files (x86)\Arduino\libraries\UTFT\hardware/avr/HW_ATmega1280.h:134:6: note: 'void UTFT::_set_direction_registers(byte)' previously defined here void UTFT::_set_direction_registers(byte mode) In file included from C:\Program Files (x86)\Arduino\libraries\UTFT\UTFT.cpp:47:0:

Do you think that providing help would be just a tiny bit easier if you posted the code here ?

Please follow the advice given in the link below when posting code . Use code tags when posting code here to make it easier to read and copy for examination

@pauldemint, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with your project :wink: See About the Installation & Troubleshooting category.

I figured that having a link to the code would be much better than to clog up this forum with copies. As I stated, it has not been modified! I originally had the direct link, but apparently new users to this forum cannot have more than two links in a post. This is the direct link to the files.
( UTFT - Rinky-Dink Electronics )
I have tried to compile this on 3 seperate computers with the same results. Win7 & Win10
The "SainSmart Code" is seemingly identical and apparently it was just copied to the Sainsmart website for their customers to find easily!

I actually figured this would be quickly recognized by those who use the Arduino IDE and knows the nuances of what items need to be put in what directories. (i.e. the Library stuff.) As I looked around I found I'm not the only person to experience issues with the UTFT software, yet when I look at the forum for solutions, it appears that useful comments, get drowned out by useless quips and chatter, which is even less useful than nothing!

http://www.rinkydinkelectronics.com/

// UTFT_Demo_800x480
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// This program is a demo of how to use most of the functions
// of the library with a supported display modules.
//
// This demo was made for modules with a screen resolution
// of 800x480 pixels.
//
// This program requires the UTFT library.
//

#include <UTFT.h>

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

// Set the pins to the correct ones for your development shield
// ------------------------------------------------------------
// Arduino Uno / 2009:
// -------------------
// Standard Arduino Uno/2009 shield : ,A5,A4,A3,A2
// DisplayModule Arduino Uno TFT shield : ,A5,A4,A3,A2
//
// Arduino Mega:
// -------------------
// Standard Arduino Mega/Due shield : ,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Mega : ,38,39,40,41
//
// Remember to change the model parameter to suit your display module!
UTFT myGLCD(ITDB50,38,39,40,41);

void setup()
{
randomSeed(analogRead(0));

// Setup the LCD
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
}

void loop()
{
int buf[798];
int x, x2;
int y, y2;
int r;

// Clear the screen and draw the frame
myGLCD.clrScr();

myGLCD.setColor(255, 0, 0);
myGLCD.fillRect(0, 0, 799, 13);
myGLCD.setColor(64, 64, 64);
myGLCD.fillRect(0, 466, 799, 479);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(255, 0, 0);
myGLCD.print("* Universal Color TFT Display Library *", CENTER, 1);
myGLCD.setBackColor(64, 64, 64);
myGLCD.setColor(255,255,0);
myGLCD.print("http://www.RinkyDinkElectronics.com/", CENTER, 467);

myGLCD.setColor(0, 0, 255);
myGLCD.drawRect(0, 14, 799, 465);

// Draw crosshairs
myGLCD.setColor(0, 0, 255);
myGLCD.setBackColor(0, 0, 0);
myGLCD.drawLine(399, 15, 399, 464);
myGLCD.drawLine(1, 239, 798, 239);
for (int i=9; i<790; i+=10)
myGLCD.drawLine(i, 237, i, 242);
for (int i=19; i<470; i+=10)
myGLCD.drawLine(397, i, 402, i);

// Draw sin-, cos- and tan-lines
myGLCD.setColor(0,255,255);
myGLCD.print("Sin", 5, 15);
for (int i=1; i<798; i++)
{
myGLCD.drawPixel(i,239+(sin(((i*1.13)*3.14)/180)*200));
}

myGLCD.setColor(255,0,0);
myGLCD.print("Cos", 5, 27);
for (int i=1; i<798; i++)
{
myGLCD.drawPixel(i,239+(cos(((i*1.13)*3.14)/180)*200));
}

myGLCD.setColor(255,255,0);
myGLCD.print("Tan", 5, 39);
for (int i=1; i<798; i++)
{
myGLCD.drawPixel(i,239+(tan(((i*0.9)*3.14)/180)));
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,798,464);
myGLCD.setColor(0, 0, 255);
myGLCD.setBackColor(0, 0, 0);
myGLCD.drawLine(399, 15, 399, 464);
myGLCD.drawLine(1, 239, 798, 239);

// Draw a moving sinewave
x=1;
for (int i=1; i<(79820); i++)
{
x++;
if (x==799)
x=1;
if (i>799)
{
if ((x==399)||(buf[x-1]==239))
myGLCD.setColor(0,0,255);
else
myGLCD.setColor(0,0,0);
myGLCD.drawPixel(x,buf[x-1]);
}
myGLCD.setColor(0,255,255);
y=239+(sin(((i
1.65)3.14)/180)(200-(i / 100)));
myGLCD.drawPixel(x,y);
buf[x-1]=y;
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,798,464);

// Draw some random filled rectangles
for (int i=0; i<50; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(746);
y=16+random(397);
x2=x+50;
y2=y+50;
myGLCD.fillRect(x, y, x2, y2);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,798,464);

// Draw some random filled, rounded rectangles
for (int i=0; i<50; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(746);
y=16+random(397);
x2=x+50;
y2=y+50;
myGLCD.fillRoundRect(x, y, x2, y2);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,798,464);

// Draw some random filled circles
for (int i=0; i<50; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=27+random(746);
y=41+random(397);
myGLCD.fillCircle(x, y, 25);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,798,464);

// Draw some lines in a pattern
myGLCD.setColor (255,0,0);
for (int i=15; i<463; i+=5)
{
myGLCD.drawLine(1, i, (i1.66)-10, 463);
}
myGLCD.setColor (255,0,0);
for (int i=463; i>15; i-=5)
{
myGLCD.drawLine(798, i, (i
1.66)+30, 15);
}
myGLCD.setColor (0,255,255);
for (int i=463; i>15; i-=5)
{
myGLCD.drawLine(1, i, 770-(i1.66), 15);
}
myGLCD.setColor (0,255,255);
for (int i=15; i<463; i+=5)
{
myGLCD.drawLine(798, i, 810-(i
1.66), 463);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,798,464);

// Draw some random circles
for (int i=0; i<250; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=32+random(736);
y=45+random(386);
r=random(30);
myGLCD.drawCircle(x, y, r);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,798,464);

// Draw some random rectangles
for (int i=0; i<250; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(796);
y=16+random(447);
x2=2+random(796);
y2=16+random(447);
myGLCD.drawRect(x, y, x2, y2);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,798,464);

// Draw some random rounded rectangles
for (int i=0; i<250; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(796);
y=16+random(447);
x2=2+random(796);
y2=16+random(447);
myGLCD.drawRoundRect(x, y, x2, y2);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,798,464);

for (int i=0; i<250; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(796);
y=16+random(447);
x2=2+random(796);
y2=16+random(447);
myGLCD.drawLine(x, y, x2, y2);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,798,464);

for (int i=0; i<10000; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
myGLCD.drawPixel(2+random(796), 16+random(447));
}

delay(2000);

myGLCD.fillScr(0, 0, 255);
myGLCD.setColor(255, 0, 0);
myGLCD.fillRoundRect(320, 190, 479, 289);

myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(255, 0, 0);
myGLCD.print("That's it!", CENTER, 213);
myGLCD.print("Restarting in a", CENTER, 239);
myGLCD.print("few seconds...", CENTER, 252);

myGLCD.setColor(0, 255, 0);
myGLCD.setBackColor(0, 0, 255);
myGLCD.print("Runtime: (msecs)", CENTER, 450);
myGLCD.printNumI(millis(), CENTER, 465);

delay (10000);
}

Why do users choose to ignore the advice on posting code ?

The easier you make it to read and copy your code the more likely it is that you will get help

Please follow the advice given in the link below when posting code . Use code tags when posting code here to make it easier to read and copy for examination

Dear Sir, Thank You So much for critiquing my posts!
If only you were really helpful!

At this point, I will approach this project differently both bailing on the Arduino platform and this POS display!

Take note of what I said and you will get plenty of help

1 Like

@pauldemint, I strongly suggest that you edit your post with the code as requested earlier, select all code and click the </> button to apply code tags and next save your post. It makes it easier to read, easier to copy and prevents the forum software from incorrect interpretation of the code (e.g. extern uint8_t SmallFont[] does not change to extern uint8_t SmallFont[]).

Now to your problem

Remove the UTFT library from C:\Program Files (x86)\Arduino\libraries\UTFT, it does not belong there. It will cleanout the errors/warnings.

I've downloaded the Rinky-Dink Library: UTFT (I hope it's the correct one, if not, please post a link) and used menu sketch -> include library -> add zip library.

Next I compiled your sketch and got errors relating to il.66. So I took the example that came with the library and it compiles with a few warnings.

A bit more analysis
Your code contains e.g. myGLCD.drawLine(798, i, 810 - (i1.66), 463);, the Rinky-Dink code contains myGLCD.drawLine(798, i, 810-(i*1.66), 463);.

Conclusion:

  1. Your code is corrupt (for whatever reason).
    //Edit: I now realise that that might be because you did not use code tags and the * has a special meaning for the forum software.
  2. Base your code on the example that comes with the Rinky-Dink library.

Dear Sir, Thank You!
I appreciate your help and suggestions. This was indeed helpful, and I'm truly grateful!
I will attempt to used the code tags in the future, if only I knew what they are & where to find them. Which I will find them. These forums are not inherently intuitive! I'm not a forum junky and this is the 1st time I have attempted to request help. Those who live on here forget that those who don't, are stumbling just to get their question posted, let alone in the correct place and with the proper punctuation and tags!

...And I did find out what, where and what for!
Thanks again!
Paul

You would know if you read the advice in the topic that I linked to previously How to get the best out of this forum

I probably would have had you had been encouraging instead of starting things off in a condescending statement!

That was not the first time in this topic that you had been asked to post your code, hence my pointed question

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.