I’m trying to create an if statement that validates the time to create a custom header, but prints both text at the same time on top of each other.
lambda: |-
if (id(esptime).now().hour < 12);
{
it.printf(64, 0, id(font5), TextAlign::TOP_CENTER, "Good Morning!");
}
if (id(esptime).now().hour > 13);
{
it.printf(64, 0, id(font5), TextAlign::TOP_CENTER, "Good Afternoon!");
}
Magnetic
(Mike)
2
I got it working… adding incase anyone searches in the future.
I had an extra semicolon in the IF statement. I modified it to add variable times of the day for the greeting.
lambda: |-
if ((id(esptime).now().hour) < 12)
{
it.printf(64, 0, id(font5), TextAlign::TOP_CENTER, "Good Morning!");
}
else if ((id(esptime).now().hour) > 11 and (id(esptime).now().hour) < 17)
{
it.printf(64, 0, id(font5), TextAlign::TOP_CENTER, "Good Afternoon!");
}
else if ((id(esptime).now().hour) > 16 and (id(esptime).now().hour) < 21)
{
it.printf(64, 0, id(font5), TextAlign::TOP_CENTER, "Good Evening!");
}
else if ((id(esptime).now().hour) > 20)
{
it.printf(64, 0, id(font5), TextAlign::TOP_CENTER, "Good Night!");
}