It is currently December 15th, 2019, 6:35 am

Looking for a Unit Conversion tool

Help with creating, editing & fixing problems with skins
User avatar
CoffeeJoe
Posts: 17
Joined: November 6th, 2019, 4:19 am

Looking for a Unit Conversion tool

CoffeeJoe » November 10th, 2019, 1:13 pm

Does anyone know if a good unit conversion tool exists?
  • Enter degrees in Celsius and it displays the value in Fahrenheit
  • Enter the weight in Metric and it returns the Imperial value
  • Enter Tbsp. and it'll tell me how many tsp. that is.
I imagine someone has created something that can do this. Any suggestion where to look ?
User avatar
jsmorley
Developer
Posts: 19870
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Looking for a Unit Conversion tool

jsmorley » November 10th, 2019, 1:23 pm

I don't think I have seen a Rainmeter skin that does this, mostly because there are so many thousands of things you can convert between, you would need just boatloads of keywords and formulas. The effort seems to fit a bad cost/benefit curve in my view, since it is just so easy to say "5 tablespoons to teaspoons", or any other unit conversion question, in your browser URL, and Google will pretty much instantly tell you the answer.


1.jpg


I mean, each individual one would be trivial to do, but the aggregate would be the Bataan Death March.

https://www.convertworld.com/en/
You do not have the required permissions to view the files attached to this post.
User avatar
CyberTheWorm
Posts: 670
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Looking for a Unit Conversion tool

CyberTheWorm » November 10th, 2019, 3:23 pm

Besides Win10 has it built in the the Calculator now
Capture.JPG
You do not have the required permissions to view the files attached to this post.
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
balala
Rainmeter Sage
Posts: 9267
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Looking for a Unit Conversion tool

balala » November 10th, 2019, 7:20 pm

For instance the following code makes the conversion of the temperature. It converts both, from Celsius to Fahrenheit and from Fahrenheit to Celsius:

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
Solidcolor=0,0,0,150
SkinWidth=160
SkinHeight=100

[Variables]
TempScale=0
Temp=0
CheckStrokeColor=51,51,51
ButtonColor=80,80,80,150
ButtonStrokeColor=160,160,160
FontName=Segoe UI

[RadioButtonStyle]
Shape=Rectangle 0,0,14,14,7 | Extend RadioButtonModifiers
RadioButtonModifiers=Fill Color 255,255,255 | StrokeWidth 1 | Stroke Color #CheckStrokeColor#
DynamicVariables=1

[RadioButtonCheckStyle]
X=3r
Y=3r
Shape=Rectangle 0,0,8,8,4 | Extend RadioButtonModifiers
RadioButtonModifiers=Fill Color 51,51,51 | StrokeWidth 1 | Stroke Color 51,51,51
DynamicVariables=1
Hidden=1

[StringStyle]
FontColor=220,220,220
FontEffectColor=0,0,0
SolidColor=0,0,0,1
StringEffect=Shadow
FontFace=#FontName#
StringStyle=BOLD
AntiAlias=1
DynamicVariables=1

[MeasureScale]
Measure=Calc
Formula=#TempScale#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!ShowMeter "MeterRadioButtonCelsiusCheck"][!HideMeter "MeterRadioButtonFahrenheitCheck"][!SetOption MeterTemperature Text "#*Temp*#[\x00B0]C = %1[\x00B0]F"][!UpdateMeter "MeterTemperature"][!Redraw]
IfFalseAction=[!HideMeter "MeterRadioButtonCelsiusCheck"][!ShowMeter "MeterRadioButtonFahrenheitCheck"][!SetOption MeterTemperature Text "#*Temp*#[\x00B0]F = %1[\x00B0]C"][!UpdateMeter "MeterTemperature"][!Redraw]
DynamicVariables=1

[MeasureTemperature]
Measure=Calc
Formula=(( #TempScale# = 0 ) ? ( 1.8 * #Temp# + 32 ) : (( #Temp# - 32 ) / 1.8 ))
DynamicVariables=1

[MeterRadioButtonCelsius]
Meter=Shape
MeterStyle=RadioButtonStyle
X=5
Y=5
MouseOverAction=[!SetVariable CheckStrokeColor "0,120,215"][!SetOption #CURRENTSECTION#String InlineSetting "Underline"][!UpdateMeter "#CURRENTSECTION#"][!UpdateMeter "#CURRENTSECTION#String"][!Redraw]
MouseLeaveAction=[!SetVariable CheckStrokeColor "51,51,51"][!SetOption #CURRENTSECTION#String InlineSetting "None"][!UpdateMeter "#CURRENTSECTION#"][!UpdateMeter "#CURRENTSECTION#String"][!Redraw]
LeftMouseUpAction=[!SetVariable TempScale "0"][!SetVariable Temp "0"][!UpdateMeasure "MeasureScale"][!UpdateMeasure "MeasureTemperature"][!UpdateMeter "MeterTemperature"][!Redraw]

[MeterRadioButtonCelsiusCheck]
Meter=Shape
MeterStyle=RadioButtonCheckStyle

[MeterRadioButtonCelsiusString]
Meter=STRING
MeterStyle=StringStyle
X=16r
Y=-5r
W=90
H=18
ClipString=1
FontSize=10
StringAlign=LEFT
Text=[\x00B0]C -> [\x00B0]F
MouseOverAction=[!SetVariable CheckStrokeColor "0,120,215"][!SetOption #CURRENTSECTION# InlineSetting "Underline"][!UpdateMeter "MeterRadioButtonElapsedTime1"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetVariable CheckStrokeColor "51,51,51"][!SetOption #CURRENTSECTION# InlineSetting "None"][!UpdateMeter "MeterRadioButtonElapsedTime1"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
LeftMouseUpAction=[!SetVariable TempScale "0"][!SetVariable Temp "0"][!UpdateMeasure "MeasureScale"][!UpdateMeasure "MeasureTemperature"][!UpdateMeter "MeterTemperature"][!Redraw]

[MeterRadioButtonFahrenheit]
Meter=Shape
MeterStyle=RadioButtonStyle
X=-19r
Y=8R
MouseOverAction=[!SetVariable CheckStrokeColor "0,120,215"][!SetOption #CURRENTSECTION#String InlineSetting "Underline"][!UpdateMeter "#CURRENTSECTION#"][!UpdateMeter "#CURRENTSECTION#String"][!Redraw]
MouseLeaveAction=[!SetVariable CheckStrokeColor "51,51,51"][!SetOption #CURRENTSECTION#String InlineSetting "None"][!UpdateMeter "#CURRENTSECTION#"][!UpdateMeter "#CURRENTSECTION#String"][!Redraw]
LeftMouseUpAction=[!SetVariable TempScale "1"][!SetVariable Temp "32"][!UpdateMeasure "MeasureScale"][!UpdateMeasure "MeasureTemperature"][!UpdateMeter "MeterTemperature"][!Redraw]

[MeterRadioButtonFahrenheitCheck]
Meter=Shape
MeterStyle=RadioButtonCheckStyle

[MeterRadioButtonFahrenheitString]
Meter=STRING
MeterStyle=StringStyle
X=16r
Y=-5r
W=90
H=18
ClipString=1
FontSize=10
StringAlign=LEFT
Text=[\x00B0]F -> [\x00B0]C
MouseOverAction=[!SetVariable CheckStrokeColor "0,120,215"][!SetOption #CURRENTSECTION# InlineSetting "Underline"][!UpdateMeter "MeterRadioButtonElapsedTime1"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseLeaveAction=[!SetVariable CheckStrokeColor "51,51,51"][!SetOption #CURRENTSECTION# InlineSetting "None"][!UpdateMeter "MeterRadioButtonElapsedTime1"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
LeftMouseUpAction=[!SetVariable TempScale "1"][!SetVariable Temp "32"][!UpdateMeasure "MeasureScale"][!UpdateMeasure "MeasureTemperature"][!UpdateMeter "MeterTemperature"][!Redraw]

[MeasureInputTemperature]
Measure=Plugin
Plugin=InputText
SolidColor=229,241,251
StringAlign=LEFT
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,20
FontColor=0,0,0
FontFace=#FontName#
FontSize=10
X=10
Y=50
W=70
H=16
FocusDismiss=1
DefaultValue=#Temp#
InputNumber=1
Command1=[!SetVariable Temp "$UserInput$"]
UpdateDivider=86400
DynamicVariables=1

[MeterTemperature]
Meter=STRING
MeterStyle=StringStyle
MeasureName=MeasureTemperature
X=80
Y=64
Padding=15,5,15,5
FontSize=12
StringAlign=CENTER
LeftMouseUpAction=[!CommandMeasure MeasureInputTemperature "ExecuteBatch 1"]
GIF.gif
Please check this code and let me know what you think. If you find it appropriate, it can be further developed, to make the other conversions as well.
You do not have the required permissions to view the files attached to this post.
User avatar
Yamajac
Posts: 134
Joined: June 30th, 2014, 8:44 am

Re: Looking for a Unit Conversion tool

Yamajac » November 12th, 2019, 3:57 am

It wouldn't be hard to make this for any conversions you need, but a general purpose unit conversion skin would be far more hassle than it's worth.

You'd need one measure for each conversion you want, so it's not really hard on a per-conversion basis but it starts to get kinda crazy once you think about things like a teaspoon to a cup is one measure. A tablespoon to a cup is another measure. A teaspoon to a tablespoon is another one. Cup to teaspoon another, cup to tablespoon, tablespoon to teaspoon, foot to meter, foot to kilometer, foot to yard, mile to kilometer, kilometer to mile, celcius to fahrenheit, fahrenheit to celcius, pound to kilogram. Kilogram to gram. Gram to pound. Pound to stone. The list goes on. Where do you stop?


Now, I suppose you *could* implement some kinda smart system that would convert cup -> tablespoon -> teaspoon for cup -> teaspoon preventing the need for one measure there but I doubt that would be less work than just hardcoding each one.


Then you have to have the meters/measures responsible for controlling the inputs/outputs and determining which measure you need to interact with to get the information out of it..
User avatar
balala
Rainmeter Sage
Posts: 9267
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Looking for a Unit Conversion tool

balala » November 12th, 2019, 7:37 am

Yamajac wrote:
November 12th, 2019, 3:57 am
You'd need one measure for each conversion you want, so it's not really hard on a per-conversion basis but it starts to get kinda crazy once you think about things like a teaspoon to a cup is one measure. A tablespoon to a cup is another measure. A teaspoon to a tablespoon is another one. Cup to teaspoon another, cup to tablespoon, tablespoon to teaspoon, foot to meter, foot to kilometer, foot to yard, mile to kilometer, kilometer to mile, celcius to fahrenheit, fahrenheit to celcius, pound to kilogram. Kilogram to gram. Gram to pound. Pound to stone. The list goes on. Where do you stop?
Yes, this way the list can go infinite, but initially CoffeeJoe has asked just for:
CoffeeJoe wrote:
November 10th, 2019, 1:13 pm
  • Enter degrees in Celsius and it displays the value in Fahrenheit
  • Enter the weight in Metric and it returns the Imperial value
  • Enter Tbsp. and it'll tell me how many tsp. that is.
And such a small list can be handled easily even through a Rainmeter code.
User avatar
Yamajac
Posts: 134
Joined: June 30th, 2014, 8:44 am

Re: Looking for a Unit Conversion tool

Yamajac » November 12th, 2019, 8:05 am

balala wrote:
November 12th, 2019, 7:37 am
Yes, this way the list can go infinite, but initially CoffeeJoe has asked just for: And such a small list can be handled easily even through a Rainmeter code.
Well I sincerely doubt OP is only after Celsius -> Fahrenheit, Kilograms -> Pounds and Tablespoons -> Teaspoons. My understanding is they want an all purpose unit conversion skin.
User avatar
balala
Rainmeter Sage
Posts: 9267
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Looking for a Unit Conversion tool

balala » November 12th, 2019, 11:34 am

Yamajac wrote:
November 12th, 2019, 8:05 am
Well I sincerely doubt OP is only after Celsius -> Fahrenheit, Kilograms -> Pounds and Tablespoons -> Teaspoons. My understanding is they want an all purpose unit conversion skin.
His request specifically was just about these three. Obviously as more conversions are needed, as more complicated the skin becomes.
User avatar
Yamajac
Posts: 134
Joined: June 30th, 2014, 8:44 am

Re: Looking for a Unit Conversion tool

Yamajac » November 13th, 2019, 2:06 am

jsmorley wrote:
November 10th, 2019, 1:23 pm
I don't think I have seen a Rainmeter skin that does this, mostly because there are so many thousands of things you can convert between, you would need just boatloads of keywords and formulas. The effort seems to fit a bad cost/benefit curve in my view, since it is just so easy to say "5 tablespoons to teaspoons", or any other unit conversion question, in your browser URL, and Google will pretty much instantly tell you the answer.



1.jpg



I mean, each individual one would be trivial to do, but the aggregate would be the Bataan Death March.

https://www.convertworld.com/en/
Googling was a good idea.

Code can be found here


Not sure if this is very helpful to you OP, but hey, I made it and it works so there you go.
User avatar
CoffeeJoe
Posts: 17
Joined: November 6th, 2019, 4:19 am

Re: Looking for a Unit Conversion tool

CoffeeJoe » November 13th, 2019, 2:58 am

Balala's solution is exactly what I was looking for, I want to understand how I can enter data and have a skin run a calculation or a lookup on that data and return a result. I don't expect you guys to be my personal coders, and I wasn't expecting anyone to write an example (its exactly what I was looking for), I was more thinking if anyone had ever created a unit converter it would have all the moving pieces I want to see in action.

The google-it answer was inspired even though it doesn't work for me. It reminds me of the "LMGTFY" https://lmgtfy.com/ we used to use long ago.

Thanks guys