changeset 300:5ad479f2a868

Merged Screen layout mod #1 into Screen layout work #3
author Janos Kovacs <kovjanos@gmail.com>
date Sun, 31 May 2015 21:24:16 +0200
parents 6c4800af27ac
children 4e803c136972
files src/compass_ops.asm src/convert.asm src/convert.inc src/customview.asm src/divemode.inc src/hwos.inc src/menu_processor.asm src/surfmode.inc src/text_english.inc src/text_french.inc src/text_german.inc src/text_italian.inc src/tft_outputs.asm
diffstat 13 files changed, 768 insertions(+), 409 deletions(-) [+]
line wrap: on
line diff
--- a/src/compass_ops.asm	Sun May 31 20:25:12 2015 +0200
+++ b/src/compass_ops.asm	Sun May 31 21:24:16 2015 +0200
@@ -397,7 +397,7 @@
 
     global  TFT_dive_compass_mask
 TFT_dive_compass_mask:
-    WIN_FRAME_STD   dive_compass_graph_row, dive_compass_graph_row+dive_compass_graph_height, .0, .159
+    WIN_FRAME_STD   dm_custom_compass_graph_row, dm_custom_compass_graph_row+dm_custom_compass_graph_height, .0, .159
     return
 
     global  TFT_surface_compass_heading
@@ -1085,14 +1085,14 @@
     btfsc   compass_bearing_lft
     bra     TFT_dive_compass_dir_ldir      ; bearing_lft=1, print the left marker
 ;TFT_dive_compass_text_rdir:
-    WIN_SMALL   dive_compass_rdir_column,dive_compass_head_row
+    WIN_SMALL   dm_custom_compass_rdir_column, dm_custom_compass_head_row
     STRCPY_PRINT    ">>"
     ; do not forget to clear the left
     rcall    TFT_dive_compass_dir_lclr
     bra     TFT_dive_compass_text
 
 TFT_dive_compass_dir_ldir:
-    WIN_SMALL   dive_compass_ldir_column,dive_compass_head_row
+    WIN_SMALL   dm_custom_compass_ldir_column, dm_custom_compass_head_row
     STRCPY_PRINT    "<<"
     ; do not forget to clear the right
     rcall    TFT_dive_compass_dir_rclr
@@ -1101,17 +1101,17 @@
 TFT_dive_compass_text:
     ; Text output
     call    TFT_standard_color
-    WIN_SMALL   dive_compass_head_column,dive_compass_head_row
+    WIN_SMALL   dm_custom_compass_head_column, dm_custom_compass_head_row
     rcall   TFT_surface_compass_heading_com  ; Show "000° N"
     return
 
 TFT_dive_compass_dir_lclr:
-    WIN_SMALL   dive_compass_ldir_column,dive_compass_head_row
+    WIN_SMALL   dm_custom_compass_ldir_column, dm_custom_compass_head_row
     STRCPY_PRINT    "  "
     return
 
 TFT_dive_compass_dir_rclr:
-    WIN_SMALL   dive_compass_rdir_column,dive_compass_head_row
+    WIN_SMALL   dm_custom_compass_rdir_column, dm_custom_compass_head_row
     STRCPY_PRINT    "  "
     return
 
@@ -1163,7 +1163,7 @@
     call    TFT_standard_color
     bsf     print_compass_label
 ;TFT_dive_compass_label_print:
-    movlw   dive_compass_label_row
+    movlw   dm_custom_compass_label_row
     movff   WREG,win_top
     movff   lo,win_leftx2
     movlw   FT_SMALL
@@ -1252,14 +1252,14 @@
 ;    return
 TFT_dive_compass_mk_print_3:
     movff   WREG,win_leftx2
-    movlw   dive_compass_label_row
+    movlw   dm_custom_compass_label_row
     movff   WREG,win_top
-    movlw   dive_compass_label_height-.2
+    movlw   dm_custom_compass_label_height-.2
     movff   WREG,win_height
     bra     TFT_dive_compass_mk_print_4
 TFT_dive_compass_mk_print_dot:
     movff   WREG,win_leftx2
-    movlw   dive_compass_label_row + .9
+    movlw   dm_custom_compass_label_row + .9
     movff   WREG,win_top
     movlw   d'4'
     movff   WREG,win_height
@@ -1275,24 +1275,24 @@
     return
 
 TFT_dive_compass_clr_label:
-    movlw   dive_compass_label_row-.2     ; set top & height
+    movlw   dm_custom_compass_label_row-.2     ; set top & height
     movff   WREG,win_top
-    movlw   dive_compass_label_height+.2
+    movlw   dm_custom_compass_label_height+.2
     movff   WREG,win_height
     rcall   TFT_dive_compass_clear
     return
 
 TFT_dive_compass_clr_ruler:
     ; top tick
-    movlw   dive_compass_tick_top_top     ; set top & height
+    movlw   dm_custom_compass_tick_top_top     ; set top & height
     movff   WREG,win_top
-    movlw   dive_compass_tick_height
+    movlw   dm_custom_compass_tick_height
     movff   WREG,win_height
     rcall    TFT_dive_compass_clear
     ;bottom tick
-    movlw   dive_compass_tick_bot_top     ; set top & height
+    movlw   dm_custom_compass_tick_bot_top     ; set top & height
     movff   WREG,win_top
-    movlw   dive_compass_tick_height
+    movlw   dm_custom_compass_tick_height
     movff   WREG,win_height
 ;    rcall   TFT_dive_compass_clear
 ;    return
@@ -1313,9 +1313,9 @@
 
 TFT_dive_compass_ruler_print:
     ; we receive RM in lo and DD in hi
-    movlw   dive_compass_tick_top_top
+    movlw   dm_custom_compass_tick_top_top
     movff   WREG,win_top
-    movlw   dive_compass_tick_height
+    movlw   dm_custom_compass_tick_height
     movff   WREG,win_height
     movlw   d'2'
     movff   WREG,win_width
@@ -1323,9 +1323,9 @@
     movff   lo,win_leftx2          ; 0..159
     call    TFT_standard_color
     call    TFT_box
-    movlw   dive_compass_tick_bot_top
+    movlw   dm_custom_compass_tick_bot_top
     movff   WREG,win_top
-    movlw   dive_compass_tick_height
+    movlw   dm_custom_compass_tick_height
     movff   WREG,win_height
     call    TFT_standard_color  ; color in WREG is trashed, must be set again!
     call    TFT_box
@@ -1333,7 +1333,7 @@
 
 TFT_dive_compass_cline:
    	movlw   color_yellow
-    WIN_BOX_COLOR     dive_compass_tick_top_top,dive_compass_tick_bot_bot,.80,.81
+    WIN_BOX_COLOR     dm_custom_compass_tick_top_top, dm_custom_compass_tick_bot_bot,.80,.81
     return
 
 tft_compass_cardinal:
--- a/src/convert.asm	Sun May 31 20:25:12 2015 +0200
+++ b/src/convert.asm	Sun May 31 21:24:16 2015 +0200
@@ -28,6 +28,7 @@
 #define DP_done2        cvt_flags2,3
 #define show_last3      cvt_flags2,4
 #define leading_zeros   cvt_flags2,5
+#define show_last4      cvt_flags2,6
 
 basic   CODE
 
@@ -93,6 +94,31 @@
 	rcall	DEC2ASCII
 	bra		LCD_val99_2			
 
+	global	output16_4_call
+output16_4_call:                ; limit to 9999
+	bsf		show_last4
+    ; 9999 = 27 0F = [39][15]
+    movlw   .40
+    cpfslt  hi                  ; hi < 40 ?
+    bra     output16_4_call_2   ; No, hi >= 40, do limit
+    ; Yes, hi <= 39
+    movlw   .39
+    cpfseq  hi                  ; hi = 39 ?
+    bra     output16_4_call_3   ; No, hi < 39, no limit needed
+    ; Yes, hi = 39
+    movlw   .15
+    cpfslt  lo                  ; lo < 15
+    movwf   lo                  ; No, lo >= 15, set lo = 15.
+    ; Yes, lo <= 14 or lo set to =15
+    bra     output16_4_call_3   ; done.
+output16_4_call_2:  ; Set to 9999
+    movlw   LOW     .9999
+    movwf   lo
+    movlw   HIGH    .9999
+    movwf   hi
+output16_4_call_3:
+    bra     output16_call
+
 	global	output16_3_call
 	global	output16_call
 	global	output16
@@ -140,9 +166,14 @@
 	movwf	temp2		 
 	movlw	b'00100111'
 	movwf	temp3		 
-	btfss	show_last3		; display only last three figures?
+	btfsc	show_last3		; display only last three figures?
+    bra     output16_sk5
+	btfsc	show_last4		; display only last four figures?
+    bra     output16_sk5
 	rcall	DEC2ASCII		; No, show all. Here: 5th order digit
-	
+
+output16_sk5:
+    bcf     show_last4
 	movlw	b'11101000'	; 1000s
 	movwf	temp2		 
 	movlw	b'00000011'
--- a/src/convert.inc	Sun May 31 20:25:12 2015 +0200
+++ b/src/convert.inc	Sun May 31 21:24:16 2015 +0200
@@ -16,6 +16,11 @@
 	call 	output16_3_call
 	endm
 
+    extern  output16_4_call
+output_16_4 macro			; displays only last four figures from a 16Bit value (0-9999)
+	call 	output16_4_call
+	endm
+
     extern  output16
 output_16dp macro temp4		; 16Bit with decimal point
 	movlw	temp4			; Temp4 stores position for decimal point
--- a/src/customview.asm	Sun May 31 20:25:12 2015 +0200
+++ b/src/customview.asm	Sun May 31 21:24:16 2015 +0200
@@ -250,16 +250,16 @@
 	clrf	menupos2
     bcf     menuview
 menuview_mask:
-    WIN_BOX_BLACK   divemode_simtext_row, divemode_simtext_row+.24, divemode_simtext_column, divemode_simtext_column+.49    ; top, bottom, left, right
+    WIN_BOX_BLACK   dm_simtext_row, dm_simtext_row+.23, dm_simtext_column, dm_simtext_column+.49 ; top, bottom, left, right
     btfss   FLAG_gauge_mode
     bra     menuview_mask2
-    ; Clear some more in gauge mode
-    WIN_BOX_BLACK   divemode_simtext_row, divemode_simtext_row+.24, divemode_simtext_column+.50, divemode_simtext_column+.70    ; top, bottom, left, right
+    ; Clear some more in gauge mode  --
+    WIN_BOX_BLACK   dm_simtext_row, dm_simtext_row+.23, dm_simtext_column+.50, dm_simtext_column+.70  ; top, bottom, left, right
 menuview_mask2:
     movlw   color_yellow
     call	TFT_set_color
     bsf     win_invert                  ; Set invert flag
-    WIN_SMALL   divemode_simtext_column,divemode_simtext_row
+    WIN_SMALL   dm_simtext_column,dm_simtext_row
 	movff	menupos2,WREG                   ; Menupos2 holds number of menu option to show
 	dcfsnz	WREG,F
 	bra		menuview_view_gaschange         ; If a better gas is indicated
@@ -365,7 +365,7 @@
     global  customview_mask
 customview_mask:	
 	call	TFT_clear_customview_divemode	
-	WIN_SMALL	divemode_customview_column,divemode_customview_row
+	WIN_SMALL	dm_customview_column,dm_customview_row
 	call	TFT_standard_color
 	movff	menupos3,WREG                   ; Menupos3 holds number of customview function
 	dcfsnz	WREG,F
--- a/src/divemode.inc	Sun May 31 20:25:12 2015 +0200
+++ b/src/divemode.inc	Sun May 31 21:24:16 2015 +0200
@@ -8,218 +8,338 @@
 ; HISTORY
 ;  2011-08-15 : [mH] moving from OSTC code
 
- 	extern 	set_dive_modes
- 	extern	diveloop
-	extern	apnoe_calc_maxdepth
+    extern    set_dive_modes
+    extern    diveloop
+    extern    apnoe_calc_maxdepth
 
 ; Divemode layout:
 ; row=0...239
 ; column=0...159 (x2)
 
-#DEFINE	depth_row			.14
-#DEFINE	depth_column		.0
-#DEFINE	depth_feet_row		depth_row
-#DEFINE	depth_feet_column	.0
-#DEFINE	depth_dm_row		depth_row+.25
-#DEFINE	depth_dm_column		.40
+; Divemode has multiple layouts but basicly splits the screen into 3 rows:
+;   - upper content row: depth, max depth, dive time, etc.
+;   - custom content view with selectable views
+;   - bottom content: temp, gas, ndl, tts, etc.
+
+; I. The upper conent row. (0-99)
+;   The top row can be divided 2 areas: 
+;    - header: has the titles (mask)
+;    - content: has the values
+;******* Upper content / header row *******
+#DEFINE    dm_mask_depth_row         .0
+#DEFINE    dm_mask_depth_column      .12
+#DEFINE    dm_mask_maxdepth_row      .0
+#DEFINE    dm_mask_maxdepth_column   .62
+#DEFINE    dm_mask_divetime_row      .0
+#DEFINE    dm_mask_divetime_column   .122
 
-#DEFINE	max_depth_row           depth_row
-#DEFINE	max_depth_column        .64
-#DEFINE	max_depth_dm_column     .87
-#DEFINE max_depth_dm_row        depth_row+.12
-#DEFINE	max_depth_feet_row		max_depth_row
-#DEFINE	max_depth_feet_column	.64
+;   The content row contains 3 columns:
+;    - depth and ascend rate warning
+;    - max depth and warning messages
+;    - dive time, apnea dive times and warning icon
+;   DIVEMODE_OFFSET=position below the title row
+;******* Upper content / content row / 1st col *******
+; GLOBAL
+#DEFINE    dm_offset              .14                    ; 14
+; Depth
+#DEFINE    dm_depth_row           dm_offset              ; TOP  - 14 - start position of the detph numbers
+#DEFINE    dm_depth_column        .0                     ; LEFT - 0
+#DEFINE    dm_depth_bot           dm_depth_row+.61       ; 75
+#DEFINE    dm_depth_rgt           dm_depth_column+.61    ; 61
+#DEFINE    dm_depth_dm_row        dm_depth_row+.25       ; 39 - if metric and d<100, decimeter shown as: ".5"
+#DEFINE    dm_depth_dm_column     dm_depth_column+.40    ; 40 - bottom aligned so it has its own position (2nd content line only)
+; Ascend rate
+#DEFINE    dm_velocity_text_row        dm_depth_row+.62             ; 76
+#DEFINE    dm_velocity_text_column     dm_depth_column              ; 0
+#DEFINE    dm_velocity_text_bot        dm_velocity_text_row+.23     ; 99
+#DEFINE    dm_velocity_text_rgt        dm_depth_rgt                 ; 61
 
-#DEFINE	divetime_row            depth_row
-#DEFINE	divetime_column             .103        ; Mins:Secs
-#DEFINE divetime_minsonly_column    .100        ; Minutes only
-#DEFINE divetime_secs_column    .139
-#DEFINE divetime_secs_row       depth_row+.12
-#DEFINE	divetime_apnoe_row		depth_row
-#DEFINE	divetime_apnoe_column	.103
-#DEFINE apnoe_total_divetime_row            divetime_apnoe_row+.50
-#DEFINE apnoe_total_divetime_column         divetime_apnoe_column
-#DEFINE apnoe_total_divetime_secs_row       apnoe_total_divetime_row+.12
-#DEFINE apnoe_total_divetime_secs_column    divetime_secs_column
-#DEFINE total_apnoe_text_column             .132
-#DEFINE total_apnoe_text_row                apnoe_total_divetime_row-.14
+;******* Upper content / content row / 2nd col *******
+; Max depth
+#DEFINE    dm_max_depth_row           dm_offset                 ; 14
+#DEFINE    dm_max_depth_column        .64                       ; 64
+#DEFINE    dm_max_depth_bot           dm_max_depth_row+.34      ; 48
+#DEFINE    dm_max_depth_rgt           dm_max_depth_column+.36   ; 100
+#DEFINE    dm_max_depth_dm_row        dm_max_depth_row+.11      ; 25
+#DEFINE    dm_max_depth_dm_column     dm_max_depth_column+.23   ; 87
+; Warning area (combined)
+#DEFINE    dm_warning_row             dm_offset+.36             ; 50
+#DEFINE    dm_warning_column          .64                       ; 64
+#DEFINE    dm_warning_bot             dm_warning_row+.49        ; 99
+#DEFINE    dm_warning_rgt             dm_warning_column+.68     ; 130
+#DEFINE    dm_warning_length          .9                        ; total string length
+; Warning row #1
+#DEFINE    dm_warning1_row            dm_warning_row            ; 36/50
+#DEFINE    dm_warning1_column         dm_warning_column         ; 64
+#DEFINE    dm_warning1_bot            dm_warning1_row+.23       ; 59/73
+#DEFINE    dm_warning1_rgt            dm_warning1_column+.68    ; 130
+; Warning row #2
+#DEFINE    dm_warning2_row            dm_warning_row+.24        ; 60/74
+#DEFINE    dm_warning2_column         dm_warning_column         ; 64
+#DEFINE    dm_warning2_bot            dm_warning2_row+.23       ; 83/97
+#DEFINE    dm_warning2_rgt            dm_warning2_column+.68    ; 130
+
+;******* Upper content / content row / 3rd col *******
+; Dive time
+#DEFINE    dm_divetime_row                dm_offset              ; 14
+#DEFINE    dm_divetime_column             .115                   ; 115
+#DEFINE    dm_divetime_minsonly_column    .113                   ; 113
+#DEFINE    dm_divetime_bot                dm_divetime_row+.34    ; 48
+#DEFINE    dm_divetime_rgt                .159                   ; 159
+#DEFINE    dm_divetime_secs_row           dm_divetime_row+.11    ; 25
+#DEFINE    dm_divetime_secs_column        dm_divetime_column+.24 ; 139
+; Warning icon
+#DEFINE    dm_warning_icon_row            dm_offset+.41                ; 55
+#DEFINE    dm_warning_icon_column         .135                         ; 135
+#DEFINE    dm_warning_icon_bot            dm_warning_icon_row+.38      ; 93
+#DEFINE    dm_warning_icon_rgt            dm_warning_icon_column+.21   ; 156
+; Apnea dive time
+#DEFINE    dm_divetime_apnoe_row                  dm_offset                        ; 14
+#DEFINE    dm_divetime_apnoe_column               .103                             ; 103
+#DEFINE    dm_divetime_apnoe_secs_row             dm_divetime_apnoe_row+.11        ; 25
+#DEFINE    dm_divetime_apnoe_secs_column          dm_divetime_apnoe_column+.36     ; 139
+; Apnea total time
+#DEFINE    dm_apnoe_total_divetime_row            dm_divetime_apnoe_row+.50        ; 64
+#DEFINE    dm_apnoe_total_divetime_column         dm_divetime_apnoe_column         ; 103
+#DEFINE    dm_apnoe_total_divetime_secs_row       dm_apnoe_total_divetime_row+.11  ; 75
+#DEFINE    dm_apnoe_total_divetime_secs_col       dm_divetime_apnoe_column+.36     ; 139
+#DEFINE    dm_total_apnoe_text_row                dm_apnoe_total_divetime_row-.11  ; 53
+#DEFINE    dm_total_apnoe_text_column             .132                             ; 132
+; I. End of the upper conent row. (0-99)
+
+
+
+; 1px space between the 1st and 2nd content rows
+#DEFINE    dm_sep_1_2_row    dm_offset+.86         ; 100
+
 
 
-#DEFINE divemode_mask_depth_row         .0
-#DEFINE divemode_mask_depth_column      .12
-#DEFINE divemode_mask_maxdepth_row      .0
-#DEFINE divemode_mask_maxdepth_column   .62
-#DEFINE divemode_mask_divetime_row      .0
-#DEFINE divemode_mask_divetime_column   .122
-
-#DEFINE surface_apnoe_text_row      .190
-#DEFINE surface_apnoe_text_column   .30
-#DEFINE	surface_time_apnoe_row		.204
-#DEFINE	surface_time_apnoe_column	.15
-
-#DEFINE last_max_apnoe_text_row     .190
-#DEFINE last_max_apnoe_text_column  .100
-#DEFINE apnoe_last_max_depth_row	.204
-#DEFINE	apnoe_last_max_depth_column	.100
+; II. Custom/selectable content row
+;   The costume view display area is:  101,163,0,159 (t,b,l,r), or 0,101->159,163
+;   1. Stopwatch with avarage depth
+;   2. Decoplan - decompression stops up to 6 stops
+;   3. Time, EAD/END and tissue saturation (graph)
+;   4. GF and aGF pairs
+;   5. Compass
+;   6. HUD - 3 sensor readings
+;   7. Gas list
+;   8. Ceiling (for GF_hi)
+;******* Custom content / Global *******
+#DEFINE    dm_customview_row              dm_offset+.87             ; 101
+#DEFINE    dm_customview_column           .0                        ; 0
+#DEFINE    dm_customview_bot              dm_customview_row+.62     ; 163
+#DEFINE    dm_customview_rgt              .159                      ; 159
 
-#DEFINE	dive_temp_row		.163
-#DEFINE	dive_temp_column	.2
-
-; TTS
-#DEFINE	tts_text_row		.211
-#DEFINE	tts_text_column     .85
-#DEFINE	tts_value_row		.207
-#DEFINE	tts_value_column	.118
+;******* Custom content / #1 - Avg depth, stopwatch and avg depth *******
+; Title
+#DEFINE    dm_custom_avr_stop_title_row         dm_customview_row+.1      ; 102
+#DEFINE    dm_custom_avr_stop_title_column1     .2                        ; 2
+#DEFINE    dm_custom_avr_stop_title_column2     .57                       ; 57
+#DEFINE    dm_custom_avr_stop_title_column3     .110                      ; 110
+; Values
+#DEFINE    dm_custom_avr_stop_row               dm_customview_row+.16     ; 117
+#DEFINE    dm_custom_avr_stop_column1           .0                        ; 0
+#DEFINE    dm_custom_avr_stop_column2           .54                       ; 54
+#DEFINE    dm_custom_avr_stop_column3           .118                      ; 118
 
-#DEFINE	ndl_text_row		tts_text_row
-#DEFINE	ndl_text_column     tts_text_column
-#DEFINE	ndl_value_row		tts_value_row
-#DEFINE	ndl_value_column	tts_value_column
-
-#DEFINE	active_gas_row		.210
-#DEFINE	active_gas_column	.1
-#DEFINE active_dil_row      .186
-#DEFINE active_dil_column   .1
+;******* Custom content / #2 - Decompressions stops *******
+; Title
+#DEFINE    dm_custom_decoplan_title_row          dm_customview_row              ; 101
+#DEFINE    dm_custom_decoplan_title_column       .65                            ; 65
+; 1st col
+#DEFINE    dm_cust_dstop_2nd_stop_row            dm_customview_row+.15          ; 116
+#DEFINE    dm_cust_dstop_2nd_stop_column         .0                             ; 0
+#DEFINE    dm_cust_dstop_3rd_stop_row            dm_customview_row+.39          ; 140
+#DEFINE    dm_cust_dstop_3rd_stop_column         dm_cust_dstop_2nd_stop_column  ; 0
+; 2nd col
+#DEFINE    dm_cust_dstop_4th_stop_row            dm_cust_dstop_2nd_stop_row     ; 116
+#DEFINE    dm_cust_dstop_4th_stop_column         .56                            ; 56
+#DEFINE    dm_cust_dstop_5th_stop_row            dm_cust_dstop_3rd_stop_row     ; 140
+#DEFINE    dm_cust_dstop_5th_stop_column         dm_cust_dstop_4th_stop_column  ; 56
+; 3rd col
+#DEFINE    dm_cust_dstop_6th_stop_row            dm_cust_dstop_2nd_stop_row     ; 116
+#DEFINE    dm_cust_dstop_6th_stop_column         .112                           ; 112
+#DEFINE    dm_cust_dstop_7th_stop_row            dm_cust_dstop_3rd_stop_row     ; 140
+#DEFINE    dm_cust_dstop_7th_stop_column         dm_cust_dstop_6th_stop_column  ; 112
 
-; Warnings
-#DEFINE	warning_icon_row	.55
-#DEFINE	warning_icon_column	.135
-#DEFINE	warning1_row		.50
-#DEFINE	warning1_column		.70
-#DEFINE	warning2_row		.74
-#DEFINE	warning2_column		warning1_column
-#DEFINE warning_length      .9                 ; total string length
-
-#DEFINE	velocity_text_row		.76
-#DEFINE	velocity_text_column	.0
-
-#DEFINE	divemode_customview_row		.101        ; Upper border
-#DEFINE	divemode_customview_column	.0
-
-#DEFINE dive_custom_hud_row         divemode_customview_row+.1
-#DEFINE dive_custom_hud_column1     .10
-#DEFINE dive_custom_hud_column2     .65
-#DEFINE dive_custom_hud_column3     .120
-#DEFINE dive_hud_data_row           divemode_customview_row+.16
-#DEFINE dive_hud_sensor1_column     .6
-#DEFINE dive_hud_sensor2_column     .62
-#DEFINE dive_hud_sensor3_column     .118
+;******* Custom content / #3 - Time, EAD/END and tissue saturation *******
+; Clock
+#DEFINE    dm_custom_clock_title_row               dm_customview_row+.1              ; 102
+#DEFINE    dm_custom_clock_row                     dm_customview_row+.16             ; 117
+#DEFINE    dm_custom_clock_column                  .0                                ; 0
+#DEFINE    dm_custom_endtime_row                   dm_custom_clock_row+.23           ; 140 - not used
+#DEFINE    dm_custom_endtime_column                dm_custom_clock_column            ; 0   - not used
+; EAD/AND
+#DEFINE    dm_custom_eadend_title_row              dm_customview_row+.1              ; 102
+#DEFINE    dm_custom_ead_row                       dm_customview_row+.16             ; 117
+#DEFINE    dm_custom_ead_column                    .46                               ; 46
+#DEFINE    dm_custom_end_row                       dm_custom_ead_row+.23             ; 140
+#DEFINE    dm_custom_end_column                    dm_custom_ead_column              ; 46
+; Tissue title
+#DEFINE    dm_custom_tissue_title_row              dm_customview_row+.1              ; 102
+#DEFINE    dm_custom_tissue_title_column           .120                              ; 120
+; N2 / He values
+#DEFINE    dm_custom_tissue_N2_row                 dm_custom_ead_row+.5              ; 122
+#DEFINE    dm_custom_tissue_N2_column              .105                              ; 105
+#DEFINE    dm_custom_tissue_He_row                 dm_custom_end_row+.5              ; 145
+#DEFINE    dm_custom_tissue_He_column              dm_custom_tissue_N2_column        ; 105
+; Tissue diagram
+#DEFINE    dm_custom_tissue_diagram_top            dm_customview_row+.16             ; 117
+#DEFINE    dm_custom_tissue_diagram_bottom         dm_custom_tissue_diagram_top+.43  ; 160
+#DEFINE    dm_custom_tissue_diagram_left           .116                              ; 116
+#DEFINE    dm_custom_tissue_diagram_frame_spacing  .8                                ; 8
 
-; Customview Ceiling
-#DEFINE dive_ceiling_text_row       divemode_customview_row+.1
-#DEFINE dive_ceiling_text_column    .66
-#DEFINE dive_ceiling_value_row      divemode_customview_row+.18
-#DEFINE dive_ceiling_value_column   .64
+;******* Custom content / #4 - GF-lo/hi, aGF-lo/hi, current GF value *******
+; Title
+#DEFINE    dm_custom_gf_title_row            dm_customview_row+.1        ; 102
+#DEFINE    dm_custom_gf_title_col1           .8                          ; 8
+#DEFINE    dm_custom_gf_title_col2           .62                         ; 62
+#DEFINE    dm_custom_gf_title_col3           .115                        ; 115
+; GF
+#DEFINE    dm_custom_gf_row                  dm_customview_row+.18       ; 119
+#DEFINE    dm_custom_gf_column               .0                          ; 0
+; aGF
+#DEFINE    dm_custom_agf_row                 dm_custom_gf_row            ; 119
+#DEFINE    dm_custom_agf_column              .60                         ; 60
+; Current GF
+#DEFINE    dm_custom_currentgf_row           dm_custom_gf_row            ; 119
+#DEFINE    dm_custom_currentgf_column        .118                        ; 118
 
-; Customview GF
-#DEFINE dive_gf_text_row            divemode_customview_row+.1
-#DEFINE dive_gf_column1             .8
-#DEFINE dive_gf_column2             .62
-#DEFINE dive_gf_column3             .115
-#DEFINE dive_gf_row                 divemode_customview_row+.18
-#DEFINE dive_gf_column              .0
-#DEFINE dive_agf_row                dive_gf_row
-#DEFINE dive_agf_column             .60
-#DEFINE dive_currentgf_row          dive_gf_row
-#DEFINE dive_currentgf_column       .118
-
-; Customview Dynamic Gaslist
-#DEFINE dive_custom_dyn_mask_column .59
-#DEFINE dive_custom_dyn_mask_row    decoplan_title_row
-#DEFINE dive_custom_dyn_mask_row1   dive_hud_data_row
-#DEFINE dive_custom_dyn_mask_column1   .0
-#DEFINE dive_custom_dyn_mask_row2   dive_hud_data_row+.23
-#DEFINE dive_custom_dyn_mask_column2   .80
+;******* Custom content / #5 - Compass *******
+; Title
+#DEFINE    dm_custom_compass_mask_row           dm_customview_row        ; 101
+#DEFINE    dm_custom_compass_mask_column        .65                      ; 65
+; Head and arrows
+#DEFINE    dm_custom_compass_head_row           dm_customview_row+.39    ; 140
+#DEFINE    dm_custom_compass_head_column        .62                      ; 62
+#DEFINE    dm_custom_compass_ldir_column        .5                       ; 5
+#DEFINE    dm_custom_compass_rdir_column        .140                     ; 140
+; Ruler
+#DEFINE    dm_custom_compass_graph_row          dm_customview_row                  ; 101
+#DEFINE    dm_custom_compass_graph_height       .33                                ; 33
+#DEFINE    dm_custom_compass_tick_height        .3                                 ; 3
+#DEFINE    dm_custom_compass_tick_top_top       dm_custom_compass_graph_row+.1     ; 102
+#DEFINE    dm_custom_compass_tick_top_bot       dm_custom_compass_graph_row+.4     ; 105
+#DEFINE    dm_custom_compass_label_row          dm_custom_compass_graph_row+.6     ; 107
+#DEFINE    dm_custom_compass_label_height       .24                                ; 24
+#DEFINE    dm_custom_compass_tick_bot_top       dm_custom_compass_graph_row+.30    ; 131
+#DEFINE    dm_custom_compass_tick_bot_bot       dm_custom_compass_graph_row+.33    ; 134
 
