It is currently March 28th, 2024, 11:44 am

Fine control over String Meters SolidColor values ?

Get help with creating, editing & fixing problems with skins
Post Reply
MadMatty72
Posts: 3
Joined: February 4th, 2023, 12:13 am

Fine control over String Meters SolidColor values ?

Post by MadMatty72 »

Hi all, I'm a total noob to RainMeter so decided to create my first Skin that shows (via text) and displays (via back ground color) the CPU temp (as my new 5600X with stock cooler gets quite hot) - simple right? was not the case...

The issue I have is that I am unable to programmatically insert a single colors value into a String Meters 'SolidColor' string, I.e. I'm trying to dynamically change the RED value of the RGBA components of the its string "red#, green#, blue#, alpha#" so that the String Meters back ground color slowly turns red as temperature rises.

I DO NOT want to predefine a few color strings and change out the entire SolidColor string at specific temps - I want the color change to be very progressive, I.e. 35 to 40 different colors of RED (and likely alpha once I get it working) for each degree the CPU rises in temp.

The specific issue I think I'm having is that I'm unable to convert the CPU temp value(a float string) to an integer string suitable for the SolidColor string, Rainmeter seems to always embed the original floating point string regardless of any Calc Measure or Variable conversion I attempt.

Has anyone every achieved this? (dynamic single color change)

Please advise me on value transfer and conversion.

Thanks.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Fine control over String Meters SolidColor values ?

Post by eclectic-tech »

You will need to truncate the raw temperature values in a calc measure, so they return integer values; TRUNC() function
Then perhaps something like this:

Code: Select all

[Rainmeter]
Update=500
AccurateText=1
DynamicWindowSize=1

[MeasureLoop]
Measure=Loop
StartValue=59
EndValue=99
Increment=1
LoopCount=0
InvertMeasure=0

[MeasureTemp2ColorRed]
Measure=Calc
Formula=55+MeasureLoop*2
DynamicVariables=1

[MeasureTemp2ColorGreen]
Measure=Calc
Formula=255-MeasureLoop*2
DynamicVariables=1

[MeasureTemp2ColorBlue]
Measure=Calc
Formula=255-MeasureLoop*2
DynamicVariables=1

[MeterString]
Meter=String
MeasureName=MeasureLoop
StringStyle=Bold
SolidColor=[MeasureTemp2ColorRed:],[MeasureTemp2ColorGreen:],[MeasureTemp2ColorBlue:],240
Text=%1°C
Padding=8,4,8,4
DynamicVariables=1
I use a loop measure to simulate your temp values from 59 to 99 degrees Celsius, and calc measures to retun increasing and decreasing values for RGB.
tempred.gif
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Fine control over String Meters SolidColor values ?

Post by balala »

MadMatty72 wrote: February 4th, 2023, 1:00 am Please advise me on value transfer and conversion.
eclectic-tech offered you above an idea on how to round or truncate the decimal value returned by the appropriate measure, but to be used into color codes, this truncation is not even needed in fact. Color codes are perfectly fine if get non-integer values. What he said but didn't insist is how can you use a value returned by a measure, into a color code of any kind of option (SolidColor here specifically, but this is less important). As you can see in his code, the SolidColor option of the [MeterString] meter is using the three values returned by the three measures ([MeasureTemp2ColorRed], [MeasureTemp2ColorGreen], [MeasureTemp2ColorBlue]) as the first three components of the SolidColor option. He used the numeric values of these measures, this being specified by the colons added to the names of measures: SolidColor=[MeasureTemp2ColorRed:][MeasureTemp2ColorGreen:],[MeasureTemp2ColorBlue:]. This way the option uses those numeric values (all measures have a string and a numeric value, here he used the numeric value, as said above).
No need for truncation if the values returned by the measure(s) you want to use in the SolidColor option is/are returning non-integer values. The meter using this SolidColor option is perfectly fine even with decimal values. Much more important is to specify a DynamicVariables=1 option on the meter which has to use the values of those measures (see that eclectic-tech also added this option to his [MeterString] meter). Without this option, the meter won't use the values specified into the SolidColor option and the color changing won't go on.
However even these have been said, there might be a lot of details, which could make the difference on how those measures and meter are behaving. So, a code would be nice if you want much more specific help on this problem. Please post it if you can't be this to properly work.
MadMatty72
Posts: 3
Joined: February 4th, 2023, 12:13 am

Re: Fine control over String Meters SolidColor values ?

Post by MadMatty72 »

