欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1038|回復: 3
打印 上一主題 下一主題
收起左側

Arduino庫有優(yōu)先級?

[復制鏈接]
跳轉到指定樓層
樓主
ID:1130032 發(fā)表于 2024-8-1 15:53 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
tft.startWrite()是TFT_eSPI庫(已使用)中的代碼但報錯是exit status 1  class Adafruit_ST7735' has no member named 'startWrite'; did you mean 'spiwrite'?
感覺沒有掃描到我引用的TFT_eSPI,一直說Adafruit_ST7735中沒有tft.startWrite()
源代碼如下,求求各位大神幫幫孩子吧。
//接線方式https://blog.csdn.net/moshanghuaw/article/details/122037124
#include <TFT_eSPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SD.h>
#include <SPI.h>

#if defined(__SAM3X8E__)
    #undef __FlashStringHelper::F(string_literal)
    #define F(string_literal) string_literal
#endif
//TFT顯示屏和SD卡將共享硬件SPI接口。
//硬件SPI引腳特定于Arduino板類型
//無法重新映射到備用接點。對于Arduino Uno,
//Duemilanove等,引腳11=MOSI,引腳12=MISO,引腳13=SCK。
#define SD_CS    4  // Chip select line for SD card
#define TFT_CS  10  // Chip select line for TFT display
#define TFT_DC   9  // Data/command line for TFT
#define TFT_RST  8  // Reset line for TFT (or connect to +5V)
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
#define BUFFPIXEL 20
void bmpDraw(char *filename, uint8_t x, uint8_t y)
{
  File     bmpFile;
  int      bmpWidth, bmpHeight;   // W+H(以像素為單位)
  uint8_t  bmpDepth;              // 位深度(當前必須為24)
  uint32_t bmpImageoffset;        // 文件中圖像數(shù)據(jù)的開始
  uint32_t rowSize;               // 不總是=bmpWidth;可能有填充
  uint8_t  sdbuffer[3*BUFFPIXEL]; // 像素緩沖區(qū)(每個像素R+G+B)
  uint8_t  buffidx = sizeof(sdbuffer); // sdbuffer中的當前位置
  boolean  goodBmp = false;       // 在有效的標頭分析時設置為true
  boolean  flip    = true;        // BMP自下而上存儲
  int      w, h, row, col;
  uint8_t  r, g, b;
  uint32_t pos = 0, startTime = millis();

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



  // 在SD卡上打開請求的文件
  if ((bmpFile = SD.open(filename)) == NULL)
  {

    return;
  }

  // 分析BMP標頭,二進制BMP文件以0x4D42開頭
  if(read16(bmpFile) == 0x4D42)
  { // BMP簽名
    Serial.print("File size: ");
    Serial.println(read32(bmpFile));
    (void)read32(bmpFile); // 讀取并忽略創(chuàng)建者字節(jié)
    bmpImageoffset = read32(bmpFile); // 圖像數(shù)據(jù)的開始

    // 讀取DIB標題
    Serial.print("Header size: ");
    Serial.println(read32(bmpFile));
    bmpWidth  = read32(bmpFile);
    bmpHeight = read32(bmpFile);
    if(read16(bmpFile) == 1)
    { // # planes -- must be '1'
      bmpDepth = read16(bmpFile); // 每像素位

      if((bmpDepth == 24) && (read32(bmpFile) == 0))
      { // 0 = uncompressed

        goodBmp = true; // 支持的BMP格式--繼續(xù)!


        // BMP行填充(如果需要)到4字節(jié)邊界
        rowSize = (bmpWidth * 3 + 3) & ~3;

        //若bmpHeight為負數(shù),則圖像按自上而下的順序排列。
        //這不是標準,而是在野外觀察到的。
        if(bmpHeight < 0) {
          bmpHeight = -bmpHeight;
          flip      = false;
        }

        // 要裝載的作物區(qū)域
        w = bmpWidth;
        h = bmpHeight;
        if((x+w-1) >= tft.width())  w = tft.width()  - x;
        if((y+h-1) >= tft.height()) h = tft.height() - y;

        // 將TFT地址窗口設置為剪切圖像邊界
        tft.startWrite();
        tft.setAddrWindow(x, y, w, h);

        for (row=0; row<h; row++)
        { //對于每條掃描線。。。
          //尋找掃描線的起點。這可能看起來很吃力
          //每一行都要這么做,但這
          //這種方法涵蓋了很多細節(jié),比如裁剪
          //以及掃描線填充。此外,搜索只需要
          //如果文件位置確實需要更改,則放置
          //(避免了SD庫中的大量集群數(shù)學)。
          if(flip) // 位圖按自下而上的順序存儲(普通BMP)
            pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
          else     // 位圖自上而下存儲
            pos = bmpImageoffset + row * rowSize;
          if(bmpFile.position() != pos) { // 需要尋求?
            tft.endWrite();
            bmpFile.seek(pos);
            buffidx = sizeof(sdbuffer); // 強制重新加載緩沖區(qū)
          }

          for (col=0; col<w; col++)
          { // 對于每個像素。。。
            // 是時候讀取更多像素數(shù)據(jù)了嗎?
            if (buffidx >= sizeof(sdbuffer)) { // 的確
              bmpFile.read(sdbuffer, sizeof(sdbuffer));
              buffidx = 0; // 將索引設置為開頭
              tft.startWrite();
            }

            // 將像素從BMP轉換為TFT格式,按鍵顯示
            r = sdbuffer[buffidx++];
            g = sdbuffer[buffidx++];
            b = sdbuffer[buffidx++];
            tft.pushColor(tft.color565(r,g,b));
          } // end pixel
        } // end scanline
        tft.endWrite();

      } // end goodBmp
    }
  }

  bmpFile.close();
  if(!goodBmp) Serial.println("BMP format not recognized.");
}

