Beruflich Dokumente
Kultur Dokumente
#include <MCUFRIEND_kbv.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <TouchScreen.h>
/*______End of Libraries_______*/
#define LCD_D0 8
#define LCD_D1 9
#define LCD_D2 2
#define LCD_D3 3
#define LCD_D4 4
#define LCD_D5 5
#define LCD_D6 6
#define LCD_D7 7
#define SD_SS 10
#define SD_DI 11
#define SD_DO 12
#define SD_SCK 13
#define LCD_RESET A4
#define LCD_CS A3
#define LCD_RS A2
#define LCD_WR A1
#define LCD_RD A0
/*_______End of defanitions______*/
#define MINPRESSURE 10
#define MAXPRESSURE 1000
MCUFRIEND_kbv tft;
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); //300 is the sensitivity
Adafruit_GFX_Button on_btn, off_btn;
void setup() {
Serial.begin(9600);
uint16_t ID = tft.readID();
Serial.print("TFT ID = 0x");
Serial.println(ID, HEX);
Serial.println("Calibrate for your Touch Panel");
//if (ID == 0xD3D3) ID = 0x9486; // write-only shield
tft.begin(0x7796);
tft.setRotation(0); //PORTRAIT
tft.fillScreen(BLACK);
on_btn.initButton(&tft, 60, 200, 100, 40, WHITE, CYAN, BLACK, "ON", 2);
off_btn.initButton(&tft, 180, 200, 100, 40, WHITE, CYAN, BLACK, "OFF", 2);
on_btn.drawButton(true);
off_btn.drawButton(true);
tft.fillRect(40, 80, 160, 80, RED);
Serial.println("REACH END");
}
void loop() {
Serial.println("REACH END1");
bool down = Touch_getXY();
on_btn.press(down && on_btn.contains(pixel_x, pixel_y));
off_btn.press(down && off_btn.contains(pixel_x, pixel_y));
if (on_btn.justReleased())
on_btn.drawButton();
if (off_btn.justReleased())
off_btn.drawButton();
if (on_btn.justPressed()) {
on_btn.drawButton(true);
tft.fillRect(40, 80, 160, 80, GREEN);
}
if (off_btn.justPressed()) {
off_btn.drawButton(true);
tft.fillRect(40, 80, 160, 80, RED);
}
Serial.println("REACH END2");
}