It is currently April 17th, 2021, 2:07 am

TimerNixie

Clocks and timer skins
User avatar
jsmorley
Developer
Posts: 21635
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

TimerNixie

Post by jsmorley »

A countdown / timer skin that will count down some number of hours, minutes and / or seconds and execute some action. Currently it is set to play an alarm sound when the timer expires, but this can be changed to any bangs or commands you want.

Note that this is based on actual elapsed time, not just counting skin updates.
TimerNixie_1.1.rmskin
GIF.gif
Timer.ini:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
RightMouseUpAction=[!SkinCustomMenu]
ContextTitle=Start Timer
ContextAction=[!EnableMeasureGroup Timers][!UpdateMeasureGroup Timers]
ContextTitle2=Stop Timer
ContextAction2=[!Refresh]
ContextTitle3=----
ContextAction3=[]
ContextTitle4=Edit Time Values
ContextAction4=["#CURRENTPATH#TimeSettings.inc"]
ContextTitle5=----
ContextAction5=[]
ContextTitle6=More actions ...
ContextAction6=[!SkinMenu]
LeftMouseUpAction=[PlayStop][!Refresh]

[Variables]
@Include=TimeSettings.inc
ActionToTake=[PlayLoop "#@#Sounds\Alarm.wav"]

[MeasureNow]
Measure=Time
Group=Timers
UpdateDivider=-1
Disabled=1

[MeasureTotalSeconds]
Measure=Calc
Group=Timers
Formula=(#TimerHours# * 3600) + (#TimerMinutes# * 60) + #TimerSeconds#
UpdateDivider=-1
Disabled=1

[MeasureTarget]
Measure=Time
Group=Timers
Format=%#m/%#d/%Y %#H:%M:%S
TimeStamp=([MeasureNow:TimeStamp] + [MeasureTotalSeconds])
UpdateDivider=1
Disabled=1
DynamicVariables=1
OnUpdateAction=[!SetVariable Target "[MeasureTarget]"][!UpdateMeasure MeasureLua]

[MeasureLua]
Measure=Script
Group=Timers
ScriptFile=#CURRENTPATH#Timer.lua
IfCondition=MeasureLua <= 0
IfTrueAction=#ActionToTake#
Disabled=1

[MeasureHours]
Measure=Calc
Formula=#TimerHours#
[MeasureMinutes]
Measure=Calc
Formula=#TimerMinutes#
[MeasureSeconds]
Measure=Calc
Formula=#TimerSeconds#

[MeterBack]
Meter=Shape
Shape=Rectangle 0.75,0.75,291,98,12 | StrokeWidth 1.5 | Stroke Color 150,150,150,255 | Fill Color 0,0,0,255

[MeterHours]
Meter=Bitmap
MeasureName=MeasureHours
X=10
Y=10
BitmapImage=#@#Nixie\digits60.png
BitmapFrames=10
BitmapExtend=1
BitmapDigits=2

[MeterMinutes]
Meter=Bitmap
MeasureName=MeasureMinutes
X=105
Y=10
BitmapImage=#@#Nixie\digits60.png
BitmapFrames=10
BitmapExtend=1
BitmapDigits=2

[MeterSeconds]
Meter=Bitmap
MeasureName=MeasureSeconds
X=201
Y=10
BitmapImage=#@#Nixie\digits60.png
BitmapFrames=10
BitmapExtend=1
BitmapDigits=2

[MeterHoursText]
Meter=String
X=30
Y=70
FontSize=9
FontColor=255,228,110,255
FontWeight=400
AntiAlias=1
Text=HOURS

[MeterMinutesText]
Meter=String
X=119
Y=70
FontSize=9
FontColor=255,228,110,255
FontWeight=400
AntiAlias=1
Text=MINUTES

[MeterSecondsText]
Meter=String
X=211
Y=70
FontSize=9
FontColor=255,228,110,255
FontWeight=400
AntiAlias=1
Text=SECONDS
Timer.lua:

Code: Select all

function Update()

	targetString = SKIN:GetVariable('Target')

	timeTarget = TimeStamp(targetString)
	timeNow = os.time(os.date('*t'))
	
	countDown = os.difftime(timeTarget, timeNow)

	if countDown < 0 then countDown = 0 end
	weeks, days, hours, minutes, seconds = FormatSeconds(countDown)	
	
	SKIN:Bang('!SetOption', 'MeasureHours', 'Formula', hours)
	SKIN:Bang('!SetOption', 'MeasureMinutes', 'Formula', minutes)
	SKIN:Bang('!SetOption', 'MeasureSeconds', 'Formula', seconds)
	
	return(countDown)

end

function TimeStamp(targetString)
   
   -- date format: 7/26/2017 8:32:10

   month, day, year, hour, min, sec =
   string.match(targetString, "(%d+)/(%d+)/(%d+) (%d+):(%d+):(%d+)")
	
	currentTimeTable = os.date()
	currentDST = currentTimeTable['isdst']
	
   timeStamp = os.time({year=year, month=month, day=day, hour=hour, min=min, sec=sec, isdst=currentDST})
   
   return timeStamp

end

function FormatSeconds(secondsArg)

	weeks = math.floor(secondsArg / 604800)
	remainder = secondsArg % 604800
	days = math.floor(remainder / 86400)
	remainder = remainder % 86400
	hours = math.floor(remainder / 3600)
	remainder = remainder % 3600
	minutes = math.floor(remainder / 60)
	seconds = remainder % 60
	
	return weeks, days, hours, minutes, seconds
	
end
Usage:

Set the amount of time in TimeSettings.inc. This can be accessed by right-clicking the skin.

Code: Select all

[Variables]
TimerHours=0
TimerMinutes=0
TimerSeconds=20
Right click the skin to start and stop the timer. When the timer has expired, simply click the skin to reset.
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 21635
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: TimerNixie

Post by jsmorley »

Edit: Moved the time settings in [Variables] into a TimeSettings.inc file, and added a context menu item to edit this file.
1.jpg
Latest .rmskin in the first post of this thread.
You do not have the required permissions to view the files attached to this post.
wice
Posts: 1
Joined: August 28th, 2017, 5:02 pm

Re: TimerNixie

Post by wice »

Hi there,

Can I modify it somehow to perform 2 actions

start after countdown is over from the begining
and play a sound just ones

Regrads