It is currently June 18th, 2024, 8:54 am

changing bar image according to battery percentage

Get help with creating, editing & fixing problems with skins
FreakQuency
Posts: 33
Joined: May 4th, 2010, 4:38 pm

changing bar image according to battery percentage

Post by FreakQuency »

I want to use a red bar image instead of a green one if the percent goes below %20. but even if i add the substitute value for .00000 But the image shows correctly just for a moment and dissappears.Is there a simple way to do it or what am i doing wrong?

Code: Select all

[MeasurePercent]
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=PERCENT
UpdateDivider=60

[CheckPercent]
Measure=Calc
Formula=(MeasurePercent > 20 ? 0 : 1)
Substitute=".00000": "" , "1" : "batterylow.png", "0" : "batteryload.png"


[BatteryBar]
MeasureName=MeasurePercent
Meter=BAR
X=20
Y=45
BarImage=[CheckPercent]
BarOrientation=VERTICAL
Flip=0
DynamicVariables=1
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: changing bar image according to battery percentage

Post by JpsCrazy »

Put 'dynamic variables' under the measure, not the meter.
Maybe delete the spaces?
I don't see the point of ".000000":""
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: changing bar image according to battery percentage

Post by Chewtoy »

You could do this

Code: Select all

[MeasurePower]
Measure=Plugin
Plugin=Plugins\PowerPlugin.dll
PowerState=PERCENT

[CalcColour]
Measure=Calc
Formula=MeasurePower*2.55

[Bar]
Meter=Bar
MeasureName=MeasurePower
X=0
Y=R
H=1
W=70
BarColor=255, [CalcColour], [CalcColour], 190
BarOrientation=Horizontal
SolidColor=#SolidColor#
DynamicVariables=1
This will graduatly turn red. This one goes from white to red, but you can alter that as you see fit.

Or just simply,

IfBelowValue=20
IfBelowAction=!Execute [!RainmeterHideMeter MeterThatDisplaysGreen][!RainmeterShowMeter MeterTHatIsRedButOtherwiseExactlyTheSameAndHiddenFromTheStart]
I don't think, therefore I'm not.
User avatar
Alex2539
Rainmeter Sage
Posts: 642
Joined: July 19th, 2009, 5:59 am
Location: Montreal, QC, Canada

Re: changing bar image according to battery percentage

Post by Alex2539 »

JpsCrazy wrote:Put 'dynamic variables' under the measure, not the meter.
Maybe delete the spaces?
I don't see the point of ".000000":""
No, "DynamicVariables=1" definitely needs to be with the meter. The reason ".00000":"" is there is that when you use a number as a dynamic variable, Rainmeter automatically tacks on 5 decimal places. If you are trying to use that number as a filename, the extra zeroes will cause an error, so they need to be substituted into nothing.

As for the problem, try adding these two lines to [MeasurePercent]:

Code: Select all

MinValue=0
MaxValue=100
ImageImageImageImage
User avatar
JpsCrazy
Posts: 667
Joined: April 18th, 2010, 2:16 pm
Location: NY, USA

Re: changing bar image according to battery percentage

Post by JpsCrazy »

I always thought that it had to be with the Substitute. Oh well.
I kinda feel like I should stop trying to help people, seeing as 4/5 times I'm wrong. :P
User avatar
NeverOutofTune
Posts: 12
Joined: September 4th, 2009, 1:51 am

Re: changing bar image according to battery percentage

Post by NeverOutofTune »

Not sure of the look you are after but here is what I did. I have a PNG that has sixteen frames. When my battery is full, its all green, as it decays, it starts to turn to various shades of orange and then finally red.

Here's the code snippit followed by the PNG:

[MeasureBatt]
Measure=Plugin
Plugin=Plugins\PowerPlugin.dll
PowerState=PERCENT
UpdateDivider=30


[MeterBatt]
MeasureName=MeasureBatt
Meter=BITMAP
X=1r
Y=0
BitmapImage=gt57battlightsVert.png
BitmapFrames=16
BitmapZeroFrame=1
You do not have the required permissions to view the files attached to this post.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: changing bar image according to battery percentage

Post by smurfier »

That is a very interesting approach for a battery meter. Also, I finally understand how a bitmap meter can be used.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .