It is currently May 7th, 2024, 10:02 pm

Converting UpTime into Bar Graphs

Get help with creating, editing & fixing problems with skins
Peach
Posts: 2
Joined: January 16th, 2011, 5:29 pm

Converting UpTime into Bar Graphs

Post by Peach »

In all, what I'd like to do is have four bars. One is for days, one for hours, one for minutes, and one for seconds.

Seconds goes to 60, minutes to 60, hours to 24, days to a set amount (say 100? I don't think I'll leave my computer for that long).

I've only just started working with Rainmeter, but I thought this would be a bit simple. However, I've come across some issues.

First off, here's the code

Code: Select all

[Rainmeter]
DynamicWindowSize=1
Update=1000
MiddleMouseDownAction=!RainmeterRefresh #CURRENTCONFIG#

[MeasureUpTime]
Measure=UpTime
Format="%4!i! Days, %3!i! Hours, %2!i! Minutes %1!i! Seconds"

[MeasureUpSec]
Measure=UpTime
Format="%1!i!"
MinValue=0
MaxValue=60

[MeterUpTime]
Meter=String
MeasureName=MeasureUpTime
X=0
Y=0
FontSize=15
FontColor=255,255,255,255
AntiAlias=1
Text=System UpTime: %1

[MeterUpSec]
Meter=String
MeasureName=MeasureUpSec
X=0
Y=25
FontSize=15
FontColor=255,255,255,255
AntiAlias=1
Text=System UpTime Seconds: %1

[ProgressBar]
MeasureName=MeasureUpSec
Meter=BAR
BarColor=255,255,255,255
SolidColor=105,37,6,150
y=50
x=50
W=100
H=20
BarOrientation=HORIZONTAL
It properly displays this:
System UpTime: a days, b hours, x minutes y seconds
System UpTime seconds: y seconds

But then displays a Bar graph, completely white (full).
All I want it to do is be seconds/60 and create a graph like that. I can't seem to find how to do that, though :(
Would anybody be able to shed some light on this? I can't find why it's not working.
Thanks in advance :)
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Converting UpTime into Bar Graphs

Post by jsmorley »

Seems like "UpTime" is returning a string and not a real number, so I had to do:

[MeasureUpSec]
Measure=UpTime
Format="%1!i!"

[MeasureBarCalc]
Measure=Calc
Formula=[MeasureUpSec]
DynamicVariables=1
MinValue=0
MaxValue=60

[ProgressBar]
Meter=BAR
MeasureName=MeasureBarCalc
BarColor=255,255,255,255
SolidColor=105,37,6,150
Y=50
X=50
W=100
H=20
BarOrientation=HORIZONTAL

And then it worked fine. Running a string "number" through a Calc measure turns it into a real number...

So you could do something like this. Note the extra bit on the "hours" calc, as Rainmeter automatically adds "days" expressed as "hours" to hours if days is not specifically asked for. The "& 24" is a bitwise AND which blows away the extra hours for days or percentage of a day in the result.

Code: Select all

[Rainmeter]
DynamicWindowSize=1
Update=1000
MiddleMouseUpAction=!RainmeterRefresh #CURRENTCONFIG#

;[MEASURES]==========================================

[MeasureUpDay]
Measure=UpTime
Format="%4!i!"

[MeasureDayCalc]
Measure=Calc
Formula=[MeasureUpDay]
DynamicVariables=1
MinValue=0
MaxValue=30

[MeasureUpHour]
Measure=UpTime
Format="%3!i!"

[MeasureHourCalc]
Measure=Calc
Formula=([MeasureUpHour] & 24)
DynamicVariables=1
MinValue=0
MaxValue=24

[MeasureUpMin]
Measure=UpTime
Format="%2!i!"

[MeasureMinCalc]
Measure=Calc
Formula=[MeasureUpMin]
DynamicVariables=1
MinValue=0
MaxValue=60

[MeasureUpSec]
Measure=UpTime
Format="%1!i!"

[MeasureSecCalc]
Measure=Calc
Formula=[MeasureUpSec]
DynamicVariables=1
MinValue=0
MaxValue=60

;[METERS]============================================

[MeterDayBar]
Meter=BAR
MeasureName=MeasureDayCalc
BarColor=255,255,255,255
SolidColor=150,150,150,255
X=0
Y=0
W=100
H=20
BarOrientation=HORIZONTAL

[MeterDayText]
Meter=String
MeasureName=MeasureDayCalc
X=0
Y=4
FontSize=9
FontColor=0,0,0,255
AntiAlias=1
Text=Days: %1

[MeterHourBar]
Meter=BAR
MeasureName=MeasureHourCalc
BarColor=255,255,255,255
SolidColor=150,150,150,255
X=100
Y=0
W=100
H=20
BarOrientation=HORIZONTAL

[MeterHourText]
Meter=String
MeasureName=MeasureHourCalc
X=100
Y=4
FontSize=9
FontColor=0,0,0,255
AntiAlias=1
Text=Hours: %1

[MeterMinBar]
Meter=BAR
MeasureName=MeasureMinCalc
BarColor=255,255,255,255
SolidColor=150,150,150,255
X=200
Y=0
W=200
H=20
BarOrientation=HORIZONTAL

[MeterMinText]
Meter=String
MeasureName=MeasureMinCalc
X=200
Y=4
FontSize=9
FontColor=0,0,0,255
AntiAlias=1
Text=Minutes: %1

[MeterSecBar]
Meter=BAR
MeasureName=MeasureSecCalc
BarColor=255,255,255,255
SolidColor=150,150,150,255
X=300
Y=0
W=100
H=20
BarOrientation=HORIZONTAL

[MeterSecText]
Meter=String
MeasureName=MeasureSecCalc
X=300
Y=4
FontSize=9
FontColor=0,0,0,255
AntiAlias=1
Text=Seconds: %1
1-16-2011 9-29-16 PM.png
I'll let you take it from here and customize and purty up as you see fit... I set the MAXVALUE for Days as 30, but really you should probably have it be 365, then add "Years", "Decades", "Centuries", "Millennium", and "Exaseconds", then bury your computer in a time capsule under Mt. Everest.

:-)
You do not have the required permissions to view the files attached to this post.
Peach
Posts: 2
Joined: January 16th, 2011, 5:29 pm

Re: Converting UpTime into Bar Graphs

Post by Peach »

Ahh, makes sense. I actually did try doing that, but didn't know how to go about it exactly.

And if anyone ever reads this, the 'minutes' bar is off because width is set to 200 instead of 100. I just set that to 100 and it matches the rest of the bars.

Thanks a lot :)
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Converting UpTime into Bar Graphs

Post by jsmorley »

There is always some typo when I rush. ;-)

Glad to help, have fun.
User avatar
Alex2539
Rainmeter Sage
Posts: 642
Joined: July 19th, 2009, 5:59 am
Location: Montreal, QC, Canada

Re: Converting UpTime into Bar Graphs

Post by Alex2539 »

One small adjustment, change [MeasureHourCalc] to this:

Code: Select all

[MeasureHourCalc]
Measure=Calc
Formula=([MeasureUpHour] % 24)
DynamicVariables=1
MinValue=0
MaxValue=24
If you're trying to limit the hours to a 24-hour cycle, you want to use % not &. The % sign is the modulus operator, which means that it divides the number by 24, then uses the remainder as the result. For example, 26 % 24 = 2 because 26 /24 = 1 remainder 2. This means that you will always have the hour of the current day, without the multiples of 24 that depict how many days have gone by.

The & sign is the bitwise-and operator, which means that it takes the binary of both numbers, compares the bits, and returns a number with the bits where both of the original numbers match are 1. For example, 26 & 24 would convert the numbers to 11010 and 11000, then compare them, keeping only the bits that are 1 in both cases: 11000 which is 24. By using this, the only possible numbers are 0, 8, 16 and 24.
ImageImageImageImage
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Converting UpTime into Bar Graphs

Post by jsmorley »

Ah, thanks Alex. I started with % and then changed it for some reason. I just wasn't thinking it through.