M5Stack Dial - ESP32-S3 Smart Rotary Knob

There are two i2c busses on this device so it needs to know which one to use.
Add this line - i2c_id: bus_internal

ft3267_touchscreen:
  i2c_id:  bus_internal
  id: ft3267_touch
  address: 0x38
  interrupt_pin: GPIO14
  on_release:
    then:
      - display.page.show_next: my_lcd
1 Like

works! great. but indeed it almost always registers two touchesā€¦

Indeed it does, but rest assured I will solve it :smiley:

I am now getting the correct touch points.

image

image

Should also have mostly resolved the double touch issue

3 Likes

Ok, so Iā€™ve completely refactored the code, there are breaking changes, so youā€™ll need to change a lot of stuff

Youā€™ll need to change the external components reference to:

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

Itā€™s now defined simply as

touchscreen:
  platform: ft3267

And you can show some logging if you want with

touchscreen:
  platform: ft3267
  on_touch:
    then:
      - logger.log:
          format: Touch %d at (%d, %d)
          args: [touch.id, touch.x, touch.y]
      - display.page.show_next: my_lcd

The benefit of this is you can now define binary sensors (buttons!) if you want to do actions. Iā€™ve simply divided the screen up into four quarters below

binary_sensor:
  - platform: touchscreen
    name: Top Left Touch Quadrant
    x_min: 0
    x_max: 119
    y_min: 0
    y_max: 119
  - platform: touchscreen
    name: Top Right Touch Quadrant
    x_min: 120
    x_max: 240
    y_min: 0
    y_max: 119
  - platform: touchscreen
    name: Bottom Left Touch Quadrant
    x_min: 0
    x_max: 119
    y_min: 120
    y_max: 240
  - platform: touchscreen
    name: Bottom Right Touch Quadrant
    x_min: 120
    x_max: 240
    y_min: 120
    y_max: 240

As per the usual docs for the touchscreen, you can limit the buttons to a particular page by defining a page_id: within the binary sensor configuration.

4 Likes

It seems like the RFID sensor is not working when you hold an RFID card against it, unlike with the other RFID sensor that works. What could be the reason for this?

Awesome work @dgaust. Very much appreciated. This opens up a whole realm of possibilities.

  pages:
    - id: page1
      lambda: |-
        float screenheight = it.get_height();
        float screenwidth = it.get_width();
        float halfscreenheight = screenheight / 2;
        float halfscreenwidth = screenwidth /2;
        it.filled_rectangle(0, 0, halfscreenwidth, halfscreenheight, my_light_orange);
        it.filled_rectangle(halfscreenwidth, halfscreenheight, 155, 155, my_blue);
        it.filled_rectangle(0, halfscreenheight, halfscreenwidth, 155, my_green);      
        it.filled_rectangle(halfscreenwidth, 0, 155, halfscreenheight, my_red);      
        it.filled_rectangle(halfscreenwidth, halfscreenheight, - 155, - 155, my_green);      
        it.line(0, halfscreenheight, screenwidth, halfscreenheight);
        it.line(halfscreenwidth, 0, halfscreenwidth, screenheight);
        it.image(halfscreenwidth - 50, halfscreenheight - 90, fan_80, ImageAlign::TOP_CENTER);
        it.image(halfscreenwidth + 50, halfscreenheight + 10, cyclone_icon_80, ImageAlign::TOP_CENTER);
        it.image(halfscreenwidth + 50, halfscreenheight - 90, volume_notmute_80, ImageAlign::TOP_CENTER);
        it.image(halfscreenwidth - 50, halfscreenheight + 10, volumeknob, ImageAlign::TOP_CENTER);
4 Likes

Sorry but I have no idea Jarne. As I showed earlier, the tag reader is working fine on my unit although someone else said they were having issues where they needed to swipe the card numerous times to get it to work.

I just borrowed off what others did with their touchscreen drivers. And at the end of it all, I actually found a component already built (ft5x06) that would have worked by just changing the i2c addressā€¦

Still, itā€™s all tidied up now and should work ok for what is required - still working on why gestures arenā€™t being reported properly though.

2 Likes

Going from this post , there might be an additional setting you can enable for the display to disable eight_bit_color. Supposed to increase draw speed at the expense of memory.

Iā€™ve updated the screen component over on my github to incorporate the changes, and it speeds up the screen signficantly. It will automatically default to 16 bit colour, so no need to change the configuration at all.

Now the screen is much faster, and we can define touch buttons, Iā€™ve revised my main menu screen and playing around with using the round display for setting values.



3 Likes

Yeah, thatā€™s the good stuffā€¦liking the way things go in this topic

This is how it looks controlling a light. The physical button will always take you back to the home page.

4 Likes

Hello, I looked at your version 2, itā€™s nice! Could you share or put this in your GitHub so that it can be downloaded? This would be great, thanks in advance!

- id: background
  file: images/m4dial/background.png
  type: RGBA
- id: switch_animated
  file: images/m4dial/switch.gif

Just grab something you like/is suitable from online with a free use/personal use license. I just googled dark grey background and grabbed that looked semi decent to play around with.

The animated gif isnā€™t used anywhere at the moment anyway so you could remove, I was testing something but it didnā€™t work, so isnā€™t used at the moment.

1 Like

I downloaded and adapted your v2 to my HA, great job, congratulations!

Iā€™m trying out all the various features and found the icons a little small, Iā€™m thinking of using a 4-quadrant approach similar to Atomic release.

Yep, there are plenty of options available for the display. Iā€™m just playing around with it myself, I donā€™t think Iā€™ll actually need 7 options on the menu page, but just wanted to see what it looked like.

1 Like

Nice work @atomic10! Do you by chance have a github that youā€™re keeping upto date with your esphome yaml file and images?

Thanks Beccsjb. I am only building off the work from dgaust.

Have chucked a copy of my test code on Github for you. Be aware that it is just my tinker code, so some things may not work as intended, extra code thatā€™s not needed, etc.
No images to upload - all icons used are MDI icons.

3 Likes

I canā€™t wait until there is a blueprint to streamline the Dialā€™s use for the uninitiated, this is great work! Thank you!

1 Like

Guessing you have seen this: GitHub - Gitshaoxiang/M5Dial-Gui-Demo
Might be possible to steal (borrow) with prideā€¦?

1 Like

@atomic10 did you get the Port A i2c bus to work? It works for me if I disable the display in the esphome YAML but not when it is enabled. I suspect this is due to the loop() taking a long time on the gc9a01. Has found a working approach?