It is currently March 28th, 2024, 1:32 pm

Mathematic operations and manipulating variables?

Get help with creating, editing & fixing problems with skins
Post Reply
tripnikk
Posts: 2
Joined: May 31st, 2018, 9:04 pm

Mathematic operations and manipulating variables?

Post by tripnikk »

I've been trying to make a SUPER basic skin that displays my core temp in fahrenheit (CoreTemp returns values in Celsius). I've gone through the tutorials and read through the references and found them incomplete at best. I know the formula is F = (C*1.8)+32, but doing math and manipulating variables in rainmeter doesn't seem so straight forward. It tends to display the actual formula instead of actually affecting the number. I've also tried creating a variable (initially set to 0), then setting that variable to (%1*1.8)+32 but that simply returns a 0. I'm guessing it's because the code is ignored due to incorrect format, and it's simply returning the initial value I set in the Variables section.

Code: Select all

[Variables]
TempHolder=0
TempVar=0

[MeasureCoreTemp]
Measure=Plugin
Plugin=CoreTemp
CoreTempType=Temperature
CoreTempIndex=0
#TempVar#=(%1*1.8)+32.0
DynamicVariables=1

[MeterCoreTemp]
Meter=String
MeasureName=MeasureCoreTemp
;Style and other sections of code removed for readability
MeterStyle=TextStyle
DynamicVariables=1
X=0
Y=0
FontSize=160
FontColor=127,127,127,127
Text=#TempVar#

;had previously tried:
;Text=%1*1.8+32  
I've also tried using !SetVariable but the only examples I found in the references were using it in an if/then statement, not simply setting an extant variable to a new value.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Mathematic operations and manipulating variables?

Post by jsmorley »

Code: Select all

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

[Variables]

[MeasureCoreTemp]
Measure=Plugin
Plugin=CoreTemp
CoreTempType=Temperature
CoreTempIndex=0

[MeasureInF]
Measure=Calc
Formula=(MeasureCoreTemp * 1.8) + 32.0

[MeterCoreTemp]
Meter=String
MeasureName=MeasureInF
X=0
Y=0
FontSize=160
FontColor=127,127,127,127
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Mathematic operations and manipulating variables?

Post by jsmorley »

1) The tokens %1, %2, etc. are only used on a a String meter to reflect the string value of a measure "bound" to the String meter with a MeasureName, MeasureName2, etc. option. They can't be used anywhere else. They are used to embedded a measure value bound to the meter in other text when used in the Text (and ToolTipText) options on a String meter.

Text=The value is %1 right now for instance.

2) You can't simply assign a value to a variable with a simple assignment statement like MyVar=20, as Rainmeter is not a procedural programming language, and doesn't support programming statements. You must use a "Trigger Action" of some kind, (Pretty much anything that ends in ..Action) to fire a !SetVariable bang to set the value of the variable to something.

OnUpdateAction=[!SetVariable MyVar "20"] for instance.

In this case, a variable isn't really needed.

P.S. I believe you can set CoreTemp to return values in Fahrenheit in its settings...
tripnikk
Posts: 2
Joined: May 31st, 2018, 9:04 pm

Re: Mathematic operations and manipulating variables?

Post by tripnikk »

Thank you! I figured there would be a way to get CoreTemp to return Fahrenheit, but this is kind of more of a simple exercise to see if I can solidify my grasp on how rainmeter works. So far, I've found the way that information flows between meters and measures (and even the definitions themselves) sort of abstract, but I feel like it will become more natural if I just keep banging my head against the wall and trying new things.

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

Re: Mathematic operations and manipulating variables?

Post by balala »

jsmorley wrote:P.S. I believe you can set CoreTemp to return values in Fahrenheit in its settings...
Yes, it can be. You have to click Options -> Settings, click the Display tab and check the Display temperatures in Fahrenheit checkbox.
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Mathematic operations and manipulating variables?

Post by CyberTheWorm »

I use this formula for C to F the actual formula

Code: Select all

[MeasureTempInFahrenheit]
Measure=Calc
Formula=(MeasureCTemp*9)/5 +32
Post Reply