It is currently April 19th, 2024, 10:39 am

Laptop power/battery skin

Get help with creating, editing & fixing problems with skins
Bub
Posts: 37
Joined: April 2nd, 2014, 3:52 pm

Re: Laptop power/battery skin

Post by Bub »

eclectic-tech wrote:In order to change the animation speed, delete the [Rainmeter] section that is in your #@#OPTIONS.INC file; you have Update=1000 in that file, so that overrides anything you change in the [Rainmeter] section in your skin. Now set Update=100 in your skin to see the animation speed up.

Have not tried any of the other changes balala suggested, but if you are still having issues, let's handle them 1 by 1...


balala already corrected this earlier... :oops:
As a matter of fact I did this too.
Not working at all as same as with dear balala suggestion.
All meters start working ether fast or slowly but not this image sequence - still at the same speed no matter what I do.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Laptop power/battery skin

Post by balala »

Ok Bub, I partially rewrote the code. I added a new Calc measure, which handles when what bar meter should have to be shown / hidden ([MeasureStat]). Completely removed these kind of bangs from everywhere else. A few other comments:
  • I don't see the meaning of the [MeasureBarColor] or [MeasureDelayNetIn] measures. Besides the fact that I suppose you've copied them from another code and didn't change their names, at least in my opinion they are useless. I removed them (well in fact I just commented them out, but this is the same).
  • I completely removed the [Rainmeter] section from the Options.inc file and added the needed options into the [Rainmeter] section of the skin file (as I don't post the Options.inc, please take care to remove the [Rainmeter] section you too).
  • The [MeasureACLine] measure has a few, partially commented out options which have nothing to do with a measure. They belong to a String meter. Also have commented out all of them.
  • Having three Bar meters, with many common options, I've created a [BarStyle] section, added these options there. I obviously have used this style in all Bar meters.
  • For the [MeterBatteryBar3] meter I've used a specific yellow color (BarColor=255,240,0), you can use any color you like.
Finally here is the code of the main .ini file:

Code: Select all

[Rainmeter]
Update=100
DefaultUpdateDivider=10

[Variables]
@include=#@#Options.inc

[StringStyle]
StringAlign=left
FontColor=#FontColor#
FontSize=#FontHeight1#
FontFace=#Font#
AntiAlias=1
Text=%1

[BarStyle]
MeasureName=MeasurePercent
X=56
Y=4
W=220
H=10
SolidColor=#graph.line2#
BarOrientation=Horizontal

[MeasurePercent]
Measure=Plugin
PlugIn=PowerPlugin
PowerState=PERCENT

[MeasureStatus]
Measure=Plugin
PlugIn=PowerPlugin
PowerState=STATUS
Substitute="0":"NO BATTERY","1":"Charging","2":"CRITICAL","3":"Low","4":"Above Low"

[MeasureACLine]
Measure=Plugin
PlugIn=PowerPlugin
PowerState=ACLINE
;X=40
;Y=4
;StringAlign=Right
;FontColor=#FontColor#
;FontSize=#FontHeight1#
;FontFace=#Font#
;AntiAlias=1
Substitute="0":"BATTERY","1":"PLUGGED"
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetOption MeterStatusLifetime MeasureName "MeasureLifetime"][!UpdateMeasure "MeterStatusLifetime"]
IfFalseAction=[!SetOption MeterStatusLifetime MeasureName "MeasureStatus"][!UpdateMeasure "MeterStatusLifetime"]

