Как интегрировать Adafruit_GFX_AS с Adafruit_GFX и Adafruit_TFTLCD? - PullRequest
1 голос
/ 05 апреля 2020

Итак, как следует из названия, мне нужна помощь в интеграции библиотеки Adafruit_GFX_AS с библиотеками Adafruit_GFX и Adafruit_TFTLCD. Вот код, который у меня есть ...

#include <Adafruit_GFX.h>
#include <Adafruit_GFX_AS.h>
#include <Adafruit_TFTLCD.h>

#define LCD_PIN_CD A2 // Command/Data is connected to Analog 2
#define LCD_PIN_CS A3 // Chip Select is connected to Analog 3
#define LCD_PIN_RD A0 // Read is connected to Analog 0
#define LCD_PIN_RS A4 // Reset is connected to Analog 4
#define LCD_PIN_WR A1 // Write is connected to Analog 1

// Assigns common human-readable colors
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

Adafruit_TFTLCD lcd(LCD_PIN_CS, LCD_PIN_CD, LCD_PIN_WR, LCD_PIN_RD, LCD_PIN_RS);

void setup(void)
{
  // Serial
  Serial.begin(9600);
  Serial.println("Serial port initialization succeeded.");

  // LCD
  Serial.println("Initializing LCD...");
  lcd.reset();
  uint16_t lcdID = lcd.readID();

  switch(lcdID)
  {
    case 0x7575:
      Serial.println("Found HX8347G LCD driver.");
      break;
    case 0x8357:
      Serial.println("Found HX8357D LCD driver.");
      break;
    case 0x9325:
      Serial.println("Found ILI9325 LCD driver.");
      break;
    case 0x9328:
      Serial.println("Found ILI9328 LCD driver.");
      break;
    case 0x9341:
      Serial.println("Found ILI9341 LCD driver.");
      break;
    default:
      Serial.println((String)"Error: LCD initialization failed. Unknown LCD driver chip: "+lcdID+".");
      deinitialize(EXIT_FAILURE);
  }

  lcd.begin(lcdID);
  pinMode(13, OUTPUT);
  lcd.fillScreen(BLACK);
  lcd.setRotation(-1);
  Serial.println("LCD initialization succeeded.");

  menu();
}

void loop()
{

}

void deinitialize(int exitStatus)
{
  Serial.println("Exiting program...");
  delay(100);
  exit(exitStatus);
}

void menu()
{
  int spaceWidth = lcd.width() / 20;
  int spaceHeight = lcd.height() / 20;
  int boxWidth = (lcd.width() / 20) * 8.5;
  int boxHeight = (lcd.height() / 20) * 6.5;

  lcd.fillScreen(BLACK);
  lcd.drawRoundRect(0, 0, lcd.width(), lcd.height(), 8, WHITE);

  lcd.fillRoundRect(spaceWidth, spaceHeight, boxWidth, boxHeight, 8, BLUE);
  lcd.drawRoundRect(spaceWidth, spaceHeight, boxWidth, boxHeight, 8, WHITE);

  lcd.fillRoundRect((spaceWidth * 2) + boxWidth, spaceHeight, boxWidth, boxHeight, 8, BLUE);
  lcd.drawRoundRect((spaceWidth * 2) + boxWidth, spaceHeight, boxWidth, boxHeight, 8, WHITE);

  lcd.fillRoundRect(spaceWidth, (spaceHeight * 2) + boxHeight, boxWidth, boxHeight, 8, BLUE);
  lcd.drawRoundRect(spaceWidth, (spaceHeight * 2) + boxHeight, boxWidth, boxHeight, 8, WHITE);

  lcd.fillRoundRect((spaceWidth * 2) + boxWidth, (spaceHeight * 2) + boxHeight, boxWidth, boxHeight, 8, BLUE);
  lcd.drawRoundRect((spaceWidth * 2) + boxWidth, (spaceHeight * 2) + boxHeight, boxWidth, boxHeight, 8, WHITE);

  lcd.fillRoundRect((spaceWidth * 2) + boxWidth, (spaceHeight * 3) + (boxHeight * 2), boxWidth, (lcd.height() / 20) * 3, 8, BLUE);
  lcd.drawRoundRect((spaceWidth * 2) + boxWidth, (spaceHeight * 3) + (boxHeight * 2), boxWidth, (lcd.height() / 20) * 3, 8, WHITE);
}

Сейчас я не могу использовать ни одну из функций Adafruit_GFX_AS. Например, если я попробую lcd.drawCentreString("TEST", 20, 20, 20), компилятор Arduino выдаст ошибку 'class Adafruit_TFTLCD' has no member named 'drawCentreString'.

Я установил библиотеку в соответствии с инструкциями GitHub readme, так что я не знаю, что не так , Любая помощь будет принята с благодарностью!

...