I'm sure I tried both Trunc(), colon, and Dynamic variable=1 features with no luck so can only assume I made some other mistake.

Big thankyou for the replies and code example, very clear and explanatory considering my wordy post that lacked any example code. I'm aware I should have included code but didn't do so because it was so butchered from the many many failed attempts to get it working. The moment I get it working, I'll post the resulting code as a follow up post.

Btw, when I included square brackets surrounding Measure IDs within a Meter, the Measures value was always lost, usually just 0 resulted.
Is the colon always required to return a value ? (regardless of numeric or string selection)

Much appreciated.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Fine control over String Meters SolidColor values ?

Post by eclectic-tech »

MadMatty72 wrote: February 5th, 2023, 12:14 am I'm sure I tried both Trunc(), colon, and DynamicVariable=1 features with no luck so can only assume I made some other mistake.
See the correct syntax above (in Red) for dynamic variables. Lettle typos like that make code not work.
MadMatty72 wrote: February 5th, 2023, 12:14 amBig thankyou for the replies and code example, very clear and explanatory considering my wordy post that lacked any example code. I'm aware I should have included code but didn't do so because it was so butchered from the many many failed attempts to get it working. The moment I get it working, I'll post the resulting code as a follow up post.
You came here for help, but we need to see what you coded to do that. Post the 'messy' code you have, and we can help you.
MadMatty72 wrote: February 5th, 2023, 12:14 amBtw, when I included square brackets surrounding Measure IDs within a Meter, the Measures value was always lost, usually just 0 resulted.
Is the colon always required to return a value ? (regardless of numeric or string selection)

Much appreciated.
https://docs.rainmeter.net/manual/variables/section-variables/
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Fine control over String Meters SolidColor values ?

Post by balala »

eclectic-tech wrote: February 5th, 2023, 11:55 am See the correct syntax above (in Red) for dynamic variables. Lettle typos like that make code not work.
Actually (not to nitpick!) the red syntax is not quite the correct syntax of this option. Its correct form is: DynamicVariables=1.
MadMatty72 wrote: February 5th, 2023, 12:14 am I'm aware I should have included code but didn't do so because it was so butchered from the many many failed attempts to get it working. The moment I get it working, I'll post the resulting code as a follow up post.
I agree with eclectic-tech:
eclectic-tech wrote: February 5th, 2023, 11:55 am You came here for help, but we need to see what you coded to do that. Post the 'messy' code you have, and we can help you.
The code is absolutely needed to can help you further. Don't worry about how your code is. It might be "butchered", but if you post it as you have it, probably you'll get further help as well. Seeing the messy code, we can help you with all kind of advices even related to parts of code not exactly related to the issue. And don't worry you had "many many failed attempts to get it working" either. We all have from time to time such attempts to get a skin working, until we finally really get it well working.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5380
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Fine control over String Meters SolidColor values ?

Post by eclectic-tech »

balala wrote: February 5th, 2023, 6:18 pm Actually (not to nitpick!) the red syntax is not quite the correct syntax of this option. Its correct form is: DynamicVariables=1.
You caught my typo! :D
Simple mistakes like that will break the code :(
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Fine control over String Meters SolidColor values ?

Post by balala »

eclectic-tech wrote: February 6th, 2023, 1:05 am You caught my typo! :D
Simple mistakes like that will break the code :(
MadMatty72
Posts: 3
Joined: February 4th, 2023, 12:13 am

Re: Fine control over String Meters SolidColor values ?

Post by MadMatty72 »

My issue was the lack of a DynamicVariable=1 (as suggested).

Here's the code as promised - is an illustro Skin, I.e. the .ini should exist in a folder under illustro as it uses its graphic (that's in illustro Resources folder). The Coloring is auto ranging - the RegValue Ids will need to be changed to suit your own setup (HWInfo selections).

I'll ask more questions in future as I'd like to add option menu to it:

Code: Select all

;======================================================
; This skin displays CPU and GFX card temps.
; The graphs backcolor turns increasingly red with rise in temperature, intensity is auto scaled between min-max measured temps.
; The titles backcolor turns max red when temp exceeds 98% of max measured temp and is over 68 degrees.
; Temp (and other values such as Mhz) are retrieved form the Win Registry.
; HWInfo must be configured to place such values in the Win Registry.
; Once HWInfo is configured, type 'reg query HKEY_CURRENT_USER\SOFTWARE\HWiNFO64\VSB' into CMD to view the ID#s of the temp data (only raw value is used).. 
; Adjust Source & Result temp range limits for your system within Variables section
;=====================================================

[Metadata]
Name= Temps
Author= MadMatty72
Information= Show CPU & GFX temps via text and color
Version= 1
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Rainmeter]
Update=1000
Background=#@#Background.png
BackgroundMode=3
BackgroundMargins=0,34,0,10