[MeasureStat]
Measure=Calc
Formula=(( MeasureStatus = 0 ) ? -1 : ( MeasureACLine * MeasurePercent ))
IfCondition=(#CURRENTSECTION#<0)
IfTrueAction=[!HideMeter "MeterBatteryBar1"][!HideMeter "MeterBatteryBar2"][!HideMeter "MeterBatteryBar3"]
IfCondition2=(#CURRENTSECTION#=0)
IfTrueAction2=[!HideMeter "MeterBatteryBar1"][!ShowMeter "MeterBatteryBar2"][!HideMeter "MeterBatteryBar3"]
IfCondition3=((#CURRENTSECTION#>0)&&(#CURRENTSECTION#<100))
IfTrueAction3=[!ShowMeter "MeterBatteryBar1"][!HideMeter "MeterBatteryBar2"][!HideMeter "MeterBatteryBar3"]
IfCondition4=(#CURRENTSECTION#=100)
IfTrueAction4=[!HideMeter "MeterBatteryBar1"][!HideMeter "MeterBatteryBar2"][!ShowMeter "MeterBatteryBar3"]

[MeasureLifetime]
Measure=Plugin
PlugIn=PowerPlugin
PowerState=LIFETIME
Format=%#Hh %Mm

[ImageNumberCalc]
Measure=Calc
Formula=( Counter % 4 )
UpdateDivider=1

;=============================================
;Background
;=============================================

[Meter.Background]
Meter=Image
X=0
Y=0
H=28
W=276
;SolidColor=38,201,157
SolidColor=#Background.color#

[MeterBattery]
MeasureName=MeasureACLine
Meter=STRING
MeterStyle=StringStyle
FontColor=#FontColor#
FontSize=#FontHeight2#
FontFace=#Font#
X=51
Y=10
StringAlign=RightCenter

;=============================================
;Graphs
;=============================================

;[MeasureBarColor]
;MeasureName=MeasurePercent
;IfAboveValue=99
;IfAboveAction=[!HideMeter MeterBatteryBar2][!ShowMeter MeterBatteryBar1]
;IfBelowValue=99
;IfBelowAction=[!HideMeter MeterBatteryBar1][!ShowMeter MeterBatteryBar2]

;[MeasureDelayNetIn]
;Measure=Calc
;Formula=MeasureBarColor

[MeterBatteryBar1]
Meter=Bar
MeterStyle=BarStyle
MeasureName=MeasurePercent
BarImage=Frames\bar2_[ImageNumberCalc].png
DynamicVariables=1
UpdateDivider=1

[MeterBatteryBar2]
Meter=Bar
MeterStyle=BarStyle
MeasureName=MeasurePercent
BarColor=#graph.line1#

[MeterBatteryBar3]
Meter=Bar
MeterStyle=BarStyle
MeasureName=MeasurePercent
BarColor=255,240,0

[MeterStatusLifetime]
Meter=STRING
MeterStyle=StringStyle
X=6r
Y=14r
StringAlign=Left

[MeterPercent]
MeasureName=MeasurePercent
Meter=STRING
MeterStyle=StringStyle
X=212r
Y=0r
StringAlign=Right
Postfix=%
Bub
Posts: 37
Joined: April 2nd, 2014, 3:52 pm

Re: Laptop power/battery skin

Post by Bub »

:17group

Works like a charm, I have no idea on how to repay you for all help you done for last few days :bow: :bow: :bow:
Animation running fast (stupid me, did simple syntax error), everything working as I want it to work.
'Bout all those unneeded parts of code I just forgot to clear them up before sending to you. It was messy, I know...

I still get error in log : !UpdateMeasure: [MeterStatusLifetime] not found

And once again I am in your debt. :thumbup: :great: :bow:
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Laptop power/battery skin

Post by balala »

Bub wrote:I still get error in log : !UpdateMeasure: [MeterStatusLifetime] not found
This is my fault: I mistaken the last bangs of the IfTrueAction and IfFalseAction options of the [MeasureACLine] measure. [MeterStatusLifetime] being a meter, the [!Update[color=#FF0000]Measure[/color] "MeterStatusLifetime"] bang is wrong. It should have to be [!Update[color=#00BF40]Meter[/color] "MeterStatusLifetime"]. Replace those bangs and the error messages will go away. Sorry...
Bub
Posts: 37
Joined: April 2nd, 2014, 3:52 pm

Re: Laptop power/battery skin

Post by Bub »

balala wrote: Sorry...
You kiddin' me, right?!
You don't have to be sorry for anything!

Thank you again for your help :bow: :thumbup: :great:
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Laptop power/battery skin

Post by balala »

Glad to help.
But there was one more request, about a fade in / fade out effect. I suppose when the three bars are changing. Is the question still in place?
Bub
Posts: 37
Joined: April 2nd, 2014, 3:52 pm

Re: Laptop power/battery skin

Post by Bub »

balala wrote:Glad to help.
But there was one more request, about a fade in / fade out effect. I suppose when the three bars are changing. Is the question still in place?

Oh yes :)
The idea was when rig goes to state mode (PLUGGED and FULLY CHARGED) and skin switches to MeterBatteryBar3 (thanks to you! :bow: ) this Bar3 start fading in and out.
I've been trying to use this idea here https://forum.rainmeter.net/viewtopic.php?f=99&t=12802 but not sure it is possible to add Fade.ula function to Meter=Bar instead of Meter=Image like in original example 'cos all I get is solid color.
Been trying to imply MeterBatteryBar4 with different color - just to test if it will work - and switch between them using Array.ula but not working ether. As I said before not sure if I can apply it to Bar instead of Image...
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Laptop power/battery skin

Post by balala »

Bub wrote:The idea was when rig goes to state mode (PLUGGED and FULLY CHARGED) and skin switches to MeterBatteryBar3 (thanks to you! :bow: ) this Bar3 start fading in and out.
For a such action we should have to use the (very good!) ActionTimer plugin. I added the needed sections / option, see the code below:

Code: Select all

[Rainmeter]
Update=100
DefaultUpdateDivider=10

[Variables]
@include=#@#Options.inc
Alpha=0
U=[!UpdateMeasure "MeasureSlide"][!UpdateMeasure "MeasureAlpha"][!UpdateMeter "MeterBatteryBar3"][!Redraw]
Wait=50

[StringStyle]
StringAlign=left
FontColor=#FontColor#
FontSize=#FontHeight1#
FontFace=#Font#
AntiAlias=1
Text=%1

[BarStyle]
MeasureName=MeasurePercent
X=56
Y=4
W=220
H=10
SolidColor=#graph.line2#
BarOrientation=Horizontal

[MeasureSlide]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat FadeIn,#Wait#,20
FadeIn=[!SetVariable Alpha "(Clamp((#Alpha#+1),0,20))"]#U#
ActionList2=Repeat FadeOut,#Wait#,20
FadeOut=[!SetVariable Alpha "(Clamp((#Alpha#-1),0,20))"]#U#
DynamicVariables=1

[MeasureAlpha]
Measure=Calc
Formula=#Alpha#
IfCondition=(#Alpha#=20)
IfTrueAction=[!CommandMeasure "MeasureSlide" "Stop 1"][!CommandMeasure "MeasureSlide" "Execute 2"]
IfCondition2=(#Alpha#=0)
IfTrueAction2=[!CommandMeasure "MeasureSlide" "Stop 2"][!CommandMeasure "MeasureSlide" "Execute 1"]
DynamicVariables=1
Disabled=1

[MeasurePercent]
Measure=Plugin
PlugIn=PowerPlugin
PowerState=PERCENT

[MeasureStatus]
Measure=Plugin
PlugIn=PowerPlugin
PowerState=STATUS
Substitute="0":"NO BATTERY","1":"Charging","2":"CRITICAL","3":"Low","4":"Above Low"

[MeasureACLine]
Measure=Plugin
PlugIn=PowerPlugin
PowerState=ACLINE
Substitute="0":"BATTERY","1":"PLUGGED"
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetOption MeterStatusLifetime MeasureName "MeasureLifetime"][!UpdateMeter "MeterStatusLifetime"][!Redraw]
IfFalseAction=[!SetOption MeterStatusLifetime MeasureName "MeasureStatus"][!UpdateMeter "MeterStatusLifetime"][!Redraw]

[MeasureStat]
Measure=Calc
Formula=(( MeasureStatus = 0 ) ? -1 : ( MeasureACLine * MeasurePercent ))
IfCondition=(#CURRENTSECTION#<0)
IfTrueAction=[!HideMeter "MeterBatteryBar1"][!HideMeter "MeterBatteryBar2"][!HideMeter "MeterBatteryBar3"][!SetVariable Alpha "0"][!DisableMeasure "MeasureAlpha"]#U#
IfCondition2=(#CURRENTSECTION#=0)
IfTrueAction2=[!HideMeter "MeterBatteryBar1"][!ShowMeter "MeterBatteryBar2"][!HideMeter "MeterBatteryBar3"][!SetVariable Alpha "0"][!DisableMeasure "MeasureAlpha"]#U#
IfCondition3=((#CURRENTSECTION#>0)&&(#CURRENTSECTION#<100))
IfTrueAction3=[!ShowMeter "MeterBatteryBar1"][!HideMeter "MeterBatteryBar2"][!HideMeter "MeterBatteryBar3"][!SetVariable Alpha "0"][!DisableMeasure "MeasureAlpha"]#U#
IfCondition4=(#CURRENTSECTION#=100)
IfTrueAction4=[!HideMeter "MeterBatteryBar1"][!HideMeter "MeterBatteryBar2"][!ShowMeter "MeterBatteryBar3"][!EnableMeasure "MeasureAlpha"]

[MeasureLifetime]
Measure=Plugin
PlugIn=PowerPlugin
PowerState=LIFETIME
Format=%#Hh %Mm

[ImageNumberCalc]
Measure=Calc
Formula=( Counter % 4 )
UpdateDivider=1

;=============================================
;Background
;=============================================

[Meter.Background]
Meter=Image
X=0
Y=0
H=28
W=276
SolidColor=#Background.color#

[MeterBattery]
MeasureName=MeasureACLine
Meter=STRING
MeterStyle=StringStyle
FontColor=#FontColor#
FontSize=#FontHeight2#
FontFace=#Font#
X=51
Y=10
StringAlign=RightCenter

;=============================================
;Graphs
;=============================================

[MeterBatteryBar1]
Meter=Bar
MeterStyle=BarStyle
MeasureName=MeasurePercent
BarImage=Frames\bar2_[ImageNumberCalc].png
DynamicVariables=1
UpdateDivider=1

[MeterBatteryBar2]
Meter=Bar
MeterStyle=BarStyle
MeasureName=MeasurePercent
BarColor=#graph.line1#

[MeterBatteryBar3]
Meter=Bar
MeterStyle=BarStyle
MeasureName=MeasurePercent
BarColor=255,240,0,(12.75*#Alpha#)
DynamicVariables=1

[MeterStatusLifetime]
Meter=STRING
MeterStyle=StringStyle
X=6r
Y=14r
StringAlign=Left

[MeterPercent]
MeasureName=MeasurePercent
Meter=STRING
MeterStyle=StringStyle
X=212r
Y=0r
StringAlign=Right
Postfix=%
The fading of the [MeterBatteryBar3] meter is done through a newly added Alpha variable. Its values varies between 0 (in this case the bar isn't visible) and 20 (the bar is fully opaque). The value of this variable is controlled by the newly added [MeasureSlide] measure. This is the ActionTimer plugin measure. Another new measure is [MeasureAlpha], which once the fading started, will turn back the value of the Alpha variable when this one reaches it lowest / largest possible value. When this plugin is started / stopped, is controlled by the [MeasureAlpha] measure, which is enabled / disabled by the appropriate bangs of the IfTrueAction options of the [MeasureStat] measure.
The speed of the fade effect, is set through the new Wait variable ([Variables] section). Take into account that the higher the variable is, the slower the effect will occur.
Please test this code and let me know if it has problems.
Bub
Posts: 37
Joined: April 2nd, 2014, 3:52 pm

Re: Laptop power/battery skin

Post by Bub »

Just copy-paste it into skin and... NOthing happens. Just a solid bar.
So sorry for bothering you, especially at weekend :oops:
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Laptop power/battery skin

Post by balala »

Bub wrote:So sorry for bothering you, especially at weekend :oops:
No problem!
Bub wrote:Just copy-paste it into skin and... NOthing happens. Just a solid bar.
When you see "Just a solid bar"? Because the fade effect should have to be seen when the yellow bar is shown (so when the computer is plugged in AND the battery is fully charged).