esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
422 stars 27 forks source link

Support for m5dial touch driver #2500

Open dgaust opened 1 year ago

dgaust commented 1 year ago

Describe the problem you have/What new integration you would like The m5dial uses a GC9A01 screen with a FT3267 touch driver. I have been able to integrate the display using an external component, but not the touchscreen.

Please describe your use case for this integration and alternatives you've tried: I have tried external components with used for other devices with GC9A01 based screens (like the ones with CST816S series touchscreens), but have not had any luck registering touch events.

Additional context Details of the m5dial are here, including pinouts and other details

https://docs.m5stack.com/en/core/M5Dial

dgaust commented 1 year ago

I think? this might be the relevant driver file for the touchscreen

https://github.com/Xinyuan-LilyGO/T-RGB/blob/b5f004cfe723dd54a0fa63f04eaf4668e20ac77f/examples/factory/ft3267.cpp https://github.com/Xinyuan-LilyGO/T-RGB/blob/b5f004cfe723dd54a0fa63f04eaf4668e20ac77f/examples/factory/ft3267.h

lboue commented 11 months ago

I'd like to do exactly the same. Maybe this Arduino lib could help: LILYGO-TRGB-Library

lboue commented 9 months ago

I found an ESPHome config file for M5Dial 1.28" Round Touch Screen.

external_components:
  - source: github://dgaust/esphome@gc9a01
    components: [ ft3267, gc9a01 ]
    refresh: 0s

i2c:
  - id: bus_internal
    sda: GPIO11
    scl: GPIO12
    scan: False
    frequency: 400kHz

touchscreen:
  platform: ft3267

binary_sensor:
  - platform: touchscreen
    name: "Central Circle Touch"
    x_min: 90   # Center x - radius
    x_max: 150  # Center x + radius
    y_min: 90   # Center y - radius
    y_max: 150  # Center y + radius
    page_id: TestPage
    on_release:
      - display.page.show: FirstPage
  - platform: touchscreen
    name: "Circle 2 Touch"
    x_min: 160  # Center x - radius
    x_max: 220  # Center x + radius
    y_min: 90   # Center y - radius
    y_max: 150  # Center y + radius
    page_id: TestPage
    on_release:
      then:
        - logger.log: "Circle 2 Touched"
  - platform: touchscreen
    name: "Circle 3 Touch"
    x_min: 125  # Center x - radius
    x_max: 185  # Center x + radius
    y_min: 151  # Center y - radius
    y_max: 211  # Center y + radius
    page_id: TestPage
    on_release:
      - display.page.show: WifiQR
  - platform: touchscreen
    name: "Circle 4 Touch"
    page_id: TestPage
    x_min: 55   # Center x - radius
    x_max: 115  # Center x + radius
    y_min: 151  # Center y - radius
    y_max: 211  # Center y + radius
    on_release:
      then:
        - logger.log: "Circle 4 Touched"
  - platform: touchscreen
    name: "Circle 5 Touch"
    page_id: TestPage
    x_min: 20   # Center x - radius
    x_max: 80   # Center x + radius
    y_min: 90   # Center y - radius
    y_max: 150  # Center y + radius
    on_release:
      then:
        - logger.log: "Circle 5 Touched"
  - platform: touchscreen
    name: "Circle 6 Touch"
    page_id: TestPage
    x_min: 55   # Center x - radius
    x_max: 115  # Center x + radius
    y_min: 29   # Center y - radius
    y_max: 89   # Center y + radius
    on_release:
      - display.page.show: AirConPage
  - platform: touchscreen
    name: "Circle 7 Touch"
    page_id: TestPage
    x_min: 125  # Center x - radius
    x_max: 185  # Center x + radius
    y_min: 29   # Center y - radius
    y_max: 89   # Center y + radius
    on_release:
      then:
        - logger.log: "Circle 7 Touched"

And it works !

[09:48:03][D][ft3267.touchscreen:132]: Read 0 status, id: 0, pos 113/73
[09:48:03][D][ft3267.touchscreen:132]: Read 0 status, id: 0, pos 130/79
[09:48:05][D][ft3267.touchscreen:132]: Read 0 status, id: 0, pos 129/44
[09:48:05][D][ft3267.touchscreen:132]: Read 0 status, id: 0, pos 117/11
dgaust commented 9 months ago

Yeah, that's mine, I ended up writing a custom component that got the touchscreen working based off a similar touchscreen component

lboue commented 9 months ago

Yeah, that's mine, I ended up writing a custom component that got the touchscreen working based off a similar touchscreen component

You should have put a comment here to share 😉 Maybe you can create a PR to integrate it in ESPHome.

dgaust commented 9 months ago

Probably, if someone with more experience than me with esphome components wants to the repository is here.... It works, but no idea how it complies with esphome's requirements

https://github.com/dgaust/esphome/tree/gc9a01/esphome/components/ft3267

More discussion on how it all comes together is over

https://community.home-assistant.io/t/m5stack-dial-esp32-s3-smart-rotary-knob/623518

dgaust commented 7 months ago

Yeah, that's mine, I ended up writing a custom component that got the touchscreen working based off a similar touchscreen component

You should have put a comment here to share 😉 Maybe you can create a PR to integrate it in ESPHome.

Coming back to this, you can use an inbuilt touch component for the touchscreen in the dial. Just need to define the address for it to work.

touchscreen:
  platform: ft5x06
  address: 0x38