0

2.8" TFT Touch Shield Tutorial Code problem
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

2.8" TFT Touch Shield Tutorial Code problem

by Blueshark on Sat Feb 02, 2019 7:02 pm

Everything was working right until the displaying images part, the example code will not work.

using this TFT shield...
https://www.adafruit.com/product/1651

following this tutorial....
https://learn.adafruit.com/adafruit-2-8-tft-touch-shield-v2/drawing-bitmaps

All libraries have been installed right...

For FORUM use I had to change the name of one of the pictures because the Forums says its a word that is banned in the Forums, the new name is "fox.bmp"

Here is the example code giving me the problem....
Code: Select all | TOGGLE FULL SIZE
    // Adafruit_ImageReader test for Adafruit ILI9341 TFT Shield for Arduino.
// Demonstrates loading images to the screen, to RAM, and how to query
// image file dimensions.
// Requires three BMP files in root directory of SD card:
// purple.bmp, parrot.bmp and fox.bmp.

#include <SPI.h>
#include <SD.h>
#include <Adafruit_GFX.h>         // Core graphics library
#include <Adafruit_ILI9341.h>     // Hardware-specific library
#include <Adafruit_ImageReader.h> // Image-reading functions

// TFT display and SD card share the hardware SPI interface, using
// 'select' pins for each to identify the active device on the bus.
// Hardware SPI pins are specific to the Arduino board type and
// cannot be remapped to alternate pins.  For Arduino Uno,
// Duemilanove, etc., pin 11 = MOSI, pin 12 = MISO, pin 13 = SCK.

#define SD_CS   4 // SD card select pin
#define TFT_CS 10 // TFT select pin
#define TFT_DC  9 // TFT display/command pin

Adafruit_ILI9341     tft    = Adafruit_ILI9341(TFT_CS, TFT_DC);
Adafruit_ImageReader reader;     // Class w/image-reading functions
Adafruit_Image       img;        // An image loaded into RAM
int32_t              width  = 0, // BMP image dimensions
                     height = 0;

void setup(void) {

  ImageReturnCode stat; // Status from image-reading functions

  Serial.begin(9600);
#if !defined(ESP32)
  while(!Serial);       // Wait for Serial Monitor before continuing
#endif

  tft.begin();          // Initialize screen

  Serial.print(F("Initializing SD card..."));
  if(!SD.begin(SD_CS)) {
    Serial.println(F("failed!"));
    for(;;); // Loop here forever
  }
  Serial.println(F("OK!"));

  // Fill screen blue. Not a required step, this just shows that we're
  // successfully communicating with the screen.
  tft.fillScreen(ILI9341_BLUE);

  // Load full-screen BMP file 'purple.bmp' at position (0,0) (top left).
  // Notice the 'reader' object performs this, with 'tft' as an argument.
  Serial.print(F("Loading purple.bmp to screen..."));
  stat = reader.drawBMP("/purple.bmp", tft, 0, 0);
  reader.printStatus(stat);   // How'd we do?

  // Query the dimensions of image 'parrot.bmp' WITHOUT loading to screen:
  Serial.print(F("Querying parrot.bmp image size..."));
  stat = reader.bmpDimensions("/parrot.bmp", &width, &height);
  reader.printStatus(stat);   // How'd we do?
  if(stat == IMAGE_SUCCESS) { // If it worked, print image size...
    Serial.print(F("Image dimensions: "));
    Serial.print(width);
    Serial.write('x');
    Serial.println(height);
  }

  // Load small BMP 'fox.bmp' into a GFX canvas in RAM. This should fail
  // gracefully on Arduino Uno and other small devices, meaning the image
  // will not load, but this won't make the program stop or crash, it just
  // continues on without it. Should work on Arduino Mega, Zero, etc.
  Serial.print(F("Loading fox.bmp to canvas..."));
  stat = reader.loadBMP("/fox.bmp", img);
  reader.printStatus(stat); // How'd we do?

  delay(2000); // Pause 2 seconds before moving on to loop()
}

void loop() {
  for(int r=0; r<4; r++) { // For each of 4 rotations...
    tft.setRotation(r);    // Set rotation
    tft.fillScreen(0);     // and clear screen

    // Load 4 copies of the 'parrot.bmp' image to the screen, some
    // partially off screen edges to demonstrate clipping. Globals
    // 'width' and 'height' were set by bmpDimensions() call in setup().
    for(int i=0; i<4; i++) {
      reader.drawBMP("/parrot.bmp", tft,
        (tft.width()  * i / 3) - (width  / 2),
        (tft.height() * i / 3) - (height / 2));
    }

    delay(1000); // Pause 1 sec.

    // Draw 50 Welsh dragon flags in random positions. This has no effect
    // on memory-constrained boards like the Arduino Uno, where the image
    // failed to load due to insufficient RAM, but it's NOT fatal.
    for(int i=0; i<50; i++) {
      // Rather than reader.drawBMP() (which works from SD card),
      // a different function is used for RAM-resident images:
      img.draw(tft,                                    // Pass in tft object
        (int16_t)random(-img.width() , tft.width()) ,  // Horiz pos.
        (int16_t)random(-img.height(), tft.height())); // Vert pos
      // Reiterating a prior point: img.draw() does nothing and returns
      // if the image failed to load. It's unfortunate but not disastrous.
    }

    delay(2000); // Pause 2 sec.
  }



Here is the error messege I get....

Code: Select all | TOGGLE FULL SIZE
   Arduino: 1.8.5 (Windows 10), Board: "Adafruit Metro"

In file included from C:\Program Files (x86)\Arduino\libraries\Adafruit_ImageReader/Adafruit_ImageReader.h:17:0,

                 from C:\Users\alex2\AppData\Local\Temp\arduino_modified_sketch_116188\ShieldILI9341.ino:11:

C:\Program Files (x86)\Arduino\libraries\Adafruit_GFX/Adafruit_SPITFT.h:71:18: error: 'RwReg' does not name a type

         volatile RwReg *mosiport, *misoport, *clkport, *dcport, *csport;

                  ^

C:\Program Files (x86)\Arduino\libraries\Adafruit_GFX/Adafruit_SPITFT.h:72:9: error: 'RwReg' does not name a type

         RwReg  mosipinmask, misopinmask, clkpinmask, cspinmask, dcpinmask;

         ^

C:\Users\alex2\AppData\Local\Temp\arduino_modified_sketch_116188\ShieldILI9341.ino: In function 'void setup()':

ShieldILI9341:54: error: no matching function for call to 'Adafruit_ImageReader::drawBMP(const char [12], Adafruit_ILI9341&, int, int)'

   stat = reader.drawBMP("/purple.bmp", tft, 0, 0);

                                                 ^

C:\Users\alex2\AppData\Local\Temp\arduino_modified_sketch_116188\ShieldILI9341.ino:54:49: note: candidate is:

In file included from C:\Users\alex2\AppData\Local\Temp\arduino_modified_sketch_116188\ShieldILI9341.ino:11:0:

C:\Program Files (x86)\Arduino\libraries\Adafruit_ImageReader/Adafruit_ImageReader.h:74:21: note: ImageReturnCode Adafruit_ImageReader::drawBMP(char*, Adafruit_SPITFT&, int16_t, int16_t, boolean)

     ImageReturnCode drawBMP(char *filename, Adafruit_SPITFT &tft,

                     ^

C:\Program Files (x86)\Arduino\libraries\Adafruit_ImageReader/Adafruit_ImageReader.h:74:21: note:   no known conversion for argument 2 from 'Adafruit_ILI9341' to 'Adafruit_SPITFT&'

C:\Users\alex2\AppData\Local\Temp\arduino_modified_sketch_116188\ShieldILI9341.ino: In function 'void loop()':

ShieldILI9341:90: error: no matching function for call to 'Adafruit_ImageReader::drawBMP(const char [12], Adafruit_ILI9341&, int32_t, int32_t)'

         (tft.height() * i / 3) - (height / 2));

                                              ^

C:\Users\alex2\AppData\Local\Temp\arduino_modified_sketch_116188\ShieldILI9341.ino:90:46: note: candidate is:

In file included from C:\Users\alex2\AppData\Local\Temp\arduino_modified_sketch_116188\ShieldILI9341.ino:11:0:

C:\Program Files (x86)\Arduino\libraries\Adafruit_ImageReader/Adafruit_ImageReader.h:74:21: note: ImageReturnCode Adafruit_ImageReader::drawBMP(char*, Adafruit_SPITFT&, int16_t, int16_t, boolean)

     ImageReturnCode drawBMP(char *filename, Adafruit_SPITFT &tft,

                     ^

C:\Program Files (x86)\Arduino\libraries\Adafruit_ImageReader/Adafruit_ImageReader.h:74:21: note:   no known conversion for argument 2 from 'Adafruit_ILI9341' to 'Adafruit_SPITFT&'

ShieldILI9341:103: error: no matching function for call to 'Adafruit_Image::draw(Adafruit_ILI9341&, int16_t, int16_t)'

         (int16_t)random(-img.height(), tft.height())); // Vert pos

                                                     ^

C:\Users\alex2\AppData\Local\Temp\arduino_modified_sketch_116188\ShieldILI9341.ino:103:53: note: candidate is:

In file included from C:\Users\alex2\AppData\Local\Temp\arduino_modified_sketch_116188\ShieldILI9341.ino:11:0:

C:\Program Files (x86)\Arduino\libraries\Adafruit_ImageReader/Adafruit_ImageReader.h:45:20: note: void Adafruit_Image::draw(Adafruit_SPITFT&, int16_t, int16_t)

     void           draw(Adafruit_SPITFT &tft, int16_t x, int16_t y);

                    ^

C:\Program Files (x86)\Arduino\libraries\Adafruit_ImageReader/Adafruit_ImageReader.h:45:20: note:   no known conversion for argument 1 from 'Adafruit_ILI9341' to 'Adafruit_SPITFT&'

exit status 1
no matching function for call to 'Adafruit_ImageReader::drawBMP(const char [12], Adafruit_ILI9341&, int, int)'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
   


any help will be apricciated


Cheers...

Blueshark
 
Posts: 120
Joined: Thu Dec 21, 2017 7:19 pm

Re: 2.8" TFT Touch Shield Tutorial Code problem

by Blueshark on Sat Feb 02, 2019 9:35 pm

I found the problem.....

I must have had an old version of the Adafruit ILI9341 library and/or the Adafruit GFX Library, because I just re-installed those files from the Adafruit GitHub repository and now this code works...

Cheers....

Blueshark
 
Posts: 120
Joined: Thu Dec 21, 2017 7:19 pm

Re: 2.8" TFT Touch Shield Tutorial Code problem

by franklin97355 on Sat Feb 02, 2019 11:46 pm

Thanks for letting us know the fix.

franklin97355
 
Posts: 20475
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Please be positive and constructive with your questions and comments.