Westcott1 / Waveshare-ESP32-S3-Touch-LCD-4.3-and-Arduino

19 stars 2 forks source link

Incorrect pins bitmap in expander->multiPinMode #6

Open paulhamsh opened 4 months ago

paulhamsh commented 4 months ago

This code is great and so useful! I have a Waveshare esp32-s3 7” and the touch isn’t always working so I needed to understand the io_expander.

Just one point, for

expander->multiPinMode(TP_RST | LCD_BL | LCD_RST | SD_CS | USB_SEL, OUTPUT);

In

https://github.com/Westcott1/Waveshare-ESP32-S3-Touch-LCD-4.3-and-Arduino/blob/main/Examples/Arduino_LVGL/Expander.ino

I think the pins in this call are a bitmap and should use the pin references like this:

IO_EXPANDER_PIN_NUM_0 = (1ULL << 0)

From https://github.com/esp-arduino-libs/ESP32_IO_Expander/blob/master/src/base/esp_io_expander.h

Westcott1 commented 4 months ago

Hi Paulhamsh, Glad you found it useful! Touch doesn't use any expander pins, it's a separate GT911 chip defined in Pins.h (LovyanGFX) or Touch.ino (Arduino_xxx) For the Expander, I just copied the example code. It can only turn the backlight on or off.

paulhamsh commented 4 months ago

I think touch reset is on the expander?I hope that does something because sometimes my code works and sometimes it doesn’t and that is my best hope!On 19 Jul 2024, at 15:50, Hamish West @.***> wrote: Hi Paulhamsh, Glad you found it useful! Touch doesn't use any expander pins, it's a separate GT911 chip defined in Pins.h (LovyanGFX) or Touch.ino (Arduino_xxx) For the Expander, I just copied the example code. It can only turn the backlight on or off.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

Westcott1 commented 4 months ago

Ah, yes, I forgot that. Although I never had a problem with touch. Now I've changed to using LovyanGFX, it's all handled neatly by that.

paulhamsh commented 3 months ago

I think it worked because you only use pins 1 and 2, which are the same value using as a mask or using as a pin number

Name Pin Mask
TP_RST 1 1
LCD_BL 2 2
LCD_RST 3 4
SD_CS 4 8
USB_SEL_MASK 5 16

Although my issue was that the touchpad used a differed i2c address each time (from the two available) and thought I needed to use IO Expander to control the INT level on reset. But I have wiggled the cable connecting it to the ESP and now it seems to have stopped that, so I can't test my theory above!

You are spot on that the published examples also do the same as you - I think they are wrong but it never mattered.