home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-04-14 | 32.8 KB | 1,610 lines |
- {
- ══════════════════════════════════════════════════════════════════════════════
-
- Visionix RealTime Alarm Clock Functions Unit (VALARM)
- Copyright 1991,92,93 Visionix
- ALL RIGHTS RESERVED
-
- ──────────────────────────────────────────────────────────────────────────────
-
- Revision history in reverse chronological order:
-
- Initials Date Comment
- ──────── ──────── ──────────────────────────────────────────────────────────
-
- lpg 03/11/93 Source Code Documentation Complete
-
- mep 02/11/93 Cleaned up code for beta release
-
- jrt 02/08/93 Sync with beta 0.12 release
-
- jrt 12/07/92 Sync with beta 0.11 release
-
- lpg 12/04/92 Everything functional and tested. (works except CallFlag)
-
- lpg 12/02/92 Added RealTime Clock System Time Functions.
- Get/SetSysTime,Get/SetSysDate,SystemTime/Date,
- Sync,SyncSystemTime/Date,Get/SetDayLightSavings
-
- lpg 11/30/92 Created Alarm Unit
-
- ══════════════════════════════════════════════════════════════════════════════
-
- Caveats/Known Bugs
-
- Register C - Alarm Call Flag is Invalid. Seems to only be briefly
- set between interrupts. Need to keep own flags to cover for this.
-
- AFFECTS: AlarmCallFlag, UnsetAlarmCallFlag.
-
-
-
- ══════════════════════════════════════════════════════════════════════════════
- }
-
- (*-
-
- NOTES on the RTC Registers:
-
- Register Meaning
- ----------- -----------------------------------
- 0(00h) ....... Current Second
- 1(01h) ....... Alarm Second
- 2(02h) ....... Current Minute
- 3(03h) ....... Alarm Minute
- 4(04h) ....... Current Hour
- 5(05h) ....... Alarm Hour
- 6(06h) ....... Day of the Week
- 7(07h) ....... Number of Day
- 8(08h) ....... Month
- 9(09h) ....... Year
- 10(0Ah) ....... Clock Status Register A
- 11(0Bh) ....... Clock Status Register B
- 12(0Ch) ....... Clock Status Register C
- 13(0Dh) ....... Clock Status Register D
- 14(0Eh) ....... Diagnostic Byte
- 50(32h) ....... Year Hundreds
-
- ---------------------------
-
- STATUS REGISTER A (BYTE)
-
- 76543210 (Bits) = BYTE
-
- Bit
- 7 - VIP 0=Time Not Actualized, 1=Time Actualized
- 6-4 - Time Frequency
- 3-0 - Interrupt Frequency
-
- ---------------------------
-
- STATUS REGISTER B
-
- 76543210 (Bits) = BYTE
-
- Bit
- 7 - Actualized Time (0=yes,1=no)
- 6 - Call Periodic Interrupt (0=no, 1=yes)
- 5 - Call Alarm Interrupt (0=no,1=yes)
- 4 - Call Interrupt after time Actualization (0=no,1=yes)
- 3 - Block Generator (0=off,1=on)
- 2 - Time and date Format (0=BCD,1=binary)
- 1 - 24/12 Hour Format (0=12-hour,1=24hour)
- 0 - DayLight Savings Time (0=yes,1=no)
-
- ---------------------------
-
- STATUS REGISTER C
-
- 76543210 (Bits) = BYTE
-
- Bits:
- 7 - UNUSED
- 6 - Alarm Time Reached
- 5 - Periodic Interrupt Call
- 4 - Close Time Actualization
- 3 - UNUSED
- 2 - UNUSED
- 1 - UNUSED
- 0 - UNUSED
-
- Generally indicates the reason for this Time Interrupt.
-
- Bit 6: 1=Reason for Interrupt was for Alarm Time Reached
- Bit 5: 1=Reason was for was a routine Clock Update Call.
- Bit 4: 1=Reason was that Time Actuation was Close (Restarted?)
-
- ---------------------------
-
- STATUS REGISTER D
-
- 76543210 (Bits) = BYTE
-
- Bits:
- 7 - Battery Status (1=battery ok,0=Battery low/needs replacement)
- 6 - ?
- 5 - ?
- 4 - ?
- 3 - ?
- 2 - ?
- 1 - ?
-
- ---------------------------
-
- DIAGNOSTIC BYTE
-
- Bits
- 7 - Battery (0=Battery is OK, Battery Dead or almost Dead)
- 6 - Checksum (0=Checksum in memory location 46 and 47 OK,
- 1=Checksum in memory location 46 and 47 is FALSE)
- 5 - Config (0=Configuration in Memory Location 20 is OK,
- 1=Another Configuration found during booting)
- 4 - Memory (0=Mem Size in Memory Locations 21-24
- 1=Other Memory Size Determined during Booting)
- 3 - Hard Disk Controller (0=HD & Controller OK
- 1=Hard Disk not Present or Not Functional)
- 2 - RESERVED
- 1 - RESERVED
- 0 - RESERVED
-
- --------------------------
-
- -*)
-
- Unit VAlarm;
-
-
- Uses
- DOS,
- VDates,
- VGen;
-
- {────────────────────────────────────────────────────────────────────────────}
-
- Var
-
- AlarmCalled : BOOLEAN; { Was the Alarm Called? }
- AlarmMsg : STRING; { Area Where Alarm INT can pass data }
-
-
-
- {----------------------------------}
- { Primary Alarm Interrupt Function }
- {----------------------------------}
-
- Function SetAlarmProc( ProcPtr : POINTER ) : BYTE;
-
- Function ClearAlarmProc : BYTE;
-
-
-
- {---------------------------}
- { Low-Level Alarm Functions }
- {---------------------------}
-
- Function GetRegA : BYTE;
-
- Function GetRegB : BYTE;
-
- Function GetRegC : BYTE;
-
- Function GetRegD : BYTE;
-
- Function AlarmSetFlag( Var BcdHour : BYTE;
- Var BcdMin : BYTE;
- Var BcdSec : BYTE ) : BOOLEAN;
-
- Procedure UnsetAlarmSetFlag;
-
-
-
- {-------------------------------------------------------}
- {NOTE: Call Flag is Invalid. Also Can't Set or Reset it!}
-
- Function AlarmCallFlag : BOOLEAN;
-
- Procedure UnsetAlarmCallFlag;
-
- {-------------------------------------------------------}
-
-
- Function SetAlarmTime( BcdHour : BYTE;
- BcdMin : BYTE;
- BcdSec : BYTE ) : BYTE;
-
- Function ResetAlarmTime( BcdHour : BYTE;
- BcdMin : BYTE;
- BcdSec : BYTE ) : BYTE;
-
- Function UnsetAlarmTime : BYTE;
-
-
-
- {---------------------------}
- { Mid-Level Alarm Functions }
- {---------------------------}
-
- Function SetAlarmOn( Time : TTime ) : BOOLEAN;
-
- Function SetAlarmOff : BOOLEAN;
-
- Function AlarmIsSet : BOOLEAN;
-
- Function AlarmWasCalled : BOOLEAN;
-
-
- (* **************** MOVED TO VALARMHI.PAS ***************
- {----------------------------}
- { High-Level Alarm Functions }
- {----------------------------}
-
- { keeps sorted alarm list and manages alarm calls }
-
- Function AddAlarm() : BOOLEAN;
- Function SubAlarm() : BOOLEAN;
-
- Function CallAlarm( Var ProcItem : TProc;
- ProcPtr : POINTER ) : BOOLEAN;
-
-
- Function NewAlarm( Var ProcItem : TProc;
- ProcPtr : POINTER;
- Time : TTime ) : BOOLEAN;
-
-
- Function DisposeAlarm( ProcItem : TProc ) : BOOLEAN;
-
- *)
-
- {---------------------------------}
- { Low-Level System Time Functions }
- {---------------------------------}
-
- Procedure GetSysTime( Var BcdHour : BYTE;
- Var BcdMin : BYTE;
- Var BcdSec : BYTE );
-
- Procedure SetSysTime( BcdHour : BYTE;
- BcdMin : BYTE;
- BcdSec : BYTE );
-
- Procedure GetSysDate( Var BcdDay : BYTE;
- Var BcdMonth : BYTE;
- Var BcdYear : BYTE;
- Var BcdCent : BYTE;
- Var BcdDOW : BYTE );
-
- Procedure SetSysDate( BcdDay : BYTE;
- BcdMonth : BYTE;
- BcdYear : BYTE;
- BcdCent : BYTE;
- BcdDOW : BYTE );
-
-
-
- {----------------------------------}
- { High-Level System Time Functions }
- {----------------------------------}
-
- Procedure Sync;
-
- Procedure AccuSync;
-
- Function GetSystemTime : TTime;
-
- Function GetSystemDate : TDate;
-
- Procedure SyncSystemTime( NewTime : TTime );
-
- Procedure SyncSystemDate( NewDate : TDate );
-
- Function GetDayLightSavings : BOOLEAN;
-
- Procedure SetDayLightSavings( DLS : BOOLEAN );
-
- {────────────────────────────────────────────────────────────────────────────}
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function SetAlarmProc( ProcPtr : POINTER ) : BYTE;
-
- [PARAMETERS]
-
- ProcPtr Far Pointer to User Provided Alarm Procedure
-
- [RETURNS]
-
- Status Code ($00 = Successful)
-
- [DESCRIPTION]
-
- Installs a Provided Alarm Function into the Alarm Interrupt Routine.
- Now, whenever the RTC Alarm Call Interrupt is made, this function is
- called.
-
- WARNING: This Function MUST be kept very simple as some std functions
- don't actually return and will lock up the System!
-
- Sets the User Alarm Procedure by Storing the Original Alarm Proc
- Vector and Replacing it the User Provided Vector.
-
- NOTE: All the following Alarm Clock Functions require that the Caller
- perform this action prior to any Activity, otherwise they will all
- report Errors.
-
- IMPORTANT: As this function is an Interrupt (!!!) it absolutely MUST
- be kept simple and Obey all rules of Interrupt Procedures. Watch out
- for Nesting Interrupts and other Nasties as they WILL Lock the System!
- If you need to pass data to or from this Procedure, store it and look
- for it at a predetermined location. It should also be noted by the
- Programmer that some std functions don't properly call RETURN when
- complete (Even WriteLn!) and will Randomly Lock up the System when
- called.
-
- [SEE-ALSO]
-
- ClearAlarmProc
-
- [EXAMPLE]
-
- Procedure AlarmProc; FAR;
- BEGIN
- Flag := TRUE;
- END;
-
- VAR
- Flag : BOOLEAN;
-
- BEGIN
-
- Flag := FALSE;
- SetAlarmProc( @AlarmProc );
- SetAlarmOn( AddTime( CurrTime, 0, 0, 5 ) ); { Alarm 5 sec from Now! }
-
- While NOT KeyPressed Do;
-
- WriteLn( 'Alarm Called = ',Flag );
- ClearAlarmProc;
-
- END;
-
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function ClearAlarmProc : BYTE;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- Status Code ($00 = Successful)
-
- [DESCRIPTION]
-
- Removes the User Alarm Procedure by Restoring the Original
- System INT 4Ah Vector.
-
- NOTE: Calling this Function will Disable all the Alarm Clock
- functions provided here. This Function MUST be called Prior
- to Terminating the Host Application.
-
- [SEE-ALSO]
-
- SetAlarmProc
-
- [EXAMPLE]
-
- Procedure MyAlarmProc; FAR;
- BEGIN
- END;
-
- BEGIN
-
- If SetAlarmProc( @MyAlarmProc )=$00 Then
- WriteLn( 'Alarm Procedure Cleared : ',ClearAlarmProc=$00 )
- Else
- WriteLn( 'Alarm Procedure was NEVER ACCEPTED!' );
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function GetRegA : BYTE;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- The RealTime Clock Status Register A Flags
-
- [DESCRIPTION]
-
- Reads and returns the RealTime Clock Status Register A
-
- Flags are as follows:
- Bits
- 7 = Time Actualization (0=NO, 1=YES)
- 6-4 = Time Frequency (010b)
- 3-0 = Interrupt Frequency (0110b)
-
- [SEE-ALSO]
-
- GetRegB
- GetRegC
- GetRegD
-
- [EXAMPLE]
-
- Uses VGen;
-
- BEGIN
-
- WriteLn( 'Register A = ', ByteToBin( GetRegA ) );
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function GetRegB : BYTE;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- The RealTime Clock Status Register B Flags
-
- [DESCRIPTION]
-
- Reads and returns the RealTime Clock Status Register B
-
- Flags are as follows:
- Bits
- 7 = Actualized Time (0=YES, 1=NO)
- 6 = Call Periodic Interrupt (0=NO, 1=YES)
- 5 = Call Alarm Interrupt (0=NO, 1=YES)
- 4 = Call Intr after Time Actualization (0=NO, 1=YES)
- 3 = Block Generator (0=OFF, 1=ON)
- 2 = Time & Date Format (0=BCD, 1=Binary)
- 1 = 12/24 Hour Format (0=12 hour, 1=24 hour)
- 0 = Daylight Savings Time (0=YES, 1=NO)
-
- [SEE-ALSO]
-
- GetRegA
- GetRegC
- GetRegD
-
- [EXAMPLE]
-
- Uses VGen;
-
- BEGIN
-
- WriteLn( 'Register B = ', ByteToBin( GetRegB ) );
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function GetRegC : BYTE;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- The RealTime Clock Status Register C Flags
-
- [DESCRIPTION]
-
- Reads and returns the RealTime Clock Status Register C. The Flags
- int this Register represent the reasons for the Interrupt Call.
-
- NOTE: Most probably they are cleared during each Intr and therefore
- only useful data if the INT 70h Function were being trapped. Use
- extreme care in doing so.
-
- Flags are as follows:
- Bits
- 7 - UNKNOWN
- 6 - 1=Alarm Time Reached (seems between Intr ONLY!)
- 5 - 1=Periodic Interrupt Call
- 4 - 1=Close Time Actualization
- 3-0 - UNKNOWN
-
- [SEE-ALSO]
-
- GetRegA
- GetRegB
- GetRegD
-
- [EXAMPLE]
-
- Uses VGen;
-
- BEGIN
-
- WriteLn( 'Register C = ', ByteToBin( GetRegC ) );
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function GetRegD : BYTE;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- The RealTime Clock Status Register D Flags
-
- [DESCRIPTION]
-
- Reads and returns the RealTime Clock Status Register D
-
- Flags are as follows:
- Bits
- 7 = Battery Status (0=Dead/Dying, 1=OK)
- 6-0 = UNKNOWN
-
- [SEE-ALSO]
-
- GetRegA
- GetRegB
- GetRegC
-
- [EXAMPLE]
-
- Uses VGen;
-
- BEGIN
-
- WriteLn( 'Register D = ',ByteToBin( GetRegD ) );
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function AlarmSetFlag( Var BcdHour : BYTE;
- Var BcdMin : BYTE;
- Var BcdSec : BYTE ) : BOOLEAN;
-
- [PARAMETERS]
-
- BcdHour VAR Returned Previous Alarm Hour in BCD
- BcdMin VAR Returned Previous Alarm Minutes in BCD
- BcdSec VAR Returned Previous Alarm Seconds in BCD
-
- [RETURNS]
-
- (Function : Is the Alarm Set Flag Currently Set?)
- (VAR : [BcdHour] Returned Previous Set Hour)
- (VAR : [BcdMin] Returned Previous Set Minute)
- (VAR : [BcdSec] Returned Previous Set Second)
-
- [DESCRIPTION]
-
- Low Level Function that Returns whether or not the Alarm Clock
- is Active as well as the stored Previous Alarm Time.
-
- This is the most direct way to turn off the Alarm Clock. Without
- knowing what other actions are taken by the Standard Interrupt
- Function, it would probably be better to use the Std Int Func over
- this unless you intend to turn it back on manually also.
-
- [SEE-ALSO]
-
- UnsetAlarmSetFlag
-
- [EXAMPLE]
-
- VAR
- Hr,Min,Sec : BYTE;
- Active : BOOLEAN;
-
- BEGIN
-
- Active := AlarmSetFlag( Hr, Min, Sec) );
-
- WriteLn( 'Alarm is Active :, Active );
- WriteLn( 'Current/Previous Alarm Time is : Hr=',Hr,
- ' Min=',Min,
- ' Sec=',Sec );
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure UnsetAlarmSetFlag;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- Turns the Alarm Trigger Flag to OFF, so that the Alarm Clock is
- not called.
-
- This is the most direct way to turn off the Alarm Clock. Without
- knowing what other actions are taken by the Standard Interrupt
- Function, it would probably be better to use the Std Int Func over
- this unless you intend to turn it back on manually also.
-
- [SEE-ALSO]
-
- AlarmSetFlag
-
- [EXAMPLE]
-
- BEGIN
-
- UnsetAlarmSetFlag;
-
- { Alarm should not be turned Off }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function AlarmCallFlag : BOOLEAN;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- Is the Alarm Called Flag Set?
-
- [DESCRIPTION]
-
- Returns whether or not the Alarm has already been called.
-
- NOTE: While it is perfectly valid to Read the Flag, it seems of
- little use as even when the alarm is called, this flag is never
- set. Thus this data is of little use to the applications programmer.
- This will be corrected in future versions.
-
- [SEE-ALSO]
-
- SetAlarmOn
- SetAlarmOff
- AlarmIsSet
- AlarmWasCalled
-
- [EXAMPLE]
-
- BEGIN
-
- WriteLn( 'AlarmCallFlag Set : ', AlarmCallFlag );
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure UnsetAlarmCallFlag;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- Turns the Alarm Called Status to FALSE, so that the Alarm Clock
- is not considered to have been called already.
-
- NOTE: While it is perfectly valid to Read the Flag, it seems of
- little use as even when the alarm is called, this flag is never
- set. Thus this data is of little use to the applications programmer.
- This will be corrected in future versions.
-
- [SEE-ALSO]
-
- AlarmCallFlag
- SetAlarmOn
- SetAlarmOff
- AlarmIsSet
- AlarmWasCalled
-
- [EXAMPLE]
-
- BEGIN
-
- UnsetAlarmCallFlag;
-
- { Alarm Called Flag should not be FALSE (unset) }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function SetAlarmTime( BcdHour : BYTE;
- BcdMin : BYTE;
- BcdSec : BYTE ) : BYTE;
-
- [PARAMETERS]
-
- BcdHour Desired Alarm Hours in BCD Format
- BcdMin Desired Alarm Minutes in BCD Format
- BcdSec Desired Alarm Seconds in BCD Format
-
- [RETURNS]
-
- Status Code ($00 = Success)
-
- [DESCRIPTION]
-
- This function loads the provided Alarm Time and turns on the System
- Alarm Clock.
-
- NOTE: This Requires the caller to have Installed an Alarm Clock
- Interrupt Procedure (Thru SetAlarmProc) otherwise it will return
- an Error.
-
- [SEE-ALSO]
-
- ResetAlarmTime
- UnSetAlarmTime
-
- [EXAMPLE]
-
- VAR
- Active : BOOLEAN;
-
- BEGIN
-
- Active := SetAlarmTime( DecToBCD(14), DecToBCD(15), DecToBCD(30) ) = $00;
-
- WriteLn( 'Alarm is Set to 2:15:30PM : ', Active );
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function ResetAlarmTime( BcdHour : BYTE;
- BcdMin : BYTE;
- BcdSec : BYTE ) : BYTE;
-
- [PARAMETERS]
-
- BcdHour Desired Alarm Hours in BCD Format
- BcdMin Desired Alarm Minutes in BCD Format
- BcdSec Desired Alarm Seconds in BCD Format
-
- [RETURNS]
-
- Status Code ($00 = Success)
-
- [DESCRIPTION]
-
- Resets a previously Set Alarm Time to a New Alarm Time. Once Set,
- You Must use this Method to Reset all New Alarm Times (Unless the
- Alarm has been Called). This removes the Old Time before attempting
- to Set the New Time.
-
- NOTE: This Requires the caller to have Installed an Alarm Clock
- Interrupt Procedure (Thru SetAlarmProc) otherwise it will return
- an Error.
-
- [SEE-ALSO]
-
- SetAlarmTime
- UnSetAlarmTime
-
- [EXAMPLE]
-
- VAR
- Active : BOOLEAN;
-
- BEGIN
-
- Active := SetAlarmTime( DecToBCD(14), DecToBCD(15), DecToBCD(30) ) = $00;
-
- { If Active, Alarm Time is: 2:15:30 PM }
-
- If Active Then
- BEGIN
-
- Active := ResetAlarmTime( DecToBCD(8),
- DecToBCD(30),
- DecToBCD(0) ) = $00;
-
- WriteLn( 'Alarm Set to New Time : ', Alarm );
-
- { If Active, Alarm Time is now: 8:30:00 AM }
-
- END { If Active }
-
- Else
- WriteLn( 'Alarm Never Accepted 1st Alarm Time!' );
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function UnSetAlarmTime : BYTE;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- Status Code ($00 = Success)
-
- [DESCRIPTION]
-
- Low-Level Function to turn the System Alarm Timer Off.
-
- NOTE: This Requires the caller to have Installed an Alarm Clock
- Interrupt Procedure (Thru SetAlarmProc) otherwise it will return
- an Error.
-
- [SEE-ALSO]
-
- SetAlarmTime
- ResetAlarmTime
-
- [EXAMPLE]
-
- VAR
- Active : BOOLEAN;
-
- BEGIN
-
- Active := SetAlarmTime( DecToBCD(14), DecToBCD(15), DecToBCD(30) ) = $00;
-
- If Active Then
- BEGIN
-
- Active := UnSetAlarmTime = $00;
-
- WriteLn( 'Alarm Time is Active : ',Active )
- WriteLn( 'The alarm will now go off at 2:15:30PM' );
-
- END { If Active }
-
- Else
- WriteLn( 'Alarm was Never Activated!' );
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function SetAlarmOn( Time : TTime ) : BOOLEAN;
-
- [PARAMETERS]
-
- Time Time to Set the Alarm To
-
- [RETURNS]
-
- Was the Alarm Time Set?
-
- [DESCRIPTION]
-
- Turns on the RealTime Alarm Clock based upon the time passed in.
- This operation will Overwrite any previously set time.
-
- [SEE-ALSO]
-
- AlarmCallFlag
- SetAlarmOff
- AlarmIsSet
- AlarmWasCalled
-
- [EXAMPLE]
-
- VAR
- Time : TTime;
-
- BEGIN
-
- Time := HMStoTime( 14, 15, 30 );
-
- If SetAlarmOn( Time ) Then
- WriteLn( 'Alarm is ACTIVE' )
- Else
- WriteLn( 'Alarm FAILED to Activate!' );
-
- { If Successful, Alarm Time is now set for 2:15:30 PM }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function SetAlarmOff : BOOLEAN;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- Was the Alarm Turned Off Successfully?
-
- [DESCRIPTION]
-
- Turns off any current RealTime Alarm Clock alarm Times.
-
- [SEE-ALSO]
-
- AlarmCallFlag
- SetAlarmOn
- AlarmIsSet
- AlarmWasCalled
-
- [EXAMPLE]
-
- BEGIN
-
- WriteLn( SetAlarmOff );
-
- { If RTC Alarm Disabled successfully, Displays 'TRUE' }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function AlarmIsSet : BOOLEAN;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- Is the Alarm Clock Currently Set?
-
- [DESCRIPTION]
-
- Returns whether or not the Alarm Clock is currently set. This function
- isolates the caler from the Previous Time data information.
-
- [SEE-ALSO]
-
- AlarmCallFlag
- SetAlarmOn
- SetAlarmOff
- AlarmWasCalled
-
- [EXAMPLE]
-
- BEGIN
-
- If SetAlarmOn Then;
-
- WriteLn( AlarmIsSet );
-
- { If RTC Alarm Set successfully, Diplays 'TRUE' }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function AlarmWasCalled : BOOLEAN;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- Has the Alarm been Called?
-
- [DESCRIPTION]
-
- [SEE-ALSO]
-
- AlarmCallFlag
- SetAlarmOn
- SetAlarmOff
- AlarmIsSet
-
- [EXAMPLE]
-
- BEGIN
-
- WriteLn( AlarmWasCalled );
-
- { If Alarm Called Flag was set, Displays 'TRUE' else 'FALSE' }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure GetSysTime( Var BcdHour : BYTE;
- Var BcdMin : BYTE;
- Var BcdSec : BYTE );
-
- [PARAMETERS]
-
- BcdHour VAR Returned RealTime Clock Hours
- BcdMin VAR Returned RealTime Clock Minutes
- BcdSec VAR Returned RealTime Clock Seconds
-
- [RETURNS]
-
- (Function : None)
- (VAR : [BcdHour] RealTime Clock Hours)
- (VAR : [BcdMin] RealTime Clock Minutes)
- (VAR : [BcdSec] RealTime Clock Seconds)
-
- [DESCRIPTION]
-
- Returns the System Time as reported by the Battery powered
- Motorola MC-146818 processor chip. May not always jibe with
- DOS's System Time.
-
- [SEE-ALSO]
-
- SetSysTime
- GetSysDate
- SetSysDate
-
- [EXAMPLE]
-
- VAR
- Hr,Min,Sec : BYTE;
-
- BEGIN
-
- GetSysTime( Hr, Min, Sec );
-
- WriteLn( BCDtoDec(Hr), ':', BCDtoDec(Min), ':', BCDtoDec(Sec) );
-
- { Displays the Date as according to the RTC }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure SetSysTime( BcdHour : BYTE;
- BcdMin : BYTE;
- BcdSec : BYTE );
-
- [PARAMETERS]
-
- BcdHour Hour to set RTC to
- BcdMin Minute to set RTC to
- BcdSec Second to set RTC to
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- Returns the System Time as reported by the Battery powered
- Motorola MC-146818 processor chip. May not always jibe with
- DOS's System Time.
-
- [SEE-ALSO]
-
- GetSysTime
- GetSysDate
- SetSysDate
-
- [EXAMPLE]
-
- BEGIN
-
- SetSysTime( DecToBCD( 14 ), DecToBCD( 15 ), DecToBCD( 30 ) );
-
- { Sets the RTC Time to 2:15:30 PM }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure GetSysDate( Var BcdDay : BYTE;
- Var BcdMonth : BYTE;
- Var BcdYear : BYTE;
- Var BcdCent : BYTE;
- Var BcdDOW : BYTE );
-
- [PARAMETERS]
-
- BcdDay (BYTE) Returning BCD Day
- BcdMonth (BYTE) Returning BCD Month
- BcdYear (BYTE) Returning BCD Year (MOD 100)
- BcdCent (BYTE) Returning BCD Century (DIV 100)
- BcdDOW (BYTE) Returning BCD DayOfWeek (base=1)
-
- [RETURNS]
-
- (Function : None)
- (VAR : [BcdDay] Returning BCD Day )
- (VAR : [BcdMonth] Returning BCD Month )
- (VAR : [BcdYear] Returning BCD Year (MOD 100) )
- (VAR : [BcdCent] Returning BCD Century (DIV 100))
- (VAR : [BcdDOW] Returning BCD DayOfWeek (base=1))
-
- [DESCRIPTION]
-
- Returns the System Time as reported by the Battery powered
- Motorola MC-146818 processor chip. May not always jibe with
- DOS's System Time.
-
- [SEE-ALSO]
-
- GetSysTime
- SetSysTime
- SetSysDate
-
- [EXAMPLE]
-
- VAR
- Day,Mon,Yr,
- Cent,DOW : BYTE;
-
- BEGIN
-
- GetSysDate( Day, Mon, Yr, Cent, DOW );
-
- WriteLn( 'Day=',BCDtoDec(Day),
- 'Mon=',BCDtoDec(Mon),
- 'Yr =',BCDtoDec(Cent)*100 + BCDtoDec(Yr) );
- 'DayOfWeek=',BCDtoDec(DOW) );
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure SetSysDate( BcdDay : BYTE;
- BcdMonth : BYTE;
- BcdYear : BYTE;
- BcdCent : BYTE;
- BcdDOW : BYTE );
-
- [PARAMETERS]
-
- BcdDay New Day in BCD Format
- BcdMonth New Month in BCD Format
- BcdYear New Year (MOD 100) in BCD Format
- BcdCent New Century (DIV 100) in BCD Format
- BcdDOW New DayOfWeek (base=1) in BCD Format
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- Sets the System Time of the Battery powered Motorola MC-146818
- processor chip.
-
- There is NO Range or Error Checking so Caller MUST ensure the
- Date/DayOfWeek is Valid prior to Calling.
-
- [SEE-ALSO]
-
- GetSysTime
- SetSysTime
- GetSysDate
-
- [EXAMPLE]
-
- BEGIN
-
- SetSysDate( DecToBCD( 1 ), DecToBCD( 2 ), DecToBCD( 00 ),
- DecToBCD( 19 ), DevToBCD( 0 ) );
-
- { Will Set the RTC Date to 1 Feb 1990, SUN (whether or not it is valid) }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function GetSystemTime : TTime;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- RealTime Clock Current System Time
-
- [DESCRIPTION]
-
- Returns the System Time as reported by the Battery powered
- Motorola MC-146818 processor chip. May not always jibe with
- DOS's System Time.
-
- [SEE-ALSO]
-
- GetSystemDate
- SyncSystemTime
- SyncSystemDate
-
- [EXAMPLE]
-
- BEGIN
-
- WriteLn( TimeToStr( GetSystemTime ) );
-
- { Will Display the Time as according to the RTC }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function GetSystemDate : TDate;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- RealTime Clock Current System Date
-
- [DESCRIPTION]
-
- Returns the System Date as reported by the Battery powered
- Motorola MC-146818 processor chip. May not always jibe with
- DOS's System Date.
-
- [SEE-ALSO]
-
- GetSystemTime
- SyncSystemTime
- SyncSystemDate
-
- [EXAMPLE]
-
- BEGIN
-
- WriteLn( DateToStr( GetSystemData ) );
-
- { Will Display the Date as according to the RTC }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure Sync;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- This Procedure Synchronizes the Battery System Clock with (what
- I consider to be the more Reliable) DOS System Clock. It is
- 100% Assembly to get the Synchronization as accurate as possible.
- The tolerance is within One (1) Second which should be enough for
- most applications.
-
- Also, In order to truly Sync the Clocks, you must call this routine
- at the exact instant of the 1st tick of the new second. In other
- words, both Clocks should be Synchronized at the exact beginning of
- the same Second to ensure a nearly exact time synchronization.
-
- NOTE: Only Sychronizes the Clock Time not Date.
-
- [SEE-ALSO]
-
- AccuSync
-
- [EXAMPLE]
-
- BEGIN
-
- Sync;
-
- { RTC Times should be within a Second of Synchronization with DOS Times }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure AccuSync;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- In order to truly Sync the Clocks, you must call the Sync routine
- at the exact instant of the 1st tick of the new second. In other
- words, both Clocks should be Synchronized at the exact beginning
- of the same Second to ensure a nearly exact time synchronization.
-
- [SEE-ALSO]
-
- Sync
-
- [EXAMPLE]
-
- BEGIN
-
- AccuSync;
-
- { RTC Times should be in Synchronization with the DOS Times }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure SyncSystemTime( NewTime : TTime );
-
- [PARAMETERS]
-
- NewTime New Time to Set RTC Time to
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- This Procedure Synchronizes the Battery System Clock with (what I
- consider to be the more Reliable) DOS System Clock. Synchronization
- as accurate is within One (1) Second which should be enough for most
- applications.
-
- [SEE-ALSO]
-
- GetSystemTime
- GetSystemDate
- SyncSystemDate
-
- [EXAMPLE]
-
- VAR
- Time : TTime;
-
- BEGIN
-
- Time := HMStoTime( 14, 15, 30 );
-
- SyncSystemTime( Time );
-
- { The New RTC Time will be 2:15:30PM }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure SyncSystemDate( NewDate : TDate );
-
- [PARAMETERS]
-
- NewTime New Time To Set RTC Time To
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- This Procedure Synchronizes the Battery System Clock with (what I
- consider to be the more Reliable) DOS System Clock.
-
- [SEE-ALSO]
-
- GetSystemTime
- GetSystemDate
- SyncSystemTime
-
- [EXAMPLE]
-
- VAR
- Date : TDate;
-
- BEGIN
-
- Date := DMYtoDate( 1,2,1990 );
- SyncSystemDate( Date );
-
- { The New RTC Date will be set to 2 Feb 1990 }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Function GetDayLightSavings : BOOLEAN;
-
- [PARAMETERS]
-
- (None)
-
- [RETURNS]
-
- Is DayLight Savings Set?
-
- [DESCRIPTION]
-
- Returns whether or not the RealTime Clock DayLight Savings is
- Activated.
-
- [SEE-ALSO]
-
- SetDayLightSavings
-
- [EXAMPLE]
-
- BEGIN
-
- WriteLn( 'RTC Daylight Savings is Active : ', GetDayLightSavings );
-
- { If DLS is Active in the RTC Register then reports TRUE else FALSE }
-
- END;
-
-
- ──────────────────────────────────────────────────────────────────────────────
-
-
- [FUNCTION]
-
- Procedure SetDayLightSavings( DLS : BOOLEAN );
-
- [PARAMETERS]
-
- DLS Whether DayLight Savings is to be Set
-
- [RETURNS]
-
- (None)
-
- [DESCRIPTION]
-
- Sets the RealTime Clock Day Light Savings according to the Flag
- you pass in.
-
- [SEE-ALSO]
-
- GetDayLightSavings
-
- [EXAMPLE]
-
- BEGIN
-
- SetDayLightSavings( TRUE );
-
- { DayLight Savings Time is Now Valid in the RTC registers }
-
- END;
-
-