acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
demo.ino (1927B)
1 #define TOUCH_MODULES_GT911 2 //#define TOUCH_MODULES_CST_SELF 3 //#define TOUCH_MODULES_CST_MUTUAL 4 //#define TOUCH_MODULES_ZTW622 5 //#define TOUCH_MODULES_L58 6 //#define TOUCH_MODULES_FT3267 7 //#define TOUCH_MODULES_FT5x06 8 9 #include "Arduino.h" 10 #include "TouchLib.h" 11 #include "Wire.h" 12 13 #define PIN_IIC_SCL 48 14 #define PIN_IIC_SDA 8 15 #define PIN_TOUCH_INT 1 16 #define PIN_TOUCH_RES 2 17 18 #define TOUCH_READ_FROM_INTERRNUPT 0 19 20 TouchLib touch(Wire, PIN_IIC_SDA, PIN_IIC_SCL, GT911_SLAVE_ADDRESS2); 21 22 void scan_i2c_device(TwoWire &i2c) 23 { 24 Serial.println("Scanning for I2C devices ..."); 25 Serial.print(" "); 26 for (int i = 0; i < 0x10; i++) 27 { 28 Serial.printf("0x%02X|", i); 29 } 30 uint8_t error; 31 for (int j = 0; j < 0x80; j += 0x10) 32 { 33 Serial.println(); 34 Serial.printf("0x%02X |", j); 35 for (int i = 0; i < 0x10; i++) 36 { 37 Wire.beginTransmission(i | j); 38 error = Wire.endTransmission(); 39 if (error == 0) 40 Serial.printf("0x%02X|", i | j); 41 else 42 Serial.print(" -- |"); 43 } 44 } 45 Serial.println(); 46 } 47 48 bool get_int = false; 49 void setup() 50 { 51 Serial.begin(115200); 52 Serial.println("Hello T-Display-S3"); 53 pinMode(PIN_TOUCH_RES, OUTPUT); 54 digitalWrite(PIN_TOUCH_RES, 0); 55 delay(200); 56 digitalWrite(PIN_TOUCH_RES, 1); 57 delay(200); 58 Wire.begin(PIN_IIC_SDA, PIN_IIC_SCL); 59 scan_i2c_device(Wire); 60 61 touch.init(); 62 #if (TOUCH_READ_FROM_INTERRNUPT) 63 attachInterrupt( 64 PIN_TOUCH_INT, 65 [] 66 { 67 get_int = 1; 68 Serial.println("get_int"); 69 }, 70 CHANGE); 71 #endif 72 } 73 74 void loop() 75 { 76 delay(5); 77 #if (TOUCH_READ_FROM_INTERRNUPT) 78 if (get_int) 79 { 80 get_int = 0; 81 touch.read(); 82 #else 83 if (touch.read()) 84 { 85 #endif 86 uint8_t n = touch.getPointNum(); 87 Serial.printf("getPointNum: %d ", n); 88 for (uint8_t i = 0; i < n; i++) 89 { 90 TP_Point t = touch.getPoint(i); 91 Serial.printf("[%d] point x: %d point y: %d \r\n", i, t.x, t.y); 92 } 93 } 94 }