Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • 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
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
having problems uploading program with headers to arduino (Read 14341 times)
sam9116
Newbies
*
Offline



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

this is the header file
Code:
/*
 * 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:
/* 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:
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: 'C:\Users\Sam\AppData\Local\VMicro\Arduino\Builds\parrot_display\mega2560\parrot_display.hex': No such file

 



are there additional files required or changes needs to be made to the code?
Back to top
« Last Edit: Oct 19th, 2012 at 11:53pm by sam9116 »  

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10706
United Kingdom
Re: having problems uploading program with headers to arduino
Reply #1 - Oct 19th, 2012 at 11:53pm
 
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
Back to top
« Last Edit: Oct 19th, 2012 at 11:59pm by Visual Micro »  

Please Register or Login to the Forum to see File Attachments
WWW  
IP Logged
 
sam9116
Newbies
*
Offline



Posts: 6
Edmonton
Re: having problems uploading program with headers to arduino
Reply #2 - Oct 19th, 2012 at 11:55pm
 
Visual Micro wrote on Oct 19th, 2012 at 11: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
Back to top
« Last Edit: Oct 19th, 2012 at 11:58pm by Visual Micro »  

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10706
United Kingdom
Re: having problems uploading program with headers to arduino
Reply #3 - Oct 20th, 2012 at 12:03am
 
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
 

Please Register or Login to the Forum to see File Attachments
WWW  
IP Logged
 
sam9116
Newbies
*
Offline



Posts: 6
Edmonton
Re: having problems uploading program with headers to arduino
Reply #4 - Oct 20th, 2012 at 12:51am
 
it worked!,the problem was i didn't link the lcd_image.cpp to resource file!
Back to top
« Last Edit: Oct 20th, 2012 at 1:09am by sam9116 »  

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10706
United Kingdom
Re: having problems uploading program with headers to arduino
Reply #5 - Oct 20th, 2012 at 12:57am
 
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?



Back to top
« Last Edit: Oct 20th, 2012 at 12:59am by Visual Micro »  

Please Register or Login to the Forum to see File Attachments
WWW  
IP Logged
 
sam9116
Newbies
*
Offline



Posts: 6
Edmonton
Re: having problems uploading program with headers to arduino
Reply #6 - Oct 20th, 2012 at 1:01am
 
it worked, its just i didn't link that file to the lcd_image display.cpp to the resource file, thanks for the hint!
Back to top
« Last Edit: Oct 20th, 2012 at 1:11am by sam9116 »  

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10706
United Kingdom
Re: having problems uploading program with headers to arduino
Reply #7 - Oct 20th, 2012 at 1: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
Back to top
« Last Edit: Oct 20th, 2012 at 1:22am by Visual Micro »  

Please Register or Login to the Forum to see File Attachments
WWW  
IP Logged
 
sam9116
Newbies
*
Offline



Posts: 6
Edmonton
Re: having problems uploading program with headers to arduino
Reply #8 - Oct 20th, 2012 at 1:28am
 
Visual Micro wrote on Oct 20th, 2012 at 1: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:
/*
 * 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
 

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10706
United Kingdom
Re: having problems uploading program with headers to arduino
Reply #9 - Oct 20th, 2012 at 1:36am
 
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
 

Please Register or Login to the Forum to see File Attachments
WWW  
IP Logged
 
Marius
Developer
****
Offline



Posts: 198
Centurion RSA
Re: having problems uploading program with headers to arduino
Reply #10 - Oct 20th, 2012 at 7:14am
 
Tim
The image is converted to an array containing pixel information in that file. That is how my system works anyway.
Back to top
 

Please Register or Login to the Forum to see File Attachments
marius_d.liebenberg  
IP Logged
 
sam9116
Newbies
*
Offline



Posts: 6
Edmonton
Re: having problems uploading program with headers to arduino
Reply #11 - Oct 20th, 2012 at 10:05am
 
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


Back to top
« Last Edit: Oct 20th, 2012 at 10:13am by sam9116 »  

Please Register or Login to the Forum to see File Attachments
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10706
United Kingdom
Re: having problems uploading program with headers to arduino
Reply #12 - Oct 20th, 2012 at 3:46pm
 
Oh okay thanks both

So I can assume that everything is good and working unless you say otherwise  Smiley
Back to top
« Last Edit: Oct 20th, 2012 at 4:22pm by Visual Micro »  

Please Register or Login to the Forum to see File Attachments
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print