It is currently March 28th, 2024, 5:43 pm

Timer

General topics related to Rainmeter.
Post Reply
memenomentomori
Posts: 2
Joined: December 19th, 2016, 7:57 am

Timer

Post by memenomentomori »

Hi i just want to create countdown timer using a bar horizontally, is it possible that the every time the seconds decreases the bar horizontally increment by 1? Assuming that my birthday is December 25. Thank you. :confused: :confused:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Timer

Post by balala »

memenomentomori wrote:Hi i just want to create countdown timer using a bar horizontally, is it possible that the every time the seconds decreases the bar horizontally increment by 1? Assuming that my birthday is December 25. Thank you. :confused: :confused:
Although this sounds as it would be a skin request, which is not allowed here, I'll give you a simple code, to can start.
In the following code, add to the Year, Month and Day variables the values of the date which is "your birthday". The skin will count up to midnight of that day. The [MeasureDifStart] is never updated, while the skin runs "normally" and isn't refreshed. It is used to get the largest value of the difference between the current moment and the date you've entered above, as the Year, Month and Day variables. We need this largest value, to can crate the [MeterTimeLeft] Bar meter (the measure used into its code, must return percentual values, so we have to set its MinValue and MaxValue options).

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Year=2017
Month=12
Day=25

[MeasureTime]
Measure=Time

[MeasureDate]
Measure=Time
TimeStamp=#Year#-#Month#-#Day#
TimeStampFormat=%Y-%m-%d

[MeasureDif]
Measure=Calc
Formula=( MeasureDifStart - [MeasureDate:] + [MeasureTime:] )
MinValue=0
MaxValue=[MeasureDifStart]
DynamicVariables=1

[MeasureDifStart]
Measure=Calc
Formula=( [MeasureDate:] - [MeasureTime:] )
DynamicVariables=1
UpdateDivider=-1

[MeterTimeLeft]
MeasureName=MeasureDif
Meter=BAR
X=0
Y=0
W=200
H=30
BarColor=185,250,0
SolidColor=150,150,150,150
BarOrientation=Horizontal
Please check this code and let me know if this is what you wanted.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Timer

Post by jsmorley »

This entire thing seems like odd logic to me.

There are currently over seven billion seconds until Christmas, so the percentual value of the difference between now and then in seconds when you start the skin is like 0.0001. That percentage is going to tick up at glacial speeds. So nothing will display in the Bar meter, and won't for a long time.I don't know how long before this percentage will result in even 1 pixel of Bar value, but not for a while I suspect.

Also, be aware than any time you restart your computer or refresh the skin, this will start over from scratch with the percentage at zero.

I could see some logic in counting "up" and using a Bar meter, where you start with figuring out how many seconds there are in 2017, which will be 30,931,200, and then determine the percentage of time left in this year until Christmas, but counting "down" doesn't seem like a good fit for a Bar meter to me. Down to what? Define "now". The counting "down" logic will always be based on a arbitrary definition of "now" that really has no valid meaning.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Timer

Post by jsmorley »

So perhaps something like:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Year=2017
Month=12
Day=25

[MeasureTime]
Measure=Time

[MeasureDate]
Measure=Time
TimeStamp=#Year#-#Month#-#Day#
TimeStampFormat=%Y-%m-%d

[MeasureThisYear]
Measure=Time
TimeStamp=2017-1-1
TimeStampFormat=%Y-%m-%d
UpdateDivider=-1

[MeasureTotalSeconds]
Measure=Calc
Formula=([MeasureDate:Timestamp] - [MeasureThisYear:Timestamp])
DynamicVariables=1

[MeasureDif]
Measure=Calc
Formula=([MeasureDate:Timestamp] - [MeasureTime:Timestamp])
MinValue=0
MaxValue=[MeasureTotalSeconds:]
DynamicVariables=1

[MeterTimeLeft]
MeasureName=MeasureDif
Meter=BAR
X=0
Y=0
W=200
H=30
BarColor=100,219,70,255
SolidColor=219,70,70,255
BarOrientation=Horizontal
Flip=1

[MeterPercentageComplete]
Meter=String
Y=10R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=[&MeasureDif:%,10] Percent of year left until Christmas
DynamicVariables=1
1.png
The green "shopping seconds left!" will slowly decrease until December 25th is reached.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Timer

Post by balala »

jsmorley wrote:There are currently over seven billion seconds until Christmas, so the percentual value of the difference between now and then in seconds when you start the skin is like 0.0001. That percentage is going to tick up at glacial speeds. So nothing will display in the Bar meter, and won't for a long time.I don't know how long before this percentage will result in even 1 pixel of Bar value, but not for a while I suspect.
Yes, you're perfectly right. I also thought to this detail, but finally I wrote my code (which I think is somehow similar with yours) in accord to memenomentomori's initial request.
But to be a bit precise: there are around 7,084,800 seconds until Christmas. Not seven billions. But this is just a detail, one percent of this amount of seconds, when the bar will start to indicate something, will pass around tomorrow. Not too efficient, but the Bar meter will indicate something after a day. Maybe there would be a good idea to increase the Update value of the skin, up to Update=10000, to get one update per ten seconds, or even more. I know you're not too happy with a such Update value, I remember I read once something about this a while ago, but I think in this case a such Update would be completely justified.
jsmorley wrote:Also, be aware than any time you restart your computer or refresh the skin, this will start over from scratch with the percentage at zero.
Yes, this definitely is a problem.
User avatar
limitless
Posts: 76
Joined: January 8th, 2017, 2:31 am
Location: Charlotte, NC
Contact:

Re: Timer

Post by limitless »

You would have to write the values to a ini file each time they are changed. And the Percentages would need to be read from the ini file variables.

So, each time you restart your computer or close rainmeter, it's always the correct data.

It would have to be a little longer than each second though. That would be hell for your computer.

This is doable. I think.

But it would require alot of work to do that.
Post Reply