Advertisement
balatech

BasicTouch using PCA9557-Arduino V1.0.0

Jan 5th, 2025 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 1.61 KB | Source Code | 0 0
  1. #include <Wire.h>
  2. #include <PCA9557.h> // updated to PCA9557-Arduino
  3. #include <TAMC_GT911.h>
  4. #include <LovyanGFX.hpp>
  5. #include "gfx_conf.h"
  6.  
  7. #define TOUCH_SDA  19
  8. #define TOUCH_SCL  20
  9. #define TOUCH_INT -1
  10. #define TOUCH_RST -1
  11. #define TOUCH_WIDTH  800
  12. #define TOUCH_HEIGHT 480
  13.  
  14. TAMC_GT911 tp = TAMC_GT911(TOUCH_SDA, TOUCH_SCL, TOUCH_INT, TOUCH_RST, TOUCH_WIDTH, TOUCH_HEIGHT);
  15. PCA9557 Out(0x14,&Wire);
  16.  
  17.  
  18.  
  19. void setup() {
  20.   tp.begin(0x5D); // sets up the touch instance
  21.   tp.setRotation(ROTATION_INVERTED); // set it to landscape, 0,0 top left with usb on left
  22.  
  23.   lcd.begin(); // start the lcd
  24.   Serial.begin(115200);
  25.   Wire.begin(19, 20); // talk to the IO Expander chip PCA9557
  26.   // now we're going to 'reset' the touch panel.
  27.  
  28.  
  29.   Out.pinMode(0,OUTPUT);
  30.   Out.pinMode(1,OUTPUT);
  31.   Out.digitalWrite(0, LOW); // takes the reset pin of the GT_911 low
  32.   Out.digitalWrite(1, LOW); // takes the ??INTE (poss interrupt) pin low
  33.   delay(20);                 // wait for timings
  34.   Out.digitalWrite(0, HIGH);// release reset pin
  35.   delay(100);                // wait for timing again
  36.   Out.pinMode(1, INPUT);// set the intE pin as input again
  37.   delay(2000);
  38.  
  39.   lcd.fillScreen(0x6ecb); // set it to a colour of choice
  40.   lcd.setTextFont(&fonts::FreeMonoBold9pt7b);
  41.   lcd.setTextSize(2);
  42.   lcd.setTextColor(TFT_BLUE,0x6ecb);
  43.  
  44.  
  45. }
  46.  
  47. void loop() {
  48.    tp.read();
  49.  
  50.   if( tp.isTouched )
  51.   {
  52.     for(int i=0; i<tp.touches; i++){
  53.       lcd.fillCircle(tp.points[i].x, tp.points[i].y, 10, TFT_WHITE);
  54.       lcd.setCursor(tp.points[i].x,tp.points[i].y + 10);
  55.       lcd.print(i);
  56.     }
  57.   }
  58.  
  59.  
  60.    
  61.  
  62. }
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement