Inserting a bmp image

Arduino: 1.8.5 (Windows 10), Board: "Arduino Due (Programming Port)"

C:\Users\Johan Prinsloo\Documents\Arduino\BitmapExample\BitmapExample.ino: In function 'void setup()':

BitmapExample:41: error: invalid conversion from 'unsigned int' to 'unsigned int*' [-fpermissive]

drawBitmap(20, 20, 83, 83, ButtonPlay[0x1AE9]); // (0,0) where on the screen, (64,64) size of image, (conix_64x64) image name.

^

BitmapExample:52: error: initializing argument 5 of 'void drawBitmap(int, int, int, int, unsigned int*)' [-fpermissive]

void drawBitmap(int x, int y, int sx, int sy, unsigned int *data)

^

C:\Users\Johan Prinsloo\Documents\Arduino\BitmapExample\BitmapExample.ino: In function 'void loop()':

BitmapExample:48: error: too few arguments to function 'void drawBitmap(int, int, int, int, unsigned int*)'

drawBitmap();

^

C:\Users\Johan Prinsloo\Documents\Arduino\BitmapExample\BitmapExample.ino:52:6: note: declared here

void drawBitmap(int x, int y, int sx, int sy, unsigned int *data)

^

exit status 1
invalid conversion from 'unsigned int' to 'unsigned int*' [-fpermissive]

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

/*DUE and 2.8" UNO TFT multi pin screen

*/
#include <MCUFRIEND_kbv.h>
#include <Adafruit_GFX.h>
#include <TouchScreen.h>
MCUFRIEND_kbv tft;

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#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
#define LIGHTGREY 0xDEDB
#define GREY    0xCE79

extern unsigned int ButtonPlay[0x1AE9]; // "conix_[0x1000]" must match the name in the file.

void setup() {

  Serial.begin(9600);
  Serial.print("Starting...");
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation(2);


  /* add in the functions to get your LCD started */
  drawBitmap(20, 20, 83, 83, ButtonPlay[0x1AE9]); // (0,0) where on the screen, (64,64) size of image, (conix_64x64) image name.

}


void loop()
{
  drawBitmap();
}


void drawBitmap(int x, int y, int sx, int sy, unsigned int *data)
{
  int tc = 0;
  for (int Y = 0; Y < sy; Y++)
  {
    for (int X = 0; X < sx; X++)
    {
      tft.drawPixel(X + x, Y + y, pgm_read_word(&data[tc]));
      if (tc < (sx * sy)) tc++;
    }
  }
}

Members

I received the error above when I compile this. Please help me to fix this. Thanks

drawBitmap(20, 20, 83, 83, ButtonPlay[0x1AE9]);

Why do you want to pass the value of the item 1 place beyond your array?

I think you want to pass the pointer to your array

drawBitmap(20, 20, 83, 83, ButtonPlay);

PS drop the macros (define's), in C++ we have the saver alternative of const byte for pin definitions :wink:

Arduino: 1.8.5 (Windows 10), Board: "Arduino Due (Programming Port)"

sketch\BitmapExample.ino.cpp.o: In function `setup':

C:\Users\Johan Prinsloo\Documents\Arduino\BitmapExample/BitmapExample.ino:43: undefined reference to `ButtonPlay'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino Due (Programming Port).

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

/*DUE and 2.8" UNO TFT multi pin screen

*/
#include <MCUFRIEND_kbv.h>
#include <Adafruit_GFX.h>
#include <TouchScreen.h>
MCUFRIEND_kbv tft;

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#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
#define LIGHTGREY 0xDEDB
#define GREY    0xCE79

extern unsigned int ButtonPlay[0x1AE9]; // "conix_[0x1000]" must match the name in the file.

void setup() {

  Serial.begin(9600);
  Serial.print("Starting...");
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation(2);


  /* add in the functions to get your LCD started */
  drawBitmap(20, 20, 83, 83, ButtonPlay); // (0,0) where on the screen, (64,64) size of image, (conix_64x64) image name.

}


void loop()
{
//  drawBitmap();
}


void drawBitmap(int x, int y, int sx, int sy, unsigned int *data)
{
  int tc = 0;
  for (int Y = 0; Y < sy; Y++)
  {
    for (int X = 0; X < sx; X++)
    {
      tft.drawPixel(X + x, Y + y, pgm_read_word(&data[tc]));
      if (tc < (sx * sy)) tc++;
    }
  }
}

Thanks for the help. I changed the code but its still not compiling. Any suggestions?

Thanks

Any suggestions?

Yes. Look at your definition for ButtonPlay. See that extern keyword? That means that the variable will actually be defined in another file. What other file have you defined it in, and how is this file supposed to know that?

Thanks Paul.

The folder consists of 2 files: the .ino & a folder called 'bitmaps'. Inside 'bitmaps is the .c file for the 'buttonPlay'

How can I include the .c file into my code?

Thanks

Thanks Paul.

Ive relocated the .c file in the same folder as the .ino file.

Thanks for the help