Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) having problems uploading program with headers to arduino (Read 18085 times)
sam9116
Newbies
*
Offline


Posts: 6
Location: Edmonton
Joined: Oct 19th, 2012
having problems uploading program with headers to arduino
Oct 19th, 2012 at 10:50pm
Print Post  
this code is supposed to display an image onto a lcd display on an arduino mega 2560

this is the header file
Code
Select All
/*
 * Routine for drawing an image patch from the SD card to the LCD display.
 */

#ifndef _LCD_IMAGE_H
#define _LCD_IMAGE_H

typedef struct {
  char *file_name;
  uint16_t ncols;
  uint16_t nrows;
} lcd_image_t;

/* Draws the referenced image to the LCD screen.
 *
 * img           : the image to draw
 * tft           : the initialized tft struct
 * icol, irow    : the upper-left corner of the image patch to draw
 * scol, srow    : the upper-left corner of the screen to draw to
 * width, height : controls the size of the patch drawn.
 */
void lcd_image_draw(lcd_image_t *img, Adafruit_ST7735 *tft,uint16_t icol, uint16_t irow, uint16_t scol, uint16_t srow, uint16_t width, uint16_t height);
#endif
 


this is the actual code
Code
Select All
/* Simple Image Drawing
 *
 * Draws an image to the screen.  The image is stored in "parrot.lcd" on
 * the SD card.  The image file contains only raw pixel byte-pairs.
 */

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <SD.h>
#include "lcd_image.h"

// standard U of A library settings, assuming Atmel Mega SPI pins
#define SD_CS    5  // Chip select line for SD card
#define TFT_CS   6  // Chip select line for TFT display
#define TFT_DC   7  // Data/command line for TFT
#define TFT_RST  8  // Reset line for TFT (or connect to +5V)


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

lcd_image_t map_image = { "parrot.lcd", 128, 128 };

void setup(void) {
  Serial.begin(9600);

  // If your TFT's plastic wrap has a Red Tab, use the following:
  tft.initR(INITR_REDTAB);   // initialize a ST7735R chip, red tab
  // If your TFT's plastic wrap has a Green Tab, use the following:
  //tft.initR(INITR_GREENTAB); // initialize a ST7735R chip, green tab

  Serial.print("Initializing SD card...");
  if (!SD.begin(SD_CS)) {
    Serial.println("failed!");
    return;
  }
  Serial.println("OK!");

  // clear to yellow
  tft.fillScreen(tft.Color565(0xff, 0xff, 0x00));

  lcd_image_draw(&map_image, &tft, 0, 0, 0, 0, 128, 128);
  lcd_image_draw(&map_image, &tft, 0, 0, 64, 64, 64, 64);
}

void loop() {
} 