-; Customview clock/date, END/EAD and Tissues
-#DEFINE dive_clock_row              dive_hud_data_row
-#DEFINE dive_clock_column           .0
-#DEFINE dive_endtime_row            dive_clock_row+.23
-#DEFINE dive_endtime_column         dive_clock_column
-#DEFINE dive_ead_row                dive_hud_data_row
-#DEFINE dive_ead_column             .46
-#DEFINE dive_end_row                dive_ead_row+.23
-#DEFINE dive_end_column             dive_ead_column
+;******* Custom content / #6 - HUD / O2 sensor values *******
+#DEFINE    dm_custom_hud_row                dm_customview_row+.1        ; 102
+#DEFINE    dm_custom_hud_column1            .10                         ; 10
+#DEFINE    dm_custom_hud_column2            .65                         ; 65
+#DEFINE    dm_custom_hud_column3            .120                        ; 120
+#DEFINE    dm_custom_hud_data_row           dm_customview_row+.16       ; 117
+#DEFINE    dm_custom_hud_sensor1_column     .6                          ; 6
+#DEFINE    dm_custom_hud_sensor2_column     .62                         ; 62
+#DEFINE    dm_custom_hud_sensor3_column     .118                        ; 118
 
-#DEFINE dive_tissue_N2_row          dive_ead_row+.5
-#DEFINE dive_tissue_N2_column       .105
-#DEFINE dive_tissue_He_row          dive_end_row+.5
-#DEFINE dive_tissue_He_column       dive_tissue_N2_column
-#DEFINE tissue_diagram_top          divemode_customview_row+.16
-#DEFINE tissue_diagram_bottom       .160
-#DEFINE tissue_diagram_left         .116
-#DEFINE tissue_diagram_frame_spacing    .8
+;******* Custom content / #7 - Gas list *******
+; Title
+#DEFINE    dm_custom_dyn_gas_mask_row          dm_customview_row        ; 101
+#DEFINE    dm_custom_dyn_gas_mask_column       .59                      ; 59
+; col #1
+#DEFINE    dm_custom_dyn_gas_row1              dm_customview_row+.16    ; 117
+#DEFINE    dm_custom_dyn_gas_column1           .0                       ; 0
+; col #2
+#DEFINE    dm_custom_dyn_gas_row2              dm_customview_row+.39    ; 140
+#DEFINE    dm_custom_dyn_gas_column2           .80                      ; 80
 
-#DEFINE dive_custom_avr_stop_row        dive_custom_hud_row
-#DEFINE dive_custom_avr_stop_column1    .2
-#DEFINE dive_custom_avr_stop_column2    .57
-#DEFINE dive_custom_avr_stop_column3    .110
-#DEFINE dive_avr_stop_row               dive_hud_data_row
-#DEFINE dive_avr_stop_column1           .0
-#DEFINE dive_avr_stop_column2           .54
-#DEFINE dive_avr_stop_column3           .118
+;******* Custom content / #8 - Ceiling value for GF_hi *******
+; Title
+#DEFINE    dm_custom_ceiling_text_row       dm_customview_row+.1        ; 102
+#DEFINE    dm_custom_ceiling_text_column    .66                         ; 66
+; Value
+#DEFINE    dm_custom_ceiling_value_row      dm_customview_row+.18       ; 119
+#DEFINE    dm_custom_ceiling_value_column   .64                         ; 64
+; II. End of the custom conent row. (101-163)
+
+
 
-#DEFINE	decostop_1st_stop_row		.171		; In medium font...
-#DEFINE	decostop_1st_stop_column	.82
-#DEFINE	safetystop_row              .171		; In medium font...
-#DEFINE	safetystop_column           .118
+; 1px space between the 2nd and 3rd content rows
+#DEFINE    dm_sep_2_3_row    dm_offset+.150         ; 164
+
+
 
-#DEFINE safetystop_text_row         .175
-#DEFINE safetystop_text_column      .70
-
-#DEFINE decoplan_title_row          .101
-#DEFINE decoplan_title_column       .65
+; III. The 3rd content row contains temperature, active gas, NDL/TTS time,
+;      simulator menu, active/dil gas, decostop, Apnea surface time and max depth
+;  The content row contains 2 columns:
+;    - temperature, gas names
+;    - NDL/TTS, DecoStop
+#DEFINE    dm_3rdrow_top     dm_offset+.151    ; 165
+#DEFINE    dm_3rdrow_bot     .239              ; 239
+#DEFINE    dm_3rdrow_lft     .0                ; 0
+#DEFINE    dm_3rdrow_rgt     .159              ; 159
 
-#DEFINE	decostop_2nd_stop_row		divemode_customview_row+.15
-#DEFINE	decostop_2nd_stop_column	.0
-#DEFINE	decostop_3rd_stop_row		divemode_customview_row+.39
-#DEFINE	decostop_3rd_stop_column	decostop_2nd_stop_column
-#DEFINE	decostop_4th_stop_row		decostop_2nd_stop_row
-#DEFINE	decostop_4th_stop_column	.56
-#DEFINE	decostop_5th_stop_row		decostop_3rd_stop_row
-#DEFINE	decostop_5th_stop_column	decostop_4th_stop_column
-#DEFINE	decostop_6th_stop_row		decostop_2nd_stop_row
-#DEFINE	decostop_6th_stop_column	.112
-#DEFINE	decostop_7th_stop_row		decostop_3rd_stop_row
-#DEFINE	decostop_7th_stop_column	decostop_6th_stop_column
-
-#DEFINE divemode_simtext_row        .164
-#DEFINE divemode_simtext_column     .32
-
-; Divemode menu
-#DEFINE divemode_menu_row           .164        ; Upper row
-#DEFINE divemode_menu_lower         .239        ; Lower border
-#DEFINE divemode_menu_left          .0          ; Left
-#DEFINE divemode_menu_right         .159        ; Right
+;******* Bottom content / 1st col *******
+; Temperature
+#DEFINE    dm_temp_row               dm_3rdrow_top     ; 165
+#DEFINE    dm_temp_column            .0                ; 0
+; Simulation text
+#DEFINE    dm_simtext_row            dm_3rdrow_top     ; 165
+#DEFINE    dm_simtext_column         .30               ; 30
+; Diluent gas
+#DEFINE    dm_active_dil_row         dm_3rdrow_top+.24 ; 189
+#DEFINE    dm_active_dil_column      .0                ; 0
+; active gas for OC, blinking better gas, setpoint or bailout for CCR
+#DEFINE    dm_active_gas_row         .210              ; 210
+#DEFINE    dm_active_gas_column      .0                ; 0
 
-#DEFINE divemode_menu_item1_row    .165
-#DEFINE divemode_menu_item1_column .9
-#DEFINE divemode_menu_item2_row    divemode_menu_item1_row+.24
-#DEFINE divemode_menu_item2_column divemode_menu_item1_column
-#DEFINE divemode_menu_item3_row    divemode_menu_item2_row+.24
-#DEFINE divemode_menu_item3_column divemode_menu_item1_column
-#DEFINE divemode_menu_item4_row    divemode_menu_item1_row
-#DEFINE divemode_menu_item4_column .89
-#DEFINE divemode_menu_item5_row    divemode_menu_item4_row+.24
-#DEFINE divemode_menu_item5_column divemode_menu_item4_column
-#DEFINE divemode_menu_item6_row    divemode_menu_item5_row+.24
-#DEFINE divemode_menu_item6_column divemode_menu_item4_column
+;******* Bottom content / 2nd col *******
+; Next deco stop for TTS
+#DEFINE    dm_decostop_1st_stop_row       dm_3rdrow_top             ; 165
+#DEFINE    dm_decostop_1st_stop_column    .82                       ; 82
+; Safety Stop
+#DEFINE    dm_safetystop_row              dm_3rdrow_top             ; 165 (pre: 171)
+#DEFINE    dm_safetystop_column           .118                      ; 118
+#DEFINE    dm_safetystop_bot              dm_safetystop_row+.31     ; 196
+#DEFINE    dm_safetystop_text_row         dm_safetystop_row+.1      ; 166 (pre: 175)
+#DEFINE    dm_safetystop_text_column      .80                       ; 80 - for the 4char "Stop"!!!
+; TTS
+#DEFINE    dm_tts_value_row               dm_3rdrow_top+.32;        ; 197 (pre: 207)
+#DEFINE    dm_tts_value_column            .118                      ; 118
+#DEFINE    dm_tts_text_row                dm_tts_value_row+.5       ; 202 (pre: 211)
+#DEFINE    dm_tts_text_column             .85                       ; 85
+; NDL - the same position as TTS
+#DEFINE    dm_ndl_value_row               dm_tts_value_row          ; 197
+#DEFINE    dm_ndl_value_column            dm_tts_value_column       ; 118
+#DEFINE    dm_ndl_text_row                dm_tts_text_row           ; 202
+#DEFINE    dm_ndl_text_column             dm_tts_text_column        ; 85
+; FTTS (only modded screen)
+#DEFINE    dm_ftts_value_row              dm_3rdrow_top+.64         ; 215
+#DEFINE    dm_ftts_value_column           .97                       ; 97
 
-#DEFINE dive_compass_mask_row       decoplan_title_row
-#DEFINE dive_compass_mask_column    decoplan_title_column
-#DEFINE dive_compass_head_column    .62
-#DEFINE dive_compass_head_row       divemode_customview_row+.39
-#DEFINE dive_compass_ldir_column    .5
-#DEFINE dive_compass_rdir_column    .140
+;******* Bottom content / Apnea mode *******;
+#DEFINE    dm_apnoe_surface_time_text_row           .190                   ; 190
+#DEFINE    dm_apnoe_surface_time_text_col           .30                    ; 30
+#DEFINE    dm_apnoe_surface_time_row                .204                   ; 204
+#DEFINE    dm_apnoe_surface_time_column             .15                    ; 15
+#DEFINE    dm_apnoe_last_max_depth_text_row         .190                   ; 190
+#DEFINE    dm_apnoe_last_max_depth_text_col         .100                   ; 100
+#DEFINE    dm_apnoe_last_max_depth_row              .204                   ; 204
+#DEFINE    dm_apnoe_last_max_depth_column           .100                   ; 100
+
+
 
-#DEFINE dive_compass_graph_row      .101
-#DEFINE dive_compass_graph_height   .33
+; IV. The last set of parameters are for the menus displayed in dive mode
+; Divemode menu
+#DEFINE    dm_menu_row           .164        ; 164 Upper row -- the frame's top line is the separator
+#DEFINE    dm_menu_lower         .239        ; 239 Lower border
+#DEFINE    dm_menu_left          .0          ; 0   Left
+#DEFINE    dm_menu_right         .159        ; 159 Right
 
-#DEFINE dive_compass_tick_height      .3
-#DEFINE dive_compass_tick_top_top     .102
-#DEFINE dive_compass_tick_top_bot     .105
-#DEFINE dive_compass_label_row        .107
-#DEFINE dive_compass_label_height     .24
-#DEFINE dive_compass_tick_bot_top     .131
-#DEFINE dive_compass_tick_bot_bot     .134
+#DEFINE    dm_menu_item1_row         dm_menu_row+.1          ; 165
+#DEFINE    dm_menu_item1_column      .9                      ; 9
+#DEFINE    dm_menu_item2_row         dm_menu_item1_row+.24   ; 189
+#DEFINE    dm_menu_item2_column      dm_menu_item1_column    ; 9
+#DEFINE    dm_menu_item3_row         dm_menu_item2_row+.24   ; 213
+#DEFINE    dm_menu_item3_column      dm_menu_item1_column    ; 9
 
+#DEFINE    dm_menu_item4_row         dm_menu_row+.1          ; 165
+#DEFINE    dm_menu_item4_column      .89                     ; 89
+#DEFINE    dm_menu_item5_row         dm_menu_item4_row+.24   ; 189
+#DEFINE    dm_menu_item5_column      dm_menu_item4_column    ; 89
+#DEFINE    dm_menu_item6_row         dm_menu_item5_row+.24   ; 213
+#DEFINE    dm_menu_item6_column      dm_menu_item4_column    ; 89
+
--- a/src/hwos.inc	Sun May 31 20:25:12 2015 +0200
+++ b/src/hwos.inc	Sun May 31 21:24:16 2015 +0200
@@ -680,6 +680,9 @@
 #DEFINE compass_bearing_lft     flag12,2    ; bearing is to the left/<< if set, otherwise to the right/>>
 #DEFINE compass_bearing_vis     flag12,3    ; bearing is visible? (either ahead or behind/-180°)
 #DEFINE compass_bearing_ahd     flag12,4    ; bearing is ahead or behind?
+#DEFINE blinking_depth_warning  flag12,5    ; set by the color_depth. =1: warning color
+#DEFINE blinking_depth_prev     flag12,6    ; set by the TFT_depth.   =1: prev display had warning color
+#DEFINE blinking_depth_toggle   flag12,7    ; toggle to blink
 
 ;=============================================================================
 ; C-code Routines
--- a/src/menu_processor.asm	Sun May 31 20:25:12 2015 +0200
+++ b/src/menu_processor.asm	Sun May 31 21:24:16 2015 +0200
@@ -92,7 +92,7 @@
         ; Draw one frame around the divemode menu
         extern  TFT_divemask_color
         call    TFT_divemask_color
-    	WIN_FRAME_COLOR16 divemode_menu_row, divemode_menu_lower, divemode_menu_left ,divemode_menu_right	; top, bottom, left, right
+    	WIN_FRAME_COLOR16 dm_menu_row, dm_menu_lower, dm_menu_left ,dm_menu_right	; top, bottom, left, right
         call    TFT_standard_color
 
         bra     menu_processor1         ; Yes, skip some lines here
@@ -436,9 +436,9 @@
 ;-----------------------------------------------------------------------------
 
 menu_draw_lines_divemode:
-        movlw   divemode_menu_item1_row
+        movlw   dm_menu_item1_row
         movff   WREG,win_top
-        movlw   divemode_menu_item1_column
+        movlw   dm_menu_item1_column
         movff   WREG,win_leftx2
         clrf    start_item
         movff   item_max,menupos4           ; Copy item_max for divemode cursor routine
@@ -578,9 +578,9 @@
         cpfseq  menu_item               ; At pos 4?
         bra     menu_draw_line_none2    ; No
 
-        movlw   divemode_menu_item4_row
+        movlw   dm_menu_item4_row
         movff   WREG,win_top            ; Reset row
