Search code examples
batteryskinrainmeter

Unable to assign positive values of red


This is a bit of an odd issue. I've got a battery skin that is supposed to change color dynamically with the current percent of the battery. However, any positive red values in the RGB do not appear. Full skin code included below, can provide screenshot of issue if needed.

[Rainmeter]
Update=1000
AccurateText=1

[Variables]
COLORBKGD=255,255,255,255
COLORMEASURE=0,255,0,255

[MeasureBatteryStatus]
Measure=Plugin
Plugin=PowerPlugin
PowerState=Status
IfCondition=MeasureBatteryStatus = 1
IfFalseAction=[!SetOption MeterIcon ImageName "#@#power.png"][!Redraw]
IfTrueAction=[!SetOption MeterIcon ImageName "#@#powerCharging.png"][!Redraw]

[MeasureGreenValue]
Measure=Calc
Formula=Floor([MeasureBatteryPct] < 25 ? 0 : ([MeasureBatteryPct] > 75 ? 255 : ([MeasureBatteryPct] - 25) / 50 * 255))
DynamicVariables=1

[MeasureRedValue]
Measure=Calc
Formula=Floor([MeasureBatteryPct] > 75 ? 0 : ([MeasureBatteryPct] < 25 ? 255 : (1 - ([MeasureBatteryPct] - 25) / 50) * 255))
DynamicVariables=1


[MeasureBatteryPct]
Measure=Plugin
Plugin=PowerPlugin
PowerState=Percent
DynamicVariables=1
OnUpdateAction=[!SetVariable COLORMEASURE ([MeasureRedValue],[MeasureGreenValue],0,255)][!SetOption MeterBatteryPct LineColor #COLORMEASURE#][!Redraw]

[MeterIcon]
Meter=Image
ImageName="#@#power.png"
X=8
Y=7
W=48
PreserveAspectRatio=1

[MeterBkgd]
Meter=Roundline
X=0
Y=0
W=64
H=64
RotationAngle=(2*PI)
LineWidth=16
LineLength=29
LineStart=28
AntiAlias=1
Solid=1
LineColor=#COLORBKGD#

[MeterBatteryPct]
Meter=Roundline
MeasureName=MeasureBatteryPct
X=0
Y=0
W=64
H=64
StartAngle=(3*PI/2)
RotationAngle=(2*PI)
LineLength=31
Solid=1
AntiAlias=1
LineColor=255,0,0,255
LineStart=26
DynamicVariables=1

Solution

  • OK, I solved it a couple hours ago. The only significant difference I can find between the working code and the code I originally posted is the parentheses around the assigned value for COLORMEASURE:

    OnUpdateAction=[!SetVariable COLORMEASURE ([MeasureRedValue],[MeasureGreenValue],0,255)][!SetOption MeterBatteryPct LineColor #COLORMEASURE#][!Redraw]
    

    At this point, I'm not certain if that was the cause of the issue or not, but issue solved regardless.