this is the error im getting
Code
Select All
Compiling 'parrot_display' for 'Arduino Mega 2560 or Mega ADK'
parrot_display.cpp.o : In function `setup'
parrot_display.cpp : undefined reference to `lcd_image_draw(lcd_image_t*, Adafruit_ST7735*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)'
parrot_display.cpp : undefined reference to `lcd_image_draw(lcd_image_t*, Adafruit_ST7735*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)'
avr-objcopy* : No such file
avr-objcopy* : No such file
Couldn't determine program size: C:\arduino\arduino-1.0.1\hardware\tools\avr\bin\avr-size: _display.hex': No such file

 



are there additional files required or changes needs to be made to the code?
« Last Edit: Oct 19th, 2012 at 10:53pm by sam9116 »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: having problems uploading program with headers to arduino
Reply #1 - Oct 19th, 2012 at 10:53pm
Print Post  
Does it compile okay in the arduino ide?

By the way the error messages will be improved in the next release! Not that they are too bad but should be neater
« Last Edit: Oct 19th, 2012 at 10:59pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
sam9116
Newbies
*
Offline


Posts: 6
Location: Edmonton
Joined: Oct 19th, 2012
Re: having problems uploading program with headers to arduino
Reply #2 - Oct 19th, 2012 at 10:55pm
Print Post  
Tim@Visual Micro wrote on Oct 19th, 2012 at 10:53pm:
Does it compile okay in the arduino ide?

By the way the error messages will be improved in the next release!.

thanks for the reminder, I'll try that on the arduino IDE and see how it goes
« Last Edit: Oct 19th, 2012 at 10:58pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: having problems uploading program with headers to arduino
Reply #3 - Oct 19th, 2012 at 11:03pm
Print Post  
By the way, where is the method called lcd_image_draw()?

The .h file contains the prototype but I can't see the method body in your code? Am I being thick?
  
Back to top
WWW  
IP Logged
 
sam9116
Newbies
*
Offline


Posts: 6
Location: Edmonton
Joined: Oct 19th, 2012
Re: having problems uploading program with headers to arduino
Reply #4 - Oct 19th, 2012 at 11:51pm
Print Post  
it worked!,the problem was i didn't link the lcd_image.cpp to resource file!
« Last Edit: Oct 20th, 2012 at 12:09am by sam9116 »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: having problems uploading program with headers to arduino
Reply #5 - Oct 19th, 2012 at 11:57pm
Print Post  
There are some slightly different compiler flags in the make file that will shortly be supported. This might affect compilation as it stands at the moment. When the new flags are supported I will show you how to register your own board so that it appeas in the boards list with the other arduino boards.

However right now the first problem is to find the missing .cpp source for the .h. There should be a lcd_image.cpp or .c?

Where did you get this project? Can you give me a link?



« Last Edit: Oct 19th, 2012 at 11:59pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
sam9116
Newbies
*
Offline


Posts: 6
Location: Edmonton
Joined: Oct 19th, 2012
Re: having problems uploading program with headers to arduino
Reply #6 - Oct 20th, 2012 at 12:01am
Print Post  
it worked, its just i didn't link that file to the lcd_image display.cpp to the resource file, thanks for the hint!
« Last Edit: Oct 20th, 2012 at 12:11am by sam9116 »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: having problems uploading program with headers to arduino
Reply #7 - Oct 20th, 2012 at 12:21am
Print Post  
Okay it compiles fine for me. This is what I did.

1) Library Install

Download the two adafruit libraries to GFX and ST7735 to any of the two allowed arduino library locations. arduinoexe/libraries or mydocuments/arduino/libraries. 

The folder names containing the libraries must match the name of the library. So you should have two folders "Adafruit_GFX" and "Adafruit_ST7735"

2) Sketch Install

Download the zip in your link and unpack into a folder below your "mydocuments\arduino" sketch folder called simpleimage. rename the file called simpleimage.cpp to simpleimage.ino.

The arduino rule is that the folder name must match the name of the master .ino file. In this example simpleimage is both the folder name and the name of the .ino that contains the setup() and loop() methods. 

Example: If you want to unpack the zip and make an arduino project with a different name ... Unpack the zip to a new folder called "MyParrotTestBlah"  and rename the simpleimage.cpp to MyParrotTestBlah.ino

Let me know how you get on. Thanks

ps: I'll move this thread into the project guidance section. It will be useful for others
« Last Edit: Oct 20th, 2012 at 12:22am by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
sam9116
Newbies
*
Offline


Posts: 6
Location: Edmonton
Joined: Oct 19th, 2012
Re: having problems uploading program with headers to arduino
Reply #8 - Oct 20th, 2012 at 12:28am
Print Post  
Tim@Visual Micro wrote on Oct 20th, 2012 at 12:21am:
Okay it compiles fine for me. This is what I did.

1) Library Install

Download the two adafruit libraries to GFX and ST7735 to any of the two allowed arduino library locations. arduinoexe/libraries or mydocuments/arduino/libraries. 

The folder names containing the libraries must match the name of the library. So you should have two folders "Adafruit_GFX" and "Adafruit_ST7735"

2) Sketch Install

Download the zip in your link and unpack into a folder below your "mydocuments\arduino" sketch folder called simpleimage. rename the file called simpleimage.cpp to simpleimage.ino.

The arduino rule is that the folder name must match the name of the master .ino file. In this example simpleimage is both the folder name and the name of the .ino that contains the setup() and loop() methods. 

Example: If you want to unpack the zip and make an arduino project with a different name ... Unpack the zip to a new folder called "MyParrotTestBlah"  and rename the simpleimage.cpp to MyParrotTestBlah.ino

Let me know how you get on. Thanks

ps: I'll move this thread into the project guidance section. It will be useful for others

here is the lcd_display.cpp that i used to hook up to resource file secion to make it work

Code
Select All
/*
 * Routine for drawing an image patch from the SD card to the LCD display.
 */

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <SD.h>

#include "lcd_image.h"

/* Draws the referenced image to the LCD screen.
 *
 * img           : the image to draw
 * tft           : the initialized tft struct
 * icol, irow    : the upper-left corner of the image patch to draw
 * scol, srow    : the upper-left corner of the screen to draw to
 * width, height : controls the size of the patch drawn.
 */
void lcd_image_draw(lcd_image_t *img, Adafruit_ST7735 *tft,
		    uint16_t icol, uint16_t irow,
		    uint16_t scol, uint16_t srow,
		    uint16_t width, uint16_t height)
{
  File file;

  // Open requested file on SD card if not already open
  if ((file = SD.open(img->file_name)) == NULL) {
    Serial.print("File not found:'");
    Serial.print(img->file_name);
    Serial.println('\'');
    return;  // how do we inform the caller than things went wrong?
  }

  // Setup display to receive window of pixels
  tft->setAddrWindow(scol, srow, scol+width-1, srow+height-1);

  for (uint16_t row=0; row < height; row++) {
    uint16_t pixels[width];

    uint32_t pos;

    // Seek to start of pixels to read from, need 32 bit arith for big images
    pos = ( (uint32_t) irow +  (uint32_t) row) *
                 (2 *  (uint32_t) img->ncols) +  (uint32_t) icol * 2;
    file.seek(pos);

    // Read row of pixels
    if (file.read((uint8_t *) pixels, 2 * width) != 2 * width) {
      Serial.println("SD Card Read Error!");
      file.close();
      return;
    }

    // Send pixels to display
    for (uint16_t col=0; col < width; col++) {
      uint16_t pixel = pixels[col];

      // pixel bytes in reverse order on card
      pixel = (pixel << 8) | (pixel >> 8);
      tft->pushColor(pixel);
    }
  }

  file.close();
}

 

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: having problems uploading program with headers to arduino
Reply #9 - Oct 20th, 2012 at 12:36am
Print Post  
I'm sorry I don't understand. The code you show is lcd_image.cpp and is included in the arduino program because the lcd_image.h is included in your main sketch file. It compiled first time without change for me.

What does this mean?

Quote:
here is the lcd_display.cpp that i used to hook up to resource file section to make it work


Thanks
  
Back to top
WWW  
IP Logged
 
Marius
Developer
****
Offline


Posts: 204
Location: Centurion RSA
Joined: Sep 7th, 2011
Re: having problems uploading program with headers to arduino
Reply #10 - Oct 20th, 2012 at 6:14am
Print Post  
Tim
The image is converted to an array containing pixel information in that file. That is how my system works anyway.
  
Back to top
IP Logged
 
sam9116
Newbies
*
Offline


Posts: 6
Location: Edmonton
Joined: Oct 19th, 2012
Re: having problems uploading program with headers to arduino
Reply #11 - Oct 20th, 2012 at 9:05am
Print Post  
Remember the undefined reference to LCD_image?that was what led to the .hex file no such file or directory error

The .h file called the prototype for Lcd_image
The.cpp file defined what LCD_image does(this was the part I was scratching my head for two hours try to figure out a solution,and that's why I decide to come here and ask.my instructor actually told to write a whole new compiler for some reason,for first year student , it basically meant go f* myself)
And the simpleimage.ino calls the LCD_image function to display image


« Last Edit: Oct 20th, 2012 at 9:13am by sam9116 »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: having problems uploading program with headers to arduino
Reply #12 - Oct 20th, 2012 at 2:46pm
Print Post  
Oh okay thanks both

So I can assume that everything is good and working unless you say otherwise  Smiley
« Last Edit: Oct 20th, 2012 at 3:22pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint