It is currently March 29th, 2024, 9:44 am

Switch between two types of GPU

Get help with creating, editing & fixing problems with skins
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Switch between two types of GPU

Post by pul53dr1v3r »

I'm searching for a better way to accomplish merging measures and meters of two GPU types (ATI and NVIDIA) into one .ini file where the desired GPU type will be chosen by GPUType variable. The submitted way to get it works fine. The only issue is that GPU1MemoryUsage value used through [SwitchBetweenGPUType] measure gives the values in format "307.04251 MB" instead of "307". Nevertheless, using the same measure in a meter (for example in GPU1NvidiaMemoryText) to get the value gives the round value ("307" etc.). :confused: Seems i don't understand why does it happen. Btw. even if the issue doesn't exist, i'd like to see if there is a better way to do this all and to get the rpund values.

Code: Select all

[Variables]
GPUType=0
GPUMemoryInMegaBytes=1024

Code: Select all

[GPU1MemoryUsageString]
Meter=STRING
MeterStyle=styleLeftText
FontColor=#colorText#,#colorTextAlpha#
Text=MEM:
X=7
Y=([GPU1UsageText:Y]+14)
TransformationMatrix=#Scale#;0;0;#Scale#;#Scale#;#Scale#

Code: Select all

;::::::::::NVIDIA::::::::::

[GPU1NvidiaMemoryText]
Meter=STRING
MeterStyle=styleCenterText
FontColor=[GPU1NvidiaMemoryMBTextWarn]
X=102
Y=r
DynamicVariables=1
Group=NVIDIA

[GPU1NvidiaMemoryPercentString]
Meter=STRING
MeterStyle=styleRightText
MeasureName=GPU1NvidiaMemoryPercent
FontColor=#colorText#,#colorTextAlpha#
Text="[%1%]"
X=197
Y=r
TransformationMatrix=#Scale#;0;0;#Scale#;#Scale#;#Scale#
Group=NVIDIA

[GPU1NvidiaMemUsageBar]
Meter=Bar
MeasureName=GPU1NvidiaMemoryPercent
X=7
Y=([GPU1MemoryUsageString:Y]+12)
W=189
H=#barHeight#
BarColor=[GPU1NvidiaMemoryBarWarn]
SolidColor=#EmptyBarColor#,#EmptyBarColorAlpha#
BarOrientation=HORIZONTAL
DynamicVariables=1
AutoScale=1
TransformationMatrix=#Scale#;0;0;#Scale#;#Scale#;#Scale#
Group=NVIDIA

[GPU1NvidiaMemoryPercent]
Measure=Plugin
Plugin=HWiNFO.dll
HWiNFOSensorId=#HWiNFO-GPU0-SensorId#
HWiNFOSensorInstance=#HWiNFO-GPU0-SensorInstance#
HWiNFOEntryId=#HWiNFO-GPU0-MemUsg#
HWiNFOType=CurrentValue
MinValue=0
MaxValue=100
Group=NVIDIA

[GPU1NvidiaMemoryBarWarn]
Measure=Calc
Formula=GPU1NvidiaMemoryPercent> 75 ? -1 : -2
Substitute="-1":"220,20,60,200","-2":"#colorBar#,#colorBarAlpha#"
Group=NVIDIA

[GPU1NvidiaMemoryMBTextWarn]
Measure=Calc
Formula=GPU1NvidiaMemoryPercent< 20 ? -1 : (GPU1NvidiaMemoryPercent< 40 ? -2 : (GPU1NvidiaMemoryPercent< 60 ? -3: (GPU1NvidiaMemoryPercent< 80 ? -4 : -5)))
Substitute="-1":"255,229,204,100","-2":"255,204,153,150","-3":"255,178,102,150","-4":"255,153,51,150","-5":"255,51,51,150"
Group=NVIDIA

[GPU1TotalMemMB]
Measure=Calc
Formula=(GPU1MemoryUsage) / (GPU1NvidiaMemoryPercent / 100)
Group=NVIDIA

Code: Select all

;::::::::::ATI::::::::::

[GPU1AtiMemoryText]
Meter=STRING
MeterStyle=styleCenterText
FontColor=[GPU1AtiMemoryMBTextWarn]
X=102
Y=[GPU1MemoryUsageString:Y]
DynamicVariables=1
TransformationMatrix=#Scale#;0;0;#Scale#;#Scale#;#Scale#
Group=ATI

[GPU1AtiMemoryPercentString]
Meter=STRING
MeterStyle=styleRightText
MeasureName=GPU1AtiMemoryPercent
FontColor=#colorText#,#colorTextAlpha#
Text="[%1%]"
X=197
Y=r
TransformationMatrix=#Scale#;0;0;#Scale#;#Scale#;#Scale#
Group=ATI

[GPU1AtiMemUsageBar]
Meter=Bar
MeasureName=GPU1MemoryCalc2
X=7
Y=([GPU1MemoryUsageString:Y]+12)
W=189
H=#barHeight#
BarColor=[GPU1AtiMemoryBarWarn]
SolidColor=#EmptyBarColor#,#EmptyBarColorAlpha#
BarOrientation=HORIZONTAL
DynamicVariables=1
AutoScale=1
TransformationMatrix=#Scale#;0;0;#Scale#;#Scale#;#Scale#
Group=ATI