//這些從SD卡文件中讀取16位和32位類型。
//BMP數(shù)據(jù)存儲為小端序,Arduino也是小端序。
//如果移植到其他地方,可能需要顛倒下標順序。

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;
}

void setup(void) {
  pinMode(12,INPUT); // 設置SD的MISO IO狀態(tài),非常重要!
  Serial.begin(9600);

  // Initialize 1.8" TFT
  tft.initR(INITR_REDTAB);   // (已解決)顯示部分圖像128X128,其余部分為花邊,復位斷電重連無用,圖片一側隨RX燈的閃動而變色,使用tft.initR(INITR_BLACKTAB)后顯示完整其余不變,復位后不變斷電重連后癥狀恢復
  //tft.initR(INITR_HALLOWING);   // 解決方法 在Adafuit_ST7735.h的第13行將INITR_144GRENTAB更改為0x03,例如#define INITR_14GRENTAB 0x03
  //tft.initR(INITR_144GREENTAB);   // 同上
  //tft.initR(INITR_BLACKTAB);   // 圖片全部顯示,色調不對,無閃動變色現(xiàn)象

  tft.setRotation(3);


  tft.fillScreen(ST7735_BLACK);
}

void loop() {
    Serial.print("Initializing SD card...");
    if (!SD.begin(SD_CS))
    {
      Serial.println("failed!");
      tft.setTextSize(2);
      tft.fillScreen(ST7735_BLACK);
      tft.setCursor(0, 0);
      tft.setTextColor(ST7735_BLUE);
      tft.print("SD Card init error!");
      return;
    }
bmpDraw("x.bmp", 0, 0);
}



51hei截圖_20240801154952.png (410.04 KB, 下載次數(shù): 21)

51hei截圖_20240801154952.png
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發(fā)
ID:1130032 發(fā)表于 2024-8-1 16:29 | 只看該作者
TFT_eSPI下載后好像需要配置,應該是沒有配置我去試試兄弟們等我消息
回復

使用道具 舉報

板凳
ID:1130032 發(fā)表于 2024-8-2 09:48 | 只看該作者
解決了兄弟們,之前用的是2014年的Adafruit_ST7735庫
解決方法:刪除后重新下載Adafruit_ST7735_and_ST7789_Library庫就可以了
回復

使用道具 舉報

地板
ID:1129414 發(fā)表于 2024-8-12 10:50 | 只看該作者
刪掉后重新下載Adafruit_ST7735_and_ST7789_Library庫
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表