New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Subforum for general discussions. Do not dump your questions/problems here, but try to find the subforum where it belongs!

Moderators: leecollings, remb0

Post Reply
Rik60
Posts: 82
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

Thorgal789 wrote: Thursday 11 April 2024 19:31 Thx, I will add it in future build.

For the psram, in "build_flags", adde[/code]

This is sure at 99% https://thingpulse.com/esp32-how-to-use-psram/

You can need too some stuff like

Code: Select all

board_build.psram = enable  ; Enable PSRAM
board_build.psram_config = ${platform}_${board} 8MB  ; Set PSRAM size to 8MB
But this was untested yet. You can compare with the "4848S040", but it's not tested.
I have put in Common environment settings -> build_flags:

Code: Select all

    -DCORE_DEBUG_LEVEL=5
    -DBOARD_HAS_PSRAM
    -mfix-esp32-psram-cache-issue  ; Enable PSRAM in code
and in [env:esp32-8048S043C]:

Code: Select all

board_build.psram = enable  ; Enable PSRAM
board_build.psram_config = ${platform}_${board} 8MB  ; Set PSRAM size to 8MB
If i go to the Tools screen the display resets:

Stack smashing protect failure!

Do you want more information about this?
wim57
Posts: 16
Joined: Monday 25 September 2017 12:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by wim57 »

wim57 wrote: Saturday 13 April 2024 9:53 I tried with another unit and everything was fine, so maybe I made some mistake the first time.
Sadly, I have to correct my previous post. I tried the first unit once more and the display looked like below. Both are ESP32-2432S028 but one is USB-C and the other is micro-USB, so the hardware/display controller may be different. The USB-C is the one that is working ok. The malformed display seems to be in portrait mode where the other one shows landscape.
Image
Attachments
Image1.png
Image1.png (327.94 KiB) Viewed 2486 times
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

Ha yes, I see the problem, you need to play with rotation and wifth/height.
I will search the correct setting today, but yes there is different hardware, have already see this issue.
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

After some search there is no 2 versions but at least 3 (For hardware and more for software)

On the json file I m using

Code: Select all

      "-DILI9342_DRIVER=1",
It's a custom setting for the ILI9341 chipset but in landscape mode. And honnestly I can't say if color are fine on your capture ^^ (from that I have read using a different chipset have impact on color more than display).

So for the moment we can keep the same driver, the same chipset and just try with rotation.
Always in the json file

Find

Code: Select all

      "-DTFT_ROTATION=4",
and try with rotation = 0

For information, here It's the one I m using

Code: Select all

;region -- TFT_eSPI build options ------------------------
    -D LGFX_USE_V1=1
    -D ILI9341_DRIVER=1 ;
    -D TFT_ROTATION=4 
    -D TFT_WIDTH=320
    -D TFT_HEIGHT=240
    -D TOUCH_OFFSET_ROTATION=1  ; 1=swap xy, 2=invert x, 4=inverty
;endregion
And here for the old version (the one you have)

Code: Select all

;region -- TFT_eSPI build options ------------------------
    ; -D USER_SETUP_LOADED=1
    -D LGFX_USE_V1=1
    -D ILI9341_DRIVER=1
    -D TFT_ROTATION=0 ;
    -D TFT_WIDTH=240
    -D TFT_HEIGHT=320
    -D TOUCH_OFFSET_ROTATION=0  ;
;endregion
But I m afraid to swap again TFT_WIDTH and TFT_HEIGHT

About the rotation

Code: Select all

; 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
wim57
Posts: 16
Joined: Monday 25 September 2017 12:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by wim57 »

Well, I don't understand which json you mean. I can only find the board definition in esp32-2432S028R.json which mentions DILI9342_DRIVER=1.
Changing DTFT_ROTATION in this definition does not change anything (on both boards) so maybe this is not the right place.
For now I will stick to the previous version of the test branch that works on both boards.

Edit: removed remark about refresh after wake timeout because it was not correct.
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

