changeset 314:226e1405b86c new_screen_layout

Merged default into new_screen_layout
author Janos Kovacs <kovjanos@gmail.com>
date Wed, 10 Jun 2015 22:24:27 +0100
parents 453a3d13570f (diff) 0ce5fa241b8e (current diff)
children 4f83470dcece
files
diffstat 8 files changed, 316 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/divemode.asm	Wed Jun 10 16:03:21 2015 +0200
+++ b/src/divemode.asm	Wed Jun 10 22:24:27 2015 +0100
@@ -995,7 +995,7 @@
 
 divemode_option3:			; minus 1m
 	banksel	isr_backup
-	movlw	d'100'
+	movlw	d'10'
 	subwf	sim_pressure+0
 	movlw	.0
 	subwfb	sim_pressure+1
@@ -1005,7 +1005,7 @@
 
 divemode_option2:			; plus 1m
 	banksel	isr_backup
-	movlw	d'100'
+	movlw	d'10'
 	addwf	sim_pressure+0
 	movlw	.0
 	addwfc	sim_pressure+1
--- a/src/divemode.inc	Wed Jun 10 16:03:21 2015 +0200
+++ b/src/divemode.inc	Wed Jun 10 22:24:27 2015 +0100
@@ -29,7 +29,7 @@
 #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_maxdepth_column   .73
 #DEFINE    dm_mask_divetime_row      .0
 #DEFINE    dm_mask_divetime_column   .122
 
@@ -45,7 +45,7 @@
 #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_rgt           dm_depth_column+.59    ; 59
 #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
@@ -53,31 +53,38 @@
 #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
+; Ascend/Descend bar
+#DEFINE    dm_velobar_top          dm_offset           ; 14  !! _top+60 must fit into sub_a+0 !!
+#DEFINE    dm_velobar_lft          dm_depth_rgt+.1     ; 62
+#DEFINE    dm_velobar_bot          dm_offset+.85       ; 99
+#DEFINE    dm_velobar_rgt          .73                 ; 73
+#DEFINE    dm_velobar_width        .12
 
 ;******* Upper content / content row / 2nd col *******
+#DEFINE    dm_upcnt_2ndcol            .74                       ; 74
 ; Max depth
 #DEFINE    dm_max_depth_row           dm_offset                 ; 14
-#DEFINE    dm_max_depth_column        .64                       ; 64
+#DEFINE    dm_max_depth_column        dm_upcnt_2ndcol           ; 74
 #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_column          dm_upcnt_2ndcol           ; 74
 #DEFINE    dm_warning_bot             dm_warning_row+.49        ; 99
-#DEFINE    dm_warning_rgt             dm_warning_column+.68     ; 130
+#DEFINE    dm_warning_rgt             dm_warning_column+.62     ; 136
 #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
+#DEFINE    dm_warning1_rgt            dm_warning_rgt            ; 136
 ; 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
+#DEFINE    dm_warning2_rgt            dm_warning_rgt            ; 136
 
 ;******* Upper content / content row / 3rd col *******
 ; Dive time
@@ -90,7 +97,7 @@
 #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_column         .137                         ; 137
 #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
--- a/src/hwos.inc	Wed Jun 10 16:03:21 2015 +0200
+++ b/src/hwos.inc	Wed Jun 10 22:24:27 2015 +0100
@@ -688,6 +688,8 @@
 
 flag13                  res 1
 #DEFINE neg_flag_save           flag13,0    ; neg_flag backup for velocity logic
+#DEFINE velocity_warn           flag13,1    ; flag set when ascend is in warning rate
+#DEFINE velocity_attn           flag13,2    ; flag set when ascend is in attention rate
 
 ;=============================================================================
 ; C-code Routines
--- a/src/text_english.inc	Wed Jun 10 16:03:21 2015 +0200
+++ b/src/text_english.inc	Wed Jun 10 22:24:27 2015 +0100
@@ -208,7 +208,7 @@
     TCODE   tSelectNx,   "Nx"               ; Nx
     TCODE   tSelectTx,   "Tx"               ; Tx
     TCODE   tDepth,      "Depth"            ; Depth
-    TCODE   tMaxDepth,   "Max. Depth"       ; Max. Depth
+    TCODE   tMaxDepth,   "Max. Depth"       ; Max. Depth - max 10chars!
     TCODE   tDivetime,   "Divetime"         ; Divetime
     TCODE   tDiveHudMask1,  "Sensor 1"
     TCODE   tDiveHudMask2,  "Sensor 2"
--- a/src/text_french.inc	Wed Jun 10 16:03:21 2015 +0200
+++ b/src/text_french.inc	Wed Jun 10 22:24:27 2015 +0100
@@ -208,7 +208,7 @@
     TCODE   tSelectNx,   "Nx"               ; Nx
     TCODE   tSelectTx,   "Tx"               ; Tx
     TCODE   tDepth,      "Prof."            ; Depth
-    TCODE   tMaxDepth,   "Prof. Max."       ; Max. Depth
+    TCODE   tMaxDepth,   "Prof. Max."       ; Max. Depth - max 10chars!
     TCODE   tDivetime,   "Durée T."         ; Divetime
     TCODE   tDiveHudMask1,   "cell. 1"
     TCODE   tDiveHudMask2,   "cell. 2"
--- a/src/text_german.inc	Wed Jun 10 16:03:21 2015 +0200
+++ b/src/text_german.inc	Wed Jun 10 22:24:27 2015 +0100
@@ -207,7 +207,7 @@
     TCODE   tSelectNx,   "Nx"               ; Nx
     TCODE   tSelectTx,   "Tx"               ; Tx
     TCODE   tDepth,      "Tiefe"            ; Depth
-    TCODE   tMaxDepth,   "Max. Tiefe"       ; Max. Depth
+    TCODE   tMaxDepth,   "Max. Tiefe"       ; Max. Depth - max 10chars!
     TCODE   tDivetime,   "    Zeit"         ; Divetime
     TCODE   tDiveHudMask1,  "Sensor 1"
     TCODE   tDiveHudMask2,  "Sensor 2"
--- a/src/text_italian.inc	Wed Jun 10 16:03:21 2015 +0200
+++ b/src/text_italian.inc	Wed Jun 10 22:24:27 2015 +0100
@@ -208,7 +208,7 @@
     TCODE   tSelectNx,   "Nx"               ; Nx
     TCODE   tSelectTx,   "Tx"               ; Tx
     TCODE   tDepth,      "Prof."            ; Depth
-    TCODE   tMaxDepth,   "Prof. Max"        ; Max. Depth
+    TCODE   tMaxDepth,   "Prof. Max"        ; Max. Depth - max 10chars!
     TCODE   tDivetime,   "Divetime"         ; Divetime
     TCODE   tDiveHudMask1,  "Sensor 1"
     TCODE   tDiveHudMask2,  "Sensor 2"
--- a/src/tft_outputs.asm	Wed Jun 10 16:03:21 2015 +0200
+++ b/src/tft_outputs.asm	Wed Jun 10 22:24:27 2015 +0100
@@ -536,6 +536,15 @@
         WIN_TINY            dm_mask_divetime_column,dm_mask_divetime_row
         STRCAT_TEXT_PRINT   tDivetime
     endif
+
+    ; DEBUG !!!
+    movlw       color_dark_red
+    call        TFT_set_color
+    WIN_FRAME_COLOR16 dm_velobar_top, dm_velobar_bot, dm_velobar_lft, dm_velobar_rgt ;top, bottom, left, right
+
+    movlw       color_blue
+    WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right
+
     call	TFT_standard_color
     return
 
@@ -548,7 +557,11 @@
 
 	global	TFT_display_velocity
 TFT_display_velocity:						; With divA+0 = m/min
-
+    ; init flags used to store warning/attention
+    bcf     velocity_warn
+    bcf     velocity_attn
+
+    ; check if old/new ascend logic is used
     TSTOSS  opt_vsitextv2       			; 0=standard, 1=dynamic
     bra     TFT_dispay_velocity_std
 
@@ -556,10 +569,11 @@
     ;   neg_flag: ascend=1, descend=0
     ;   divA+0:   rate in m/min
 
-	movlw	velocity_display_threshold_2	; lowest threshold for display vertical velocity
+    ; check if velocity is below the treshold level
+	movlw	velocity_display_threshold_2
 	subwf	divA+0,W
 	btfss	STATUS,C
-	bra		TFT_display_velocity_clear
+	bra		TFT_display_velocity_ntr
 	bsf		display_velocity
 
     ; use a depth-dependent ascent rate warning
@@ -569,11 +583,17 @@
     ; speed(m/min):    7   8   9  10  11  13   15   17   18   19   20 (warning)
 	; speed(m/min):    5   6   7   8   8  10   12   13   14   15   15 (attention)
 
+    ; w-multip         7   6   5   5   4   3    3    2    2    2    2
+    ; a-multip         6   5   4   3   3   3    2    2    2    2    2
+    ; w-offset         1   2   5   0   6  11    5   16   14   12   10
+    ; a-offset         0   0   2   6   6   0    6    4    2    0    0
+
+    ; retain the neg_flag (descending information)
     bcf     neg_flag_save
     btfsc   neg_flag
     bsf     neg_flag_save
 
-    ; no warning color if descending
+    ; check if descending: no warning color if descending
     call	TFT_standard_color
 	btfss	neg_flag                            ; Ignore for descent!
 	bra		TFT_display_velocity_out
@@ -598,6 +618,15 @@
 	movwf	xA+0
     movlw   .15                     ; store the attn limit to xA+1
     movwf   xA+1
+    ; graphical position helpers
+    movlw   .2
+    movwf   xC+0
+    movlw   .2
+    movwf   xC+1
+    movlw   .10
+    movwf   xC+2
+    movlw   .0
+    movwf   xC+3
 	; check if current depth > segment limit
 	call	subU16								;  sub_c = sub_a - sub_b;  depth - sLimit
 	btfss	neg_flag							;  depth lower than segment limit? sLimit>depth?
@@ -612,6 +641,15 @@
 	movwf	xA+0
     movlw   .15                     ; store the attn limit to xA+1
     movwf   xA+1
+    ; graphical position helpers
+    movlw   .2
+    movwf   xC+0
+    movlw   .2
+    movwf   xC+1
+    movlw   .12
+    movwf   xC+2
+    movlw   .0
+    movwf   xC+3
 	; check if current depth > segment limit
 	call	subU16								;  sub_c = sub_a - sub_b;  depth - sLimit
 	btfss	neg_flag							;  depth lower than segment limit? sLimit>depth?
@@ -626,6 +664,15 @@
 	movwf	xA+0
     movlw   .14                     ; store the attn limit to xA+1
     movwf   xA+1
+    ; graphical position helpers
+    movlw   .2
+    movwf   xC+0
+    movlw   .2
+    movwf   xC+1
+    movlw   .14
+    movwf   xC+2
+    movlw   .2
+    movwf   xC+3
 	; check if current depth > segment limit
 	call	subU16								;  sub_c = sub_a - sub_b;  depth - sLimit
 	btfss	neg_flag							;  depth lower than segment limit? sLimit>depth?
@@ -640,6 +687,15 @@
 	movwf	xA+0
     movlw   .13                     ; store the attn limit to xA+1
     movwf   xA+1
+    ; graphical position helpers
+    movlw   .2
+    movwf   xC+0
+    movlw   .2
+    movwf   xC+1
+    movlw   .16
+    movwf   xC+2
+    movlw   .4
+    movwf   xC+3
 	; check if current depth > segment limit
 	call	subU16								;  sub_c = sub_a - sub_b;  depth - sLimit
 	btfss	neg_flag							;  depth lower than segment limit? sLimit>depth?
@@ -654,6 +710,15 @@
 	movwf	xA+0
     movlw   .12                     ; store the attn limit to xA+1
     movwf   xA+1
+    ; graphical position helpers
+    movlw   .3
+    movwf   xC+0
+    movlw   .2
+    movwf   xC+1
+    movlw   .5
+    movwf   xC+2
+    movlw   .6
+    movwf   xC+3
 	; check if current depth > segment limit
 	call	subU16								;  sub_c = sub_a - sub_b;  depth - sLimit
 	btfss	neg_flag							;  depth lower than segment limit? sLimit>depth?
@@ -668,6 +733,15 @@
 	movwf	xA+0
     movlw   .10                     ; store the attn limit to xA+1
     movwf   xA+1
+    ; graphical position helpers
+    movlw   .3
+    movwf   xC+0
+    movlw   .3
+    movwf   xC+1
+    movlw   .11
+    movwf   xC+2
+    movlw   .0
+    movwf   xC+3
 	; check if current depth > segment limit
 	call	subU16								;  sub_c = sub_a - sub_b;  depth - sLimit
 	btfss	neg_flag							;  depth lower than segment limit? sLimit>depth?
@@ -682,6 +756,15 @@
 	movwf	xA+0
     movlw   .8                     ; store the attn limit to xA+1
     movwf   xA+1
+    ; graphical position helpers
+    movlw   .4
+    movwf   xC+0
+    movlw   .3
+    movwf   xC+1
+    movlw   .6
+    movwf   xC+2
+    movlw   .6
+    movwf   xC+3
 	; check if current depth > segment limit
 	call	subU16								;  sub_c = sub_a - sub_b;  depth - sLimit
 	btfss	neg_flag							;  depth lower than segment limit? sLimit>depth?
@@ -696,6 +779,15 @@
 	movwf	xA+0
     movlw   .8                     ; store the attn limit to xA+1
     movwf   xA+1
+    ; graphical position helpers
+    movlw   .5
+    movwf   xC+0
+    movlw   .3
+    movwf   xC+1
+    movlw   .0
+    movwf   xC+2
+    movlw   .6
+    movwf   xC+3
 	; check if current depth > segment limit
 	call	subU16								;  sub_c = sub_a - sub_b;  depth - sLimit
 	btfss	neg_flag							;  depth lower than segment limit? sLimit>depth?
@@ -710,6 +802,15 @@
 	movwf	xA+0
     movlw   .7                     ; store the attn limit to xA+1
     movwf   xA+1
+    ; graphical position helpers
+    movlw   .5
+    movwf   xC+0
+    movlw   .4
+    movwf   xC+1
+    movlw   .5
+    movwf   xC+2
+    movlw   .2
+    movwf   xC+3
 	; check if current depth > segment limit
 	call	subU16								;  sub_c = sub_a - sub_b;  depth - sLimit
 	btfss	neg_flag							;  depth lower than segment limit? sLimit>depth?
@@ -724,6 +825,15 @@
 	movwf	xA+0
     movlw   .6                     ; store the attn limit to xA+1
     movwf   xA+1
+    ; graphical position helpers
+    movlw   .6
+    movwf   xC+0
+    movlw   .5
+    movwf   xC+1
+    movlw   .2
+    movwf   xC+2
+    movlw   .0
+    movwf   xC+3
 	; check if current depth > segment limit
 	call	subU16								;  sub_c = sub_a - sub_b;  depth - sLimit
 	btfss	neg_flag							;  depth lower than segment limit? sLimit>depth?
@@ -736,6 +846,15 @@
 	movwf	xA+0
     movlw   .5
     movwf   xA+1
+    ; graphical position helpers
+    movlw   .7
+    movwf   xC+0
+    movlw   .6
+    movwf   xC+1
+    movlw   .1
+    movwf   xC+2
+    movlw   .0
+    movwf   xC+3
     ;bra     TFT_velocity_check                  ;  depth < 20ft / 6m
 
 TFT_velocity_check:
@@ -764,10 +883,12 @@
 TFT_velocity_warn:
 	call	TFT_warnings_color             ; Set to warning color
     bsf     win_invert
+    bsf     velocity_warn
     bra     TFT_display_velocity_out
 
 TFT_velocity_attn:
 	call	TFT_attention_color            ; Set to attention color
+    bsf     velocity_attn
     ;bra     TFT_display_velocity_out
 
 TFT_display_velocity_out:
@@ -813,6 +934,7 @@
 	STRCAT_TEXT_PRINT  tVelImperial			; Unit switch
 	call	TFT_standard_color
     bcf     win_invert
+    call    TFT_display_VSIbar
     return
 
 TFT_display_velocity_metric:
@@ -825,6 +947,142 @@
 	STRCAT_TEXT_PRINT  tVelMetric			; Unit switch
 	call	TFT_standard_color
     bcf     win_invert
+    call    TFT_display_VSIbar
+    return
+
+TFT_display_VSIbar:
+    ; use another logic when descending
+    btfss   neg_flag
+    bra     TFT_dispay_VSIbar_desc
+    btfsc   velocity_warn
+    bra     TFT_display_VSIbar_warn
+    btfsc   velocity_attn
+    bra     TFT_display_VSIbar_attn
+    ; all ok, use attn's values
+    movff   xC+1,sub_b+0    ; multiplier
+    movff   xC+3,sub_b+1    ; offset
+    bra     TFT_display_VSIbar_com
+
+TFT_display_VSIbar_warn:
+    ; save multiplier and offset out from the xC
+    movff   xC+0,sub_b+0    ; multiplier
+    movff   xC+2,sub_b+1    ; offset
+    bra     TFT_display_VSIbar_com
+
+TFT_display_VSIbar_attn:
+    ; save multiplier and offset out from the xC
+    movff   xC+1,sub_b+0    ; multiplier
+    movff   xC+3,sub_b+1    ; offset
+    ;bra     TFT_display_VSIbar_com
+
+TFT_display_VSIbar_com:
+    ; multiply
+    movff   divA+0,xA+0
+    clrf    xA+1
+    movff   sub_b+0,xB+0
+    clrf    xB+1
+    call    mult16x16               ; xA*xB=xC
+    movlw   .1
+    cpfslt  xC+3
+    bra     TFT_display_VSIbar_max
+    cpfslt  xC+2
+    bra     TFT_display_VSIbar_max
+    cpfslt  xC+1
+    bra     TFT_display_VSIbar_max
+    ; add offset
+    movff   sub_b+1,WREG
+    addwf   xC+0,1
+    btfsc   STATUS,C
+    bra     TFT_display_VSIbar_max
+    ; check if out-of-range
+    movff   xC+0,divB
+    movlw   .60
+    cpfsgt  divB
+    bra     TFT_display_VSIbar_draw
+
+TFT_display_VSIbar_max:
+    movlw   .60
+    movff   WREG,divB
+
+TFT_display_VSIbar_draw:
+    ; calculate top&height for the bar and mask
+    ; 1. Bar:  top=(bar_top+60-divB); height=divB
+    movlw   dm_velobar_top+.1
+    movff   WREG,sub_a+0                        ; !!!!!!  bar position must fit into lo !!
+    movlw   .60
+    addwf   sub_a+0,1
+    clrf    sub_a+1
+    movff   divB,sub_b+0
+    clrf    sub_b+1
+    call    subU16
+   
+    movff   sub_c+0,win_top
+    movff   divB,win_height
+    movlw   dm_velobar_width
+    movff   WREG,win_width
+    movff   WREG,win_bargraph
+    movlw   dm_velobar_lft+.1
+    movff   WREG,win_leftx2
+    movlw   color_green
+    call    TFT_set_color
+    btfsc   velocity_attn
+    call    TFT_attention_color
+    btfsc   velocity_warn
+    call    TFT_warnings_color
+    call    TFT_box
+
+    ;clear the rest
+    movlw   .60
+    cpfslt  divB
+    return  ; divB !< 60 - the graph uses the full bar, no need to clear
+
+    ; 2. Mask: top=bar_top; height=60-divB
+    movlw   .60
+    movff   WREG,sub_a+0
+    clrf    sub_a+1
+    movff   divB,sub_b+0
+    clrf    sub_b+1
+    call    subU16              ; sub_c = sub_a - sub_b
+
+    movlw   dm_velobar_top+.1
+    movff   WREG,win_top
+    movff   sub_c+0,win_height
+    movlw   dm_velobar_width
+    movff   WREG,win_width
+    movff   WREG,win_bargraph
+    movlw   dm_velobar_lft+.1
+    movff   WREG,win_leftx2
+    movlw   color_black
+    call    TFT_set_color
+    call    TFT_box
+    return
+
+TFT_dispay_VSIbar_desc:
+    ; clear the ascend part of the bar
+    call    TFT_display_VSIbar_clr
+    ; TODO
+    return
+
+TFT_display_VSIbar_clr: ; clears the ascend part of hte bar
+    WIN_BOX_BLACK   dm_velobar_top+.1,dm_velobar_top+.59,dm_velobar_lft+.1,dm_velobar_rgt-.1
+    movlw       color_blue
+    WIN_BOX_COLOR dm_velobar_top+.60, dm_velobar_top+.63, dm_velobar_lft+.1, dm_velobar_rgt-.1 ;top, bottom, left, right
+    return
+
+TFT_display_velocity_ntr:   ; velocity under treshold
+    call    TFT_display_velocity_clear
+    ; use another logic when descending
+    btfss   neg_flag
+    bra     TFT_dispay_VSIbar_desc
+    movlw   .7
+    movwf   xC+0
+    movlw   .6
+    movwf   xC+1
+    movlw   .1
+    movwf   xC+2
+    movlw   .0
+    movwf   xC+3
+    call    TFT_display_VSIbar
     return
 
 	global	TFT_display_velocity_clear
@@ -1593,6 +1851,7 @@
 	call	TFT_warning_set_window		; Sets the row and column for the current warning
     tstfsz  WREG                        ; Is there room for the warning?
     return                              ; No
+    call    TFT_warning_set_window_com
 	STRCPY	"Int:"
 	movff	surface_interval+0,lo
 	movff	surface_interval+1,hi
@@ -1607,6 +1866,7 @@
     movlw   surf_warning_length         ; No, use surface string length
     call    TFT_fillup_with_spaces      ; Fillup FSR2 with spaces (Total string length in #WREG)
 	STRCAT_PRINT ""
+    call    TFT_warning_set_window_end
 	return
 
     global  TFT_surface_decosettings    ; Show all deco settings
@@ -1683,7 +1943,7 @@
 	call	TFT_warning_set_window		; Sets the row and column for the current warning
     tstfsz  WREG                        ; Is there room for the warning?
     return                              ; No
-
+    call    TFT_warning_set_window_com
     call	TFT_standard_color
     STRCPY  0x94                        ; "End of dive" icon
     movlw   LOW     divemode_timeout
@@ -1706,6 +1966,7 @@
     movlw   dm_warning_length             ; Divemode string length
     call    TFT_fillup_with_spaces     ; Fillup FSR2 with spaces (Total string length in #WREG)
 	STRCAT_PRINT ""
+    call    TFT_warning_set_window_end
 	return
 
 	global	TFT_ftts
@@ -1720,6 +1981,7 @@
         call    TFT_warning_set_window		; Sets the row and column for the current warning
         tstfsz  WREG                        ; Is there room for the warning?
         return                              ; No
+        call    TFT_warning_set_window_com
     else
         call    TFT_standard_color
         WIN_SMALL dm_ftts_value_column, dm_ftts_value_row
@@ -1745,6 +2007,7 @@
     movlw   dm_warning_length             ; Divemode string length
     call    TFT_fillup_with_spaces     ; Fillup FSR2 with spaces (Total string length in #WREG)
 	STRCAT_PRINT ""
+    call    TFT_warning_set_window_end
 	return
 
 TFT_ftts2:
@@ -1753,6 +2016,7 @@
     movlw   dm_warning_length             ; Divemode string length
     call    TFT_fillup_with_spaces     ; Fillup FSR2 with spaces (Total string length in #WREG)
     STRCAT_PRINT ""
+    call    TFT_warning_set_window_end
     return
 
 
@@ -2636,6 +2900,7 @@
 
 TFT_max_pressure2_metric:
     WIN_MEDIUM	dm_max_depth_column, dm_max_depth_row
+    call    TFT_standard_color
 
 	movlw	.039
 	cpfslt	hi
@@ -3138,6 +3403,7 @@
 	rcall	TFT_warning_set_window		; Sets the row and column for the current warning
     tstfsz  WREG                        ; Is there room for the warning?
     return                              ; No
+    call    TFT_warning_set_window_com
 	STRCPY	"Desat:"
 	movff		desaturation_time+0,lo			; divide by 60...
 	movff		desaturation_time+1,hi
@@ -3156,6 +3422,7 @@
     movlw   .0
     movff   WREG,buffer+11
 	STRCAT_PRINT	""
+    call    TFT_warning_set_window_end
 	return
 
 	global	TFT_nofly_time
@@ -3163,6 +3430,7 @@
 	rcall	TFT_warning_set_window		; Sets the row and column for the current warning
     tstfsz  WREG                        ; Is there room for the warning?
     return                              ; No
+    call    TFT_warning_set_window_com
 	STRCPY	"NoFly:"
 	movff		nofly_time+0,lo			; divide by 60...
 	movff		nofly_time+1,hi
@@ -3181,6 +3449,7 @@
     movlw   .0
     movff   WREG,buffer+11
 	STRCAT_PRINT	""
+    call    TFT_warning_set_window_end
 	return
 
     global  TFT_warning_agf
@@ -3188,12 +3457,14 @@
 	rcall	TFT_warning_set_window		; Sets the row and column for the current warning
     tstfsz  WREG                        ; Is there room for the warning?
     return                              ; No
+    call    TFT_warning_set_window_com
     call	TFT_warnings_color
 	STRCPY_TEXT tDiveaGF_active         ; "aGF!"
     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
+    call    TFT_warning_set_window_end
     return
 
     global  TFT_warning_fallback
@@ -3214,6 +3485,7 @@
 	rcall	TFT_warning_set_window		; Sets the row and column for the current warning
     tstfsz  WREG                        ; Is there room for the warning?
     return                              ; No
+    call    TFT_warning_set_window_com
 	TFT_color_code		warn_gf		; Color-code Output
 	STRCPY  "GF:"
 	movff	char_O_gradient_factor,lo		; gradient factor
@@ -3227,6 +3499,7 @@
     STRCAT_PRINT  ""
     bcf     leftbind
 	call	TFT_standard_color
+    call    TFT_warning_set_window_end
 	return
 
 TFT_warning_set_window:                 ; Sets the row and column for the current warning
@@ -3263,12 +3536,22 @@
     bsf     second_row_warning          ; =1: The second row contains a warning
 	retlw   .0                          ; WREG=0 -> Warning window defined
 
+TFT_warning_set_window_com:
+    if dm_offset == 0
+        bsf     win_invert
+    endif
+    return
+
+TFT_warning_set_window_end:
+    bcf     win_invert
+    return
 
 	global	TFT_update_batt_percent_divemode
 TFT_update_batt_percent_divemode:
 	rcall	TFT_warning_set_window		; Sets the row and column for the current warning
     tstfsz  WREG                        ; Is there room for the warning?
     return                              ; No
+    call    TFT_warning_set_window_com
     movff   batt_percent,lo         ; Get battery percent
     TFT_color_code		warn_battery; Color-code battery percent
     STRCPY  "Batt:"
@@ -3282,9 +3565,9 @@
     rcall   TFT_fillup_with_spaces      ; Fillup FSR2 with spaces (Total string length in #WREG)
 	STRCAT_PRINT	""
 	call	TFT_standard_color
+    call    TFT_warning_set_window_end
 	return
 
-
     global  TFT_gf_mask                         ; Setup Mask
 TFT_gf_mask:
     ; The mask
@@ -3599,6 +3882,7 @@
 	rcall	TFT_warning_set_window		; Sets the row and column for the current warning
     tstfsz  WREG                        ; Is there room for the warning?
     return                              ; No
+    call    TFT_warning_set_window_com
 	TFT_color_code		warn_cns		; Color-code CNS output
 	STRCPY_TEXT tCNS2                   ; CNS:
 	movff	int_O_CNS_fraction+0,lo
@@ -3613,6 +3897,7 @@
     rcall   TFT_fillup_with_spaces          ; Fillup FSR2 with spaces (Total string length in #WREG)
 	STRCAT_PRINT ""
 	call	TFT_standard_color
+    call    TFT_warning_set_window_end
 	return
 
 	global	TFT_display_ppo2
@@ -3620,6 +3905,7 @@
 	rcall	TFT_warning_set_window		; Sets the row and column for the current warning
     tstfsz  WREG                        ; Is there room for the warning?
     return                              ; No
+    call    TFT_warning_set_window_com
 	TFT_color_code		warn_ppo2		; Color-code output (ppO2 stored in xC)
     STRCPY_TEXT tppO2                   ; ppO2:
 ; Check very high ppO2 manually
@@ -3634,6 +3920,7 @@
     rcall   TFT_fillup_with_spaces      ; Fillup FSR2 with spaces (Total string length in #WREG)
     STRCAT_PRINT ""
 	call	TFT_standard_color
+    call    TFT_warning_set_window_end
 	return
 
 TFT_show_ppO2_3: