Touchscreen on CrowPanel 7inch v3.0 not working

Hello. I've tested the 7 inch CrowPanel using the demo codes and I got stuck on trying to figure out how to get the touchscreen to work.
With the demo codes, the touch does not simply work. However, the touch does work when I flash it and upload the factory / presentation code on it. So it is not a hardware issue or anything like that.
The display works, I've tested it, the serial is ok, SD reader and so on. However, I've been using the exact pinout as specified for this type with SDA on 19, SCL on 20, added all the necessary libraries, checked the gfx_config.h and it simply does not want to work. Again I've only tried the demo code and I also tried to test if there is any communication via I2C, both options failed for me. It's as if those aren't the pins or maybe I need something more than the test.ino and gfx_conf.h file. Anyhow, here's what I used.
Arduino IDE 2.3.3 with esp32 by Espressif 2.0.15, lovyanGFX 1.1.16, wire.h, spi.h, PCA9557.h, TAMC_GT911.h, and so on.
I even tried to test on serial if the touch works at all, giving the pin config from the 3.0 7inch display version. The code is below, and it returned nonsense touch instances.

include <Wire.h>

include <TAMC_GT911.h>

// Define the I2C settings

define TOUCH_GT911_SDA 19

define TOUCH_GT911_SCL 20

define TOUCH_GT911_INT -1

define TOUCH_GT911_RST -1

define I2C_FREQ 400000

// Touch screen resolution

define TOUCH_WIDTH 800

define TOUCH_HEIGHT 480

// Create an instance of the GT911 touch controller
TAMC_GT911 ts = TAMC_GT911(TOUCH_GT911_SDA, TOUCH_GT911_SCL, TOUCH_GT911_INT, TOUCH_GT911_RST, TOUCH_WIDTH, TOUCH_HEIGHT);

// Variables to store calibration data
int raw_x_min = 0, raw_x_max = 800;
int raw_y_min = 0, raw_y_max = 480;

void setup() {
Serial.begin(115200);
Wire.begin(TOUCH_GT911_SDA, TOUCH_GT911_SCL, I2C_FREQ);
ts.begin();

Serial.println("Starting touch calibration...");
touch_calibration();
Serial.println("Touch calibration complete.");
}

void touch_calibration() {
int raw_x_tl, raw_y_tl, raw_x_tr, raw_y_tr, raw_x_bl, raw_y_bl, raw_x_br, raw_y_br;

// Calibrate Top-Left
Serial.println("Touch the Top-Left corner");
wait_for_touch(&raw_x_tl, &raw_y_tl);

// Calibrate Top-Right
Serial.println("Touch the Top-Right corner");
wait_for_touch(&raw_x_tr, &raw_y_tr);

// Calibrate Bottom-Left
Serial.println("Touch the Bottom-Left corner");
wait_for_touch(&raw_x_bl, &raw_y_bl);

// Calibrate Bottom-Right
Serial.println("Touch the Bottom-Right corner");
wait_for_touch(&raw_x_br, &raw_y_br);

// Calculate min and max values for X and Y axes
raw_x_min = min(raw_x_tl, raw_x_bl);
raw_x_max = max(raw_x_tr, raw_x_br);
raw_y_min = min(raw_y_tl, raw_y_tr);
raw_y_max = max(raw_y_bl, raw_y_br);

// Output the calibration results
Serial.println("Calibration complete!");
Serial.print("X Min: "); Serial.print(raw_x_min); Serial.print(" X Max: "); Serial.println(raw_x_max);
Serial.print("Y Min: "); Serial.print(raw_y_min); Serial.print(" Y Max: "); Serial.println(raw_y_max);
}

void wait_for_touch(int* x, int* y) {
while (!ts.isTouched) {
ts.read(); // Read until a touch is detected
}

// Capture raw touch data
*x = ts.points[0].x; // Capture raw X coordinate
*y = ts.points[0].y; // Capture raw Y coordinate

// Debugging output
Serial.print("Captured raw touch at X: "); Serial.print(x); Serial.print(", Y: "); Serial.println(y);

delay(1000); // Give some time to remove the touch before continuing
}

void loop() {
ts.read();
if (ts.isTouched) {
// Print raw touch coordinates for debugging
Serial.print("Raw Touched at X: ");
Serial.print(ts.points[0].x);
Serial.print(", Y: ");
Serial.println(ts.points[0].y);

// Map the touch coordinates to fit the display resolution
int touch_x = map(ts.points[0].x, raw_x_min, raw_x_max, 0, TOUCH_WIDTH - 1);
int touch_y = map(ts.points[0].y, raw_y_min, raw_y_max, 0, TOUCH_HEIGHT - 1);

Serial.print("Mapped Touched at X: ");
Serial.print(touch_x);
Serial.print(", Y: ");
Serial.println(touch_y);

}

delay(200); // Delay to avoid flooding the serial monitor
}

I'm not sure what I'm missing here, but I just can't seem to get the touchscreen working, under the given pinouts, freqs and whatnot. I'd really appreciate the help if anyone knows what's going on. Thank you!

«1

Comments

  • I have the same problem. ¿any idea to solve it?

  • Hello everyone, please try to add the content in the red box of following pictures.

  • Hi,
    I added, but it is not want to work..
    Even with the simle "drawing board" demo code.
    I wasted a whole day trying to figure it out the solution.

  • @Krisz971 said:
    Hi,
    I added, but it is not want to work..
    Even with the simle "drawing board" demo code.
    I wasted a whole day trying to figure it out the solution.

    Hi @Krisz971 ,
    Could you please provide your code to us for finding the solution?

    Best regards,
    Winny

  • Hi Winny,
    We get touched in Email.
    If we find a solution to the problem, I will share with the others in the forum.
    Thanks,
    Chris

  • edited October 30

    Hello,
    I am having the same issue.
    This might help track things down. The I2C is not communicating properly. Enable core debug output.
    I ran an i2c scanner and it shows devices at address 0x18 and 0x58.
    Source code shows i2c address for touch configured as 0x14 for the displays touch controller, however changing 0x14 to 0x58 or 0x18 did not seem to help.

    Thanks
    Tom

  • edited October 31

    I misread the address, it was 0x5D. some other important info. I coppied some i2c scanner code to the demo project and quickly found the i2c bus to have error 5 busy if the scanner code is run after
    tft.begin();
    tft.fillScreen(TFT_BLACK);
    tft.setTextSize(2);
    delay(200);

    Something in these functions locks up the i2c bus.

  • edited November 4

    I have everything configured as shown and does not work. One person on another thread indicated we should use TAMC_GT911 library because there was a breaking issue in either lvgl or lovyanGFX libraries. This however was written for platform IO and not arduino

  • hello guys,
    please try the demo code here:

  • does not work. i get a black screen.

Sign In or Register to comment.