I have a weather-related Arduino Yun project I'm building. I wanted to read small BMP image files from the SD card on the Yun but I've run into a problem. It appears the Bridge is reading the bytes incorrectly. I've been working through this issue with Adafruit as the icon will be displayed on their 2.8" TFT and I started with their sample code. At this point we both think there is a bug in the Bridge. There is a thread showing all the steps in troubleshooting we have taken on their forum at this URL.
To display the icon I need to read sets of RGB values and push them to the TFT. What we have observed is that on each 64 byte boundary their is a 'glitch' and the Bridge returns the wrong value and also is at the wrong position in the file. As I said, full details are on the Adafruit forum and I don't want to duplicate it all here but here is a snippet showing the RGB values and position values as we cross a 64 byte boundary. At this point in the file the Bridge should continue reading RGB values of (42, 46, 50) but instead returns (50, 42, 46) and also the position increments by 2 when reading at the boundary going from 6102 to 6104.
42, (6094), (46, (6095), (50, (6096)
42, (6097), (46, (6098), (50, (6099)
42, (6100), (46, (6101), (50, (6102) <------------ Increments by 3 up until this point, then next position is +2 and wrong data
50, (6104), (42, (6105), (46, (6106)
50, (6107), (42, (6108), (46, (6109)
This pattern of wrong data and a position skip continues every 64 bytes through the file.I've verified the file on the SD card is identical to the original BMP using mk5 checksums so I don't think there is any issue with the file itself. Also, I am reading and writing small files with no issue. One thing that may be unique in this sketch is it isn't simply starting with the first byte and reading to the end. It seeks to positions in the file to read the different rows needed to display the icon. Also of note is the sample code works fine with the TFT shield on a regular Arduino using the SD library (but of course I had to modify it for use on the Yun). I am using IDE version 1.5.4.
I'm wondering if the team could check into. As things stand now I'm unable to display icons. I can't post the full sketch as the forum complains the post is too long. But below is the loop that is reading the RGB values when the errors occur.
for (col=0; col<w; col++) { // For each pixel...
b = bmpFile.read();
delay(500);
int p1 = bmpFile.position();
g = bmpFile.read();
delay(500);
int p2 = bmpFile.position();
r = bmpFile.read();
delay(500);
int p3 = bmpFile.position();
Console.print(r); Console.print(", (");
Console.print(p1); Console.print("), (");
Console.print(g); Console.print(", (");
Console.print(p2); Console.print("), (");
Console.print(b); Console.print(", (");
Console.print(p3); Console.println(")");
tft.pushColor(tft.color565(r,g,b));
} // end pixel