TFT Led dimming ...

Code tips and tricks for beginners
its1000
Posts: 76
Joined: Thu May 20, 2021 6:57 pm
Has thanked: 3 times
Been thanked: 1 time

TFT Led dimming ...

Post by its1000 »

Hello guys (and girls)

hope you had a good summer time and holidays.

First of all I will thank very much Ciccio for the latest firmware and the very interesting support of the ILI9488. this screen is not much better than ILI9486 but the main interest is that the 9488 has a separate + pin to power the Led backlight, allowing to power on or off the light and probably dimming it.

I will connect the led pin to an output of the ESP (perhaps thru a transistor, i imagine that direct drive is not possible due to led current need...), i will use the PWM.setup and ouput to manage backlight variation.

is there a particular parameter to apply in terms of pwm.setup in order to get the best light management to dim?

thank you for your help in advance.
its1000
Posts: 76
Joined: Thu May 20, 2021 6:57 pm
Has thanked: 3 times
Been thanked: 1 time

Re: TFT Led dimming ...

Post by its1000 »

so, no one has a clue?
Zim
Posts: 280
Joined: Mon Feb 08, 2021 9:15 pm
Has thanked: 251 times
Been thanked: 128 times

Re: TFT Led dimming ...

Post by Zim »

you may want to try different frequency for the dimming, using:

OPTION.PWMFREQ value


Define PWM frequency speed in Hz of the module.

The value can be from 1 to 40000 Hz.
its1000
Posts: 76
Joined: Thu May 20, 2021 6:57 pm
Has thanked: 3 times
Been thanked: 1 time

Re: TFT Led dimming ...

Post by its1000 »

thank you Zim. I knew I had to use this function. my question was to know if someone already tried different parameters to dim a TFT backlight in order to use the best one... But if no one did it, I will have to make some tests...
User avatar
Fernando Perez
Posts: 378
Joined: Mon Feb 15, 2021 10:09 pm
Location: Santander (Spain)
Has thanked: 195 times
Been thanked: 266 times

Re: TFT Led dimming ...

Post by Fernando Perez »

I don't have this module, so I can't test with it.
But in http://www.lcdwiki.com/3.5inch_SPI_Modu ... KU:MSP3520 I can see that the LED pin is connected to the base of an S8050 transistor that controls, through its collector, the cathodes of the backlight LEDs.
image.png
To confirm that your module is identical to the one on the quoted web page, try to locate transistor Q1 and resistors R5 and R6 on the board.
image.png
If so, you will be able to control the brightness using a directly a pin output of the ESP, without the need for an intermediate transistor.
You do not have the required permissions to view the files attached to this post.
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 119 times
Been thanked: 132 times

Re: TFT Led dimming ...

Post by AndyGadget »

Am I missing some complication here?
Simply connecting IO32 to the LED pin of the display will give you full brightness control using the TFT.BRIGHTNESS command (takes values 0 to 255).
This is what I'm doing on my earthquake monitor with an ILI9488 and it works perfectly, dimmng down the display overnight.
FU83VQFKSONICNH.jpg
You do not have the required permissions to view the files attached to this post.
Last edited by AndyGadget on Mon Sep 06, 2021 9:41 am, edited 1 time in total.
its1000
Posts: 76
Joined: Thu May 20, 2021 6:57 pm
Has thanked: 3 times
Been thanked: 1 time

Re: TFT Led dimming ...

Post by its1000 »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sun Sep 05, 2021 12:54 pm Am I missing some complication here?
Simply connecting IO32 to the LED pin of the display will give you full brightness control using the TFT.BRIGHTNESS command (takes values 0 to 127).
This is what I'm doing on my earthquake monitor with an ILI9488 and it works perfectly, dimmng down the display overnight.

FU83VQFKSONICNH.jpg
Thank you! I think that you gave me the better solution!
It seems ESP32 support direct powering of the led with output (I feared too much power consumption), and this commande directly support brightness.
i will test and tell you
Zathras
Posts: 3
Joined: Tue Aug 31, 2021 4:13 am
Has thanked: 2 times

Re: TFT Led dimming ...

Post by Zathras »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sun Sep 05, 2021 12:54 pm ...
Simply connecting IO32 to the LED pin of the display will give you full brightness control using the TFT.BRIGHTNESS command (takes values 0 to 127).
This is what I'm doing on my earthquake monitor with an ILI9488 and it works perfectly, dimmng down the display overnight.
....
Have you got the code for this please Andy? Looked through Quakes32 v1.0 and can't see where the brightness is being controlled.
AndyGadget
Posts: 222
Joined: Mon Feb 15, 2021 1:44 pm
Has thanked: 119 times
Been thanked: 132 times

Re: TFT Led dimming ...

Post by AndyGadget »

Whoops, I added that after I posted the original code.
Here it is, slot it into the QueryServer subroutine.
I'll be doing a tidy-up in the Instructables project today and I'll update there too.

(I made a mistake in my earlier post - It's 0 to 255, not 0 to 127. I have actually been using 255 but mis-read the help file :-)

Code: [Local Link Removed for Guests]

' Turn TFT brightness down overnight
Hour = val(left$(time$,2))
select case Hour
  case 23 : TFT.BRIGHTNESS 20
  case 0 to 7 : TFT.BRIGHTNESS 20  
  case 8 to 22 : TFT.BRIGHTNESS 255
end select
Or simpler :

Code: [Local Link Removed for Guests]

Hour = val(left$(time$,2))
if (Hour >=23) or (Hour <=7) then TFT.BRIGHTNESS 20 else TFT.BRIGHTNESS 255
its1000
Posts: 76
Joined: Thu May 20, 2021 6:57 pm
Has thanked: 3 times
Been thanked: 1 time

Re: TFT Led dimming ...

Post by its1000 »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sun Sep 05, 2021 6:58 pm
[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sun Sep 05, 2021 12:54 pm Am I missing some complication here?
Simply connecting IO32 to the LED pin of the display will give you full brightness control using the TFT.BRIGHTNESS command (takes values 0 to 127).
This is what I'm doing on my earthquake monitor with an ILI9488 and it works perfectly, dimmng down the display overnight.

FU83VQFKSONICNH.jpg
Thank you! I think that you gave me the better solution!
It seems ESP32 support direct powering of the led with output (I feared too much power consumption), and this commande directly support brightness.
i will test and tell you
So I confirm, it works fine! thank you very much.Really Ciccio thought about all... Except that for me I have to go very low to dim between 1 and 20... upper than 20 i am nearly around 50% light. but it is fine. knowing that I can do whatever i want
so having a screen declared in the config, alway put io32 at ON when we start and then we can manage.

The only issue I have for one particular usage is that I want to start with the screen OFF and light it only when programm starts in order to avoid having the blue wifi screen connection. so for this particular project I think I will have to use another IO being at OFF when I start, then lighting it when programm starts execution, and dimming it after.
Post Reply