ESP Easy 0.96" OLED set contrast with a button on NodeMCU

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Mav63
Normal user
Posts: 3
Joined: 17 Feb 2019, 15:08

ESP Easy 0.96" OLED set contrast with a button on NodeMCU

#1 Post by Mav63 » 17 Feb 2019, 15:22

Hello everybody,
I run current ESP Easy on a NodeMCU (LoLin V3) with an DHT22 and a 0,96 OLED connected. Everything works fine so far.
I am able to set the display contrast through the web interface.
Now it would be great, if I am able to connect a switch which goes through the states (i.e. "On/hight contr."; "On/medium contr."; "On/low contr."; "Off").
Since I am a newbie I need to ask if such is possible at all and, if yes how to do it.

Thanks for all help
/Mav

Wiki
Normal user
Posts: 145
Joined: 23 Apr 2018, 17:55

Re: ESP Easy 0.96" OLED set contrast with a button on NodeMCU

#2 Post by Wiki » 18 Feb 2019, 02:13

Yes, it is possible at all, pretty easy using the rules functionality of espeasy.
Sorry, at this daytime I'm too tired to post a detailed example using a button, just a short example how to set the contrast depending on daytime:

Code: Select all

On Clock#Time=All,21:00 do
  OLEDFRAMEDCMD,low
endon
On Clock#Time=All,19:00 do
  OLEDFRAMEDCMD,medium
endon
On Clock#Time=All,08:00 do
  OLEDFRAMEDCMD,medium
endon
On Clock#Time=All,9:30 do
  OLEDFRAMEDCMD,high
endon
Probably it might help to have a look at https://www.letscontrolit.com/wiki/inde ... rial_Rules

Before being able to use the rules you have to enable it in Tools/Advanced

Mav63
Normal user
Posts: 3
Joined: 17 Feb 2019, 15:08

Re: ESP Easy 0.96" OLED set contrast with a button on NodeMCU

#3 Post by Mav63 » 18 Feb 2019, 16:21

Thank you so much!
It is working!!
So now I am facing next challenge:
Am I able to find the current setting on contrast?
This is because I like to use the push button to toggle between the states (on-high; on-med; on-low; off).
Therefore I need to know the current state to choose the one I like to fire.

Thanks again!
/Mav63

Mav63
Normal user
Posts: 3
Joined: 17 Feb 2019, 15:08

Re: ESP Easy 0.96" OLED set contrast with a button on NodeMCU

#4 Post by Mav63 » 19 Feb 2019, 12:17

Solved with a Dummy device...
But need to press push button sometimes multiple time to get effect.
My rules:

Code: Select all

On Button#Switch=toggle do
  IF [Dummy#Wert1]=1
    OLEDFRAMEDCMD,medium
    TaskValueSet 4,1,2
  ELSE
    IF [Dummy#Wert1]=2
      OLEDFRAMEDCMD,high
      TaskValueSet 4,1,3
    ELSE
      OLEDFRAMEDCMD,low
      TaskValueSet 4,1,1
    ENDIF
  ENDIF
endon
I do not evaluate Value of 3 because having Dummy set to 1 in all other cases than 1 or 2.

The interval of Dummy device is set to 1 sec. and of OLED device to 5 sec. which lowers the amount of pressing push button in short time to get result.

Any idea to get a (not) each click get a result issue?

Thanks!
/Mav

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests