;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Copyright (c) 2001-2002 TIMEX Corporation.
; 
; This document is the property of, and contains information proprietary to
; TIMEX Corporation.  It is to be returned upon request.  Reproduction by any
; means, disclosure, or use of its contents for other than the expressed
; purpose for which it is loaned, without the written consent of TIMEX
; Corporation, is strictly prohibited.
;
; File Name:    chr.h
;
; Purpose:      CHRONO Header File
;
; File Change History:
;
;               08/01/2000 RVD - Created chr.h for m841
;
; M851 Development:
;
;				11/08/2001 RBR - Modified and reused for M851 Development
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	  
;---------------------------------------------------
; Boundary Conditions Related Equates.
;---------------------------------------------------

CHRMAXNOOFLAPS				equ		200				; Maximum Number of Laps by Default is \
													;   200				

CHRPAGEACCESSSIZE           equ     64				; byte size of the EEPROM Page access (TBD)



;---------------------------------------------------
; Redefinition of CORE States
;---------------------------------------------------

CHRBANNERSTATE          	equ     COREBANNERSTATE
CHRDEFAULTSTATE         	equ     COREDEFAULTSTATE
CHRSET1BANNERSTATE      	equ     CORESET1BANNERSTATE
CHRFORMATSTATE            	equ     CORESET1STATE
CHRPOPUPSTATE           	equ     COREPOPUPSTATE
CHRRESETSTATE           	equ     COREMISCSTATE0 
CHRRUNNINGSTATE       	  	equ     COREMISCSTATE1 
CHRSTOPPEDSTATE            	equ     COREMISCSTATE2 
CHRRECALLSTATE              equ     COREMISCSTATE3 
CHRWRKOUTSTOREDSTATE		equ     COREMISCSTATE4 
CHRTURNCROWNMESSAGESTATE	equ     COREMISCSTATE5 
CHRYOUROCKSETSTATE          equ		COREMISCSTATE6

;---------------------------------------------------
; Redefinition of CORE Events used
;---------------------------------------------------

CHREVENT_STATEENTRY         equ     COREEVENT_STATEENTRY
CHREVENT_TIMEOUTLORES       equ     COREEVENT_TIMEOUTDONE_LOWRES
CHREVENT_TIMEOUTDONE_HIRES	equ		COREEVENT_TIMEOUTDONE_HIGHRES
CHREVENT_STICKY_TIMEOUTDONE equ		COREEVENT_STICKY_TIMEOUTDONE
CHREVENT_CROWN_HOME  		equ		COREEVENT_CROWN_HOME
CHREVENT_CROWN_SET1	    	equ		COREEVENT_CROWN_SET1	   
CHREVENT_CW_EDGE	    	equ		COREEVENT_CW_EDGE_TRAILING	   
CHREVENT_CCW_EDGE	    	equ		COREEVENT_CCW_EDGE_TRAILING	   
CHREVENT_ANYSWITCHDEPRESS	equ		COREEVENT_ANYSWITCHDEPRESS	   
CHREVENT_ANYSWITCHRELEASE	equ		COREEVENT_ANYSWITCHRELEASE	   

CHREVENT_MODEDEPRESS  		equ     COREEVENT_SWITCH1DEPRESS
CHREVENT_STOPRESETDEPRESS	equ     COREEVENT_SWITCH2DEPRESS
CHREVENT_STARTSPLITDEPRESS	equ     COREEVENT_SWITCH3DEPRESS



CHREVENT_MODERELEASE  		equ     COREEVENT_SWITCH1RELEASE
CHREVENT_STOPRESETRELEASE	equ     COREEVENT_SWITCH2RELEASE
CHREVENT_STARTSPLITRELEASE	equ     COREEVENT_SWITCH3RELEASE


CHREVENT_DISPLAY_TODRES	  	equ		COREEVENT_DISPLAY_UPDATE_TODRES	   
CHREVENT_DISPLAY_STPRES		equ		COREEVENT_DISPLAY_UPDATE_STPRES	   
CHREVENT_MELODY_DONE	    equ		COREEVENT_MELODY_DONE	   
CHREVENT_POPUP_MEL_CANCELED equ  	COREEVENT_MELODYPOPUPCANCEL



