AM 10:00 ~ PM 05:00 / ɽð PM 12:00 ~ PM 01:00
ް ڼ ֽø ִ 亯帮ڽϴ.
ֹ,, Ǵ <1:1 Խ> ֽ̿ñ ٶϴ.

Ҹ ͱ̴ īַ ǵ ϰڽϴ.
16Ⱑ Sdī忡 bmp ̹ ְ ȭ鿡 ϴ ۾ ϰ ִµ, sdī尡 16Ⱑ ͳݿ (2Ⱑsdī̿) ̿ϰ ֽϴ
ٸ Ϲ ؽƮ , ð¥ ǥϱ Ǵµ sdī忡 ̹ ° ȵdz׿

http://kocoafab.cc/tutorial/view/230 
̰ 鼭 غϴµ.. 

1. ٸ ILI9327 ؼ ư ߽ϴ. ׷ ILI9327 𵨸 ³?

2. ILI9327 𵨸̶ Ͽ Ʈ 󰡵, ILI9327 ̺귯 ãƼ (UTFT_master) ̺귯 ߰Ͽ ׽Ʈ Ͽµ Ͽϴ..

3. ͳ Ʈ ̺귯 ߰ , bmp , bmp ϸ ְ ̹ ϰ ϴ ̰ ȵɱ..Ф 亯 Ź帳ϴ..!!

ILI9327 ̺귯 ߰Ͽ Դϴ. 

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <SD.h>
#include <SPI.h>

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0

Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, A4);

void setup()
{
  Serial.begin(9600);

  tft.reset();

  uint16_t identifier = tft.readID();

  if(identifier == 0x9325) {
    Serial.println(F("Found ILI9325 LCD driver"));
  } else if(identifier == 0x9328) {
    Serial.println(F("Found ILI9328 LCD driver"));
  } else if(identifier == 0x7575) {
    Serial.println(F("Found HX8347G LCD driver"));
  } else if(identifier == 0x9341) {
    Serial.println(F("Found ILI9341 LCD driver"));
  } else if(identifier == 0x8357) {
    Serial.println(F("Found HX8357D LCD driver"));
  } else {
    Serial.print(F("Unknown LCD driver chip: "));
    Serial.println(identifier, HEX);
    Serial.println(F("If using the Adafruit 2.8\" TFT Arduino shield, the line:"));
    Serial.println(F("  #define USE_ADAFRUIT_SHIELD_PINOUT"));
    Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
    Serial.println(F("If using the breakout board, it should NOT be #defined!"));
    Serial.println(F("Also if using the breakout, double-check that all wiring"));
    Serial.println(F("matches the tutorial."));
    return;
  }

  tft.begin(identifier);

  Serial.print(F("Initializing SD card..."));
  if (!SD.begin(SD_CS)) {
    Serial.println(F("failed!"));
    return;
  }
  Serial.println(F("OK!"));

  bmpDraw("test.bmp", 0, 0);
  delay(1000);
}

void loop()
{
  for(int i = 0; i<4; i++) {
    tft.setRotation(i);
    tft.fillScreen(0);
    for(int j=0; j <= 200; j += 50) {
      bmpDraw("test.bmp", j, j);
    }
    delay(1000);
  }
}
#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;

  Serial.println();
  Serial.print(F("Loading image '"));
  Serial.print(filename);
  Serial.println('\'');
  // Open requested file on SD card
  if ((bmpFile = SD.open(filename)) == NULL) {
    Serial.println(F("File not found"));
    return;
  }

  // Parse BMP header
  if(read16(bmpFile) == 0x4D42) { // BMP signature
    Serial.println(F("File size: ")); Serial.println(read32(bmpFile));
    (void)read32(bmpFile); // Read & ignore creator bytes
    bmpImageoffset = read32(bmpFile); // Start of image data
    Serial.print(F("Image Offset: ")); Serial.println(bmpImageoffset, DEC);
    // Read DIB header
    Serial.print(F("Header size: ")); Serial.println(read32(bmpFile));
    bmpWidth  = read32(bmpFile);
    bmpHeight = read32(bmpFile);
    if(read16(bmpFile) == 1) { // # planes -- must be '1'
      bmpDepth = read16(bmpFile); // bits per pixel
      Serial.print(F("Bit Depth: ")); Serial.println(bmpDepth);
      if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed

        goodBmp = true; // Supported BMP format -- proceed!
        Serial.print(F("Image size: "));
        Serial.print(bmpWidth);
        Serial.print('x');
        Serial.println(bmpHeight);

        // 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);
        } 
        Serial.print(F("Loaded in "));
        Serial.print(millis() - startTime);
        Serial.println(" ms");
      } // end goodBmp
    }
  }

  bmpFile.close();
  if(!goodBmp) Serial.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;
}




<޼>


Ƶ̳:1.6.12 (Windows 10), :"Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\yeom\AppData\Local\Temp\arduino_modified_sketch_105802\tftbmp.pde: In function 'void setup()':

tftbmp:51: error: 'SD_CS' was not declared in this scope

   if (!SD.begin(SD_CS)) {

                 ^

C:\Users\yeom\AppData\Local\Temp\arduino_modified_sketch_105802\tftbmp.pde:57:27: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

   bmpDraw("test.bmp", 0, 0);

                           ^

C:\Users\yeom\AppData\Local\Temp\arduino_modified_sketch_105802\tftbmp.pde: In function 'void loop()':

C:\Users\yeom\AppData\Local\Temp\arduino_modified_sketch_105802\tftbmp.pde:67:31: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

       bmpDraw("test.bmp", j, j);

                               ^

C:\Users\yeom\AppData\Local\Temp\arduino_modified_sketch_105802\tftbmp.pde: In function 'void bmpDraw(char*, int, int)':

C:\Users\yeom\AppData\Local\Temp\arduino_modified_sketch_105802\tftbmp.pde:99:40: warning: converting to non-pointer type 'int' from NULL [-Wconversion-null]

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

                                        ^

exit status 1
'SD_CS' was not declared in this scope


tft lcd 2.8ġ() sdī ̹ ¹ () ȫԴ
Posted at 2016-11-17 10:30:16


Ʒ Ű 帳ϴ.
IR LED
tft lcd 2.8ġ() sdī ̹ ¹ ()
tft lcd 2.8ġ() sdī ̹ ¹ ()


û
Ŵ
/湮
ĺҰ