Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <PCA9557.h> //PCA9557-arduino v1.0.0
- #include <TAMC_GT911.h> //TAMC_GT911 by TAMC v 1.0.9
- #include <LovyanGFX.hpp> //LovyanGFX v1.2.0
- #include "gfx_conf.h" // part of this build
- #define TOUCH_SDA 19
- #define TOUCH_SCL 20
- #define TOUCH_INT -1
- #define TOUCH_RST -1
- #define TOUCH_WIDTH 800
- #define TOUCH_HEIGHT 480
- TAMC_GT911 tp = TAMC_GT911(TOUCH_SDA, TOUCH_SCL, TOUCH_INT, TOUCH_RST, TOUCH_WIDTH, TOUCH_HEIGHT);
- PCA9557 Out;
- void setup() {
- tp.begin(0x5D); // sets up the touch instance
- tp.setRotation(ROTATION_INVERTED); // set it to landscape, 0,0 top left with usb on left
- Wire.begin(19, 20); // talk to the IO Expander chip PCA9557
- // now we're going to 'reset' the touch panel.
- Out.reset();
- Out.setMode(IO_OUTPUT);
- Out.setState(IO0, IO_LOW); // takes the reset pin of the GT_911 low
- Out.setState(IO1, IO_LOW); // takes the ??INTE (poss interrupt) pin low
- delay(20); // wait for timings
- Out.setState(IO0, IO_HIGH);// release reset pin
- delay(100); // wait for timing again
- Out.setMode(IO1, IO_INPUT);// set the intE pin as input again
- delay(2000);
- lcd.begin(); // start the lcd
- lcd.fillScreen(0x6ecb); // set it to a colour of choice
- lcd.setTextFont(&fonts::FreeMonoBold9pt7b);
- lcd.setTextSize(2);
- lcd.setTextColor(TFT_BLUE,TFT_WHITE);
- }
- void loop() {
- tp.read();
- if (tp.isTouched){
- for (int i=0; i<tp.touches; i++){
- Serial.printf(" Touch point %i, X =%i, Y =%i \n\r",i,tp.points[i].x, tp.points[i].y);
- lcd.fillCircle(tp.points[i].x, tp.points[i].y, 10, TFT_WHITE);
- lcd.setCursor(tp.points[i].x,tp.points[i].y);
- lcd.print(String(i));
- }
- }
- }
Advertisement
Comments
-
- This is the main .ino file to test touch functions. Ensure you also download the gfx_conf.h file!
Add Comment
Please, Sign In to add comment
Advertisement