;------------------------------------------------
; LCD Main dot matrix position redefinition
;------------------------------------------------


CHRDMPOSITION_HOUR_HMS      equ		LCDBIGCHARDMCOL1
CHRDMPOSITION_MIN_HMS       equ		LCDBIGCHARDMCOL17
CHRDMPOSITION_SEC_HMS       equ		LCDMAINDMLINE2COL32

CHRDMPOSITION_MIN_MSH       equ		LCDBIGCHARDMCOL1
CHRDMPOSITION_SEC_MSH       equ		LCDBIGCHARDMCOL17
CHRDMPOSITION_HUND_MSH      equ		LCDMAINDMLINE2COL32

CHRDMPOSITION_COLON         equ		LCDMAINDMLINE1COL15
CHRDMPOSITION_DOT1          equ		LCDMAINDMLINE1COL15


;------------------------------------------------
; LCD dot matrix Line 1 position redefinition
;------------------------------------------------

CHRDMLINE1POSITION_HOUR_HMS equ		LCDMAINDMLINE1COL1
CHRDMLINE1POSITION_MIN_HMS  equ		LCDMAINDMLINE1COL15
CHRDMLINE1POSITION_SEC_HMS  equ		LCDMAINDMLINE1COL29

CHRDMLINE1POSITION_MIN_MSH  equ		LCDMAINDMLINE1COL1
CHRDMLINE1POSITION_SEC_MSH  equ		LCDMAINDMLINE1COL15
CHRDMLINE1POSITION_HUND_MSH equ		LCDMAINDMLINE1COL29

CHRDMLINE1POSITION_COLON	equ		LCDMAINDMLINE1COL13
CHRDMLINE1POSITION_DOT1		equ		LCDMAINDMLINE1COL13
CHRDMLINE1POSITION_DOT2		equ		LCDMAINDMLINE1COL27

;------------------------------------------------
; LCD segment position redefinition
;------------------------------------------------

CHRSEGPOSITION_HOUR_HMS 	equ		LCDSEGDIGIT1
CHRSEGPOSITION_MIN_HMS  	equ		LCDSEGDIGIT3
CHRSEGPOSITION_SEC_HMS      equ		LCDSEGDIGIT5

CHRSEGPOSITION_MIN_MSH  	equ		LCDSEGDIGIT1
CHRSEGPOSITION_SEC_MSH  	equ		LCDSEGDIGIT3
CHRSEGPOSITION_HUND_MSH 	equ		LCDSEGDIGIT5

CHRTODSEG_HOUR              equ    	LCDSEGDIGIT3
CHRTODSEG_MINUTE			equ    	LCDSEGDIGIT5

;------------------------------------------------
; LCD position redefinition	for lap number in
;   the upper dot matrix display.
;------------------------------------------------

CHRLAPCOUNTPOSITION			equ	LCDUPPERDMCOL3


;*******************************************************************************
;  Stopwatch resource update display related equates. These are implemented as
;    a jump table in the chrono display routines for stopwatch resources.
;*******************************************************************************

;---------------------------------------------------
;  Equates indicating where to start the display.
;---------------------------------------------------				  


CHRSTARTUPDATEFROMHUND      equ     00000000b	    ; Start from hundrethds
CHRSTARTUPDATEFROMSEC       equ     00000001b		; Start from seconds
CHRSTARTUPDATEFROMMIN       equ     00000011b		; Start from minutes
CHRSTARTUPDATEFROMHOUR      equ     00000111b		; Start from hours


;---------------------------------------------------
;  Equates indicating what field is zero.
;---------------------------------------------------				  


CHRUPD_HHMMSS_ZERO          equ     00000000b		; Hours, minutes and seconds is zero, hund - MSD
CHRUPD_HHMM_ZERO       		equ     00000001b		; Hours and minutes is zero. seconds - MSD
CHRUPD_HH_ZERO              equ     00000011b		; Hours is zero, Minutes - MSD
CHRUPD_HH_NONZERO           equ     00000111b		; Hours is non-zero and the MSD.

