How to get the frame number of an oled frame device

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
oryxxx
New user
Posts: 2
Joined: 10 Apr 2024, 10:22

How to get the frame number of an oled frame device

#1 Post by oryxxx » 10 Apr 2024, 10:45

Dear community,

comming from tasmota I am trying to do the first steps using ESPeasy.
My goal is to present a couple of mqtt data on an oled display.
The framed display together with a button seems to perfectly fit to this task.
Up to now a set of four values were displayed and can be replaced by the next four values using the button.
Unfortunately the value were not updated if they were changed in the background as long as no button press were done.

Updating could be easily done by executing, e.g.

OledFramedCmd,Frame 1(2,3,4)

in an appropriate rule with a recurring timer. Therefore, I need to know which frame is currently displayed to refresh exactly this frame.
My rule currently likes like this (the if-clause is of course not working ...)

On System#Boot do timerSet,1,5 Endon

On Rules#Timer=1 do
If display#Frame=1 Do OledFramedCmd,Frame 1 Endon
If display#Frame=2 Do OledFramedCmd,Frame 2 Endon
If display#Frame=3 Do OledFramedCmd,Frame 3 Endon
If display#Frame=4 Do OledFramedCmd,Frame 4 Endon
timerSet,1,1
endon


Does anyone have an idea how to get the number of the displayed frame or even how to get the currently displayed content?

Would be great to get support!

Thank you in advance!
Oliver

User avatar
Ath
Normal user
Posts: 3531
Joined: 10 Jun 2018, 12:06
Location: NL

Re: How to get the frame number of an oled frame device

#2 Post by Ath » 10 Apr 2024, 11:00

The frame should be auto-incremented every Interval seconds as configured in the task. If you leave that on 0 there will be no updates...

Once you manually select the desired Frame, using the "oledframedcmd,frame,<framenumber>" command, or automatically update to the next frame, the predefined content is re-displayed on the display.
Also, depending on the build (this feature is not available for LIMIT_BUILD_SIZE builds like the ESP8266 Display build), you can enable Generate events for Display, Contrast, Frame, Line & LineCount so you will see an event <taskname>#Frame=<framenumber> where you can handle your screen updates as desired.

The current frame is not available from the plugin, mostly to not further expand this already very large plugin :?
/Ton (PayPal.me)

User avatar
Ath
Normal user
Posts: 3531
Joined: 10 Jun 2018, 12:06
Location: NL

Re: How to get the frame number of an oled frame device

#3 Post by Ath » 10 Apr 2024, 11:02

Also, the ESPEasy rules syntax is somewhat different from the Tasmota syntax, see the ESPEasy docs on Rules
/Ton (PayPal.me)

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

Re: How to get the frame number of an oled frame device

#4 Post by TD-er » 10 Apr 2024, 11:31

Code: Select all

If display#Frame=1 Do OledFramedCmd,Frame 1 Endon
Should be:

Code: Select all

If [display#Frame]=1 
  OledFramedCmd,Frame,1
endif
Also not sure if the oneliner will work

Code: Select all

On System#Boot do 
  timerSet,1,5 
Endon

oryxxx
New user
Posts: 2
Joined: 10 Apr 2024, 10:22

Re: How to get the frame number of an oled frame device

#5 Post by oryxxx » 10 Apr 2024, 12:19

thank you for your swift answer!
Currently it looks like the code below. The syntax seems to be ok, but I did not receive any value for [display#fame] (see logs)
Any further ideas how to get the current content or the frame number? :-(

Regrads,
Oliver

Code: Select all

On System#Boot do 
  timerSet,1,5 
Endon

On Rules#Timer=1 do
  LogEntry,  FrameNumber:[display#Frame], 1
  If [display#frame]=1 
    OledFramedCmd,Frame 1 
  Endif
  If [display#frame]=2 
    OledFramedCmd,Frame 2
  Endif
  If [display#frame]=3 
    OledFramedCmd,Frame 3
  Endif
  timerSet,1,1 
endon
Logs:
789654: FrameNumber:
790722: FrameNumber:
791797: FrameNumber:
792882: FrameNumber:
793950: FrameNumber:
795018: FrameNumber:
Last edited by TD-er on 10 Apr 2024, 14:03, edited 1 time in total.
Reason: Added code tags

User avatar
Ath
Normal user
Posts: 3531
Joined: 10 Jun 2018, 12:06
Location: NL

Re: How to get the frame number of an oled frame device

#6 Post by Ath » 10 Apr 2024, 13:04

1) Can you please use code blocks (the </> button in the toolbar) to wrap rules code in?

2) There is no [Display#Frame] variable. There can be an event Display#Frame=<framenr> if you have enabled that Generate events option (if that's available, else you're out of luck.)
But: Have you changed the Interval setting for the device task? When set to 5 your display content will be showing the next frame, with updated data, every 5 seconds, solving 99% of your issues.

The event can be handled like this, if still needed (though IMHO you won't need it, after setting the Interval, and the Generate events option):

Code: Select all

On Display#Frame Do
  LogEntry,'Currently selected frame: %eventvalue1%'
Endon
/Ton (PayPal.me)

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

Re: How to get the frame number of an oled frame device

#7 Post by TD-er » 10 Apr 2024, 14:06

Also you're using quite a few spaces, like here:

Code: Select all

LogEntry,  FrameNumber:[display#Frame], 1
Both a space and a comma (and a combination of both) will be considered as a separator for command arguments.
If you need a space or comma in an argument, like with strings for logs or to put some text on a display, you can wrap the argument in quotes:

Code: Select all

LogEntry,"  FrameNumber:[display#Frame], 1"

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 12 guests