It is currently September 18th, 2019, 12:13 am

BUG: "Counter" not working correctly when using "DefaultUpdateDivider"

Report bugs with the Rainmeter application and suggest features.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3542
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

BUG: "Counter" not working correctly when using "DefaultUpdateDivider"

eclectic-tech » August 23rd, 2019, 6:15 pm

Here are 2 simple skins that will "blink" an image based on the value of the internal "counter".
The one that uses Standard "Update" works as expected, but the one that uses "Update" and "DefaultUpdateDivider" breaks the counter function.

This code shows a blinking image every other second:

Code: Select all

[Rainmeter]
Update=1000

[MeasureBlink]
Measure=Calc
Formula=Counter % 2
IfBelowValue=1
IfBelowAction=[!HideMeter Blink][!Redraw]
IfEqualValue=1
IfEqualAction=[!ShowMeter Blink][!Redraw]

[Blink]
Meter=Image
SolidColor=245,137,20,200
X=0
Y=0
W=10
H=10
This code does not show any counter activity in the log:

Code: Select all

[Rainmeter]
Update=100
DefaultUpdateDivider=10

[MeasureBlink]
Measure=Calc
Formula=Counter % 2
IfBelowValue=1
IfBelowAction=[!HideMeter Blink][!Redraw]
IfEqualValue=1
IfEqualAction=[!ShowMeter Blink][!Redraw]

[Blink]
Meter=Image
SolidColor=245,137,20,200
X=0
Y=0
W=10
H=10
If I manually add UpdateDivider=5 to the [MeasureBlink] measure, I see is half-second blinking, but adding UpdateDivider=10, which should bring the update back to 1 second, I see no counter activity.

Any help is appreciated. :welcome:
User avatar
Brian
Developer
Posts: 1896
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: BUG: "Counter" not working correctly when using "DefaultUpdateDivider"

Brian » August 26th, 2019, 5:48 am

The "Counter" function is not specific to a measure, but to the skin itself. It increases by 1 during the "global" update cycle of each skin.

In your first example, the formula Counter % 2 will either be 0 or 1 (depending on if the Counter is odd or even). So on each update of the skin, either the IfEqualAction or IfBelowAction will fire since the Formula changes on each update of the measure.

In other words, this is what happens on each update cycle:
Update Cycle 1: Counter is 1, Formula evaluates to 1 (1 % 2 = 1), IfEqualValue is true, IfEqualAction is executed
Update Cycle 2: Counter is 2, Formula evaluates to 0 (2 % 2 = 0), IfBelowValue is true, IfBelowAction is executed
Update Cycle 3: Counter is 3, Formula evaluates to 1 (3 % 2 = 1), IfEqualValue is true, IfEqualAction is executed
Update Cycle 4: Counter is 4, Formula evaluates to 0 (4 % 2 = 0), IfBelowValue is true, IfBelowAction is executed
... and so forth



However, on your second example, the calc is only updating on every 10th update cycle. This means your calc will always evaluate to 1 and never change since the Counter will be always be odd on each update cycle.

Update Cycle:
Update Cycle 1: Counter is 1, Formula evaluates to 1 (1 % 2 = 1), IfEqualValue is true, IfEqualAction is executed
Update Cycle 2: Counter is 2, Calc is skipped
Update Cycle 3: Counter is 3, Calc is skipped
Update Cycle 4: Counter is 4, Calc is skipped
...
Update Cycle 10: Counter is 10, Calc is skipped
Update Cycle 11: Counter is 11, Formula evaluates to 1 (11 % 2 = 1), Nothing is executed because the evaluated formula did not change
Update Cycle 12: Counter is 12, Calc is skipped
...
Update Cycle 20: Counter is 20, Calc is skipped
Update Cycle 21: Counter is 21, Formula evaluates to 1 (21 % 2 = 1), Nothing is executed because the evaluated formula did not change
Update Cycle 22: Counter is 22, Calc is skipped
... and so forth



Ultimately, what this boils down to is the evaluated formula does not change, thus no IfActions are exectued.
https://docs.rainmeter.net/manual-beta/measures/general-options/ifactions/#IfEqualAction
Rainmeter Docs wrote:The action is executed only once when the measure is equal to the value, so it needs to go above or below the defined value before the action is executed again.

You can test this by modifying the formula to Formula=Counter. The first example will show the Counter starting at 1 and increases on each update cycle. In the second example, the Counter starts at 1, then increases by 10 (11, 21, 31,...) on each update cycle.

-Brian
User avatar
eclectic-tech
Rainmeter Sage
Posts: 3542
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: BUG: "Counter" not working correctly when using "DefaultUpdateDivider"

eclectic-tech » August 26th, 2019, 11:57 am

Thanks for the explanation Brian.
I never liked "blinking" objects anyways :D , but it's good to know what was happening :thumbup: