changeset 576:ab2686087bce

faster font display, code cleaning
author heinrichsweikamp
date Sun, 22 Apr 2012 14:38:10 +0200
parents cbdcbbc91877
children e3ffc6d62a63
files code_part1/OSTC_code_asm_part1/altimeter.asm code_part1/OSTC_code_asm_part1/definitions.asm code_part1/OSTC_code_asm_part1/divemode_menu.asm code_part1/OSTC_code_asm_part1/english_text.asm code_part1/OSTC_code_asm_part1/french_text.asm code_part1/OSTC_code_asm_part1/german_text.asm code_part1/OSTC_code_asm_part1/menu.asm code_part1/OSTC_code_asm_part1/menu_battery.asm code_part1/OSTC_code_asm_part1/menu_custom.asm code_part1/OSTC_code_asm_part1/menu_gassetup.asm code_part1/OSTC_code_asm_part1/menu_logbook.asm code_part1/OSTC_code_asm_part1/menu_ppO2.asm code_part1/OSTC_code_asm_part1/menu_reset.asm code_part1/OSTC_code_asm_part1/menu_settime.asm code_part1/OSTC_code_asm_part1/oled_samsung.asm code_part1/OSTC_code_asm_part1/pled_outputs.asm code_part1/OSTC_code_asm_part1/russian_text.asm code_part1/OSTC_code_asm_part1/simulator.asm code_part1/OSTC_code_asm_part1/spanish_text.asm code_part1/OSTC_code_asm_part1/start.asm code_part1/OSTC_code_asm_part1/surfmode.asm code_part1/OSTC_code_asm_part1/turkish_text.asm
diffstat 22 files changed, 117 insertions(+), 200 deletions(-) [+]
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/altimeter.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/altimeter.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -300,8 +300,7 @@
 
 alt_menu_loop:
         call        PLED_menu_cursor    ; Display cursor
-    	bcf		    switch_left         ; reset buttons state
-    	bcf		    switch_right
+		call		wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 
 alt_menu_loop1:                         ; Wait for button.
     	btfsc	uart_dump_screen        ; Asked to dump screen contains ?
--- a/code_part1/OSTC_code_asm_part1/definitions.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/definitions.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -450,7 +450,7 @@
 #DEFINE	menubit2			flag3,0	; menu
 #DEFINE	menubit3			flag3,1	; menu
 #DEFINE	set_minutes			flag3,2	; set minutes (not hours)
-#DEFINE cursor				flag3,3	; display cursor
+;#DEFINE unused				flag3,3	;
 #DEFINE	menubit4			flag3,4	; quit set time 
 #DEFINE	display_velocity	flag3,5	; velocity is displayed
 #DEFINE	temp_changed		flag3,6	; temperature changed
--- a/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/divemode_menu.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -32,9 +32,8 @@
 
 	btfss	switch_right
 	return
-	
-	bcf		switch_left				; Left button pressed!
-	bcf		switch_right
+
+	call	wait_switches			; Waits until switches are released, resets flag if button stays pressed!
 	
 	bcf		select_bailoutgas		; Clear Flag for Bailout list
 
@@ -68,8 +67,7 @@
 	return
 
 test_switches_divemode2:
-	bcf		switch_left			; Also reactivate left button if there was a right press without prior left press
-	bcf		switch_right		; enable right button again
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 
 	btfsc	premenu
 	bra		test_switches_divemode2_2
@@ -101,8 +99,7 @@
 	call	PLED_divemode_menu_mask_first	; Write Divemode menu1 mask
 	bcf		display_set_simulator			; Clear Simulator-Menu flag
 	call	PLED_divemenu_cursor	; show cursor
-	bcf		switch_right
-	bcf		switch_left				; Left button pressed!
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 	return
 
 test_switches_divemode_menu:
@@ -161,8 +158,7 @@
 	return
 
 test_switches_divemode_menu3:
-	bcf		switch_left
-	bcf		switch_right
+	call	wait_switches			; Waits until switches are released, resets flag if button stays pressed!
 	bsf		menubit					; Enter Divemode-Menu!
 	bcf		premenu					; clear premenu flag
 	clrf	timeout_counter3
@@ -339,8 +335,7 @@
 divemode_menu_simulator:
 	bsf		menubit					; Enter Divemode-Menu!
 	bcf		premenu					; clear premenu flag
-	bcf		switch_right
-	bcf		switch_left				; Left button pressed!
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 	bsf		display_set_simulator	; Set Flag
 	bsf		menu3_active			; So "+1" is accessible at all times
 	call	PLED_clear_divemode_menu	; Clear Menu