-        movlw   divemode_menu_item4_column
+        movlw   dm_menu_item4_column
         movff   WREG,win_leftx2         ; New column
         bra     menu_draw_line_none2    ; Done.
 
--- a/src/surfmode.inc	Sun May 31 20:25:12 2015 +0200
+++ b/src/surfmode.inc	Sun May 31 21:24:16 2015 +0200
@@ -84,7 +84,7 @@
 #DEFINE surf_menu2_ambient_column   .95
 
 #DEFINE surf_tissue_diagram_top     .66
-#DEFINE surf_tissue_diagram_bottom  tissue_diagram_top+.64
+#DEFINE surf_tissue_diagram_bottom  surf_tissue_diagram_top+.117  ; 183
 #DEFINE surf_tissue_diagram_left    .5
 #DEFINE surf_tissue_diagram_right   surf_decotype_column-.5
 #DEFINE surf_tissue_N2_row          surf_tissue_diagram_top+.1
--- a/src/text_english.inc	Sun May 31 20:25:12 2015 +0200
+++ b/src/text_english.inc	Sun May 31 21:24:16 2015 +0200
@@ -229,7 +229,7 @@
     TCODE   taGFactors,     "aGF Values"    ; aGF Values
     TCODE   tGFInfo,        "Current GF"    ; GF Info
     TCODE   tCeiling,       "Ceiling"       ; Ceiling
-    TCODE   tDiveSafetyStop," Stop"         ; Stop (Five chars, right alligned)
+    TCODE   tDiveSafetyStop,"Stop"         ; Stop (Four chars, right alligned)
     TCODE   tDiveFallback,  "Fallback!"     ; Fallback! (max. nine chars)
 
 ; Divemode menu
--- a/src/text_french.inc	Sun May 31 20:25:12 2015 +0200
+++ b/src/text_french.inc	Sun May 31 21:24:16 2015 +0200
@@ -229,7 +229,7 @@
     TCODE   taGFactors,     "Valeurs aGF"   ; aGF Values
     TCODE   tGFInfo,        "   GF Info"    ; GF Info
     TCODE   tCeiling,       "Ceiling"       ; Ceiling
-    TCODE   tDiveSafetyStop," Stop"         ; Stop (Five chars, right alligned)
+    TCODE   tDiveSafetyStop,"Stop"         ; Stop (Four chars, right alligned)
     TCODE   tDiveFallback,  "Fallback!"     ; Fallback! (max. nine chars)
 
 ; Divemode menu
--- a/src/text_german.inc	Sun May 31 20:25:12 2015 +0200
+++ b/src/text_german.inc	Sun May 31 21:24:16 2015 +0200
@@ -228,7 +228,7 @@
     TCODE   taGFactors,     "aGF Values"    ; aGF Values
     TCODE   tGFInfo,        "GF Info"       ; GF Info
     TCODE   tCeiling,       "Ceiling"       ; Ceiling
-    TCODE   tDiveSafetyStop,"Stopp"         ; Stop (Five chars, right alligned)
+    TCODE   tDiveSafetyStop,"Stop"         ; Stop (Four chars, right alligned)
     TCODE   tDiveFallback,  "Fallback!"     ; Fallback! (max. nine chars)
 
 ; Divemode menu
--- a/src/text_italian.inc	Sun May 31 20:25:12 2015 +0200
+++ b/src/text_italian.inc	Sun May 31 21:24:16 2015 +0200
@@ -229,7 +229,7 @@
     TCODE   taGFactors,     "Valori aGF"    ; aGF Values
     TCODE   tGFInfo,        "Info GF"       ; GF Info
     TCODE   tCeiling,       "Ceiling"       ; Ceiling
-    TCODE   tDiveSafetyStop," Stop"         ; Stop (Five chars, right alligned)
+    TCODE   tDiveSafetyStop,"Stop"         ; Stop (Four chars, right alligned)
     TCODE   tDiveFallback,  "Fallback!"     ; Fallback! (max. nine chars)
 
 ; Divemode menu
--- a/src/tft_outputs.asm	Sun May 31 20:25:12 2015 +0200
+++ b/src/tft_outputs.asm	Sun May 31 21:24:16 2015 +0200
@@ -241,10 +241,63 @@
 	movff	lo_temp,lo			; Restore hi, lo
 	call	subU16			;  sub_c = sub_a - sub_b
 	btfss	neg_flag
-	bra		TFT_warnings_color ; Set to warning color
-	call	TFT_standard_color
+	bra		TFT_color_code_depth_warn ; Set to warning color
+    call    TFT_color_code_ppo2_depth  ; check depth against MOD
 	return
 
+TFT_color_code_ppo2_depth:
+    SAFE_2BYTE_COPY amb_pressure, xA
+	movlw	d'10'
+	movwf	xB+0
+	clrf	xB+1
+	call	div16x16				; xC=p_amb/10
+
+	movff	xC+0,xA+0
+	movff	xC+1,xA+1
+    movff   char_I_O2_ratio,xB+0    ; =O2 ratio
+	clrf	xB+1
+	call	mult16x16               ; char_I_O2_ratio * p_amb/10
+
+; Check if ppO2>6,55bar
+	tstfsz	xC+2					; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar?
+	;bra		TFT_color_code_warn     ; Yes, warn in warning color
+    bra     TFT_color_code_depth_warn
+; Check if ppO2>3,30bar
+	btfsc	xC+1,7
+    bra     TFT_color_code_depth_warn
+
+	movff	xC+0,sub_a+0
+	movff	xC+1,sub_a+1
+	movff	opt_ppO2_max,WREG		; PPO2 Max for MOD calculation and color coding in divemode
+	mullw	d'100'
+	movff	PRODL,sub_b+0
+	movff	PRODH,sub_b+1
+	call	subU16			  		; sub_c = sub_a - sub_b
+	btfss	neg_flag
+    bra     TFT_color_code_depth_warn
+
+	movff	xC+0,sub_a+0
+	movff	xC+1,sub_a+1
+	movff	opt_ppO2_min,WREG		; PPO2 min for Sensors and color coding in divemode
+	mullw	d'100'
+	movff	PRODL,sub_b+0
+	movff	PRODH,sub_b+1
+	call	subU16			  		; sub_c = sub_a - sub_b
+	btfsc	neg_flag
+    bra     TFT_color_code_depth_warn
+    if dm_offset != 0
+        call	TFT_standard_color
+    else
+        movlw   color_green
+    	call	TFT_set_color
+    endif
+    bcf     blinking_depth_warning      ; reset warning
+    return
+
+TFT_color_code_depth_warn:
+   	bsf		blinking_depth_warning         ; Set warning
+    bra     TFT_warnings_color ; Set to warning color
+
 TFT_color_code_cns:
     movff   int_O_CNS_fraction+1,lo		; copy into bank1
     tstfsz  lo                          ; >255% ?
@@ -398,18 +451,18 @@
 TFT_show_color_schemes:         ; update the color schemes
     bsf     divemode            ; put in divemode
     call    TFT_divemask_color
-    WIN_TINY  divemode_mask_depth_column,divemode_mask_depth_row+.40
+    WIN_TINY  .12,.40
     STRCAT_TEXT_PRINT	tDepth
-    WIN_TINY  divemode_mask_maxdepth_column,divemode_mask_maxdepth_row+.40
+    WIN_TINY  .62,.40
     STRCAT_TEXT_PRINT	tMaxDepth
-    WIN_TINY  divemode_mask_divetime_column,divemode_mask_divetime_row+.40
+    WIN_TINY  .122,.40
     STRCAT_TEXT_PRINT	tDivetime
 
     ; Show some demo screen
 
     ; Depth demo
     call	TFT_standard_color
-	WIN_MEDIUM	depth_column+.3,depth_row+.40
+	WIN_MEDIUM	.3,.54
     movlw   LOW     .5172
     movwf   lo
     movlw   HIGH    .5172
@@ -419,7 +472,7 @@
 	output_16						; Full meters in Big font
 	bcf		leftbind
 	STRCAT_PRINT ""					; Display full meters
-    WIN_SMALL	depth_dm_column-.15,max_depth_dm_row+.40
+    WIN_SMALL	.25,.66
     movlw   LOW     .5172
     movwf   lo
     movlw   HIGH    .5172
@@ -433,7 +486,7 @@
 	WIN_FONT 	FT_SMALL
 
     ; Max. Depth demo
-    WIN_MEDIUM	max_depth_column,max_depth_row+.40
+    WIN_MEDIUM	.64,.54
 	bsf     ignore_digit4			; no 0.1m
     bsf     leftbind
     movlw   LOW     .6349
@@ -444,7 +497,7 @@
 	STRCAT_PRINT ""					; Display full meters
     bcf     leftbind
 	; .1m in SMALL font
-	WIN_SMALL	max_depth_dm_column,max_depth_dm_row+.40
+	WIN_SMALL	.87,.66
 	PUTC    "."
 	movlw	d'4'
 	movwf	ignore_digits
@@ -461,10 +514,10 @@
     ; Divetime demo
     movff   mins,lo
     clrf    hi
-	WIN_MEDIUM	divetime_column, divetime_row+.40
+	WIN_MEDIUM	.103, .54
 	output_16_3                     ; limit to 999 and display only (0-999)
 	STRCAT_PRINT ""                 ; Show minutes in large font
-	WIN_SMALL  divetime_secs_column, divetime_secs_row+.40   		; left position for two sec figures
+	WIN_SMALL  .139, .66   		; left position for two sec figures
 	PUTC    ':'
 	bsf		leftbind
 	movff   secs,lo
@@ -477,26 +530,27 @@
 
 	global	TFT_divemode_mask
 TFT_divemode_mask:					; Displays mask in Dive-Mode
-    call    TFT_divemask_color
-    WIN_TINY  divemode_mask_depth_column,divemode_mask_depth_row
-    STRCAT_TEXT_PRINT	tDepth
-    WIN_TINY  divemode_mask_maxdepth_column,divemode_mask_maxdepth_row
-    STRCAT_TEXT_PRINT	tMaxDepth
-    WIN_TINY  divemode_mask_divetime_column,divemode_mask_divetime_row
-    STRCAT_TEXT_PRINT	tDivetime
-    
+    if dm_offset != 0
+        call    TFT_divemask_color
+        WIN_TINY            dm_mask_depth_column,dm_mask_depth_row
+        STRCAT_TEXT_PRINT   tDepth
+        WIN_TINY            dm_mask_maxdepth_column,dm_mask_maxdepth_row
+        STRCAT_TEXT_PRINT   tMaxDepth
+        WIN_TINY            dm_mask_divetime_column,dm_mask_divetime_row
+        STRCAT_TEXT_PRINT   tDivetime
+    endif
     call	TFT_standard_color
-	return
+    return
 
 	global	TFT_clear_customview_divemode
 TFT_clear_customview_divemode:
-    WIN_BOX_BLACK    divemode_customview_row, .163, .0, .159	; top, bottom, left, right
+    WIN_BOX_BLACK    dm_customview_row, dm_customview_bot, dm_customview_column, dm_customview_rgt	; top, bottom, left, right
 	return
 
 	global	TFT_display_velocity
 TFT_display_velocity:						; With divA+0 = m/min
 	TFT_color_code	warn_velocity	    	; Color-code Output (With divA+0 = m/min)
-	WIN_SMALL	velocity_text_column,velocity_text_row
+	WIN_SMALL	dm_velocity_text_column, dm_velocity_text_row
 
     TSTOSS  opt_units			; 0=Meters, 1=Feets
 	bra		TFT_display_velocity_metric
@@ -531,17 +585,21 @@
 	global	TFT_display_velocity_clear
 TFT_display_velocity_clear:
 	; Clear Text
-	WIN_BOX_BLACK   velocity_text_row, velocity_text_row+.22, velocity_text_column, (velocity_text_column+.7*.8)-1	; top, bottom, left, right
+	WIN_BOX_BLACK   dm_velocity_text_row, dm_velocity_text_bot, dm_velocity_text_column, dm_velocity_text_rgt	; top, bottom, left, right
 	return
 
     global  TFT_clear_decoarea
 TFT_clear_decoarea:
-    WIN_BOX_BLACK   decostop_1st_stop_row, .239, decostop_1st_stop_column ,.159	; top, bottom, left, right
+    WIN_BOX_BLACK   dm_decostop_1st_stop_row, .239, dm_decostop_1st_stop_column, .159	; top, bottom, left, right
 	return
 
     global  TFT_clear_divemode_menu
 TFT_clear_divemode_menu:
-    WIN_BOX_BLACK   divemode_menu_row, divemode_menu_lower, divemode_menu_left ,divemode_menu_right	; top, bottom, left, right
+    if dm_offset != 0
+        WIN_BOX_BLACK   dm_menu_row,   dm_menu_lower, dm_menu_left,  dm_menu_right	; top, bottom, left, right
+    else
+        WIN_BOX_BLACK   dm_3rdrow_top, dm_3rdrow_bot, dm_3rdrow_lft, dm_3rdrow_rgt	; top, bottom, left, right
+    endif
 	return
 
 	global	TFT_display_ndl_mask
@@ -550,7 +608,7 @@
     return                              ; Yes, return
 	rcall	TFT_clear_decoarea			; Clear Dekostop and Dekosum
     call    TFT_divemask_color
-   	WIN_STD 	ndl_text_column,ndl_text_row
+   	WIN_STD 	dm_ndl_text_column, dm_ndl_text_row
 	STRCPY_TEXT_PRINT  tNDL             ; NDL
 	call	TFT_standard_color
 	return
@@ -562,7 +620,7 @@
 	call	TFT_standard_color
 	movff	int_O_ascenttime+0,lo       ; TTS
 	movff	int_O_ascenttime+1,hi       ; on 16bits
-	WIN_MEDIUM  tts_value_column,tts_value_row
+	WIN_MEDIUM  dm_tts_value_column, dm_tts_value_row
 	output_16_3					;Displays only 0...999
 	STRCAT_PRINT "'"
 	return
@@ -571,7 +629,7 @@
 TFT_display_ndl:
     btfsc   divemode_menu               ; Is the dive mode menu shown?
     return                              ; Yes, return
-	WIN_MEDIUM	ndl_value_column,ndl_value_row
+	WIN_MEDIUM	dm_ndl_value_column, dm_ndl_value_row
 	call	TFT_standard_color
 	movff	char_O_nullzeit,lo		; Get NDL from C-code
 	output_8
@@ -581,8 +639,8 @@
 	global	TFT_divemode_warning
 TFT_divemode_warning:
     bsf     dive_warning_displayed              ; =1: The warning sign is shown
-    WIN_TOP  	warning_icon_row
-	WIN_LEFT 	warning_icon_column
+    WIN_TOP  	dm_warning_icon_row
+	WIN_LEFT 	dm_warning_icon_column
     TFT_WRITE_PROM_IMAGE dive_warning2_block 	; Show Warning icon
     return
 
@@ -591,13 +649,13 @@
     btfss   dive_warning_displayed              ; =1: The warning sign is shown
     return
     bcf     dive_warning_displayed              ; clear only once
