4x20 LCD display, change names of day of week

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mackowiakp
Normal user
Posts: 126
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

4x20 LCD display, change names of day of week

#1 Post by mackowiakp » 13 Sep 2019, 19:34

I try to display name on day of week in my language. Because of that I use such rule:

Code: Select all

On UpdateDisplay Do
 if %sysyear% > 2000 
  Let,1,0 
  Let,2,%sysweekday%
  if %v2% = 1
   LCD,1,1,%systm_hm% Niedz %sysday%/%sysmonth_0%/%sysyears%
  else
  if %v2% = 2
   LCD,1,1,%systm_hm% Pon. %sysday%/%sysmonth_0%/%sysyears%
  else
  if %v2% = 3
   LCD,1,1,%systm_hm% Wt. %sysday%/%sysmonth_0%/%sysyears%
  else
  if %v2% = 4
   LCD,1,1,%systm_hm% Sr. %sysday%/%sysmonth_0%/%sysyears%
  else
  if %v2% = 5
   LCD,1,1,%systm_hm% Czw. %sysday%/%sysmonth_0%/%sysyears%
  else
  if %v2% = 6
   LCD,1,1,%systm_hm% Pt. %sysday%/%sysmonth_0%/%sysyears%
  else
  if %v2% = 7
   LCD,1,1,%systm_hm% Sob. %sysday%/%sysmonth_0%/%sysyears%
  endif
  endif
  endif
  endif
  endif
  endif
  endif
  Let,1,1
 Endif
EndOn
But it does not work. Does anybody has an idea why?

TD-er
Core team member
Posts: 1456
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: 4x20 LCD display, change names of day of week

#2 Post by TD-er » 13 Sep 2019, 19:37

That's a lot of endif statements.
Have you tried with just one layer?
So many endif statements looks like it may be quite a number of levels deep, but the else statement tells it should be all in the same level.

mackowiakp
Normal user
Posts: 126
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: 4x20 LCD display, change names of day of week

#3 Post by mackowiakp » 13 Sep 2019, 19:45

OK,then what do you suggest? I don't really know how to do it in the same level.

TD-er
Core team member
Posts: 1456
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: 4x20 LCD display, change names of day of week

#4 Post by TD-er » 13 Sep 2019, 19:50

Well, let's summon the Rules master @Grovkillen then :)

mackowiakp
Normal user
Posts: 126
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: 4x20 LCD display, change names of day of week

#5 Post by mackowiakp » 13 Sep 2019, 19:56

OK. I sent him PM.

User avatar
grovkillen
Core team member
Posts: 3197
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: 4x20 LCD display, change names of day of week

#6 Post by grovkillen » 13 Sep 2019, 22:17

Nested if's aren't allowed. And %variable% isn't always treated as a float but as a string and try to always use the [VAR#n] syntax to make it transfer into a float.

So.... try this instead:

Code: Select all

On UpdateDisplay Do
  Let,2,%sysweekday%
  if [VAR#2] = 1
   LCD,1,1,%systm_hm% Niedz %sysday%/%sysmonth_0%/%sysyears%
  EndIf
  if [VAR#2] = 2
   LCD,1,1,%systm_hm% Pon. %sysday%/%sysmonth_0%/%sysyears%
  EndIf
  if [VAR#2] = 3
   LCD,1,1,%systm_hm% Wt. %sysday%/%sysmonth_0%/%sysyears%
  Endif
  if [VAR#2] = 4
   LCD,1,1,%systm_hm% Sr. %sysday%/%sysmonth_0%/%sysyears%
  EndIf
  if [VAR#2] = 5
   LCD,1,1,%systm_hm% Czw. %sysday%/%sysmonth_0%/%sysyears%
  EndIf
  if [VAR#2] = 6
   LCD,1,1,%systm_hm% Pt. %sysday%/%sysmonth_0%/%sysyears%
  EndIf
  if [VAR#2] = 7
   LCD,1,1,%systm_hm% Sob. %sysday%/%sysmonth_0%/%sysyears%
  Endif
EndOn

ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

mackowiakp
Normal user
Posts: 126
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: 4x20 LCD display, change names of day of week

#7 Post by mackowiakp » 14 Sep 2019, 06:45

Thanks @grovkillen ! Works as it should work. But I think about little improvement of this code. Bit complicated procedure of if/else statements is done every minute. I mean complicated because of limited processor capabilities. In fact running such procedure is necessary only after boot and first NTP sync and at midnight. Then LCD command executed every minute should have syntax something like this:

Code: Select all

LCD,1,1,%systm_hm% %day_of_week_name% %sysday%/%sysmonth_0%/%sysyears%
So my question is. Is it possible to assign text string to any user variable and use it in LCD command instead of explicit text string?

User avatar
grovkillen
Core team member
Posts: 3197
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: 4x20 LCD display, change names of day of week

#8 Post by grovkillen » 14 Sep 2019, 07:03

No strings are allowed, only floats. You may want to ask for an implementation to convert an integer to day/month which would be the nicest way about it.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

mackowiakp
Normal user
Posts: 126
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: 4x20 LCD display, change names of day of week

#9 Post by mackowiakp » 14 Sep 2019, 07:07

OK. Well, everything has its limits.

User avatar
grovkillen
Core team member
Posts: 3197
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: 4x20 LCD display, change names of day of week

#10 Post by grovkillen » 14 Sep 2019, 09:00

You could store the day number at the end of each if and look at it first thing. If it's the same value you don't need to check all the ifs. That way over once per day the unit has to go through them all.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

mackowiakp
Normal user
Posts: 126
Joined: 07 Jun 2018, 06:47
Location: Gdynia/Poland

Re: 4x20 LCD display, change names of day of week

#11 Post by mackowiakp » 14 Sep 2019, 09:18

Good idea !

User avatar
grovkillen
Core team member
Posts: 3197
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: 4x20 LCD display, change names of day of week

#12 Post by grovkillen » 14 Sep 2019, 09:19

So if the value is not the same, send it to a custom event and have all the ifs there.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests