view code_part1/OSTC_code_asm_part1/temp_extrema.asm @ 305:77c70898c7aa

cleanup
author heinrichsweikamp
date Sat, 30 Apr 2011 14:18:30 +0200
parents 96a35aeda5f2
children 2144f19fa1eb
line wrap: on
line source


; OSTC - diving computer code
; Copyright (C) 2008 HeinrichsWeikamp GbR

;    This program is free software: you can redistribute it and/or modify
;    it under the terms of the GNU General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;    (at your option) any later version.

;    This program is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;    GNU General Public License for more details.

;    You should have received a copy of the GNU General Public License
;    along with this program.  If not, see <http://www.gnu.org/licenses/>.


; takes care of the temperature extrema routine
; written by: Matthias Heinrichs, info@heinrichsweikamp.com
; written: 05/15/08
; last updated: 05/15/08
; known bugs:
; ToDo:

check_temp_extrema:			; called once every minute from Sleeploop, Surfloop and Diveloop
	read_int_eeprom d'54'			; get lowest temperature so far
	movff	EEDATA,sub_b+0
	read_int_eeprom d'55'
	movff	EEDATA,sub_b+1
	movff	temperature+0,sub_a+0
	movff	temperature+1,sub_a+1
	call	sub16					; sub_c = sub_a - sub_b
	btfss	neg_flag				; new lowest temperature ?
	bra		check_temp_extrema_high	
	; Yes, store new value together with the date
	movff	temperature+0,EEDATA
	write_int_eeprom	d'54'
	movff	temperature+1,EEDATA
	write_int_eeprom	d'55'
	movff	month,EEDATA
	write_int_eeprom	d'56'
	movff	day,EEDATA
	write_int_eeprom	d'57'
	movff	year,EEDATA
	write_int_eeprom	d'58'
	; Now check high extrema
check_temp_extrema_high:
	read_int_eeprom d'59'			; get highest temperature so far
	movff	EEDATA,sub_b+0
	read_int_eeprom d'60'
	movff	EEDATA,sub_b+1
	movff	temperature+0,sub_a+0
	movff	temperature+1,sub_a+1
	call	sub16					; sub_c = sub_a - sub_b
	btfsc	neg_flag				; new highest temperature ?
	return							; no, quit!
	; Yes, store new value together with the date
	movff	temperature+0,EEDATA
	write_int_eeprom	d'59'
	movff	temperature+1,EEDATA
	write_int_eeprom	d'60'
	movff	month,EEDATA
	write_int_eeprom	d'61'
	movff	day,EEDATA
	write_int_eeprom	d'62'
	movff	year,EEDATA
	write_int_eeprom	d'63'
	return