It is currently April 26th, 2024, 2:54 pm

Display image based on sunrise / sunset measures

Get help with creating, editing & fixing problems with skins
User avatar
xenium
Posts: 867
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote:Yes, but in this case all measures have to be rewritten. Do you know how to do this?
No need to rewrite the code!
I kept all the code for the 24-hour format.
I added the 12-hour link.
I added [MeasureSunrise12H] and [MeasureSunset12H]
We have modified [MeterSunrise] and [MeterSunset] to display in 12-hour format
And that's it... :D
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:No need to rewrite the code!
I kept all the code for the 24-hour format.
I added the 12-hour link.
I added [MeasureSunrise12H] and [MeasureSunset12H]
We have modified [MeterSunrise] and [MeterSunset] to display in 12-hour format
And that's it... :D
Ok, in this case. Glad you got it working.
User avatar
xenium
Posts: 867
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

Hello again :D
I found a code that counts the time left until sunset and sunrise.
I tried to adapt it to my code but it does not work.
What is wrong ?

Code: Select all

[MeasureCurrent]
Measure=Calc
Formula=(60 * MeasureHour + MeasureMin)

[MeasureToSunrise]
Measure=Calc
Formula=(MeasureSunriseMoment - MeasureCurrent)

[MeasureToSunset]
Measure=Calc
Formula=(MeasureSunsetMoment - MeasureCurrent)
IfCondition=MeasureToSunset > 0
IfTrueAction=[!SetVariable "upordown" "sunset"]
IfFalseAction=[!SetVariable "upordown" "sunrise"]
DynamicVariables=1

[MeasureLeft]
Measure=Calc
Formula=(((MeasureToSunrise < 0) && (MeasureToSunset < 0)) ? ( 1440 + MeasureToSunrise ) : (((MeasureToSunrise < 0) && (MeasureToSunset > 0)) ? MeasureToSunset : MeasureToSunrise))

[MeasureLeftHours]
Measure=Calc
Formula=(Floor(MeasureLeft / 60))
IfCondition=MeasureLeftHours > 1
IfTrueAction=[!SetVariable "hour" "[MeasureLeftHours] hrs"]
IfFalseAction=[!SetVariable "hour" "[MeasureLeftHours] hr"]
IfConditionMode=1 

[MeasureLeftMin]
Measure=Calc
Formula=(MeasureLeft - 60 * MeasureLeftHours)
IfCondition=(MeasureLeftMin > 1)
IfTrueAction=[!SetVariable "min" "[MeasureLeftMin] mins"]
IfFalseAction=[!SetVariable "min" "[MeasureLeftMin] min"]
IfConditionMode=1 ]

[MeterHoursRem]
Meter=String
MeasureName=MeasureLeftHours
MeasureName2=MeasureLeftMin
FontColor=255,255,255,255
FontFace=arial
FontSize=10
AntiAlias=1
ClipString=1
StringAlign=center
X=100
Y=250
Text=#hour# #min# #CRLF# until #upordown#
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:Hello again :D
I found a code that counts the time left until sunset and sunrise.
I tried to adapt it to my code but it does not work.
What is wrong ?
Nothing. Does work for me.
One small thing I had to adjust. In the Formula option of the [MeasureCurrent] measure, I replaced the MeasureMin measure name with MeasureMinute (I have this measure name):

Code: Select all