-	WIN_BOX_BLACK   warning_icon_row, warning_icon_row+.38, warning_icon_column, warning_icon_column+.21; top, bottom, left, right
+	WIN_BOX_BLACK   dm_warning_icon_row, dm_warning_icon_bot, dm_warning_icon_column, dm_warning_icon_rgt  ; top, bottom, left, right
 	return
 
 	global	TFT_display_deko_mask
 TFT_display_deko_mask:
 	rcall		TFT_clear_decoarea
-   	WIN_STD 	tts_text_column,tts_text_row
+   	WIN_STD 	dm_tts_text_column, dm_tts_text_row
     call    TFT_divemask_color
 	STRCPY_TEXT_PRINT  tTTS             ; TTS
 	call	TFT_standard_color
@@ -648,7 +706,7 @@
 TFT_display_deko:
     btfsc   divemode_menu               ; Is the dive mode menu shown?
     return                              ; Yes, return
-	WIN_MEDIUM	decostop_1st_stop_column,decostop_1st_stop_row
+	WIN_MEDIUM	dm_decostop_1st_stop_column, dm_decostop_1st_stop_row
 	TFT_color_code		warn_ceiling    ; Color-code Output
 	movff	char_O_first_deco_depth,lo  ; Ceiling in m
 	rcall	TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft)
@@ -661,7 +719,7 @@
     global  TFT_decoplan
 TFT_decoplan:
     call    TFT_divemask_color
-    WIN_TINY    decoplan_title_column,decoplan_title_row
+    WIN_TINY    dm_custom_decoplan_title_column, dm_custom_decoplan_title_row
     STRCPY_TEXT_PRINT tDiveDecoplan
 	call	TFT_standard_color
 
@@ -670,14 +728,14 @@
 	bra		TFT_display_deko2			; Yes
 	; No, clear output and return
 	call	TFT_standard_color
-	WIN_SMALL	decostop_4th_stop_column,decostop_4th_stop_row
+	WIN_SMALL	dm_cust_dstop_4th_stop_column,dm_cust_dstop_4th_stop_row
 	STRCPY_PRINT "  ---  "
-	WIN_BOX_BLACK   decostop_2nd_stop_row, divemode_simtext_row-1, decostop_2nd_stop_column, decostop_4th_stop_column	; top, bottom, left, right
-	WIN_BOX_BLACK   decostop_5th_stop_row, divemode_simtext_row-1, decostop_5th_stop_column, decostop_6th_stop_column	; top, bottom, left, right
-	WIN_BOX_BLACK   decostop_6th_stop_row, divemode_simtext_row-1, decostop_6th_stop_column, .159	; top, bottom, left, right
+	WIN_BOX_BLACK   dm_cust_dstop_2nd_stop_row, dm_customview_bot, dm_cust_dstop_2nd_stop_column, dm_cust_dstop_4th_stop_column	; top, bottom, left, right
+	WIN_BOX_BLACK   dm_cust_dstop_5th_stop_row, dm_customview_bot, dm_cust_dstop_5th_stop_column, dm_cust_dstop_6th_stop_column	; top, bottom, left, right
+	WIN_BOX_BLACK   dm_cust_dstop_6th_stop_row, dm_customview_bot, dm_cust_dstop_6th_stop_column, .159	; top, bottom, left, right
     return
 TFT_display_deko2:
-	WIN_SMALL	decostop_2nd_stop_column,decostop_2nd_stop_row
+	WIN_SMALL	dm_cust_dstop_2nd_stop_column, dm_cust_dstop_2nd_stop_row
 	movff	char_O_deco_depth+1,lo  	; stop in m
 	bcf     lo,7                        ; Clear GAS_SWITCH bit
 	rcall	TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft)
@@ -688,12 +746,12 @@
 	tstfsz	lo							; Show another stop?
 	bra		TFT_display_deko3			; Yes
 	; No, clear output and return
-	WIN_BOX_BLACK   decostop_3rd_stop_row, divemode_simtext_row-1, decostop_2nd_stop_column, decostop_4th_stop_column	; top, bottom, left, right
-	WIN_BOX_BLACK   decostop_4th_stop_row, divemode_simtext_row-1, decostop_4th_stop_column, .159	; top, bottom, left, right
+	WIN_BOX_BLACK   dm_cust_dstop_3rd_stop_row, dm_customview_bot, dm_cust_dstop_2nd_stop_column, dm_cust_dstop_4th_stop_column	; top, bottom, left, right
+	WIN_BOX_BLACK   dm_cust_dstop_4th_stop_row, dm_customview_bot, dm_cust_dstop_4th_stop_column, .159	; top, bottom, left, right
 	return
 
 TFT_display_deko3:
-	WIN_SMALL	decostop_3rd_stop_column,decostop_3rd_stop_row
+	WIN_SMALL	dm_cust_dstop_3rd_stop_column, dm_cust_dstop_3rd_stop_row
 	movff	char_O_deco_depth+2,lo  	; stop in m
 	bcf     lo,7                        ; Clear GAS_SWITCH bit
 	rcall	TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft)
@@ -705,11 +763,11 @@
 	tstfsz	lo							; Show another stop?
 	bra		TFT_display_deko4			; Yes
 	; No, clear output and return
-	WIN_BOX_BLACK   decostop_4th_stop_row, divemode_simtext_row-1, decostop_4th_stop_column, .159 ; top, bottom, left, right
+	WIN_BOX_BLACK   dm_cust_dstop_4th_stop_row, dm_customview_bot, dm_cust_dstop_4th_stop_column, .159  ; top, bottom, left, right
 	return								; Done.
 
 TFT_display_deko4:
-	WIN_SMALL	decostop_4th_stop_column,decostop_4th_stop_row
+	WIN_SMALL	dm_cust_dstop_4th_stop_column, dm_cust_dstop_4th_stop_row
 	movff	char_O_deco_depth+3,lo  	; stop in m
 	bcf     lo,7                        ; Clear GAS_SWITCH bit
 	rcall	TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft)
@@ -721,12 +779,12 @@
 	tstfsz	lo							; Show another stop?
 	bra		TFT_display_deko5			; Yes
 	; No, clear output and return
-	WIN_BOX_BLACK   decostop_5th_stop_row, divemode_simtext_row-1, decostop_5th_stop_column, decostop_6th_stop_column	; top, bottom, left, right
-	WIN_BOX_BLACK   decostop_6th_stop_row, divemode_simtext_row-1, decostop_6th_stop_column, .159                     ; top, bottom, left, right
+	WIN_BOX_BLACK   dm_cust_dstop_5th_stop_row, dm_customview_bot, dm_cust_dstop_5th_stop_column, dm_cust_dstop_6th_stop_column	; top, bottom, left, right
+	WIN_BOX_BLACK   dm_cust_dstop_6th_stop_row, dm_customview_bot, dm_cust_dstop_6th_stop_column, .159                     ; top, bottom, left, right
 	return								; Done.
 
 TFT_display_deko5:
-	WIN_SMALL	decostop_5th_stop_column,decostop_5th_stop_row
+	WIN_SMALL	dm_cust_dstop_5th_stop_column, dm_cust_dstop_5th_stop_row
 	movff	char_O_deco_depth+4,lo  	; stop in m
 	bcf     lo,7                        ; Clear GAS_SWITCH bit
 	rcall	TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft)
@@ -737,10 +795,10 @@
 	tstfsz	lo							; Show another stop?
 	bra		TFT_display_deko6			; Yes
 	; No, clear output and return
-	WIN_BOX_BLACK   decostop_6th_stop_row, divemode_simtext_row-1, decostop_6th_stop_column, .159                     ; top, bottom, left, right
+	WIN_BOX_BLACK   dm_cust_dstop_6th_stop_row, dm_customview_bot, dm_cust_dstop_6th_stop_column, .159        ; top, bottom, left, right
 	return								; Done.
 TFT_display_deko6:
-	WIN_SMALL	decostop_6th_stop_column,decostop_6th_stop_row
+	WIN_SMALL	dm_cust_dstop_6th_stop_column, dm_cust_dstop_6th_stop_row
 	movff	char_O_deco_depth+5,lo  	; stop in m
 	bcf     lo,7                        ; Clear GAS_SWITCH bit
 	rcall	TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft)
@@ -751,10 +809,10 @@
 	tstfsz	lo							; Show another stop?
 	bra		TFT_display_deko7			; Yes
 	; No, clear output and return
-	WIN_BOX_BLACK   decostop_7th_stop_row, divemode_simtext_row-1, decostop_7th_stop_column, .159                     ; top, bottom, left, right
+	WIN_BOX_BLACK   dm_cust_dstop_7th_stop_row, dm_customview_bot, dm_cust_dstop_7th_stop_column, .159     ; top, bottom, left, right
 	return								; Done.
 TFT_display_deko7:
-	WIN_SMALL	decostop_7th_stop_column,decostop_7th_stop_row
+	WIN_SMALL	dm_cust_dstop_7th_stop_column, dm_cust_dstop_7th_stop_row
 	movff	char_O_deco_depth+6,lo  	; stop in m
 	bcf     lo,7                        ; Clear GAS_SWITCH bit
 	rcall	TFT_display_deko_output_depth ; Outputs depth (stored in lo) to POSTINC2 with "m" or w/o (For ft)
@@ -774,7 +832,7 @@
 
     global  TFT_clear_safety_stop
 TFT_clear_safety_stop:
-    WIN_BOX_BLACK   safetystop_text_row, ndl_text_row-.4, safetystop_text_column, .159	; top, bottom, left, right
+    WIN_BOX_BLACK   dm_safetystop_row, dm_safetystop_bot, dm_safetystop_text_column, .159	; top, bottom, left, right
     return
 
     global  TFT_show_safety_stop
@@ -798,15 +856,18 @@
 
     btfsc   divemode_menu                   ; Is the dive mode menu shown?
     return                                  ; Yes, return
-    btfsc   menuview
-    bra     TFT_show_safety_stop3           ; No room when menuview=1...
-
-    rcall    TFT_divemask_color
-    WIN_STD safetystop_text_column,safetystop_text_row
+    ;btfsc   menuview
+    ;bra     TFT_show_safety_stop3           ; No room when menuview=1...
+    if dm_offset != 0
+        call    TFT_divemask_color
+    else
+        call    TFT_standard_color
+    endif
+    WIN_STD  dm_safetystop_text_column, dm_safetystop_text_row
     STRCPY_TEXT_PRINT tDiveSafetyStop
 TFT_show_safety_stop3:
-	rcall    TFT_attention_color            ; show in yellow
-    WIN_MEDIUM	safetystop_column,safetystop_row
+	call    TFT_attention_color            ; show in yellow
+    WIN_MEDIUM	dm_safetystop_column, dm_safetystop_row
 	lfsr	FSR2,buffer
 	movff	safety_stop_countdown,lo
 	clrf	hi
@@ -822,18 +883,18 @@
 	output_99x
 	STRCAT_PRINT ""
 	WIN_FONT 	FT_SMALL
-	rcall	TFT_standard_color
+	call	TFT_standard_color
 	return
 
     global  TFT_mask_avr_stopwatch             ; Show mask for average depth and stopwatch
 TFT_mask_avr_stopwatch:
     ; The mask
     call    TFT_divemask_color
-    WIN_TINY  dive_custom_avr_stop_column1,dive_custom_avr_stop_row
+    WIN_TINY          dm_custom_avr_stop_title_column1,dm_custom_avr_stop_title_row
     STRCPY_TEXT_PRINT tDiveTotalAvr
-    WIN_TINY  dive_custom_avr_stop_column2,dive_custom_avr_stop_row
+    WIN_TINY          dm_custom_avr_stop_title_column2,dm_custom_avr_stop_title_row
     STRCPY_TEXT_PRINT tDiveStopwatch
-    WIN_TINY  dive_custom_avr_stop_column3,dive_custom_avr_stop_row
+    WIN_TINY          dm_custom_avr_stop_title_column3,dm_custom_avr_stop_title_row
     STRCPY_TEXT_PRINT tDiveStopAvr
     call	TFT_standard_color
     return
@@ -842,24 +903,24 @@
 TFT_dyn_gaslist:                            ; Show the dynamic gaslist
     ; The mask
     call    TFT_divemask_color
-    WIN_TINY  dive_custom_dyn_mask_column,dive_custom_dyn_mask_row
+    WIN_TINY    dm_custom_dyn_gas_mask_column,dm_custom_dyn_gas_mask_row
     STRCPY_TEXT_PRINT tGaslist
 ;    call	TFT_standard_color
 
-    WIN_SMALL dive_custom_dyn_mask_column1,dive_custom_dyn_mask_row1
+    WIN_SMALL   dm_custom_dyn_gas_column1,dm_custom_dyn_gas_row1
     movlw   .1
     movwf   uart1_temp
     bsf     short_gas_decriptions   ; =1: Use short versions of gaslist_strcat_gas_mod and gaslist_strcat_setpoint
     rcall   TFT_dyn_gaslist_common
-    WIN_SMALL dive_custom_dyn_mask_column1,dive_custom_dyn_mask_row2
+    WIN_SMALL   dm_custom_dyn_gas_column1,dm_custom_dyn_gas_row2
     incf    uart1_temp,F     ; +1
     movf    uart1_temp,W     ; into W
     rcall   TFT_dyn_gaslist_common
-    WIN_SMALL dive_custom_dyn_mask_column2,dive_custom_dyn_mask_row1
+    WIN_SMALL   dm_custom_dyn_gas_column2,dm_custom_dyn_gas_row1
     incf    uart1_temp,F     ; +1
     movf    uart1_temp,W     ; into W
     rcall   TFT_dyn_gaslist_common
-    WIN_SMALL dive_custom_dyn_mask_column2,dive_custom_dyn_mask_row2
+    WIN_SMALL   dm_custom_dyn_gas_column2,dm_custom_dyn_gas_row2
     incf    uart1_temp,F     ; +1
     movf    uart1_temp,W     ; into W
     rcall   TFT_dyn_gaslist_common
@@ -891,7 +952,7 @@
     call    TFT_standard_color
     SAFE_2BYTE_COPY  average_divesecs,lo
 	call	convert_time			; lo=secs, hi=mins
-    WIN_MEDIUM  dive_avr_stop_column2,dive_avr_stop_row
+    WIN_MEDIUM  dm_custom_avr_stop_column2,dm_custom_avr_stop_row
     bsf     leftbind
 	movf	hi,W
 	movff	lo,hi
@@ -913,7 +974,7 @@
     movff   avr_rel_pressure_total+1,hi
     call	adjust_depth_with_salinity			; computes salinity setting into lo:hi [mbar]
     call	convert_mbar_to_feet       	; convert value in lo:hi from mbar to feet
-    WIN_MEDIUM  dive_avr_stop_column1,dive_avr_stop_row
+    WIN_MEDIUM  dm_custom_avr_stop_column1,dm_custom_avr_stop_row
     bsf     leftbind
     output_16                       ; yxz
     STRCAT_PRINT " "
@@ -922,7 +983,7 @@
     movff   avr_rel_pressure+1,hi
     call	adjust_depth_with_salinity			; computes salinity setting into lo:hi [mbar]
     call	convert_mbar_to_feet       	; convert value in lo:hi from mbar to feet
