diff code_part1/OSTC_code_asm_part1/menu.asm @ 575:cbdcbbc91877

some code cleaning
author heinrichsweikamp
date Sat, 21 Apr 2012 15:08:09 +0200
parents 101fec6a6137
children ab2686087bce
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/menu.asm	Sat Apr 21 13:58:30 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu.asm	Sat Apr 21 15:08:09 2012 +0200
@@ -57,25 +57,13 @@
 	goto	restart						; exit menu, restart
 
 	btfsc	onesecupdate
-	call	timeout_surfmode
-
-	btfsc	onesecupdate
-	call	set_dive_modes
-
-	btfsc	onesecupdate
-	call	test_charger				; check if charger IC is active
-
-	btfsc	onesecupdate
-	call	get_battery_voltage			; get battery voltage
+	call	menu_check_dive_and_timeout	; "Goto restart" or sets sleepmode flag
 
 	bcf		onesecupdate				; End of one second tasks
 
 	btfsc	sleepmode
 	goto	restart
 
-	btfsc	divemode
-	goto	restart						; exit menu, restart and enter divemode
-
 	bra		menu_loop	
 		
 check_switches_menu:                    ; checks switches
@@ -155,25 +143,13 @@
 	bra		menu							; exit setup menu and return to main menu
 
 	btfsc	onesecupdate
-	call	timeout_surfmode
-
-	btfsc	onesecupdate
-	call	set_dive_modes
-
-	btfsc	onesecupdate
-	call	test_charger				; check if charger IC is active
-
-	btfsc	onesecupdate
-	call	get_battery_voltage			; get battery voltage
+	call	menu_check_dive_and_timeout	; "Goto restart" or sets sleepmode flag
 
 	bcf		onesecupdate				; End of one second tasks
 
 	btfsc	sleepmode
 	bra		menu
 
-	btfsc	divemode
-	goto	restart						; exit menu, restart and enter divemode
-
 	bra		more_menu_loop	
 
 do_more_menu:								; calls submenu
@@ -219,23 +195,15 @@
 
 	btfss	menubit
 	goto	restart						; exit menu, restart and enter surfmode
-	btfsc	onesecupdate
-	call	timeout_surfmode
+
 	btfsc	onesecupdate
-	call	set_dive_modes
-	btfsc	onesecupdate
-	call	test_charger				; check if charger IC is active
-	btfsc	onesecupdate
-	call	get_battery_voltage			; get battery voltage
+	call	menu_check_dive_and_timeout	; "Goto restart" or sets sleepmode flag
 
 	bcf		onesecupdate				; End of one second tasks
 
 	btfsc	sleepmode
 	goto	restart						; exit menu, restart and enter surfmode
 
-	btfsc	divemode
-	goto	restart						; exit menu, restart and enter divemode
-
 	bra		setup_menu_loop	
 
 
@@ -378,22 +346,13 @@
 	goto	restart						; exit menu, restart and enter surfmode
 
 	btfsc	onesecupdate
-	call	timeout_surfmode
-	btfsc	onesecupdate
-	call	set_dive_modes
-	btfsc	onesecupdate
-	call	test_charger				; check if charger IC is active
-	btfsc	onesecupdate
-	call	get_battery_voltage			; get battery voltage
+	call	menu_check_dive_and_timeout	; "Goto restart" or sets sleepmode flag
 
 	bcf		onesecupdate				; End of one second tasks
 
 	btfsc	sleepmode
 	goto	setup_menu					; exit menu
 
-	btfsc	divemode
-	goto	restart						; exit menu, restart and enter divemode
-
 	bra		more_setup_menu_loop	
 
 do_more_setup_menu:								; calls submenu
@@ -576,3 +535,10 @@
 	bra		show_decotype3
 	DISPLAYTEXT	.130			; ON
 	return
+
+menu_check_dive_and_timeout:
+	call	set_dive_modes	; Check thresholds
+	call	timeout_surfmode	; Sets sleepmode flag if timeout
+	btfsc	divemode
+	goto	restart			; dive started!
+	return