[Variables]
FontName=Trebuchet MS
RedMin=0
RedMax=255
AlphaMin=0
AlphaMax=255
CPUColor=0,190,0,255
GFXColor=255,127,255,255
DynamicVariable=1

;==========================
; Measures of registry data
;==========================
;[Measure0Sensor]
;Measure=Registry
;RegHKey=HKEY_CURRENT_USER
;RegKey=SOFTWARE\HWiNFO64\VSB
;RegValue=Sensor0

;[Measure0Label]
;Measure=Registry
;RegHKey=HKEY_CURRENT_USER
;RegKey=SOFTWARE\HWiNFO64\VSB
;RegValue=Label0

;[Measure0ValueFormatted]
;Measure=Registry
;RegHKey=HKEY_CURRENT_USER
;RegKey=SOFTWARE\HWiNFO64\VSB
;RegValue=Value0

[Measure0ValueRaw]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=SOFTWARE\HWiNFO64\VSB
RegValue=ValueRaw0
DynamicVariables=1

;[Measure1Sensor]
;Measure=Registry
;RegHKey=HKEY_CURRENT_USER
;RegKey=SOFTWARE\HWiNFO64\VSB
;RegValue=Sensor1

;[Measure1Label]
;Measure=Registry
;RegHKey=HKEY_CURRENT_USER
;RegKey=SOFTWARE\HWiNFO64\VSB
;RegValue=Label1

;[Measure1ValueFormatted]
;Measure=Registry
;RegHKey=HKEY_CURRENT_USER
;RegKey=SOFTWARE\HWiNFO64\VSB
;RegValue=Value1

[Measure1ValueRaw]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=SOFTWARE\HWiNFO64\VSB
RegValue=ValueRaw1
DynamicVariables=1

;[Measure2Sensor]
;Measure=Registry
;RegHKey=HKEY_CURRENT_USER
;RegKey=SOFTWARE\HWiNFO64\VSB
;RegValue=Sensor2

;[Measure2Label]
;Measure=Registry
;RegHKey=HKEY_CURRENT_USER
;RegKey=SOFTWARE\HWiNFO64\VSB
;RegValue=Label2

;[Measure2ValueFormatted]
;Measure=Registry
;RegHKey=HKEY_CURRENT_USER
;RegKey=SOFTWARE\HWiNFO64\VSB
;RegValue=Value2

[Measure2ValueRaw]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=SOFTWARE\HWiNFO64\VSB
RegValue=ValueRaw2
DynamicVariables=1

;==================================
; Calcs (Ghz & Temp alert coloring)
;==================================
[MeasureCPUMHz]
Measure=Calc
Formula=Measure0ValueRaw
DynamicVariable=1

[MeasureCPUTemp]
Measure=Calc
Formula=Measure1ValueRaw
DynamicVariable=1

[MeasureGFXTemp]
Measure=Calc
Formula=Measure2ValueRaw
DynamicVariable=1

[MeasureMinOfTemps]
Measure=Calc
Formula=Round(Min(MeasureCPUTemp, MeasureGFXTemp),0)
DynamicVariable=1

[MeasureMaxOfTemps]
Measure=Calc
Formula=Round(Max(MeasureCPUTemp, MeasureGFXTemp),0)
DynamicVariable=1

[MeasureMinTemp]
Measure=Calc
Formula=MeasureMinTemp = 0 ? MeasureMinOfTemps : (MeasureMinOfTemps < MeasureMinTemp ? MeasureMinOfTemps : MeasureMinTemp)
DynamicVariable=1

[MeasureMaxTemp]
Measure=Calc
Formula=MeasureMaxOfTemps > MeasureMaxTemp ? MeasureMaxOfTemps : MeasureMaxTemp
DynamicVariable=1

