Code covered by the BSD License  

Highlights from
ALARM

4.5

4.5 | 2 ratings Rate this file 9 Downloads (last 30 days) File Size: 4.02 KB File ID: #9018
image thumbnail

ALARM

by Jiro Doke

 

12 Nov 2005 (Updated 06 Jun 2008)

An alarm function that displays a dialog box after a set length of time.

| Watch this File

File Information
Description

ALARM Displays an alarm message after a set time.

ALARM(T, MSG) displays a message after T seconds with a text message MSG. After T seconds, the computer will start beeping and display a dialog box with an option to Snooze. The beeping will stop after one minute or when the dialog box is closed. The snooze interval is 5 minutes and up to 10 snoozes are allowed. These values can be changed by ALARM(T, MSG, PROP, VAL, ...) where PROP can be one of the two:

 'SnoozeInt' : snooze interval in seconds (default: 300)
 'SnoozeCount' : number of maximum snoozes (default: 10)

T can also be a string of a specific time for the alarm. The string may be any of the following formats:
  HH:MM, HH:MM:SS, HH:MM PM, HH:MM:SS PM.
If the date is specified, it is ignored. The alarm will go off at the next possible HH:MM:SS.

The dialog box is a QUESTDLG, which means that all execution will be halted until the user selects one of the buttons.

ALARM by itself will list all active alarms. It will display whether the alarm has not yet gone off (pending) or has been snoozed, the time til the next alarm, and the alarm message.

ALARM('-delete') will display the active alarms and give the option of deleting any of the alarms.

When an ALARM is initially defined, it can return the number of seconds before it will go off. Use semicolon to suppress this output.

This code uses a timer object, and it will delete itself once the alarm is turned off. Note that the timer can be deleted. When MATLAB closes, it will also be deleted and will NOT be restored at the next session. The purpose of this code is for a simple time reminder function for those long coding sessions one might have.

Example:
  % alarm in 60 seconds
  alarm(60, 'You can stop waiting now');

  % alarm at 9 PM
  alarm('9:00 PM', 'It''s 9 PM!!');

  % snooze time of 3 minutes for a max of 5 snoozes
  alarm(120, 'Hello!', 'SnoozeInt', 180, 'SnoozeCount', 5);

Acknowledgements
This submission has inspired the following:
Send Timed Alerts Over Email
MATLAB release MATLAB 7.0.4 (R14SP2)
Other requirements Tested in R2008a
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
14 Nov 2005 Jiro Doke

A new version will be posted in a couple of days, or you can download from
http://www-personal.umich.edu/~jdokeh/my_mfiles.html

This version adds the option of viewing and deleting active alarms.

02 Dec 2005 Pramud Rawat

Very nice. Would be absolutely perfect if the alarm could be set to clock time.

24 Jul 2007 wag tsio  
Please login to add a comment or rating.
Updates
15 Nov 2005

1. Added option to view and delete active alarms.

2. Added 1-min beeping until dialog box is closed. This behaves more like an alarm clock.

07 Dec 2005

Added option to set alarm to clock time. (per request)

06 Jun 2008

Minor bug fixes and added examples in the help.

Tag Activity for this File
Tag Applied By Date/Time
clock Jiro Doke 22 Oct 2008 08:06:11
fun Jiro Doke 22 Oct 2008 08:06:11
alarm Jiro Doke 22 Oct 2008 08:06:11
timer Jiro Doke 22 Oct 2008 08:06:11
reminder Jiro Doke 22 Oct 2008 08:06:11
beep Jiro Doke 22 Oct 2008 08:06:11
counter Jiro Doke 22 Oct 2008 08:06:11

Contact us at files@mathworks.com