[MeasureCurrent]
Measure=Calc
Formula=( 60 * MeasureHour + MeasureMinute )
Check your code, to see how that measure is named.
After this adjustment, the [MeasureToSunrise] and [MeasureToSunset] measures are returning the number of minutes to the sunrise and sunset of today (after sunrise, the [MeasureToSunrise] measure returns a negative number, which is perfectly ok - today's sunrise already has passed).
The [MeasureLeft] measure are returning the number of minutes up to the appropriate moment (sunrise or sunset, which is the next one).
Finally the [MeasureLeftHours] and [MeasureLeftMin] measures are returning the number of left hours and minutes respectively. The hour and min variables are set up by the IfTrueAction and IfFalseAction options of these two measures. Here again one small error I found: there is an extra bracket after the IfConditionMode=1 option of the [MeasureLeftMin] measure.
Additionally just mention that I think those IfConditionMode=1 options are useless. I'd remove them.

If you can't get it to work properly, please post again the whole code.
User avatar
xenium
Posts: 867
Joined: January 4th, 2018, 9:52 pm

Re: Display image based on sunrise / sunset measures

Post by xenium »

balala wrote:Nothing. Does work for me.
One small thing I had to adjust. In the Formula option of the [MeasureCurrent] measure, I replaced the MeasureMin measure name with MeasureMinute (I have this measure name):

Code: Select all

[MeasureCurrent]
Measure=Calc
Formula=( 60 * MeasureHour + MeasureMinute )
Check your code, to see how that measure is named.
After this adjustment, the [MeasureToSunrise] and [MeasureToSunset] measures are returning the number of minutes to the sunrise and sunset of today (after sunrise, the [MeasureToSunrise] measure returns a negative number, which is perfectly ok - today's sunrise already has passed).
The [MeasureLeft] measure are returning the number of minutes up to the appropriate moment (sunrise or sunset, which is the next one).
Finally the [MeasureLeftHours] and [MeasureLeftMin] measures are returning the number of left hours and minutes respectively. The hour and min variables are set up by the IfTrueAction and IfFalseAction options of these two measures. Here again one small error I found: there is an extra bracket after the IfConditionMode=1 option of the [MeasureLeftMin] measure.
Additionally just mention that I think those IfConditionMode=1 options are useless. I'd remove them.

If you can't get it to work properly, please post again the whole code.
Now it is working! :17good
The problem was indeed [MeasureMin] instead of [MeasureMinute].
If i remove the IfConditionMode=1, it does not display the proper time.
Shows the time until 24:00, time that changes only when refresh.
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

xenium wrote:If i remove the IfConditionMode=1, it does not display the proper time.
Shows the time until 24:00, time that changes only when refresh.
Ok, in this case keep that option.
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Display image based on sunrise / sunset measures

Post by Mordasius »

xenium wrote:If i remove the IfConditionMode=1, it does not display the proper time.
Shows the time until 24:00, time that changes only when refresh.
I think the 24 hour clock only goes up until 23:59:59 after which it becomes 00:00:00. To automatically refresh a skin when the date changes you can use something like.

Code: Select all

[MeasureIsItAnewDay]
Measure=Time
Format=%A %d %B
OnChangeAction=[!Refresh]
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

Mordasius wrote:To automatically refresh a skin when the date changes you can use something like.

Code: Select all

[MeasureIsItAnewDay]
Measure=Time
Format=%A %d %B
OnChangeAction=[!Refresh]
Not sure this is a good approach. Although it definitely can be used, the refresh is a "big gun" (to quote jsmorley): https://forum.rainmeter.net/viewtopic.php?p=119966#p119966
I always try to avoid skin refresh, as much as possible.
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Display image based on sunrise / sunset measures

Post by Mordasius »

balala wrote:Not sure this is a good approach. Although it definitely can be used, the refresh is a "big gun" .. I always try to avoid skin refresh, as much as possible.
Sorry balala I may have grabbed the wrong end of the stick but how can you consider a measure that refreshes a skin once every 24 hours at a time when most normal people are deep in the land of nod to be a "big gun"? IMHO it is the most effective and sure-fire way of keeping skins that track things like sunrise, moonrise, Islamic prayer times, daily horoscopes, etc. current and up to date for those of us that routinely stay on our computers after midnight. Sure, one might be best to avoid !Refresh on skins that are updating once a second ... but I don't see how a !Refresh bang triggered once a day at midnight has a big impact on the grander scheme of things.
:-) :)
User avatar
balala
Rainmeter Sage
Posts: 16173
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Display image based on sunrise / sunset measures

Post by balala »

Mordasius wrote:how can you consider a measure that refreshes a skin once every 24 hours at a time when most normal people are deep in the land of nod to be a "big gun"? IMHO it is the most effective and sure-fire way of keeping skins that track things like sunrise, moonrise, Islamic prayer times, daily horoscopes, etc. current and up to date for those of us that routinely stay on our computers after midnight. Sure, one might be best to avoid !Refresh on skins that are updating once a second ... but I don't see how a !Refresh bang triggered once a day at midnight has a big impact on the grander scheme of things.
Don't misunderstand me, I don't say refresh couldn't be done, sometimes it indeed is unavoidable, other times it is avoidable, but better to be however used. But in this case I think it is not needed, nor even once per day.
On the other hand I didn't say your measure would be a big gun. It was just a quote of what jsmorley said, generally about the refresh.
But as usual everyone is free to choose the best solution for his needs. If someone shuts down his computer every evening (before midnight) when he turns it on again, the skin is anyway refreshed (or better say reloaded) so this has no importance. But I almost never shut down my computer (I'm usually just hibernating it over night). This would mean every day a refresh is done.
Again: I don't contest a such solution, probably it is good enough, but me personally just don't like it. Sorry...