Помогите пожалуйста разобраться. Второй день ломаю голову. Проблема с тачскрином и ардуино уно.
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.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
#define LCD_RESET A4 // Can alternately just connect to Arduino’s reset pin
#define YP A3 // must be an analog pin, use “An” notation!
#define XM A2 // must be an analog pin, use “An” notation!
#define YM 9 // can be a digital pin
#define XP 8 // can be a digital pin
#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 tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
int S=0;
int x_tach=0;
int y_tach=0;
int POLE_X=0;
int POLE_Y=0;
byte POLE[8];
void setup() {
Serial.begin(9600);
tft.reset();
uint16_t identifier = tft.readID();
tft.begin(identifier);
tft.cp437(true);
memset(POLE, 0, 8);
pinMode(13, OUTPUT);
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
pinMode(YM, OUTPUT);
}
void loop() {
if (S==0)ZAGRUZKA();
digitalWrite(13, HIGH);
TSPoint p = ts.getPoint();
digitalWrite(13, LOW);
if (p.z < 100 || p.z > 1000) {
return;
}
else{
Serial.print("X = “); Serial.print(p.x);
Serial.print(”\tY = “); Serial.print(p.y);
// Serial.print(”\tPressure = "); Serial.println(p.z);
x_tach=p.x;
y_tach=p.y;
delay(100);
tft.setCursor(10,10);
tft.setTextColor(RED);
tft.setTextSize(5);
tft.print("Х");
}
switch (x_tach) {
case 760 … 895: POLE_X = 1; break;
case 553 … 693: POLE_X = 2; break;
case 350 … 489:POLE_X = 3; break;
}
switch (y_tach) {
case 730 … 949: POLE_Y = 1; break;
case 414 … 640: POLE_Y = 2; break;
case 130 … 329:POLE_X = 3; break;
}
if ((POLE_X == 1)&&(POLE_Y == 1)){
POLE_X = 0;
POLE_Y = 0;
x_tach=0;
y_tach=0;
Serial.println("POLE 1");
POLE[0]=1;
}
}
void ZAGRUZKA()
{
tft.setRotation(1);
tft.fillScreen(BLUE);
tft.setCursor(20, 70);
tft.fillScreen(BLACK);
tft.fillScreen(BLUE);
tft. fillRect (10, 5, 70, 70,GREEN);
tft. fillRect (10, 85, 70, 70,GREEN);
tft. fillRect (10, 165, 70, 70,GREEN);
tft. fillRect (93, 5, 70, 70,GREEN);
tft. fillRect (93, 85, 70, 70,GREEN);
tft. fillRect (93, 165, 70, 70,GREEN);
tft. fillRect (175, 5, 70, 70,GREEN);
tft. fillRect (175, 85, 70, 70,GREEN);
tft. fillRect (175, 165, 70, 70,GREEN);
S=1;
}
При выполнении функции void ZAGRUZKA() на экране отображается всё что прописано в функции. При касании экрана в монитор последовательного выводятся все значения, НО на экране символ “Х” не отображается.