Muestreo de imágenes en pantalla TFT

Buenas, tardes.
Tengo una duda respecto a mostrar imágenes en una pantalla TFT 3.5" con controlador grafico ILI9486
queiro mostrar imagenes guardadas en la memoria SD, hasta ahora lo logre pero el problema es que necesito que las muestre con mayor rapidez ya que hasta el momento muestra cada imagen con un tiempo aproximado de 7 segundos queria saber si alguien sabe como puedo aumentar la velocidad de muestreo de las imagenes.

Muchas gracias y saludos

Adjunto mi codigo

#include <Adafruit_GFX.h> // Libreria de graficos
//#include <Adafruit_TFTLCD.h> // Libreria de LCD
#include <SD.h> // Libreria de tarjeta SD
#include <SPI.h> // Libreria bus SPI
#include <UTFT.h>
//#include <Adafruit_TFTLCD.h>
#include <TouchScreen.h>
#include <UTFTGLUE.h>
#include <stdint.h>
#include <MCUFRIEND_kbv.h>
#include <EEPROM.h>
UTFTGLUE myGLCD(0x9481, A2, A1, A3, A4, A0);
MCUFRIEND_kbv tft;

#define YP A1
#define XM A2
#define YM 7
#define XP 6

//Rotacion 3
short TS_MINX = 68; // Controla el final de eje X del lado derecho en rotacion 3
#define TS_MAXX 950 //Controla el inicio de eje X del lado izquierdo en rotacion 3 // no contenpla los botones prediseñados 1-318
short TS_MINY = 170; // inicio Eje Y
#define TS_MAXY 890 // fin Eje Y
//Rotacion 3

#define MINPRESSURE 1
#define MAXPRESSURE 1000
// Instancia del panel tactil (Pin XP, YP, XM, YM, Resistencia del panel)
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 364);

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4

#if defined AVR_ATmega2560
#define SD_SCK 52
#define SD_MISO 50
#define SD_MOSI 51

#endif

#define SD_CS 53
//Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, A4);

#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
uint16_t color;

int X, Y, Z;

void setup()
{
Serial.begin(9600); // Iniciamos el puerto serie para comprobar
// la comunicacion con la tarjeta microSD
uint16_t ID;
ID = tft.readID();
Serial.println(ID, HEX);
if (ID == 0x0D3D3) ID = 0x9481;
tft.begin(ID);
tft.setRotation(1);
tft.fillScreen(0x0000);
Serial.print(F(“Inicializando tarjeta SD…”));

if (!SD.begin(SD_CS)) // Si se produce un error al intentar acceder
{ // a la tarjeta SD, lo mostramos por el Serial Monitor
Serial.println(F(“Error!”));
return;
}
Serial.println(F(“OK!”));

bmpDraw(“1.bmp”,0,0);

}
void loop () {}

#define BUFFPIXEL 20

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

File bmpFile;
int bmpWidth, bmpHeight; // W+H in pixels
uint8_t bmpDepth; // Bit depth (currently must be 24)
uint32_t bmpImageoffset; // Start of image data in file
uint32_t rowSize; // Not always = bmpWidth; may have padding
uint8_t sdbuffer[3*BUFFPIXEL]; // pixel in buffer (R+G+B per pixel)
uint16_t lcdbuffer[BUFFPIXEL]; // pixel out buffer (16-bit per pixel)
uint8_t buffidx = sizeof(sdbuffer); // Current position in sdbuffer
boolean goodBmp = false; // Set to true on valid header parse
boolean flip = true; // BMP is stored bottom-to-top
int w, h, row, col;
uint8_t r, g, b;
uint32_t pos = 0, startTime = millis();
uint8_t lcdidx = 0;
boolean first = true;

if((x >= tft.width()) || (y >= tft.height())) return;

#ifdef DEBUG
tft.fillScreen(0);
tft.setCursor(0,0);
tft.print(F(“Loading image '”));
tft.print(filename);
tft.println(’’’);
#endif
// Open requested file on SD card
if ((bmpFile = SD.open(filename)) == NULL) {
#ifdef DEBUG
tft.println(F(“File not found”));
#endif
return;
}

// Parse BMP header
if(read16(bmpFile) == 0x4D42) {
// BMP signature
#ifdef DEBUG
tft.println(F("File size: ")); tft.println(read32(bmpFile));
#else
read32(bmpFile);
#endif
(void)read32(bmpFile); // Read & ignore creator bytes
bmpImageoffset = read32(bmpFile); // Start of image data
#ifdef DEBUG
tft.print(F("Image Offset: ")); tft.println(bmpImageoffset, DEC);
// Read DIB header
tft.print(F("Header size: ")); tft.println(read32(bmpFile));
#else
read32(bmpFile);
#endif

bmpWidth = read32(bmpFile);
bmpHeight = read32(bmpFile);
if(read16(bmpFile) == 1) { // # planes – must be ‘1’
bmpDepth = read16(bmpFile); // bits per pixel
#ifdef DEBUG
// Serial.print(F("Bit Depth: ")); Serial.println(bmpDepth);
#endif
if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed

goodBmp = true; // Supported BMP format – proceed!
#ifdef DEBUG
tft.print(F("Image size: "));
tft.print(bmpWidth);
tft.print(‘x’);
tft.println(bmpHeight);
//delay(3000);
#endif*/
// BMP rows are padded (if needed) to 4-byte boundary
rowSize = (bmpWidth * 3 + 3) & ~3;

// If bmpHeight is negative, image is in top-down order.
// This is not canon but has been observed in the wild.
if(bmpHeight < 0) {
bmpHeight = -bmpHeight;
flip = false;
}

// Crop area to be loaded
w = bmpWidth;
h = bmpHeight;
if((x+w-1) >= tft.width()) w = tft.width() - x;
if((y+h-1) >= tft.height()) h = tft.height() - y;

// Set TFT address window to clipped image bounds
tft.setAddrWindow(x, y, x+w-1, y+h-1);

for (row=0; row<h; row++) { // For each scanline…
// Seek to start of scan line. It might seem labor-
// intensive to be doing this on every line, but this
// method covers a lot of gritty details like cropping
// and scanline padding. Also, the seek only takes
// place if the file position actually needs to change
// (avoids a lot of cluster math in SD library).
if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
else // Bitmap is stored top-to-bottom
pos = bmpImageoffset + row * rowSize;
if(bmpFile.position() != pos) { // Need seek?
bmpFile.seek(pos);
buffidx = sizeof(sdbuffer); // Force buffer reload
}

for (col=0; col<w; col++) { // For each column…
// Time to read more pixel data?
if (buffidx >= sizeof(sdbuffer)) { // Indeed
// Push LCD buffer to the display first
if(lcdidx > 0) {
tft.pushColors(lcdbuffer, lcdidx, first);
lcdidx = 0;
first = false;
}
bmpFile.read(sdbuffer, sizeof(sdbuffer));
buffidx = 0; // Set index to beginning
}

// Convert pixel from BMP to TFT format
b = sdbuffer[buffidx++];
g = sdbuffer[buffidx++];
r = sdbuffer[buffidx++];
lcdbuffer[lcdidx++] = tft.color565(r,g,b);
} // end pixel
} // end scanline
// Write any remaining data to LCD
if(lcdidx > 0) {
tft.pushColors(lcdbuffer, lcdidx, first);
}

} // end goodBmp
}
}

bmpFile.close();
if(!goodBmp) tft.println(F(“BMP format not recognized.”));
}

// These read 16- and 32-bit types from the SD card file.
// BMP data is stored little-endian, Arduino is little-endian too.
// May need to reverse subscript order if porting elsewhere.

uint16_t read16(File f) {
uint16_t result;
((uint8_t *)&result)[0] = f.read(); // LSB
((uint8_t *)&result)[1] = f.read(); // MSB
return result;
}

uint32_t read32(File 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;
}

imagen.c (7.54 KB)

Moderador
Hola, bienvenido al foro Arduino en Español

Por favor edita tu post usando etiquetas de código.
Los códigos menores a 9k deben hacerse visibles.
Gracias.

Normas del foro

Las extensiones de Arduino son .ino no .c ni .txt. Tenlo presente

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.