Загрузка данных



#include <Arduino.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>

#define TFT_CS   10
#define TFT_DC    9
#define TFT_RST   8

Adafruit_ILI9341 tft(TFT_CS, TFT_DC, TFT_RST);

void setup() {
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);

  Serial.begin(115200);

  tft.begin();
  tft.setRotation(1);
  tft.fillScreen(ILI9341_BLACK);

  tft.setTextColor(ILI9341_CYAN);
  tft.setTextSize(2);
  tft.setCursor(15, 20);
  tft.println("MAWWKI");

  tft.setTextColor(ILI9341_WHITE);
  tft.setCursor(15, 50);
  tft.println("MACROPAD");

  tft.drawFastHLine(15, 80, 200, ILI9341_BLUE);

  tft.setTextSize(2);
  tft.setCursor(15, 105);
  tft.println("Button 1: D2");

  tft.setCursor(15, 140);
  tft.println("Button 2: D3");
}

void loop() {
  static bool old1 = HIGH;
  static bool old2 = HIGH;

  bool b1 = digitalRead(2);
  bool b2 = digitalRead(3);

  if (b1 != old1) {
    tft.fillRect(15, 190, 220, 30, ILI9341_BLACK);
    tft.setCursor(15, 190);
    tft.setTextColor(b1 == LOW ? ILI9341_GREEN : ILI9341_WHITE);
    tft.println(b1 == LOW ? "Button 1 DOWN" : "Button 1 UP");
    old1 = b1;
  }

  if (b2 != old2) {
    tft.fillRect(15, 225, 220, 30, ILI9341_BLACK);
    tft.setCursor(15, 225);
    tft.setTextColor(b2 == LOW ? ILI9341_GREEN : ILI9341_WHITE);
    tft.println(b2 == LOW ? "Button 2 DOWN" : "Button 2 UP");
    old2 = b2;
  }

  delay(20);
}