CHRFORCEIN_HHMMSS    		equ     00001001b		; Forces the display format to be HH:MM.SS irregardless
													;   if Hours or minutes is zero.


;----------------------------------------------------
; Mask equate for the Non-zero and update bits of the
;   stopwatch resource.
;----------------------------------------------------

CHRMASKUNUSEDRESOURCE_NONZERO_AND_UPDATEBITS equ 01110111b


;---------------------------------------------------
;  Equates indicating the start field and format
;    of the chrono resource display.
;---------------------------------------------------				  

;-------------------------------------------------------------------------------
; Seconds is the MSD and displayed in HH:MM.SS format. Hours and minutes are 
;   zero and undisplayed.
;-------------------------------------------------------------------------------

CHRDISPSECONDSWITHZEROSUP_IN_HHMMSS		equ	(CHRFORCEIN_HHMMSS  + CHRSTARTUPDATEFROMSEC)

;-------------------------------------------------------------------------------
; Minutes is the MSD and displayed in HH:MM.SS format. Hour is zero and 
;   undisplayed.
;-------------------------------------------------------------------------------

CHRDISPMINUTEWITHZEROSUP_IN_HHMMSS      equ (CHRFORCEIN_HHMMSS  + CHRSTARTUPDATEFROMHOUR)

;-------------------------------------------------------------------------------
; Hours is the MSD and Non-Zero. Start display from hours in HH:MM.SS format
;-------------------------------------------------------------------------------

CHRDISPHOURWITHZEROSUP_IN_HHMMSS		equ	(CHRUPD_HH_NONZERO  + CHRSTARTUPDATEFROMHOUR)

;-------------------------------------------------------------------------------
; Hours is the MSD and Non-Zero. Start display from minutes in HH:MM.SS format
;-------------------------------------------------------------------------------

CHRDISPMINUTEWITHOUTZEROSUP_IN_HHMMSS	equ	(CHRUPD_HH_NONZERO  + CHRSTARTUPDATEFROMMIN)

;-------------------------------------------------------------------------------
; Hours is the MSD and Non-Zero. Start display from seconds in HH:MM.SS format
;-------------------------------------------------------------------------------

CHRDISPSECONDSWITHOUTZEROSUP_IN_HHMMSS	equ	(CHRUPD_HH_NONZERO  + CHRSTARTUPDATEFROMSEC)


;-------------------------------------------------------------------------------
; Seconds is the MSD and displayed in MM:SS.hh format. Minute is zero and 
;   undisplayed. Hours is also zero in this case.
;-------------------------------------------------------------------------------

CHRDISPSECONDSWITHZEROSUP_IN_MMSSHH		equ	(CHRUPD_HHMM_ZERO   + CHRSTARTUPDATEFROMSEC)

;-------------------------------------------------------------------------------
; Hundredths is the MSD and displayed in MM:SS.hh format. Minute and seconds 
;   are zero and undisplayed.  Hours is also zero in this case.
;-------------------------------------------------------------------------------

CHRDISPHUNDWITHZEROSUP					equ	(CHRUPD_HHMMSS_ZERO + CHRSTARTUPDATEFROMHUND)


;-------------------------------------------------------------------------------
; Minute is the MSD and Non-Zero. Start display from minutes in MM:SS.hh format.
;   Hours is zero in this case.
;-------------------------------------------------------------------------------

CHRDISPMINUTEWITHOUTZEROSUP_IN_MMSSHH	equ	(CHRUPD_HH_ZERO     + CHRSTARTUPDATEFROMMIN)

;-------------------------------------------------------------------------------
; Minute is the MSD and Non-Zero. Start display from seconds in MM:SS.hh format.
;   Hours is zero in this case.
;-------------------------------------------------------------------------------


CHRDISPSECONDSWITHOUTZEROSUP_IN_MMSSHH	equ	(CHRUPD_HH_ZERO     + CHRSTARTUPDATEFROMSEC)

;-------------------------------------------------------------------------------
; Seconds is the MSD and Non-Zero. Start display from hundredths in MM:SS.hh 
;   format.	Hours and Minutes are zero in this case.
;-------------------------------------------------------------------------------

