1 Reply Latest reply on Aug 26, 2015 4:36 PM by Intel_Alvarado

    How should one configure Arduino IDE and application code for Edison?

    jrs_asgard

      A previous project using a 1.3" panel with the SD card breakout built-in had previously worked as expected, when using the Atmel boards (Uno, etc).

      Now I have been migrating this project to use the Intel Edison / Arduino combination. "Some" of the existing code works fine, but not the SD card.

       

      One digression here. After some head scratching I found out that the C++ pre-processor has a funny idea about how to insert the Arduino support wrapper around the sketch file, when the x86 architecture is selected. Apparently the wrapper code is inserted one "line" in front of the first parseable piece of code, which means that:

       

        #include <iostream>

        #include <SPI.h>

        #include <SD.h>

       

        void setup(void)

        { /* ... */

        }

       

      This piece of code will not compile on the Edison - the inserted wrapper occurs *after* the include directives. Really nasty.

      To make that part work I have to insert a junky dummy as the first line *before* the include directives:

       

        struct __useless {char __dummy; };

       

      This is a pass-two parseable line of code that does not actually consume any memory.

       

      I am still trying to puzzle out why File and read16/read32 references won't compile with the Edison but does with the Uno, as follows:

       

        /* */

        struct __useless { char whatever; };

        /* */

       

        #include <iostream>

       

        #include <SPI.h> // Core SPI devices library

        #include <SD.h> // SPI SD card driver

       

        #include <Adafruit_GFX.h> // Core graphics library

        #include <Adafruit_ST7735.h> // LCD panel driver

       

        void setup (void) { /* ... */ }

       

        // ...

       

        // This function opens a Windows Bitmap (BMP) file and

        // displays it at the given coordinates. It's sped up

        // by reading many pixels worth of data at a time

        // (rather than pixel by pixel). Increasing the buffer

        // size takes more of the Arduino's precious RAM but

        // makes loading a little faster. 20 pixels seems a

        // good balance.

       

        #define BUFFPIXEL 20

       

        void bmpDraw(char *filename, uint8_t x, uint8_t y) {

       

        File bmpFile;

       

        // Open requested file on SD card

       

        if ((bmpFile = SD.open(filename)) == NULL) {

        Serial.print("File not found");

        return;

        }

       

        // Parse BMP header

        if(read16(bmpFile) == 0x4D42) { // BMP signature

       

        /* ...and so on.*/

       

      The compiler here will complain about 'File' not declared in this scope (bmpfile declaration), and that 'read16' cannot be used as a function.

       

      For what it is worth all of the include files and references are plain unmodified Adafruit drivers, and as such, worked correctly when using the Arduino boards as the target

       

      Ideas?

       

      J.R. Stoner

      BDG

        • 1. Re: How should one configure Arduino IDE and application code for Edison?
          Intel_Alvarado

          Hi,

           

          What error specifically are you receiving? Could you add a screenshot of the log in the Arduino IDE? Also what IDE version are you using? I checked the SD sketches included in the IDE and all compiled and uploaded fine and they use

           

          #include <SPI.h 

          #include <SD.h>

           

          I also took a look at the Adafruit libraries you are using and if you do some additional work you are likely to get them working. From where did you download these libraries? Where in the Arduino folder did you place the libraries?

           

          Sergio