Smanar / CYD-Domoticz-Remote

WIP project to control your home-automation using Domoticz and a CYD (Cheap touchscreen).
9 stars 2 forks source link

esp32-2432S028R enhancements and issues #22

Open SargonofAssyria opened 1 month ago

SargonofAssyria commented 1 month ago

I bought also a esp32-2432S028R, Chip identifies with ESP32-D0WD-V3 (revision v3.1) To get in running I had to add/change: platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.10.03/platform-espressif32.zip because of SPI errors.

Also the timeout for the screen go blank does not work.

It looks like the -DAUTO_BRIGHTNESS does not work. Will need some more testing.

Info: ESP2SOTA works.

Question: How do I rotate 90 degrees?

Smanar commented 1 month ago

Ha yes there is so much version for this device. There is already

default_envs = esp32-2432S028R
;default_envs = esp32-2432S028R_old

Can make a new one.

This device can work with 3 differents libs, by defaut it's TFT_eSPI so setting are defined by defaut on the lib by -Desp2432S028R To rotate the screen 2 option possible, by the settings directly on the device, and if it don't work

    // Rotation option
    #ifdef TFT_ESPI
        tft.setRotation(global_config.rotateScreen ? 0 : 2);
    #endif

You normaly need to use TFT_ROTATION but I m just seing it's hard coded for this device, not good.

Can use value from 0 to 8. I need to check if the lib is updated and support your version now.

The esp32-2432S028R_old use another lib LovyanGFX, perhaps easier to use, all the config is in a different file.

The easier way is copy/paste one existing default_envs and edit it.

Smanar commented 1 month ago

And for the autobrightness, need to use a special setting too in the device settting https://github.com/Smanar/CYD-Domoticz-Remote/issues/10#issuecomment-2083140328

Smanar commented 1 month ago

BTW can you try with this environnement default_envs = esp32-2432S028R_old ? If I remember the user use it in portrait mode, so probably reversed.

if you are using

In board/esp32-2432S028R.json

Try replace "-DILI9342_DRIVER=1", by "-DILI9341_DRIVER=1", or "-DILI9341_2_DRIVER=1",

Have found this post with your device https://github.com/HASwitchPlate/openHASP/issues/550#issuecomment-1737530615

Smanar commented 1 month ago

Chip identifies with ESP32-D0WD-V3 (revision v3.1)

How you can have this information ? But it's the chip, not the display driver, so for me it don't have impact on result.

// TFT_ROTATION values:
// 0 - 0 deg (= default when not set)
// 1 - 90 deg anti-clockwise (from 0 deg)
// 2 - 180 deg anti-clockwise
// 3 - 270 deg anti-clockwise
// 4 - mirror content, and rotate 180 deg anti-clockwise
// 5 - mirror content, and rotate 270 deg anti-clockwise
// 6 - mirror content, and rotate 0 deg anti-clockwise
// 7 - mirror content, and rotate 90 deg anti-clockwise
SargonofAssyria commented 1 month ago

Tnx, for all the answers. Will work with those answers soon. Mine is a newer device because of the USB-C connector. The info comes from

esptool.py flash_id

https://pypi.org/project/esptool/

Smanar commented 1 month ago

Better to start with TFT_eSPI (for homogenization) If you can't success can switch on the second driver.

    #-DTFT_ESPI=1
    -DLOVYANGFX=1

    ;https://github.com/Bodmer/TFT_eSPI.git
    lovyan03/LovyanGFX@^1.1.8

For this one it's easier, it will use a file in the "drivers" folders, so easier to make change.

I have too the USB-C connector, but it's a V2 if I remember.

SargonofAssyria commented 1 month ago

Tnx, for all the info. No good result yet. Blanking of screen after timeout is working now. Rotation of screen not yet, will keep testing. Same for -DAUTO_BRIGHTNESS not yet working but will keep experimenting.

SargonofAssyria commented 1 month ago

Got my screen 90 degrees rotate with on env:esp32-2432S028R:

    -DTFT_HEIGHT=320
    -DTFT_WIDTH=240
    -DTOTAL_ICONX=2 # How many icon widht
    -DTOTAL_ICONY=3 # How many icon Heigh

Also used the driver

-DILI9341_2_DRIVER=1

Which already did the 90 degrees rotation Only small problem is now that the Reboot and Settings button are to small for the text. Swipe is from top to bottom and visa versa. And touch is somewhat 'inverted' have to find out how.... Seems like 90 rotated back

Smanar commented 1 month ago

Reverse TFT_HEIGHT and TFT_WIDTH is not a good method because the code use them later. But you have same issue using esp32-2432S028R and esp32-2432S028R_old ? Can you share a capture with all by defaut and default_envs = esp32-2432S028R

in screen_driver.cpp you can force rotation using (around line 554)

    // Rotation option
    #ifdef TFT_ESPI
        tft.setRotation(X);
    #endif
// TFT_ROTATION values:
// 0 - 0 deg (= default when not set)
// 1 - 90 deg anti-clockwise (from 0 deg)
// 2 - 180 deg anti-clockwise
// 3 - 270 deg anti-clockwise
// 4 - mirror content, and rotate 180 deg anti-clockwise
// 5 - mirror content, and rotate 270 deg anti-clockwise
// 6 - mirror content, and rotate 0 deg anti-clockwise
// 7 - mirror content, and rotate 90 deg anti-clockwise

About the driver, the ILI9342_DRIVER is an "auto reverse"

#if defined (ILI9341_DRIVER) || defined (ILI9341_2_DRIVER)
  #define TFT_WIDTH  240
  #define TFT_HEIGHT 320
#elif defined (ILI9342_DRIVER)
  #define TFT_WIDTH  320
  #define TFT_HEIGHT 240
#endif

But if I remember it make a conflict somewhere.

But this libs is boring to configure. Can try

    #-DTFT_ESPI=1
    -DLOVYANGFX=1

    ;https://github.com/Bodmer/TFT_eSPI.git
    lovyan03/LovyanGFX@^1.1.8

It will use the file esp32-2432S028R.h in "drivers" so ALL settings in esp32-2432S028R.json will be working.

because of SPI errors.

I m searching information, I m seing issues with color, rotation, but never SPI errors, you can share your errors ?

Edit:

BTW it seem yhe V3 use another driver https://github.com/rzeldent/platformio-espressif32-sunton/blob/59ec63edd07c4d5d75d5b1e46083c2ab6446ab46/esp32-2432S028Rv3.json ST7789_SPI instead of ILI9341_SPI

Perhaps better with "-DST7789_DRIVER=1",

instead of "-DILI9341_DRIVER=1",

You have 2 USB port ?

https://github.com/HASwitchPlate/openHASP/blob/bbd96b256a315b467c149cf2596ea32236cc6e9b/user_setups/esp32/esp32-2432s028.ini#L71

Smanar commented 1 month ago

So have you finaly succed ? Else I can try to make a new environnement that use the other lib ? Easier for you to make "tweak".

SargonofAssyria commented 1 month ago

Did not have much time to test. The default setting of env:esp32-2432S028R_old did not work at all. The tft.setRotation(1) or tft.setRotation(3) did not work either on both. Please make an environment fot the DST7789_DRIVER Yes I have 2 usb ports on the device nect to each other.

Smanar commented 1 month ago

Have pushed a new version. You can select the "esp32-2432S028R_V3" environnement.

Can test 2 drivers (both will use the ST7789 driver) :

    -DTFT_ESPI=1
    #-DLOVYANGFX=1

This one will use the file board/esp32-2432S028R_V3.json but rotations are 50% locked, you can set an initial rotation but the code change it later, take care it have an impact, if you use direclty the last rotation you can have a different result.

    #-DTFT_ESPI=1
    -DLOVYANGFX=1

This one will use the file board/esp32-2432S028R_V3.json but will use too the file drivers/esp32-2432S028R_V3.h, so you can have more liberty with height and width, have same problem for rotations (one at driver initialisation, and one other in code hard coded after the launch)

Hard coded rotation (to test, can disable them if you want)

    // Rotation option
    #ifdef TFT_ESPI
        tft.setRotation(global_config.rotateScreen ? 0 : 2);
    #endif
    #ifdef LOVYANGFX
        #ifdef esp2432S028R
        tft.setRotation(global_config.rotateScreen ? 2 : 0);
        #endif
        #ifdef esp2432S028R_V3
        tft.setRotation(global_config.rotateScreen ? 2 : 0);
        #endif
    #endif

Edit : I have too 2 usb port on mine, an USB C and Micro USB on same side.

SargonofAssyria commented 1 month ago

Tnx, will look into it, but only have time from Wednesday.

SargonofAssyria commented 3 weeks ago

I tested with a lot of settings, but panel ST7789 does not work, I have to use ILI9341 Will keep on testing.

Smanar commented 3 weeks ago

For information, if it's not possible to use the bigger value for width (and if you use it in landscape ofc) I can make modification on the code for it use for example DISPLAY_WITDH, and reverse TFT_WIDTH and TFT_HEIGHT. Can you share the better result you have ? (the picture)

Smanar commented 2 weeks ago

Still not working ?