-    WIN_MEDIUM  dive_avr_stop_column3,dive_avr_stop_row
+    WIN_MEDIUM  dm_custom_avr_stop_column3,dm_custom_avr_stop_row
     output_16                       ; yxz
     bcf     leftbind
     STRCAT_PRINT " "
@@ -933,7 +994,7 @@
     movff   avr_rel_pressure_total+0,lo
     movff   avr_rel_pressure_total+1,hi
     call	adjust_depth_with_salinity			; computes salinity setting into lo:hi [mbar]
-    WIN_MEDIUM  dive_avr_stop_column1,dive_avr_stop_row
+    WIN_MEDIUM  dm_custom_avr_stop_column1,dm_custom_avr_stop_row
     bsf     ignore_digit5         ; no cm
     output_16dp  .3               ; yxz.a
     STRCAT_PRINT " "
@@ -941,7 +1002,7 @@
     movff   avr_rel_pressure+0,lo
     movff   avr_rel_pressure+1,hi
     call	adjust_depth_with_salinity			; computes salinity setting into lo:hi [mbar]
-    WIN_MEDIUM  dive_avr_stop_column3,dive_avr_stop_row
+    WIN_MEDIUM  dm_custom_avr_stop_column3,dm_custom_avr_stop_row
     bsf     ignore_digit5         ; no cm
     output_16dp  .3               ; yxz.a
     bcf     leftbind
@@ -952,7 +1013,7 @@
     global  TFT_ceiling_mask                        ; The ceiling mask
 TFT_ceiling_mask:
     call    TFT_divemask_color
-    WIN_TINY  dive_ceiling_text_column,dive_ceiling_text_row
+    WIN_TINY  dm_custom_ceiling_text_column,dm_custom_ceiling_text_row
     STRCPY_TEXT_PRINT tCeiling
     call	TFT_standard_color
     return
@@ -960,7 +1021,7 @@
     global  TFT_ceiling                             ; Ceiling
 TFT_ceiling:
     call    TFT_standard_color
-    WIN_MEDIUM  dive_ceiling_value_column,dive_ceiling_value_row
+    WIN_MEDIUM  dm_custom_ceiling_value_column,dm_custom_ceiling_value_row
     movff   int_O_ceiling+0,lo
     movff   int_O_ceiling+1,hi
     call	adjust_depth_with_salinity			; computes salinity setting into lo:hi [mbar]
@@ -985,18 +1046,18 @@
     global  TFT_hud_mask                        ; The HUD mask
 TFT_hud_mask:
     call    TFT_divemask_color
-    WIN_TINY  dive_custom_hud_column1,dive_custom_hud_row
+    WIN_TINY          dm_custom_hud_column1,dm_custom_hud_row
     STRCPY_TEXT_PRINT tDiveHudMask1
-    WIN_TINY  dive_custom_hud_column2,dive_custom_hud_row
+    WIN_TINY          dm_custom_hud_column2,dm_custom_hud_row
     STRCPY_TEXT_PRINT tDiveHudMask2
-    WIN_TINY  dive_custom_hud_column3,dive_custom_hud_row
+    WIN_TINY          dm_custom_hud_column3,dm_custom_hud_row
     STRCPY_TEXT_PRINT tDiveHudMask3
     call	TFT_standard_color
     return
 
     global  TFT_hud_voltages
 TFT_hud_voltages:                    ; Show HUD details
-    WIN_SMALL .5,dive_hud_data_row
+    WIN_SMALL dm_custom_hud_sensor1_column,dm_custom_hud_data_row
     call	TFT_standard_color
     btfss   use_O2_sensor1
     call    TFT_warnings_color
@@ -1006,7 +1067,7 @@
     output_16dp  .4         ; x.xx
     bcf     leftbind
     STRCAT_PRINT "mV  "
-    WIN_SMALL .55,dive_hud_data_row
+    WIN_SMALL dm_custom_hud_sensor2_column,dm_custom_hud_data_row
     call	TFT_standard_color
     btfss   use_O2_sensor2
     call    TFT_warnings_color
@@ -1016,7 +1077,7 @@
     output_16dp  .4         ; x.xx
     bcf     leftbind
     STRCAT_PRINT "mV  "
-    WIN_SMALL .105,dive_hud_data_row
+    WIN_SMALL dm_custom_hud_sensor3_column,dm_custom_hud_data_row
     call	TFT_standard_color
     btfss   use_O2_sensor3
     call    TFT_warnings_color
@@ -1038,13 +1099,13 @@
     btfss   dive_hud1_displayed         ; Was the sensor shown?
     bra     TFT_update_hud2             ; Yes, skip clear
     bcf     dive_hud1_displayed         ; No, clear display flag
-    WIN_BOX_BLACK   dive_hud_data_row, dive_hud_data_row+.31, dive_hud_sensor1_column, dive_hud_sensor2_column	; top, bottom, left, right
-	WIN_STD dive_hud_sensor1_column+.7,dive_hud_data_row+.5
+    WIN_BOX_BLACK   dm_custom_hud_data_row, dm_customview_bot, dm_custom_hud_sensor1_column, dm_custom_hud_sensor2_column	; top, bottom, left, right
+	WIN_STD         dm_custom_hud_sensor1_column+.7, dm_custom_hud_data_row+.5
    	call	TFT_standard_color
     STRCPY_PRINT "---"
     bra     TFT_update_hud2 ; Skip Sensor 1
 TFT_update_hud1:
-    WIN_MEDIUM dive_hud_sensor1_column,dive_hud_data_row
+    WIN_MEDIUM dm_custom_hud_sensor1_column,dm_custom_hud_data_row
     movff   o2_ppo2_sensor1,lo
     TFT_color_code  warn_ppo2_hud       ; With ppO2 [cbar] in lo
     btfss   voting_logic_sensor1        ; Sensor within voting logic?
@@ -1062,13 +1123,13 @@
     btfss   dive_hud2_displayed         ; Was the sensor shown?
     bra     TFT_update_hud4             ; Yes, skip clear
     bcf     dive_hud2_displayed         ; No, clear display flag
-    WIN_BOX_BLACK   dive_hud_data_row, dive_hud_data_row+.31, dive_hud_sensor2_column, dive_hud_sensor3_column	; top, bottom, left, right
-    WIN_STD dive_hud_sensor2_column+.7,dive_hud_data_row+.5
+    WIN_BOX_BLACK   dm_custom_hud_data_row, dm_customview_bot, dm_custom_hud_sensor2_column, dm_custom_hud_sensor3_column	; top, bottom, left, right
+    WIN_STD         dm_custom_hud_sensor2_column+.7, dm_custom_hud_data_row+.5
    	call	TFT_standard_color
     STRCPY_PRINT "---"
     bra     TFT_update_hud4 ; Skip Sensor 2
 TFT_update_hud3:
-    WIN_MEDIUM dive_hud_sensor2_column,dive_hud_data_row
+    WIN_MEDIUM dm_custom_hud_sensor2_column,dm_custom_hud_data_row
     movff   o2_ppo2_sensor2,lo
     TFT_color_code  warn_ppo2_hud       ; With ppO2 [cbar] in lo
     btfss   voting_logic_sensor2        ; Sensor within voting logic?
@@ -1086,13 +1147,13 @@
     btfss   dive_hud3_displayed         ; Was the sensor shown?
     bra     TFT_update_hud6             ; Yes, skip clear
     bcf     dive_hud3_displayed         ; No, clear display flag
-    WIN_BOX_BLACK   dive_hud_data_row, dive_hud_data_row+.31, dive_hud_sensor3_column, .159 ; top, bottom, left, right
-    WIN_STD dive_hud_sensor3_column+.7,dive_hud_data_row+.5
+    WIN_BOX_BLACK   dm_custom_hud_data_row, dm_customview_bot, dm_custom_hud_sensor3_column, .159 ; top, bottom, left, right
+    WIN_STD         dm_custom_hud_sensor3_column+.7, dm_custom_hud_data_row+.5
    	call	TFT_standard_color
     STRCPY_PRINT "---"
     bra     TFT_update_hud6 ; Skip Sensor 3
 TFT_update_hud5:
-    WIN_MEDIUM dive_hud_sensor3_column,dive_hud_data_row
+    WIN_MEDIUM dm_custom_hud_sensor3_column,dm_custom_hud_data_row
     movff   o2_ppo2_sensor3,lo
     TFT_color_code  warn_ppo2_hud       ; With ppO2 [cbar] in lo
     btfss   voting_logic_sensor3        ; Sensor within voting logic?
@@ -1392,7 +1453,7 @@
 	PUTC    ':'
 	movff	hi,lo
 	output_99x
