It is currently March 29th, 2024, 8:04 am

[Solved]Battery bar not changing color only while charging

Get help with creating, editing & fixing problems with skins
User avatar
Dany Gee
Posts: 33
Joined: July 11th, 2012, 8:32 am

[Solved]Battery bar not changing color only while charging

Post by Dany Gee »

Hello guys,

I have a problem with my battery bar not changing its programmed bar color, but only while charging.
When it is discharging, the bar color gets changed as programmed - green 100% - 70%, yellow 69% - 30%, red 29% - 0%.
What did I miss in the config?

Code: Select all

#Check battery or acline 
[MeasureAC]
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=ACLINE
Substitute="0":"5","1":"6"

#Measure battery energy
[MeasurePercent]
Measure=Plugin
PlugIn=PlugIns\PowerPlugin.dll
PowerState=PERCENT
UpdateDivider=10

#Battery measure when energy is more than 0%
[MeasureBatteryL]
Measure=Plugin 
Plugin=PlugIns\PowerPlugin.dll
PowerState=PERCENT
UpdateDivider=10
IfAboveValue=0
IfAboveAction=!execute [!RainmeterShowMeter BatteryBarL][!RainmeterHideMeter BatteryBarM][!RainmeterHideMeter BatteryBarH]
 
#Battery measure when energy is more than 30%
[MeasureBatteryM]
Measure=Plugin 
Plugin=PlugIns\PowerPlugin.dll
PowerState=PERCENT
UpdateDivider=10
IfAboveValue=30
IfAboveAction=!execute [!RainmeterShowMeter BatteryBarM][!RainmeterHideMeter BatteryBarL][!RainmeterHideMeter BatteryBarH]
 
#Battery measure when energy is more than 70%
[MeasureBatteryH]
Measure=Plugin 
Plugin=PlugIns\PowerPlugin.dll
PowerState=PERCENT
UpdateDivider=10
IfAboveValue=70
IfAboveAction=!execute [!RainmeterShowMeter BatteryBarH][!RainmeterHideMeter BatteryBarM][!RainmeterHideMeter BatteryBarL]

[BatteryIcon] 
Meter=STRING
MeasureName=MeasureAC
X=-3 
Y=20r 
FontColor=#FontColor# 
FontSize=16 
FontFace=ConkyColors 
AntiAlias=1 
StringAlign=Left 
 
#Battery text meter
[MeterBatteryLabel] 
Meter=STRING 
X=27 
Y=0r 
FontColor=#FontColor# 
FontSize=#FontHeight# 
FontFace=#FontName# 
AntiAlias=1 
StringAlign=left 
Text="Poziom baterii:" 
 
#Battery bar meter color green
[BatteryBarH] 
MeasureName=MeasurePercent  
Meter=BAR 
X=143r 
Y=5r 
H=10 
W=130 
BarOrientation=HORIZONTAL 
BarColor=53DD6C
UpdateDivider=10
Hidden=1
 
#Battery bar meter color yellow
[BatteryBarM] 
MeasureName=MeasurePercent 
Meter=BAR 
X=0r 
Y=0r 
H=10 
W=130 
BarOrientation=HORIZONTAL 
BarColor=F2CC8F
UpdateDivider=10
Hidden=1

#Battery bar meter color red
[BatteryBarL] 
MeasureName=MeasurePercent 
Meter=BAR 
X=0r 
Y=0r 
H=10 
W=130
BarOrientation=HORIZONTAL 
BarColor=D64933
UpdateDivider=10
Hidden=1
 
#Actual battery percentage value string
[MeterBattery] 
Meter=String 
MeasureName=MeasurePercent
X=297 
Y=-4r 
FontColor=#FontColor# 
FontSize=#FontHeight# 
FontFace=#FontName# 
AntiAlias=1 
StringAlign=Right 
Text="%1%"
Last edited by Dany Gee on April 18th, 2017, 4:28 pm, edited 1 time in total.
SYSTEM: Windows 11 Pro 64bit|MOBO: ASUS Z170 Deluxe|CPU: i7-6700K @ 4.3Ghz|GPU: Asus GTX1080 Strix|RAM: 64GB Gskill Trident Z RGB (2400Mhz CL15)
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Battery bar not changing color only while charging

Post by balala »

