Problem using TFT screen with Adafruit ImageReader (Loading BMP from SD card)

So i get this error when i run the program:

VendingMachineAttemptSD:131:50: error: no matching function for call to 'Adafruit_ImageReader::drawBMP(const char [13], MCUFRIEND_kbv&, int, int)'

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

                                              ^

In file included from C:\Users\andyw.000\Desktop\VendingMachineAttemptSD\VendingMachineAttemptSD.ino:4:0:

C:\Users\andyw.000\Favorites\Documents\Arduino\libraries\Adafruit_ImageReader_Library/Adafruit_ImageReader.h:99:19: note: candidate: ImageReturnCode Adafruit_ImageReader::drawBMP(const char*, Adafruit_SPITFT&, int16_t, int16_t, boolean)

ImageReturnCode drawBMP(const char *filename, Adafruit_SPITFT &tft, int16_t x,

C:\Users\andyw.000\Favorites\Documents\Arduino\libraries\Adafruit_ImageReader_Library/Adafruit_ImageReader.h:99:19: note: no known conversion for argument 2 from 'MCUFRIEND_kbv' to 'Adafruit_SPITFT&'

no matching function for call to 'Adafruit_ImageReader::drawBMP(const char [13], MCUFRIEND_kbv&, int, int)'

Im using this display with the Arduino Mega2560

Any idea what's wrong with my program?


#include <SdFat.h>                // SD card & FAT filesystem library
#include <Adafruit_SPIFlash.h>    // SPI / QSPI flash library
#include <Adafruit_ImageReader.h> // Image-reading functions

#include <Servo.h>
#include <Adafruit_Fingerprint.h>
#include <stdint.h>
#include "TouchScreen.h"
#include <Adafruit_GFX.h>    // Core graphics library
#include <MCUFRIEND_kbv.h>
#include <Fonts\FreeSans18pt7b.h>
#include <Fonts\FreeSansBold24pt7b.h>
#include <Fonts\FreeSansBold12pt7b.h>
#include <Fonts\FreeSansBold18pt7b.h>
#include <Fonts\FreeSans9pt7b.h>



MCUFRIEND_kbv tft;
#define USE_SD_CARD

// TFT Breakout  -- Arduino UNO / Mega2560 / OPEN-SMART UNO Black
// GND              -- GND
// 3V3               -- 3.3V
// CS                 -- A3
// RS                 -- A2
// WR                -- A1
// RD                 -- A0
// RST                -- RESET
// LED                -- GND
// DB0                -- 8
// DB1                -- 9
// DB2                -- 10
// DB3                -- 11
// DB4                -- 4
// DB5                -- 13
// DB6                -- 6
// DB7                -- 7

// Assign human-readable names to some common 16-bit color values:
#define  BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
#define MINPRESSURE 10
#define MAXPRESSURE 1000
#define DARKGREEN 0x1420
#define DARKRED 0x8000

int waitUntil=1;
int waitUntil_2=1;
int waitUntil_3=1;
int waitUntil_4=1;
int amountCount=2;

uint16_t g_identifier;
uint8_t YP = A1;  // must be an analog pin, use "An" notation!
uint8_t XM = A2;  // must be an analog pin, use "An" notation!
uint8_t YM = 7;   // can be a digital pin
uint8_t XP = 6;   // can be a digital pin
uint16_t pLEFT = 950;
uint16_t pRIGHT  = 170;
uint16_t pTOP = 200;
uint16_t pBOTTOM = 890;
int v1;
uint16_t xpos, ypos; 
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

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

#if defined(USE_SD_CARD)
  SdFat                SD;         // SD card filesystem
  Adafruit_ImageReader reader(SD); // Image-reader object, pass in SD filesys
#else
  // SPI or QSPI flash filesystem (i.e. CIRCUITPY drive)
  #if defined(__SAMD51__) || defined(NRF52840_XXAA)
    Adafruit_FlashTransport_QSPI flashTransport(PIN_QSPI_SCK, PIN_QSPI_CS,
      PIN_QSPI_IO0, PIN_QSPI_IO1, PIN_QSPI_IO2, PIN_QSPI_IO3);
  #else
    #if (SPI_INTERFACES_COUNT == 1)
      Adafruit_FlashTransport_SPI flashTransport(SS, &SPI);
    #else
      Adafruit_FlashTransport_SPI flashTransport(SS1, &SPI1);
    #endif
  #endif
  Adafruit_SPIFlash    flash(&flashTransport);
  FatFileSystem        filesys;
  Adafruit_ImageReader reader(filesys); // Image-reader, pass in flash filesys
#endif

Adafruit_Image       img;        // An image loaded into RAM

void setup() {
tft.reset();
Serial.begin(9600);
uint16_t g_identifier = tft.readID();
tft.begin(g_identifier);
tft.setRotation(1);
 Serial.print(F("Initializing filesystem..."));
#if defined(USE_SD_CARD)
  // SD card is pretty straightforward, a single call...
  if(!SD.begin(SD_CS, SD_SCK_MHZ(25))) { // ESP32 requires 25 MHz limit
    Serial.println(F("SD begin() failed"));
    for(;;); // Fatal error, do not continue
  }
#else
  // SPI or QSPI flash requires two steps, one to access the bare flash
  // memory itself, then the second to access the filesystem within...
  if(!flash.begin()) {
    Serial.println(F("flash begin() failed"));
    for(;;);
  }
  if(!filesys.begin(&flash)) {
    Serial.println(F("filesys begin() failed"));
    for(;;);
  }
#endif
  Serial.println(F("OK!"));
bootScreen();
}

void bootScreen(){
  ImageReturnCode stat;
  stat = reader.drawBMP("/theLogo.bmp", tft, 0, 0);
  delay(3000);
  tft.fillScreen(BLACK); 
  tft.setFont(&FreeSansBold24pt7b);
  tft.setCursor(0,50);
  tft.setTextColor(WHITE);
  tft.print("Secure Vending Machine");
  tft.setFont(&FreeSansBold12pt7b);
  tft.setCursor(0,150);
  tft.print("Made by Shimon");
  tft.setCursor(290,230);
  tft.print("1.0 BETA");
  delay(4000);
  
  homeScreen();
}

void homeScreen(){  
  waitUntil=1;
  waitUntil_4=1;
  v1 = random(0, 2);
  tft.fillScreen(WHITE); 
  tft.setFont(&FreeSansBold24pt7b);
  tft.setTextColor(BLACK);
  if (v1 ==0){
  tft.setCursor(90,65);
  tft.print("Welcome!");
  }
  else if (v1 == 1){
  tft.setCursor(135,65);
  tft.print("Hello!");
  }

   tft.drawLine(20, 85, 380, 85, BLACK);
   tft.fillRoundRect(150, 100, 100, 100, 20, BLACK);
   tft.fillRoundRect(157, 107, 86, 86, 15, WHITE);
   tft.fillTriangle(175, 180, 175, 120, 225, 150, BLACK);
   playTouch();
}


void playTouch(){
    do {
    TSPoint p = ts.getPoint();
    xpos = map(p.x, pLEFT, pRIGHT, 0, 400);
    ypos = map(p.y, pTOP, pBOTTOM, 0, 240);
    if ( p.z > MINPRESSURE && p.z < MAXPRESSURE && xpos<250 && xpos>150 && ypos>100 && ypos<200 ){
    Serial.print("X = "); Serial.print(p.x);
    Serial.print("\tY = "); Serial.print(p.y);
    Serial.print("\tPressure = "); Serial.println(p.z);
    //tft.fillRoundRect(150, 100, 100, 100, 20, GREEN);
    highlightPlay();
    }
   } 
    while (waitUntil<2); 
    
}
void lockScreen(){
  tft.fillScreen(WHITE);
  tft.setCursor(50,60);
  tft.setTextColor(BLACK);
  tft.setFont(&FreeSansBold12pt7b);
  tft.print("Please Enter Fingerprint");
  tft.drawLine(20, 80, 380, 80, BLACK);
  tft.fillCircle(200, 140, 30, BLACK);
  tft.fillCircle(200, 140, 22, WHITE);
  tft.fillRoundRect(157, 140, 86, 70, 15, BLACK);
  delay(1000);
  waitUntil_2=1;
  unlockScreen();
  //accesesDenied();
  
}

void unlockScreen(){
  tft.fillScreen(WHITE);
  tft.setCursor(85,60);
  tft.setTextColor(GREEN);
  tft.setFont(&FreeSansBold12pt7b);
  tft.print("ACCESS APPROVED");
  tft.drawLine(20, 80, 380, 80, BLACK);
  tft.fillCircle(245, 140, 30, BLACK);
  tft.fillCircle(245, 140, 22, WHITE);
  tft.fillRoundRect(157, 140, 200, 200, 15, WHITE);
  tft.fillRoundRect(157, 140, 86, 70, 15, BLACK);
  delay(1000);
  amountPicker();
}

void accesesDenied(){
   tft.fillScreen(WHITE); 
   tft.setFont(&FreeSansBold18pt7b);
   tft.setTextColor(RED);
   tft.setCursor(55,70);
   tft.print("ACCESS DENIED");
   tft.drawLine(20, 85, 380, 85, BLACK);
   tft.fillRoundRect(150, 100, 100, 100, 20, BLACK);
   tft.fillRoundRect(157, 107, 86, 86, 15, WHITE);
   tft.fillCircle(200, 150, 30, BLACK);
   tft.fillCircle(200, 150, 22, WHITE);
   tft.fillRect(162, 112, 40, 40, WHITE);
   tft.fillTriangle(185, 125, 201, 115, 201, 135, BLACK);
   tft.setFont(&FreeSans9pt7b);
   tft.setCursor(10,65);
   tft.setTextColor(BLACK);
   againTouch();
   //tft.print("If you aren't trying to steal my candy,Please try again");
   
  
}

void againTouch(){
    pinMode(XM, INPUT);
    pinMode(YP, INPUT);
   do {
    TSPoint p = ts.getPoint();

    if ( p.z > MINPRESSURE && p.z < MAXPRESSURE && xpos<250 && xpos>150 && ypos>100 && ypos<200 ){
    Serial.print("X = "); Serial.print(p.x);
    Serial.print("\tY = "); Serial.print(p.y);
    Serial.print("\tPressure = "); Serial.println(p.z);
    //tft.fillRoundRect(150, 100, 100, 100, 20, GREEN);
    highlightAgain();

    }
   } 
    while (waitUntil_2<2);
}
void highlightAgain(){
   waitUntil_2=3;
   pinMode(XM, OUTPUT);
   pinMode(YP, OUTPUT);
   tft.fillRoundRect(150, 100, 100, 100, 20, GREEN);
   tft.fillRoundRect(157, 107, 86, 86, 15, WHITE);
   tft.fillCircle(200, 150, 30, GREEN);
   tft.fillCircle(200, 150, 22, WHITE);
   tft.fillRect(162, 112, 40, 40, WHITE);
   tft.fillTriangle(185, 125, 201, 115, 201, 135, GREEN);
   delay(100);
   lockScreen();
}
void highlightPlay(){
  waitUntil=3;
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  tft.setCursor(0,0);
  tft.fillRoundRect(150, 100, 100, 100, 20, GREEN);
  tft.fillRoundRect(157, 107, 86, 86, 15, WHITE);
  tft.fillTriangle(175, 180, 175, 120, 225, 150, GREEN);
  delay(100);
  
  lockScreen();
}

void amountPicker(){
  tft.fillScreen(WHITE); 
  tft.setFont(&FreeSansBold18pt7b);
  tft.setTextColor(BLACK);
  tft.setCursor(60,65);
  tft.print("Choose Amount:");
  tft.drawLine(20, 85, 380, 85, BLACK);
  //- button
  tft.fillRoundRect(20,105,80,80,20,BLACK);
  tft.fillRoundRect(27,112,66,66,15,WHITE);
  //+ button
  tft.fillRoundRect(300,105,80,80,20,BLACK);
  tft.fillRoundRect(307,112,66,66,15,WHITE);
  //mid button
  tft.fillRoundRect(105,105,190,80,20,BLACK);
  tft.fillRoundRect(112,112,176,66,15,WHITE);
  //X button
  tft.fillRoundRect(118,190,80,40,20,BLACK);
  tft.fillRoundRect(123,195,70,30,15,WHITE);
  //v button
  tft.fillRoundRect(203,190,80,40,20,BLACK);
  tft.fillRoundRect(208,195,70,30,15,WHITE);
  // v icon
  tft.drawLine(239,220,249,200,DARKGREEN);
  tft.drawLine(238,220,248,200,DARKGREEN);
  tft.drawLine(240,220,250,200,DARKGREEN);
  tft.drawLine(239,220,232,214,DARKGREEN);
  tft.drawLine(240,220,233,214,DARKGREEN);
  tft.drawLine(241,220,234,214,DARKGREEN);
  //X icon
  tft.drawLine(143+4,200,173-4,220,DARKRED);
  tft.drawLine(144+4,200,174-4,220,DARKRED);
  tft.drawLine(142+4,200,172-4,220,DARKRED);
  tft.drawLine(173-4,200,143+4,220,DARKRED);
  tft.drawLine(172-4,200,142+4,220,DARKRED);
  tft.drawLine(174-4,200,144+4,220,DARKRED);
  //- icon
  tft.drawLine(37,145,83,145,BLACK);
  tft.drawLine(37,144,83,144,BLACK);
  tft.drawLine(37,146,83,146,BLACK);
  //+ icon
  tft.drawLine(317,145,363,145,BLACK);
  tft.drawLine(317,144,363,144,BLACK);
  tft.drawLine(317,146,363,146,BLACK);
  tft.drawLine(340,122,340,168,BLACK);
  tft.drawLine(339,122,339,168,BLACK);
  tft.drawLine(341,122,341,168,BLACK);
  tft.setFont(&FreeSansBold12pt7b);
  tft.setCursor(150,153);
  tft.setTextColor(BLACK);
  tft.print("Not Alot");
  waitUntil_3=1;
  amountTouch();
}

void amountTouch(){
    pinMode(XM, INPUT);
    pinMode(YP, INPUT);
   do {
    TSPoint p = ts.getPoint();
    xpos = map(p.y, pLEFT, pRIGHT, 0, 400);
    ypos = map(p.x, pTOP, pBOTTOM, 0, 240);
    if ( p.z > MINPRESSURE && p.z < MAXPRESSURE && xpos<380 && xpos>300 && ypos>105 && ypos<185 ){
    Serial.print("X = "); Serial.print(p.x);
    Serial.print("\tY = "); Serial.print(p.y);
    Serial.print("\tPressure = "); Serial.println(p.z);
    highlightPlus();
    
    }
    if ( p.z > MINPRESSURE && p.z < MAXPRESSURE && xpos<80 && xpos>20 && ypos>105 && ypos<185 ){
    Serial.print("X = "); Serial.print(p.x);
    Serial.print("\tY = "); Serial.print(p.y);
    Serial.print("\tPressure = "); Serial.println(p.z);
    highlightMinus();
    }
    if ( p.z > MINPRESSURE && p.z < MAXPRESSURE && xpos<283 && xpos>203 && ypos>190 && ypos<230 ){
    Serial.print("X = "); Serial.print(p.x);
    Serial.print("\tY = "); Serial.print(p.y);
    Serial.print("\tPressure = "); Serial.println(p.z);
    highlightVi();
    }
    if ( p.z > MINPRESSURE && p.z < MAXPRESSURE && xpos<198 && xpos>118 && ypos>190 && ypos<230 ){
    Serial.print("X = "); Serial.print(p.x);
    Serial.print("\tY = "); Serial.print(p.y);
    Serial.print("\tPressure = "); Serial.println(p.z);
    highlightX();
    }
    
    
   } 
    while (waitUntil_3<2);
}

void highlightPlus(){
  Serial.print("got to highlightPlus");
  waitUntil_3=3;
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  tft.fillRoundRect(300,105,80,80,20,GREEN);
  tft.fillRoundRect(307,112,66,66,15,WHITE);
  tft.drawLine(317,145,363,145,GREEN);
  tft.drawLine(317,144,363,144,GREEN);
  tft.drawLine(317,146,363,146,GREEN);
  tft.drawLine(340,122,340,168,GREEN);
  tft.drawLine(339,122,339,168,GREEN);
  tft.drawLine(341,122,341,168,GREEN);
  delay(100);
  tft.fillRoundRect(300,105,80,80,20,BLACK);
  tft.fillRoundRect(307,112,66,66,15,WHITE);
  tft.drawLine(317,145,363,145,BLACK);
  tft.drawLine(317,144,363,144,BLACK);
  tft.drawLine(317,146,363,146,BLACK);
  tft.drawLine(340,122,340,168,BLACK);
  tft.drawLine(339,122,339,168,BLACK);
  tft.drawLine(341,122,341,168,BLACK);
  amountCount++;
  if (amountCount>3){
    amountCount=3;
  }
  else if (amountCount>=3){
   tft.fillRoundRect(112,112,176,66,15,WHITE);
   tft.setCursor(142,153);
   tft.setTextColor(BLACK);
   tft.print("Too Much");
  }
   else if (amountCount==2){
   tft.fillRoundRect(112,112,176,66,15,WHITE);
   tft.setCursor(150,153);
   tft.setTextColor(BLACK);
   tft.print("Not Alot");
  }
  waitUntil_3=1;
  amountTouch();
}

void highlightMinus(){
  waitUntil_3=3;
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  tft.fillRoundRect(20,105,80,80,20,RED);
  tft.fillRoundRect(27,112,66,66,15,WHITE);
  tft.drawLine(37,145,83,145,RED);
  tft.drawLine(37,144,83,144,RED);
  tft.drawLine(37,146,83,146,RED);
  delay(100);
  tft.fillRoundRect(20,105,80,80,20,BLACK);
  tft.fillRoundRect(27,112,66,66,15,WHITE);
  tft.drawLine(37,145,83,145,BLACK);
  tft.drawLine(37,144,83,144,BLACK);
  tft.drawLine(37,146,83,146,BLACK);
  amountCount--;
  if (amountCount<1){
    amountCount=1;
  }
  else if (amountCount<=1){
   tft.fillRoundRect(112,112,176,66,15,WHITE);
   tft.setCursor(167,153);
   tft.setTextColor(BLACK);
   tft.print("A Bit");
  }

  else if (amountCount==2){
   tft.fillRoundRect(112,112,176,66,15,WHITE);
   tft.setCursor(150,153);
   tft.setTextColor(BLACK);
   tft.print("Not Alot");
  }
  waitUntil_3=1;
  amountTouch();
}

void highlightX(){
  waitUntil_3=3;
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  tft.fillRoundRect(118,190,80,40,20,RED);
  tft.fillRoundRect(123,195,70,30,15,WHITE);
  tft.drawLine(143+4,200,173-4,220,DARKRED);
  tft.drawLine(144+4,200,174-4,220,DARKRED);
  tft.drawLine(142+4,200,172-4,220,DARKRED);
  tft.drawLine(173-4,200,143+4,220,DARKRED);
  tft.drawLine(172-4,200,142+4,220,DARKRED);
  tft.drawLine(174-4,200,144+4,220,DARKRED);
  delay(100);
  //back to defult state
  amountCount=2;
  //back to home screen
  homeScreen();

}

void highlightVi(){
  waitUntil_3=3;
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  //tft.fillRoundRect(203,190,80,40,20,GREEN);
  //tft.fillRoundRect(208,195,70,30,15,WHITE);
  //tft.drawLine(239,220,249,200,GREEN);
  //tft.drawLine(238,220,248,200,GREEN);
  //tft.drawLine(240,220,250,200,GREEN);
  //tft.drawLine(239,220,232,214,GREEN);
  //tft.drawLine(240,220,233,214,GREEN);
  //tft.drawLine(241,220,234,214,GREEN);
  //delay(100);
  endScreen();
}

void endScreen(){

  int v2 = random(0, 2);
  tft.fillScreen(WHITE); 
  tft.setFont(&FreeSansBold24pt7b);
  tft.setTextColor(BLACK);
  if (v2 ==0){
  tft.setCursor(120,65);
  tft.print("Enjoy!");
  }
  else if (v2 == 1){
  tft.setCursor(85,65);
  tft.setFont(&FreeSansBold18pt7b);
  tft.print("There you go!");
  }

   tft.drawLine(20, 85, 380, 85, BLACK);
   tft.fillRoundRect(150, 100, 100, 100, 20, BLACK);
   tft.fillRoundRect(157, 107, 86, 86, 15, WHITE);
   tft.fillTriangle(200, 117, 170, 145, 230, 145, BLACK);
   tft.fillRoundRect(180, 138, 40, 40, 5, BLACK);
   homeTouch();
}
void homeTouch(){
    pinMode(XM, INPUT);
    pinMode(YP, INPUT);
   do {
    TSPoint p = ts.getPoint();
    xpos = map(p.x, pLEFT, pRIGHT, 0, 400);
    ypos = map(p.y, pTOP, pBOTTOM, 0, 240);

    if ( p.z > MINPRESSURE && p.z < MAXPRESSURE && xpos<250 && xpos>150 && ypos>100 && ypos<200 ){
    highlightHome();

    }
   } 
    while (waitUntil_4<2);
}

void highlightHome(){
   waitUntil_4=3;
   pinMode(XM, OUTPUT);
   pinMode(YP, OUTPUT);
   tft.fillRoundRect(150, 100, 100, 100, 20,GREEN);
   tft.fillRoundRect(157, 107, 86, 86, 15, WHITE);
   tft.fillTriangle(200, 117, 170, 145, 230, 145, GREEN);
   tft.fillRoundRect(180, 135, 40, 43, 10, GREEN);
   delay(100);
   homeScreen();
  
}
void loop(){
  
}

You can ignore most of the program, the SD stuff is only at the begining and at bootScreen()

It would appear you are declaring your 'tft' as type MCUFRIEND_kbv but it needs to be of type Adafruit_SPITFT. I don't see any examples from that library that use MCUFRIEND_kbv as a type of display.

So are you saying i cant use Adafruit imageReader library because it dosent support mcufriend?

If you look at all the examples that come with that library, they all use some type of adafruit SPI display. There are multiple types supported. Are you using one of those types? Why did you choose the MCUFRIEND_kbv type?

Because MCUFRIEND is the only one that support my display (sadly). Anyway, i eventually (took me 3 hours) got it to work by looking at the example of displaying bitmaps that MCUFRIEND actually included.

Sounds like a good solution to share with a follow-up post that includes the working code.

heres the quick tutorial I made: How to display Bitmap images from SD on your TFT display using MCUFRIEND_kbv (tutorial)