@@ -742,8 +737,7 @@
 	bcf		display_set_simulator
 	bcf		display_set_active
 	bcf		menu3_active
-	bcf		switch_left				; and debounce switches
-	bcf		switch_right
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 	return
 
 ; Re-Draw current page of decoplan (may have more stops)
--- a/code_part1/OSTC_code_asm_part1/english_text.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/english_text.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -233,7 +233,7 @@
     TCODE    .85,   .125,    "Gauge"                     ;103 Gauge
     TCODE    .85,   .125,    "ZH-L16 CC"                 ;104 ZH-L16 CC
     TCODE    .0,    .0,      "Active Gas? "              ;105 Active Gas?
-    TCODE    .10,   .2,      "Gas Setup - Gaslist"	 ;106 Gas Setup - Gaslist
+    TCODE    .10,   .2,      "Gas Setup - Gaslist"	 	 ;106 Gas Setup - Gaslist
     TCODE    .20,   .95,     "Depth +/-:"                ;107 Depth +/-:
     TCODE    .20,   .125,    "Change:" 		             ;108 Change:
 	TCODE	 .20,	.155,	 "Default:"				  	 ;109 Default:
@@ -370,7 +370,7 @@
     TCODE    .0,    .0,      ""		                     ;233 unused
     TCODE    .0,    .0,      ""     	                 ;234 unused
 
-    TCODE    .10,   .2,      "Decomode changed!  "       ;235 Decomode changed!
+    TCODE    .10,   .2,      "Decomode changed!"       	 ;235 Decomode changed!
     TCODE    .85,   .125,    "L16-GF CC"                 ;236 L16-GF CC
     TCODE    .2,    .12,     "Not found"                 ;237 Not found
     TCODE    .100,  .0,      "SetPoint"                  ;238 SetPoint
@@ -446,7 +446,7 @@
     TCODE    .0,    .0,      "MOD:"                      ;297 MOD:                  (max operating depth of a gas).
     TCODE    .0,    .0,      "END:"                      ;298 END:                  (equivalent nitrogen depth of a gas).
     TCODE    .0,    .0,      "EAD:"                      ;299 EAD:                  (equivalent air depth of a gas).
-	TCODE    .100,  .125,	 "Active?"					 ;300 Active?               (Enable/Disable Gas underwater)
+	TCODE    .100,  .125,	 "More"						 ;300 More               	(Enable/Disable Gas underwater)
 	TCODE    .0,    .2,      "OCR Gas Usage:"            ;301 OCR Gas Usage:        (Planned gas consumtion by tank).
 ; 115k Bootloader support:
 	TCODE	 .45,	.100,	 "Bootloader"				 ;302 Bootloader
@@ -469,53 +469,53 @@
     TCODE    .103,  .155,    "High" 	                 ;313 High					(Same length as #312!)
 
 ; ZH-L16 mode description
-    TCODE    .0,    .35,     "Decotype: ZH-L16 OC"       ;314 Decotype: ZH-L16 OC
-    TCODE    .0,    .65,     "For Open Circuit   "       ;315 For Open Circuit
-    TCODE    .0,    .95,     "Divers. Supports 5 "       ;316 Divers. Supports 5
-    TCODE    .0,    .125,    "Trimix Gases.      "       ;317 Trimix Gases.
-    TCODE    .0,    .155,    "Configure your gas "       ;318 Configure your gas
-    TCODE    .0,    .185,    "in Gassetup menu.  "       ;319 in Gassetup menu.
-    TCODE    .0,    .215,    "Check CF11 & CF12 !"       ;320 Check CF11 & CF12 !
+    TCODE    .0,    .35,     "Decotype: ZH-L16 OC"      ;314 Decotype: ZH-L16 OC
+    TCODE    .0,    .65,     "For Open Circuit" 	    ;315 For Open Circuit
+    TCODE    .0,    .95,     "Divers. Supports 5"    	;316 Divers. Supports 5
+    TCODE    .0,    .125,    "Trimix Gases."       		;317 Trimix Gases.
+    TCODE    .0,    .155,    "Configure your gas"      	;318 Configure your gas
+    TCODE    .0,    .185,    "in Gassetup menu."      	;319 in Gassetup menu.
+    TCODE    .0,    .215,    "Check CF11 & CF12 !"      ;320 Check CF11 & CF12 !
 ; Gaugemode description
-    TCODE    .0,    .35,     "Decotype: Gauge    "       ;321 Decotype: Gauge    
-    TCODE    .0,    .65,     "Divetime will be in"       ;322 Divetime will be in
-    TCODE    .0,    .95,     "Minutes:Seconds.   "       ;323 Minutes:Seconds.   
-    TCODE    .0,    .125,    "OSTC2 will not     "       ;324 OSTC2 will not     
-    TCODE    .0,    .155,    "compute Deco, NoFly"       ;325 compute Deco, NoFly
-    TCODE    .0,    .185,    "time and Desat.    "       ;326 time and Desat.
-    TCODE    .0,    .215,    "time at all!       "       ;327 time at all!
+    TCODE    .0,    .35,     "Decotype: Gauge"      	;321 Decotype: Gauge    
+    TCODE    .0,    .65,     "Divetime will be in"      ;322 Divetime will be in
+    TCODE    .0,    .95,     "Minutes:Seconds."      	;323 Minutes:Seconds.   
+    TCODE    .0,    .125,    "OSTC2 will not"      		;324 OSTC2 will not     
+    TCODE    .0,    .155,    "compute Deco, NoFly"      ;325 compute Deco, NoFly
+    TCODE    .0,    .185,    "time and Desat."      	;326 time and Desat.
+    TCODE    .0,    .215,    "time at all!"      		;327 time at all!
 ; Const.ppO2 description
-    TCODE    .0,    .35,     "Decotype: ZH-L16 CC"       ;328 Decotype: ZH-L16 CC
-    TCODE    .0,    .65,     "For closed"       		 ;329 For closed
-    TCODE    .0,    .95,     "circuit rebreathers"       ;330 circuit rebreathers
-    TCODE    .0,    .125,    "Configure the 3    "       ;331 Configure the 3
-    TCODE    .0,    .155,    "SetPoints in CCR - "       ;332 SetPoints in CCR -
-    TCODE    .0,    .185,    "Setup menu. 5 bail-"       ;333 Setup menu. 5 bail-
-    TCODE    .0,    .215,    "outs are available."       ;334 outs are available.
+    TCODE    .0,    .35,     "Decotype: ZH-L16 CC"      ;328 Decotype: ZH-L16 CC
+    TCODE    .0,    .65,     "For closed"       		;329 For closed
+    TCODE    .0,    .95,     "circuit rebreathers"      ;330 circuit rebreathers
+    TCODE    .0,    .125,    "Configure the 3"      	;331 Configure the 3
+    TCODE    .0,    .155,    "SetPoints in CCR -"      	;332 SetPoints in CCR -
+    TCODE    .0,    .185,    "Setup menu. 5 bail-"      ;333 Setup menu. 5 bail-
+    TCODE    .0,    .215,    "outs are available."      ;334 outs are available.
 ; Apnoemode description
-    TCODE    .0,    .35,     "Decotype: Apnoe    "       ;335 Decotype: Apnoe
-    TCODE    .0,    .65,     "OSTC2 will display "       ;336 OSTC2 will display
-    TCODE    .0,    .95,     "each descent separ-"       ;337 each descent separ-
-    TCODE    .0,    .125,    "ately in Min:Sec.  "       ;338 ately in Min:Sec.
-    TCODE    .0,    .155,    "Will temporally set"       ;339 Will temporally set
-    TCODE    .0,    .185,    "samplerate to 1 sec"       ;340 samplerate to 1 sec
-    TCODE    .0,    .215,    "No Deco calculation"       ;341 No Deco calculation
+    TCODE    .0,    .35,     "Decotype: Apnoe"      	;335 Decotype: Apnoe
+    TCODE    .0,    .65,     "OSTC2 will display"	    ;336 OSTC2 will display
+    TCODE    .0,    .95,     "each descent separ-"      ;337 each descent separ-
+    TCODE    .0,    .125,    "ately in Min:Sec."      	;338 ately in Min:Sec.
+    TCODE    .0,    .155,    "Will temporally set"      ;339 Will temporally set
+    TCODE    .0,    .185,    "samplerate to 1 sec"      ;340 samplerate to 1 sec
+    TCODE    .0,    .215,    "No Deco calculation"      ;341 No Deco calculation
 ; Multi GF OC mode description
-    TCODE    .0,    .35,     "Decotype: L16-GF OC"       ;342 Decotype: L16-GF OC
-    TCODE    .0,    .65,     "Decompression cal- "       ;343 Decompression cal-
-    TCODE    .0,    .95,     "culations with the "       ;344 culations with the
-    TCODE    .0,    .125,    "GF-Method (GF_lo/GF"       ;345 GF-Method (GF_lo/GF
-    TCODE    .0,    .155,    "_hi). Check CF32 & "       ;346 _hi). Check CF32 &
-    TCODE    .0,    .185,    "CF33! Open Circuit "       ;347 CF33! Open Circuit
-    TCODE    .0,    .215,    "with Deep Stops.   "       ;348 with Deep Stops.
+    TCODE    .0,    .35,     "Decotype: L16-GF OC"      ;342 Decotype: L16-GF OC
+    TCODE    .0,    .65,     "Decompression cal-"       ;343 Decompression cal-
+    TCODE    .0,    .95,     "culations with the"       ;344 culations with the
+    TCODE    .0,    .125,    "GF-Method (GF_lo/GF"      ;345 GF-Method (GF_lo/GF
+    TCODE    .0,    .155,    "_hi). Check CF32 &"       ;346 _hi). Check CF32 &
+    TCODE    .0,    .185,    "CF33! Open Circuit"       ;347 CF33! Open Circuit
+    TCODE    .0,    .215,    "with Deep Stops."	  	    ;348 with Deep Stops.
 ; Multi GF CC mode description
-    TCODE    .0,    .35,     "Decotype: L16-GF CC"       ;349 Decotype: L16-GF CC
-    TCODE    .0,    .65,     "Decompression cal- "       ;350 Decompression cal-
-    TCODE    .0,    .95,     "culations with the "       ;351 culations with the
-    TCODE    .0,    .125,    "GF-Method (GF_lo/GF"       ;352 GF-Method (GF_lo/GF
-    TCODE    .0,    .155,    "_hi). Check CF32 & "       ;353 _hi). Check CF32 &
-    TCODE    .0,    .185,    "CF33!Closed Circuit"       ;354 CF33!Closed Circuit
-    TCODE    .0,    .215,    "with Deep Stops.   "       ;355 with Deep Stops.
+    TCODE    .0,    .35,     "Decotype: L16-GF CC"      ;349 Decotype: L16-GF CC
+    TCODE    .0,    .65,     "Decompression cal-"      	;350 Decompression cal-
+    TCODE    .0,    .95,     "culations with the"      	;351 culations with the
+    TCODE    .0,    .125,    "GF-Method (GF_lo/GF"      ;352 GF-Method (GF_lo/GF
+    TCODE    .0,    .155,    "_hi). Check CF32 &"       ;353 _hi). Check CF32 &
+    TCODE    .0,    .185,    "CF33!Closed Circuit"      ;354 CF33!Closed Circuit
+    TCODE    .0,    .215,    "with Deep Stops."       	;355 with Deep Stops.
 ; Spare (PSCR?)
     TCODE    .0,    .35,     ""     ;356
     TCODE    .0,    .65,     ""     ;357
--- a/code_part1/OSTC_code_asm_part1/french_text.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/french_text.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -446,7 +446,7 @@
     TCODE    .0,    .0,      "PMU:"                      ;297 MOD:                  (max operating depth of a gas).
     TCODE    .0,    .0,      "PEN:"                      ;298 END:                  (equivalent nitrogen depth of a gas).
     TCODE    .0,    .0,      "PEA:"                      ;299 EAD:                  (equivalent air depth of a gas).
-	TCODE	 .100,	.125,	 "Active?"					 ;300 Active?               (Enable/Disable Gas underwater)
+	TCODE    .100,  .125,	 "Suite"					 ;300 More               	(Enable/Disable Gas underwater)
 	TCODE    .0,    .2,      "OCR Gas Usage:"            ;301 OCR Gas Usage:        (Planned gas consumtion by tank).
 ; 115k Bootloader support:
 	TCODE	 .45,	.100,	 "Bootloader"				 ;302 Bootloader
--- a/code_part1/OSTC_code_asm_part1/german_text.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/german_text.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -446,7 +446,7 @@
     TCODE    .0,    .0,      "MOD:"                      ;297 MOD:                  (max operating depth of a gas).
     TCODE    .0,    .0,      "END:"                      ;298 END:                  (equivalent nitrogen depth of a gas).
     TCODE    .0,    .0,      "EAD:"                      ;299 EAD:                  (equivalent air depth of a gas).
-    TCODE    .100,  .125,	 "Aktiv?"			 		 ;300 Active?               (Enable/Disable Gas underwater)
+	TCODE    .100,  .125,	 "Mehr"						 ;300 More               	(Enable/Disable Gas underwater)
     TCODE    .0,    .2,      "OCR Gasverbrauch:"         ;301 OCR Gas Usage:        (Planned gas consumtion by tank).
 ; 115k Bootloader support:
 	TCODE	 .45,	.100,	 "Bootloader"				 ;302 Bootloader
--- a/code_part1/OSTC_code_asm_part1/menu.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -34,18 +34,10 @@
 	movlw	d'1'
 	movwf	menupos
 menu2:
-
-	bcf		leftbind
 	call	PLED_ClearScreen
-	clrf	timeout_counter2
-	bcf		sleepmode
-	bcf		menubit2
-	bcf		menubit3
-	bsf		menubit
-	bsf		cursor
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	PLED_menu_mask
 	call	PLED_menu_cursor
-	rcall	wait_switches
 
 menu_loop:
 	call	check_switches_menu
@@ -76,10 +68,10 @@
 	incf	menupos,F
 	movlw	d'6'
 	cpfsgt	menupos
-	bra		refresh_cursor
+	bra		refresh_cursor				; Returns
 	movlw	d'1'
 	movwf	menupos
-	bra		refresh_cursor
+	bra		refresh_cursor				; Returns
 check_switches_menu2:
 	btfsc	switch_left
 	bsf		menubit2					; Enter!
@@ -102,10 +94,8 @@
 
 refresh_cursor:
 	clrf	timeout_counter2
-	btfsc	cursor
 	call	PLED_menu_cursor
-	bcf		switch_right
-	bcf		switch_left
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 	return
 
 more_menu:
@@ -115,16 +105,9 @@
 	bcf		leftbind
 	call	PLED_ClearScreen
 more_menu3:
-	clrf	timeout_counter2
-	bcf		sleepmode
-	bcf		menubit2
-	bcf		menubit3
-	bsf		menubit
-	bsf		cursor
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	PLED_more_menu_mask
 	call	PLED_menu_cursor
-	bcf		switch_left
-	bcf		switch_right
 more_menu_loop:
 	call	check_switches_menu
 
@@ -176,16 +159,9 @@
 	call	PLED_ClearScreen
 	call	PLED_setup_menu_mask
 setup_menu3a:
-	clrf	timeout_counter2
-	bcf		sleepmode
-	bcf		menubit2
-	bcf		menubit3
-	bsf		menubit
-	bsf		cursor
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	show_decotype
 	call	PLED_menu_cursor
-	bcf		switch_left
-	bcf		switch_right
 
 setup_menu_loop:
 	call	check_switches_menu
@@ -314,19 +290,12 @@
 	call	PLED_ClearScreen
 	call	PLED_more_setup_menu_mask
 more_setup_menu3a:
-	clrf	timeout_counter2
-	bcf		sleepmode
-	bcf		menubit2
-	bcf		menubit3
-	bsf		menubit
-	bsf		cursor
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	show_debugstate
 	call	show_dateformat
 	call	show_salinity_value
 	call	PLED_menu_cursor
 	call	toggle_brightness_show
-	bcf		switch_left
-	bcf		switch_right
 
 more_setup_menu_loop:
 	call	check_switches_menu
@@ -542,3 +511,14 @@
 	btfsc	divemode
 	goto	restart			; dive started!
 	return
+
+menu_pre_loop_common:		; Clear some menu flags and the timeout
+	clrf	timeout_counter2
+	bcf		leftbind
+	bcf		sleepmode
+	bcf		menubit2
+	bcf		menubit3
+	bsf		menubit
+	bcf		switch_left
+	bcf		switch_right
+	return
--- a/code_part1/OSTC_code_asm_part1/menu_battery.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_battery.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -134,9 +134,8 @@
 	movff	EEDATA,convert_value_temp+2
 	call	PLED_convert_date		; coverts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
 	STRCAT_PRINT ") "
-	
-	bcf		switch_left
-	bcf		switch_right
+
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!	
 	bcf		menubit2
 menu_battery_state_loop:
 	call	check_switches_logbook
--- a/code_part1/OSTC_code_asm_part1/menu_custom.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_custom.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -204,7 +204,6 @@
 	movwf	menupos
 
 	bcf		menubit4
-	bcf		cursor
 	bcf		sleepmode
 	clrf	decodata+0				; here: # of CustomFunction
 	clrf	cf32_x4                 ; here: # of CustomFunction*4
--- a/code_part1/OSTC_code_asm_part1/menu_gassetup.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_gassetup.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -30,10 +30,7 @@
 menu_gassetup_prelist:
 	call	PLED_ClearScreen
 	call	gassetup_sort_gaslist			; Sorts Gaslist according to change depth
-	clrf	timeout_counter2
-	bcf		sleepmode
-	bcf		menubit2
-	bcf		menubit3
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	PLED_topline_box
 	WIN_INVERT	.1	; Init new Wordprocessor
 	DISPLAYTEXT	.106			; Gas List
@@ -277,7 +274,6 @@
 	movwf	menupos
 	bcf		gas_setup_page2			; Page 1 of gassetup
 	bcf		menubit4
-	bcf		cursor
 	bcf		sleepmode
 	bcf		first_FA				; Here: =1: -, =0: +
 
@@ -287,9 +283,7 @@
 	DISPLAYTEXT	.11			; Exit
 
 menu_gassetup1:
-	clrf	timeout_counter2
-	bcf		menubit2
-	bcf		menubit3
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 
 	rcall	gassetup_title_bar2			; Displays the title bar with the current Gas info
 
@@ -621,9 +615,7 @@
 	DISPLAYTEXT	.11			; Exit
 
 next_gas_page1:
-	clrf	timeout_counter2
-	bcf		menubit2
-	bcf		menubit3
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 
 	WIN_TOP		.65
 	WIN_LEFT	.20
--- a/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_logbook.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -206,13 +206,7 @@
 	
 	DISPLAYTEXT .11							; Displays "Exit" in the last row on the current page
 
-	bcf			sleepmode					; clear some flags for user input
-	bcf			menubit2
-	bcf			menubit3
-	bcf			cursor
-	bcf			switch_right
-	bcf			switch_left
-	clrf		timeout_counter2
+	call		menu_pre_loop_common		; Clear some menu flags, timeout and switches
 
 	movlw		d'1'						; Set cursor to position 1...
 	btfsc		return_from_profileview		; .. unless we are returning from a detail/profile view
@@ -824,13 +818,7 @@
 ; Done.
 profile_display_loop_done:
 	call		PLED_standard_color			; Restore color
-
-	bcf			sleepmode					; clear some flags
-	bcf			menubit2
-	bcf			menubit3
-	bcf			switch_right
-	bcf			switch_left
-	clrf		timeout_counter2
+	call		menu_pre_loop_common		; Clear some menu flags, timeout and switches
 
 display_profile_loop:
 	call		check_switches_logbook
@@ -996,15 +984,10 @@
 	bcf		leftbind
 	STRCAT_PRINT  TXT_VOLT1
 
-	bcf			leftbind					; Clear flag
 
 ;	call		I2CREAD2					; Skip Sampling rate
 
-	bcf			menubit2
-	bcf			menubit3
-	bcf			switch_right
-	bcf			switch_left
-	clrf		timeout_counter2
+	call		menu_pre_loop_common		; Clear some menu flags, timeout and switches
 display_profile2_loop:
 	call		check_switches_logbook
 	btfsc		menubit2					; SET/MENU?
--- a/code_part1/OSTC_code_asm_part1/menu_ppO2.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_ppO2.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -28,8 +28,6 @@
 	movwf	menupos
 
 	bcf		menubit4
-	bcf		cursor
-	bcf		sleepmode
 	clrf	decodata+0				; Here: # of SP
 	bcf		first_FA				; Here: =1: -, =0: +
 	bcf		second_FA				; Here: =1: 1, =0: 10 steps
@@ -44,10 +42,6 @@
 
 
 menu_const_ppO21:
-	clrf	timeout_counter2
-	bcf		menubit2
-	bcf		menubit3
-
 	WIN_LEFT 	.20
 	WIN_TOP		.35
 	lfsr	FSR2,letter
@@ -130,6 +124,7 @@
 
 	DISPLAYTEXT	.11			; Exit
 	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	PLED_menu_cursor
 
 menu_const_ppO2_loop:
@@ -167,12 +162,8 @@
 	movwf	menupos
 
 menu_const_ppO23:
-	clrf	timeout_counter2
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	PLED_menu_cursor
-	
-	; debounce switches
-	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!	
-	bcf		menubit3		; clear flag
 	bra		menu_const_ppO2_loop
 
 do_menu_const_ppO2:
@@ -231,7 +222,7 @@
 
 	movlw	d'4'
 	movwf	menupos
-	bra	menu_const_ppO21
+	bra		menu_const_ppO21
 
 change_ppo2_reset:				; reset to 1.00Bar
 	movf	decodata+0,W		; read current value 
@@ -253,4 +244,4 @@
 next_ppO22:	
 	movlw	d'1'
 	movwf	menupos
-	bra	menu_const_ppO21	
\ No newline at end of file
+	bra		menu_const_ppO21	
\ No newline at end of file
--- a/code_part1/OSTC_code_asm_part1/menu_reset.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_reset.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -238,16 +238,9 @@
 	call	PLED_reset_menu_mask
 
 menu_reset2:
-	clrf	timeout_counter2
-	bcf		sleepmode
-	bcf		menubit2
-	bcf		menubit3
-	bsf		menubit
-	bsf		cursor
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	PLED_reset_menu_mask
 	call	PLED_menu_cursor
-	bcf		switch_left
-	bcf		switch_right
 menu_reset_loop:
 	call	check_switches_menu
 	btfsc	menubit2
--- a/code_part1/OSTC_code_asm_part1/menu_settime.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/menu_settime.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -26,14 +26,10 @@
 
 menu_settime:
 	call	PLED_ClearScreen
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 
 	bcf		set_minutes
 	bcf		menubit4
-	bcf		cursor
-	clrf	timeout_counter2
-	bcf		menubit2
-	bcf		menubit3
-	bcf		sleepmode
 	bcf		set_year
 	bcf		set_day
 	bcf		set_month
@@ -50,9 +46,6 @@
 
 	DISPLAYTEXT	.24			; Set Hours
 	
-	bcf		switch_right
-	bcf		switch_left
-
 settime_loop:
 	btfsc	switch_right
 	call	add_hours_or_minutes_or_date
@@ -223,7 +216,7 @@
 	return
 	
 add_hours_or_minutes_or_date:
-	bcf		switch_left
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 	clrf	secs
 
 	btfsc	set_year
--- a/code_part1/OSTC_code_asm_part1/oled_samsung.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/oled_samsung.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -204,11 +204,13 @@
 ;
 AA_CMD_WRITE macro cmd
 		movlw	cmd
-		rcall   PLED_CmdWrite
-;		bcf		oled_rs				    ; Cmd mode
-;		movwf	PORTD,A
-;		bcf		oled_rw				    ; Tick the clock
-;		bsf		oled_rw
+;		rcall   PLED_CmdWrite			; slow but saves a lot of bytes in flash
+	; /* Fast writing
+		bcf		oled_rs				    ; Cmd mode
+		movwf	PORTD,A
+		bcf		oled_rw				    ; Tick the clock
+		bsf		oled_rw
+	; Fast writing */
 		endm
 ;
 ; Input	 : data as macro parameter.
@@ -225,14 +227,16 @@
 ; Trash  : NONE
 ;
 AA_DATA_WRITE_PROD	macro
-        rcall   PLED_DataWrite_PROD
-;		bsf		oled_rs				    ; Data mode
-;		movff	PRODH,PORTD			    ; NOTE: OLED is BIGENDIAN!
-;		bcf		oled_rw				    ; Tick the clock
-;		bsf		oled_rw
-;		movff	PRODL,PORTD
-;		bcf		oled_rw				    ; Tick the clock
-;		bsf		oled_rw
+;       rcall   PLED_DataWrite_PROD	; slow but saves a lot of bytes in flash
+	; /* Fast writing
+		bsf		oled_rs				    ; Data mode
+		movff	PRODH,PORTD			    ; NOTE: OLED is BIGENDIAN!
+		bcf		oled_rw				    ; Tick the clock
+		bsf		oled_rw
+		movff	PRODL,PORTD
+		bcf		oled_rw				    ; Tick the clock
+		bsf		oled_rw
+	; Fast writing */
 		endm
 
 ;=============================================================================
--- a/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/pled_outputs.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -373,7 +373,7 @@
 	output_8		
 	call	word_processor
 
-	bcf		switch_left	
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 PLED_resetdebugger_loop:
     bcf     LED_blue            ; Blink blue led every seconds..
     btfss   secs,0
@@ -383,7 +383,7 @@
 	bra		PLED_resetdebugger_loop		; Loop
 
     bcf     LED_blue
-	bcf		switch_left	
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 	return
 
 PLED_divemode_mask:					; Displays mask in Dive-Mode
--- a/code_part1/OSTC_code_asm_part1/russian_text.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/russian_text.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -449,7 +449,7 @@
     TCODE    .0,    .0,      "MOD:"                      ;297 MOD:                  (max operating depth of a gas).
     TCODE    .0,    .0,      "END:"                      ;298 END:                  (equivalent nitrogen depth of a gas).
     TCODE    .0,    .0,      "EAD:"                      ;299 EAD:                  (equivalent air depth of a gas).
-	TCODE	 .100,	.125,	 "Âêëþ÷åí?"   				 ;300 Active?               (Enable/Disable Gas underwater)
+	TCODE    .100,  .125,	 "Äàëåå"					 ;300 More               	(Enable/Disable Gas underwater)
 	TCODE    .0,    .2,      "Ðàñõîä OCR ãàçîâ:"         ;301 OCR Gas Usage:        (Planned gas consumtion by tank).
 ; 115k Bootloader support:
 	TCODE	 .45,	.100,	 "Çàãðóç÷èê"				 ;302 Bootloader
--- a/code_part1/OSTC_code_asm_part1/simulator.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/simulator.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -45,18 +45,12 @@
     movff   WREG,char_I_dive_interval
 
 menu_simulator1:
-	clrf	timeout_counter2
-	bsf		menubit
-	bsf		cursor
 	call	PLED_brightness_full			;max. brightness
 	call	PLED_ClearScreen
 	call	PLED_simulator_mask
 
 menu_simulator2:
-	bcf		switch_left
-	bcf		switch_right
-	bcf		menubit2
-	bcf		menubit3
+	call	menu_pre_loop_common		; Clear some menu flags, timeout and switches
 	call	PLED_simulator_data
 	call	PLED_menu_cursor
 
@@ -160,8 +154,7 @@
 	bcf		menubit2
 	bcf		menubit3
 	bcf		menubit
-	bcf		switch_left
-	bcf		switch_right
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 
 	call	simulator_save_tissue_data  ; Stores 32 floats "pre_tissue" into bank3
 
@@ -235,8 +228,7 @@
         WIN_INVERT	.0                  ; Init new Wordprocessor	
 	
 simulator_show_decoplan1:
-        bcf		switch_left
-        bcf		switch_right
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 simulator_show_decoplan2:
 	btfsc	uart_dump_screen        ; Asked to dump screen contains ?
 	call	dump_screen             ; Yes!
--- a/code_part1/OSTC_code_asm_part1/spanish_text.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/spanish_text.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -445,7 +445,7 @@
     TCODE    .0,    .0,      "MOD:"                      ;297 MOD:                  (max operating depth of a gas).
     TCODE    .0,    .0,      "END:"                      ;298 END:                  (equivalent nitrogen depth of a gas).
     TCODE    .0,    .0,      "EAD:"                      ;299 EAD:                  (equivalent air depth of a gas).
-	TCODE	 .100,	.125,	 "¿Activar?"				 ;300 Active?               (Enable/Disable Gas underwater)
+	TCODE    .100,  .125,	 "Más"						 ;300 More               	(Enable/Disable Gas underwater)
 	TCODE    .0,    .2,      "Uso Gas OCR:"              ;301 OCR Gas Usage:        (Planned gas consumtion by tank).
 ; 115k Bootloader support:
 	TCODE	 .45,	.100,	 "CargadorArr"				 ;302 Bootloader
--- a/code_part1/OSTC_code_asm_part1/start.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/start.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -362,8 +362,7 @@
 	movlw	d'10'					; timeout for startup screen
 	movwf	temp1			
 	WAITMS	d'200'
-	bcf		switch_left
-	bcf		switch_right
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 screen1_loop:
 	btfsc	uart_dump_screen                ; Asked to dump screen contains ?
 	call	dump_screen     			    ; Yes!
@@ -395,8 +394,7 @@
 startup_screen3a:; WARNING: Also used for decodescriptions and CF Warning screen!
 	movwf	temp1			
 	WAITMS	d'200'
-	bcf		switch_left
-	bcf		switch_right
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 screen3_loop:
 	btfsc	uart_dump_screen                ; Asked to dump screen contains ?
 	call	dump_screen     			    ; Yes!
--- a/code_part1/OSTC_code_asm_part1/surfmode.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/surfmode.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -444,7 +444,7 @@
 	return
 
 test_switches_surfmode2:
-	bcf		switch_left
+	call	wait_switches		; Waits until switches are released, resets flag if button stays pressed!
 	btfss	premenu
 	bra		test_switches_surfmode4
 	bsf		menubit					; Enter Menu!
--- a/code_part1/OSTC_code_asm_part1/turkish_text.asm	Sat Apr 21 15:08:09 2012 +0200
+++ b/code_part1/OSTC_code_asm_part1/turkish_text.asm	Sun Apr 22 14:38:10 2012 +0200
@@ -448,7 +448,7 @@
     TCODE    .0,    .0,      "MOD:"                      ;297 MOD:                  (max operating depth of a gas).
     TCODE    .0,    .0,      "END:"                      ;298 END:                  (equivalent nitrogen depth of a gas).
     TCODE    .0,    .0,      "EAD:"                      ;299 EAD:                  (equivalent air depth of a gas).
-    TCODE    .100,  .125,    "Aktif?"	 		 ;300 Active?               (Enable/Disable Gas underwater)
+	TCODE    .100,  .125,	 "Daha"						 ;300 More               	(Enable/Disable Gas underwater)
     TCODE    .0,    .2,      "OCR Gaz kullanim:"         ;301 OCR Gas Usage:        (Planned gas consumtion by tank).
 ; 115k Bootloader support:
    TCODE    .45,   .100,     "Yükleniyor"		 ;302 Bootloader