-    movlw   warning_length             ; Divemode string length
+    movlw   dm_warning_length             ; Divemode string length
     call    TFT_fillup_with_spaces     ; Fillup FSR2 with spaces (Total string length in #WREG)
 	STRCAT_PRINT ""
 	return
@@ -1403,10 +1464,17 @@
     tstfsz  lo
     bra     $+4
     return                              ; char_I_extra_time=0, return.
-	incf	warning_counter,F			; increase counter
-	call	TFT_warning_set_window		; Sets the row and column for the current warning
-    tstfsz  WREG                        ; Is there room for the warning?
-    return                              ; No
+
+    if dm_offset !=0
+        incf    warning_counter,F			; increase counter
+        call    TFT_warning_set_window		; Sets the row and column for the current warning
+        tstfsz  WREG                        ; Is there room for the warning?
+        return                              ; No
+    else
+        call    TFT_standard_color
+        WIN_SMALL dm_ftts_value_column, dm_ftts_value_row
+    endif
+
     movff   char_I_extra_time,lo
     STRCPY  "@+"
     bsf     leftbind
@@ -1424,7 +1492,7 @@
 	output_16
 	bcf         leftbind
     PUTC    "'"
-    movlw   warning_length             ; Divemode string length
+    movlw   dm_warning_length             ; Divemode string length
     call    TFT_fillup_with_spaces     ; Fillup FSR2 with spaces (Total string length in #WREG)
 	STRCAT_PRINT ""
 	return
@@ -1432,7 +1500,7 @@
 TFT_ftts2:
     STRCAT  "---"
 	bcf     leftbind
-    movlw   warning_length             ; Divemode string length
+    movlw   dm_warning_length             ; Divemode string length
     call    TFT_fillup_with_spaces     ; Fillup FSR2 with spaces (Total string length in #WREG)
     STRCAT_PRINT ""
     return
@@ -1497,27 +1565,27 @@
 ;=============================================================================
     global  TFT_divemode_menu_cursor
 TFT_divemode_menu_cursor:
-    WIN_BOX_BLACK   divemode_menu_item1_row,divemode_menu_item3_row+.24,divemode_menu_item1_column-.8,divemode_menu_item1_column-.1
-    WIN_BOX_BLACK   divemode_menu_item4_row,divemode_menu_item6_row+.24,divemode_menu_item4_column-.8,divemode_menu_item4_column-.1
+    WIN_BOX_BLACK   dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item1_column-.8, dm_menu_item1_column-.1
+    WIN_BOX_BLACK   dm_menu_row+.1, dm_menu_lower-.1, dm_menu_item4_column-.8, dm_menu_item4_column-.1
     call	TFT_standard_color
 
-    movlw   divemode_menu_item1_column-.8
+    movlw   dm_menu_item1_column-.8
     btfsc   menupos,2       ; >3?
-    movlw   divemode_menu_item4_column-.8  ; Yes
+    movlw   dm_menu_item4_column-.8  ; Yes
     movff   WREG,win_leftx2
     
     movff   menupos,lo                      ; Copy menu pos
-    movlw   divemode_menu_item6_row
+    movlw   dm_menu_item6_row
     dcfsnz  lo,F
-    movlw   divemode_menu_item1_row
+    movlw   dm_menu_item1_row
     dcfsnz  lo,F
-    movlw   divemode_menu_item2_row
+    movlw   dm_menu_item2_row
     dcfsnz  lo,F
-    movlw   divemode_menu_item3_row
+    movlw   dm_menu_item3_row
     dcfsnz  lo,F
-    movlw   divemode_menu_item4_row
+    movlw   dm_menu_item4_row
     dcfsnz  lo,F
-    movlw   divemode_menu_item5_row
+    movlw   dm_menu_item5_row
     movff   WREG,win_top
     movlw   FT_SMALL
     movff   WREG,win_font
@@ -1531,7 +1599,7 @@
 	btfsc	blinking_better_gas         ; blinking better Gas?
 	return                              ; Yes, no update of temperature now
 ; temperature
-	WIN_SMALL	dive_temp_column,dive_temp_row
+	WIN_SMALL	dm_temp_column,dm_temp_row
 	call	TFT_standard_color
     bsf     leftbind
 
@@ -1577,7 +1645,7 @@
     return
 
 TFT_active_setpoint:         ; Show setpoint
-	WIN_STD  active_gas_column,active_gas_row
+	WIN_STD  dm_active_gas_column, dm_active_gas_row
 	call	TFT_standard_color
     btfsc   is_bailout                  ; =1: Bailout
     bra     TFT_active_setpoint_bail    ; Show "Bailout" instead of Setpoint
@@ -1593,7 +1661,7 @@
 	movlw	color_yellow                ; Blink in yellow
     call	TFT_set_color
     bsf     win_invert              ; Set invert flag
-    WIN_STD active_gas_column,active_gas_row
+    WIN_STD dm_active_gas_column, dm_active_gas_row
 	movff	char_I_const_ppO2,lo
 	clrf	hi
 	bsf		leftbind
@@ -1608,7 +1676,11 @@
 
 TFT_active_setpoint_diluent:
     call	TFT_standard_color
-	WIN_SMALL  active_dil_column,active_dil_row
+    if dm_offset != 0
+    	WIN_SMALL  dm_active_dil_column, dm_active_dil_row
+    else
+    	WIN_STD    dm_active_dil_column, dm_active_dil_row
+    endif
     movff   char_I_O2_ratio,lo          ; lo now stores O2 in %
     movff   char_I_He_ratio,hi          ; hi now stores He in %
     rcall   TFT_show_dil_divemode2      ; Show diluent  (Non-Inverted in all cases)
@@ -1622,7 +1694,11 @@
 	movlw	color_yellow                ; Blink in yellow
     call	TFT_set_color
     bsf     win_invert              ; Set invert flag
-    WIN_SMALL   active_dil_column,active_dil_row
+    if dm_offset != 0
+        WIN_SMALL   dm_active_dil_column, dm_active_dil_row
+    else
+        WIN_STD     dm_active_dil_column, dm_active_dil_row
+    endif
     movff   char_I_O2_ratio,lo          ; lo now stores O2 in %
     movff   char_I_He_ratio,hi          ; hi now stores He in %
 	rcall	TFT_show_dil_divemode2      ; Show gas
@@ -1649,7 +1725,7 @@
     bra     TFT_active_setpoint         ; Yes, show setpoint
 
     call    TFT_standard_color
-	WIN_STD active_gas_column,active_gas_row
+	WIN_STD dm_active_gas_column, dm_active_gas_row
     movff   char_I_O2_ratio,lo          ; lo now stores O2 in %
     movff   char_I_He_ratio,hi          ; hi now stores He in %
 	rcall	TFT_active_gas_divemode2    ; Show gas (Non-Inverted in all cases)
@@ -1661,7 +1737,7 @@
 	return                              ; No, Done.
     call    TFT_attention_color         ; blink in yellow
     bsf     win_invert                  ; Set invert flag
-    WIN_STD active_gas_column,active_gas_row
+    WIN_STD dm_active_gas_column, dm_active_gas_row
     movff   char_I_O2_ratio,lo          ; lo now stores O2 in %
     movff   char_I_He_ratio,hi          ; hi now stores He in %
 	rcall	TFT_active_gas_divemode2    ; Show gas (Non-Inverted in all cases)
@@ -1810,17 +1886,20 @@
     bcf     ccr_diluent_setup       ; Clear flag
     return
 
+;==================================================================
+
 	global	TFT_depth
 TFT_depth:
     SAFE_2BYTE_COPY rel_pressure, lo
-	call	adjust_depth_with_salinity			; computes salinity setting into lo:hi [mbar]
+    call    adjust_depth_with_salinity			; computes salinity setting into lo:hi [mbar]
+
+    TFT_color_code  warn_depth			; Color-code the output
+    call TFT_depth_blink
+    WIN_LARGE   dm_depth_column, dm_depth_row
 
     TSTOSS  opt_units   			; 0=m, 1=ft
-	bra		TFT_depth_metric
+    bra     TFT_depth_metric
 ;TFT_depth_imperial
-	WIN_LARGE	depth_feet_column,depth_feet_row
-	TFT_color_code	warn_depth			; Color-code the output
-
     clrf    sub_a+1                     ; Display 0ft if lower then 30cm
 	movlw	d'30'
 	movwf	sub_a+0
@@ -1837,16 +1916,15 @@
     movlw   .3                      ; limit to three chars
     call    TFT_fillup_with_spaces  ; Fillup FSR2 with spaces (Total string length in #WREG)
 	STRCAT_PRINT ""					; Display feet
+    bcf     win_invert                  ; Reset invert flag
     return
 
 depth_less_0.3mtr_feet:
 	STRCAT_PRINT "0  "				; manual zero
+    bcf     win_invert                  ; Reset invert flag
 	return
 
 TFT_depth_metric:
-	WIN_LARGE	depth_column,depth_row
-	TFT_color_code	warn_depth			; Color-code the output
-
 	movlw	.039
 	cpfslt	hi
     bra		depth_greater_99_84mtr
@@ -1895,7 +1973,7 @@
 	STRCAT_PRINT ""					; Display full meters
 
 	; .1m in MEDIUM font
-	WIN_MEDIUM	depth_dm_column,depth_dm_row
+	WIN_MEDIUM	dm_depth_dm_column, dm_depth_dm_row
 	TFT_color_code	warn_depth			; Color-code the output
 
     SAFE_2BYTE_COPY rel_pressure, lo
@@ -1917,17 +1995,20 @@
 	bsf		ignore_digit5
 	output_16dp	d'0'
 	STRCAT_PRINT ""					; Display decimeters
+    bcf     win_invert                  ; Reset invert flag
 	WIN_FONT 	FT_SMALL
 	return
 
 depth_less_0.3mtr:
 	STRCAT_PRINT "0"				; Display 0.0m manually
+    bcf     win_invert                  ; Reset invert flag
 	WIN_FONT 	FT_SMALL
 	return
 
 depth_greater_99_84mtr:			; Display only in full meters
 	btfss	depth_greater_100m		; Is depth>100m already?
 	rcall	TFT_clear_depth			; No, clear depth area and set flag
+    TFT_color_code	warn_depth
 	; Depth is already in hi:lo
 	; Show depth in Full meters
 	; That means ignore figure 4 and 5
@@ -1937,14 +2018,80 @@
 	output_16
 	bcf		leftbind
     STRCAT_PRINT ""					; Display full meters only
+    bcf     win_invert                  ; Reset invert flag
 	WIN_FONT 	FT_SMALL
 	return
 
 TFT_clear_depth:            			; No, clear depth area and set flag
-    WIN_BOX_BLACK   depth_row, .77,.0, max_depth_column-.1    ;top, bottom, left, right
+    WIN_BOX_BLACK   dm_depth_row, dm_depth_bot, dm_depth_column, dm_depth_rgt    ;top, bottom, left, right
 	bsf		depth_greater_100m			; Set Flag
 	return
 
+TFT_depth_blink:
+    ; check if previous cycle had the blinking warning or not
+    btfsc   blinking_depth_prev         ; did we have warning prev?
+    bra     TFT_depth_blink_prevwarn    ; Yes
+
+    ; No; check if it's set now
+    btfsc   blinking_depth_warning      ; do we have warning set now?
+    bra     TFT_depth_blink_warn        ; Yes  - so we have warning now but not prev
+
+    ; no warning in previous cycle, no warning now, reset all flags
+    bcf     blinking_depth_prev         ; reset prev flag
+    bcf     blinking_depth_toggle       ; reset toggle
+    bcf     win_invert
+    ; all done
+    return
+
+TFT_depth_blink_prevwarn:
+    ; ...we had warning in previous cycle, check if we still have the warning set
+    btfss   blinking_depth_warning              ; do we still have the warning?
+    bra     TFT_depth_blink_prevwarn_nowarn     ; No, clear the depth area
+
+    ; we still have the warning, set previous flag for next cycle...
+    bsf     blinking_depth_prev                 ; set prev flag
+    ; and set toggle and invert if required
+    btfss   blinking_depth_toggle               ; do we have the toggle set?
+    bra    TFT_depth_blink_set                  ; No:  set inverse,   do color_box, set flag
+    bra    TFT_depth_blink_reset                ; Yes: clear inverse, do black box, reset flag
+
+TFT_depth_blink_prevwarn_nowarn:
+    ; we had warning, but not now... (e.g. ascended or switched to better gas)
+    ; reset the previous cycle flag for the next cycle...
+    bcf     blinking_depth_prev         ; reset prev flag
+    ; clear it - just in case if we had a blinked before
+    bra    TFT_depth_blink_reset                ; Yes: clear inverse, do black box, reset flag
+
+TFT_depth_blink_warn:
+    ; new blinking warning activated (had no warning in previous cycle)
+    bsf     blinking_depth_prev                 ; set prev flag
+    ; set toggle and invert
+    bra    TFT_depth_blink_set
+
+TFT_depth_blink_set:
+    ; clear the area with color
+    movlw   color_red  ; that should not be hardcoded...
+    WIN_BOX_COLOR    dm_depth_row, dm_depth_bot, dm_depth_column, dm_depth_rgt    ;top, bottom, left, right
+    ;set the invert color
+    bsf     win_invert
+    ; set the toggle
+    bsf     blinking_depth_toggle
+    ; all done
+    return
+
+TFT_depth_blink_reset:
+    ; clear the area with black
+    WIN_BOX_BLACK    dm_depth_row, dm_depth_bot, dm_depth_column, dm_depth_rgt    ;top, bottom, left, right
+    ;reset the invert color
+    bcf     win_invert
+    ; reset the toggle
+    bcf     blinking_depth_toggle
+    ; if it's still warning...
+    btfsc   blinking_depth_warning
+    call    TFT_warnings_color
+    ; all done
+    return
+
 ;=============================================================================
 
     global  TFT_custom_text
@@ -2228,14 +2375,14 @@
 	bra		TFT_max_pressure2_metric
 ;TFT_max_pressure2_imperial
 	call	convert_mbar_to_feet              	; convert value in lo:hi from mbar to feet
-	WIN_MEDIUM	max_depth_feet_column,max_depth_feet_row
+	WIN_MEDIUM	dm_max_depth_column, dm_max_depth_row
 	call	TFT_standard_color
 	output_16_3
 	STRCAT_PRINT ""
 	return
 
 TFT_max_pressure2_metric:
-    WIN_MEDIUM	max_depth_column,max_depth_row
+    WIN_MEDIUM	dm_max_depth_column, dm_max_depth_row
 
 	movlw	.039
 	cpfslt	hi
@@ -2278,7 +2425,7 @@
 	bra		tft_max_depth3
 
 tft_max_depth2:
-	WIN_MEDIUM	max_depth_column,max_depth_row
+	WIN_MEDIUM	dm_max_depth_column, dm_max_depth_row
 	STRCAT	"0"
 
 tft_max_depth3:
@@ -2287,7 +2434,7 @@
     bcf     leftbind
 
 	; .1m in SMALL font
-	WIN_SMALL	max_depth_dm_column,max_depth_dm_row
+	WIN_SMALL	dm_max_depth_dm_column, dm_max_depth_dm_row
 
     SAFE_2BYTE_COPY max_pressure, lo
 	call	adjust_depth_with_salinity			; computes salinity setting into lo:hi [mbar]
@@ -2319,7 +2466,7 @@
 	return
 
 TFT_clear_max_depth:            			; No, clear max. depth area and set flag
-    WIN_BOX_BLACK   max_depth_row,.49,max_depth_column, max_depth_dm_column+.13    ;top, bottom, left, right
+    WIN_BOX_BLACK   dm_max_depth_row, dm_max_depth_bot, dm_max_depth_column, dm_max_depth_rgt    ;top, bottom, left, right
 	bsf		max_depth_greater_100m			; Set Flag
 	return
 
@@ -2333,7 +2480,7 @@
 	global	TFT_display_apnoe_last_max
 TFT_display_apnoe_last_max:
     call    TFT_divemask_color
-    WIN_TINY    last_max_apnoe_text_column,last_max_apnoe_text_row
+    WIN_TINY    dm_apnoe_last_max_depth_text_col, dm_apnoe_last_max_depth_text_row
     STRCPY_TEXT_PRINT   tApnoeMax
 
 	call	TFT_standard_color
@@ -2343,13 +2490,13 @@
 	bra		TFT_display_apnoe_last_m_metric
 ;TFT_display_apnoe_last_max_imperial
 	call	convert_mbar_to_feet              	; convert value in lo:hi from mbar to feet
-	WIN_MEDIUM	apnoe_last_max_depth_column,apnoe_last_max_depth_row
+	WIN_MEDIUM	dm_apnoe_last_max_depth_column, dm_apnoe_last_max_depth_row
 	output_16
 	STRCAT_PRINT ""
 	return
 
 TFT_display_apnoe_last_m_metric:
-	WIN_MEDIUM	apnoe_last_max_depth_column,apnoe_last_max_depth_row
+	WIN_MEDIUM	dm_apnoe_last_max_depth_column, dm_apnoe_last_max_depth_row
 	bsf		ignore_digit5		; do not display 1cm depth
 	output_16dp	d'3'
 	STRCAT_PRINT ""
@@ -2360,27 +2507,56 @@
 TFT_divemins:
 	movff	divemins+0,lo
 	movff	divemins+1,hi
-    bcf		leftbind
-
+
+    ; Already showing divemins > 99min
 	btfsc	no_more_divesecs		; Ignore seconds?
 	bra     TFT_divemins2           ; Show minutes only
 
+    ; check if divemins has hi, definitely > 99min
+    movlw   .1
+    cpfslt  hi                      ; HI less than 1?
+    bra     TFT_divemins_clr        ; No, show mins only
+
+    ; check if divemins (when HI is zero) > 99min
 	movlw	.99
-	cpfsgt	lo                      ; bigger then 99?
+	cpfsgt	lo                      ; bigger than 99?
 	bra		TFT_divemins1           ; No show mins:secs
+
+TFT_divemins_clr:
 	; Yes, remove second display for the rest of the dive and clear seconds
 	bsf		no_more_divesecs        ; Set flag
 	; Clear rest of seconds
-	WIN_BOX_BLACK   divetime_row, warning1_row,divetime_column,.159 ;top, bottom, left, right
+	WIN_BOX_BLACK   dm_divetime_row, dm_divetime_bot, dm_divetime_column, dm_divetime_rgt ;top, bottom, left, right
     bra     TFT_divemins2           ; Show minutes only
 
 TFT_divemins1:
-	WIN_MEDIUM	divetime_column, divetime_row
-	output_16_3                     ; displays only last three figures from a 16Bit value (0-999)
+    ; Print out the minutes, up to 99min, only 2chars !
 	call	TFT_standard_color
+	WIN_MEDIUM	dm_divetime_column, dm_divetime_row
+
+    movlw	.9
+	cpfsgt	lo                      ; bigger then 9?
+    bra     TFT_divemins1_pad       ; No, need padding
+    ; Yes, just print out the value
+	bsf		leftbind
+	movff	divemins+0,lo
+	output_99x                     ; displays only last two figures from a 8Bit value (00-99)
+	bcf     leftbind
 	STRCAT_PRINT ""                 ; Show minutes in large font
-
-	WIN_SMALL  divetime_secs_column, divetime_secs_row   		; left position for two sec figures
+    bra     TFT_divemins1_sec
+
+TFT_divemins1_pad:
+	bcf     leftbind
+	PUTC    " "                     ; Add a padding space
+	bsf		leftbind
+	movff	divemins+0,lo
+	output_99                     ; displays only last two figures from a 8Bit value (0-99)
+	bcf     leftbind
+	STRCAT_PRINT ""                 ; Show minutes in large font
+
+TFT_divemins1_sec:
+    ; Print out the seconds
+	WIN_SMALL  dm_divetime_secs_column, dm_divetime_secs_row   		; left position for two sec figures
 	PUTC    ':'
 	bsf		leftbind
 	movff   divesecs,lo
@@ -2390,21 +2566,45 @@
 	return
 
 TFT_divemins2:
-	WIN_MEDIUM	divetime_minsonly_column, divetime_row
-	output_16
 	call	TFT_standard_color
+	WIN_MEDIUM	dm_divetime_minsonly_column, dm_divetime_row
+    bcf		leftbind
+
+    ; if we are at or over the limit, do a WARNIGN color
+    ; 9999 = 27 0F = [39][15]
+    movlw   .38
+    cpfsgt  hi                  ; hi > 38 ?
+    bra     TFT_divemins2_out   ; No, hi <= 38, no need to warn
+
+    movlw   .40
+    cpfslt  hi                  ; hi < 40 ?
+    bra     TFT_divemins2_warn  ; No, hi >= 40, need to warn
+    
+    ; hi = 39, check lo. check 14 as 9999 should be already WARN!
+    movlw   .14
+    cpfsgt  lo
+    bra     TFT_divemins2_out   ; No, lo <= 14, no need to warn
+    ; Yes, lo > 14, need to warn
+
+TFT_divemins2_warn:
+    call    TFT_warnings_color
+    bsf     win_invert
+
+TFT_divemins2_out:
+	output_16_4
 	STRCAT_PRINT ""                 ; Show minutes in large font
+    bcf     win_invert
     return
 
 ;=============================================================================
 	global	TFT_display_apnoe_surface
 TFT_display_apnoe_surface:
     call    TFT_divemask_color
-    WIN_TINY    surface_apnoe_text_column,surface_apnoe_text_row
+    WIN_TINY    dm_apnoe_surface_time_text_col,  dm_apnoe_surface_time_text_row
     STRCPY_TEXT_PRINT   tApnoeSurface
 
 	call	TFT_standard_color
-	WIN_MEDIUM	surface_time_apnoe_column, surface_time_apnoe_row
+	WIN_MEDIUM	dm_apnoe_surface_time_column, dm_apnoe_surface_time_row
 	movff	apnoe_surface_mins,lo
 	output_8
     PUTC    ':'
@@ -2416,18 +2616,18 @@
 	global	TFT_apnoe_clear_surface
 TFT_apnoe_clear_surface:
 	; Clear Surface timer....
-	WIN_BOX_BLACK   surface_apnoe_text_row, .239, surface_apnoe_text_column, .159                 ;top, bottom, left, right
+	WIN_BOX_BLACK   dm_apnoe_surface_time_text_row, .239, dm_apnoe_surface_time_text_col, .159                 ;top, bottom, left, right
 	return
 
 	global	TFT_display_apnoe_descent
 TFT_display_apnoe_descent:		; Descent divetime
 	movff	apnoe_mins,lo
     clrf    hi
-	WIN_MEDIUM	divetime_column, divetime_row
+	WIN_MEDIUM	dm_divetime_apnoe_column, dm_divetime_apnoe_row
 	output_16_3                     ; displays only last three figures from a 16Bit value (0-999)
 	call	TFT_standard_color
 	STRCAT_PRINT ""                 ; Show minutes in large font
-	WIN_SMALL  divetime_secs_column, divetime_secs_row   		; left position for two sec figures
+	WIN_SMALL   dm_divetime_apnoe_secs_column, dm_divetime_apnoe_secs_row   		; left position for two sec figures
 	PUTC    ':'
 	bsf		leftbind
 	movff	apnoe_secs,lo
@@ -2436,16 +2636,16 @@
 	STRCAT_PRINT ""                 ; Show seconds in small font
 
     call    TFT_divemask_color
-    WIN_TINY    total_apnoe_text_column,total_apnoe_text_row
+    WIN_TINY    dm_total_apnoe_text_column,dm_total_apnoe_text_row
     STRCPY_TEXT_PRINT   tApnoeTotal
 	call	TFT_standard_color
 	movff	divemins,lo
     clrf    hi
-	WIN_MEDIUM	apnoe_total_divetime_column, apnoe_total_divetime_row
+	WIN_MEDIUM	dm_apnoe_total_divetime_column, dm_apnoe_total_divetime_row
 	output_16_3                     ; displays only last three figures from a 16Bit value (0-999)
 	call	TFT_standard_color
 	STRCAT_PRINT ""                 ; Show minutes in large font
-	WIN_SMALL  apnoe_total_divetime_secs_column, apnoe_total_divetime_secs_row   		; left position for two sec figures
+	WIN_SMALL   dm_apnoe_total_divetime_secs_col, dm_apnoe_total_divetime_secs_row	; left position for two sec figures
 	PUTC    ':'
 	bsf		leftbind
 	movff	divesecs,lo
@@ -2648,7 +2848,7 @@
 TFT_clear_warning_text:
     btfss   divemode                            ; in divemode?
     bra     TFT_clear_warning_text2             ; No, setup for surface mode
-    WIN_BOX_BLACK   warning1_row, divemode_customview_row-3, warning1_column, warning_icon_column-3	;top, bottom, left, right
+    WIN_BOX_BLACK   dm_warning_row,    dm_warning_bot,        dm_warning_column,    dm_warning_rgt	;top, bottom, left, right
     return
 TFT_clear_warning_text2:
     WIN_BOX_BLACK   surf_warning1_row, surf_warning2_row+.24, surf_warning1_column, surf_warning1_column+.76     ;top, bottom, left, right
@@ -2658,7 +2858,7 @@
 TFT_clear_warning_text_2nd_row:
     btfss   divemode                            ; in divemode?
     bra     TFT_clear_warning_text_2nd_2        ; No, setup for surface mode
-    WIN_BOX_BLACK   warning2_row, divemode_customview_row-3, warning2_column, warning_icon_column-3	;top, bottom, left, right
+    WIN_BOX_BLACK  dm_warning2_row,    dm_warning2_bot,       dm_warning2_column,   dm_warning2_rgt	;top, bottom, left, right
     return
 TFT_clear_warning_text_2nd_2:
     WIN_BOX_BLACK   surf_warning2_row, surf_warning2_row+.24, surf_warning2_column, surf_warning2_column+.76     ;top, bottom, left, right
@@ -2737,7 +2937,7 @@
     return                              ; No
     call	TFT_warnings_color
 	STRCPY_TEXT tDiveaGF_active         ; "aGF!"
-    movlw   warning_length              ; Divemode string length
+    movlw   dm_warning_length              ; Divemode string length
     rcall   TFT_fillup_with_spaces      ; Fillup FSR2 with spaces (Total string length in #WREG)
     STRCAT_PRINT ""
 	call	TFT_standard_color
@@ -2750,7 +2950,7 @@
     return                              ; No
     call	TFT_warnings_color
 	STRCPY_TEXT tDiveFallback           ; "Fallback!"
-    movlw   warning_length              ; Divemode string length
+    movlw   dm_warning_length              ; Divemode string length
     rcall   TFT_fillup_with_spaces      ; Fillup FSR2 with spaces (Total string length in #WREG)
     STRCAT_PRINT ""
 	call	TFT_standard_color
@@ -2767,7 +2967,7 @@
     bsf     leftbind
 	output_8
     PUTC    "%"
-    movlw   warning_length              ; Divemode string length
+    movlw   dm_warning_length              ; Divemode string length
     btfss   divemode                    ; In Divemode?
     movlw   surf_warning_length         ; No, use surface string length
     rcall   TFT_fillup_with_spaces      ; Fillup FSR2 with spaces (Total string length in #WREG)
@@ -2791,11 +2991,11 @@
 
     btfss   warning_counter,0           ; Toggle with each warning
 	bra		TFT_warning_set_window2
-	WIN_SMALL	warning1_column,warning1_row
+	WIN_SMALL	dm_warning1_column, dm_warning1_row
     bcf     second_row_warning          ; =1: The second row contains a warning
 	retlw   .0                          ; WREG=0 -> Warning window defined
 TFT_warning_set_window2:
-	WIN_SMALL	warning2_column,warning2_row
+	WIN_SMALL	dm_warning2_column, dm_warning2_row
     bsf     second_row_warning          ; =1: The second row contains a warning
 	retlw   .0                          ; WREG=0 -> Warning window defined
 
@@ -2823,7 +3023,7 @@
 	output_8
 	bcf		leftbind
     PUTC    "%"
-    movlw   warning_length              ; Divemode string length
+    movlw   dm_warning_length              ; Divemode string length
     btfss   divemode                    ; In Divemode?
     movlw   surf_warning_length         ; No, use surface string length
     rcall   TFT_fillup_with_spaces      ; Fillup FSR2 with spaces (Total string length in #WREG)
@@ -2836,11 +3036,11 @@
 TFT_gf_mask:
     ; The mask
     call    TFT_divemask_color
-    WIN_TINY  dive_gf_column1,dive_gf_text_row
+    WIN_TINY          dm_custom_gf_title_col1, dm_custom_gf_title_row
     STRCPY_TEXT_PRINT tGFactors
-    WIN_TINY  dive_gf_column2,dive_gf_text_row
+    WIN_TINY          dm_custom_gf_title_col2, dm_custom_gf_title_row
     STRCPY_TEXT_PRINT taGFactors
-    WIN_TINY  dive_gf_column3,dive_gf_text_row
+    WIN_TINY          dm_custom_gf_title_col3, dm_custom_gf_title_row
     STRCPY_TEXT_PRINT tGFInfo
 
     ; Show GF (Static)
@@ -2848,7 +3048,7 @@
     btfss   use_agf
     call	TFT_standard_color
 
-    WIN_STD   dive_gf_column,dive_gf_row
+    WIN_STD   dm_custom_gf_column, dm_custom_gf_row
     bsf     leftbind
     movff   opt_GF_low,lo
     output_8
@@ -2864,7 +3064,7 @@
     btfss   use_agf
     call    TFT_disabled_color
 
-    WIN_STD   dive_agf_column,dive_agf_row
+    WIN_STD   dm_custom_agf_column, dm_custom_agf_row
     movff   opt_aGF_low,lo
     output_8
     PUTC    "/"
@@ -2876,7 +3076,7 @@
     return
 
 TFT_gf_mask2:
-    WIN_STD   dive_agf_column+.10,dive_agf_row
+    WIN_STD   dm_custom_agf_column+.10, dm_custom_agf_row
     STRCPY_PRINT   "---"
     bcf     leftbind
     return
@@ -2888,7 +3088,7 @@
 	movff	char_I_deco_model,hi
 	decfsz	hi,F		; jump over next line if char_I_deco_model == 1
 	movff	char_O_relative_gradient_GF,lo		; gradient factor relative (GF model)
-    WIN_STD   dive_currentgf_column,dive_currentgf_row
+    WIN_STD   dm_custom_currentgf_column, dm_custom_currentgf_row
     output_8
     STRCAT_PRINT   "%"
     return
@@ -2902,12 +3102,12 @@
 	btfsc	FLAG_gauge_mode					; In Gauge mode?
 	bra		TFT_ead_end_tissues_clock_mask2 ; Yes
     ; Put three columns at HUD positions
-    WIN_TINY  dive_custom_hud_column2,dive_custom_hud_row
+    WIN_TINY          dm_custom_ead_column,     dm_custom_eadend_title_row
     STRCPY_TEXT_PRINT tDiveEAD_END
-    WIN_TINY  dive_custom_hud_column3,dive_custom_hud_row
+    WIN_TINY          dm_custom_tissue_title_column,  dm_custom_tissue_title_row
     STRCPY_TEXT_PRINT tDiveTissues
 TFT_ead_end_tissues_clock_mask2:            ; Show only clock
-    WIN_TINY  dive_custom_hud_column1,dive_custom_hud_row
+    WIN_TINY    dm_custom_clock_column,  dm_custom_clock_title_row
     STRCPY_TEXT_PRINT tDiveClock
     call	TFT_standard_color
     return
@@ -2915,7 +3115,7 @@
     global  TFT_ead_end_tissues_clock           ; Show EAD/END, Tissues and clock
 TFT_ead_end_tissues_clock:
     ; Update clock and date
-    WIN_SMALL   dive_clock_column,dive_clock_row
+    WIN_SMALL   dm_custom_clock_column, dm_custom_clock_row
     call    TFT_clock2                          ; print clock
 
 	btfsc	FLAG_apnoe_mode					; In Apnoe mode?
@@ -2960,20 +3160,20 @@
 ;TFT_ead_end_tissues_clock3:
 
     ; Show END/EAD
-    WIN_SMALL   dive_ead_column,dive_ead_row
+    WIN_SMALL   dm_custom_ead_column, dm_custom_ead_row
     STRCPY_TEXT tEAD                            ; EAD:
     movff   char_O_EAD,lo
     rcall   TFT_end_ead_common                  ; print "lo m" (or ft) and limit to 8 chars
-    WIN_SMALL   dive_end_column,dive_end_row
+    WIN_SMALL   dm_custom_end_column, dm_custom_end_row
     STRCPY_TEXT tEND                            ; END:
     movff   char_O_END,lo
     rcall   TFT_end_ead_common                  ; print "lo m" (or ft) and limit to 8 chars
 
     ; Show tissue diagram
     call    TFT_divemask_color
-    WIN_TINY    dive_tissue_N2_column,dive_tissue_N2_row
+    WIN_TINY    dm_custom_tissue_N2_column, dm_custom_tissue_N2_row
     STRCPY_TEXT_PRINT   tN2
-    WIN_TINY    dive_tissue_He_column,dive_tissue_He_row
+    WIN_TINY    dm_custom_tissue_He_column, dm_custom_tissue_He_row
     STRCPY_TEXT_PRINT   tHe
  	call    deco_calc_desaturation_time         ; calculate desaturation time (and char_O_tissue_N2_saturation and char_O_tissue_He_saturation)
 	movlb	b'00000001'                         ; select ram bank 1
@@ -3032,7 +3232,7 @@
 	movff	WREG,win_height             ; row bottom (0-239)
     movlw   surf_tissue_diagram_left+.4      ; Surface mode
 	movff	WREG,win_leftx2             ; column left (0-159)
-	movlw	surf_tissue_diagram_right-surf_tissue_diagram_left-4  ; Width
+	movlw	surf_tissue_diagram_right - surf_tissue_diagram_left - .4  ; Width
 	movff   WREG,win_width
 
     ;---- Draw N2 Tissues
@@ -3084,13 +3284,13 @@
 DISP_tissue_saturation_graph:
     ;---- Draw Frame
     call	TFT_standard_color
-    WIN_FRAME_COLOR16   tissue_diagram_top, tissue_diagram_bottom, tissue_diagram_left, .159    ; outer frame
+    WIN_FRAME_COLOR16   dm_custom_tissue_diagram_top, dm_custom_tissue_diagram_bottom, dm_custom_tissue_diagram_left, .159    ; outer frame
 
 	movlw	.1
 	movff	WREG,win_height             ; row bottom (0-239)
-    movlw   tissue_diagram_left+.3      ; divemode
+    movlw   dm_custom_tissue_diagram_left+.3      ; divemode
 	movff	WREG,win_leftx2             ; column left (0-159)
-	movlw	.159-tissue_diagram_left-4  ; Width
+	movlw	.159-dm_custom_tissue_diagram_left-.4  ; Width
 	movff   WREG,win_width
 
     ;---- Draw N2 Tissues
@@ -3099,7 +3299,7 @@
 	movwf	wait_temp                   ; 16 tissues
 	clrf	waitms_temp                 ; Row offset
 tissue_saturation_graph_N2:
-    movlw   tissue_diagram_top+3        ; divemode
+    movlw   dm_custom_tissue_diagram_top+.3        ; divemode
 	addwf	waitms_temp,W
 	movff	WREG,win_top                ; row top (0-239)
     rcall   tissue_saturation_graph_loop    ; Show one tissue
@@ -3112,7 +3312,7 @@
 	movwf	wait_temp                   ; 16 tissues
 	clrf	waitms_temp                 ; Row offset
 tissue_saturation_graph_He:
-    movlw   tissue_diagram_top+3+.22    ; divemode
+    movlw   dm_custom_tissue_diagram_top+.3+.22    ; divemode
 	addwf	waitms_temp,W
 	movff	WREG,win_top                ; row top (0-239)
 
@@ -3154,7 +3354,7 @@
 	output_16_3					;Displays only 0...999
 	bcf		leftbind
     PUTC    "%"
-    movlw   warning_length              ; Divemode string length
+    movlw   dm_warning_length              ; Divemode string length
     btfss   divemode                    ; In Divemode?
     movlw   surf_warning_length         ; No, use surface string length
     rcall   TFT_fillup_with_spaces          ; Fillup FSR2 with spaces (Total string length in #WREG)
@@ -3177,7 +3377,7 @@
 	bsf		ignore_digit4
 	output_16dp	d'1'
 TFT_show_ppO2_2:
-    movlw   warning_length              ; Divemode string length
+    movlw   dm_warning_length              ; Divemode string length
     rcall   TFT_fillup_with_spaces      ; Fillup FSR2 with spaces (Total string length in #WREG)
     STRCAT_PRINT ""
 	call	TFT_standard_color