Alright so sorry for bringing this thread back but I have an update. I bought an ardunio uno as requested. Everything seems to be working a lot better now. BUT its still not working perfectly. By using the script on the website I’ve been able to make some progress I make sure the images are named right and are 16 bit but regardless of what I do I seem to have an issue with the screen distorting horribly when running the tftbmp sketch. Here is an example of what the screen does i.imgur.com/kIFizQY.png Occasionally the screen will just be completely black.
If you notice the only difference between this and the original is that I changed the pins to 10 instead of 53. Since the uno doesn’t have a pin 53 I figured this has to be incorrect and indeed it was. Now I do get things on the screen but its all garbled (unlike before when nothing would come up). By editing it it seems to allow it to access the sd card here is the current adaptation.
[code]// This sketch is adapted to Seeed’s TFT library from
// https://github.com/adafruit/TFTLCD-Library/blob/master/examples/tftbmp/tftbmp.pde
// by ladyada/adafruit under MIT license
#include <SD.h>
#include <TFT.h>
// In the SD card, place 24 bit color BMP files (be sure they are 24-bit!)
// the file itself
File bmpFile;
// information we extract about the bitmap file
int bmpWidth, bmpHeight;
uint8_t bmpDepth, bmpImageoffset;
void setup()
{
Serial.begin(9600);
Tft.init();
Serial.print(“Initializing SD card…”);
pinMode(10, OUTPUT); //53 is used as chip select pin
if (!SD.begin(10)) { //53 is used as chip select pin
Serial.println(“failed!”);
return;
}
Serial.println(“SD OK!”);
}
void loop()
{
Tft.setOrientation(0);
//Image 1
bmpFile = SD.open(“flower.bmp”);
if (! bmpFile) {
Serial.println(“didnt find image”);
while (1);
}
if (! bmpReadHeader(bmpFile)) {
Serial.println(“bad bmp”);
return;
}
Serial.print("image size “);
Serial.print(bmpWidth, DEC);
Serial.print(”, ");
Serial.println(bmpHeight, DEC);
bmpdraw(bmpFile, 0, 0);
delay(3000);
bmpFile.close();
//Image 2
bmpFile = SD.open(“hibiscus.bmp”);
if (! bmpFile) {
Serial.println(“didnt find image”);
while (1);
}
if (! bmpReadHeader(bmpFile)) {
Serial.println(“bad bmp”);
return;
}
Serial.print("image size “);
Serial.print(bmpWidth, DEC);
Serial.print(”, ");
Serial.println(bmpHeight, DEC);
bmpdraw(bmpFile, 0, 0);
delay(3000);
}
/*********************************************/
// This procedure reads a bitmap and draws it to the screen
// its sped up by reading many pixels worth of data at a time
// instead of just one pixel at a time. increading the buffer takes
// more RAM but makes the drawing a little faster. 20 pixels’ worth
// is probably a good place
#define BUFFPIXEL 20
void bmpdraw(File f, int x, int y) {
bmpFile.seek(bmpImageoffset);
uint32_t time = millis();
uint16_t p;
uint8_t g, b;
int i, j;
uint8_t sdbuffer[3 * BUFFPIXEL]; // 3 * pixels to buffer
uint8_t buffidx = 3*BUFFPIXEL;
for (i=0; i< bmpHeight; i++) {
Tft.setXY(x, y+bmpHeight-i);
for (j=0; j<bmpWidth; j++) {
// read more pixels
if (buffidx >= 3*BUFFPIXEL) {
bmpFile.read(sdbuffer, 3*BUFFPIXEL);
buffidx = 0;
}
// convert pixel from 888 to 565
b = sdbuffer[buffidx++]; // blue
g = sdbuffer[buffidx++]; // green
p = sdbuffer[buffidx++]; // red
p >>= 3;
p <<= 6;
g >>= 2;
p |= g;
p <<= 5;
b >>= 3;
p |= b;
// write out the 16 bits of color
Tft.sendData(p);
}
}
Serial.print(millis() - time, DEC);
Serial.println(" ms");
}
boolean bmpReadHeader(File f) {
// read header
uint32_t tmp;
if (read16(f) != 0x4D42) {
// magic bytes missing
return false;
}
// read file size
tmp = read32(f);
Serial.print(“size 0x”); Serial.println(tmp, HEX);
// read and ignore creator bytes
read32(f);
bmpImageoffset = read32(f);
Serial.print("offset "); Serial.println(bmpImageoffset, DEC);
// read DIB header
tmp = read32(f);
Serial.print("header size "); Serial.println(tmp, DEC);
bmpWidth = read32(f);
bmpHeight = read32(f);
if (read16(f) != 1)
return false;
bmpDepth = read16(f);
Serial.print("bitdepth "); Serial.println(bmpDepth, DEC);
if (read32(f) != 0) {
// compression not supported!
return false;
}
Serial.print("compression "); Serial.println(tmp, DEC);
return true;
}
/*********************************************/
// These read data from the SD card file and convert them to big endian
// (the data is stored in little endian format!)
// LITTLE ENDIAN!
uint16_t read16(File f) {
uint16_t d;
uint8_t b;
b = f.read();
d = f.read();
d <<= 8;
d |= b;
return d;
}
// LITTLE ENDIAN!
uint32_t read32(File f) {
uint32_t d;
uint16_t b;
b = read16(f);
d = read16(f);
d <<= 16;
d |= b;
return d;
}
[/code]
By checking the serial monitor I get this
Initializing SD card...SD OK!
size 0x27DB6
offset 54
header size 40
bitdepth 16
compression 40
image size 240, 340
2051 ms
size 0x25836
offset 54
header size 40
bitdepth 16
compression 40
image size 240, 320
1929 ms
size 0x27DB6
offset 54
header size 40
bitdepth 16
compression 40
image size 240, 340
2051 ms
size 0x25836
offset 54
header size 40
bitdepth 16
compression 40
image size 240, 320
1931 ms
size 0x27DB6
offset 54
header size 40
bitdepth 16
compression 40
image size 240, 340
2051 ms
size 0x25836
offset 54
header size 40
bitdepth 16
compression 40
image size 240, 320
1932 ms
size 0x27DB6
offset 54
header size 40
bitdepth 16
compression 40
image size 240, 340