ZTiK.nl
Well-known member
Hello everyone,
I am trying to combine 2 example .ino files to make one functioning script, but I have been stuck at the same point for a while now.
I am combining the tftbmp example that comes with Adafruits TFTLCD library for (including but not limited to) the 2.8" Touchscreen TFT with SdFat, so that I can load fullscreen bmp files at reasonable speed.
A few hours ago I noticed a new SdFat so I updated, and finally my code does compile, but results arent as they should.
The most important change I made to the original tftbmp example is a call to SdFile.position() and one to SdFile.seek(pos):
which I changed to:
position() and search() could not be found in SdFat libs, but I did find curPosition() and seekSet()
This code resulted in compile errors in the previous SdFat beta (dated 12/2012) but it does compile in the newer version.
However, I believe that the problem lies in two other functions which I only changed to point to SdFile instead of File:
The reason I think the problem lies here is because right after where the file is opened there is a check for the BMP signature, which doesnt validate.
I'm not too sure how to troubleshoot any further, so I'm kinda looking for any advice on where I'm going the wrong way.
(I included the original example .ino file and my 'updated' .ino file, SdFat can be downloaded here and the full TFTLCD lib is here)
I am trying to combine 2 example .ino files to make one functioning script, but I have been stuck at the same point for a while now.
I am combining the tftbmp example that comes with Adafruits TFTLCD library for (including but not limited to) the 2.8" Touchscreen TFT with SdFat, so that I can load fullscreen bmp files at reasonable speed.
A few hours ago I noticed a new SdFat so I updated, and finally my code does compile, but results arent as they should.
The most important change I made to the original tftbmp example is a call to SdFile.position() and one to SdFile.seek(pos):
Code:
if(bmpFile.position() != pos) { // Need seek?
bmpFile.search(pos);
buffidx = sizeof(sdbuffer); // Force buffer reload
}
Code:
if(bmpFile.curPosition() != pos) { // Need seek?
bmpFile.seekSet(pos);
buffidx = sizeof(sdbuffer); // Force buffer reload
}
This code resulted in compile errors in the previous SdFat beta (dated 12/2012) but it does compile in the newer version.
However, I believe that the problem lies in two other functions which I only changed to point to SdFile instead of File:
Code:
uint16_t read16(SdFile f) {
uint16_t result;
((uint8_t *)&result)[0] = f.read(); // LSB
((uint8_t *)&result)[1] = f.read(); // MSB
return result;
}
uint32_t read32(SdFile f) {
uint32_t result;
((uint8_t *)&result)[0] = f.read(); // LSB
((uint8_t *)&result)[1] = f.read();
((uint8_t *)&result)[2] = f.read();
((uint8_t *)&result)[3] = f.read(); // MSB
return result;
}
The reason I think the problem lies here is because right after where the file is opened there is a check for the BMP signature, which doesnt validate.
I'm not too sure how to troubleshoot any further, so I'm kinda looking for any advice on where I'm going the wrong way.
(I included the original example .ino file and my 'updated' .ino file, SdFat can be downloaded here and the full TFTLCD lib is here)