CHRDISPHUNDWITHOUTZEROSUP_MINZERO		equ	(CHRUPD_HHMM_ZERO   + CHRSTARTUPDATEFROMHUND)

;-------------------------------------------------------------------------------
; Minute is the MSD and Non-Zero. Start display from hundredths in MM:SS.hh 
;   format.	Hours is zero in this case.
;-------------------------------------------------------------------------------


CHRDISPHUNDWITHOUTZEROSUP_MINNONZERO	equ (CHRUPD_HH_ZERO		+ CHRSTARTUPDATEFROMHUND)



;-------------------------------------------------------------------------------
; Offsets of Chrono Hours, minutes and seconds from hundredths.
;
;	Chrono Data Sturcture format:  Hundredths , Seconds , Minutes , Hours.
;-------------------------------------------------------------------------------
	 

CHRSECOFFSETFROMHUNDRENTHS     		equ 1			; Seconds offset from hundredths
CHRMINUTEOFFSETFROMHUNDRENTHS		equ 2			; Minutes offset from hundredths
CHRHOUROFFSETFROMHUNDRENTHS			equ 3			; Hours   offset from hundredths


CHRMASKOFFUNUSEDUPDBITS             equ 00000111b	; Masks the unused update bits.
 
CHRFIRSTLAPTAKEN                    equ 1			; Lap Number of the first lap.


CHRMAXLAPCOUNT                      equ 200			; Maximum Lap Count.

CHRFIRSTWORKOUTDEFAULTRECNO         equ 0			; Record number of the first workout stored.

CHRNOOFFSETATALL                    equ 0			; Used to indicate that the data to be stored
													;   in a database record doesn't have an offset
													;   from the start of the record.


CHRAVELAP							equ 255			; Since Chrono is upto 200, choose this as 
													;   the value for the average lap.  


CHRBESTLAP							equ 254			; Since Chrono is upto 200, choose this as 
													;   the value for the average lap.

CHRMASKOFFBITSOTHERTHANDISPFORMAT   equ CHRDISPTIMELAPFORMAT
													
CHROFFSETOFDBASENOOFREC				equ 5 
CHRMINIMUMRECFORWORKOUTSTORAGE      equ 2			; Minimum record for to make the least 
													;   storage for a workout.

;---------------------------------------------------
; Chrono Display Format Equates
;---------------------------------------------------

CHRDISPLAPSPLITFORMAT               equ 0			; Lap-Split  format.
CHRDISPSPLITLAPFORMAT               equ 1			; Split-Lap  format.
CHRDISPTIMESPLITFORMAT              equ 2			; Time-split format.
CHRDISPTIMELAPFORMAT                equ 3			; Time-Lap   format.

CHRDISPFORMAT_IN_NORMAL				equ 0			; display in normal and depends on the
													;   split data. If Hour is zero, display
													;   is in MM.SS.hh , if not , then HH:MM.SS

CHRDISPFORMAT_IN_HMS				equ 8			; Forces the split to be displayed in 
  													;   HH:MM.SS even if Hours data is zero




CHRDISPLAYFORMAT_PORINIT_VALUE		 	equ CHRDISPLAPSPLITFORMAT
CHRSYSTEMFLAG_PORINIT_VALUE          	equ	0
CHRLAPCOUNT_PORINIT_VALUE			 	equ	1
CHRRECFREECOUNT_PORINIT_VALUE           equ (CHRMAXNOOFLAPS + 1)
CHRMAXRECCOUNTCONFIG_POR_INITVALUE      equ (CHRMAXNOOFLAPS + 1)
CHRLAPSFREECOUNT_PORINIT_VALUE      	equ	200
CHRMAXLAPCOUNTCONFIG_PORINIT_VALUE  	equ	200
CHRCURRENTWORKOUTRECNO_PORINIT_VALUE	equ	0
CHRFREEMEMRECNO_PORINIT_VALUE       	equ	0
CHRLASTWORKOUTRECNO_PORINIT_VALUE   	equ	0
CHRUNSTOREWORKOUTRECNO_PORINIT_VALUE	equ	0