Dany Gee wrote:I have a problem with my battery bar not changing its programmed bar color, but only while charging.
When it is discharging, the bar color gets changed as programmed - green 100% - 70%, yellow 69% - 30%, red 29% - 0%.
What did I miss in the config?
A few comments about your code:
  • There is no need to use three distinct bar meter, with three distinct colors, then show one of them and hiding the others. One single would be enough, instead of showing / hiding the appropriate meter, you could change the color of the only existing bar, according to the measured value, using !SetOption bangs.
  • Also no need to use four Power plugin measures with the PowerState=PERCENT option. One single is again enough, but it should have set some proper IfConditions, instead of IfActions. The IfConditions do the same things, but are more - more versatile and easier to use.
  • The shorter for of the PlugIn options in the appropriate measures would be PlugIn=PowerPlugin, instead of the original PlugIn=PlugIns\PowerPlugin.dll (but however, even the original for doesn't have any issue, it works well).
  • In Rainmeter (as well as in any other ini file), the lines which should be ignored must be commented out with semicolons. I mean that eg the first line of your code, which is a comment (#Check battery or acline), should have a semicolon in front of it: [color=#FF0000];[/color]#Check battery or acline. This will indicate Rainmeter, that that's a comment and should be ignored.
  • Both the !Rainmeter... bang prefix and the !Execute bang are deprecated. You should remove them.
With all these, your code should look in the following much simpler form:

Code: Select all

;#Check battery or acline 
[MeasureAC]
Measure=Plugin
PlugIn=PowerPlugin
PowerState=ACLINE
Substitute="0":"5","1":"6"

;#Measure battery energy
[MeasurePercent]
Measure=Plugin
PlugIn=PowerPlugin
PowerState=PERCENT
UpdateDivider=10

;#Battery measure when energy is more than 0%
[MeasureBattery]
Measure=Plugin 
PlugIn=PowerPlugin
PowerState=PERCENT
UpdateDivider=10
IfCondition=(MeasureBattery<=30)
IfTrueAction=[!SetOption BatteryBar BarColor "D64933"][!UpdateMeter "BatteryBar"][!Redraw]
IfCondition2=((MeasureBattery>30)&&(MeasureBattery<=70))
IfTrueAction2=[!SetOption BatteryBar BarColor "F2CC8F"][!UpdateMeter "BatteryBar"][!Redraw]
IfCondition3=(MeasureBattery>70)
IfTrueAction3=[!SetOption BatteryBar BarColor "53DD6C"][!UpdateMeter "BatteryBar"][!Redraw]

[BatteryIcon] 
Meter=STRING
MeasureName=MeasureAC
X=-3 
Y=20r 
FontColor=#FontColor# 
FontSize=16 
FontFace=ConkyColors 
AntiAlias=1 
StringAlign=Left 
 
;#Battery text meter
[MeterBatteryLabel] 
Meter=STRING 
X=27 
Y=0r 
FontColor=#FontColor# 
FontSize=#FontHeight# 
FontFace=#FontName# 
AntiAlias=1 
StringAlign=left 
Text="Poziom baterii:" 
 
;#Battery bar meter color green
[BatteryBar] 
MeasureName=MeasurePercent  
Meter=BAR 
X=143r 
Y=5r 
H=10 
W=130 
BarOrientation=HORIZONTAL
UpdateDivider=10
 
;#Actual battery percentage value string
[MeterBattery] 
Meter=String 
MeasureName=MeasurePercent
X=297 
Y=-4r 
FontColor=#FontColor# 
FontSize=#FontHeight# 
FontFace=#FontName# 
AntiAlias=1 
StringAlign=Right 
Text="%1%"
Note the following: I removed the BarColor option of the [BatteryBar] meter, because this option is set by the IfTrueAction options of the [MeasureBattery] measure. See that you can add there as many conditions and the appropriate IfTrueActions, as you want, their number isn't limited.
User avatar
Dany Gee
Posts: 33
Joined: July 11th, 2012, 8:32 am

Re: Battery bar not changing color only while charging

Post by Dany Gee »

Quality reply there balala.
I really appreciate it.
Tested your code and it works like a charm!
Case solved :beer:
SYSTEM: Windows 11 Pro 64bit|MOBO: ASUS Z170 Deluxe|CPU: i7-6700K @ 4.3Ghz|GPU: Asus GTX1080 Strix|RAM: 64GB Gskill Trident Z RGB (2400Mhz CL15)
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Solved]Battery bar not changing color only while charging

Post by balala »

I'm glad.