[MeasureRed]
Measure=Calc
Formula=Round((MeasureMaxOfTemps - MeasureMinTemp) * ((#RedMax# - #RedMin#) / (MeasureMaxTemp - MeasureMinTemp)) + #RedMin#)
IfCondition=(MeasureMaxOfTemps > (0.98 * MeasureMaxTemp)) && (MeasureMaxOfTemps > 68)
IfTrueAction=[!SetOption MeterTitle SolidColor 255,35,56,255]
IfFalseAction=[!SetOption MeterTitle SolidColor 0,0,0,0]
DynamicVariable=1

[MeasureAlpha]
Measure=Calc
Formula=Round((MeasureMaxOfTemps - MeasureMinTemp) * ((#AlphaMax# - #AlphaMin#) / (MeasureMaxTemp - MeasureMinTemp)) + #AlphaMin#)
DynamicVariable=1

;======
;Styles
;======
[StyleTitle]
Meter=String
StringAlign=Center
StringCase=Upper
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,50
FontColor=255,255,255,205
FontFace=#FontName#
FontSize=10
AntiAlias=1
ClipString=1
DynamicVariable=1

[styleLeftText]
StringAlign=Left
StringCase=None
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontSize=8
AntiAlias=1
ClipString=1
DynamicVariable=1

;======
;Meters
;======
[MeterTitle]
Meter=String
MeterStyle=styleTitle
X=103
Y=12
W=188
H=18
Text=TEMPS
LeftMouseUpAction=["C:\Users\matty\Downloads\hwi_736\HWiNFO64.exe"]
ToolTipText=Open 'HWInfo64.exe' app
DynamicVariable=1

[MeterTempLines]
Meter=Line
X=9
Y=35
W=190
H=64
Flip=1
GraphOrientation=Horizontal
GraphStart=Left
MeasureName=Measure1ValueRaw
MeasureName2=Measure2ValueRaw
MeasureName3=MeasureMaxTemp
SolidColor=0,0,0,[MeasureAlpha:]
SolidColor2=[MeasureRed:],0,0,[MeasureAlpha:]
LineCount=3
LineWidth=2
LineColor=#CPUColor#
LineColor2=#GFXColor#
LineColor3=255,255,255,163
AutoScale=0
AntiAlias=1
DynamicVariables=1
RightMouseUpAction=[]

[MeterCPUTemp]
Meter=String
MeasureName=MeasureCPUTemp
X=10
Y=40
W=190
H=14
MeterStyle=styleLeftText
FontColor=#CPUColor#
Text=CPU Temp: %1°C
DynamicVariables=1

[MeterGFXTemp]
Meter=String
MeasureName=MeasureGFXTemp
X=10
Y=60
W=190
H=14
MeterStyle=styleLeftText
FontColor=#GFXColor#
Text=GFX Temp: %1°C
DynamicVariables=1

[MeterMaxTemp]
Meter=String
MeasureName=MeasureMaxTemp
X=10
Y=80
W=190
H=14
MeterStyle=styleLeftText
FontEffectColor=0,0,0,50
FontColor=255,255,255,205
Text=Max Temp: %1°C
DynamicVariables=1

Thanks all.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Fine control over String Meters SolidColor values ?

Post by balala »

MadMatty72 wrote: February 11th, 2023, 5:54 am Here's the code as promised - is an illustro Skin, I.e. the .ini should exist in a folder under illustro as it uses its graphic (that's in illustro Resources folder). The Coloring is auto ranging - the RegValue Ids will need to be changed to suit your own setup (HWInfo selections).
Noted two errors in log, when refreshing the skin. There is a simply fix, same for both.
The messages are Calc: Division by 0, for the [MeasureRed] and [MeasureAlpha] measures and are caused by the fact that the divisor in both measures are 0 when refreshing the skin, because the (MeasureMaxTemp - MeasureMinTemp) difference is zero in such cases.
The fix is simple for both errors: you should have to add an extremely small value to the above differences, which doesn't change the result, but avoids the error. See for instance the added 0.00001 to both (MeasureMaxTemp - MeasureMinTemp) differences in Formula options of the mentioned measures:

Code: Select all

[MeasureRed]
...
Formula=Round((MeasureMaxOfTemps - MeasureMinTemp) * ((#RedMax# - #RedMin#) / (MeasureMaxTemp - MeasureMinTemp + 0.00001)) + #RedMin#)
...

[MeasureAlpha]
...
Formula=Round((MeasureMaxOfTemps - MeasureMinTemp) * ((#AlphaMax# - #AlphaMin#) / (MeasureMaxTemp - MeasureMinTemp + 0.00001)) + #AlphaMin#)
...
MadMatty72 wrote: February 11th, 2023, 5:54 am I'll ask more questions in future as I'd like to add option menu to it:
Feel free to come back with those questions, when arise.
Post Reply