I can only find the board definition in esp32-2432S028R.json
Yes it's this one.
Changing DTFT_ROTATION in this definition does not change anything (on both boards) so maybe this is not the right place
Nope you are fine, after checking, this setting is used for other drivers, for this one the value is hardcoded

Code: Select all

    #ifdef TFT_ESPI
        tft.setRotation(global_config.rotateScreen ? 0 : 2);
    #endif
For now I will stick to the previous version of the test branch that works on both boards
You have the branch version, for I compare code ? I can understand how you can have different result on the actual one but I don't understand how the code can work for both previosuly .... Perhaps I was using a different driver.
Edit: removed remark about refresh after wake timeout because it was not correct.
You can be right too, I have never tested this part as I use the 100% always powered mode, the working mode is strange, It turn off the light AND decrease the CPU rate. The incomings requests are still managed but IDK how a reduced CPU usage can have as impact on them.

Edit:

Have found an old code with

Code: Select all

#ifdef TFT_ESPI
    tft.setRotation(global_config.rotateScreen ? 3 : 1);
#endif
But this code had width and height reversed, and for this I can't make rollback, I need to find a "homogeneity".
Try to edit direclty screen_driver.cpp, line 526.

Code: Select all

tft.setRotation(global_config.rotateScreen ? 0 : 2);

Only the first number is usefull (except if you have used the rotation setting)
wim57
Posts: 16
Joined: Monday 25 September 2017 12:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by wim57 »

I downloaded the latest test branch, just to make sure no changes are missing.
Line 526 in sreen_driver.cpp was already as you described, but it did not change anything.


The version of the test branch that I used before works on both units, only the colors are different.
20240418.jpg
20240418.jpg (79.14 KiB) Viewed 2388 times
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

If you use the "test" branch, you have the display corrupted.
But if you replace the "0" by for exemple "3" on this line

Code: Select all

tft.setRotation(global_config.rotateScreen ? 0 : 2);
There is no changes ?
wim57
Posts: 16
Joined: Monday 25 September 2017 12:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by wim57 »

Ah, I thought I needed to change it TO zero.
If I change it to 1, 2 or 3 the screen is still not good.
But when I change the driver from ILI9342 to ILI9341 (which is in my other version) the screen is readable but rotated (heigth and with swapped?).
Again, I can put 1, 2 or 3 in screen_driver.cpp but that stays the same. So, at least, driver ILI9341 seems to work better for my board.
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

You have 3 hardware in this library

Code: Select all

//#define ILI9341_DRIVER       // Generic driver for common displays
//#define ILI9341_2_DRIVER   // Alternative ILI9341 driver, see https://github.com/Bodmer/TFT_eSPI/issues/1172
//#define ILI9342_DRIVER     // Landscape default orientation variant of ILI9341
But as the code is working in landscape, I need this mode.
This hardware probably need a ILI9341_1_DRIVER, it's possible too using the false resolution and ILI9341_DRIVER, and force the resolution with the constructor fonction on line 41 on screen_driver.cpp file

Code: Select all

static TFT_eSPI tft = TFT_eSPI(320,240);
An other solution is using another driver.
I have updatedthe code on the branch "test", now you have a new device in platformio.ini

Code: Select all

[platformio]
;default_envs = esp32-2432S028R
default_envs = esp32-2432S028R_old
This one use another lib, so idk the result,
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

@wim57 Have you had time to test the new versions ?
wim57
Posts: 16
Joined: Monday 25 September 2017 12:58
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by wim57 »

I did just now but it was still the same garbled screen.
Since I have a previous version with driver ILI9341 that is working I will stick to that.
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

Yep, it's the same "garbage" screen.
But with this driver, you have more values to make test in esp32-2432S028R_old.json
Can just try with reversing for exemple

Code: Select all

      "-DTFT_HEIGHT=240",
      "-DTFT_WIDTH=320",
And playing with

Code: Select all

      "-DTFT_ROTATION=4",
Rik60
Posts: 82
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

Hi,

I try to add some status to the Home Screen, On/ Off status of a switch (now only displaying the On status), and the open/ closed status of the blinds. The On/ Off status works, but not the Open/ Closed status of a blind. I tried to modify the Home panel.ccp file:

lv_obj_set_style_img_recolor(img, color, 0);

// Display a "on" icon
if (d->type < TYPE_SWITCH && strcmp(d->data, "On") == 0)
{
lv_obj_t * label = lv_label_create(Button_icon);
lv_obj_set_style_text_color(label, color, 0);
lv_obj_align_to(label, img, LV_ALIGN_OUT_RIGHT_BOTTOM, 0, 0);
//lv_obj_set_style_border_width(label, 5, 0); // To make it visible
lv_label_set_text(label, " On");
}
// Display a "Off" icon
if (d->type < TYPE_SWITCH && strcmp(d->data, "Off") == 0)
{
lv_obj_t * label = lv_label_create(Button_icon);
lv_obj_set_style_text_color(label, color, 0);
lv_obj_align_to(label, img, LV_ALIGN_OUT_RIGHT_BOTTOM, 0, 0);
//lv_obj_set_style_border_width(label, 5, 0); // To make it visible
lv_label_set_text(label, " Off");
}
// Display a "Open" icon
if (d->type < TYPE_BLINDS && strcmp(d->data, "Open") == 0)
{
lv_obj_t * label = lv_label_create(Button_icon);
lv_obj_set_style_text_color(label, color, 0);
lv_obj_align_to(label, img, LV_ALIGN_OUT_RIGHT_BOTTOM, 0, 0);
//lv_obj_set_style_border_width(label, 5, 0); // To make it visible
lv_label_set_text(label, " Open");
}
// Display a "Closed" icon
if (d->type < TYPE_BLINDS && strcmp(d->data, "Closed") == 0)
{
lv_obj_t * label = lv_label_create(Button_icon);
lv_obj_set_style_text_color(label, color, 0);
lv_obj_align_to(label, img, LV_ALIGN_OUT_RIGHT_BOTTOM, 0, 0);
//lv_obj_set_style_border_width(label, 5, 0); // To make it visible
lv_label_set_text(label, " Closed");
}
/*Create description*/

Is it right to do in this way?
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

It's from the code here https://github.com/Smanar/CYD-Domoticz- ... ta_setup.h

Code: Select all

d->type < TYPE_SWITCH
mean device before TYPE_SWITCH so

Code: Select all

    TYPE_PLUG,
    TYPE_COLOR,
    TYPE_LIGHT,
    TYPE_DIMMER,
So for you need to use

Code: Select all

if (d->type == TYPE_BLINDS && strcmp(d->data, "Open") == 0)
You can too "factorise" the code, to avoid to have common command.

I m too on this code part, I don't realy like the "on" text.
My first idea was to use 'image concanetation" for exemple an icon with just the bulb and another with ray added or not according to state, but a complete icon take the same size ....
I m searching too an "image effect" to do on the actual icon, but no ideas. Different color, no, we can think it's another device type, a circle, bof, a glowing effect, not visible enought, change the background, ugly too.

A small icon close the first one ? but need one for bulb and at least 2 for covering ....

About the icon change, there is a fonction that return the icon to use

Code: Select all

const lv_img_dsc_t *Geticon(int type)
It's easier and faster to direclty make something in this fonction.

If I have understand your project is to use 3 icons for covering for exemple ?
Rik60
Posts: 82
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

Thorgal789 wrote: Friday 26 April 2024 19:47 It's from the code here https://github.com/Smanar/CYD-Domoticz- ... ta_setup.h

Code: Select all

d->type < TYPE_SWITCH
mean device before TYPE_SWITCH so

Code: Select all

    TYPE_PLUG,
    TYPE_COLOR,
    TYPE_LIGHT,
    TYPE_DIMMER,
So for you need to use

Code: Select all

if (d->type == TYPE_BLINDS && strcmp(d->data, "Open") == 0)
You can too "factorise" the code, to avoid to have common command.

I m too on this code part, I don't realy like the "on" text.
My first idea was to use 'image concanetation" for exemple an icon with just the bulb and another with ray added or not according to state, but a complete icon take the same size ....
I m searching too an "image effect" to do on the actual icon, but no ideas. Different color, no, we can think it's another device type, a circle, bof, a glowing effect, not visible enought, change the background, ugly too.

A small icon close the first one ? but need one for bulb and at least 2 for covering ....

About the icon change, there is a fonction that return the icon to use

Code: Select all

const lv_img_dsc_t *Geticon(int type)
It's easier and faster to direclty make something in this fonction.

If I have understand your project is to use 3 icons for covering for exemple ?
Thx,
I did use (as you can see):

Code: Select all

if (d->type == TYPE_BLINDS && strcmp(d->data, "Open") == 0)
I was suprised that it didn't work.
Even more confusing was when i replaced "Open " with "On" the text On and Open in the Switch (bulb) icon was mixed up.
I dublicated the code to try, and when it worked, "factorise" it to avoid common commands.

For me i like the On, Off, Open, Closed as text in a icon.
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

Ha yes, I m reading the value, data don't contain "open" or "closed" but the level (except for 0 and 100 value, so only full closed or full open)

Code: Select all

Data	: "Set Level: 38 %"

Code: Select all

For me i like the On, Off, Open, Closed as text in a icon.
So you don't to change the icon but add a text for the covering ?

If it's just that, I can make the code today. But if you want to search yourself, you can use

Code: Select all

d->level
to have the covering level and print "open" or "closed" (it's a numeric value, from 0> 100)

or use

Code: Select all

if (d->type == TYPE_BLINDS && strcmp(d->data, "Closed") == 0)
with that you will check the "full closed", and all others values will be the "Open"

Check the "data" value on a browser using the URL

Code: Select all

http://192.168.1.1:8080/json.htm?type=command&param=getdevices&rid=ID
you can have a "custom" device not managed like mines.
ElMyggo
Posts: 10
Joined: Sunday 01 November 2020 20:48
Target OS: Windows
Domoticz version: 2024.4
Location: Sweden
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by ElMyggo »

I manage to fix the Swedish font åäö to my project :-)
I made new files (lv_font_montserrat_10.c + lv_font_montserrat_12.c) with the same input as the original (find the settings in top of the file) and then added the swedish fonts åäö ÅÄÖ with online converter https://lvgl.io/tools/fontconverter
settings.png
settings.png (10.6 KiB) Viewed 2144 times
When i change the file Montserrat_Bold_14 ESP32 crash when doing setup page for Domoticz so i try some more there..

I run the test version
fixed-font.jpg
fixed-font.jpg (289.46 KiB) Viewed 2144 times
menu.jpg
menu.jpg (278.84 KiB) Viewed 2144 times
Rik60
Posts: 82
Joined: Sunday 25 June 2023 21:54
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.3
Location: The Netherlands
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Rik60 »

Thorgal789 wrote: Saturday 27 April 2024 12:13 Ha yes, I m reading the value, data don't contain "open" or "closed" but the level (except for 0 and 100 value, so only full closed or full open)

Code: Select all

Data	: "Set Level: 38 %"

Code: Select all

For me i like the On, Off, Open, Closed as text in a icon.
So you don't to change the icon but add a text for the covering ?

If it's just that, I can make the code today. But if you want to search yourself, you can use

Code: Select all

d->level
to have the covering level and print "open" or "closed" (it's a numeric value, from 0> 100)

or use

Code: Select all

if (d->type == TYPE_BLINDS && strcmp(d->data, "Closed") == 0)
with that you will check the "full closed", and all others values will be the "Open"

Check the "data" value on a browser using the URL

Code: Select all

http://192.168.1.1:8080/json.htm?type=command&param=getdevices&rid=ID
you can have a "custom" device not managed like mines.
Thx,
I am going to try to edit the code myself.
Thanks for the tips.
Thorgal789
Posts: 815
Joined: Wednesday 15 August 2018 14:38
Target OS: -
Domoticz version:
Contact:

Re: New project, a small wall display to control Domoticz using CYD (Cheap ESP32 touchscreen)

Post by Thorgal789 »

@Rik60 Do you need some help ?
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests