Go Down

Topic: TFT Shield from Hobbytronics wont compile. Please help! (Read 137 times) previous topic - next topic

jzcoder

Hi All,

I have some expoerience ofArduino, i just started a new project with a TFT shield i purchased a few years back.

I have a problem with the example code, "Example Arduino Sketch (menu driven)" at the link below.

http://www.hobbytronics.co.uk/arduino-tft-shield?keyword=tft%20shield

Both libraries installed ok. Can anyone help or even try and compile it and comment back for me?


Messages:


Code: [Select]
E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

                 "SD Card Bitmap "};

                                  ^

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

TFT_Shield:36:29: error: 'tftTextTest' was not declared in this scope

                 tftTextTest(),

                             ^

TFT_Shield:37:17: error: 'tftPrintTest' was not declared in this scope

                 tftPrintTest,

                 ^

TFT_Shield:38:17: error: 'tftLinesTest' was not declared in this scope

                 tftLinesTest,

                 ^

TFT_Shield:39:17: error: 'tftRectTest' was not declared in this scope

                 tftRectTest,

                 ^

TFT_Shield:40:17: error: 'tftBarGraphTest' was not declared in this scope

                 tftBarGraphTest,

                 ^

TFT_Shield:41:17: error: 'tftCirclesTest' was not declared in this scope

                 tftCirclesTest,

                 ^

TFT_Shield:42:17: error: 'tftMediaButtonsTest' was not declared in this scope

                 tftMediaButtonsTest,

                 ^

TFT_Shield:43:17: error: 'tftBitmapTest' was not declared in this scope

                 tftBitmapTest};                          

                 ^

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:53:62: warning: passing NULL to non-pointer argument 3 of 'Adafruit_ST7735::Adafruit_ST7735(int8_t, int8_t, int8_t)' [-Wconversion-null]

 Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

                                                              ^

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino: In function 'void tftTextTest()':

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:183:16: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

   char * lorem="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat.";

                ^

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino: In function 'void tftPrintTest()':

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:197:16: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

   char * hello="Hello World!";

                ^

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino: In function 'void tftBitmapTest()':

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:361:33: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

      bmpDraw("ht_logo.bmp", 0, 0);

                                 ^

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino: In function 'void bmpDraw(char*, uint8_t, uint8_t)':

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:399:40: warning: converting to non-pointer type 'int' from NULL [-Wconversion-null]

   if ((bmpFile = SD.open(filename)) == NULL) {

                                        ^

TFT_Shield:475:31: error: 'class Adafruit_ST7735' has no member named 'Color565'

             tft.pushColor(tft.Color565(r,g,b));

                               ^

exit status 1
'tftTextTest' was not declared in this scope





jzcoder

Hi All,

I have some experience of Arduino, i just started a new project with a TFT shield i purchased a few years back.

I have a problem with the example code, "Example Arduino Sketch (menu driven)" at the link below.

http://www.hobbytronics.co.uk/arduino-tft-shield?keyword=tft%20shield

Both libraries installed ok. Can anyone help or even try and compile it and comment back for me?


Messages:

Code: [Select]










E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

                 "SD Card Bitmap "};

                                  ^

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:33:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

TFT_Shield:36:29: error: 'tftTextTest' was not declared in this scope

                 tftTextTest(),

                             ^

TFT_Shield:37:17: error: 'tftPrintTest' was not declared in this scope

                 tftPrintTest,

                 ^

TFT_Shield:38:17: error: 'tftLinesTest' was not declared in this scope

                 tftLinesTest,

                 ^

TFT_Shield:39:17: error: 'tftRectTest' was not declared in this scope

                 tftRectTest,

                 ^

TFT_Shield:40:17: error: 'tftBarGraphTest' was not declared in this scope

                 tftBarGraphTest,

                 ^

TFT_Shield:41:17: error: 'tftCirclesTest' was not declared in this scope

                 tftCirclesTest,

                 ^

TFT_Shield:42:17: error: 'tftMediaButtonsTest' was not declared in this scope

                 tftMediaButtonsTest,

                 ^

TFT_Shield:43:17: error: 'tftBitmapTest' was not declared in this scope

                 tftBitmapTest};                           

                 ^

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:53:62: warning: passing NULL to non-pointer argument 3 of 'Adafruit_ST7735::Adafruit_ST7735(int8_t, int8_t, int8_t)' [-Wconversion-null]

 Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

                                                              ^

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino: In function 'void tftTextTest()':

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:183:16: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

   char * lorem="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat.";

                ^

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino: In function 'void tftPrintTest()':

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:197:16: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

   char * hello="Hello World!";

                ^

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino: In function 'void tftBitmapTest()':

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:361:33: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

      bmpDraw("ht_logo.bmp", 0, 0);

                                 ^

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino: In function 'void bmpDraw(char*, uint8_t, uint8_t)':

E:\Dropbox\Arduino\TFT DataLogger\TFT_Shield\TFT_Shield.ino:399:40: warning: converting to non-pointer type 'int' from NULL [-Wconversion-null]

   if ((bmpFile = SD.open(filename)) == NULL) {

                                        ^

TFT_Shield:475:31: error: 'class Adafruit_ST7735' has no member named 'Color565'

             tft.pushColor(tft.Color565(r,g,b));

                               ^

exit status 1
'tftTextTest' was not declared in this scope

david_prentice

I suggest that you upgrade any libraries via the IDE Library Manager.

And make some edits to your sketch e.g.  look for SD_CS line and insert the next lines

Code: [Select]

#define SD_CS    4          // Chip select line for SD card

//fix original typo
#define Color565(r, g, b) color565(r, g, b)
//add forward declarations
extern void     tftTextTest(void),
                tftPrintTest(void),
                tftLinesTest(void),
                tftRectTest(void),
                tftBarGraphTest(void),
                tftCirclesTest(void),
                tftMediaButtonsTest(void),
                tftBitmapTest(void);                           


Adafruit alter and improve code.   They seem to have fixed their early Color565() typo.
I am not sure why the forward declarations were required.    The Arduino "kludge phase" normally does this for you.

David.

groundFungus

I got the code to compile by adding function prototypes at the top of the code.

Code: [Select]
#define lcdBacklight  9
#define SD_CS    4          // Chip select line for SD card

void tftTextTest();
void tftPrintTest();
void tftLinesTest();
void tftRectTest();
void tftBarGraphTest();
void tftCirclesTest();
void tftMediaButtonsTest();
void tftBitmapTest();

/* For those of you interested in creating a Menu system, we have defined
   two arrays here. One holds


The IDE is supposed to automatically generate function prototypes, but in some cases it fails so you must generate the prototypes manually.  I can't explain why (above my knowledge), but have seen the same problem before.

You will get better help if you follow the posting guidelines in the how to use this forum-please read sticky.

To see your code one must go the the linked page, download the zip file, unzip the file and put into the IDE (after creating a file for it that I later must delete).  Only then can you see the code.  What an unholy pain in the ass.

Post the code in code tags.

Edit:  If the code is too big for a post you can attach the code.  A pain for us to open and read, but still way better than downloading a zip file.

groundFungus


jzcoder

Hi David,

Thank you,

I have now updated all my libraries.
I also added your lines of code!
Didn't work at first, installed latest version of Arduino again and now working perfectly.

Thank you very much for your time and help.


jzcoder

Sorry for the double post!

Thank you for your help and advice on how to use the forum too.

Hopefully i will make my posting better next time!



david_prentice

#8
Jul 15, 2019, 11:21 pm Last Edit: Jul 16, 2019, 12:06 am by david_prentice
First off.    I think that this question was correctly put in the Displays Forum.   

If you do ask the same question in two Forums please SAY SO.    Ideally with clickable links.


I was fascinated by WHY the forward declarations were failing.

A typical sketch has:

Code: [Select]

#include headers

#defines

global variables

function definitions

The Arduino kludge phase identifies forward declarations and inserts them just in front of the first function definition.

So you can solve the OP's problem by simply placing a "function" immediately after the includes:
Code: [Select]

void dummy_function(void) { }


This ensures that you get
Code: [Select]

#include headers

forward function declarations

dummy_function definition

#defines

global variables

function definitions

As a general rule function declarations might contain as yet undefined typedefs
As we have seen,   you can't reference function pointers until they have been declared.

Personally I dislike the kludging of forward references.   It is NOT part of C++.
I do like the parsing of .INO files to determine INCLUDE paths and LIBRARY paths.

I presume that IDE v1.8.9 has altered the positioning of forward declarations.

David.

Go Up