[GPU1MemoryUsage]
Measure=Plugin
Plugin=HWiNFO.dll
HWiNFOSensorId=#HWiNFO-GPU0-SensorId#
HWiNFOSensorInstance=#HWiNFO-GPU0-SensorInstance#
HWiNFOEntryId=#HWiNFO-GPU0-MemAlloc#
HWiNFOType=CurrentValue

;percentage
[GPU1AtiMemoryPercent]
Measure=Calc
Formula= (GPU1MemoryUsage * 100 / ( #GPUMemoryInMegaBytes# + 0.000001 ))
Group=ATI

[GPU1MemoryCalc2]
Measure=Calc
Formula=GPU1AtiMemoryPercent
MinValue=0
MaxValue=100
Group=ATI

[GPU1AtiMemoryBarWarn]
Measure=Calc
Formula=GPU1MemoryCalc2> 75 ? -1 : -2
Substitute="-1":"220,20,60,200","-2":"#colorBar#,#colorBarAlpha#"
Group=ATI

[GPU1AtiMemoryMBTextWarn]
Measure=Calc
Formula=GPU1MemoryCalc2< 20 ? -1 : (GPU1MemoryCalc2< 40 ? -2 : (GPU1MemoryCalc2< 60 ? -3: (GPU1MemoryCalc2< 80 ? -4 : -5)))
Substitute="-1":"255,229,204,100","-2":"255,204,153,150","-3":"255,178,102,150","-4":"255,153,51,150","-5":"255,51,51,150"
Group=ATI

Code: Select all

[SwitchBetweenGPUType]
Measure=Calc
Formula=#GPUType#
OnChangeAction=[!UpdateMeter "GPU1AtiMemoryText"][!UpdateMeter "GPU1AtiMemoryPercentString"][!UpdateMeter "GPU1NvidiaMemoryText"][!UpdateMeter "GPU1NvidiaMemoryPercentString"][!Redraw]
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetOption "GPU1NvidiaMemoryText" "Text" "[*GPU1MemoryUsage*]MB/[GPU1TotalMemMB]MB"][!EnableMeasureGroup "NVIDIA"][!ShowMeterGroup "NVIDIA"][!DisableMeasureGroup "ATI"][!HideMeterGroup "ATI"][!UpdateMeterGroup "NVIDIA"][!Redraw]
IfFalseAction=[!SetOption "GPU1AtiMemoryText" "Text" "[*GPU1MemoryUsage*]MB/#GPUMemoryInMegaBytes#MB"][!EnableMeasureGroup "ATI"][!ShowMeterGroup "ATI"][!DisableMeasureGroup "NVIDIA"][!HideMeterGroup "NVIDIA"][!UpdateMeterGroup "ATI"][!Redraw]
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Switch between two types of GPU

Post by balala »

Pul53dr1v3r wrote: July 3rd, 2019, 4:48 pm The only issue is that GPU1MemoryUsage value used through [SwitchBetweenGPUType] measure gives the values in format "307.04251 MB" instead of "307". Nevertheless, using the same measure in a meter (for example in GPU1NvidiaMemoryText) to get the value gives the round value ("307" etc.). :confused:
Yes, because although the default value of the NumOfDecimals options of a String meter is 0 and the meter should show the value accordingly with no decimals, this is only true if the shown value is the value set through a MeasureName option within the String meter. In your case the best way to get the shown value as an integer is to pass it through a Calc measure, which rounds the original value.
If you want to try out this, add the following measure to your code:

Code: Select all

[GPU1MemoryUsageNum]
Measure=Calc
Formula=( Round ( GPU1MemoryUsage ))
The above used Round function rounds the value returned by the measure, returning an integer.
Now you have to modify the IfTrueAction and IfFalseAction options of the [SwitchBetweenGPUType] measure, to get the String meter to show the value returned by the newly added [GPU1MemoryUsageNum] Calc measure:

Code: Select all

[SwitchBetweenGPUType]
...
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetOption "GPU1NvidiaMemoryText" "Text" "[*GPU1MemoryUsageNum*]MB/[GPU1TotalMemMB]MB"][!EnableMeasureGroup "NVIDIA"][!ShowMeterGroup "NVIDIA"][!DisableMeasureGroup "ATI"][!HideMeterGroup "ATI"][!UpdateMeterGroup "NVIDIA"][!Redraw]
IfFalseAction=[!SetOption "GPU1AtiMemoryText" "Text" "[*GPU1MemoryUsageNum*]MB/#GPUMemoryInMegaBytes#MB"][!EnableMeasureGroup "ATI"][!ShowMeterGroup "ATI"][!DisableMeasureGroup "NVIDIA"][!HideMeterGroup "NVIDIA"][!UpdateMeterGroup "ATI"][!Redraw]
...
Note that if you want to get the value of the [GPU1TotalMemMB] measure as an integer, as well, that measure being from the beginning a calc measure, you can add the Round function directly to its Formula.
User avatar
pul53dr1v3r
Posts: 442
Joined: July 30th, 2014, 10:30 am

Re: Switch between two types of GPU

Post by pul53dr1v3r »

balala wrote: July 3rd, 2019, 5:26 pm
ah so... It's fine with the calc measure. :thumbup: