changeset 873:e373e90a48db Evo_2_23

merge new screen stuff
author heinrichsweikamp
date Wed, 14 Aug 2024 16:44:46 +0200
parents 5e027b0f7475 (diff) f7318457df4d (current diff)
children fbb6f8f41e0a
files Common/Inc/settings.h Discovery/Inc/ostc_discovery.h Discovery/Inc/ostc_hw1.h Discovery/Inc/text_multilanguage.h Discovery/Src/check_warning.c Discovery/Src/data_central.c Discovery/Src/display.c Discovery/Src/gfx_engine.c Discovery/Src/settings.c Discovery/Src/tComm.c Discovery/Src/text_multilanguage.c RefPrj/Firmware/.cproject
diffstat 77 files changed, 3373 insertions(+), 1488 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BootLoader/CPU1-F429_boot.ld	Wed Aug 14 16:44:46 2024 +0200
@@ -0,0 +1,597 @@
+/*****************************************************************************
+ * -*- coding: UTF-8 -*-
+ *
+ * \file   Common/CPU1-F429.ld
+ * \brief  Linker Script for CPU1 alias Discovery
+ * \author Ac6 workbench, Heinrichs Weikamp, and JD Gascuel
+ * \date   2018
+ *
+ * \details
+ *  Linker script for STM32F429IIT6 Device from STM32F4 series
+ *  - 192Kbytes RAM
+ *  - 2048Kbytes ROM
+ *
+ *  Set heap size, stack size and stack location according
+ *  to application requirements.
+ *
+ *  Set memory bank area and size if external memory is used.
+ *
+ * $Id$
+ *****************************************************************************
+ * \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
+ *
+ *     This program is free software: you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation, either version 3 of the License, or
+ *     (at your option) any later version.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *****************************************************************************
+ * HISTORY
+ *  2017-12-18 jDG: Mix between std AC6 file and chw stm32f429zi_flash.ld settings.
+ */
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+SEARCH_DIR(.)
+
+/****************************************************************************/
+/***************************** Memory Definition ****************************/
+MEMORY
+{
+  ROM_BOOT  (rx) : ORIGIN = 0x08000000, LENGTH = 0x00040000 /* 256K */
+    ROM  (rx) : ORIGIN = 0x08040000, LENGTH = 0x00090000 /* 576K */
+    UPPER(rx) : ORIGIN = 0x08132000, LENGTH = 0xAE270 /* 713K */
+    RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 192K
+  CCRAM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K
+}
+
+/* Linker file shall be shared between Bootloader, Font and Firmware projects. Not used memory areas to be cut during bin generation */
+
+/* Make sure ROM and UPPER are contiguous, and map 2MB */
+/* TODO: At the moment the size of the defined memory will be directly reflected into the file size of resultion bin => Keep small until not used memory may be excluded from build */
+/*ASSERT( ORIGIN(UPPER) - ORIGIN(ROM) == LENGTH(ROM), "ROM lower and upper region shall be continuous" )
+/*ASSERT( LENGTH(ROM) + LENGTH(UPPER) == 2048K, "ROM lower + upper regions = 2MB" ) */
+
+/* Highest address of the user mode stack */
+/*_estack = ORIGIN(RAM) + LENGTH(RAM);*/
+
+
+_Min_Heap_Size  = 0;      	/* no required heap  (malloc'ed space) */
+_Min_Stack_Size = 0x08000; 	/* required 32K of stack */
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ *   Reset_Handler : Entry of reset handler
+ * 
+ * It defines following symbols, which code can use without definition:
+ *   __exidx_start
+ *   __exidx_end
+ *   __preinit_array_start
+ *   __preinit_array_end
+ *   __init_array_start
+ *   __init_array_end
+ *   __fini_array_start
+ *   __fini_array_end
+ *	 _sbss
+ *   __bss_start__
+ *	 _ebss
+ *   __bss_end__
+ *   _edata
+ *   end
+ *   _end
+ *   _estack
+ */
+
+/****************************************************************************/
+/*************************** Code and Data Sections *************************/
+SECTIONS
+{
+  /******************* NVIC reset and interupt vectors **********************/
+ 
+  .isr_vector 0x08000000 :
+  {
+  . = ALIGN(4);
+    KEEP( *(.isr_vector) ) 
+    KEEP(*(.init))
+  } >ROM_BOOT
+
+
+ .StdLibs 0x08000200:
+  {
+  . = ALIGN(4);
+     *libm.a:*(*)
+  } >ROM_BOOT
+
+  .rodata :
+  {
+    . = ALIGN(4);
+    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
+    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
+    . = ALIGN(4);
+  } >ROM_BOOT
+
+ /********************** Constant data into ROM memory *********************/
+
+
+  .ARM.extab   : { 
+  	. = ALIGN(4);
+  	*(.ARM.extab* .gnu.linkonce.armextab.*)
+  	. = ALIGN(4);
+  } >ROM_BOOT
+  
+  .ARM : {
+    . = ALIGN(4);
+    __exidx_start = .;
+    *(.ARM.exidx*)
+    __exidx_end = .;
+    . = ALIGN(4);
+  } >ROM_BOOT
+  
+   .preinit_array     :
+  {
+    . = ALIGN(4);
+    PROVIDE_HIDDEN( __preinit_array_start = . );
+    KEEP( *(.preinit_array*) )
+    PROVIDE_HIDDEN( __preinit_array_end = . );
+    . = ALIGN(4);
+  } >ROM_BOOT
+  
+  .init_array :
+  {
+    . = ALIGN(4);
+    PROVIDE_HIDDEN( __init_array_start = . );
+    KEEP( *(SORT(.init_array.*)) )
+    KEEP( *(.init_array*) )
+    PROVIDE_HIDDEN( __init_array_end = . );
+    . = ALIGN(4);
+  } >ROM_BOOT
+  
+  .fini_array :
+  {
+    . = ALIGN(4);
+    PROVIDE_HIDDEN( __fini_array_start = . );
+    KEEP( *(SORT(.fini_array.*)) )
+    KEEP( *(.fini_array*) )
+    PROVIDE_HIDDEN( __fini_array_end = . );
+    . = ALIGN(4);
+  } >ROM_BOOT
+  
+    /************* The program code and other data into ROM memory ************/
+
+/*
+ .firmware_FirmwareData 0x08050000 : {
+ 	KEEP( *(.firmware_firmware_data) )
+  } >ROM
+  
+  .font_firmware_data 0x08132000 : {
+  	KEEP( *(.font_firmware_data) ) 
+  	  
+  } >UPPER
+  */
+  
+    /************* Data and Structures at absolute address in ROM *************/
+ 
+ /* FIXME: this sets the SFirmwareData structure, not the code ... */
+ .bootloader_firmware_data 0x0800A000 : {
+ 	PROVIDE( bootloader_FirmwareData = . );
+ 	KEEP( *(.bootloader_firmware_data) )
+ } > ROM_BOOT
+ 
+ 
+ 
+  .text 0x08001000 :
+  {
+    . = ALIGN(4);
+    *(.text.HAL*)
+    . = ALIGN(4);
+  } >ROM_BOOT
+ 
+ 
+  .text2 0x0800A100 :
+  {
+    . = ALIGN(4);
+    *(.text)           /* .text sections (code) */
+    *(.text*)          /* .text* sections (code) */
+    *(.glue_7)         /* glue arm to thumb code */
+    *(.glue_7t)        /* glue thumb to arm code */
+    *(.eh_frame)
+    . = ALIGN(4);
+    _etext = .;        /* define a global symbols at end of code */
+  } >ROM_BOOT
+ 
+
+ 	
+    /* Define Known Address for Each Font */
+    /* Flash Sector 23 is protected (bootloader font + image) => use end of sector 22 */
+
+.lower_fonts 	0x08016000  : {
+	 *(.lower_fonts.image_data_*)
+	 *(.lower_fonts.*)
+	 *(.upper_fonts.image_data_FontT48*) 
+	 *(.upper_fonts.FontT48*)
+	 *(.upper_fonts.image_data_FontT24*) 
+	 *(.upper_fonts.FontT24*)
+} > ROM_BOOT
+
+.lower_directory 0x08004000 : {
+	*(.lower_font_directory*)
+	*(.upper_font_directory.FontT48*)
+	*(.upper_font_directory.FontT24*)
+} > ROM_BOOT
+
+
+.lower_image	0x08009000  : {
+	 *(.lower_image*)
+	  
+} > ROM_BOOT
+
+.lower_directory 0x08009500 : {
+	*(.lower_image_directory*)
+} > ROM_BOOT
+
+  .upper_fonts 	0x08132040  : {
+  	__upper_font_data = .;
+  	 . = 0x13E; 
+  	 *(.upper_fonts.image_data_FontT144_0x0030)
+  	 . = 0x02515; 
+  	 *(.upper_fonts.image_data_FontT144_0x0031)
+  	 . = 0x03469; 
+  	 *(.upper_fonts.image_data_FontT144_0x0032)
+  	 . = 0x4FDC; 
+  	 *(.upper_fonts.image_data_FontT144_0x0033)
+  	 . = 0x6862; 
+  	 *(.upper_fonts.image_data_FontT144_0x0034)
+  	 . = 0x86C2; 
+  	 *(.upper_fonts.image_data_FontT144_0x0035)
+  	 . = 0x9FB3; 
+  	 *(.upper_fonts.image_data_FontT144_0x0036)
+  	 . = 0xBB26; 
+  	 *(.upper_fonts.image_data_FontT144_0x0037)
+  	 . = 0xD845; 
+  	 *(.upper_fonts.image_data_FontT144_0x0038)
+  	 . = 0xF34D;
+  	 *(.upper_fonts.image_data_FontT144_0x0039)
+  	 . = 0x10EC0;
+  	 *(.upper_fonts.image_data_FontT24_0x0020)
+  	 *(.upper_fonts.image_data_FontT24_0x0021)
+  	 *(.upper_fonts.image_data_FontT24_0x0022)
+  	 *(.upper_fonts.image_data_FontT24_0x0023)
+  	 *(.upper_fonts.image_data_FontT24_0x0024)
+  	 *(.upper_fonts.image_data_FontT24_0x0025)
+  	 *(.upper_fonts.image_data_FontT24_0x0026)
+  	 *(.upper_fonts.image_data_FontT24_0x0027)
+  	 *(.upper_fonts.image_data_FontT24_0x0028)
+  	 *(.upper_fonts.image_data_FontT24_0x0029)
+  	 *(.upper_fonts.image_data_FontT24_0x002a)
+  	 *(.upper_fonts.image_data_FontT24_0x003f)
+  	 *(.upper_fonts.image_data_FontT24_0x002c)
+  	 *(.upper_fonts.image_data_FontT24_0x002d)
+  	 *(.upper_fonts.image_data_FontT24_0x002e)
+  	 *(.upper_fonts.image_data_FontT24_0x002f)
+     *(.upper_fonts.image_data_FontT24_0x0030)
+  	 *(.upper_fonts.image_data_FontT24_0x0031)
+  	 *(.upper_fonts.image_data_FontT24_0x0032)
+  	 *(.upper_fonts.image_data_FontT24_0x0033)
+  	 *(.upper_fonts.image_data_FontT24_0x0034)
+  	 *(.upper_fonts.image_data_FontT24_0x0035)
+  	 *(.upper_fonts.image_data_FontT24_0x0036)
+  	 *(.upper_fonts.image_data_FontT24_0x0037)
+  	 *(.upper_fonts.image_data_FontT24_0x0038)
+  	 *(.upper_fonts.image_data_FontT24_0x0039)
+  	 *(.upper_fonts.image_data_FontT24_0x003a)
+  	 *(.upper_fonts.image_data_FontT24_0x003b)
+  	 *(.upper_fonts.image_data_FontT24_0x003c)
+  	 *(.upper_fonts.image_data_FontT24_0x003d)
+  	 *(.upper_fonts.image_data_FontT24_0x003e)
+  	 . = . + 0x8c;
+     *(.upper_fonts.image_data_FontT24_0x0040)
+  	 *(.upper_fonts.image_data_FontT24_0x0041)
+  	 *(.upper_fonts.image_data_FontT24_0x0042)
+  	 *(.upper_fonts.image_data_FontT24_0x0043)
+  	 *(.upper_fonts.image_data_FontT24_0x0044)
+  	 *(.upper_fonts.image_data_FontT24_0x0045)
+  	 *(.upper_fonts.image_data_FontT24_0x0046)
+  	 *(.upper_fonts.image_data_FontT24_0x0047)
+  	 *(.upper_fonts.image_data_FontT24_0x0048)
+  	 *(.upper_fonts.image_data_FontT24_0x0049)
+  	 *(.upper_fonts.image_data_FontT24_0x004a)
+  	 *(.upper_fonts.image_data_FontT24_0x004b)
+  	 *(.upper_fonts.image_data_FontT24_0x004c)
+  	 *(.upper_fonts.image_data_FontT24_0x004d)
+  	 *(.upper_fonts.image_data_FontT24_0x004e)  	
+  	 *(.upper_fonts.image_data_FontT24_0x004f)   
+     *(.upper_fonts.image_data_FontT24_0x0050)
+  	 *(.upper_fonts.image_data_FontT24_0x0051)
+  	 *(.upper_fonts.image_data_FontT24_0x0052)
+  	 *(.upper_fonts.image_data_FontT24_0x0053)
+  	 *(.upper_fonts.image_data_FontT24_0x0054)
+  	 *(.upper_fonts.image_data_FontT24_0x0055)
+  	 *(.upper_fonts.image_data_FontT24_0x0056)
+  	 *(.upper_fonts.image_data_FontT24_0x0057)
+  	 *(.upper_fonts.image_data_FontT24_0x0058)
+  	 *(.upper_fonts.image_data_FontT24_0x0059)
+  	 *(.upper_fonts.image_data_FontT24_0x005a)
+  	 *(.upper_fonts.image_data_FontT24_0x005b)
+  	 *(.upper_fonts.image_data_FontT24_0x005c)
+  	 *(.upper_fonts.image_data_FontT24_0x005d)
+  	 *(.upper_fonts.image_data_FontT24_0x005e)  	
+  	 *(.upper_fonts.image_data_FontT24_0x005f)    
+  	 *(.upper_fonts.image_data_FontT24_0x0060)
+  	 *(.upper_fonts.image_data_FontT24_0x0061)
+  	 *(.upper_fonts.image_data_FontT24_0x0062)
+  	 *(.upper_fonts.image_data_FontT24_0x0063)
+  	 . = . + 0x1c;
+  	 *(.upper_fonts.image_data_FontT24_0x0064)
+  	 *(.upper_fonts.image_data_FontT24_0x0065)
+  	 *(.upper_fonts.image_data_FontT24_0x0066)
+  	 *(.upper_fonts.image_data_FontT24_0x0067)
+  	 *(.upper_fonts.image_data_FontT24_0x0068)
+  	 *(.upper_fonts.image_data_FontT24_0x0069)
+  	 *(.upper_fonts.image_data_FontT24_0x006a)
+  	 *(.upper_fonts.image_data_FontT24_0x006b)
+  	 *(.upper_fonts.image_data_FontT24_0x006c)
+  	 *(.upper_fonts.image_data_FontT24_0x006d)
+  	 *(.upper_fonts.image_data_FontT24_0x006e)  	
+  	 *(.upper_fonts.image_data_FontT24_0x006f)  	 
+  	 *(.upper_fonts.image_data_FontT24_0x0070)
+  	 *(.upper_fonts.image_data_FontT24_0x0071)
+  	 *(.upper_fonts.image_data_FontT24_0x0072)
+  	 *(.upper_fonts.image_data_FontT24_0x0073)
+  	 *(.upper_fonts.image_data_FontT24_0x0074)
+  	 *(.upper_fonts.image_data_FontT24_0x0075)
+  	 *(.upper_fonts.image_data_FontT24_0x0076)
+  	 *(.upper_fonts.image_data_FontT24_0x0077)
+  	 *(.upper_fonts.image_data_FontT24_0x0078)
+  	 *(.upper_fonts.image_data_FontT24_0x0079)
+  	 *(.upper_fonts.image_data_FontT24_0x007a)
+  	 *(.upper_fonts.image_data_FontT24_0x007b)
+  	 *(.upper_fonts.image_data_FontT24_0x007c)
+  	 . = . + 0x1c;
+  	 *(.upper_fonts.image_data_FontT24_0x007d)
+  	 *(.upper_fonts.image_data_FontT24_0x007e)  	
+  	 *(.upper_fonts.image_data_FontT24_0x00a1)
+  	 *(.upper_fonts.image_data_FontT24_0x00bf)    
+  	 *(.upper_fonts.image_data_FontT24_0x00c1)
+  	 *(.upper_fonts.image_data_FontT24_0x00c4)  
+  	 *(.upper_fonts.image_data_FontT24_0x00c6) 
+  	 *(.upper_fonts.image_data_FontT24_0x00c7)
+  	 *(.upper_fonts.image_data_FontT24_0x00c9)
+  	 *(.upper_fonts.image_data_FontT24_0x00cd)
+  	 *(.upper_fonts.image_data_FontT24_0x00d1)
+  	 *(.upper_fonts.image_data_FontT24_0x00d3)
+  	 *(.upper_fonts.image_data_FontT24_0x00d6)
+  	 *(.upper_fonts.image_data_FontT24_0x00da)
+  	 *(.upper_fonts.image_data_FontT24_0x00dc)
+  	 *(.upper_fonts.image_data_FontT24_0x00df) 
+  	 *(.upper_fonts.image_data_FontT24_0x00e0)
+  	 *(.upper_fonts.image_data_FontT24_0x00e1)
+  	 *(.upper_fonts.image_data_FontT24_0x00e2)
+  	 *(.upper_fonts.image_data_FontT24_0x00e4)
+  	 *(.upper_fonts.image_data_FontT24_0x00e6)
+  	 *(.upper_fonts.image_data_FontT24_0x00e7)
+  	 *(.upper_fonts.image_data_FontT24_0x00e8)
+  	 *(.upper_fonts.image_data_FontT24_0x00e9)         
+  	 *(.upper_fonts.image_data_FontT24_0x00ec)
+  	 *(.upper_fonts.image_data_FontT24_0x00ed)
+  	 *(.upper_fonts.image_data_FontT24_0x00f0)
+  	 *(.upper_fonts.image_data_FontT24_0x00f1)
+  	 *(.upper_fonts.image_data_FontT24_0x00f2)
+  	 *(.upper_fonts.image_data_FontT24_0x00f3)
+  	 *(.upper_fonts.image_data_FontT24_0x00f6)
+  	 *(.upper_fonts.image_data_FontT24_0x00f9)
+  	 *(.upper_fonts.image_data_FontT24_0x00fa)
+  	 *(.upper_fonts.image_data_FontT24_0x00fc)         
+  	 *(.upper_fonts.image_data_FontT24_0x00ff)
+  	 *(.upper_fonts.image_data_FontT24_0x0152)
+  	 *(.upper_fonts.image_data_FontT24_0x0153)
+  	 *(.upper_fonts.image_data_FontT24_0x0178)
+  	 *(.upper_fonts.image_data_FontT24_0x002b)
+  	 . =  . + 0x1d642;
+  	  *(.upper_images.image_data_ostc_fuer_Tauchcomputer_240px)
+	 *(.upper_fonts.image_data_FontT84_0x002e)
+	  . =  . + 0x9f;
+	 *(.upper_fonts.image_data_FontT84_0x0030)
+	  . =  . + 0x0d;
+	 *(.upper_fonts.image_data_FontT84_0x0031)
+	  . =  . + 0xaa;
+	 *(.upper_fonts.image_data_FontT84_0x0032)
+	  . =  . + 0x7b;
+	 *(.upper_fonts.image_data_FontT84_0x0033)
+	  . =  . + 0x38;
+	 *(.upper_fonts.image_data_FontT84_0x0034)
+	  . =  . + 0x7f;
+	 *(.upper_fonts.image_data_FontT84_0x0035)
+	  . =  . + 0x77;
+	 *(.upper_fonts.image_data_FontT84_0x0036)
+	  . =  . + 0x7b;
+	 *(.upper_fonts.image_data_FontT84_0x0037)
+	 . =  . + 0x0d;
+	 *(.upper_fonts.image_data_FontT84_0x0038)
+	 . =  . + 0x2b;
+	 *(.upper_fonts.image_data_FontT84_0x0039)
+	 . =  . + 0xe8;
+  	 *(.upper_fonts.image_data_FontT54_0x0022)
+  	 *(.upper_fonts.image_data_FontT54_0x0025)
+  	 . =  . + 0x112;
+  	 *(.upper_fonts.image_data_FontT54_0x0027)
+  	 . =  . + 0xd8;
+  	 *(.upper_fonts.image_data_FontT54_0x002a)
+  	 . =  . + 0x133;
+     *(.upper_fonts.image_data_FontT54_0x002d)
+  	 . =  . + 0x1d7;
+  	 *(.upper_fonts.image_data_FontT54_0x002e)
+  	 . =  . + 0x17b;
+  	 *(.upper_fonts.image_data_FontT54_0x002f)
+  	 . =  . + 0x02;
+  	 *(.upper_fonts.image_data_FontT54_0x0030)
+  	 . =  . + 0x0ba;
+  	 *(.upper_fonts.image_data_FontT54_0x0031)
+  	 . =  . + 0x27d;
+  	 *(.upper_fonts.image_data_FontT54_0x0032)
+  	 . =  . + 0xe3;
+  	 *(.upper_fonts.image_data_FontT54_0x0033)
+  	 . =  . + 0x35;
+  	 *(.upper_fonts.image_data_FontT54_0x0034)
+  	 . =  . + 0x68;
+  	 *(.upper_fonts.image_data_FontT54_0x0035)
+  	 . =  . + 0x35;
+  	 *(.upper_fonts.image_data_FontT54_0x0036)
+  	 . =  . + 0xba;
+  	 *(.upper_fonts.image_data_FontT54_0x0037)
+  	 . =  . + 0x191;
+  	 *(.upper_fonts.image_data_FontT54_0x0038)
+  	 . =  . + 0xe3;
+  	 *(.upper_fonts.image_data_FontT54_0x0039)
+  	 . =  . + 0xe3;
+  	 *(.upper_fonts.image_data_FontT54_0x003a)
+  	 . =  . + 0x7b;
+  	 *(.upper_fonts.image_data_FontT54_0x0043)
+  	 . =  . + 0x3b;
+  	 *(.upper_fonts.image_data_FontT54_0x006c)
+  	 . =  . + 0x2d;
+  	 *(.upper_fonts.image_data_FontT54_0x006d)
+  	 . =  . + 0x94;
+  	 *(.upper_fonts.image_data_FontT54_0x00ba)
+  	 . =  . + 0x0a;
+  	 
+  	 *(.upper_fonts.image_data_FontT105_0x002*)
+  	 *(.upper_fonts.image_data_FontT105_0x003*)
+  	 *(.upper_fonts.image_data_FontT105_0x0043)
+  	 . =  . + 0x17c8;
+  	 *(.upper_fonts.image_data_FontT105_0x007c)
+  	 *(.upper_fonts.image_data_FontT105_0x00ba)
+  	 *(.upper_fonts.image_data_FontT105_54_0x006d)
+  	 
+	 *(.upper_fonts.image_data_FontT54_0x0068)
+	 . =  . + 0x1195;
+	 
+	 *(.upper_fonts.image_data_FontT42_0x00b0)
+	 *(.upper_fonts.image_data_FontT42_0x0020)
+	  . =  . + 0x23;
+	 *(.upper_fonts.image_data_FontT42_0x002*)
+	 *(.upper_fonts.image_data_FontT42_0x003*)
+	 *(.upper_fonts.image_data_FontT42_0x004*)
+	 *(.upper_fonts.image_data_FontT42_0x005*)
+	 . =  . + 0x420;
+	 *(.upper_fonts.image_data_FontT42_0x006*)
+	 *(.upper_fonts.image_data_FontT42_0x0070)
+	 *(.upper_fonts.image_data_FontT42_0x0071)
+	 *(.upper_fonts.image_data_FontT42_0x0072)
+	 *(.upper_fonts.image_data_FontT42_0x0073)
+	 *(.upper_fonts.image_data_FontT42_0x0074)
+	 *(.upper_fonts.image_data_FontT42_0x0075)
+	 *(.upper_fonts.image_data_FontT42_0x0076)
+	 *(.upper_fonts.image_data_FontT42_0x0077)
+	 *(.upper_fonts.image_data_FontT42_0x0078)
+	 *(.upper_fonts.image_data_FontT42_0x0079)
+	 . =  . + 0x12c0;
+  	 *(.upper_fonts.image_data_FontT42_*)
+  	 *(.upper_fonts.image_data_T54addon_0x002b_PLUS*)
+  	 *(.upper_fonts.image_data_T54addon_0x0040_AT*)
+  	 *(.upper_fonts.image_data_FontT48addon*)
+  	 *(.upper_fonts.image_data_FontT24plus_0x00fb*)
+  	 *(.upper_fonts.image_data_FontT24plus_0x00fd*)
+  	 *(.upper_fonts.image_data_FontT48_*) 	 
+  	 *(.upper_fonts.image_data_awe48_*)
+  
+/* moving of fonts from lower to upper */  	 
+  	 
+	 *(.upper_fonts.*) 
+	 
+  	__upper_font_data_end = .;
+  } >UPPER
+
+ 
+
+  .upper_directory 0x081DEF00 : {
+      __font_directory = .;
+	*(.upper_font_directory.Awe48)
+	*(.upper_font_directory.FontT24)
+	*(.upper_font_directory.FontT42)
+	*(.upper_font_directory.FontT48)
+	*(.upper_font_directory.FontT54)
+	*(.upper_font_directory.FontT84)
+	*(.upper_font_directory.FontT105)
+	*(.upper_font_directory.FontT144)
+	*(.upper_font_directory.Batt24*)
+		
+	__font_directory_end = .;
+  	LONG( -1 );	/* Magic End Marker */
+
+  } >UPPER  
+
+
+
+
+  
+  /* Used by the startup to initialize data */
+_sidata = LOADADDR(.data);
+
+  /************ Initialized Data Sections into RAM & ROM Memory **************/
+  .data : 
+  {
+    . = ALIGN(4);
+    
+    _sdata = .;        /* create a global symbol at data start */
+    *(.data)           /* .data sections */
+    *(.data*)          /* .data* sections */
+	*(vtable)
+
+    . = ALIGN(4);
+    _edata = .;        /* define a global symbol at data end */
+  } >RAM AT>ROM_BOOT
+  
+ 
+
+  /*************** Uninitialized Data Section into RAM Memory ****************/
+  .bss :
+  {
+	. = ALIGN(4);
+    
+    /* This is used by the startup in order to initialize the .bss secion */
+    _sbss = .;         /* define a global symbol at bss start */
+    __bss_start__ = _sbss;
+    *(.bss)
+    *(.bss*)
+    *(COMMON)
+
+    . = ALIGN(4);
+    _ebss = .;         /* define a global symbol at bss end */
+    __bss_end__ = _ebss;
+  } >RAM
+
+ /********************** User_heap_stack section ****************************/
+  /* just to check that there is enough RAM left */
+  ._user_heap_stack :
+  {
+    . = ALIGN(8);
+    PROVIDE ( end = . );
+    PROVIDE ( _end = . );
+    PROVIDE ( __end__ = . );
+    . = . + _Min_Heap_Size;
+    . = . + _Min_Stack_Size;
+    . = ALIGN(8);
+    _estack = .;
+  } >RAM
+
+  /* Remove information from the compiler libraries */
+  /DISCARD/ :
+  {
+    libc.a ( * )
+    libm.a ( * )
+    libgcc.a ( * )
+  }
+
+  .ARM.attributes 0 : { *(.ARM.attributes) }
+}
--- a/BootLoader/Inc/base_bootloader.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/BootLoader/Inc/base_bootloader.h	Wed Aug 14 16:44:46 2024 +0200
@@ -59,9 +59,6 @@
 #define BASE_BOOTLOADER_H
 
 /* Includes ------------------------------------------------------------------*/
-
-#define STM32F429xx
-
 #include "stm32f4xx_hal.h"
 
 #include "tStructure.h"
--- a/BootLoader/Src/base_bootlader.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/BootLoader/Src/base_bootlader.c	Wed Aug 14 16:44:46 2024 +0200
@@ -223,6 +223,19 @@
 #include "stm32f4xx_hal_flash_ex.h"
 #include "stm32f4xx_hal_wwdg.h"
 
+#ifdef BOOTLOADER_STANDALONE
+#include "Fonts/Font_T144_plus.h"
+#include "Fonts/Font_T84.h"
+#include "Fonts/Font_T105.h"
+#include "Fonts/Font_T54.h"
+#include "Fonts/Font_T48_plus.h"
+#include "Fonts/Font_T24.h"
+#include "Fonts/Font_T42.h"
+#include "Fonts/image_battery.h"
+#include "Fonts/image_heinrichs_weikamp.h"
+#include "Fonts/image_ostc.h"
+#endif
+
 // From Discovery/Inc (shall be shared...)
 #include "data_exchange_main.h"
 #include "display.h"
@@ -269,7 +282,7 @@
 	.magic[3] = FIRMWARE_MAGIC_END
 };
 
-
+#if 0
 const SHardwareData HardwareData __attribute__((at(HARDWAREDATA_ADDRESS))) = {
 
 	// first 52 bytes
@@ -297,7 +310,7 @@
 	.secondary_bluetooth_name_set = 0xFF,
 	.secondary_info = {0xFF,0xFF,0xFF,0xFF}
 };
-
+#endif
 
 RTC_HandleTypeDef	RtcHandle;
 TIM_HandleTypeDef   TimHandle; /* used in stm32f4xx_it.c too */
@@ -418,10 +431,15 @@
 	uint8_t ptr;
 	uint32_t pOffset;
 
+	const SHardwareData* HardwareData = hardwareDataGetPointer();
+
 	set_globalState(StBoot0);
 
 	HAL_Init();
 	HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_2);
+	SystemClock_Config();
+
+	MX_GPIO_Init();
 
 	/* feedback for the user
 	 * aber sehr unsch�n beim Warmstart
@@ -442,8 +460,8 @@
 	}
 	else
 	if(			(firmware_MainCodeIsProgammed() == 0)
-			||	(hardwareDataGetPointer()->primarySerial == 0xFFFF)
-			||	(hardwareDataGetPointer()->production_bluetooth_name_set == 0xFF))
+			||	(HardwareData->primarySerial == 0xFFFF)
+			||	(HardwareData->production_bluetooth_name_set == 0xFF))
 	{
 		i = 1;
 	}
@@ -495,10 +513,6 @@
 	if((i == 0) && (callForUpdate == 0))
 		firmware_JumpTo_Application();
 
-	SystemClock_Config();
-
-	MX_GPIO_Init();
-	MX_Bluetooth_PowerOn();
 	MX_SPI_Init();
 	SDRAM_Config();
 	HAL_Delay(100);
@@ -663,7 +677,7 @@
 	textVersion[ptr++] = 'a';
 	textVersion[ptr++] = 'l';
 	textVersion[ptr++] = ' ';
-	if(HardwareData.primarySerial == 0xFFFF)
+	if(HardwareData->primarySerial == 0xFFFF)
 	{
 		textVersion[ptr++] = 'n';
 		textVersion[ptr++] = 'o';
@@ -673,36 +687,44 @@
 		textVersion[ptr++] = 'e';
 		textVersion[ptr++] = 't';
 	}
-	else if(HardwareData.secondarySerial == 0xFFFF)
+	else if(HardwareData->secondarySerial == 0xFFFF)
 	{
 		textVersion[ptr++] = '#';
-		ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData.primarySerial);
+		ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData->primarySerial);
 	}
 	else
 	{
 		textVersion[ptr++] = '#';
-		ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData.secondarySerial);
+		ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData->secondarySerial);
 		textVersion[ptr++] = ' ';
 		textVersion[ptr++] = '(';
-		ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData.primarySerial);
+		ptr += gfx_number_to_string(5,1,&textVersion[ptr],HardwareData->primarySerial);
 		textVersion[ptr++] = ')';
 	}
 	textVersion[ptr++] = '\020';
 	textVersion[ptr] = 0;
 
+	TIM_init();
+	MX_UART_Init();
+	MX_Bluetooth_PowerOn();
+	tComm_init();
+
 	tInfo_button_text("Exit","","Sleep");
-	tInfo_newpage("Bootloader 160602");
+	tInfo_newpage("Bootloader 240812");
 	tInfo_write("start bluetooth");
 	tInfo_write("");
 	tInfo_write(textVersion);
-	tInfo_write("");
+	if(tComm_Set_Bluetooth_Name(0) == 0xFF)
+	{
+		tInfo_write("Init bluetooth");
+		tComm_StartBlueModBaseInit();
+	}
+	else
+	{
+		tInfo_write("");
+		tComm_StartBlueModConfig();
+	}
 
-	TIM_init();
-	MX_UART_Init();
-	MX_Bluetooth_PowerOn();
-	tComm_Set_Bluetooth_Name(0);
-
-	tComm_init();
 	set_globalState_Base();
 
 	GFX_start_VSYNC_IRQ();
@@ -1153,54 +1175,65 @@
 	*/
 static void SystemClock_Config(void)
 {
-	RCC_ClkInitTypeDef RCC_ClkInitStruct;
-	RCC_OscInitTypeDef RCC_OscInitStruct;
-	RCC_PeriphCLKInitTypeDef  PeriphClkInitStruct;
+    /* Enable Power Control clock */
+    __PWR_CLK_ENABLE();
 
-	/* Enable Power Control clock */
-	__PWR_CLK_ENABLE();
-
-	/* The voltage scaling allows optimizing the power consumption when the device is
-		 clocked below the maximum system frequency, to update the voltage scaling value
-		 regarding system frequency refer to product datasheet.  */
-	__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
+    /* The voltage scaling allows optimizing the power consumption when the device is
+     clocked below the maximum system frequency, to update the voltage scaling value
+     regarding system frequency refer to product datasheet.  */
+    __HAL_PWR_VOLTAGESCALING_CONFIG( PWR_REGULATOR_VOLTAGE_SCALE1 );
 
-	/*##-1- System Clock Configuration #########################################*/
-	/* Enable HSE Oscillator and activate PLL with HSE as source */
-	RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
-	RCC_OscInitStruct.HSEState = RCC_HSE_ON;
-	RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
-	RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
-	RCC_OscInitStruct.PLL.PLLM = 8;
-	RCC_OscInitStruct.PLL.PLLN = 336;//360;
-	RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
-	RCC_OscInitStruct.PLL.PLLQ = 7;
-	HAL_RCC_OscConfig(&RCC_OscInitStruct);
+    /*##-1- System Clock Configuration #########################################*/
+    /* Enable HighSpeed Oscillator and activate PLL with HSE/HSI as source */
+    RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };
+#ifdef DISC1_BOARD
+    // Use High Speed Internal (HSI) oscillator, running at 16MHz.
+    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
+    RCC_OscInitStruct.HSIState       = RCC_HSI_ON;
+    RCC_OscInitStruct.HSICalibrationValue = 0x10;
+    RCC_OscInitStruct.PLL.PLLSource  = RCC_PLLSOURCE_HSI;
+    RCC_OscInitStruct.PLL.PLLM       = 16;				// HSI/16 is 1Mhz.
+#else
+    // Use High Speed External oscillator, running at 8MHz
+    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
+    RCC_OscInitStruct.HSEState       = RCC_HSE_ON;
+    RCC_OscInitStruct.PLL.PLLSource  = RCC_PLLSOURCE_HSE;
+    RCC_OscInitStruct.PLL.PLLM       = 8;               // HSE/8 is 1Mhz.
+#endif
+    // System clock = PLL (1MHz) * N/p = 180 MHz.
+    RCC_OscInitStruct.PLL.PLLN = 360;
+    RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+    RCC_OscInitStruct.PLL.PLLQ = 7;
+    RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+    HAL_RCC_OscConfig( &RCC_OscInitStruct );
 
 //  HAL_PWREx_ActivateOverDrive();
-HAL_PWREx_DeactivateOverDrive();
-	/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2
-		 clocks dividers */
-	RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
-	RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
-	RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
-	RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
-	RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
-	HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_8);//FLASH_LATENCY_5);
+    HAL_PWREx_DeactivateOverDrive();
+
+    /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
+    RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };
+    RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK
+                                                            | RCC_CLOCKTYPE_PCLK1  | RCC_CLOCKTYPE_PCLK2;
+    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
+    RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
+    RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
+    RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
+    HAL_RCC_ClockConfig( &RCC_ClkInitStruct, FLASH_LATENCY_8 );	//FLASH_LATENCY_5);
 
-	/*##-2- LTDC Clock Configuration ###########################################*/
-	/* LCD clock configuration */
-	/* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
-	/* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */
-	/* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */
-	/* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDIVR_8 = 48/8 = 6 Mhz */
+    /*##-2- LTDC Clock Configuration ###########################################*/
+    /* LCD clock configuration */
+    /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
+    /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 192 Mhz */
+    /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 192/4 = 48 Mhz */
+    /* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDIVR_8 = 48/8 = 6 Mhz */
 
-	/* neu: 8MHz/8*300/5/8 = 7,5 MHz = 19,5 Hz bei 800 x 480 */
-	PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
-	PeriphClkInitStruct.PLLSAI.PLLSAIN = 300;//192;
-	PeriphClkInitStruct.PLLSAI.PLLSAIR = 5;//4;
-	PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8;//RCC_PLLSAIDIVR_4;// RCC_PLLSAIDIVR_2; // RCC_PLLSAIDIVR_8
-	HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
+    /* neu: 8MHz/8*300/5/8 = 7,5 MHz = 19,5 Hz bei 800 x 480 */
+    RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
+    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC;
+    PeriphClkInitStruct.PLLSAI.PLLSAIN = 300;				//192;
+    PeriphClkInitStruct.PLLSAI.PLLSAIR = 5;				//4;
+    PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_8;//RCC_PLLSAIDIVR_4;// RCC_PLLSAIDIVR_2; // RCC_PLLSAIDIVR_8
+    HAL_RCCEx_PeriphCLKConfig( &PeriphClkInitStruct );
 }
 
 
@@ -1503,7 +1536,7 @@
 	WwdgHandle.Init.Counter   = 127;
 
 	HAL_WWDG_Init(&WwdgHandle);
-	HAL_WWDG_Start(&WwdgHandle);
+/*	HAL_WWDG_Start(&WwdgHandle);	has been removed from HAL library starting_V120 */
 	while(1);
 }
 
--- a/Common/Drivers/STM32F4xx/Include/system_stm32f4xx.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Common/Drivers/STM32F4xx/Include/system_stm32f4xx.h	Wed Aug 14 16:44:46 2024 +0200
@@ -73,7 +73,6 @@
   */
 extern uint32_t SystemCoreClock;          /*!< System Clock Frequency (Core Clock) */
 
-extern const uint8_t  AHBPrescTable[16];    /*!< AHB prescalers table values */
 extern const uint8_t  APBPrescTable[8];     /*!< APB prescalers table values */
 
 /**
--- a/Common/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Common/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h	Wed Aug 14 16:44:46 2024 +0200
@@ -44,6 +44,9 @@
 /* Includes ------------------------------------------------------------------*/
 #include "stm32f4xx.h"
 
+
+extern __IO const uint8_t AHBPrescTable[16];
+
 /** @addtogroup STM32F4xx_LL_Driver
   * @{
   */
--- a/Common/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Common/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c	Wed Aug 14 16:44:46 2024 +0200
@@ -93,6 +93,8 @@
   * @{
   */
 
+
+extern __IO const uint8_t AHBPrescTable[16];
 #ifdef HAL_RCC_MODULE_ENABLED
 
 /* Private typedef -----------------------------------------------------------*/
--- a/Common/Inc/configuration.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Common/Inc/configuration.h	Wed Aug 14 16:44:46 2024 +0200
@@ -48,6 +48,9 @@
 /* Enable to have access to the debug view options (turn on / off via menu instead of compile switch) */
 /* #define HAVE_DEBUG_VIEW */
 
+/* Enable to have event based warnings being displayed as warning messages when the occure */
+#define HAVE_DEBUG_WARNINGS
+
 /* Enable to have access to the motion control selection menu */
 /* #define ENABLE_MOTION_CONTROL */
 
--- a/Common/Inc/data_central.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Common/Inc/data_central.h	Wed Aug 14 16:44:46 2024 +0200
@@ -276,6 +276,9 @@
 #ifdef ENABLE_BOTTLE_SENSOR
 	int8_t newPressure;
 #endif
+#ifdef HAVE_DEBUG_WARNINGS
+	int8_t debug;
+#endif
 } SWarnings;
 
 
@@ -351,6 +354,8 @@
 
 	uint8_t pscr_o2_drop;
 	uint8_t pscr_lung_ratio;
+
+	uint32_t activeAFViews;
  }  SDiveSettings;
 
 enum CHARGE_STATUS{
@@ -446,6 +451,7 @@
 	 SENSOR_DIGO2,
 	 SENSOR_DIGO2M,
 	 SENSOR_SENTINEL,
+	 SENSOR_SENTINELM,
 	 SENSOR_TYPE_O2_END,
 	 SENSOR_CO2,
 	 SENSOR_CO2M,
@@ -525,4 +531,7 @@
 const SDecoinfo *getDecoInfo(void);
 
 void disableTimer(void);
+
+uint8_t drawingColor_from_ascentspeed(float speed);
+
 #endif // DATA_CENTRAL_H
--- a/Common/Inc/data_exchange.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Common/Inc/data_exchange.h	Wed Aug 14 16:44:46 2024 +0200
@@ -38,10 +38,6 @@
 /* 4th nibble command channel */
 #define EXT_INTERFACE_33V_ON		(0x8000u)	/* Bit set to enable 3.3V power interface */
 #define EXT_INTERFACE_ADC_ON		(0x4000u)	/* Bit set to enable ADC conversion */
-#define EXT_INTERFACE_UART_MASK 	(0x0700u)   /* Reserve 3 bits for UART protocol selection */
-#define EXT_INTERFACE_UART_CO2  	(0x0100u)	/* Activate protocol for CO2 sensor */
-#define EXT_INTERFACE_UART_SENTINEL (0x0200u)	/* Activate Sentinel Backup monitor protocol */
-#define EXT_INTERFACE_UART_O2		(0x0400u)	/* Activate digital o2 sensor protocol (DiveO2) */
 
 /* Command subset */
 #define EXT_INTERFACE_AUTODETECT 	(0x0001u)	/* Start auto detection of connected sensors	*/
--- a/Common/Inc/settings.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Common/Inc/settings.h	Wed Aug 14 16:44:46 2024 +0200
@@ -120,7 +120,8 @@
 uint8_t deco:1;
 uint8_t travel:1;
 uint8_t off:1;
-uint8_t spare:3;
+uint8_t decocalc:1;
+uint8_t spare:2;
 } gasubit8_t;
 
 typedef union{
@@ -311,6 +312,7 @@
 	uint16_t scrubTimerCur_Obsolete;	/* have been replaced with new scrubber data format */
 	uint8_t scrubTimerMode;
 	uint8_t ext_sensor_map[8];		/* redefined in 0xFFFF0027 */
+	uint8_t cvAutofocus;
 } SSettings;
 
 typedef struct
--- a/Common/Src/decom.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Common/Src/decom.c	Wed Aug 14 16:44:46 2024 +0200
@@ -37,10 +37,11 @@
 #include "decom.h"
 
 #include <math.h>
+#include <string.h>
 #include "settings.h"
 #include "calc_crush.h"
 
-#	define	FRACTION_N2_AIR			0.7902
+#define	FRACTION_N2_AIR			0.7902
 
 const float helium_time_constant[16] = {
 										3.68695308808482E-001,
@@ -577,99 +578,100 @@
 }
 
 
+void insertGasIntoList(SGasLine* pGas, SGasLine** pGasList, uint8_t gasInSettings, uint8_t* pGasInSettingsList, uint8_t GasListLength)
+{
+	uint8_t localGasIndex = GasListLength;
+	if(pGas != 0)
+	{
+		while(localGasIndex != 0)	/* first entry */
+		{
+			if(pGasList[localGasIndex-1]->depth_meter > pGas->depth_meter)	/* switch depth of existing gas is deeper then new one => move down */
+			{
+				pGasList[localGasIndex] = pGasList[localGasIndex-1];
+				pGasInSettingsList[localGasIndex] = pGasInSettingsList[localGasIndex - 1];
+				localGasIndex--;
+			}
+			else
+			{
+				break;
+			}
+		}
+		pGasList[localGasIndex] = pGas;
+		pGasInSettingsList[localGasIndex] = gasInSettings;
+	}
+}
 
 void decom_CreateGasChangeList(SDiveSettings* pInput, const SLifeData* pLifeData)
 {
-	int i=0, j = 0;
-	int count = 0;
-	 for(i=0;i< 5;i++)
-				{
-						//FirstGas
+	SGasLine localPSCRFirst;
+	SGasLine *pLocalGasList[5] = {0,0,0,0,0};
+	uint8_t localGasInSettingsList[5] = {0,0,0,0,0};
+
+	uint8_t gasStart = 1;
+	uint8_t gasIndex = 0;
+	uint8_t gasEntryCnt = 0;
 
-								pInput->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero = 0;
-								pInput->decogaslist[i].GasIdInSettings = 255;
-								pInput->decogaslist[i].setPoint_cbar = 0;
-								pInput->decogaslist[i].helium_percentage = 0;
-								pInput->decogaslist[i].nitrogen_percentage = 0;
+	int i=0;
+	for(i=0;i< 5;i++)	/* reset list */
+	{
+		pInput->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero = 0;
+		pInput->decogaslist[i].GasIdInSettings = 255;
+		pInput->decogaslist[i].setPoint_cbar = 0;
+		pInput->decogaslist[i].helium_percentage = 0;
+		pInput->decogaslist[i].nitrogen_percentage = 0;
+	}
+	/* FirstGas
+	 * 0 = special gas, 1 to 5 is OC gas, 6 to 10 is diluent
+	 */
+	pInput->decogaslist[0] = pLifeData->actualGas;
+	/* Add Deco Gases
+	 * special (gasId == 0) is never a deco/travel gas but actual gas only
+	*/
+
+	if(pInput->diveMode != DIVEMODE_OC)
+	{
+		gasStart = 6;	/* CCR or PSCR => CC gaslist */
+	}
+
+	if(pInput->diveMode == DIVEMODE_PSCR)				/* Handle first gas as deco gas */
+	{
+		for(gasIndex = gasStart; gasIndex < gasStart + 5; gasIndex++)
+		{
+			if(pInput->gas[gasIndex].note.ub.first)
+			{
+				if (pLifeData->actualGas.GasIdInSettings != gasIndex)
+				{
+					memcpy(&localPSCRFirst, &pInput->gas[gasIndex], sizeof(SGasLine));
+					localPSCRFirst.depth_meter = calc_MOD(gasIndex);
+					insertGasIntoList(&localPSCRFirst, pLocalGasList, gasIndex, localGasInSettingsList, gasEntryCnt);
+					gasEntryCnt++;
+					break;
 				}
-	//pInput->liveData.dive_time_seconds = 0;
-
-		/* FirstGas
-		 * 0 = special gas, 1 to 5 ist OC gas, 6 to 10 is diluent
-		 */
-
+			}
+		}
+	}
 
 
-		pInput->decogaslist[0] = pLifeData->actualGas;
-
-				/* Add Deco Gases
-				 * special (gasId == 0) is never a deco/travel gas but actual gas only
-				 */
-		if(pInput->diveMode == DIVEMODE_OC)
-		{
-
-				for(i=1;i<= 5;i++)
-				{
-						if(pInput->gas[i].note.ub.active && pInput->gas[i].depth_meter
-							 && (pLifeData->actualGas.GasIdInSettings != i)
-							 &&(pInput->gas[i].depth_meter < pLifeData->depth_meter ) )
-						{
-								count = 1;
-								for(j=1;j<= 5;j++)
-								{
-										if(			(pInput->gas[j].note.ub.active && pInput->gas[j].depth_meter > 0)
-												&&	(pLifeData->actualGas.GasIdInSettings != j) // new hw 160905
-												&&	(pInput->gas[j].depth_meter > pInput->gas[i].depth_meter))
-												count++;
-								}
-								pInput->decogaslist[count].change_during_ascent_depth_meter_otherwise_zero = pInput->gas[i].depth_meter;
-								pInput->decogaslist[count].nitrogen_percentage = 100;
-								pInput->decogaslist[count].nitrogen_percentage -= pInput->gas[i].oxygen_percentage;
-								pInput->decogaslist[count].nitrogen_percentage -= pInput->gas[i].helium_percentage;
-								pInput->decogaslist[count].helium_percentage = pInput->gas[i].helium_percentage;
-								pInput->decogaslist[count].GasIdInSettings = i;
-								pInput->decogaslist[count].AppliedDiveMode = DIVEMODE_OC;
-						}
-				}
-		}
-		else
+	for(gasIndex = gasStart; gasIndex < gasStart + 5; gasIndex++)
+	{
+		if(((pInput->gas[gasIndex].note.ub.active) && (pInput->gas[gasIndex].depth_meter))		/* ready for deco calculation */
+			&& (pLifeData->actualGas.GasIdInSettings != gasIndex)							/* not the actual gas */
+			&& (pInput->gas[gasIndex].depth_meter < pLifeData->depth_meter ))				/* a gas which is on the way to surface */
 		{
-			//divmode CCR or PSCR
-				for(i=6; i <= 10; i++)
-				{
-						if((pInput->gas[i].note.ub.active) && (pInput->gas[i].depth_meter)
-							 && (pLifeData->actualGas.GasIdInSettings != i)
-							 && (pInput->gas[i].depth_meter < pLifeData->depth_meter ))
-						{
-								count = 1;
-								for(j=6;j<= 10;j++)
-								{
-//                    if(pInput->gas[j].note.ub.active && pInput->gas[j].depth_meter > 0 &&pInput->gas[j].depth_meter > pInput->gas[i].depth_meter)
-										if(((pInput->gas[j].note.ub.active) && (pInput->gas[j].depth_meter > 0))
-												&&	(pLifeData->actualGas.GasIdInSettings != j) // new hw 160905
-												&&	(pInput->gas[j].depth_meter > pInput->gas[i].depth_meter))
-												count++;
-								}
-								pInput->decogaslist[count].change_during_ascent_depth_meter_otherwise_zero = pInput->gas[i].depth_meter;
-								pInput->decogaslist[count].nitrogen_percentage = 100;
-								if(pInput->diveMode == DIVEMODE_PSCR)
-								{
-									pInput->decogaslist[count].AppliedDiveMode = DIVEMODE_PSCR;
-									pInput->decogaslist[count].setPoint_cbar = decom_calc_SimppO2_O2based((float)(pInput->gas[i].depth_meter / 10.0 + 1.0), pInput->gas[i].oxygen_percentage, pInput->decogaslist[count].pscr_factor ) * 100;
-									pInput->decogaslist[count].nitrogen_percentage -= pInput->gas[i].oxygen_percentage;
-								}
-								else
-								{
-									pInput->decogaslist[count].nitrogen_percentage -= pInput->gas[i].oxygen_percentage;
-									pInput->decogaslist[count].AppliedDiveMode = DIVEMODE_CCR;
-									pInput->decogaslist[count].setPoint_cbar = pInput->decogaslist[0].setPoint_cbar;		/* assume that current setpoint is kept till end of the dive */
-								}
-								pInput->decogaslist[count].nitrogen_percentage -= pInput->gas[i].helium_percentage;
-								pInput->decogaslist[count].helium_percentage = pInput->gas[i].helium_percentage;
-								pInput->decogaslist[count].GasIdInSettings = i;
-						}
-				}
+			insertGasIntoList(&pInput->gas[gasIndex], pLocalGasList, gasIndex, localGasInSettingsList, gasEntryCnt);
+			gasEntryCnt++;
 		}
+	}
+	for(gasIndex = 1; gasIndex < gasEntryCnt+1; gasIndex++)									/* move gasLine Information into deco List */
+	{
+		pInput->decogaslist[gasIndex].change_during_ascent_depth_meter_otherwise_zero = pLocalGasList[gasIndex-1]->depth_meter;
+		pInput->decogaslist[gasIndex].nitrogen_percentage = 100;
+		pInput->decogaslist[gasIndex].nitrogen_percentage -= pLocalGasList[gasIndex-1]->oxygen_percentage;
+		pInput->decogaslist[gasIndex].nitrogen_percentage -= pLocalGasList[gasIndex-1]->helium_percentage;
+		pInput->decogaslist[gasIndex].helium_percentage = pLocalGasList[gasIndex-1]->helium_percentage;
+		pInput->decogaslist[gasIndex].GasIdInSettings = localGasInSettingsList[gasIndex-1];
+		pInput->decogaslist[gasIndex].AppliedDiveMode = pInput->diveMode;
+	}
 }
 void test_decom_CreateGasChangeList(void)
 {
--- a/Discovery/Inc/gfx_engine.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/gfx_engine.h	Wed Aug 14 16:44:46 2024 +0200
@@ -113,6 +113,7 @@
 /* Exported functions --------------------------------------------------------*/
 
 void GFX_init(uint32_t * pDestinationOut);
+void GFX_init1_no_DMA(uint32_t  * pDestinationOut, uint8_t blockFrames);
 
 void GFX_helper_font_memory_list(const tFont *Font);
 
@@ -199,4 +200,5 @@
 
 tFont* GFX_Check_Extra_Font(uint8_t character, tFont *Font);
 uint32_t GFX_Character_Width(uint8_t character, tFont *Font);
+void Gfx_colorsscheme_mod(char *text, uint8_t alternativeColor);
 #endif // GFX_ENGINE_H
--- a/Discovery/Inc/gfx_fonts.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/gfx_fonts.h	Wed Aug 14 16:44:46 2024 +0200
@@ -52,6 +52,7 @@
 //    Actual data is stored between __upper_font_data and __upper_font_data_end,
 //    and uses 0x081b9a3a - 0x08132040 = 879FA = 542 KB.
 //
+
 extern const tFont Awe48;
 extern const tFont FontT24;
 extern const tFont FontT42;
--- a/Discovery/Inc/ostc_hw2.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/ostc_hw2.h	Wed Aug 14 16:44:46 2024 +0200
@@ -197,4 +197,11 @@
 #define RESET_LOGIC_ALLES_OK_GPIO_PORT				GPIOB
 #define RESET_LOGIC_ALLES_OK_GPIO_ENABLE()          __GPIOB_CLK_ENABLE()
 
+/* new OSTC5 */
+#define BLE_UBLOX_DSR_PIN                             GPIO_PIN_12
+#define BLE_UBLOX_DSR_GPIO_PORT                       GPIOC
+#define BLE_UBLOX_DSR_GPIO_ENABLE()                   __GPIOC_CLK_ENABLE()
+
+
+
 #endif // OSTC_HW2_H
--- a/Discovery/Inc/stm32f4xx_hal_conf.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/stm32f4xx_hal_conf.h	Wed Aug 14 16:44:46 2024 +0200
@@ -83,7 +83,9 @@
 //#define HAL_USART_MODULE_ENABLED
 //#define HAL_IRDA_MODULE_ENABLED
 //#define HAL_SMARTCARD_MODULE_ENABLED
-//#define HAL_WWDG_MODULE_ENABLED
+#ifdef BOOTLOADER_STANDALONE
+#define HAL_WWDG_MODULE_ENABLED
+#endif
 //#define HAL_PCD_MODULE_ENABLED
 //#define HAL_HCD_MODULE_ENABLED
 #define HAL_SDRAM_MODULE_ENABLED
--- a/Discovery/Inc/t3.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/t3.h	Wed Aug 14 16:44:46 2024 +0200
@@ -42,6 +42,7 @@
 uint8_t t3_getCustomView(void);
 void t3_set_customview_to_primary(void);
 uint8_t t3_customview_disabled(uint8_t view);
+void t3_handleAutofocus(void);
 
 int printScrubberText(char *text, size_t size, SSettings *settings);
 
--- a/Discovery/Inc/tComm.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/tComm.h	Wed Aug 14 16:44:46 2024 +0200
@@ -42,7 +42,22 @@
 		BM_CONFIG_BAUD,
 		BM_CONFIG_SILENCE,
 		BM_CONFIG_DONE,
-		BM_CONFIG_RETRY
+		BM_CONFIG_RETRY,
+#ifdef BOOTLOADER_STANDALONE
+		BM_INIT_TRIGGER_ON = 100,
+		BM_INIT_TRIGGER_OFF,
+		BM_INIT_FACTORY,
+		BM_INIT_MODE,
+		BM_INIT_BLE,
+		BM_INIT_NAME,
+		BM_INIT_SSP_IDO_OFF,
+		BM_INIT_SSP_IDO_ON,
+		BM_INIT_SSP_ID1_OFF,
+		BM_INIT_SSP_ID1_ON,
+		BM_INIT_STORE,
+		BM_INIT_RESTART,
+		BM_INIT_DONE
+#endif
 } BlueModTmpConfig_t;
 
 /* Exported functions --------------------------------------------------------*/
@@ -53,6 +68,7 @@
 void tComm_exit(void);
 void tComm_verlauf(uint8_t percentage_complete);
 uint8_t tComm_Set_Bluetooth_Name(uint8_t force);
+void tComm_StartBlueModBaseInit(void);
 void tComm_StartBlueModConfig(void);
 void tComm_RequestBluetoothStrength(void);
 
--- a/Discovery/Inc/tHome.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/tHome.h	Wed Aug 14 16:44:46 2024 +0200
@@ -80,7 +80,7 @@
 		CVIEW_Charger,
 		CVIEW_CcrSummary,
         CVIEW_Timer,
-		CVIEW_END = 31			/* The ID is used in shift operation => 31 is the max number of supported views */
+		CVIEW_END			/* The ID is used in shift operation => 31 is the max number of supported views */
 };
 
 enum CUSTOMVIEWS_BF
--- a/Discovery/Inc/tInfo.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/tInfo.h	Wed Aug 14 16:44:46 2024 +0200
@@ -58,6 +58,7 @@
 void tInfo_write_field_on_off(uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t int1);
 
 void tInfo_write_buttonTextline(GFX_DrawCfgScreen *screenPtr, uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode);
+void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode);
 
 void tInfo_setEvent(uint32_t inputEventID, uint32_t inputFunctionCall);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Discovery/Inc/tInfoPreDive.h	Wed Aug 14 16:44:46 2024 +0200
@@ -0,0 +1,37 @@
+///////////////////////////////////////////////////////////////////////////////
+/// -*- coding: UTF-8 -*-
+///
+/// \file   Discovery/Inc/tInfoSensor.h
+/// \brief  Infopage content for connected smart sensors
+/// \author heinrichs weikamp gmbh
+/// \date   17-11-2022
+///
+/// $Id$
+///////////////////////////////////////////////////////////////////////////////
+/// \par Copyright (c) 2014-2022 Heinrichs Weikamp gmbh
+///
+///     This program is free software: you can redistribute it and/or modify
+///     it under the terms of the GNU General Public License as published by
+///     the Free Software Foundation, either version 3 of the License, or
+///     (at your option) any later version.
+///
+///     This program is distributed in the hope that it will be useful,
+///     but WITHOUT ANY WARRANTY; without even the implied warranty of
+///     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+///     GNU General Public License for more details.
+///
+///     You should have received a copy of the GNU General Public License
+///     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//////////////////////////////////////////////////////////////////////////////
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef TINFO_PREDIVE_H
+#define TINFO_PREDIVE_H
+
+/* Exported functions --------------------------------------------------------*/
+void openInfo_PreDive();
+void refreshInfo_PreDive(GFX_DrawCfgScreen s);
+void sendActionToInfoPreDive(uint8_t sendAction);
+
+
+#endif /* TINFO_COMPASS_H */
--- a/Discovery/Inc/tMenu.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/tMenu.h	Wed Aug 14 16:44:46 2024 +0200
@@ -87,6 +87,7 @@
 
 void selectPage(uint32_t selection);
 
+uint8_t getLineMask(uint32_t lineId);
 void resetLineMask(uint32_t lineId);
 void disableLine(uint32_t lineId);
 void enableLine(uint32_t lineId);
--- a/Discovery/Inc/tMenuEdit.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/tMenuEdit.h	Wed Aug 14 16:44:46 2024 +0200
@@ -40,6 +40,7 @@
 #define ME_Y_LINE5					(ME_Y_LINE1 + (4 * ME_Y_LINE_STEP))
 #define ME_Y_LINE6					(ME_Y_LINE1 + (5 * ME_Y_LINE_STEP))
 
+#define EXIT_TO_INFO_PREDIVE 		(245)
 #define EXIT_TO_NEXT_MENU   		(246)
 #define EXIT_TO_INFO_SENSOR 		(247)
 #define EXIT_TO_INFO_COMPASS 		(248)
@@ -59,6 +60,8 @@
 void sendActionToMenuEdit(uint8_t sendAction);
 
 void tMenuEdit_init(void);
+void resetMenuContentStructure();
+void resetMenuStructure(uint8_t color);
 void resetMenuEdit(uint8_t color);
 void tMenuEdit_refresh_live_content(void);
 void tMenuEdit_refresh_field(uint32_t editID);
--- a/Discovery/Inc/tMenuEditCustom.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/tMenuEditCustom.h	Wed Aug 14 16:44:46 2024 +0200
@@ -34,10 +34,19 @@
 #include "settings.h"
 #include "data_central.h"
 
+enum afDetectionState
+{
+	AF_VIEW_NOCHANGE		= 0,
+	AF_VIEW_ACTIVATED,
+	AF_VIEW_DEACTIVATED
+};
+
+
 void openEdit_Custom(uint8_t line);
 void openEdit_CustomviewDivemode(const uint8_t* pcv_changelist);
 void openEdit_CustomviewDivemodeMenu(uint8_t line);
 void CustomviewDivemode_refresh();
 void refresh_ViewPort(void);
+uint8_t HandleAFCompass(void);
 
 #endif /* TMENU_EDIT_CUSTOM_H */
--- a/Discovery/Inc/tMenuEditXtra.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/tMenuEditXtra.h	Wed Aug 14 16:44:46 2024 +0200
@@ -33,6 +33,5 @@
 
 void openEdit_Xtra(uint8_t line);
 void refresh_CompassHeading(void);
-void refresh_CO2Data(void);
 
 #endif /* TMENU_EDIT_XTRA_H */
--- a/Discovery/Inc/tMenuSystem.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/tMenuSystem.h	Wed Aug 14 16:44:46 2024 +0200
@@ -44,5 +44,6 @@
 /* Exported functions --------------------------------------------------------*/
 
 uint32_t tMSystem_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext);
+void tMSystem_checkLineStatus(void);
 
 #endif /* TMENU_SYSTEM_H */
--- a/Discovery/Inc/tMenuXtra.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/tMenuXtra.h	Wed Aug 14 16:44:46 2024 +0200
@@ -45,7 +45,7 @@
 /* Exported functions --------------------------------------------------------*/
 
 uint32_t tMXtra_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext);
-
+void tMXtra_checkLineStatus(void);
 	 #ifdef __cplusplus
 }
 #endif
--- a/Discovery/Inc/tStructure.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/tStructure.h	Wed Aug 14 16:44:46 2024 +0200
@@ -65,6 +65,7 @@
 #define InfoPageLogShow 3
 #define InfoPageCompass 6
 #define InfoPageSensor  8
+#define InfoPagePreDive 9
 
 #define StI 			_MB(0,1,0,0,0)
 #define StILOGLIST		_MB(0,2,0,0,0)
@@ -74,6 +75,7 @@
 #define StICOMPASS		_MB(0,6,0,0,0)
 #define StIDEBUG		_MB(0,7,0,0,0)
 #define StISENINFO		_MB(0,8,0,0,0)
+#define StIPREDIVE		_MB(0,9,0,0,0)
 
 #define StI_GoToLogbook			_MB(0,1,1,0,0)
 #define StI_GoToPlanner			_MB(0,1,2,0,0)
@@ -129,7 +131,8 @@
 #define StMOG_GasType				_MB(2,1,255,2,0)
 #define StMOG_ChangeDepth		_MB(2,1,255,3,0)
 #define StMOG_SetToMOD			_MB(2,1,255,4,0)
-#define StMOG_Bottle				_MB(2,1,255,5,0)
+#define StMOG_CalcDeco				_MB(2,1,255,5,0)
+/* #define StMOG_Bottle				_MB(2,1,255,5,0) */
 
 #define StMOG_MOD					_MB(2,1,255,9,0)
 
@@ -212,11 +215,10 @@
 #define StMXTRA_ScrubTimer_Max			_MB(2,4,3,2,0)
 #define StMXTRA_ScrubTimer_Reset		_MB(2,4,3,3,0)
 #define StMXTRA_ScrubTimer_OP_Mode		_MB(2,4,3,5,0)
-
 #define StMXTRA_PSCR_O2_Drop			_MB(2,4,4,1,0)
 #define StMXTRA_PSCR_LUNG_RATIO			_MB(2,4,4,2,0)
-#define StMXTRA_CO2_Sensor				_MB(2,4,5,1,0)
-#define StMXTRA_CO2_Sensor_Calib		_MB(2,4,5,2,0)
+#define StMXTRA_Predive_Check			_MB(2,4,5,1,0)
+
 
 
 
@@ -267,6 +269,7 @@
 
 #define StMHARD1_Bluetooth			_MB(2,7,1,1,0)
 
+#define StMHARD2_Compass				_MB(2,7,2,0,0)
 #define StMHARD2_Compass_SetCourse		_MB(2,7,2,2,0)
 #define StMHARD2_Compass_ResetCourse	_MB(2,7,2,3,0)
 #define StMHARD2_Compass_Calibrate		_MB(2,7,2,4,0)
@@ -339,6 +342,7 @@
 #define StMSYS5_SetFactoryBC	_MB(2,8,6,11,0)
 #define StMSYS5_ResetBluetooth	_MB(2,8,6,12,0)
 #define StMSYS5_SetSampleIndx   _MB(2,8,6,13,0)
+#define StMSYS5_AdjustSurfPres  _MB(2,8,6,14,0)
 
 #define StMSYS_Custom0			_MB(2,8,1,0,0)
 #define StMSYS_Custom1			_MB(2,8,2,0,0)
@@ -357,8 +361,9 @@
 #define StMCustom1_CViewTimeout		_MB(2,9,1,1,0)
 #define StMCustom1_CViewStandard	_MB(2,9,1,2,0)
 #define StMCustom1_CViewStandardBF	_MB(2,9,1,3,0)
-#define StMCustom1_CornerTimeout	_MB(2,9,1,4,0)
-#define StMCustom1_CornerStandard	_MB(2,9,1,5,0)
+#define StMCustom1_CViewAutoFocusBF	_MB(2,9,1,4,0)
+#define StMCustom1_CornerTimeout	_MB(2,9,1,5,0)
+#define StMCustom1_CornerStandard	_MB(2,9,1,6,0)
 
 #define StMCustom2_BFSelection		_MB(2,9,2,1,0)
 
--- a/Discovery/Inc/text_multilanguage.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Inc/text_multilanguage.h	Wed Aug 14 16:44:46 2024 +0200
@@ -121,6 +121,7 @@
 		TXT_Apnoe,
 		TXT_Gauge,
 		TXT_PSClosedCircuit,
+		TXT_PreDive,
 		TXT_Sensor,
 		TXT_FixedSP,
 		TXT_Decoparameters,
@@ -212,6 +213,7 @@
 		TXT2BYTE_CompassCalib,
 		TXT2BYTE_CompassInertia,
 		TXT2BYTE_CompassDeclination,
+		TXT2BYTE_Autofocus,
 		TXT2BYTE_UseSensor,
 		TXT2BYTE_AutomaticSP,
 		/* */
@@ -319,6 +321,7 @@
 		TXT2BYTE_Sensor,
 		TXT2BYTE_Maintenance,
 		TXT2BYTE_SetBatteryCharge,
+		TXT2BYTE_AdjustAmbPressure,
 		TXT2BYTE_SetFactoryDefaults,
 		TXT2BYTE_ResetBluetooth,
 		TXT2BYTE_SetSampleIndex,
@@ -370,6 +373,9 @@
         TXT2BYTE_Clear,
         TXT2BYTE_Reset,
 
+		TXT2BYTE_CounterLung,
+		TXT2BYTE_Pressure,
+
         TXT2BYTE_Timer,
         TXT2BYTE_Starting,
         TXT2BYTE_Finished,
--- a/Discovery/Src/base.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/base.c	Wed Aug 14 16:44:46 2024 +0200
@@ -213,6 +213,7 @@
 #include "tInfo.h"
 #include "tInfoLog.h"
 #include "tInfoSensor.h"
+#include "tInfoPreDive.h"
 #include "tMenu.h"
 #include "tMenuEdit.h"
 #include "tMenuEditGasOC.h"
@@ -544,7 +545,11 @@
         		HandleMotionDetection();
         	}
 #endif
-
+		/* Autofocus for T3 view */
+        	if((settingsGetPointer()->cvAutofocus) && (settingsGetPointer()->design == 3) && (get_globalState() == StD) && (stateUsed->mode == MODE_DIVE))
+        	{
+        		t3_handleAutofocus();
+        	}
 #ifdef SIM_WRITES_LOGBOOK
         if(stateUsed == stateSimGetPointer())
             logbook_InitAndWrite(stateUsed);
@@ -894,6 +899,8 @@
 								break;
 							case InfoPageSensor: 	sendActionToInfoSensor(action);
 								break;
+							case InfoPagePreDive: 	sendActionToInfoPreDive(action);
+								break;
 							default:				sendActionToInfo(action);
 								break;
 						}
--- a/Discovery/Src/buehlmann.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/buehlmann.c	Wed Aug 14 16:44:46 2024 +0200
@@ -258,8 +258,11 @@
 		gStop.depth = next_depth;
     for(i = gGas_id + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
     {
-        if(pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+        if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+        	|| (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
+        {
             break;
+        }
         float pressureChange =  ((float)pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero) / 10;
         if(gStop.depth <= pressureChange + 0.00001f)
         {
@@ -458,8 +461,11 @@
         pressureTop_tmp = pressureTop;
         for(i = gGas_id + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
         {
-            if(pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            		|| (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
+            {
                 break;
+            }
             pressureChange = gSurface_pressure_bar + ((float)pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero) / 10;
             if(pressureBottom <= pressureChange)
             {
@@ -473,8 +479,12 @@
         }
         for(i = gGas_id + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
         {
-            if(pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            		|| (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
+            {
                 break;
+            }
+
             pressureChange = gSurface_pressure_bar + ((float)pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero)/ 10;
             if((pressureChange < pressureBottom) && (pressureChange > pressureTop))
             {
--- a/Discovery/Src/check_warning.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/check_warning.c	Wed Aug 14 16:44:46 2024 +0200
@@ -72,6 +72,10 @@
 static int8_t check_co2(SDiveState * pDiveState);
 #endif
 static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2);
+#ifdef HAVE_DEBUG_WARNINGS
+static int8_t check_debug(SDiveState * pDiveState);
+#endif
+
 
 /* Exported functions --------------------------------------------------------*/
 
@@ -101,6 +105,9 @@
 #ifdef ENABLE_CO2_SUPPORT
 	pDiveState->warnings.numWarnings += check_co2(pDiveState);
 #endif
+#ifdef HAVE_DEBUG_WARNINGS
+	pDiveState->warnings.numWarnings += check_debug(pDiveState);
+#endif
 }
 
 
@@ -220,9 +227,10 @@
 static uint8_t getBetterGasId(bool getDiluent, uint8_t startingGasId, SDiveState *diveState)
 {
     SDiveSettings diveSettings = diveState->diveSettings;
-
+    SGasLine localGas;
     uint8_t betterGasIdLocal = startingGasId;
     uint8_t bestGasDepth = 255;
+    uint8_t i;
 
     uint8_t gasIdOffset;
     if (getDiluent) {
@@ -231,30 +239,29 @@
         gasIdOffset = 0;
     }
 
-    if (betterGasIdLocal == NO_GAS_ID) {
-        for (unsigned i = gasIdOffset + 1; i <= gasIdOffset + 5; i++) {
-            if (diveSettings.gas[i].note.ub.active && diveSettings.gas[i].note.ub.first) {
-                betterGasIdLocal = i;
-            }
-        }
-    }
-
 	/* life data is float, gas data is uint8 */
     if (actualLeftMaxDepth(diveState)) { /* deco gases */
-        for (int i=1+gasIdOffset; i<= 5+gasIdOffset; i++) {
-            if ((diveSettings.gas[i].note.ub.active)
-                && (diveSettings.gas[i].note.ub.deco)
-                && (diveSettings.gas[i].depth_meter)
-                && (diveSettings.gas[i].depth_meter >= (diveState->lifeData.depth_meter - 0.01f ))
-                && (diveSettings.gas[i].depth_meter <= bestGasDepth)) {
+        for (i=1+gasIdOffset; i<= 5+gasIdOffset; i++) {
+        	memcpy(&localGas,&diveSettings.gas[i],sizeof(SGasLine));
+        	if((localGas.note.ub.first) && (diveSettings.diveMode == DIVEMODE_PSCR))	/* handle first gas as if it would be a deco gas set to MOD */
+        	{
+        		localGas.note.ub.active = 1;
+        		localGas.note.ub.deco = 1;
+        		localGas.depth_meter = calc_MOD(i);
+        	}
+            if ((localGas.note.ub.active)
+                && (localGas.note.ub.deco)
+                && (localGas.depth_meter)
+                && (localGas.depth_meter >= (diveState->lifeData.depth_meter - 0.01f ))
+                && (localGas.depth_meter <= bestGasDepth)) {
                 betterGasIdLocal = i;
                 bestGasDepth = diveSettings.gas[i].depth_meter;
             }
         }
     } else { /* travel gases */
         bestGasDepth = 0;
-        //check for travelgas
-        for (int i = 1 + gasIdOffset; i <= 5 + gasIdOffset; i++) {
+        //check for travalgas
+        for (i = 1 + gasIdOffset; i <= 5 + gasIdOffset; i++) {
             if ((diveSettings.gas[i].note.ub.active)
                 && (diveSettings.gas[i].note.ub.travel)
                 && (diveSettings.gas[i].depth_meter_travel)
@@ -265,6 +272,18 @@
             }
         }
     }
+    if((!getDiluent) && (betterGasIdLocal > NUM_OFFSET_DILUENT))	/* an OC gas was requested but Id is pointing to a diluent => return first OC */
+    {
+    	for (i = 1 ; i <= NUM_OFFSET_DILUENT; i++)
+    	{
+    		if(diveSettings.gas[i].note.ub.first)
+    		{
+    			betterGasIdLocal = i;
+    			break;
+    		}
+    	}
+    }
+
 
     return betterGasIdLocal;
 }
@@ -285,7 +304,7 @@
 
     if (isLoopMode(diveSettings.diveMode)) {
         betterGasId = getBetterGasId(true, lifeData.actualGas.GasIdInSettings, diveState);
-        betterBailoutGasId = getBetterGasId(false, NO_GAS_ID, diveState);
+        betterBailoutGasId = getBetterGasId(false, lifeData.lastDiluent_GasIdInSettings, diveState);
     } else {
         betterGasId = getBetterGasId(false, lifeData.actualGas.GasIdInSettings, diveState);
     }
@@ -566,7 +585,7 @@
 #ifdef ENABLE_CO2_SUPPORT
 static int8_t check_co2(SDiveState * pDiveState)
 {
-	if(pDiveState->mode != MODE_DIVE)
+	if((pDiveState->mode != MODE_DIVE) || (settingsGetPointer()->co2_sensor_active == 0))
 	{
 		pDiveState->warnings.co2High = 0;
 	}
@@ -585,6 +604,27 @@
 }
 #endif
 
+#ifdef HAVE_DEBUG_WARNINGS
+static int8_t check_debug(SDiveState * pDiveState)
+{
+	uint8_t index = 0;
+
+	pDiveState->warnings.debug = 0;
+
+	if((settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL) || (settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG))
+	{
+	    for(index=0; index<3; index++)
+	    {
+        	if(((pDiveState->lifeData.extIf_sensor_map[index] == SENSOR_DIGO2M) && (((SSensorDataDiveO2*)(stateUsed->lifeData.extIf_sensor_data[index]))->status & DVO2_FATAL_ERROR)))
+        	{
+        		pDiveState->warnings.debug = 1;
+        	}
+	    }
+	}
+	return pDiveState->warnings.debug;
+}
+#endif
+
 uint8_t debounce_warning_fallback(uint16_t debounceStepms)
 {
 	uint8_t retVal = 0;
--- a/Discovery/Src/data_central.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/data_central.c	Wed Aug 14 16:44:46 2024 +0200
@@ -72,6 +72,8 @@
 #include "tCCR.h"
 #include "crcmodel.h"
 #include "configuration.h"
+#include "tHome.h"
+#include "t3.h"
 
 static SDiveState stateReal = { 0 };
 SDiveState stateSim = { 0 };
@@ -375,6 +377,20 @@
 			 break;
 		}
 	}
+	/* generate Bitfield of active T3 views */
+	stateReal.diveSettings.activeAFViews = 0;
+	if(t3_customview_disabled(CVIEW_T3_Navigation) == 0)
+	{
+		stateReal.diveSettings.activeAFViews |= (1 << CVIEW_T3_Navigation);
+	}
+	if(t3_customview_disabled(CVIEW_T3_GasList) == 0)
+	{
+		stateReal.diveSettings.activeAFViews |= (1 << CVIEW_T3_GasList);
+	}
+	if(t3_customview_disabled(CVIEW_T3_DecoTTS) == 0)
+	{
+		stateReal.diveSettings.activeAFViews |= (1 << CVIEW_T3_DecoTTS);
+	}
 }
 
 
@@ -902,3 +918,28 @@
 {
     stateUsedWrite->timerState = TIMER_STATE_OFF;
 }
+
+#define SPEED_SLOW		(5.0f)
+#define SPEED_MEDIUM	(10.0f)
+#define SPEED_HIGH		(15.0f)
+
+uint8_t drawingColor_from_ascentspeed(float speed)
+{
+	uint8_t color = CLUT_Font020;
+
+    if(speed >= SPEED_HIGH)
+    {
+    	color = CLUT_WarningRed;
+    }
+    else if(speed >= SPEED_MEDIUM)
+    {
+    	color = CLUT_WarningYellow;
+    }
+    else if(speed >= SPEED_SLOW)
+    {
+    	color = CLUT_NiceGreen;
+    }
+    return color;
+}
+
+
--- a/Discovery/Src/data_exchange_main.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/data_exchange_main.c	Wed Aug 14 16:44:46 2024 +0200
@@ -423,19 +423,15 @@
 	{
 		externalInterface_Cmd |= EXT_INTERFACE_ADC_ON | EXT_INTERFACE_33V_ON;
 	}
-	if(SensorActive[SENSOR_DIGO2])
+	if((SensorActive[SENSOR_DIGO2]) || (SensorActive[SENSOR_CO2]))
 	{
-		externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_O2;
-	}
-	else if(SensorActive[SENSOR_CO2])		/* TODO: at the moment only one serial sensor is supported => else condition. to be changed once multiplexing is available */
-	{
-		externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_CO2;		/* CO2 sensor has to be activated via auto detection */
+		externalInterface_Cmd |= EXT_INTERFACE_33V_ON;
 	}
 
 #ifdef ENABLE_SENTINEL_MODE
 	if(SensorActive[SENSOR_SENTINEL])
 	{
-			externalInterface_Cmd |= EXT_INTERFACE_33V_ON | EXT_INTERFACE_UART_SENTINEL;
+			externalInterface_Cmd |= EXT_INTERFACE_33V_ON;
 			externalInterface_Cmd &= (~EXT_INTERFACE_ADC_ON);
 	}
 #endif
@@ -1159,7 +1155,7 @@
 		pStateReal->sensorErrorsRTE = dataIn.sensorErrors;
 
 		/* data from CO2 sensor */
-		pStateReal->lifeData.CO2_data.CO2_ppm = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_CO2)].CO2_ppm * 10;	/* Scale factor depends on sensor */
+		pStateReal->lifeData.CO2_data.CO2_ppm = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_CO2)].CO2_ppm;
 		pStateReal->lifeData.CO2_data.signalStrength = dataIn.data[(dataIn.boolADCO2Data && DATA_BUFFER_CO2)].CO2_signalStrength;
 
 #ifdef ENABLE_EXTERNAL_PRESSURE
--- a/Discovery/Src/display.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/display.c	Wed Aug 14 16:44:46 2024 +0200
@@ -68,6 +68,14 @@
 		{
 		hardwareDisplay=1;
 		}
+	else
+	{	// re-reset the screen to be sure the 0x71 command did nothing
+		HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_RESET);
+		HAL_Delay(10);
+		HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_SET);
+		HAL_Delay(25);
+
+	}
 
 	/* RGB signals should be now for 2 frames or more (datasheet) */
 }
--- a/Discovery/Src/externLogbookFlash.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/externLogbookFlash.c	Wed Aug 14 16:44:46 2024 +0200
@@ -115,16 +115,19 @@
 /* Exported variables --------------------------------------------------------*/
 
 /* Private variables ---------------------------------------------------------*/
+
+#ifndef BOOTLOADER_STANDALONE
+static uint32_t	entryPoint = 0;
+static uint32_t	LengthLeftSampleRead = 0;
+static uint32_t	actualPointerDevicedata_Read = DDSTART;
+#endif
+
 static uint32_t	actualAddress = 0;
 static uint32_t	preparedPageAddress = 0;
 static uint32_t closeSectorAddress = 0;
-static uint32_t	entryPoint = 0;
-
 static uint32_t	actualPointerHeader = 0;
 static uint32_t	actualPointerSample = 0;
-static uint32_t	LengthLeftSampleRead = 0;
 static uint32_t	actualPointerDevicedata = DDSTART;
-static uint32_t	actualPointerDevicedata_Read = DDSTART;
 static uint32_t	actualPointerVPM = 0;
 static uint32_t	actualPointerSettings = SETTINGSSTART;
 static uint32_t	actualPointerFirmware = 0;
@@ -133,9 +136,14 @@
 /* Private function prototypes -----------------------------------------------*/
 static void chip_unselect(void);
 static void chip_select(void);
+#ifndef BOOTLOADER_STANDALONE
 static void error_led_on(void);
 static void error_led_off(void);
-
+static void ext_flash_decf_address_ring(uint8_t type);
+static void ext_flash_disable_protection(void);
+static _Bool ext_flash_test_remaining_space_of_page_empty(uint32_t pointer, uint16_t length);
+static void ext_flash_set_to_begin_of_next_page(uint32_t *pointer, uint8_t type);
+#endif
 static void write_spi(uint8_t data, uint8_t unselect_CS_afterwards);
 static uint8_t read_spi(uint8_t unselect_CS_afterwards);
 static void write_address(uint8_t unselect_CS_afterwards);
@@ -143,7 +151,6 @@
 static void wait_chip_not_busy(void);
 static void ext_flash_incf_address(uint8_t type);
 //void ext_flash_incf_address_ring(void);
-static void ext_flash_decf_address_ring(uint8_t type);
 
 static void ext_flash_erase4kB(void);
 static void ext_flash_erase32kB(void);
@@ -159,13 +166,11 @@
 static void ef_hw_rough_delay_us(uint32_t delayUs);
 static void ef_erase_64K(uint32_t blocks);
 
+#ifndef BOOTLOADER_STANDALONE
 static void ext_flash_overwrite_sample_without_erase(uint8_t *pSample, uint16_t length);
-
-static void ext_flash_disable_protection(void);
+static void ext_flash_find_start(void);
+#endif
 
-static _Bool ext_flash_test_remaining_space_of_page_empty(uint32_t pointer, uint16_t length);
-static void ext_flash_set_to_begin_of_next_page(uint32_t *pointer, uint8_t type);
-static void ext_flash_find_start(void);
 
 
 /* Exported functions --------------------------------------------------------*/
@@ -1581,7 +1586,7 @@
 }
 
 
-#endif
+
 
 static void ext_flash_disable_protection(void)
 {
@@ -1596,7 +1601,7 @@
 	write_spi(status.uw,RELEASE);	// new status
 */
 }
-
+#endif
 
 void ext_flash_disable_protection_for_logbook(void)
 {
@@ -1932,7 +1937,7 @@
 	}
 }
 
-
+#ifndef BOOTLOADER_STANDALONE
 static _Bool ext_flash_test_remaining_space_of_page_empty(uint32_t pointer, uint16_t length)
 {
 	if((pointer & 0xFFF) == 0)
@@ -2002,7 +2007,7 @@
 	if((*pointer < ringStart) || (*pointer >= ringStop))
 		*pointer = ringStart;
 }
-
+#endif
 
 static void ef_erase_64K(uint32_t blocks)
 {
@@ -2027,7 +2032,7 @@
 {
 	HAL_GPIO_WritePin(EXTFLASH_CSB_GPIO_PORT,EXTFLASH_CSB_PIN,GPIO_PIN_RESET); // chip select
 }
-
+#ifndef BOOTLOADER_STANDALONE
 static void error_led_on(void)
 {
 		HAL_GPIO_WritePin(OSCILLOSCOPE_GPIO_PORT,OSCILLOSCOPE_PIN,GPIO_PIN_SET);
@@ -2037,7 +2042,7 @@
 {
 		HAL_GPIO_WritePin(OSCILLOSCOPE_GPIO_PORT,OSCILLOSCOPE_PIN,GPIO_PIN_RESET);
 }
-
+#endif
 
 static uint8_t read_spi(uint8_t unselect_CS_afterwards)
 {
@@ -2150,7 +2155,7 @@
 		actualAddress = ringStart;
 }
 
-
+#ifndef BOOTLOADER_STANDALONE
 static void ext_flash_decf_address_ring(uint8_t type)
 {
 	uint32_t ringStart, ringStop;
@@ -2196,7 +2201,7 @@
 	else
 		actualAddress -= 1;
 }
-
+#endif
 
 static void ef_hw_rough_delay_us(uint32_t delayUs)
 {
@@ -2380,7 +2385,7 @@
 }
 
 
-/*
+
 uint8_t ext_flash_erase_firmware_if_not_empty(void)
 {
 	const uint8_t TESTSIZE_FW = 4;
@@ -2431,4 +2436,4 @@
 	}
 	else
 		return 0;
-}*/
+}
--- a/Discovery/Src/gfx_engine.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/gfx_engine.c	Wed Aug 14 16:44:46 2024 +0200
@@ -36,7 +36,8 @@
 
 /* Private types -------------------------------------------------------------*/
 
-#define RING_BUF_SIZE	(5u)
+#define RING_BUF_SIZE			(5u)
+#define MAX_COLOR_STRING_LENGTH	(100u)
 
 typedef struct
 {
@@ -251,7 +252,6 @@
 	backgroundHwStatus = LOGOSTOP;
 }
 
-
 void GFX_build_hw_background_frame(void)
 {
 	GFX_DrawCfgScreen	tLogoTemp;
@@ -319,7 +319,6 @@
 */	
 }
 
-
 void GFX_init(uint32_t  * pDestinationOut)
 {
 	frame[0].StartAddress = FBGlobalStart;
@@ -361,6 +360,57 @@
 
 	DMA2D_at_work = 255;
 }
+void GFX_init1_no_DMA(uint32_t  * pDestinationOut, uint8_t blockFrames)
+{
+	frame[0].StartAddress = FBGlobalStart;
+	GFX_clear_frame_immediately(frame[0].StartAddress);
+	frame[0].status = CLEAR;
+	frame[0].caller = 0;
+
+	for(int i=1;i<MAXFRAMES;i++)
+	{
+		frame[i].StartAddress = frame[i-1].StartAddress + FBOffsetEachIndex;
+		GFX_clear_frame_immediately(frame[i].StartAddress);
+		frame[i].status = CLEAR;
+		frame[i].caller = 0;
+	}
+
+	for(int i=0;i<blockFrames;i++)
+	{
+		frame[i].status = BLOCKED;
+		frame[i].caller = 1;
+	}
+	
+	pInvisibleFrame = getFrame(2);
+	*pDestinationOut = pInvisibleFrame;
+
+	GFX_build_logo_frame();
+	GFX_build_hw_background_frame();
+}
+
+
+void GFX_init2_DMA(void)
+{
+  /* Register to memory mode with ARGB8888 as color Mode */
+  Dma2dHandle.Init.Mode         = DMA2D_R2M;
+  Dma2dHandle.Init.ColorMode    = DMA2D_ARGB4444;//to fake AL88,  before: DMA2D_ARGB8888;
+  Dma2dHandle.Init.OutputOffset = 0;
+
+  /* DMA2D Callbacks Configuration */
+  Dma2dHandle.XferCpltCallback  = GFX_Dma2d_TransferComplete;
+  Dma2dHandle.XferErrorCallback = GFX_Dma2d_TransferError;
+
+  Dma2dHandle.Instance  = DMA2D;
+
+  /* DMA2D Initialisation */
+	if(HAL_DMA2D_Init(&Dma2dHandle) != HAL_OK)
+		GFX_Error_Handler();
+
+  if(HAL_DMA2D_ConfigLayer(&Dma2dHandle, 1) != HAL_OK)
+		GFX_Error_Handler();
+
+	DMA2D_at_work = 255;
+}
 
 
 void GFX_SetFrameTop(uint32_t pDestination)
@@ -533,6 +583,7 @@
 	}
 	else if (backgroundHwStatus != LOGOOFF)
 	{
+
 		switch(backgroundHwStatus)
 			{
 			case LOGOSTART:
@@ -567,6 +618,7 @@
 				FrameHandler.NextBottomRead = nextBottomBackup;
 				break;
 			}
+
 		return;
 	}
 	else
@@ -976,7 +1028,6 @@
 	}
 }
 	
-
 static void GFX_draw_image_color(GFX_DrawCfgScreen *hgfx, SWindowGimpStyle window, const tImage *image)
 {
 	uint16_t* pDestination;
@@ -1766,7 +1817,8 @@
 
 /**
   ******************************************************************************
-  * @brief   GFX writeGfx_write_label_varstring. /  Write string with all parameters and font color options
	heinrichs weikamp gmbh
+  * @brief   GFX writeGfx_write_label_varstring. /  Write string with all parameters and font color options
+	heinrichs weikamp gmbh
   * @version V0.0.1
   * @date    22-April-2014
   ******************************************************************************
@@ -2102,6 +2154,7 @@
 				settings.actualFont = (tFont *)settings.font;
 			}
 			else
+//#ifndef BOOTLOADER_STANDALONE
 			if((*pText == '\005') && !minimal)
 			{
 				newXdelta = GFX_write_char(hgfx, &settings, 'a', (tFont *)&Awe48);
@@ -2114,6 +2167,7 @@
 				settings.Xdelta = newXdelta;
 			}
 			else
+//#endif
 			if((*pText >= '\020') && (*pText <= '\032') && !minimal)
 				settings.color = *pText - '\020';
 			else
@@ -2190,15 +2244,13 @@
 	uint32_t found;
 	uint32_t pText;
 	uint16_t decodeUTF8;
-	uint8_t gfx_selected_language;
 #ifndef BOOTLOADER_STANDALONE
+	uint8_t gfx_selected_language = 0;
 	SSettings *pSettings;
 	pSettings = settingsGetPointer();
 	gfx_selected_language = pSettings->selected_language;
-	if(gfx_selected_language >= LANGUAGE_END)
+	if(gfx_selected_language >= LANGUAGE_END) gfx_selected_language = 0;
 #endif		
-		gfx_selected_language = 0;
-
 
 // -----------------------------
  	if(textId != (uint8_t)TXT_2BYTE)
@@ -2207,23 +2259,27 @@
 		j = 0;
 		for(i=(uint8_t)TXT_Language;i<(uint8_t)TXT_END;i++)
 		{
+#ifndef BOOTLOADER_STANDALONE
 			if(text_array[j].code == textId)
 			{
 				found = 1;
 				break;
 			}
+#endif
 			j++;
 		}
 		if(!found)
 			return cfg->Xdelta;
 
 // -----------------------------
+#ifndef BOOTLOADER_STANDALONE
 		pText = (uint32_t)text_array[j].text[gfx_selected_language];
 		if(!pText)
 			pText = (uint32_t)text_array[j].text[0];
 		else
 		if(*(char*)pText == 0)
 			pText = (uint32_t)text_array[j].text[0];
+#endif
 	}
 // -----------------------------
 	else
@@ -2234,14 +2290,17 @@
 		found = 0;
 		for(j=0;j<(uint8_t)TXT2BYTE_END-(uint8_t)TXT2BYTE_START;j++)
 		{
+#ifndef BOOTLOADER_STANDALONE
 			if((uint8_t)text_array2[j].code == (uint8_t)nextCharFor2Byte)
 			{
 				found = 1;
 				break;
 			}
+#endif
 		}
 		if(!found)
 			return cfg->Xdelta;
+#ifndef BOOTLOADER_STANDALONE
 // -----------------------------
 		pText = (uint32_t)text_array2[j].text[gfx_selected_language];
 		if(!pText)
@@ -2249,6 +2308,7 @@
 		else
 		if(*(char*)pText == 0)
 			pText = (uint32_t)text_array2[j].text[0];
+#endif
 	}
 // -----------------------------
 	
@@ -2687,7 +2747,10 @@
 
 static uint32_t GFX_write_char(GFX_DrawCfgWindow* hgfx, GFX_CfgWriteString* cfg, uint8_t character, tFont *Font)
 {
+
+#ifndef BOOTLOADER_STANDALONE
 	Font = GFX_Check_Extra_Font(character, Font);
+#endif
 	if(cfg->doubleSize)
 	{
 		return GFX_write_char_doubleSize(hgfx, cfg, character, Font);
@@ -3008,6 +3071,7 @@
 		return cfg->Xdelta + width;
 }
 
+#ifndef BOOTLOADER_STANDALONE
 
 /**
   ******************************************************************************
@@ -3107,7 +3171,7 @@
 	return counter;
 }
 
-
+#endif
 /**
   ******************************************************************************
   * @brief   GFX write Modify Ydelta for align. /  calc Ydelta for start
@@ -3128,23 +3192,22 @@
 	uint32_t result;
 	uint32_t Xsum;
 	uint32_t j;
-	uint8_t gfx_selected_language;
 	uint32_t pText;
 	uint16_t decodeUTF8;
 	uint8_t tinyState = 0;		/* used to identify the usage of tiny font */
 	tFont* ptargetFont;
 
 #ifndef BOOTLOADER_STANDALONE
+	uint8_t gfx_selected_language = 0;
 	SSettings *pSettings;
 	pSettings = settingsGetPointer();
 	gfx_selected_language = pSettings->selected_language;
 	if(gfx_selected_language >= LANGUAGE_END)
 #endif
-		gfx_selected_language = 0;
 // -----------------------------
-
+#ifndef BOOTLOADER_STANDALONE
 	GFX_write__Modify_helper(cText,pTextInput,gfx_selected_language);
-
+#endif
 	pText = (uint32_t)&cText[0];
 	Xsum = 0;
 	j = 0;
@@ -3221,28 +3284,29 @@
 
 static uint32_t GFX_write__Modify_Xdelta__RightAlign(GFX_CfgWriteString* cfg, GFX_DrawCfgWindow* hgfx, const char *pTextInput)
 {
-	char cText[101];
 	uint32_t result;
 	uint32_t Xsum;
 	uint32_t j;
 	tFont *font;
-	uint8_t gfx_selected_language;
+	char cText[101];
 	uint32_t pText;
 	uint16_t decodeUTF8;
 	uint8_t tinyState = 0;		/* used to identify the usage of tiny font */
 
 #ifndef BOOTLOADER_STANDALONE
+	uint8_t gfx_selected_language = 0;
 	SSettings *pSettings;
 	pSettings = settingsGetPointer();
 	gfx_selected_language = pSettings->selected_language;
 	if(gfx_selected_language >= LANGUAGE_END)
+#else
+	cText[0] = 0;
 #endif
-		gfx_selected_language = 0;
 // -----------------------------
-
+#ifndef BOOTLOADER_STANDALONE
 	GFX_write__Modify_helper(cText,pTextInput,gfx_selected_language);
+#endif
 	pText = (uint32_t)&cText[0];
-
 // -----------------------------
 
 	font = (tFont *)cfg->font;
@@ -3339,34 +3403,34 @@
 {
 	  /* Timing configuration */
 
-#define		ActiveH 800
-#define		ActiveW	480
-
-#define		Hsync 	10
-#define		HFP		8
-#define		HBP		10
-
-#define		Vsync	2
-#define		VFP		2
-#define		VBP		2
+#define		ActiveH_d0 	800
+#define		ActiveW_d0	480
+
+#define		Hsync_d0 	10
+#define		HFP_d0		8
+#define		HBP_d0		10
+
+#define		Vsync_d0	2
+#define		VFP_d0		2
+#define		VBP_d0		2
 
 
   /* Horizontal synchronization width = Hsync - 1 */
-  LtdcHandle.Init.HorizontalSync = Hsync - 1;
+  LtdcHandle.Init.HorizontalSync = Hsync_d0 - 1;
   /* Vertical synchronization height = Vsync - 1 */
-  LtdcHandle.Init.VerticalSync = Vsync -1;
+  LtdcHandle.Init.VerticalSync = Vsync_d0 - 1;
   /* Accumulated horizontal back porch = Hsync + HBP - 1 */
-  LtdcHandle.Init.AccumulatedHBP = Hsync + HBP - 1;
+  LtdcHandle.Init.AccumulatedHBP = Hsync_d0 + HBP_d0 - 1;
   /* Accumulated vertical back porch = Vsync + VBP - 1 */
-  LtdcHandle.Init.AccumulatedVBP = Vsync + VBP - 1;
+  LtdcHandle.Init.AccumulatedVBP = Vsync_d0 + VBP_d0 - 1;
   /* Accumulated active width = Hsync + HBP + Active Width - 1 */
-  LtdcHandle.Init.AccumulatedActiveW = Hsync + HBP + ActiveW- 1;
+  LtdcHandle.Init.AccumulatedActiveW = Hsync_d0 + HBP_d0 + ActiveW_d0 - 1;
   /* Accumulated active height = Vsync + VBP + Active Heigh - 1 */
-  LtdcHandle.Init.AccumulatedActiveH = Vsync + VBP + ActiveH - 1;
+  LtdcHandle.Init.AccumulatedActiveH = Vsync_d0 + VBP_d0 + ActiveH_d0 - 1;
   /* Total width = Hsync + HBP + Active Width + HFP - 1 */
-  LtdcHandle.Init.TotalWidth = Hsync + HBP + ActiveW + HFP - 1;
+  LtdcHandle.Init.TotalWidth = Hsync_d0 + HBP_d0 + ActiveW_d0 + HFP_d0 - 1;
   /* Total height = Vsync + VBP + Active Heigh + VFP - 1 */
-  LtdcHandle.Init.TotalHeigh = Vsync + VBP + ActiveH + VFP - 1;
+  LtdcHandle.Init.TotalHeigh = Vsync_d0 + VBP_d0 + ActiveH_d0 + VFP_d0 - 1;
 
 	/* Configure R,G,B component values for LCD background color */
 	LtdcHandle.Init.Backcolor.Red= 0;
@@ -4000,6 +4064,7 @@
 */	
 }
 
+#ifndef BOOTLOADER_STANDALONE
 tFont* GFX_Check_Extra_Font(uint8_t character, tFont *Font)
 {
 	uint32_t i;
@@ -4029,11 +4094,13 @@
 
 	return Font;
 }
-
+#endif
 uint32_t GFX_Character_Width(uint8_t character, tFont *Font)
 {
 	uint32_t i;
+#ifndef BOOTLOADER_STANDALONE
 	uint32_t found;
+#endif
 
 	for(i=0;i<Font->length;i++)
 	{
@@ -4043,6 +4110,7 @@
 		}
 	}
 
+#ifndef BOOTLOADER_STANDALONE
 	found = 0;
 	if (Font == &FontT54)
 	{
@@ -4070,6 +4138,30 @@
 			}
 		}
 	}
-
+#endif
 	return 0;
 }
+
+void Gfx_colorsscheme_mod(char *text, uint8_t alternativeColor)
+{
+	char *p = text;
+	uint8_t index = 0;
+
+	while ((*p) && (index < MAX_COLOR_STRING_LENGTH))
+	{
+		if (*p == '\020')
+		{
+			if(!GFX_is_colorschemeDiveStandard())
+			{
+				*p = '\027';
+			}
+			else if(alternativeColor != 0)
+			{
+				*p += alternativeColor;
+			}
+		}
+		p++;
+		index++;
+	}
+}
+
--- a/Discovery/Src/ostc.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/ostc.c	Wed Aug 14 16:44:46 2024 +0200
@@ -46,6 +46,7 @@
 UART_HandleTypeDef UartIR_HUD_Handle;
 
 __IO ITStatus UartReady = RESET;
+__IO ITStatus UartReadyHUD = RESET;
 
 /* Private types -------------------------------------------------------------*/
 
@@ -91,6 +92,42 @@
     HAL_SPI_Init(&cpu2DmaSpi);
 }
 
+
+void MX_GPIO_Backlight_max_static_only_Init(void)
+{
+    GPIO_InitTypeDef GPIO_InitStruct;
+    TIM_BACKLIGHT_GPIO_ENABLE();
+
+    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+    GPIO_InitStruct.Pull = GPIO_NOPULL;//GPIO_PULLUP; /* should be normally high */
+    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
+
+    GPIO_InitStruct.Pin = TIM_BACKLIGHT_PIN;
+    HAL_GPIO_Init(TIM_BACKLIGHT_GPIO_PORT, &GPIO_InitStruct);
+
+    HAL_GPIO_WritePin(TIM_BACKLIGHT_GPIO_PORT,TIM_BACKLIGHT_PIN,GPIO_PIN_SET);
+}
+
+
+void MX_GPIO_One_Button_only_Init(void)
+{
+    GPIO_InitTypeDef GPIO_InitStruct;
+    BUTTON_NEXT_GPIO_ENABLE();
+
+    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+    GPIO_InitStruct.Pull = GPIO_NOPULL;//GPIO_PULLUP; /* should be normally high */
+    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
+
+    GPIO_InitStruct.Pin = BUTTON_NEXT_PIN;
+    HAL_GPIO_Init(BUTTON_NEXT_GPIO_PORT, &GPIO_InitStruct);
+}
+
+
+GPIO_PinState MX_GPIO_Read_The_One_Button(void)
+{
+    return HAL_GPIO_ReadPin(BUTTON_NEXT_GPIO_PORT, BUTTON_NEXT_PIN);
+}
+
 void MX_GPIO_Init(void)
 {
     GPIO_InitTypeDef GPIO_InitStruct;
@@ -228,6 +265,26 @@
 #endif
 }
 
+
+void MX_SmallCPU_NO_Reset_Helper(void)
+{
+#ifdef SMALLCPU_NRESET_PIN
+    GPIO_InitTypeDef GPIO_InitStruct;
+
+    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+    GPIO_InitStruct.Pull = GPIO_NOPULL;
+    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
+
+    SMALLCPU_NRESET_GPIO_ENABLE();
+    HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct);
+    HAL_GPIO_WritePin(SMALLCPU_NRESET_GPIO_PORT,SMALLCPU_NRESET_PIN,GPIO_PIN_SET);
+//	HAL_Delay(100);
+//  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+//  HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct);
+#endif
+}
+
+
 void MX_SmallCPU_Reset_To_Standard(void)
 {
 #ifdef SMALLCPU_NRESET_PIN
@@ -248,6 +305,23 @@
 #endif
 }
 
+
+uint8_t MX_UART_ButtonAdjust(uint8_t *array)
+{
+#ifdef USART_PIEZO
+    uint8_t answer[4];
+    HAL_UART_Transmit(&UartPiezoTxHandle,array,4,1000);
+    HAL_UART_Receive(&UartPiezoTxHandle,answer,4,2000);
+    if(	(answer[0] == array[0])
+        &&(answer[1] == array[1])
+        &&(answer[2] == array[2])
+        &&(answer[3] == array[3]))
+    return 1;
+#endif
+    return 0;
+}
+
+
 void MX_UART_Init(void)
 {
   /*##-1- Configure the UART peripheral ######################################*/
@@ -311,7 +385,10 @@
     else
     if(huart == &UartIR_HUD_Handle)
     {
+#ifndef BOOTLOADER_STANDALONE
     	tCCR_SetRXIndication();
+#endif
+		UartReadyHUD = SET;
     }
 }
 
--- a/Discovery/Src/settings.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/settings.c	Wed Aug 14 16:44:46 2024 +0200
@@ -43,7 +43,7 @@
 SSettings Settings;
 
 const uint8_t RTErequiredHigh = 3;
-const uint8_t RTErequiredLow = 2;
+const uint8_t RTErequiredLow = 3;
 
 const uint8_t FONTrequiredHigh = 1;
 const uint8_t FONTrequiredLow =	0;
@@ -62,8 +62,8 @@
 {
     .versionFirst   = 1,
     .versionSecond 	= 6,
-    .versionThird   = 5,
-    .versionBeta    = 0,
+    .versionThird   = 7,
+    .versionBeta    = 1,
 
     /* 4 bytes with trailing 0 */
     .signature = "mh",
@@ -89,7 +89,7 @@
  * There might even be entries with fixed values that have no range
  */
 const SSettings SettingsStandard = {
-    .header = 0xFFFF0028,
+    .header = 0xFFFF002A,
     .warning_blink_dsec = 8 * 2,
     .lastDiveLogId = 0,
     .logFlashNextSampleStartAddress = SAMPLESTART,
@@ -339,6 +339,7 @@
     .compassDeclinationDeg = 0,
     .delaySetpointLow = false,
     .timerDurationS = 180,
+	.cvAutofocus = 0,
 };
 
 /* Private function prototypes -----------------------------------------------*/
@@ -581,7 +582,22 @@
     	pSettings->cv_config_BigScreen = pSettings->cv_config_BigScreen >> (LEGACY_T3_START_ID_PRE_TIMER - 3);
     	pSettings->cv_config_BigScreen &= ~0x00000007;		/* just to be sure: clear lower three bits */
     	pSettings->cv_config_BigScreen |= tmp;
-
+    	// no break;
+    case 0xFFFF0028:						/* In previous version deco gases were automatically used for deco calculation */
+        for(tmp=1; tmp<=2*NUM_GASES; tmp++) /* This is now handled by an additional parameter. Set it to true to maintain same behavior as before */
+        {
+            if(Settings.gas[tmp].note.ub.deco)
+            {
+            	Settings.gas[tmp].note.ub.decocalc = 1;
+            }
+            else
+            {
+            	Settings.gas[tmp].note.ub.decocalc = 0;
+            }
+        }
+    	// no break;
+    case 0xFFFF0029:
+    	Settings.cvAutofocus = 0;
     	// no break;
     default:
         pSettings->header = pStandard->header;
@@ -1821,6 +1837,12 @@
         setFirstCorrection(parameterId);
     }
     parameterId++;
+    if(Settings.cvAutofocus > 1)
+    {
+    	 corrections++;
+    	 Settings.cvAutofocus = 0;
+    }
+    parameterId++;
     if(corrections)
     {
     	settingsWarning = 1;
@@ -1836,7 +1858,7 @@
     return (uint8_t)corrections;
 }
 
-
+#ifndef BOOTLOADER_STANDALONE
 /* always at 0x8080000, do not move -> bootloader access */
 const SFirmwareData* firmwareDataGetPointer(void)
 {
@@ -1850,7 +1872,7 @@
     return (SHardwareData *)HARDWAREDATA_ADDRESS;
 }
 #endif
-
+#endif
 const SSettings* settingsGetPointerStandard(void)
 {
     return &SettingsStandard;
@@ -2989,7 +3011,7 @@
     RTEactualLow = low;
 }
 
-
+#ifndef BOOTLOADER_STANDALONE
 void getActualRTEandFONTversion(uint8_t *RTEhigh, uint8_t *RTElow, uint8_t *FONThigh, uint8_t *FONTlow)
 {
     if(RTEhigh && RTElow)
@@ -3009,7 +3031,7 @@
 {
     return hardwareDataGetPointer()->primaryLicence;
 }
-
+#endif
 
 void firmwareGetDate(RTC_DateTypeDef *SdateOutput)
 {
--- a/Discovery/Src/simulation.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/simulation.c	Wed Aug 14 16:44:46 2024 +0200
@@ -466,7 +466,8 @@
         // ascend (deco) gases
         for(int i=1; i<=5;i++)
         {
-            if(pDiveState->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            if((pDiveState->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            		|| (pDiveState->diveSettings.gas[pDiveState->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
                 break;
             gasChangeListDepthGas20x2[ptrGasChangeList++] = pDiveState->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero;
             gasChangeListDepthGas20x2[ptrGasChangeList++] = pDiveState->diveSettings.decogaslist[i].GasIdInSettings;
--- a/Discovery/Src/t3.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/t3.c	Wed Aug 14 16:44:46 2024 +0200
@@ -28,6 +28,7 @@
 
 /* Includes ------------------------------------------------------------------*/
 #include <stdbool.h>
+#include <stdlib.h>
 
 #include "t3.h"
 
@@ -40,6 +41,8 @@
 #include "unit.h"
 #include "motion.h"
 #include "logbook_miniLive.h"
+#include "tMenuEditCustom.h"
+#include "gfx_engine.h"
 
 
 #define CV_PROFILE_WIDTH		(600U)
@@ -61,31 +64,19 @@
 
 uint8_t t3_selection_customview = CVIEW_noneOrDebug;
 
+static uint8_t AF_lastDecoDepth = 0;
+static uint16_t AF_lastTTS = 0;
+
+
 /* TEM HAS TO MOVE TO GLOBAL--------------------------------------------------*/
 
 /* Private types -------------------------------------------------------------*/
 #define TEXTSIZE 16
-#define NUMBER_OF_VIEWS 7	/* number of views defined in the array below */
 
-const uint8_t t3_customviewsStandard[] =
-{
-    CVIEW_T3_Decostop,
-    CVIEW_sensors,
-    CVIEW_Compass,
-    CVIEW_T3_MaxDepth,
-    CVIEW_T3_StopWatch,
-    CVIEW_T3_TTS,
-    CVIEW_T3_ppO2andGas,
-	CVIEW_T3_GasList,
-	CVIEW_T3_Navigation,
-	CVIEW_T3_DepthData,
-	CVIEW_noneOrDebug,
-	CVIEW_T3_DecoTTS,
-#ifdef ENABLE_T3_PROFILE_VIEW
-	CVIEW_T3_Profile,
-#endif
-    CVIEW_T3_END
-};
+/* defines for autofocus of compass */
+#define AF_COMPASS_ACTIVATION_ANGLE	(10.0f)	/* angle for pitch and roll. Compass gets activated in case the value is smaller (OSTC4 hold in horitontal position */
+#define AF_COMPASS_DEBOUNCE			(10u)	/* debouncing value to avoid compass activation during normal movement */
+
 
 /* Private function prototypes -----------------------------------------------*/
 void t3_refresh_divemode(void);
@@ -93,6 +84,7 @@
 uint8_t t3_test_customview_warnings(void);
 void t3_refresh_customview(float depth);
 void t3_basics_compass(GFX_DrawCfgScreen *tXscreen, point_t center, uint16_t ActualHeading, uint16_t UserSetHeading);
+uint8_t t3_EvaluateAFCondition(uint8_t T3CView);
 
 /* Exported functions --------------------------------------------------------*/
 
@@ -101,7 +93,7 @@
 	SSettings* pSettings;
 	pSettings = settingsGetPointer();
 
-    t3_selection_customview = t3_customviewsStandard[0];
+    t3_selection_customview = cv_changelist_BS[0];
 
     t3screen.FBStartAdress = 0;
     t3screen.ImageHeight = 480;
@@ -172,6 +164,8 @@
     t3c2.WindowY0 = t3c1.WindowY0;
     t3c2.WindowY1 = t3c1.WindowY1;
     t3c2.WindowTab = 600;
+
+    t3_EvaluateAFCondition(CVIEW_T3_END);		/* reset debounce counters */
 }
 
 void t3_select_customview(uint8_t selectedCustomview)
@@ -417,7 +411,6 @@
     	GFX_draw_line(tXscreen, start, stop, CLUT_Font020);
     }
 
-
     start.y = BigFontSeperationTopBottom;
     stop.y = 479;
 
@@ -432,6 +425,7 @@
     }
 
     /* depth */
+    color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min);
     float depth = unit_depth_float(stateUsed->lifeData.depth_meter);
 
     if(depth <= 0.3f)
@@ -460,7 +454,7 @@
     else
         snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth);
 
-    t3_basics_colorscheme_mod(text);
+    Gfx_colorsscheme_mod(text,color);
     GFX_write_string(&FontT105,tXl1,text,1);
 
 
@@ -655,7 +649,7 @@
             else
                 snprintf(text,TEXTSIZE,"\020\003\002\016%u'",Divetime.Minutes);
         }
-        t3_basics_colorscheme_mod(text);
+        Gfx_colorsscheme_mod(text,0);
         GFX_write_string(&FontT105,tXr1,text,1);
     }
     else
@@ -726,7 +720,7 @@
 							else
 								snprintf(text,TEXTSIZE,"\020\003\002\016%u'",Divetime.Minutes);
 
-						    t3_basics_colorscheme_mod(text);
+						    Gfx_colorsscheme_mod(text,0);
 						    GFX_write_string(&FontT105,tXr1,text,1);
 				break;
     	}
@@ -831,7 +825,7 @@
         else
             text[textpointer++] = 'F';
         text[textpointer++] = 0;
-        t3_basics_colorscheme_mod(text);
+        Gfx_colorsscheme_mod(text,0);
         GFX_write_string(&FontT105,tXc1,text,1);
         break;
 
@@ -858,7 +852,7 @@
         }
 
         snprintf(text,TEXTSIZE,"\020\016%u:%02u",LastDivetime.Minutes, LastDivetime.Seconds);
-        t3_basics_colorscheme_mod(text);
+        Gfx_colorsscheme_mod(text,0);
         GFX_write_string(&FontT105,tXc1,text,0);
 
         if(pSettings->FlipDisplay)
@@ -880,7 +874,7 @@
         }
 
         snprintf(text,TEXTSIZE,"\020\016%u:%02u",TotalDivetime.Minutes, TotalDivetime.Seconds);
-        t3_basics_colorscheme_mod(text);
+        Gfx_colorsscheme_mod(text,0);
         GFX_write_string(&FontT105,tXc1,text,0);
 
         snprintf(text,TEXTSIZE,"\032\002%c%c",TXT_2BYTE, TXT2BYTE_ApneaTotal);
@@ -902,7 +896,7 @@
 
 void t3_basics_refresh_customview(float depth, uint8_t tX_selection_customview, GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXc1, GFX_DrawCfgWindow* tXc2, uint8_t mode)
 {
-	static uint8_t last_customview = CVIEW_END;
+	static uint8_t last_customview = CVIEW_T3_END;
 
     char text[30];
     uint16_t textpointer = 0;
@@ -971,7 +965,7 @@
     {
     	heading = (uint16_t)stateUsed->lifeData.compass_heading;
     }
-	if(last_customview != tX_selection_customview)		/* check if current selection is disabled and should be skipped */
+	if((last_customview != tX_selection_customview)	&& (settingsGetPointer()->design == 3))	/* check if current selection is disabled and should be skipped */
 	{
 		if(t3_customview_disabled(tX_selection_customview))
 		{
@@ -997,7 +991,7 @@
         }
 
         snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_last_max_depth_meter));
-        t3_basics_colorscheme_mod(text);
+        Gfx_colorsscheme_mod(text,0);
         
         if(!pSettings->FlipDisplay)
         {
@@ -1012,7 +1006,7 @@
 
 
         snprintf(text,TEXTSIZE,"\020\016%01.1f",unit_depth_float(stateUsed->lifeData.apnea_total_max_depth_meter));
-        t3_basics_colorscheme_mod(text);
+        Gfx_colorsscheme_mod(text,0);
         if(!pSettings->FlipDisplay)
         {
 		    GFX_write_string(&FontT105,tXc1,text,0);
@@ -1202,7 +1196,7 @@
 			, unit_depth_char1_T105()
 			, unit_depth_char2_T105()
 			, (nextstopLengthSeconds+59)/60);
-			t3_basics_colorscheme_mod(text);
+			Gfx_colorsscheme_mod(text,0);
 			GFX_write_string(&FontT105,tXc1,text,0);
         }
         else if(SafetyStopTime.Total && (depth > timer_Safetystop_GetDepthUpperLimit()))
@@ -1213,7 +1207,7 @@
 
             textpointer = 0;
             snprintf(&text[textpointer],TEXTSIZE,"\020\003\016%u:%02u",SafetyStopTime.Minutes,SafetyStopTime.Seconds);
-            t3_basics_colorscheme_mod(text);
+            Gfx_colorsscheme_mod(text,0);
             GFX_write_string(&FontT105,tXc1,text,0);
         }
         else if(pDecoinfo->output_ndl_seconds) // NDL
@@ -1224,7 +1218,7 @@
                 snprintf(text,TEXTSIZE,"\020\003%i'",pDecoinfo->output_ndl_seconds/60);
             else
                 snprintf(text,TEXTSIZE,"\020\003%ih",pDecoinfo->output_ndl_seconds/3600);
-            t3_basics_colorscheme_mod(text);
+            Gfx_colorsscheme_mod(text,0);
             GFX_write_string(&FontT105,tXc1,text,0);
         }
 
@@ -1240,7 +1234,7 @@
 						snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
 					else
 						snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
-					t3_basics_colorscheme_mod(text);
+					Gfx_colorsscheme_mod(text,0);
 					GFX_write_string(&FontT105,tXc1,text,0);
 				}
             }
@@ -1249,13 +1243,13 @@
             	snprintf(text,TEXTSIZE,"\002\032\f%c",TXT_ActualGradient);
 				GFX_write_string(&FontT42,tXc1,text,0);
                 snprintf(text,TEXTSIZE,"\020\003\002%.0f\016\016%%\017",100 * pDecoinfo->super_saturation);
-                t3_basics_colorscheme_mod(text);
+                Gfx_colorsscheme_mod(text,0);
                 GFX_write_string(&FontT105,tXc1,text,0);
             }
         }
         break;
 
-    case CVIEW_sensors:
+    case CVIEW_T3_sensors:
         snprintf(text,TEXTSIZE,"\032\f%c%c",TXT_2BYTE,TXT2BYTE_O2monitor);
         GFX_write_string(&FontT42,tXc1,text,0);
 
@@ -1295,6 +1289,26 @@
             }
             GFX_write_string(&FontT105,tXc1,text,0);
 
+            if((pSettings->co2_sensor_active) && isLoopMode(pSettings->dive_mode))
+            {
+            	snprintf(text,TEXTSIZE,"\032\001\f%c",TXT_CO2Sensor);
+                GFX_write_string(&FontT42,tXc1,text,0);
+                textpointer = 0;
+                if(stateUsed->lifeData.CO2_data.CO2_ppm < CO2_WARNING_LEVEL_PPM)
+                {
+                	text[textpointer++] = '\020';
+                }
+                else if(stateUsed->lifeData.CO2_data.CO2_ppm < CO2_ALARM_LEVEL_PPM)
+                {
+                	text[textpointer++] = '\024';	/* yellow */
+                }
+                else
+                {
+                	text[textpointer++] = '\025'; 	/* red */
+                }
+                snprintf(&text[textpointer],TEXTSIZE,"\001%5ld",stateUsed->lifeData.CO2_data.CO2_ppm);
+                GFX_write_string(&FontT105,tXc1,text,1);
+            }
 
             if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && isLoopMode(pSettings->dive_mode))
             {
@@ -1327,7 +1341,7 @@
         	GFX_write_string(&FontT42,tXc1,text,0);
         }
         snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter));
-        t3_basics_colorscheme_mod(text);
+        Gfx_colorsscheme_mod(text,0);
         if(pSettings->FlipDisplay)
         {
         	if(mode == DIVEMODE_Apnea)
@@ -1354,7 +1368,7 @@
                 snprintf(text,TEXTSIZE,"\020\003\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
             else
                 snprintf(text,TEXTSIZE,"\020\003\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
-            t3_basics_colorscheme_mod(text);
+            Gfx_colorsscheme_mod(text,0);
             GFX_write_string(&FontT105,tXc1,text,0);
         }
         break;
@@ -1363,7 +1377,7 @@
         snprintf(text,TEXTSIZE,"\032\f%c",TXT_ppO2);
         GFX_write_string(&FontT42,tXc1,text,0);
         snprintf(text,TEXTSIZE,"\020\003%01.2f",stateUsed->lifeData.ppO2);
-        t3_basics_colorscheme_mod(text);
+        Gfx_colorsscheme_mod(text,0);
         GFX_write_string(&FontT105,tXc1,text,0);
 
         textpointer = 0;
@@ -1375,7 +1389,7 @@
         text[textpointer++] = '\002';
         tHome_gas_writer(oxygen_percentage,stateUsed->lifeData.actualGas.helium_percentage,&text[textpointer]);
         //textpointer = snprintf(&text[textpointer],TEXTSIZE,"\020\002%02u/%02u",oxygen_percentage, stateUsed->lifeData.actualGas.helium_percentage);
-        t3_basics_colorscheme_mod(text);
+        Gfx_colorsscheme_mod(text,0);
         GFX_write_string(&FontT48,tXc1,text,0);
         break;
 
@@ -1441,7 +1455,7 @@
         	GFX_write_string(&FontT42,tXc1,text,0);
         }
         snprintf(text,TEXTSIZE,"\020\003\016%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter));
-        t3_basics_colorscheme_mod(text);
+        Gfx_colorsscheme_mod(text,0);
         if(pSettings->FlipDisplay)
         {
         	if(mode == DIVEMODE_Apnea)
@@ -1501,6 +1515,7 @@
 {
     char text[256], textMain[256];
     uint8_t textpointer, textpointerMain, lineFree, more;
+    uint8_t index = 0;
 
     snprintf(text,TEXTSIZE,"\025\f%c",TXT_Warning);
     GFX_write_string(&FontT42,&t3c1,text,0);
@@ -1622,7 +1637,19 @@
             more++;
         }
     }
-
+#ifdef HAVE_DEBUG_WARNINGS
+    if(lineFree && stateUsed->warnings.debug)
+    {
+	    for(index=0; index<3; index++)
+	    {
+        	if(((stateUsed->lifeData.extIf_sensor_map[index] == SENSOR_DIGO2M) && (((SSensorDataDiveO2*)(stateUsed->lifeData.extIf_sensor_data[index]))->status & DVO2_FATAL_ERROR)))
+        	{
+        		textpointer += snprintf(&text[textpointer],32,"\001Debug: %lx\n",((SSensorDataDiveO2*)(stateUsed->lifeData.extIf_sensor_data[index]))->status);
+        	}
+	    }
+        lineFree--;
+    }
+#endif
     text[textpointer] = 0;
     textMain[textpointerMain] = 0;
 
@@ -1655,7 +1682,7 @@
          i++;
     }
 
-    if (((view == CVIEW_sensors) || (view == CVIEW_sensors_mV)) &&
+    if ((view == CVIEW_T3_sensors) &&
        	((stateUsed->diveSettings.ppo2sensors_deactivated == 0x07) || (stateUsed->diveSettings.ccrOption == 0) || stateUsed->warnings.fallback))
     {
       	cv_disabled = 1;
@@ -1667,7 +1694,7 @@
 uint8_t t3_change_customview(uint8_t action)
 {
 
-    t3_basics_change_customview(&t3_selection_customview, t3_customviewsStandard, action);
+    t3_basics_change_customview(&t3_selection_customview, cv_changelist_BS, action);
     return t3_selection_customview;
 }
 
@@ -1688,6 +1715,7 @@
     	if (tX_customviews[index] == *tX_selection_customview)
     	{
     		curViewIdx = index;
+    		break;
     	}
     	index++;
     }
@@ -1731,7 +1759,7 @@
     			break;
 		}
 
-		if(t3_customview_disabled(tX_customviews[index]))
+		if((tX_customviews == cv_changelist_BS) && (t3_customview_disabled(tX_customviews[index])))
 		{
 			iterate = 1;
 			if(*tX_selection_customview == tX_customviews[index])
@@ -1788,16 +1816,6 @@
     }
 }
 
-
-void t3_basics_colorscheme_mod(char *text)
-{
-    if((text[0] == '\020') && !GFX_is_colorschemeDiveStandard())
-    {
-        text[0] = '\027';
-    }
-}
-
-
 point_t t3_compass_circle(uint8_t id, uint16_t degree, point_t center)
 {
     float fCos, fSin;
@@ -1931,7 +1949,7 @@
 	uint8_t increment = 1;
     uint8_t enabledViewCnt = 0;
 
-    pViews = (uint8_t*)t3_customviewsStandard;
+    pViews = (uint8_t*)cv_changelist_BS;
     while((*pViews != CVIEW_T3_END))
     {
     	increment = 1;
@@ -1967,3 +1985,143 @@
         return snprintf(text, size, "%c%u\016\016%%\017", colour, currentTimerMinutes * 100 / settingsGetPointer()->scrubberData[settings->scubberActiveId].TimerMax);
     }
 }
+
+void t3_AF_updateBorderConditions()
+{
+	uint16_t 	nextstopLengthSeconds = 0;
+	uint8_t 	nextstopDepthMeter = 0;
+
+	tHome_findNextStop(getDecoInfo()->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds);
+	AF_lastDecoDepth = nextstopDepthMeter;
+	AF_lastTTS = (getDecoInfo()->output_time_to_surface_seconds / 60) / 10;
+}
+
+uint8_t t3_CheckAfCondition(uint8_t T3CView)
+{
+	uint8_t retVal = 0;
+
+	float pitch = stateRealGetPointer()->lifeData.compass_pitch;
+	float roll = stateRealGetPointer()->lifeData.compass_roll;
+
+    uint16_t 	nextstopLengthSeconds = 0;
+    uint8_t 	nextstopDepthMeter = 0;
+
+	switch (T3CView)
+	{
+		case  CVIEW_T3_GasList: retVal = (stateUsed->warnings.betterGas) /* switch if better gas is available or depending on ppo2 if in OC mode */
+										|| ((stateUsed->diveSettings.diveMode == DIVEMODE_OC) && ((stateUsed->warnings.ppO2Low) || (stateUsed->warnings.ppO2High)));
+
+			break;
+		case CVIEW_T3_Navigation: retVal = (pitch > -AF_COMPASS_ACTIVATION_ANGLE) && (pitch < AF_COMPASS_ACTIVATION_ANGLE)
+											&& (roll > -AF_COMPASS_ACTIVATION_ANGLE) && (roll < AF_COMPASS_ACTIVATION_ANGLE);
+
+			break;
+		case CVIEW_T3_DecoTTS:		tHome_findNextStop(getDecoInfo()->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds);
+								/* A new deco step is added to the plan */
+									if(nextstopDepthMeter > AF_lastDecoDepth)
+									{
+										retVal = 1;
+									}
+
+								/* Close to the next deco step or missed deco step */
+									if((abs(stateUsed->lifeData.depth_meter - nextstopDepthMeter) < 2) || (stateUsed->warnings.decoMissed))
+									{
+										retVal = 1;
+									}
+								/* Another 10 minutes to surface */
+									if((getDecoInfo()->output_time_to_surface_seconds) && ((uint16_t)((getDecoInfo()->output_time_to_surface_seconds / 60) / 10) > AF_lastTTS))
+									{
+										retVal = 1;
+									}
+			break;
+		default: break;
+	}
+
+	return retVal;
+}
+
+uint8_t t3_EvaluateAFCondition(uint8_t T3CView)
+{
+	static uint8_t debounce[CVIEW_T3_END];
+	static uint8_t lastState[CVIEW_T3_END];
+	uint8_t detectionState = AF_VIEW_NOCHANGE;
+	uint8_t cnt = 0;
+
+	if(T3CView <= CVIEW_T3_END)
+	{
+		if(T3CView == CVIEW_T3_END)
+		{
+			for(cnt = 0; cnt < CVIEW_T3_END; cnt++)
+			{
+				debounce[cnt] = 0;
+				lastState[cnt] = AF_VIEW_NOCHANGE;
+			}
+		}
+		if(t3_CheckAfCondition(T3CView))
+		{
+			if(debounce[T3CView] < 10)
+			{
+				debounce[T3CView]++;
+			}
+			else
+			{
+				detectionState = AF_VIEW_ACTIVATED;
+			}
+		}
+		else
+		{
+			if(debounce[T3CView] > 0)
+			{
+				debounce[T3CView]--;
+			}
+			else
+			{
+				detectionState = AF_VIEW_DEACTIVATED;
+			}
+		}
+		if(detectionState)	/* no state change => return 0 */
+		{
+			if((detectionState == lastState[T3CView]))
+			{
+				detectionState = AF_VIEW_NOCHANGE;
+			}
+			else
+			{
+				lastState[T3CView] = detectionState;
+			}
+		}
+	}
+	return detectionState;
+}
+
+void t3_handleAutofocus(void)
+{
+	static uint8_t returnView = CVIEW_T3_END;
+
+	uint8_t runningT3CView = 0;
+
+	for (runningT3CView = 0; runningT3CView < CVIEW_T3_END; runningT3CView++)
+	{
+		if(stateUsed->diveSettings.activeAFViews & (1 << runningT3CView))
+		{
+			switch(t3_EvaluateAFCondition(runningT3CView))
+			{
+				case AF_VIEW_ACTIVATED:	returnView = t3_selection_customview;
+										t3_select_customview(runningT3CView);
+										t3_AF_updateBorderConditions();
+					break;
+				case AF_VIEW_DEACTIVATED: if((returnView != CVIEW_T3_END) && (t3_selection_customview == runningT3CView))
+											{
+												if(runningT3CView != CVIEW_T3_DecoTTS)	/* some view does not switch back */
+												{
+													t3_select_customview(returnView);
+												}
+												returnView = CVIEW_T3_END;
+											}
+							break;
+						default:
+							break;
+			}
+		}
+	}
+}
--- a/Discovery/Src/t4_tetris.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/t4_tetris.c	Wed Aug 14 16:44:46 2024 +0200
@@ -36,6 +36,7 @@
 #include "tHome.h"
 #include "timer.h"
 #include "unit.h"
+#include "gfx_engine.h"
 
 /* Exported variables --------------------------------------------------------*/
 
@@ -152,7 +153,7 @@
     else
         snprintf(text,TEXTSIZE,"\020%01.0f",depth);
 
-    t3_basics_colorscheme_mod(text);
+    Gfx_colorsscheme_mod(text,0);
     GFX_write_string(&FontT144,&t4l1,text,1);
 
     // divetime
@@ -186,7 +187,7 @@
         snprintf(text,TEXTSIZE,"\020\016%u:%02u",Divetime.Minutes, Divetime.Seconds);
     else
         snprintf(text,TEXTSIZE,"\020\016%u'",Divetime.Minutes);
-    t3_basics_colorscheme_mod(text);
+    Gfx_colorsscheme_mod(text,0);
     GFX_write_string(&FontT105,&t4l2,text,1);
 }
 
--- a/Discovery/Src/t5_gauge.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/t5_gauge.c	Wed Aug 14 16:44:46 2024 +0200
@@ -63,8 +63,8 @@
 
 const uint8_t t5_customviewsStandard[] =
 {
-    CVIEW_sensors,
-    CVIEW_Compass,
+	CVIEW_T3_sensors,
+    CVIEW_T3_Compass,
     CVIEW_T3_MaxDepth,
     CVIEW_T3_StopWatch,
     CVIEW_T3_Temperature,
--- a/Discovery/Src/t6_apnea.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/t6_apnea.c	Wed Aug 14 16:44:46 2024 +0200
@@ -46,7 +46,7 @@
 GFX_DrawCfgWindow	t6c2;
 GFX_DrawCfgWindow	t6c3; // for menu text
 
-uint8_t t6_selection_customview = 0;
+uint8_t t6_selection_customview = CVIEW_T3_noneOrDebug;
 
 /* Imported function prototypes ---------------------------------------------*/
 
@@ -61,7 +61,7 @@
 
 const uint8_t t6_customviewsStandard[] =
 {
-    CVIEW_noneOrDebug,
+	CVIEW_T3_noneOrDebug,
     CVIEW_T3_Temperature,
     CVIEW_T3_END
 };
--- a/Discovery/Src/t7.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/t7.c	Wed Aug 14 16:44:46 2024 +0200
@@ -33,6 +33,7 @@
 #include "t3.h"
 #include "settings.h"
 #include "data_exchange_main.h"
+#include "data_central.h"
 #include "decom.h"
 #include "gfx_fonts.h"
 #include "logbook_miniLive.h"
@@ -69,7 +70,6 @@
 void t7_miniLiveLogProfile(void);
 void t7_logo_OSTC(void);
 void t7_ChargerView(void);
-static void t7_colorscheme_mod(char *text);
 
 uint8_t t7_test_customview_warnings(void);
 void t7_show_customview_warnings(void);
@@ -120,22 +120,6 @@
 
 
 /* Private types -------------------------------------------------------------*/
-const uint8_t customviewsDiveStandard[] =
-{
-    CVIEW_sensors,
-    CVIEW_Compass,
-    CVIEW_Decolist,
-    CVIEW_Tissues,
-    CVIEW_Profile,
-    CVIEW_Gaslist,
-    CVIEW_sensors_mV,
-    CVIEW_EADTime,
-    CVIEW_SummaryOfLeftCorner,
-    CVIEW_Timer,
-    CVIEW_noneOrDebug,
-    CVIEW_END,
-    CVIEW_END
-};
 
 const uint8_t customviewsSurfaceStandard[] =
 {
@@ -155,7 +139,7 @@
 
 static uint8_t selection_custom_field = LLC_Temperature;
 
-const uint8_t *customviewsDive		= customviewsDiveStandard;
+const uint8_t *customviewsDive		= cv_changelist;
 const uint8_t *customviewsSurface	= customviewsSurfaceStandard;
 
 #define TEXTSIZE 30
@@ -580,42 +564,7 @@
 
     if(stateUsed->mode == MODE_DIVE)
     {
-        if(last_mode != MODE_DIVE)
-        {
-            last_mode = MODE_DIVE;
-            /* lower left corner primary */
-            selection_custom_field = settingsGetPointer()->tX_userselectedLeftLowerCornerPrimary;
-            /* custom view primary OR debug if automatic return is off | T7 is default dive view => also initialize big font view */
-            if((settingsGetPointer()->tX_customViewTimeout == 0) && (settingsGetPointer()->showDebugInfo))
-            {
-            	selection_customview = CVIEW_noneOrDebug;
-            	t3_select_customview(CVIEW_noneOrDebug);
-            }
-            else
-            {
-                selection_customview = settingsGetPointer()->tX_customViewPrimary;
-                t3_set_customview_to_primary();
-            }
-            t7_change_customview(ACTION_END);
-
-            if((settingsGetPointer()->MotionDetection != MOTION_DETECT_OFF))
-            {
-            	InitMotionDetection();
-            }
-
-            if(settingsGetPointer()->extraDisplay == EXTRADISPLAY_BFACTIVE)
-            {
-                settingsGetPointer()->design = 3;
-                releaseAllFramesExcept(22,t7screen.FBStartAdress);
-                releaseFrame(22,t7screen.FBStartAdress);
-                set_globalState(StD);
-                return;
-            }
-        }
-
-        if(status.page == PageSurface)
-            set_globalState(StD);
-
+    	/* T7 refresh is usally called at start of dive. Based on divesettings the design will be changed and T7 no longer called */
         if(stateUsed->diveSettings.diveMode == DIVEMODE_Gauge)
         {
             settingsGetPointer()->design = 5;
@@ -632,8 +581,44 @@
         }
         else
         {
-            t7_refresh_divemode();
-        }
+			if(last_mode != MODE_DIVE)
+			{
+				last_mode = MODE_DIVE;
+				/* lower left corner primary */
+				selection_custom_field = settingsGetPointer()->tX_userselectedLeftLowerCornerPrimary;
+				/* custom view primary OR debug if automatic return is off | T7 is default dive view => also initialize big font view */
+				if((settingsGetPointer()->tX_customViewTimeout == 0) && (settingsGetPointer()->showDebugInfo))
+				{
+					selection_customview = CVIEW_noneOrDebug;
+					t3_select_customview(CVIEW_noneOrDebug);
+				}
+				else
+				{
+					selection_customview = settingsGetPointer()->tX_customViewPrimary;
+				}
+				t7_change_customview(ACTION_END);
+
+				if((settingsGetPointer()->MotionDetection != MOTION_DETECT_OFF))
+				{
+					InitMotionDetection();
+				}
+
+				if((settingsGetPointer()->extraDisplay == EXTRADISPLAY_BFACTIVE) && ( settingsGetPointer()->design == 7))
+				{
+					settingsGetPointer()->design = 3;
+					t3_set_customview_to_primary();
+					releaseAllFramesExcept(22,t7screen.FBStartAdress);
+					releaseFrame(22,t7screen.FBStartAdress);
+					set_globalState(StD);
+					return;
+				}
+			}
+
+			if(status.page == PageSurface)
+				set_globalState(StD);
+
+			t7_refresh_divemode();
+       }
     }
     else // from if(stateUsed->mode == MODE_DIVE)
     {
@@ -1434,6 +1419,9 @@
     	count++;
     }
 #endif
+#ifdef HAVE_DEBUG_WARNINGS
+    count += stateUsed->warnings.debug;
+#endif
     return count;
 }
 
@@ -1505,6 +1493,7 @@
 {
     char text[256];
     uint8_t textpointer, lineFree;
+    uint8_t index = 0;
 
     text[0] = '\025';
     text[1] = '\f';
@@ -1591,6 +1580,19 @@
         lineFree--;
     }
 #endif
+#ifdef HAVE_DEBUG_WARNINGS
+    if(lineFree && stateUsed->warnings.debug)
+    {
+	    for(index=0; index<3; index++)
+	    {
+        	if(((stateUsed->lifeData.extIf_sensor_map[index] == SENSOR_DIGO2M) && (((SSensorDataDiveO2*)(stateUsed->lifeData.extIf_sensor_data[index]))->status & DVO2_FATAL_ERROR)))
+        	{
+        		textpointer += snprintf(&text[textpointer],32,"\001Debug: %lx\n",((SSensorDataDiveO2*)(stateUsed->lifeData.extIf_sensor_data[index]))->status);
+        	}
+	    }
+        lineFree--;
+    }
+#endif
 /*
     if(lineFree && stateUsed->warnings.lowBattery)
     {
@@ -1977,7 +1979,7 @@
         t7cY0free.WindowX1 += 10;
     }
 
-    t7_colorscheme_mod(data);
+    Gfx_colorsscheme_mod(data, 0);
 
     GFX_write_string(&FontT42, &t7cY0free, data, 1);
 }
@@ -2131,11 +2133,11 @@
         t7cY0free.WindowX1 += 10;
     }
 
-    t7_colorscheme_mod(data);
+    Gfx_colorsscheme_mod(data, 0);
 
     GFX_write_string(&FontT42, &t7cY0free, data, 1);
 
-    t7_colorscheme_mod(timer);
+    Gfx_colorsscheme_mod(timer, 0);
 
     GFX_write_string(&FontT105, &t7cY0free, timer, 4);
 }
@@ -2760,6 +2762,10 @@
         snprintf(TextL1,TEXTSIZE,"\032\f[feet]");
     else
         snprintf(TextL1,TEXTSIZE,"\032\f%c",TXT_Depth);
+
+    color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min);
+
+
     GFX_write_string(&FontT24,&t7l1,TextL1,0);
 
     if((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10))
@@ -2777,8 +2783,11 @@
     else
         snprintf(TextL1,TEXTSIZE,"\020%01.0f",depth);
 
-    t7_colorscheme_mod(TextL1);
-    GFX_write_string(&FontT144,&t7l1,TextL1,1);
+    Gfx_colorsscheme_mod(TextL1, color);
+
+
+
+    GFX_write_string(&FontT144,&t7l1,TextL1,0);
 
     /* max depth */
     snprintf(TextL2,TEXTSIZE,"\032\f%c",TXT_MaxDepth);
@@ -2789,7 +2798,7 @@
     else
         snprintf(TextL2,TEXTSIZE,"\020%01.0f",unit_depth_float(stateUsed->lifeData.max_depth_meter));
 
-    t7_colorscheme_mod(TextL2);
+    Gfx_colorsscheme_mod(TextL2, 0);
     GFX_write_string(&FontT105,&t7l2,TextL2,1);
 
     /* ascent rate graph */
@@ -2831,13 +2840,10 @@
         if(stop.y >= 470)
             stop.y = 470;
         start.y += 7; // starte etwas weiter oben
-        if(stateUsed->lifeData.ascent_rate_meter_per_min <= 10)
-            color = CLUT_EverythingOkayGreen;
-        else
-        if(stateUsed->lifeData.ascent_rate_meter_per_min <= 15)
-            color = CLUT_WarningYellow;
-        else
-            color = CLUT_WarningRed;
+        if(color == 0)
+        {
+        	color = CLUT_EverythingOkayGreen; /* do not use white color for drawing graph */
+        }
 
         GFX_draw_thick_line(12,&t7screen, start, stop, color);
     }
@@ -2859,7 +2865,7 @@
         snprintf(TextR1,TEXTSIZE,"\020\002\016%u:%02u",Divetime.Minutes, Divetime.Seconds);
     else
         snprintf(TextR1,TEXTSIZE,"\020\002\016%u'",Divetime.Minutes);
-    t7_colorscheme_mod(TextR1);
+    Gfx_colorsscheme_mod(TextR1, 0);
     GFX_write_string(&FontT105,&t7r1,TextR1,1);
 
     /* next deco stop */
@@ -2872,7 +2878,7 @@
             , unit_depth_char1_T105()
             , unit_depth_char2_T105()
             , (nextstopLengthSeconds+59)/60);
-        t7_colorscheme_mod(TextR2);
+        Gfx_colorsscheme_mod(TextR2, 0);
         if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS)
             TextR2[0] = '\031';
         if(textlength <= 9)
@@ -2887,7 +2893,7 @@
         snprintf(TextR2,TEXTSIZE,"\032\f\002%c%c",TXT_2BYTE,TXT2BYTE_SafetyStop2);
         GFX_write_string(&FontT42,&t7r2,TextR2,0);
         snprintf(TextR2,TEXTSIZE,"\020\002\016%u:%02u",SafetyStopTime.Minutes,SafetyStopTime.Seconds);
-        t7_colorscheme_mod(TextR2);
+        Gfx_colorsscheme_mod(TextR2, 0);
         GFX_write_string(&FontT105,&t7r2,TextR2,1);
     }
 
@@ -2902,7 +2908,7 @@
             snprintf(TextR3,TEXTSIZE,"\020\002%i'",(pDecoinfo->output_time_to_surface_seconds + 59)/ 60);
         else
             snprintf(TextR3,TEXTSIZE,"\020\002%ih",(pDecoinfo->output_time_to_surface_seconds + 59)/ 3600);
-        t7_colorscheme_mod(TextR3);
+        Gfx_colorsscheme_mod(TextR3, 0);
         if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS)
             TextR2[0] = '\031';
         GFX_write_string(&FontT105,&t7r3,TextR3,1);
@@ -2915,7 +2921,7 @@
             snprintf(TextR3,TEXTSIZE,"\020\002%i'",pDecoinfo->output_ndl_seconds/60);
         else
             snprintf(TextR3,TEXTSIZE,"\020\002%ih",pDecoinfo->output_ndl_seconds/3600);
-        t7_colorscheme_mod(TextR3);
+        Gfx_colorsscheme_mod(TextR3, 0);
         if(time_elapsed_ms(pDecoinfo->tickstamp, HAL_GetTick()) > MAX_AGE_DECOINFO_MS)
             TextR2[0] = '\031';
         GFX_write_string(&FontT105,&t7r3,TextR3,1);
@@ -3061,7 +3067,7 @@
         }
         else
         {
-            t7_colorscheme_mod(TextC2);
+            Gfx_colorsscheme_mod(TextC2, 0);
             GFX_write_string(&FontT48,&t7c2,TextC2,0); // T54 has only numbers
         }
 
@@ -3078,7 +3084,7 @@
                 }
                 else
                 {
-                    t7_colorscheme_mod(TextC2);
+                    Gfx_colorsscheme_mod(TextC2, 0);
                     GFX_write_string(&FontT48,&t7c2,TextC2,0);
                 }
             }
@@ -3086,7 +3092,7 @@
         else if(settingsGetPointer()->alwaysShowPPO2)
         {
             snprintf(TextC2,TEXTSIZE,"\020%01.2f",stateUsed->lifeData.ppO2);
-            t7_colorscheme_mod(TextC2);
+            Gfx_colorsscheme_mod(TextC2, 0);
             GFX_write_string(&FontT48,&t7c2,TextC2,0);
         }
     }
@@ -3173,13 +3179,13 @@
     }
     else
     {
-        t7_colorscheme_mod(TextC1);
+        Gfx_colorsscheme_mod(TextC1, 0);
         GFX_write_string(&Batt24,&t7batt,TextC1,0);
 
         if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->lifeData.battery_charge < 140))
         {
             snprintf(TextC1,16,"\020\f\002%u%%",(uint8_t)stateUsed->lifeData.battery_charge);
-            t7_colorscheme_mod(TextC1);
+            Gfx_colorsscheme_mod(TextC1, 0);
             GFX_write_string(&FontT24,&t7voltage,TextC1,0); // t7batt
         }
     }
@@ -3227,6 +3233,14 @@
     	selection_custom_field++;
     }
 #endif
+#ifdef ENABLE_CO2_SUPPORT
+    if((selection_custom_field == LCC_CO2) && (settingsGetPointer()->co2_sensor_active == 0))
+    {
+       	selection_custom_field++;
+    }
+
+#endif
+
     if(selection_custom_field >= LLC_END)
     {
         selection_custom_field = LLC_Empty;
@@ -3483,7 +3497,7 @@
     else
         GFX_write_string(&FontT42,&t7l3,headerText,0);
 
-    t7_colorscheme_mod(text);
+    Gfx_colorsscheme_mod(text, 0);
 #ifndef ENABLE_BOTTLE_SENSOR
 #ifdef ENABLE_CO2_SUPPORT
     if(selection_custom_field != LCC_CO2)
@@ -3606,15 +3620,6 @@
     return lineCount;
 }
 
-static void t7_colorscheme_mod(char *text) {
-	char *p = text;
-	while (*p) {
-		if ((*p == '\020') && !GFX_is_colorschemeDiveStandard())
-			*p = '\027';
-		p++;
-	}
-}
-
 void draw_frame(_Bool PluginBoxHeader, _Bool LinesOnTheSides, uint8_t colorBox, uint8_t colorLinesOnTheSide)
 {
     point_t LeftLow, WidthHeight;
@@ -4113,7 +4118,7 @@
         textpointer += printScrubberText(&text[textpointer], 10, pSettings);
     }
     text[textpointer++] = 0;
-    t7_colorscheme_mod(text);
+    Gfx_colorsscheme_mod(text, 0);
     GFX_write_string(&FontT42, &t7cY0free, text, 1);
 }
 
@@ -4495,6 +4500,10 @@
 	{
 		level = 10;
 	}
+	if(curIndex > 1)
+	{
+		level = (level + ChargerLog[curIndex - 1]) / 2; /* smooth small jumps */
+	}
 	if(curIndex < 59)
 	{
 		ChargerLog[curIndex++] = level;
@@ -4504,7 +4513,7 @@
 		memcpy (&ChargerLog[0],&ChargerLog[1],sizeof(ChargerLog) - 1);
 		ChargerLog[curIndex] = level;
 	}
-	if(curIndex > 1)
+	if(curIndex > 1)	/* estimate time til charging is complete */
 	{
 		averageSpeed = ((averageSpeed * (curIndex-1)) + charge) / curIndex;
 		completeSec = (100.0 - stateUsed->lifeData.battery_charge) / averageSpeed;
@@ -4561,30 +4570,28 @@
 
     if(stateUsed->chargeStatus != CHARGER_off)
     {
-		if(lastCharge != localCharge)
-		{
-			curTick = HAL_GetTick();
-			deltatime = (curTick - lastTick);
-			lastTick = curTick;
-			if(lastCharge < localCharge)
+		curTick = HAL_GetTick();
+		deltatime = (curTick - lastTick);
+
+		if((deltatime > 3000) || (lastCharge != localCharge))	/* Charge value update is expected every 2 second. */
+		{														/* Added timeout to keep graph moving in case charger is temporary idle */
+			if(lastCharge != localCharge)
 			{
-				speed = (localCharge - lastCharge) * 1000.0 / deltatime;
+				if(lastCharge < localCharge)
+				{
+					speed = (localCharge - lastCharge) * 1000.0 / deltatime;
+				}
+
+				if(localCharge > 100.0)
+				{
+					localCharge = 100.0;
+				}
+				lastCharge = localCharge;
 			}
-
-			if(localCharge > 100.0)
-			{
-				localCharge = 100.0;
-			}
-
-			lastCharge = localCharge;
-		}
-
-
-		if(deltatime > 1000)
-		{
 			deltatime = 0;
 			remainingSec = LogDeltaCharge(speed);
 			speed = 0;
+			lastTick = curTick;
 		}
     }
     textpointer += snprintf(&text[textpointer],50,"\n\r");
--- a/Discovery/Src/tComm.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tComm.c	Wed Aug 14 16:44:46 2024 +0200
@@ -79,6 +79,7 @@
 #else
 #	include "base_bootloader.h"
 #	include "firmwareEraseProgram.h"
+#	include "text_multilanguage.h"
 #endif
 
 #ifdef SPECIALPROGRAMM
@@ -110,7 +111,7 @@
 #define UART_TIMEOUT_SECONDS		(120u)		/* Timeout for keeping connection open and waiting for data */
 #define UART_TIMEOUT_LARGE_BLOCK 	(6000u)		/* Timeout (ms) for reception of an 16K data block (typical RX time ~4,5seconds) */
 
-#define UART_CMD_BUF_SIZE			(20u)		/* size of buffer for command exchange */
+#define UART_CMD_BUF_SIZE			(30u)		/* size of buffer for command exchange */
 
 const uint8_t id_Region1_firmware = 0xFF;
 const uint8_t id_RTE = 0xFE;
@@ -119,9 +120,11 @@
 
 static BlueModTmpConfig_t BmTmpConfig = BM_CONFIG_OFF;	/* Config BlueMod without storing the changes */
 static uint8_t EvaluateBluetoothSignalStrength = 0;
+#ifndef BOOTLOADER_STANDALONE
 static uint8_t RequestDisconnection = 0; 				/* Disconnection from remote device requested */
+static void tComm_Disconnect(void);
+#endif
 /* Private function prototypes -----------------------------------------------*/
-static void tComm_Disconnect(void);
 static void tComm_Error_Handler(void);
 static uint8_t select_mode(uint8_t aRxByte);
 static uint8_t tComm_CheckAnswerOK(void);
@@ -367,6 +370,13 @@
                 hardware_programmPrimaryBluetoothNameSet();
 #endif
     }
+    else	/* no serial set at all => do default configuration of the module */
+    {
+#define NINAB22103B00
+#ifdef NINAB22103B00
+    	answer = 0xFF;
+#endif
+    }
     return answer;
 }
 
@@ -436,7 +446,7 @@
     answer = HAL_OK;
     return answer;
 }
-
+#ifndef BOOTLOADER_STANDALONE
 void tComm_Disconnect()
 {
 	uint8_t answer;
@@ -482,7 +492,7 @@
 		MX_Bluetooth_PowerOff();
 	}
 }
-
+#endif
 
 uint8_t openComm(uint8_t aRxByte)
 {
@@ -586,6 +596,8 @@
     SSettings* pSettings = settingsGetPointer();
     RTC_DateTypeDef sdatestructure;
     RTC_TimeTypeDef stimestructure;
+    uint16_t index;
+    uint32_t header_profileLength, OSTC3_profileLength;
 #else
     uint8_t dummyForBootloader[256] = {0};
 #endif
@@ -593,8 +605,6 @@
     uint8_t aTxBuffer[128];
     uint8_t aRxBuffer[68];
     uint8_t answer;
-    uint16_t index;
-    uint32_t header_profileLength, OSTC3_profileLength;
     aTxBuffer[0] = type;
     aTxBuffer[1] = prompt4D4C(receiveStartByteUart);
     uint8_t tempHigh, tempLow;
@@ -1451,9 +1461,9 @@
     {
         return 0;
     }
-    uint32_t checksum = 256  * 256 * 256 *(uint32_t)sBuffer[0] + 256 * 256 *  (uint32_t)sBuffer[1] + 256 *  (uint32_t)sBuffer[2] + sBuffer[3];
+    checksum = 256  * 256 * 256 *(uint32_t)sBuffer[0] + 256 * 256 *  (uint32_t)sBuffer[1] + 256 *  (uint32_t)sBuffer[2] + sBuffer[3];
 //  uint32_t checksumCalc = crc32c_checksum(pBuffer, length,0,0);
-    uint32_t checksumCalc = CRC_CalcBlockCRC((uint32_t*)pBuffer, length/4);
+    checksumCalc = CRC_CalcBlockCRC((uint32_t*)pBuffer, length/4);
 
     if(checksum !=  checksumCalc)
     {
@@ -2138,6 +2148,13 @@
     }
 }
 
+#ifdef BOOTLOADER_STANDALONE
+void tComm_StartBlueModBaseInit()
+{
+	BmTmpConfig = BM_INIT_TRIGGER_ON;
+}
+#endif
+
 void tComm_StartBlueModConfig()
 {
 	uint8_t answer = HAL_OK;
@@ -2189,6 +2206,39 @@
 			ConfigRetryCnt = 0;
 			RestartModule = 1;
 			break;
+#ifdef BOOTLOADER_STANDALONE
+		case BM_INIT_TRIGGER_ON:	HAL_Delay(2000);
+									HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_RESET);
+									BmTmpConfig++;
+								break;
+		case BM_INIT_TRIGGER_OFF:	HAL_Delay(1);
+									HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_SET);
+									HAL_Delay(2000);
+									BmTmpConfig++;
+								break;
+		case BM_INIT_FACTORY:		sprintf(TxBuffer,"AT+UFACTORY\r");      /*Set to factory defined configuration */
+								break;
+		case BM_INIT_MODE:			sprintf(TxBuffer,"AT+UMSM=1\r");        /* start in Data mode */
+								break;
+		case BM_INIT_BLE:			sprintf(TxBuffer,"AT+UBTLE=2\r"); 		/* Bluetooth low energy Peripheral */
+								break;
+		case BM_INIT_NAME:			sprintf(TxBuffer,"AT+UBTLN=OSTC4-12345\r"); /* Bluetooth name */
+								break;
+		case BM_INIT_SSP_IDO_OFF:	sprintf(TxBuffer,"AT+UDSC=0,0\r");    /* Disable SPP Server on ID0 */
+								break;
+		case BM_INIT_SSP_IDO_ON:	sprintf(TxBuffer,"AT+UDSC=0,3\r"); 	  /* SPP Server on ID0 */
+								break;
+		case BM_INIT_SSP_ID1_OFF:	sprintf(TxBuffer,"AT+UDSC=1,0\r");    /* Disable SPS Server on ID1 */
+								break;
+		case BM_INIT_SSP_ID1_ON:	sprintf(TxBuffer,"AT+UDSC=1,6\r");	  /* SPS Server on ID1 */
+								break;
+		case BM_INIT_STORE:			sprintf(TxBuffer,"AT&W\r");	          /* write settings into eeprom */
+								break;
+		case BM_INIT_RESTART:		sprintf(TxBuffer,"AT+CPWROFF\r");	  /* reboot module */
+								break;
+		case BM_INIT_DONE:			BmTmpConfig = BM_CONFIG_ECHO;
+								break;
+#endif
 		default:
 			break;
 	}
--- a/Discovery/Src/tHome.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tHome.c	Wed Aug 14 16:44:46 2024 +0200
@@ -65,6 +65,7 @@
 #ifdef ENABLE_T3_PROFILE_VIEW
 									CVIEW_T3_Profile,
 #endif
+									CVIEW_T3_Temperature,
 									CVIEW_T3_END};
 
 /* Private function prototypes -----------------------------------------------*/
@@ -78,10 +79,6 @@
 {
     if(stateUsed->mode == MODE_DIVE)
     {
-    	if(settingsGetPointer()->extraDisplay == EXTRADISPLAY_BFACTIVE)
-    	{
-    		settingsGetPointer()->design = 3;
-    	}
         set_globalState(StD);
     }
     else
@@ -236,6 +233,10 @@
             								{
                         						set_globalState(StDMGAS);
             								}
+            								else
+            								{
+            									set_globalState(StDMENU);
+            								}
             			break;
 #ifdef ENABLE_T3_PPO_SIM
             		case CVIEW_sensors:		if(is_stateUsedSetToSim())
--- a/Discovery/Src/tInfo.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tInfo.c	Wed Aug 14 16:44:46 2024 +0200
@@ -37,6 +37,7 @@
 //#include "tInfoSurface.h"
 #include "tInfoCompass.h"
 #include "tInfoSensor.h"
+#include "tInfoPreDive.h"
 #include "tMenu.h"
 #include "tMenuEdit.h"
 
@@ -222,6 +223,11 @@
     							infoColor = CLUT_MenuPageHardware;
     							refreshInfo_Sensor(tIscreen);
     				break;
+    		case StIPREDIVE: 	tIscreen.FBStartAdress = getFrame(14);
+    							infoColor = CLUT_MenuPageGasCC;
+    							refreshInfo_PreDive(tIscreen);
+    				break;
+
     		default:
     				break;
     	}
@@ -306,13 +312,25 @@
     hgfx.WindowNumberOfTextLines = 1;
     hgfx.WindowLineSpacing = 0;
     hgfx.WindowTab = 400;
-    hgfx.WindowX0 = XleftGimpStyle;
-    hgfx.WindowX1 = XrightGimpStyle;
-    hgfx.WindowY1 = 479 - YtopGimpStyle;
-    if(hgfx.WindowY1 < Font->height)
-        hgfx.WindowY0 = 0;
+
+    if(!settingsGetPointer()->FlipDisplay)
+    {
+        hgfx.WindowX0 = XleftGimpStyle;
+        hgfx.WindowX1 = XrightGimpStyle;
+
+    	hgfx.WindowY1 = 479 - YtopGimpStyle;
+    	if(hgfx.WindowY1 < Font->height)
+    	        hgfx.WindowY0 = 0;
+    	    else
+    	        hgfx.WindowY0 = hgfx.WindowY1 - Font->height;
+    }
     else
-        hgfx.WindowY0 = hgfx.WindowY1 - Font->height;
+    {
+		hgfx.WindowX0 = 800 - XrightGimpStyle;
+		hgfx.WindowX1 = 800 - XleftGimpStyle;
+    	hgfx.WindowY0 = YtopGimpStyle;
+    	hgfx.WindowY1 = YtopGimpStyle + Font->height;
+    }
 
     GFX_write_string_color(Font, &hgfx, text, 0, color);
 }
@@ -808,3 +826,33 @@
         write_content_simple(screenPtr, 0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
     }
 }
+void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode)
+{
+    char localtext[32];
+
+    if(left2ByteCode)
+    {
+        localtext[0] = TXT_2BYTE;
+        localtext[1] = left2ByteCode;
+        localtext[2] = 0;
+        tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
+    }
+
+    if(middle2ByteCode)
+    {
+        localtext[0] = '\001';
+        localtext[1] = TXT_2BYTE;
+        localtext[2] = middle2ByteCode;
+        localtext[3] = 0;
+        tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
+    }
+
+    if(right2ByteCode)
+    {
+        localtext[0] = '\002';
+        localtext[1] = TXT_2BYTE;
+        localtext[2] = right2ByteCode;
+        localtext[3] = 0;
+        tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Discovery/Src/tInfoPreDive.c	Wed Aug 14 16:44:46 2024 +0200
@@ -0,0 +1,245 @@
+///////////////////////////////////////////////////////////////////////////////
+/// -*- coding: UTF-8 -*-
+///
+/// \file   Discovery/Src/tInfoPredive.c
+/// \brief  Show information which might be of interest during predive checks
+/// \author heinrichs weikamp gmbh
+/// \date   23-Feb-2015
+///
+/// \details
+///
+/// $Id$
+///////////////////////////////////////////////////////////////////////////////
+/// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
+///
+///     This program is free software: you can redistribute it and/or modify
+///     it under the terms of the GNU General Public License as published by
+///     the Free Software Foundation, either version 3 of the License, or
+///     (at your option) any later version.
+///
+///     This program is distributed in the hope that it will be useful,
+///     but WITHOUT ANY WARRANTY; without even the implied warranty of
+///     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+///     GNU General Public License for more details.
+///
+///     You should have received a copy of the GNU General Public License
+///     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//////////////////////////////////////////////////////////////////////////////
+
+/* Includes ------------------------------------------------------------------*/
+
+#include "gfx_engine.h"
+#include "gfx_fonts.h"
+#include "tHome.h"
+#include "tInfo.h"
+#include "tInfoPreDive.h"
+#include "tMenuEdit.h"
+#include "data_exchange_main.h"
+
+#include <string.h>
+#include <inttypes.h>
+
+#define MEASURE_INTERVALL		(10u)	/* refresh function should be called every 100ms => one second interval */
+#define HISTORY_BUF_SIZE 		(240u)	/* store 240 entries a one second */
+#define INVALID_PRESSURE_VALUE	(0xFFFF)
+#define DELTA_SHIFT				(50)	/* the graph printers do not support negative values => shift data into positiv area (assumes pressure range +- 300mBar) */
+
+/* Private variables ---------------------------------------------------------*/
+static uint16_t surfacePressureStart = INVALID_PRESSURE_VALUE;
+static uint16_t surfaceTemperatureStart = 0;
+static uint16_t pressureHistory[HISTORY_BUF_SIZE];
+static uint8_t pressureHistoryIndex = 0;
+static uint16_t temperatureHistory[HISTORY_BUF_SIZE];
+static uint8_t temperatureHistoryIndex = 0;
+static uint8_t measureCnt = MEASURE_INTERVALL;
+static uint8_t referenceSensor = 0xff;
+
+/* Exported functions --------------------------------------------------------*/
+
+
+
+static void storePressureValue(int16_t deltapressure_mBar)
+{
+	uint16_t newValue = DELTA_SHIFT - deltapressure_mBar;	/* invert value because graph is drawing larger values to bottom direction */
+	if(pressureHistoryIndex + 2 < HISTORY_BUF_SIZE)
+	{
+		pressureHistoryIndex++;
+		pressureHistory[pressureHistoryIndex] = newValue;
+		pressureHistoryIndex++;
+		pressureHistory[pressureHistoryIndex] = newValue;
+	}
+	else
+	{
+		memcpy (&pressureHistory[0],&pressureHistory[2],sizeof(pressureHistory) - 2);
+		pressureHistory[pressureHistoryIndex] = newValue;
+	}
+}
+
+static void storeTemperatureValue(uint16_t temperature)
+{
+	uint16_t newValue =  temperature;		/* todo: consider negativ temperature */
+	if(temperatureHistoryIndex + 2 < HISTORY_BUF_SIZE)
+	{
+		temperatureHistoryIndex++;
+		temperatureHistory[temperatureHistoryIndex] = newValue;
+		temperatureHistoryIndex++;
+		temperatureHistory[temperatureHistoryIndex] = newValue;
+	}
+	else
+	{
+		memcpy (&temperatureHistory[0],&temperatureHistory[2],sizeof(temperatureHistory) - 2);
+		temperatureHistory[temperatureHistoryIndex] = newValue;
+	}
+}
+
+void openInfo_PreDive()
+{
+	const SDiveState *pStateReal = stateRealGetPointer();
+	uint8_t index = 0;
+	SSensorDataDiveO2* pDiveO2Data = NULL;
+	SSettings *pSettings = settingsGetPointer();
+    set_globalState(StIPREDIVE);
+
+    surfacePressureStart = 0;
+    pressureHistoryIndex = 0;
+    referenceSensor = 0xff;
+
+	for(index = 0; index < EXT_INTERFACE_MUX_OFFSET; index++)
+	{
+		if((pSettings->ext_sensor_map[index] == SENSOR_DIGO2M) &&  pStateReal->lifeData.ppO2Sensor_bar[index] != 0)
+		{
+			referenceSensor = index;
+			pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data[index];
+			if(pDiveO2Data->pressure != 0)
+			{
+				surfacePressureStart = pDiveO2Data->pressure / 1000;
+				surfaceTemperatureStart = pDiveO2Data->temperature;
+			}
+			break;
+		}
+	}
+    for(index = 0; index < HISTORY_BUF_SIZE; index++)
+    {
+    	pressureHistory[index] = DELTA_SHIFT;
+    	temperatureHistory[index] = 0;
+    }
+}
+
+void refreshInfo_PreDive(GFX_DrawCfgScreen s)
+{
+	const SDiveState *pStateReal = stateRealGetPointer();
+	static int16_t deltaPressure = 0;
+	static uint16_t temperature = 0;
+	SSettings *pSettings = settingsGetPointer();
+	uint8_t index = 0;
+    char text[31];
+    SSensorDataDiveO2* pDiveO2Data = NULL;
+    point_t start, stop;
+
+    SWindowGimpStyle wintempppO2;
+    SWindowGimpStyle wintemptemp;
+
+    if(--measureCnt == 0)
+    {
+    	measureCnt = MEASURE_INTERVALL;
+    	pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data[referenceSensor];
+    	if(pDiveO2Data->pressure != 0)
+    	{
+    		if(surfacePressureStart == 0)
+    		{
+    			surfacePressureStart = pDiveO2Data->pressure / 1000;
+    			surfaceTemperatureStart = pDiveO2Data->temperature;
+    		}
+    		deltaPressure = (pDiveO2Data->pressure / 1000) - surfacePressureStart;
+    		storePressureValue(deltaPressure);
+    		temperature = pDiveO2Data->temperature;
+    		storeTemperatureValue(temperature);
+    	}
+    }
+
+    text[0] = '\001';
+	text[1] = TXT_PreDive;
+	text[2] = 0;
+	tInfo_write_content_simple(  30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware);
+
+	for(index = 0; index < EXT_INTERFACE_MUX_OFFSET; index++)
+	{
+		if((pSettings->ext_sensor_map[index] == SENSOR_DIGO2M) || (pSettings->ext_sensor_map[index] == SENSOR_ANALOG))
+		{
+			snprintf(text,32,"%c%c%d: %01.2f", TXT_2BYTE, TXT2BYTE_Sensor, index, pStateReal->lifeData.ppO2Sensor_bar[index]);
+			tInfo_write_content_simple(  5, 780, ME_Y_LINE1 + (index * ME_Y_LINE_STEP), &FontT48, text, CLUT_Font020);
+		}
+		else if(pSettings->ext_sensor_map[index] == SENSOR_CO2M)
+		{
+			snprintf(text,32,"CO2: %4ld", pStateReal->lifeData.CO2_data.CO2_ppm);
+			tInfo_write_content_simple(  5, 780, ME_Y_LINE5, &FontT48, text, CLUT_Font020);
+		}
+	}
+
+    wintempppO2.left = 350;
+    wintempppO2.right = 590;
+
+    wintemptemp.left = 350;
+    wintemptemp.right = 590;
+
+   	wintempppO2.top = ME_Y_LINE3;
+   	wintempppO2.bottom = wintempppO2.top + DELTA_SHIFT * 2;
+   	wintemptemp.top = ME_Y_LINE5;
+   	wintemptemp.bottom = wintemptemp.top + DELTA_SHIFT * 2;
+
+    start.x =  wintempppO2.left - 5;
+    start.y =  480 - wintemptemp.bottom - 5;
+    stop.x = wintempppO2.right- start.x + 5;
+    stop.y = DELTA_SHIFT * 2 + 10;
+    GFX_draw_box(&s, start, stop,1, CLUT_Font020);
+
+    start.y =  480 - wintempppO2.bottom - 5;
+    GFX_draw_box(&s, start, stop,1, CLUT_Font020);
+
+    if(pSettings->FlipDisplay)
+    {
+        wintempppO2.left = 800 - 590;
+        wintempppO2.right = 800 - 350;
+        wintemptemp.left = 800 - 590;
+        wintemptemp.right = 800 - 350;
+    }
+    GFX_graph_print(&s, &wintempppO2, 1,1,0, DELTA_SHIFT * 2, pressureHistory, HISTORY_BUF_SIZE, CLUT_Font030, NULL);
+
+    GFX_graph_print(&s, &wintemptemp, 1,1, surfaceTemperatureStart - 2000, surfaceTemperatureStart + 10000, temperatureHistory, HISTORY_BUF_SIZE, CLUT_Font030, NULL);
+
+/* Graph labeling */
+    snprintf(text,32,"%c%c", TXT_2BYTE, TXT2BYTE_CounterLung);
+   	tInfo_write_content_simple(  350, 795, ME_Y_LINE2, &FontT48, text, CLUT_Font020);
+
+   	snprintf(text,32,"\002\016\016%c%c", TXT_2BYTE, TXT2BYTE_Pressure);
+   	tInfo_write_content_simple(  500, 795, ME_Y_LINE3, &FontT48, text, CLUT_Font020);
+    snprintf(text,32,"\002%d",deltaPressure);
+	tInfo_write_content_simple(  500, 795, ME_Y_LINE4, &FontT48, text, CLUT_Font020);
+	snprintf(text,32,"\002\016\016%c",TXT_Temperature);
+	tInfo_write_content_simple(  300, 795, ME_Y_LINE5, &FontT48, text, CLUT_Font020);
+    snprintf(text,32,"\002%2.2f",(temperature / 1000.0));
+	tInfo_write_content_simple(  300, 795, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
+}
+
+void sendActionToInfoPreDive(uint8_t sendAction)
+{
+    switch(sendAction)
+    {
+    	case ACTION_BUTTON_BACK:
+    	//	exitInfo();
+    		exitMenuEdit_to_Menu_with_Menu_Update();
+    			break;
+
+    	case ACTION_BUTTON_ENTER:
+    		break;
+		case ACTION_BUTTON_NEXT:
+			break;
+		case ACTION_TIMEOUT:
+		case ACTION_MODE_CHANGE:
+	    case ACTION_IDLE_TICK:
+	    case ACTION_IDLE_SECOND:
+		default:
+	        break;
+    }
+}
+
--- a/Discovery/Src/tInfoSensor.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tInfoSensor.c	Wed Aug 14 16:44:46 2024 +0200
@@ -34,6 +34,7 @@
 #include "tInfo.h"
 #include "tInfoSensor.h"
 #include "tMenuEdit.h"
+#include "data_exchange_main.h"
 
 #include <string.h>
 #include <inttypes.h>
@@ -108,39 +109,8 @@
 	strcpy(pbuf,&tmpBuf[index+1]);
 }
 
-void tInfo_write_buttonTextline_simple(uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode)
-{
-    char localtext[32];
 
-    if(left2ByteCode)
-    {
-        localtext[0] = TXT_2BYTE;
-        localtext[1] = left2ByteCode;
-        localtext[2] = 0;
-        tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
-    }
-
-    if(middle2ByteCode)
-    {
-        localtext[0] = '\001';
-        localtext[1] = TXT_2BYTE;
-        localtext[2] = middle2ByteCode;
-        localtext[3] = 0;
-        tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
-    }
-
-    if(right2ByteCode)
-    {
-        localtext[0] = '\002';
-        localtext[1] = TXT_2BYTE;
-        localtext[2] = right2ByteCode;
-        localtext[3] = 0;
-        tInfo_write_content_simple(0, 800, 480-24, &FontT24,localtext,CLUT_ButtonSurfaceScreen);
-    }
-}
-
-//  ===============================================================================
-void refreshInfo_Sensor(GFX_DrawCfgScreen s)
+static void refreshInfo_SensorO2(GFX_DrawCfgScreen s)
 {
 	const SDiveState *pStateReal = stateRealGetPointer();
     SSensorDataDiveO2* pDiveO2Data;
@@ -150,6 +120,98 @@
 
     float pressure = 0.0;
 
+    pDiveO2Data = (SSensorDataDiveO2*)pStateReal->lifeData.extIf_sensor_data[activeSensorId];
+	strIndex = snprintf(text,32,"ID: ");
+	if(pDiveO2Data->sensorId != 0)
+	{
+		uint64ToString(pDiveO2Data->sensorId,&text[strIndex]);
+	}
+	tInfo_write_content_simple(  30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020);
+	snprintf(text,32,"%c: %02.1f",TXT_Temperature , (float)pDiveO2Data->temperature / 1000.0);
+	tInfo_write_content_simple(  30, 770, ME_Y_LINE2, &FontT48, text, CLUT_Font020);
+
+#ifdef ENABLE_EXTERNAL_PRESSURE
+	pressure = (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[2]);
+#else
+	pressure = (float)pDiveO2Data->pressure / 1000.0;
+#endif
+	snprintf(text,32,"Druck: %02.1f (%02.1f)", (float)pDiveO2Data->pressure / 1000.0, pressure *1000.0);
+
+	tInfo_write_content_simple(  30, 770, ME_Y_LINE3, &FontT48, text, CLUT_Font020);
+	snprintf(text,32,"Feuchtigkeit: %02.1f", (float)pDiveO2Data->humidity / 1000.0);
+	tInfo_write_content_simple(  30, 770, ME_Y_LINE4, &FontT48, text, CLUT_Font020);
+	snprintf(text,32,"Status: 0x%lx", pDiveO2Data->status);
+	tInfo_write_content_simple(  30, 770, ME_Y_LINE5, &FontT48, text, CLUT_Font020);
+#ifdef ENABLE_EXTERNAL_PRESSURE
+	snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0]));
+	tInfo_write_content_simple(  30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
+#endif
+
+	if(sensorActive)
+	{
+		*textPointer++ = '\005';
+	}
+	else
+	{
+		*textPointer++ = '\006';
+	}
+	*textPointer++ = ' ';
+	*textPointer++ = TXT_2BYTE;
+	*textPointer++ = TXT2BYTE_Sensor;
+	*textPointer++ = ' ';
+	*textPointer++ = TXT_2BYTE;
+	*textPointer++ = TXT2BYTE_O2IFDigital;
+	*textPointer++ = '1' + activeSensorId;
+
+	snprintf(textPointer, 20,": %01.2f, %01.1f mV",  pStateReal->lifeData.ppO2Sensor_bar[activeSensorId], pStateReal->lifeData.sensorVoltage_mV[activeSensorId]);
+
+	tInfo_write_content_simple(  30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
+
+	tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0);
+}
+
+static void refreshInfo_SensorCo2(GFX_DrawCfgScreen s)
+{
+	const SDiveState *pStateReal = stateRealGetPointer();
+    char text[31];
+    char *textPointer = text;
+
+    snprintf(text,32,"CO2: %ld ppm",pStateReal->lifeData.CO2_data.CO2_ppm);
+    tInfo_write_content_simple(  30, 770, ME_Y_LINE1, &FontT48, text, CLUT_Font020);
+
+
+    snprintf(text,32,"Signal: %d",pStateReal->lifeData.CO2_data.signalStrength);
+    tInfo_write_content_simple(  30, 770, ME_Y_LINE2, &FontT48, text, CLUT_Font020);
+
+	if(sensorActive)
+	{
+		*textPointer++ = '\005';
+	}
+	else
+	{
+		*textPointer++ = '\006';
+	}
+	*textPointer++ = ' ';
+	*textPointer++ = TXT_2BYTE;
+	*textPointer++ = TXT2BYTE_Sensor;
+	*textPointer++ = ' ';
+	*textPointer++ = 'C';
+	*textPointer++ = 'o';
+	*textPointer++ = '1' + activeSensorId;
+
+	snprintf(textPointer, 20,": %ld ppm",  pStateReal->lifeData.CO2_data.CO2_ppm);
+
+	tInfo_write_content_simple(  30, 770, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
+
+	tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_O2Calib);
+}
+//  ===============================================================================
+void refreshInfo_Sensor(GFX_DrawCfgScreen s)
+{
+	const SDiveState *pStateReal = stateRealGetPointer();
+
+    char text[31];
+
     text[0] = '\001';
 	text[1] = TXT_Sensor;
 	text[2] = ' ';
@@ -157,57 +219,16 @@
 	text[4] = ' ';
 	text[5] = '1' + activeSensorId;
 	text[6] = 0;
-	tInfo_write_content_simple(  30, 340, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware);
-
-    pDiveO2Data = (SSensorDataDiveO2*)&stateRealGetPointer()->lifeData.extIf_sensor_data[activeSensorId];
-
-    strIndex = snprintf(text,32,"ID: ");
-    if(pDiveO2Data->sensorId != 0)
-    {
-    	uint64ToString(pDiveO2Data->sensorId,&text[strIndex]);
-    }
-    tInfo_write_content_simple(  30, 340, ME_Y_LINE1, &FontT48, text, CLUT_Font020);
-    snprintf(text,32,"%c: %02.1f",TXT_Temperature , (float)pDiveO2Data->temperature / 1000.0);
-    tInfo_write_content_simple(  30, 340, ME_Y_LINE2, &FontT48, text, CLUT_Font020);
-
-#ifdef ENABLE_EXTERNAL_PRESSURE
-    pressure = (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[2]);
-#else
-    pressure = (float)pDiveO2Data->pressure / 1000.0;
-#endif
-    snprintf(text,32,"Druck: %02.1f (%02.1f)", (float)pDiveO2Data->pressure / 1000.0, pressure *1000.0);
+	tInfo_write_content_simple(  30, 770, ME_Y_LINE_BASE, &FontT48, text, CLUT_MenuPageHardware);
 
-    tInfo_write_content_simple(  30, 340, ME_Y_LINE3, &FontT48, text, CLUT_Font020);
-    snprintf(text,32,"Feuchtigkeit: %02.1f", (float)pDiveO2Data->humidity / 1000.0);
-    tInfo_write_content_simple(  30, 340, ME_Y_LINE4, &FontT48, text, CLUT_Font020);
-    snprintf(text,32,"Status: 0x%lx", pDiveO2Data->status);
-    tInfo_write_content_simple(  30, 340, ME_Y_LINE5, &FontT48, text, CLUT_Font020);
-#ifdef ENABLE_EXTERNAL_PRESSURE
-    snprintf(text,32,"Norm ppO2: %02.3f (%02.1f)", (float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0] / (pressure / 1000.0)),(float)(stateRealGetPointer()->lifeData.ppO2Sensor_bar[0]));
-    tInfo_write_content_simple(  30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
-#endif
-
-    if(sensorActive)
-    {
-    	*textPointer++ = '\005';
-    }
-    else
-    {
-    	*textPointer++ = '\006';
-    }
-    *textPointer++ = ' ';
-    *textPointer++ = TXT_2BYTE;
-    *textPointer++ = TXT2BYTE_Sensor;
-    *textPointer++ = ' ';
-    *textPointer++ = TXT_2BYTE;
-    *textPointer++ = TXT2BYTE_O2IFDigital;
-    *textPointer++ = '1' + activeSensorId;
-
-    snprintf(textPointer, 20,": %01.2f, %01.1f mV",  pStateReal->lifeData.ppO2Sensor_bar[activeSensorId], pStateReal->lifeData.sensorVoltage_mV[activeSensorId]);
-
-    tInfo_write_content_simple(  30, 340, ME_Y_LINE6, &FontT48, text, CLUT_Font020);
-
-    tInfo_write_buttonTextline_simple(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,0);
+	switch(pStateReal->lifeData.extIf_sensor_map[activeSensorId])
+	{
+		default:
+		case SENSOR_DIGO2M:	refreshInfo_SensorO2(s);
+			break;
+		case SENSOR_CO2M: refreshInfo_SensorCo2(s);
+			break;
+	}
 }
 
 void sendActionToInfoSensor(uint8_t sendAction)
@@ -220,16 +241,28 @@
 
     	case ACTION_BUTTON_ENTER:    	if(settingsGetPointer()->ppo2sensors_deactivated & (1 << (activeSensorId)))
 										{
+    										if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M)
+    										{
+    											settingsGetPointer()->co2_sensor_active = 1;
+    										}
     										settingsGetPointer()->ppo2sensors_deactivated &= ~(uint8_t)(1 << (activeSensorId));
 											sensorActive = 1;
 										}
 										else
 										{
+											if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M)
+											{
+    											settingsGetPointer()->co2_sensor_active = 0;
+    										}
 											settingsGetPointer()->ppo2sensors_deactivated |= (uint8_t)(1 << (activeSensorId));
 											sensorActive = 0;
 										}
     		break;
-		case ACTION_BUTTON_NEXT:
+		case ACTION_BUTTON_NEXT:		if(stateRealGetPointer()->lifeData.extIf_sensor_map[activeSensorId] == SENSOR_CO2M)
+										{
+											DataEX_setExtInterface_Cmd(EXT_INTERFACE_CO2_CALIB);
+										}
+			break;
 		case ACTION_TIMEOUT:
 		case ACTION_MODE_CHANGE:
 	    case ACTION_IDLE_TICK:
--- a/Discovery/Src/tMenu.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tMenu.c	Wed Aug 14 16:44:46 2024 +0200
@@ -261,6 +261,13 @@
 	}
 }
 
+uint8_t getLineMask(uint32_t lineId)
+{
+	SStateList idList;
+	get_idSpecificStateList(lineId, &idList);
+	return(menu.disableLineMask[idList.page]);
+}
+
 void resetLineMask(uint32_t lineId)
 {
 	SStateList idList;
@@ -591,7 +598,10 @@
     if((isLoopMode(pSettings->dive_mode)) || (stateUsed->diveSettings.ccrOption == 1))
     {
         tM_add(StMCG);
-        tM_add(StMSP);
+        if((stateUsed->diveSettings.diveMode != DIVEMODE_PSCR) || (actual_menu_content != MENU_SURFACE))
+        {
+        	tM_add(StMSP);
+        }
         if (actual_menu_content == MENU_SURFACE)  /* StMOG is now accessed using StMCG in CCR mode*/
         {
         	tM_add(StMXTRA);
@@ -931,6 +941,18 @@
     block_diluent_handler(1);
 }
 
+static void checkLineStatus()
+{
+	switch(get_globalState())
+	{
+		case StMSYS: tMSystem_checkLineStatus();
+			break;
+		case StMXTRA: tMXtra_checkLineStatus();
+			break;
+		default:
+			break;
+	}
+}
 
 static void nextPage(void)
 {
@@ -950,6 +972,8 @@
 
     set_globalState_Menu_Page(page);
 
+    checkLineStatus();		/* some lines may be enabled / disabled depending on condition occuring outside the page scope => check if update is necessary */
+
     change_CLUT_entry(CLUT_MenuLineSelectedSides, 		(CLUT_MenuPageGasOC + page - 1));
     change_CLUT_entry(CLUT_MenuLineSelectedSeperator, (CLUT_MenuPageGasOC + page - 1));
 
--- a/Discovery/Src/tMenuEdit.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tMenuEdit.c	Wed Aug 14 16:44:46 2024 +0200
@@ -36,6 +36,7 @@
 #include "tHome.h"
 #include "tInfoCompass.h"
 #include "tInfoSensor.h"
+#include "tInfoPreDive.h"
 #include "tMenuEditHardware.h"
 #include "tMenuEditPlanner.h"
 #include "tMenuEditSystem.h"
@@ -96,11 +97,13 @@
 static uint8_t menuColor;
 
 static int8_t id = 0;
+static int8_t actualId = 0;
 static int8_t idLast = -1;
 static SEditIdent ident[10];
 static int8_t tME_stop = 0;
 
 static int8_t evid = 0;
+static int8_t actualevid = 0;
 static int8_t evidLast = -1;
 static SEventHandler event[10];
 
@@ -115,6 +118,10 @@
 static _Bool WriteSettings = 0;
 
 /* Private function prototypes -----------------------------------------------*/
+static void create_newText_for_Id(int8_t localId);
+void clean_content_of_Id(int8_t localId);
+static void write_content_of_Id(int8_t localId);
+
 void draw_tMEdesign(void);
 void set_cursorNew(uint8_t forThisIdentID);
 void startMenuEditFieldSelect(void);
@@ -155,12 +162,22 @@
     tME_stop = 1;
 }
 
-void resetMenuEdit(uint8_t color)
+void resetMenuContentStructure()
 {
     id = 0;
     idLast = -1;
     evid = 0;
     evidLast = -1;
+}
+
+void resetMenuEdit(uint8_t color)
+{
+    id = 0;
+    actualId = 0;
+    idLast = -1;
+    evid = 0;
+    actualevid = 0;
+    evidLast = -1;
     tME_stop = 0;
     EnterPressed = 0;
     EnterPressedBeforeButtonAction = 0;
@@ -184,10 +201,8 @@
 
     menuColor = color;
 
-//	draw_tMEdesign();
-//	GFX_SetFramesTopBottom(tMEscreen.FBStartAdress, tMEcursor.FBStartAdress,480);
+    /* set cursor to first line */
     uint8_t line = 1;
-//	GFX_SetFramesTopBottom(tMEscreen.FBStartAdress, (tMEcursorNew.FBStartAdress) + 65*2*(line - 1),390);
     GFX_SetFrameTop(tMEscreen.FBStartAdress);
     if(!settingsGetPointer()->FlipDisplay)
     {
@@ -214,22 +229,12 @@
 	 	 case (StMHARD3_Sensor_Detect):
 	 	 case (StMHARD3_Sensor_Info):							refreshFct = refresh_O2Sensors;
 	 	 	 break;
-		 case (StMHARD2_Compass_SetCourse & MaskFieldDigit):
+		 case (StMHARD2_Compass & MaskFieldDigit):
              refreshFct = refresh_CompassEdit;
-
 			 break;
 		 case (StMXTRA_CompassHeading & MaskFieldDigit):
              refreshFct = refresh_CompassHeading;
-
 			 break;
-	 	 case (StMXTRA_PSCR_O2_Drop & MaskFieldDigit):
-            if (settingsGetPointer()->dive_mode != DIVEMODE_PSCR) { /* workaround because PSCR mode is set dynamic */
-                refreshFct = refresh_CO2Data;
-            }
-
-			break;
-	 	 case (StMXTRA_CO2_Sensor & MaskFieldDigit):  refreshFct = refresh_CO2Data;
-	 	 	 break;
 	 	 case (StMSYS4_Info & MaskFieldDigit): refreshFct = &refresh_InformationPage;
 	 	 	 break;
 	 	 case (StMPLAN5_ExitResult & MaskFieldDigit): refreshFct = refresh_PlanResult;
@@ -394,20 +399,20 @@
 
 void startMenuEditFieldSelect(void)
 {
-    id = 0;
-    helperGotoMenuEditField(id);
+    actualId = 0;
+    helperGotoMenuEditField(actualId);
 }
 
 
 void nextMenuEditField(void)
 {
-    helperLeaveMenuEditField(id);
+    helperLeaveMenuEditField(actualId);
 
-    if(id < idLast)
-        id++;
+    if(actualId < idLast)
+    	actualId++;
     else
-        id = 0;
-    helperGotoMenuEditField(id);
+    	actualId = 0;
+    helperGotoMenuEditField(actualId);
 }
 
 /*
@@ -424,16 +429,16 @@
 
 _Bool inc_subBlock_or_block_of_actual_id(void)
 {
-    if(event[evid].callerID != ident[id].callerID)
+    if(event[actualevid].callerID != ident[actualId].callerID)
         return 0;
 
-    if((ident[id].subtype != FIELD_3DIGIT) && (ident[id].subtype != FIELD_2DIGIT) && ((subBlockPosition + 1) < ident[id].size[block]))
+    if((ident[actualId].subtype != FIELD_3DIGIT) && (ident[actualId].subtype != FIELD_2DIGIT) && ((subBlockPosition + 1) < ident[actualId].size[block]))
     {
         subBlockPosition++;
         return 1;
     }
 
-    if(((block + 1) < 4) && (ident[id].size[block+1] > 0))
+    if(((block + 1) < 4) && (ident[actualId].size[block+1] > 0))
     {
         block++;
         subBlockPosition = 0;
@@ -449,33 +454,33 @@
     uint8_t (*onActionFunc)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t);
     uint8_t content;
 
-    if(event[evid].callerID != ident[id].callerID)
+    if(event[actualevid].callerID != ident[actualId].callerID)
         return 0;
 
-    onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(event[evid].pEventFunction);
+    onActionFunc = (uint8_t (*)(uint32_t, uint8_t, uint8_t, uint8_t, uint8_t))(event[actualevid].pEventFunction);
 
-    if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT))
+    if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT))
     {
-        content  = 100 * (	ident[id].newText[ident[id].begin[block] + 0] - '0');
-        content +=  10 * (	ident[id].newText[ident[id].begin[block] + 1] - '0');
-        content += 				ident[id].newText[ident[id].begin[block] + 2];
+        content  = 100 * (	ident[actualId].newText[ident[actualId].begin[block] + 0] - '0');
+        content +=  10 * (	ident[actualId].newText[ident[actualId].begin[block] + 1] - '0');
+        content += 				ident[actualId].newText[ident[actualId].begin[block] + 2];
     }
     else
-    if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT))
+    if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT))
     {
-        content = 10 * (ident[id].newText[ident[id].begin[block] + 0] - '0');
-        content += ident[id].newText[ident[id].begin[block] + 1];
+        content = 10 * (ident[actualId].newText[ident[actualId].begin[block] + 0] - '0');
+        content += ident[actualId].newText[ident[actualId].begin[block] + 1];
     }
     else
-    if(ident[id].maintype == FIELD_NUMBERS)
-        content = ident[id].newText[ident[id].begin[block] + subBlockPosition];
+    if(ident[actualId].maintype == FIELD_NUMBERS)
+        content = ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition];
     else
-    if((ident[id].maintype == FIELD_ON_OFF) || (ident[id].maintype == FIELD_TOGGLE))
-        content = ident[id].input[block];
+    if((ident[actualId].maintype == FIELD_ON_OFF) || (ident[actualId].maintype == FIELD_TOGGLE))
+        content = ident[actualId].input[block];
     else
         content = 0; /* just a default for protection */
 
-    return onActionFunc(ident[id].callerID, block, subBlockPosition, content, action);
+    return onActionFunc(ident[actualId].callerID, block, subBlockPosition, content, action);
 }
 
 void mark_digit_of_actual_id_with_this_block_and_subBlock(int8_t oldblock, int8_t oldsubblockpos)
@@ -483,15 +488,15 @@
     char oneCharText[2];
     uint16_t positionOffset;
 
-    if(event[evid].callerID != ident[id].callerID)
+    if(event[actualevid].callerID != ident[actualId].callerID)
         return;
 
-    if(ident[id].maintype == FIELD_NUMBERS)
+    if(ident[actualId].maintype == FIELD_NUMBERS)
     {
-        oneCharText[0] = ident[id].newText[ident[id].begin[oldblock] + oldsubblockpos];
+        oneCharText[0] = ident[actualId].newText[ident[actualId].begin[oldblock] + oldsubblockpos];
         oneCharText[1] = 0;
-        positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[oldblock] + oldsubblockpos);
-        write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditFieldSelected);
+        positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[oldblock] + oldsubblockpos);
+        write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditFieldSelected);
     }
 }
 
@@ -501,16 +506,16 @@
     char oneCharText[3];
     uint16_t positionOffset;
 
-    if(event[evid].callerID != ident[id].callerID)
+    if(event[actualevid].callerID != ident[actualId].callerID)
         return;
 
-    if(ident[id].maintype == FIELD_NUMBERS)
+    if(ident[actualId].maintype == FIELD_NUMBERS)
     {
-        oneCharText[0] = ident[id].newText[ident[id].begin[block] + 0];
-        oneCharText[1] = ident[id].newText[ident[id].begin[block] + 1];
+        oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + 0];
+        oneCharText[1] = ident[actualId].newText[ident[actualId].begin[block] + 1];
         oneCharText[2] = 0;
-        positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + 0);
-        write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit);
+        positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block] + 0);
+        write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit);
     }
 }
 
@@ -520,17 +525,17 @@
     char oneCharText[4];
     uint16_t positionOffset;
 
-    if(event[evid].callerID != ident[id].callerID)
+    if(event[actualevid].callerID != ident[actualId].callerID)
         return;
 
-    if(ident[id].maintype == FIELD_NUMBERS)
+    if(ident[actualId].maintype == FIELD_NUMBERS)
     {
-        oneCharText[0] = ident[id].newText[ident[id].begin[block] + 0];
-        oneCharText[1] = ident[id].newText[ident[id].begin[block] + 1];
-        oneCharText[2] = ident[id].newText[ident[id].begin[block] + 2];
+        oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + 0];
+        oneCharText[1] = ident[actualId].newText[ident[actualId].begin[block] + 1];
+        oneCharText[2] = ident[actualId].newText[ident[actualId].begin[block] + 2];
         oneCharText[3] = 0;
-        positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + 0);
-        write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit);
+        positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block] + 0);
+        write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit);
     }
 }
 
@@ -540,15 +545,15 @@
     char oneCharText[2];
     uint16_t positionOffset;
 
-    if(event[evid].callerID != ident[id].callerID)
+    if(event[actualevid].callerID != ident[actualId].callerID)
         return;
 
-    if(ident[id].maintype == FIELD_NUMBERS)
+    if(ident[actualId].maintype == FIELD_NUMBERS)
     {
-        oneCharText[0] = ident[id].newText[ident[id].begin[block] + subBlockPosition];
+        oneCharText[0] = ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition];
         oneCharText[1] = 0;
-        positionOffset = GFX_return_offset(ident[id].fontUsed, ident[id].newText, ident[id].begin[block] + subBlockPosition);
-        write_content( ident[id].coord[0] + positionOffset, ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, oneCharText, CLUT_MenuEditDigit);
+        positionOffset = GFX_return_offset(ident[actualId].fontUsed, ident[actualId].newText, ident[actualId].begin[block] + subBlockPosition);
+        write_content( ident[actualId].coord[0] + positionOffset, ident[actualId].coord[1], ident[actualId].coord[2], ident[actualId].fontUsed, oneCharText, CLUT_MenuEditDigit);
     }
 }
 
@@ -560,27 +565,27 @@
     uint8_t digit10;
     uint8_t digit1;
 
-    evid = 0;
-    while((evid < evidLast) && (event[evid].callerID != ident[id].callerID))
+    actualevid = 0;
+    while((actualevid < evidLast) && (event[actualevid].callerID != ident[actualId].callerID))
     {
-        evid++;
+        actualevid++;
     }
 
-    if(event[evid].callerID != ident[id].callerID)
+    if(event[actualevid].callerID != ident[actualId].callerID)
         return;
 
-    set_globalState(event[evid].callerID);
+    set_globalState(event[actualevid].callerID);
     block = 0;
     subBlockPosition = 0;
 
-    if(ident[id].maintype == FIELD_NUMBERS)
+    if(ident[actualId].maintype == FIELD_NUMBERS)
     {
         change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor);
         // old stuff? hw 150916, reactivated 150923, this shows which digit will be changed now as it marks the other grey/black
         // now fixed for button settings with newContent <= '0'+99 condition
-        change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldSelected);
+        change_CLUT_entry((CLUT_MenuEditField0 + actualId), CLUT_MenuEditFieldSelected);
     }
-    if(ident[id].maintype == FIELD_TOGGLE)
+    if(ident[actualId].maintype == FIELD_TOGGLE)
     {
         change_CLUT_entry(CLUT_MenuEditLineSelected, CLUT_MenuEditCursor);
     }
@@ -623,15 +628,15 @@
         return;
     }
 
-    switch(ident[id].maintype)
+    switch(ident[actualId].maintype)
     {
     case FIELD_NUMBERS:
         write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus);
 
-        switch (ident[id].subtype) {
+        switch (ident[actualId].subtype) {
         case FIELD_UDIGIT:
             if((newContent >= '0') && (newContent <= '9'))
-                ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent;
+                ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
 
             mark_new_digit_of_actual_id_block_and_subBlock();
 
@@ -640,9 +645,9 @@
             if((newContent >= '0') && (newContent <= '0'+200))
             {
                 split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1);
-                ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100;
-                ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10;
-                ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1;
+                ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + digit100;
+                ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + digit10;
+                ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + digit1;
                 mark_new_3digit_of_actual_id_block();
             }
 
@@ -650,15 +655,15 @@
         case FIELD_2DIGIT:
             if((newContent >= '0') && (newContent <= '0'+99))
             {
-                ident[id].newText[ident[id].begin[block]] = '0' + (newContent - '0')/10;
-                ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
+                ident[actualId].newText[ident[actualId].begin[block]] = '0' + (newContent - '0')/10;
+                ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
                 mark_new_2digit_of_actual_id_block();
             }
 
             break;
         case FIELD_SDIGIT:
             if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) {
-                ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent;
+                ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
             }
 
             mark_new_digit_of_actual_id_block_and_subBlock();
@@ -672,10 +677,10 @@
 
         break;
     case FIELD_SYMBOL:
-        ident[id].input[0] += 1;
-        if(ident[id].input[0] >= ident[id].input[1])
-            ident[id].input[0] = 0;
-        ident[id].newText[0] = ident[id].orgText[ident[id].input[0]];
+        ident[actualId].input[0] += 1;
+        if(ident[actualId].input[0] >= ident[actualId].input[1])
+            ident[actualId].input[0] = 0;
+        ident[actualId].newText[0] = ident[actualId].orgText[ident[actualId].input[0]];
         write_content_of_actual_Id();
         set_globalState(menuID);
         break;
@@ -693,7 +698,7 @@
 
     set_globalState(menuID);
 
-    if(event[evid].callerID != ident[id].callerID)
+    if(event[actualevid].callerID != ident[actualId].callerID)
         return;
 
     newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_TIMEOUT);
@@ -744,7 +749,7 @@
     int8_t blockOld = 0;
     int8_t subBlockPositionOld = 0;
 
-    if(event[evid].callerID != ident[id].callerID)
+    if(event[actualevid].callerID != ident[actualId].callerID)
         return;
 
     blockOld = block;
@@ -787,29 +792,29 @@
         }
     }
 
-    if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99))
+    if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99))
     {
-        ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/100;
-        ident[id].newText[ident[id].begin[block] + 1] = '0' + (newContent - '0')/10;
-        ident[id].newText[ident[id].begin[block] + 2] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
+        ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/100;
+        ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + (newContent - '0')/10;
+        ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
     }
     else
-    if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99))
+    if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT) && (action == ACTION_BUTTON_ENTER) &&(newContent >= '0') && (newContent <= '0' + 99))
     {
-        ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10;
-        ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
-    } else if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT && action == ACTION_BUTTON_ENTER && subBlockPosition == 0) {
+        ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/10;
+        ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
+    } else if (ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT && action == ACTION_BUTTON_ENTER && subBlockPosition == 0) {
         if (newContent == '+' || newContent == '-') {
-            ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent;
+            ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
         }
     }
     else
-    if((ident[id].maintype == FIELD_NUMBERS) && (action == ACTION_BUTTON_ENTER) && (newContent >= '0') && (newContent <= '9'))
-        ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent;
+    if((ident[actualId].maintype == FIELD_NUMBERS) && (action == ACTION_BUTTON_ENTER) && (newContent >= '0') && (newContent <= '9'))
+        ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
 
     if(action == ACTION_BUTTON_ENTER)
     {
-        if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT))
+        if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT))
         {
             mark_new_3digit_of_actual_id_block();
             mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0);
@@ -817,7 +822,7 @@
             mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,2);
         }
         else
-        if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT))
+        if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT))
         {
             mark_new_2digit_of_actual_id_block();
             mark_digit_of_actual_id_with_this_block_and_subBlock(blockOld,0);
@@ -861,7 +866,7 @@
 static void checkUpdateSDigit(uint8_t newContent)
 {
     if ((subBlockPosition == 0 && (newContent == '+' || newContent == '-')) || (subBlockPosition > 0 && newContent >= '0' && newContent <= '9')) {
-        ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent;
+        ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
     }
 }
 
@@ -873,33 +878,33 @@
     uint8_t digit10;
     uint8_t digit1;
 
-    if(event[evid].callerID != ident[id].callerID)
+    if(event[actualevid].callerID != ident[actualId].callerID)
         return;
 
     newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_NEXT);
 
-    if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200))
+    if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200))
     {
         split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1);
-        ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100;
-        ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10;
-        ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1;
+        ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + digit100;
+        ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + digit10;
+        ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + digit1;
         mark_new_3digit_of_actual_id_block();
         return;
     }
 
-    if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99))
+    if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99))
     {
-        ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10;
-        ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
+        ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/10;
+        ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
         mark_new_2digit_of_actual_id_block();
         return;
     }
 
-    if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT) {
+    if (ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT) {
         checkUpdateSDigit(newContent);
-    } else if (ident[id].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') {
-        ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent;
+    } else if (ident[actualId].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') {
+        ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
     }
 
     mark_new_digit_of_actual_id_block_and_subBlock();
@@ -913,33 +918,33 @@
     uint8_t digit10;
     uint8_t digit1;
 
-    if(event[evid].callerID != ident[id].callerID)
+    if(event[actualevid].callerID != ident[actualId].callerID)
         return;
 
     newContent = get_newContent_of_actual_id_block_and_subBlock(ACTION_BUTTON_BACK);
 
-    if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200))
+    if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_3DIGIT) &&(newContent >= '0') && (newContent <= '0' + 200))
     {
         split_Content_to_Digit_helper( newContent, &digit100, &digit10, &digit1);
-        ident[id].newText[ident[id].begin[block] + 0] = '0' + digit100;
-        ident[id].newText[ident[id].begin[block] + 1] = '0' + digit10;
-        ident[id].newText[ident[id].begin[block] + 2] = '0' + digit1;
+        ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + digit100;
+        ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + digit10;
+        ident[actualId].newText[ident[actualId].begin[block] + 2] = '0' + digit1;
         mark_new_3digit_of_actual_id_block();
         return;
     }
 
-    if((ident[id].maintype == FIELD_NUMBERS) && (ident[id].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99))
+    if((ident[actualId].maintype == FIELD_NUMBERS) && (ident[actualId].subtype == FIELD_2DIGIT) &&(newContent >= '0') && (newContent <= '0' + 99))
     {
-        ident[id].newText[ident[id].begin[block] + 0] = '0' + (newContent - '0')/10;
-        ident[id].newText[ident[id].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
+        ident[actualId].newText[ident[actualId].begin[block] + 0] = '0' + (newContent - '0')/10;
+        ident[actualId].newText[ident[actualId].begin[block] + 1] = '0' + ((newContent - '0') - (10*((newContent - '0')/10)));
         mark_new_2digit_of_actual_id_block();
         return;
     }
 
-    if (ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT) {
+    if (ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT) {
         checkUpdateSDigit(newContent);
-    } else if (ident[id].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') {
-        ident[id].newText[ident[id].begin[block] + subBlockPosition] = newContent;
+    } else if (ident[actualId].maintype == FIELD_NUMBERS && newContent >= '0' && newContent <= '9') {
+        ident[actualId].newText[ident[actualId].begin[block] + subBlockPosition] = newContent;
     }
 
     mark_new_digit_of_actual_id_block_and_subBlock();
@@ -948,10 +953,10 @@
 
 void evaluateNewString(uint32_t editID, uint32_t *pNewValue1, uint32_t *pNewValue2, uint32_t *pNewValue3, uint32_t *pNewValue4)
 {
-    if(editID != ident[id].callerID)
+    if(editID != ident[actualId].callerID)
         return;
 
-    bool isSigned = ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT;
+    bool isSigned = ident[actualId].maintype == FIELD_NUMBERS && ident[actualId].subtype == FIELD_SDIGIT;
 
     uint8_t i, digitCount, digit;
     uint32_t sum[4], multiplier;
@@ -960,16 +965,16 @@
         sum[i] = 0;
 
     i = 0;
-    while( ident[id].size[i] && (i < 4))
+    while( ident[actualId].size[i] && (i < 4))
     {
         multiplier = 1;
-        for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++)
+        for(digitCount = 1; digitCount < ident[actualId].size[i]; digitCount++)
             multiplier *= 10;
 
         bool isNegative = false;
-        for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++)
+        for(digitCount = 0; digitCount < ident[actualId].size[i]; digitCount++)
         {
-            digit = ident[id].newText[ident[id].begin[i] + digitCount];
+            digit = ident[actualId].newText[ident[actualId].begin[i] + digitCount];
 
             if (isSigned && digitCount == 0) {
                 if (digit == '-') {
@@ -1015,8 +1020,8 @@
 {
     uint8_t temp_id;
 
-    if(editID == ident[id].callerID)
-        return id;
+    if(editID == ident[actualId].callerID)
+        return actualId;
     else
     {
         temp_id = 0;
@@ -1043,8 +1048,8 @@
     strncpy(ident[id].newText, text, 32);
     ident[id].newText[31] = 0;
 
-    clean_content_of_actual_Id();
-    write_content_of_actual_Id();
+    clean_content_of_Id(id);
+    write_content_of_Id(id);
 
     id = backup_id;
 }
@@ -1068,8 +1073,8 @@
     else
         ident[id].newText[0] = '\006';
 
-    clean_content_of_actual_Id();
-    write_content_of_actual_Id();
+    clean_content_of_Id(id);
+    write_content_of_Id(id);
 
     id = backup_id;
 }
@@ -1081,8 +1086,8 @@
 
 	if(id_local <= idLast)
 	{
-		id = id_local;
-		set_cursorNew(id);
+		actualId = id_local;
+		set_cursorNew(id_local);
 	}
 }
 
@@ -1140,10 +1145,10 @@
     ident[id].input[2] = int3;
     ident[id].input[3] = int4;
 
-    create_newText_for_actual_Id();
+    create_newText_for_Id(id);
     if(id <= idLast)
         change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular);
-    write_content_of_actual_Id();
+    write_content_of_Id(id);
 
     id = backup_id;
 }
@@ -1185,7 +1190,7 @@
         }
     }
     else
-    if(get_globalState() == event[evid].callerID)
+    if(get_globalState() == event[actualevid].callerID)
     {
         switch(sendAction)
         {
@@ -1233,70 +1238,79 @@
 }
 
 
-void create_newText_for_actual_Id_and_field_select(void)
+void create_newText_for_Id_and_field_select(int8_t localId)
 {
     uint8_t i;
 
     i = 0;
-    while( ident[id].size[i] && (i < 4))
+    while( ident[localId].size[i] && (i < 4))
     {
-        if(ident[id].input[i])
-            ident[id].newText[ident[id].begin[i]] = '\005';
+        if(ident[localId].input[i])
+            ident[localId].newText[ident[localId].begin[i]] = '\005';
         else
-            ident[id].newText[ident[id].begin[i]] = '\006';
+            ident[localId].newText[ident[localId].begin[i]] = '\006';
         i++;
     }
 }
 
+void create_newText_for_actual_Id_and_field_select(void)
+{
+	create_newText_for_Id_and_field_select(actualId);
+}
 
-void create_newText_for_actual_Id(void)
+void create_newText_for_Id(int8_t localId)
 {
-    if(	ident[id].maintype == FIELD_SELECT)
+	bool isSigned = ident[localId].maintype == FIELD_NUMBERS && ident[localId].subtype == FIELD_SDIGIT;
+
+	uint8_t i, digitCount;
+	uint32_t remainder, digit, divider;
+	i = 0;
+
+    if(	ident[localId].maintype == FIELD_SELECT)
     {
-        create_newText_for_actual_Id_and_field_select();
+        create_newText_for_Id_and_field_select(localId);
         return;
     }
 
-    bool isSigned = ident[id].maintype == FIELD_NUMBERS && ident[id].subtype == FIELD_SDIGIT;
-
-    uint8_t i, digitCount;
-    uint32_t remainder, digit, divider;
+	while( ident[localId].size[i] && (i < 4))
+	{
+		bool isNegative = false;
+		if (isSigned) {
+			int32_t value = ((input_u)ident[localId].input[i]).int32;
+			if (value < 0) {
+				isNegative = true;
+			}
+			remainder = abs(value);
+		} else {
+			remainder = ident[localId].input[i];
+		}
+		divider = 1;
 
-    i = 0;
-    while( ident[id].size[i] && (i < 4))
-    {
-        bool isNegative = false;
-        if (isSigned) {
-            int32_t value = ((input_u)ident[id].input[i]).int32;
-            if (value < 0) {
-                isNegative = true;
-            }
-            remainder = abs(value);
-        } else {
-            remainder = ident[id].input[i];
-        }
-        divider = 1;
+		for(digitCount = 1; digitCount < ident[localId].size[i]; digitCount++)
+			divider *= 10;
 
-        for(digitCount = 1; digitCount < ident[id].size[i]; digitCount++)
-            divider *= 10;
+		for(digitCount = 0; digitCount < ident[localId].size[i]; digitCount++)
+		{
+			if (isSigned && digitCount == 0) {
+				ident[localId].newText[ident[localId].begin[i] + digitCount] = isNegative ? '-' : '+';
+			} else {
+				digit = remainder	/ divider;
+				remainder -= digit * divider;
+				if(digit < 10)
+					ident[localId].newText[ident[localId].begin[i] + digitCount] = digit + '0';
+				else
+					ident[localId].newText[ident[localId].begin[i] + digitCount] = 'x';
+			}
 
-        for(digitCount = 0; digitCount < ident[id].size[i]; digitCount++)
-        {
-            if (isSigned && digitCount == 0) {
-                ident[id].newText[ident[id].begin[i] + digitCount] = isNegative ? '-' : '+';
-            } else {
-                digit = remainder	/ divider;
-                remainder -= digit * divider;
-                if(digit < 10)
-                    ident[id].newText[ident[id].begin[i] + digitCount] = digit + '0';
-                else
-                    ident[id].newText[ident[id].begin[i] + digitCount] = 'x';
-            }
+			divider /= 10;
+		}
+		i++;
+	}
+}
 
-            divider /= 10;
-        }
-        i++;
-    }
+void create_newText_for_actual_Id(void)
+{
+    create_newText_for_Id(actualId);
 }
 
 
@@ -1306,18 +1320,25 @@
 }
 
 
+void write_content_of_Id(int8_t localId)
+{
+    write_content( ident[localId].coord[0], ident[localId].coord[1], ident[localId].coord[2], ident[localId].fontUsed, ident[localId].newText, (CLUT_MenuEditField0 + localId));
+}
 void write_content_of_actual_Id(void)
 {
-    write_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed, ident[id].newText, (CLUT_MenuEditField0 + id));
+	write_content_of_Id(actualId);
 }
 
+void clean_content_of_Id(int8_t localId)
+{
+    clean_content( ident[localId].coord[0], ident[localId].coord[1], ident[localId].coord[2], ident[localId].fontUsed);
+}
 
 void clean_content_of_actual_Id(void)
 {
-    clean_content( ident[id].coord[0], ident[id].coord[1], ident[id].coord[2], ident[id].fontUsed);
+	clean_content_of_Id(actualId);
 }
 
-
 void write_field_udigit_and_2digit(uint8_t subtype, uint32_t editID, uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint32_t int1,  uint32_t int2,  uint32_t int3,  uint32_t int4)
 {
     if(id >= 9)
@@ -1375,13 +1396,13 @@
     else
         change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditInfo);
 
-    create_newText_for_actual_Id();
+    create_newText_for_Id(id);
 
     if(editID == 0)
-        write_content_without_Id();
+    	write_content_without_Id();
     else
     {
-        write_content_of_actual_Id();
+        write_content_of_Id(id);
         if(!tME_stop)
             idLast = id;
         id++;
@@ -1458,13 +1479,13 @@
 
     change_CLUT_entry((CLUT_MenuEditField0 + id), CLUT_MenuEditFieldRegular);
 
-    create_newText_for_actual_Id();
+    create_newText_for_Id(id);
 
     if(editID == 0)
-        write_content_without_Id();
+    	write_content_without_Id();
     else
     {
-        write_content_of_actual_Id();
+        write_content_of_Id(id);
         if(!tME_stop)
             idLast = id;
         id++;
@@ -1496,7 +1517,7 @@
         write_content_without_Id();
     else
     {
-        write_content_of_actual_Id();
+        write_content_of_Id(id);
         if(!tME_stop)
             idLast = id;
         id++;
@@ -1534,7 +1555,7 @@
         write_content_without_Id();
     else
     {
-        write_content_of_actual_Id();
+        write_content_of_Id(id);
         if(!tME_stop)
             idLast = id;
         id++;
@@ -1560,7 +1581,7 @@
 	if(editID == 0) write_content_without_Id();
 	  else
 	{
-	      write_content_of_actual_Id();
+	      write_content_of_Id(id);
 	      if(!tME_stop) idLast = id;
 	        id++;
 	}
@@ -1619,7 +1640,7 @@
         write_content_without_Id();
     else
     {
-        write_content_of_actual_Id();
+        write_content_of_Id(id);
         if(!tME_stop)
             idLast = id;
         id++;
@@ -1652,7 +1673,7 @@
         write_content_without_Id();
     else
     {
-        write_content_of_actual_Id();
+        write_content_of_Id(id);
         if(!tME_stop)
             idLast = id;
         id++;
@@ -1673,12 +1694,13 @@
     if(evidLast >= 9)
         return;
 
+#if 0
     /* set cursor to first field */
     if(evidLast < 0)
     {
         startMenuEditFieldSelect();
     }
-
+#endif
     event[evid].callerID = inputEventID;
     event[evid].pEventFunction = inputFunctionCall;
 
--- a/Discovery/Src/tMenuEditCustom.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tMenuEditCustom.c	Wed Aug 14 16:44:46 2024 +0200
@@ -57,12 +57,14 @@
 void openEdit_MotionCtrl(void);
 void openEdit_ViewPort(void);
 void refresh_Customviews(void);
+void setMenuContentStructure();
 char customview_TXT2BYTE_helper(uint8_t customViewId);
 char customviewBF_TXT2BYTE_helper(uint8_t customViewId);
 /* Announced function prototypes -----------------------------------------------*/
 uint8_t OnAction_CViewTimeout  (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_CViewStandard (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_CViewStandardBF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+uint8_t OnAction_CViewAutofocusBF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_CornerTimeout (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_CornerStandard(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_CViewPortCalib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
@@ -115,6 +117,16 @@
     text[6] = 0;
     write_label_var(  30, 700, ME_Y_LINE3, &FontT48, text);
 
+    /* Bigfont autofocus selector */
+    textpointer = 0;
+    text[textpointer++] = TXT_2BYTE;
+    text[textpointer++] = TXT2BYTE_ExtraDisplay;
+    textpointer += snprintf(&text[textpointer],20,"  %c%c",TXT_2BYTE, TXT2BYTE_Autofocus);
+    write_label_var(  30, 700, ME_Y_LINE4, &FontT48, text);
+
+    tMenuEdit_refresh_field(StMCustom1_CViewAutoFocusBF);
+
+
     // field corner  return
     textpointer = 0;
     text[textpointer++] = TXT_2BYTE;
@@ -377,14 +389,14 @@
     write_field_button(StMCustom1_CViewTimeout,		400, 700, ME_Y_LINE1,  &FontT48, "");
     write_field_button(StMCustom1_CViewStandard,	400, 700, ME_Y_LINE2,  &FontT48, "");
     write_field_button(StMCustom1_CViewStandardBF,	400, 700, ME_Y_LINE3,  &FontT48, "");
-
+    write_field_on_off(StMCustom1_CViewAutoFocusBF,	650, 700, ME_Y_LINE4,  &FontT48, "", settingsGetPointer()->cvAutofocus);
     write_field_button(StMCustom1_CornerTimeout,	400, 700, ME_Y_LINE5,  &FontT48, "");
     write_field_button(StMCustom1_CornerStandard,	400, 700, ME_Y_LINE6,  &FontT48, "");
 
     setEvent(StMCustom1_CViewTimeout,		(uint32_t)OnAction_CViewTimeout);
     setEvent(StMCustom1_CViewStandard,		(uint32_t)OnAction_CViewStandard);
     setEvent(StMCustom1_CViewStandardBF,	(uint32_t)OnAction_CViewStandardBF);
-
+    setEvent(StMCustom1_CViewAutoFocusBF,	(uint32_t)OnAction_CViewAutofocusBF);
     setEvent(StMCustom1_CornerTimeout,		(uint32_t)OnAction_CornerTimeout);
     setEvent(StMCustom1_CornerStandard,		(uint32_t)OnAction_CornerStandard);
 }
@@ -522,6 +534,9 @@
         text = TXT2BYTE_Profile;
         break;
 #endif
+    case CVIEW_T3_Temperature:
+    	text = TXT2BYTE_AmbientTemperature;
+    	break;
     case CVIEW_T3_GasList:
         text = TXT2BYTE_Gaslist;
         break;
@@ -646,6 +661,20 @@
     return UPDATE_DIVESETTINGS;
 }
 
+uint8_t OnAction_CViewAutofocusBF(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+{
+	SSettings *pSettings = settingsGetPointer();
+	if(pSettings->cvAutofocus)
+	{
+		pSettings->cvAutofocus = 0;
+	}
+	else
+	{
+		pSettings->cvAutofocus = 1;
+	}
+	tMenuEdit_set_on_off(editId, pSettings->cvAutofocus);
+	return UPDATE_DIVESETTINGS;
+}
 
 uint8_t OnAction_CornerTimeout(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
@@ -733,11 +762,20 @@
 
 uint8_t OnAction_Customview_NextPage(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
+	resetMenuContentStructure();
 	customviewsSubpage++;
+
 	if(customviewsSubpage == customviewsSubpageMax)
 	{
 		customviewsSubpage = 0;
+		setMenuContentStructure();
+		tMenuEdit_select(StMCustom3_CViewSelection6);
 	}
+	else
+	{
+		setMenuContentStructure();
+	}
+
 	CustomviewDivemode_refresh();
     return UPDATE_DIVESETTINGS;
 }
@@ -828,45 +866,39 @@
     return UPDATE_DIVESETTINGS;
 }
 
-void openEdit_CustomviewDivemode(const uint8_t* pcv_changelist)
+void setMenuContentStructure()
 {
-
-	SSettings *pSettings = settingsGetPointer();
 	char text[MAX_PAGE_TEXTSIZE];
 	uint8_t textPointer = 0;
 	uint32_t id;
 
     uint8_t i;
-
-    resetMenuEdit(CLUT_MenuPageCustomView);
-	customviewsSubpageMax = (tHome_getNumberOfAvailableCVs(pcv_changelist) / CV_PER_PAGE) + 1;
+    uint8_t endID = CVIEW_END;
+	SSettings *pSettings = settingsGetPointer();
 
-	if(pcv_curchangelist != pcv_changelist)		/* new selection base? => reset page index */
-	{
-		customviewsSubpage = 0;
-	}
-	pcv_curchangelist = pcv_changelist;
-
-	CustomviewDivemode_refresh(pcv_changelist);
+    if(pcv_curchangelist == cv_changelist_BS)
+    {
+    	endID = CVIEW_T3_END;
+    }
 
-     for(i=0; i<5;i++)		/* fill maximum 5 items and leave last one for sub page selection */
-     {
-    	textPointer = 0;
-     	id = pcv_changelist[customviewsSubpage * 5 + i];
-     	if((id == CVIEW_END) || (id == CVIEW_T3_END))	/* last list item? */
-     	{
-     		break;
-     	}
-     	else
-     	{
-     			if(pcv_changelist == cv_changelist)
-     			{
-     				text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_configuration,id);
-     			}
-     			else
-     			{
-     				text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_config_BigScreen,id);
-     			}
+    for(i=0; i<5;i++)		/* fill maximum 5 items and leave last one for sub page selection */
+    {
+   	textPointer = 0;
+    	id = pcv_curchangelist[customviewsSubpage * 5 + i];
+    	if(id == endID) /* last list item? */
+    	{
+    		break;
+    	}
+    	else
+    	{
+    			if(pcv_curchangelist == cv_changelist)
+    			{
+    				text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_configuration,id);
+    			}
+    			else
+    			{
+    				text[textPointer++] = '\006' - CHECK_BIT_THOME(pSettings->cv_config_BigScreen,id);
+    			}
 				text[textPointer++] = ' ';
 				textPointer += snprintf(&text[textPointer], 60,	"%c%c\n\r",	TXT_2BYTE, customview_TXT2BYTE_helper(id));
 
@@ -885,45 +917,46 @@
 					default:
 						break;
 				}
-     	}
-     }
-     for(;i<5;i++)	/* clear empty lines in case menu shows less than 5 entries */
-     {
-			switch(i)
-			{
-				case 0: 	write_label_var( 30, 800, ME_Y_LINE1, &FontT48, "");
-					break;
-				case 1:		write_label_var( 30, 800, ME_Y_LINE2, &FontT48, "");
-					break;
-				case 2: 	write_label_var( 30, 800, ME_Y_LINE3, &FontT48, "");
-					break;
-				case 3: 	write_label_var( 30, 800, ME_Y_LINE4, &FontT48, "");
-					break;
-				case 4: 	write_label_var( 30, 800, ME_Y_LINE5, &FontT48, "");
-					break;
-				default:
-					break;
-			};
-     }
-     if(customviewsSubpageMax != 1)
-     {
-         textPointer = 0;
-         text[textPointer++] = TXT_2BYTE;
-         text[textPointer++] = TXT2BYTE_ButtonNext;
-         text[textPointer] = 0;
-    	 write_field_button(StMCustom3_CViewSelection6,	30, 800, ME_Y_LINE6,  &FontT48, text);
-     }
+    	}
+    }
+    for(;i<5;i++)	/* clear empty lines in case menu shows less than 5 entries */
+    {
+		switch(i)
+		{
+			case 0: 	write_label_var( 30, 800, ME_Y_LINE1, &FontT48, "");
+				break;
+			case 1:		write_label_var( 30, 800, ME_Y_LINE2, &FontT48, "");
+				break;
+			case 2: 	write_label_var( 30, 800, ME_Y_LINE3, &FontT48, "");
+				break;
+			case 3: 	write_label_var( 30, 800, ME_Y_LINE4, &FontT48, "");
+				break;
+			case 4: 	write_label_var( 30, 800, ME_Y_LINE5, &FontT48, "");
+				break;
+			default:
+				break;
+		};
+    }
 
-     /* because of the ID handling inside of the functions, all buttons needs to be assigned before the events may be set => have the same loop twice */
-     for(i=0; i<5;i++)		/* fill maximum 5 items and leave last one for sub page selection */
-     {
-     	id = pcv_changelist[customviewsSubpage * 5 + i];
-     	if((id == CVIEW_END) || (id == CVIEW_T3_END))	/* last list item? */
-     	{
-     		break;
-     	}
-     	else
-     	{
+    if(customviewsSubpageMax != 1)
+    {
+        textPointer = 0;
+        text[textPointer++] = TXT_2BYTE;
+        text[textPointer++] = TXT2BYTE_ButtonNext;
+        text[textPointer] = 0;
+   	 write_field_button(StMCustom3_CViewSelection6,	30, 800, ME_Y_LINE6,  &FontT48, text);
+    }
+
+    /* because of the ID handling inside of the functions, all buttons needs to be assigned before the events may be set => have the same loop twice */
+    for(i=0; i<5;i++)		/* fill maximum 5 items and leave last one for sub page selection */
+    {
+    	id = pcv_curchangelist[customviewsSubpage * 5 + i];
+    	if(id == endID)		/* last list item? */
+    	{
+    		break;
+    	}
+    	else
+    	{
 				switch(i)
 				{
 					case 0: 	setEvent(StMCustom3_CViewSelection1, 				(uint32_t)OnAction_Customview_Toggle);
@@ -941,14 +974,27 @@
 						break;
 				}
 
-     	}
-     }
-     if(customviewsSubpageMax != 1)
-     {
-    	 setEvent(StMCustom3_CViewSelection6,(uint32_t)OnAction_Customview_NextPage);
-     }
+    	}
+    }
+    if(customviewsSubpageMax != 1)
+    {
+   	 setEvent(StMCustom3_CViewSelection6,(uint32_t)OnAction_Customview_NextPage);
+    }
+}
+void openEdit_CustomviewDivemode(const uint8_t* pcv_changelist)
+{
+    resetMenuEdit(CLUT_MenuPageCustomView);
+	customviewsSubpageMax = (tHome_getNumberOfAvailableCVs(pcv_changelist) / CV_PER_PAGE) + 1;
 
-     write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
+	if(pcv_curchangelist != pcv_changelist)		/* new selection base? => reset page index */
+	{
+		customviewsSubpage = 0;
+	}
+	pcv_curchangelist = pcv_changelist;
+
+	setMenuContentStructure();
+
+    write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
 }
 
 void openEdit_CustomviewDivemodeMenu(uint8_t line)
@@ -1004,6 +1050,12 @@
 	uint32_t id;
 
     uint8_t i;
+    uint8_t endID = CVIEW_END;
+
+    if(pcv_curchangelist == cv_changelist_BS)
+    {
+    	endID = CVIEW_T3_END;
+    }
 
     text[textPointer++] = '\001';
     text[textPointer++] = TXT_2BYTE;
@@ -1018,7 +1070,7 @@
      {
     	textPointer = 0;
      	id = pcv_curchangelist[customviewsSubpage * 5 + i];
-     	if((id == CVIEW_END) || (id == CVIEW_T3_END))	/* last list item? */
+     	if(id == endID)	/* last list item? */
      	{
      		break;
      	}
--- a/Discovery/Src/tMenuEditGasOC.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tMenuEditGasOC.c	Wed Aug 14 16:44:46 2024 +0200
@@ -66,6 +66,7 @@
 uint8_t OnAction_GasType		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_ChangeDepth	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_SetToMOD		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+uint8_t OnAction_CalcDeco		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_BottleSize		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 
 uint8_t OnAction_First			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
@@ -204,11 +205,8 @@
     	return;
     }
 #endif
-    for(int i=0;i<(1+ (2*NUM_GASES));i++)
-        editGasPage.pGasLine[i].note.ub.first = 0;
 
     editGasPage.pGasLine[editGasPage.gasID].note.ub.active = 1;
-    editGasPage.pGasLine[editGasPage.gasID].note.ub.first = 1;
     setActualGas_DM(&stateUsedWrite->lifeData,editGasPage.gasID,setpoint);
 }
 
@@ -385,7 +383,7 @@
 /* surface mode */
 void openEdit_Gas(uint8_t line, uint8_t ccr)
 {
-    uint8_t gasID, oxygen, helium, depthDeco, active, first, depthMOD, deco, travel, inactive, off;//, bottleSizeLiter;
+    uint8_t gasID, oxygen, helium, depthDeco, active, first, depthMOD, deco, travel, inactive, off, decocalc;//, bottleSizeLiter;
 
     char text[32];
     char textMOD[32];
@@ -424,6 +422,7 @@
     deco = editGasPage.pGasLine[gasID].note.ub.deco;
     travel = editGasPage.pGasLine[gasID].note.ub.travel;
     off = editGasPage.pGasLine[gasID].note.ub.off;
+    decocalc = editGasPage.pGasLine[gasID].note.ub.decocalc;
     //bottleSizeLiter = editGasPage.pGasLine[gasID].bottle_size_liter;
 
     if(active)
@@ -480,11 +479,19 @@
         write_field_button(StMOG_GasType,	20, 710, ME_Y_LINE2, &FontT48, text);
 
 
-        if(deco)
+        if((deco) || (travel && ccr))
         {
             text[0] = TXT_ChangeDepth;
             text[1] = ' ';
-            text[2] = TXT_Deco;
+
+			if(deco)
+			{
+				text[2] = TXT_Deco;
+			}
+			else
+			{
+				text[2] = TXT_Travel;
+			}
             text[3] = 0;
             write_label_var(  20 ,800, ME_Y_LINE3, &FontT48, text);
 
@@ -501,6 +508,16 @@
             text[txtptr++] = TXT2BYTE_SetToMOD;
             text[txtptr++] = 0;
             write_field_button(StMOG_SetToMOD,		20, 710, ME_Y_LINE4, &FontT48,text);
+
+            if(deco)
+            {
+				txtptr = 0;
+				text[txtptr++] = TXT_2BYTE;
+				text[txtptr++] = TXT2BYTE_CalculateDeco;
+				text[txtptr++] = 0;
+
+				write_field_on_off(StMOG_CalcDeco, 20, 710, ME_Y_LINE5, &FontT48, text, decocalc);
+            }
         }
         else
         {
@@ -547,11 +564,15 @@
         setEvent(StMOG_Mix, 					(uint32_t)OnAction_Mix);
         setEvent(StMOG_GasType,				(uint32_t)OnAction_GasType);
 
-        if(deco)
+        if((deco) || (travel && ccr))
         {
             setEvent(StMOG_ChangeDepth,		(uint32_t)OnAction_ChangeDepth);
             setEvent(StMOG_SetToMOD,		(uint32_t)OnAction_SetToMOD);
         }
+        if(deco)
+        {
+        	setEvent(StMOG_CalcDeco,		(uint32_t)OnAction_CalcDeco);
+        }
 /*
         setEvent(StMOG_Bottle, 				(uint32_t)OnAction_BottleSize);
 */
@@ -1091,12 +1112,33 @@
 {
     uint8_t newChangeDepth = editGasPage.mod;
 
-    editGasPage.pGasLine[editGasPage.gasID].depth_meter = newChangeDepth;
+    if(editGasPage.pGasLine[editGasPage.gasID].note.ub.travel)
+    {
+    	editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel= newChangeDepth;
+    }
+    else
+    {
+    	editGasPage.pGasLine[editGasPage.gasID].depth_meter = newChangeDepth;
+    }
     tMenuEdit_newInput(StMOG_ChangeDepth, unit_depth_integer(newChangeDepth), 0, 0, 0);
 
     return UPDATE_DIVESETTINGS;
 }
 
+uint8_t OnAction_CalcDeco	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+{
+    if(editGasPage.pGasLine[editGasPage.gasID].note.ub.decocalc)
+    {
+    	editGasPage.pGasLine[editGasPage.gasID].note.ub.decocalc = 0;
+    }
+    else
+    {
+    	editGasPage.pGasLine[editGasPage.gasID].note.ub.decocalc = 1;
+    }
+    tMenuEdit_set_on_off(editId, editGasPage.pGasLine[editGasPage.gasID].note.ub.decocalc);
+
+    return UPDATE_DIVESETTINGS;
+}
 
 uint8_t OnAction_ChangeDepth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
@@ -1117,7 +1159,15 @@
         }
         if(newDepth > 255)
             newDepth = 255;
-        editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth;
+
+        if(editGasPage.pGasLine[editGasPage.gasID].note.ub.travel)
+        {
+        	editGasPage.pGasLine[editGasPage.gasID].depth_meter_travel = newDepth;
+        }
+        else
+        {
+        	editGasPage.pGasLine[editGasPage.gasID].depth_meter = newDepth;
+        }
         tMenuEdit_newInput(editId, unit_depth_integer(newDepth), 0, 0, 0);
         return UPDATE_DIVESETTINGS;
     }
--- a/Discovery/Src/tMenuEditHardware.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tMenuEditHardware.c	Wed Aug 14 16:44:46 2024 +0200
@@ -285,6 +285,10 @@
     char text[10];
     uint8_t textIndex = 0;
 
+
+    set_globalState(StMHARD2_Compass);
+    resetMenuEdit(CLUT_MenuPageHardware);
+
     text[textIndex++] = '\001';
     text[textIndex++] = TXT_2BYTE;
     text[textIndex++] = TXT2BYTE_Compass;
@@ -320,6 +324,8 @@
     setEvent(StMHARD2_Compass_Inertia,	(uint32_t)OnAction_InertiaLevel);
     setEvent(StMHARD2_Compass_Declination, (uint32_t)OnAction_CompassDeclination);
 
+    tMenuEdit_select(StMHARD2_Compass_SetCourse);
+
     write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
 }
 
@@ -389,9 +395,9 @@
 	{
 		memcpy(pSettings->ext_sensor_map, pStateReal->lifeData.extIf_sensor_map, EXT_INTERFACE_SENSOR_CNT);
 		pSettings->ppo2sensors_deactivated = 0x0;	/* deactivation will be done by openEditO2Sensor if need */
-
+		pSettings->co2_sensor_active = 0;
 		pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_OPTIC;
-		for(index = 0; index < 3; index++)
+		for(index = 0; index < EXT_INTERFACE_SENSOR_CNT - 1; index++)
 		{
 				switch(pSettings->ext_sensor_map[index])
 				{
@@ -415,8 +421,12 @@
 											pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_DIGITAL;
 										}
 									break;
+					case SENSOR_CO2:
+					case SENSOR_CO2M:	pSettings->co2_sensor_active = 1;
+						break;
 #ifdef ENABLE_SENTINEL_MODE
-					case SENSOR_SENTINEL:	pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_SENTINEL;
+					case SENSOR_SENTINEL:
+					case SENSOR_SENTINELM:	pSettings->ppo2sensors_source = O2_SENSOR_SOURCE_SENTINEL;
 									break;
 #endif
 					default:
@@ -462,7 +472,8 @@
 				case SENSOR_CO2M: strSensorId[3] = 'C';
 								 strSensorId[4] = 'O';
 								break;
-				case SENSOR_SENTINEL: strSensorId[3] = 'S';
+				case SENSOR_SENTINEL:
+				case SENSOR_SENTINELM: strSensorId[3] = 'S';
 				 	 	 	 	 	  strSensorId[4] = 'e';
 				 	 	 	 	break;
 				default:
@@ -524,15 +535,15 @@
 		write_label_var(  30, 340, ME_Y_LINE6, &FontT48, strSensorId);
    	}
 
-	if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_TYPE_O2_END))
+	if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_MUX))
 	{
 		tMenuEdit_refresh_field(StMHARD3_O2_Sensor1);
 	}
-	if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_TYPE_O2_END))
+	if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_MUX))
 	{
 		tMenuEdit_refresh_field(StMHARD3_O2_Sensor2);
 	}
-	if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_TYPE_O2_END))
+	if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_MUX))
 	{
 		tMenuEdit_refresh_field(StMHARD3_O2_Sensor3);
 	}
@@ -570,7 +581,7 @@
 		}
 	}
 
-	if(((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] >= SENSOR_TYPE_O2_END)))
+	if(((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] >= SENSOR_MUX)))
 	{
 		pSettings->ppo2sensors_deactivated |= 1;
 	}
@@ -578,7 +589,7 @@
 	{
 		write_field_on_off(StMHARD3_O2_Sensor1,	 30, 95, ME_Y_LINE1,  &FontT48, "", sensorActive[0]);
 	}
-	if(((pSettings->ext_sensor_map[1] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[1] >= SENSOR_TYPE_O2_END)))
+	if(((pSettings->ext_sensor_map[1] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[1] >= SENSOR_MUX)))
 	{
 		pSettings->ppo2sensors_deactivated |= 2;
 	}
@@ -586,7 +597,7 @@
 	{
 		 write_field_on_off(StMHARD3_O2_Sensor2,	 30, 95, ME_Y_LINE2,  &FontT48, "", sensorActive[1]);
 	}
-	if(((pSettings->ext_sensor_map[2] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[2] >= SENSOR_TYPE_O2_END)))
+	if(((pSettings->ext_sensor_map[2] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[2] >= SENSOR_MUX)))
 	{
 		pSettings->ppo2sensors_deactivated |= 4;
 	}
@@ -627,15 +638,15 @@
 		write_field_button(StMHARD3_Sensor_Detect,	 30, 800, ME_Y_LINE6,  &FontT48, text);
    	}
 
-    if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_TYPE_O2_END))
+    if((pSettings->ext_sensor_map[0] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[0] < SENSOR_MUX))
 	{
 			setEvent(StMHARD3_O2_Sensor1, (uint32_t)OnAction_Sensor1);
 	}
-    if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_TYPE_O2_END))
+    if((pSettings->ext_sensor_map[1] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[1] < SENSOR_MUX))
 	{
 			setEvent(StMHARD3_O2_Sensor2, (uint32_t)OnAction_Sensor2);
 	}
-    if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_TYPE_O2_END))
+    if((pSettings->ext_sensor_map[2] >= SENSOR_OPTIC) && (pSettings->ext_sensor_map[2] < SENSOR_MUX))
 	{
 			setEvent(StMHARD3_O2_Sensor3, (uint32_t)OnAction_Sensor3);
 	}
@@ -661,7 +672,7 @@
 {
 	const SDiveState *pStateReal = stateRealGetPointer();
 
-	if(pStateReal->lifeData.extIf_sensor_map[0] == SENSOR_DIGO2M)
+	if((pStateReal->lifeData.extIf_sensor_map[0] == SENSOR_DIGO2M) || (pStateReal->lifeData.extIf_sensor_map[0] == SENSOR_CO2M))
 	{
 		return EXIT_TO_INFO_SENSOR;
 	}
@@ -687,7 +698,7 @@
 {
 	const SDiveState *pStateReal = stateRealGetPointer();
 
-	if(pStateReal->lifeData.extIf_sensor_map[1] == SENSOR_DIGO2M)
+	if((pStateReal->lifeData.extIf_sensor_map[1] == SENSOR_DIGO2M) || (pStateReal->lifeData.extIf_sensor_map[1] == SENSOR_CO2M))
 	{
 		return EXIT_TO_INFO_SENSOR;
 	}
@@ -712,7 +723,7 @@
 {
 	const SDiveState *pStateReal = stateRealGetPointer();
 
-	if(pStateReal->lifeData.extIf_sensor_map[2] == SENSOR_DIGO2M)
+	if((pStateReal->lifeData.extIf_sensor_map[2] == SENSOR_DIGO2M) || (pStateReal->lifeData.extIf_sensor_map[2] == SENSOR_CO2M))
 	{
 		return EXIT_TO_INFO_SENSOR;
 	}
--- a/Discovery/Src/tMenuEditPlanner.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tMenuEditPlanner.c	Wed Aug 14 16:44:46 2024 +0200
@@ -449,7 +449,8 @@
 
     for(int i = 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
     {
-        if(stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+        if((stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+        	|| (stateSimGetPointer()->diveSettings.gas[stateSimGetPointer()->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
                 break;
         depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero;
         if(depthPrev <= depthChange)
@@ -464,7 +465,8 @@
 
     for(int i = GasIdPrev + 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
     {
-            if(stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            if((stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero == 0)
+            	|| (stateSimGetPointer()->diveSettings.gas[stateSimGetPointer()->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
                     break;
             depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero;
             if((depthChange < depthPrev) && (depthChange >= depthNext))
--- a/Discovery/Src/tMenuEditSystem.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tMenuEditSystem.c	Wed Aug 14 16:44:46 2024 +0200
@@ -52,6 +52,7 @@
 void openEdit_Design(void);
 void openEdit_Information(void);
 void openEdit_Reset(void);
+void openEdit_Maintenance(void);
 //void openEdit_ShowDebugInfo(void);
 //void openEdit_Salinity(void);
 
@@ -78,6 +79,7 @@
 
 uint8_t OnAction_Exit					(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_Confirm			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+uint8_t OnAction_Maintenance			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_RebootRTE				(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_ResetDeco		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_ResetAll			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
@@ -87,6 +89,7 @@
 uint8_t OnAction_LogbookOffset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_SetFactoryDefaults(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 uint8_t OnAction_SetBatteryCharge(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
+uint8_t OnAction_AdjustSurfacePressure		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 #ifdef ENABLE_ANALYSE_SAMPLES
 uint8_t OnAction_RecoverSampleIdx(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 #endif
@@ -835,6 +838,7 @@
     write_field_button(StMSYS4_Info, 30, 800, ME_Y_LINE6,  &FontT48, text);
 
     setEvent(StMSYS4_Info, (uint32_t)OnAction_Information);
+    tMenuEdit_select(StMSYS4_Info);
 }
 
 
@@ -1075,7 +1079,7 @@
     setEvent(StMSYS5_ResetAll, 			(uint32_t)OnAction_Confirm);
     setEvent(StMSYS5_ResetDeco, 		(uint32_t)OnAction_Confirm);
     setEvent(StMSYS5_Reboot, 				(uint32_t)OnAction_Confirm);
-    setEvent(StMSYS5_Maintenance,		(uint32_t)OnAction_Confirm);
+    setEvent(StMSYS5_Maintenance,		(uint32_t)OnAction_Maintenance);
 #ifndef RESETLOGBLOCK
     setEvent(StMSYS5_ResetLogbook,	(uint32_t)OnAction_Confirm);
 #else
@@ -1150,64 +1154,92 @@
         setEvent(StMSYS5_Exit, (uint32_t)OnAction_Exit);
         setEvent(editIdOfCaller, (uint32_t)OnAction_ResetLogbook);
         break;
+    }
 
-    case StMSYS5_Maintenance:
-    case StMSYS5_SetBattCharge:
-    case StMSYS5_SetSampleIndx:
+    write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
+}
+
+void openEdit_Maintenance(void)
+{
+    char text[32];
+    unsigned char index = 0;
+    SSettings *pSettings = settingsGetPointer();
+    SSensorDataDiveO2* pDiveO2Data = NULL;
+
+    resetMenuEdit(CLUT_MenuPageSystem);
+
+    text[0] = '\001';
+    text[1] = TXT_2BYTE;
+    text[2] = TXT2BYTE_Maintenance;
+    text[3] = 0;
+    write_topline(text);
+
+    text[0] = TXT_2BYTE;
+    text[1] = TXT2BYTE_SetFactoryDefaults;
+    text[2] = 0;
+    write_field_button(StMSYS5_SetFactoryBC,			30, 800, ME_Y_LINE1,  &FontT48, text);
+
+
+    if(stateRealGetPointer()->lifeData.battery_charge <= 0)
+    {
         text[0] = TXT_2BYTE;
-        text[1] = TXT2BYTE_SetFactoryDefaults;
+        text[1] = TXT2BYTE_SetBatteryCharge;
         text[2] = 0;
-        write_field_button(StMSYS5_SetFactoryBC,			30, 800, ME_Y_LINE2,  &FontT48, text);
+        snprintf(&text[2],10,": %u%%",pSettings->lastKnownBatteryPercentage);
+        write_field_button(StMSYS5_SetBattCharge,			30, 800, ME_Y_LINE2,  &FontT48, text);
+    }
+
+    if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL))
+    {
+    	for (index = 0; index < 3; index++)
+    	{
+    		if(pSettings->ext_sensor_map[index] == SENSOR_DIGO2M)
+    		{
+    			pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data[index];
+    			if(pDiveO2Data->pressure != 0)
+    			{
+					snprintf(text,32,"%c%c (%1.3lf => %1.3f)\016\016Bar",TXT_2BYTE,TXT2BYTE_AdjustAmbPressure,(float)(pDiveO2Data->pressure/1000000.0),
+																stateRealGetPointer()->lifeData.pressure_surface_bar);
+
+					write_field_button(StMSYS5_AdjustSurfPres,			30, 800, ME_Y_LINE4,  &FontT48, text);
+    			}
+     			break;
+    		}
+    	}
+    }
 
 #ifdef ENABLE_ANALYSE_SAMPLES
-        text[0] = TXT_2BYTE;
-        text[1] = TXT2BYTE_SetSampleIndex;
-        text[2] = 0;
-        write_field_button(StMSYS5_SetSampleIndx,			30, 800, ME_Y_LINE3,  &FontT48, text);
+    text[0] = TXT_2BYTE;
+    text[1] = TXT2BYTE_SetSampleIndex;
+    text[2] = 0;
+    write_field_button(StMSYS5_SetSampleIndx,			30, 800, ME_Y_LINE4,  &FontT48, text);
+#endif
+
+    setEvent(StMSYS5_SetFactoryBC, (uint32_t)OnAction_SetFactoryDefaults);
+    if(stateRealGetPointer()->lifeData.battery_charge <= 0)
+    {
+    	setEvent(StMSYS5_SetBattCharge, (uint32_t)OnAction_SetBatteryCharge);
+    }
+    if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL))
+    {
+    	if(pDiveO2Data != NULL)
+    	{
+    		setEvent(StMSYS5_AdjustSurfPres, (uint32_t)OnAction_AdjustSurfacePressure);
+    	}
+    }
+#ifdef ENABLE_ANALYSE_SAMPLES
+    setEvent(StMSYS5_SetSampleIndx, (uint32_t)OnAction_RecoverSampleIdx);
 #endif
 
 
-        if(stateRealGetPointer()->lifeData.battery_charge <= 0)
-        {
-            text[0] = TXT_2BYTE;
-            text[1] = TXT2BYTE_SetBatteryCharge;
-            text[2] = 0;
-            snprintf(&text[2],10,": %u%%",settingsGetPointer()->lastKnownBatteryPercentage);
-#ifdef ENABLE_ANALYSE_SAMPLES
-            write_field_button(StMSYS5_SetBattCharge,			30, 800, ME_Y_LINE4,  &FontT48, text);
-#else
-            write_field_button(StMSYS5_SetBattCharge,			30, 800, ME_Y_LINE3,  &FontT48, text);
-#endif
+    text[0] = TXT_2BYTE;
+    text[1] = TXT2BYTE_WarnBatteryLow;
+    text[2] = 0;
+    snprintf(&text[2],10,": %01.2fV",stateRealGetPointer()->lifeData.battery_voltage);
+    write_label_var(  30, 800, ME_Y_LINE5, &FontT42, text);
 
-            setEvent(StMSYS5_Exit, (uint32_t)OnAction_Exit);
-            setEvent(StMSYS5_SetFactoryBC, (uint32_t)OnAction_SetFactoryDefaults);
-#ifdef ENABLE_ANALYSE_SAMPLES
-            setEvent(StMSYS5_SetSampleIndx, (uint32_t)OnAction_RecoverSampleIdx);
-#endif
-            setEvent(StMSYS5_SetBattCharge, (uint32_t)OnAction_SetBatteryCharge);
-        }
-        else
-        {
-            setEvent(StMSYS5_Exit, (uint32_t)OnAction_Exit);
-            setEvent(StMSYS5_SetFactoryBC, (uint32_t)OnAction_SetFactoryDefaults);
-#ifdef ENABLE_ANALYSE_SAMPLES
-            setEvent(StMSYS5_SetSampleIndx, (uint32_t)OnAction_RecoverSampleIdx);
-#endif
-        }
-//		write_field_button(StMSYS5_ScreenTest,			30, 800, ME_Y_LINE3,  &FontT48, "Screen Test");
-//		setEvent(StMSYS5_ScreenTest, (uint32_t)OnAction_ScreenTest);
-
-        text[0] = TXT_2BYTE;
-        text[1] = TXT2BYTE_WarnBatteryLow;
-        text[2] = 0;
-        snprintf(&text[2],10,": %01.2fV",stateRealGetPointer()->lifeData.battery_voltage);
-        write_label_var(  30, 800, ME_Y_LINE5, &FontT42, text);
-        
-        snprintf(&text[0],30,"Code: %X",getLicence());
-        write_label_var(  30, 800, ME_Y_LINE6, &FontT42, text);
-        break;
-
-    }
+    snprintf(&text[0],30,"Code: %X",getLicence());
+    write_label_var(  30, 800, ME_Y_LINE6, &FontT42, text);
 
     write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
 }
@@ -1263,6 +1295,12 @@
     return UNSPECIFIC_RETURN;
 }
 
+uint8_t OnAction_Maintenance			(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+{
+	openEdit_Maintenance();
+    return UNSPECIFIC_RETURN;
+}
+
 uint8_t OnAction_RebootRTE				(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
     MX_SmallCPU_Reset_To_Standard();
@@ -1335,6 +1373,43 @@
     return EXIT_TO_MENU;
 }
 
+uint8_t OnAction_AdjustSurfacePressure		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
+{
+    SSensorDataDiveO2* pDiveO2Data;
+    const SDiveState* pDiveState = stateRealGetPointer();
+    SSettings* pSettings = settingsGetPointer();
+    uint8_t index = 0;
+    int8_t newOffset = 0;
+
+    char text[32];
+
+    float orgpressure_surface;
+
+    for (index = 0; index < 3; index++)
+    {
+    	if(settingsGetPointer()->ext_sensor_map[index] == SENSOR_DIGO2M)
+    	{
+    		pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data[index];
+    		orgpressure_surface = pDiveState->lifeData.pressure_surface_bar - (settingsGetPointer()->offsetPressure_mbar / 1000.0);
+    		newOffset = ((pDiveO2Data->pressure/1000) - (orgpressure_surface * 1000));
+
+    		if((pDiveState->lifeData.pressure_surface_bar * 1000 + newOffset) != (pDiveO2Data->pressure/1000)) /* there might be a rounding difference => compensate */
+			{
+    			newOffset += (pDiveO2Data->pressure/1000) - (pDiveState->lifeData.pressure_surface_bar * 1000 + newOffset);
+			}
+
+    		pSettings->offsetPressure_mbar = newOffset;
+    		snprintf(text,32,"%c%c (%1.3lf => %1.3f)\016\016Bar",TXT_2BYTE,TXT2BYTE_AdjustAmbPressure,(float)(pDiveO2Data->pressure/1000000.0),
+    		        													pDiveState->lifeData.pressure_surface_bar + pSettings->offsetPressure_mbar / 1000.0);
+    		tMenuEdit_newButtonText(StMSYS5_AdjustSurfPres,text);
+    		break;
+    	}
+    }
+
+    return UNSPECIFIC_RETURN;
+}
+
+
 #ifdef SCREENTEST
 uint8_t OnAction_ScreenTest		(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
--- a/Discovery/Src/tMenuEditXtra.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tMenuEditXtra.c	Wed Aug 14 16:44:46 2024 +0200
@@ -38,6 +38,7 @@
 #include "data_exchange_main.h"
 #include "motion.h"
 #include "configuration.h"
+#include "tInfoPreDive.h"
 
 
 /* Private function prototypes -----------------------------------------------*/
@@ -54,9 +55,6 @@
 #ifdef ENABLE_PSCR_MODE
 static void openEdit_PSCR(void);
 #endif
-#ifdef ENABLE_CO2_SUPPORT
-static void openEdit_CO2Sensor(void);
-#endif
 
 /* Announced function prototypes -----------------------------------------------*/
 uint8_t OnAction_CompassHeading	(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
@@ -69,11 +67,6 @@
 static uint8_t OnAction_PSCRLungRation(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
 #endif
 
-#ifdef ENABLE_CO2_SUPPORT
-static uint8_t OnAction_CO2OnOff(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-static uint8_t OnAction_CO2Calib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
-#endif
-
 /* Exported functions --------------------------------------------------------*/
 
 
@@ -115,11 +108,6 @@
     }
     else /* surface mode */
     {
-        if((settingsGetPointer()->dive_mode != DIVEMODE_PSCR) && (line > 3))		/* PSCR items are only optional */
-		{
-			line = 6;
-		}
-
 		switch(line)
 		{
 			case 1: openEdit_CCRModeSensorOrFixedSP();
@@ -132,10 +120,8 @@
 			case 4: openEdit_PSCR();
 				break;
 #endif
-#ifdef ENABLE_CO2_SUPPORT
-			case 6: openEdit_CO2Sensor();
+			case 5:	openInfo_PreDive();
 				break;
-#endif
 			default:
 				break;
 		}
@@ -321,42 +307,6 @@
 }
 
 
-#ifdef ENABLE_CO2_SUPPORT
-static void openEdit_CO2Sensor()
-{
-    char text[32];
-
-    resetMenuEdit(CLUT_MenuPageXtra);
-
-    snprintf(text,32,"\001%c",TXT_CO2Sensor);
-    write_topline(text);
-
-    refresh_CO2Data();
-    if(settingsGetPointer()->co2_sensor_active)
-    {
-    	text[0] = '\005';
-    }
-    else
-    {
-        text[0] = '\006';
-    }
-    text[0] = TXT_CO2Sensor;
-    text[1] = 0;
-
-    write_field_on_off(StMXTRA_CO2_Sensor,	 30, 95, ME_Y_LINE3,  &FontT48, text, settingsGetPointer()->co2_sensor_active);
-
-   	text[0] = TXT_2BYTE;
-    text[1] = TXT2BYTE_O2Calib;
-    text[2] = 0;
-    write_field_button(StMXTRA_CO2_Sensor_Calib,30, 800, ME_Y_LINE4,  &FontT48, text);
-
-    setEvent(StMXTRA_CO2_Sensor,	(uint32_t)OnAction_CO2OnOff);
-    setEvent(StMXTRA_CO2_Sensor_Calib,	(uint32_t)OnAction_CO2Calib);
-
-    write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext);
-}
-#endif
-
 
 static uint8_t OnAction_CompassHeadingClear(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
 {
@@ -443,23 +393,6 @@
 }
 
 
-void refresh_CO2Data(void)
-{
-    char text[32];
-
-    snprintf(text,32,"\001%c",TXT_CO2Sensor);
-    write_topline(text);
-
-    snprintf(text,32,"CO2: %ld ppm",stateUsed->lifeData.CO2_data.CO2_ppm);
-    write_label_var(   30, 800, ME_Y_LINE1, &FontT48, text);
-
-    snprintf(text,32,"Signal: %d",stateUsed->lifeData.CO2_data.signalStrength);
-    write_label_var(   30, 800, ME_Y_LINE2, &FontT48, text);
-
-    tMenuEdit_refresh_field(StMXTRA_CO2_Sensor);
-    tMenuEdit_refresh_field(StMXTRA_CO2_Sensor_Calib);
-}
-
 void openEdit_CompassHeading(void)
 {
     drawCompassHeadingMenu(false);
@@ -684,26 +617,4 @@
 }
 #endif
 
-#ifdef ENABLE_CO2_SUPPORT
-static uint8_t OnAction_CO2OnOff(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
-{
-	SSettings *pSettings = settingsGetPointer();
-	if(pSettings->co2_sensor_active)
-	{
-		pSettings->co2_sensor_active = 0;
-		tMenuEdit_set_on_off(StMXTRA_CO2_Sensor,0);
-	}
-	else
-	{
-		pSettings->co2_sensor_active = 1;
-		tMenuEdit_set_on_off(StMXTRA_CO2_Sensor,1);
-	}
-	return UPDATE_DIVESETTINGS;
-}
 
-static uint8_t OnAction_CO2Calib(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
-{
-	DataEX_setExtInterface_Cmd(EXT_INTERFACE_CO2_CALIB);
-	return UPDATE_DIVESETTINGS;
-}
-#endif
--- a/Discovery/Src/tMenuHardware.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tMenuHardware.c	Wed Aug 14 16:44:46 2024 +0200
@@ -102,15 +102,14 @@
             sensorStatusColor[0] = '\020';
             sensorStatusColor[1] = '\020';
             sensorStatusColor[2] = '\020';
-            if(stateUsed->diveSettings.ppo2sensors_deactivated)
-            {
-                if(stateUsed->diveSettings.ppo2sensors_deactivated & 1)
+
+            if((stateUsed->diveSettings.ppo2sensors_deactivated & 1) || (data->ext_sensor_map[0] > SENSOR_DIGO2M))
                     sensorStatusColor[0] = '\031';
-                if(stateUsed->diveSettings.ppo2sensors_deactivated & 2)
+            if((stateUsed->diveSettings.ppo2sensors_deactivated & 2) || (data->ext_sensor_map[1] > SENSOR_DIGO2M))
                     sensorStatusColor[1] = '\031';
-                if(stateUsed->diveSettings.ppo2sensors_deactivated & 4)
+            if((stateUsed->diveSettings.ppo2sensors_deactivated & 4) || (data->ext_sensor_map[1] > SENSOR_DIGO2M))
                     sensorStatusColor[2] = '\031';
-            }
+
             textPointer += snprintf(&text[textPointer],20,"%c%01.1f  %c%01.1f  %c%01.1f\020"
                 ,sensorStatusColor[0], stateUsed->lifeData.ppO2Sensor_bar[0]
                 ,sensorStatusColor[1], stateUsed->lifeData.ppO2Sensor_bar[1]
--- a/Discovery/Src/tMenuSystem.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tMenuSystem.c	Wed Aug 14 16:44:46 2024 +0200
@@ -30,6 +30,7 @@
 #include "tMenu.h"
 #include "tMenuSystem.h"
 #include "tHome.h"  // for enum CUSTOMVIEWS and init_t7_compass()
+#include "t7.h"
 
 static uint8_t customviewsSubpage = 0;
 
@@ -183,9 +184,21 @@
         textPointer += 2;
     }
 
-    if (line == 0 || line == 2) {
-        textPointer += snprintf(&text[textPointer], 21, "%c%c\t%u:%02u \016\016[m:ss]\017\n\r", TXT_2BYTE, TXT2BYTE_Timer, data->timerDurationS / 60, data->timerDurationS % 60);
-    } else {
+    if (line == 0 || line == 2)
+    {
+    	if(t7_customview_disabled(CVIEW_Timer))
+    	{
+    		text[textPointer++] = '\031';		/* change text color */
+    	    textPointer += snprintf(&text[textPointer], 21, "%c%c\t%u:%02u \016\016[m:ss]\017\n\r", TXT_2BYTE, TXT2BYTE_Timer, data->timerDurationS / 60, data->timerDurationS % 60);
+    	    disableLine(StMSYS_Timer);
+            text[textPointer++] = '\020';		/* restore text color */
+    	}
+    	else
+    	{
+    		textPointer += snprintf(&text[textPointer], 21, "%c%c\t%u:%02u \016\016[m:ss]\017\n\r", TXT_2BYTE, TXT2BYTE_Timer, data->timerDurationS / 60, data->timerDurationS % 60);
+    	}
+    } else
+    {
         textPointer += snprintf(&text[textPointer], 3, "\n\r");
     }
 
@@ -303,6 +316,19 @@
 
     return StMSYS;
 }
+void tMSystem_checkLineStatus(void)
+{
+	uint8_t localLineMask = 0;
+	uint8_t lineMask = getLineMask(StMSYS);
 
+	if(t7_customview_disabled(CVIEW_Timer))
+    {
+    	localLineMask |= 1 << 2;
+    }
+	if(lineMask != localLineMask)
+	{
+		updateMenu();
+	}
+}
 
 /* Private functions ---------------------------------------------------------*/
--- a/Discovery/Src/tMenuXtra.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/tMenuXtra.c	Wed Aug 14 16:44:46 2024 +0200
@@ -38,6 +38,7 @@
 #include "simulation.h"
 #include "configuration.h"
 
+
 /* Exported functions --------------------------------------------------------*/
 
 uint32_t tMXtra_refresh(uint8_t line, char *text, uint16_t *tab, char *subtext)
@@ -51,6 +52,8 @@
 
     SSettings *pSettings = settingsGetPointer();
 
+    resetLineMask(StMXTRA);
+
     /* DIVE MODE */
     if(actual_menu_content != MENU_SURFACE)
     {
@@ -168,10 +171,12 @@
            else
                text[textPointer++] = '\006';
 
-           if (!canDoFallback) {
+           if (!canDoFallback)
+           {
                text[textPointer++] = '\020';
                disableLine(StMXTRA_O2_Fallback);
-           } else {
+           } else
+           {
                enableLine(StMXTRA_O2_Fallback);
            }
            strcpy(&text[textPointer],"\n\r");
@@ -190,23 +195,66 @@
         }
 
 #ifdef ENABLE_PSCR_MODE
-        if(pSettings->dive_mode == DIVEMODE_PSCR)
-        {
-            if((line == 0) || (line == 4))
-             {
-                 textPointer += snprintf(&text[textPointer], 60,\
-                             "%c"
-                             ,TXT_PSClosedCircuit);
-             }
-        }
-#endif
-#ifdef ENABLE_CO2_SUPPORT
         if((line == 0) || (line == 4))
          {
-             textPointer += snprintf(&text[textPointer], 60, "%c", TXT_CO2Sensor);
+			if(pSettings->dive_mode == DIVEMODE_PSCR)
+			{
+				textPointer += snprintf(&text[textPointer], 60, "%c",TXT_PSClosedCircuit);
+				enableLine(StMXTRA_PSCR_O2_Drop);
+			}
+			else
+			{
+				text[textPointer++] = '\031';		/* change text color */
+				textPointer += snprintf(&text[textPointer], 60,"%c",TXT_PSClosedCircuit);
+				text[textPointer++] = '\020';		/* restore text color */
+				disableLine(StMXTRA_PSCR_O2_Drop);
+			}
+            strcpy(&text[textPointer],"\n\r");
+            textPointer += 2;
          }
 #endif
+        if((line == 0) || (line == 5))
+        {
+      		if((pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_ANADIG) || (pSettings->ppo2sensors_source == O2_SENSOR_SOURCE_DIGITAL))
+        	{
+        	    textPointer += snprintf(&text[textPointer], 60,"%c",TXT_PreDive);
+        	}
+      		else
+      		{
+      			text[textPointer++] = '\031';		/* change text color */
+      			textPointer += snprintf(&text[textPointer], 60,"%c",TXT_PreDive);
+      			text[textPointer++] = '\020';		/* restore text color */
+      			disableLine(StMXTRA_Predive_Check);
+      		}
+      		strcpy(&text[textPointer],"\n\r");
+      		textPointer += 2;
+        }
     }
     return StMXTRA;
 }
 
+void tMXtra_checkLineStatus(void)
+{
+	uint8_t localLineMask = 0;
+	uint8_t lineMask = getLineMask(StMXTRA);
+    SSettings *pSettings = settingsGetPointer();
+
+	if(pSettings->CCR_Mode != CCRMODE_Sensors)
+	{
+		localLineMask |= 1 << 2;
+	}
+	if(pSettings->dive_mode != DIVEMODE_PSCR)
+	{
+		localLineMask |= 1 << 4;
+	}
+	if((pSettings->ppo2sensors_source != O2_SENSOR_SOURCE_ANADIG) && (pSettings->ppo2sensors_source != O2_SENSOR_SOURCE_DIGITAL))
+	{
+		localLineMask |= 1 << 5;
+	}
+
+	if(lineMask != localLineMask)
+	{
+			updateMenu();
+	}
+}
+
--- a/Discovery/Src/text_multilanguage.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/text_multilanguage.c	Wed Aug 14 16:44:46 2024 +0200
@@ -188,6 +188,11 @@
 static uint8_t text_IT_CompassDeclination[] = "Ddeclinazione";
 static uint8_t text_ES_CompassDeclination[] = "Declinación";
 
+static uint8_t text_EN_Autofocus[] = "Autofocus";
+static uint8_t text_DE_Autofocus[] = "Automatik";
+static uint8_t text_FR_Autofocus[] = "";
+static uint8_t text_IT_Autofocus[] = "";
+static uint8_t text_ES_Autofocus[] = "";
 
 // Menu SYS1 and Customview header
 static uint8_t text_EN_Compass[] = "Compass";
@@ -465,6 +470,12 @@
 static uint8_t text_IT_PSClosedCircuit[] = "PSC circuit";
 static uint8_t text_ES_PSClosedCircuit[] = "PSC circuit";
 
+static uint8_t text_EN_PreDive[] = "PreDive Check";
+static uint8_t text_DE_PreDive[] = "";
+static uint8_t text_FR_PreDive[] = "";
+static uint8_t text_IT_PreDive[] = "";
+static uint8_t text_ES_PreDive[] = "";
+
 static uint8_t text_EN_ChargeHour[] = "Hour(s) till 100%";
 static uint8_t text_DE_ChargeHour[] = "Stunde(n) bis 100%";
 static uint8_t text_FR_ChargeHour[] = "";
@@ -637,6 +648,13 @@
 static uint8_t text_ES_SetBatteryCharge[] = "Recalibrar nivel carga";
 
 // Menu SYS2 sub
+static uint8_t text_EN_AdjustAmbPressure[] = "Adjust pressure";
+static uint8_t text_DE_AdjustAmbPressure[] = "Druckanpassung";
+static uint8_t text_FR_AdjustAmbPressure[] = "";
+static uint8_t text_IT_AdjustAmbPressure[] = "";
+static uint8_t text_ES_AdjustAmbPressure[] = "";
+
+// Menu SYS2 sub
 static uint8_t text_EN_SetFactoryDefaults[] = "Store button factory defaults";
 static uint8_t text_DE_SetFactoryDefaults[] = "Taster zurücksetzen";
 static uint8_t text_FR_SetFactoryDefaults[] = "";
@@ -803,6 +821,19 @@
 static uint8_t text_IT_Reset[] = "Ripristina";
 static uint8_t text_ES_Reset[] = "Restaurar";
 
+static uint8_t text_EN_CounterLung[] = "Counterlung";
+static uint8_t text_DE_CounterLung[] = "Gegenlunge";
+static uint8_t text_FR_CounterLung[] = "";
+static uint8_t text_IT_CounterLung[] = "";
+static uint8_t text_ES_CounterLung[] = "";
+
+static uint8_t text_EN_Pressure[] = "Pressure";
+static uint8_t text_DE_Pressure[] = "Druck";
+static uint8_t text_FR_Pressure[] = "";
+static uint8_t text_IT_Pressure[] = "";
+static uint8_t text_ES_Pressure[] = "";
+
+
 // Menu SIM
 static uint8_t text_EN_Simulator[] = "Simulator";
 static uint8_t text_DE_Simulator[] = "";
@@ -1975,6 +2006,7 @@
     {(uint8_t)TXT_Apnoe,	 		{text_EN_Apnoe, text_DE_Apnoe, text_FR_Apnoe, text_IT_Apnoe, text_ES_Apnoe}},
     {(uint8_t)TXT_Gauge,	 		{text_EN_Gauge, text_DE_Gauge, text_FR_Gauge, text_IT_Gauge, text_ES_Gauge}},
     {(uint8_t)TXT_PSClosedCircuit,  {text_EN_PSClosedCircuit, text_DE_PSClosedCircuit, text_FR_PSClosedCircuit, text_IT_PSClosedCircuit, text_ES_PSClosedCircuit}},
+	{(uint8_t)TXT_PreDive,  		{text_EN_PreDive, text_DE_PreDive, text_FR_PreDive, text_IT_PreDive, text_ES_PreDive}},
 	{(uint8_t)TXT_Sensor,			{text_EN_Sensor, text_DE_Sensor, text_FR_Sensor, text_IT_Sensor, text_ES_Sensor}},
     {(uint8_t)TXT_FixedSP,			{text_EN_FixedSP, text_DE_FixedSP, text_FR_FixedSP, text_IT_FixedSP, text_ES_FixedSP}},
     {(uint8_t)TXT_Decoparameters,	{text_EN_Decoparameters, text_DE_Decoparameters, text_FR_Decoparameters, text_IT_Decoparameters, text_ES_Decoparameters}},
@@ -2049,6 +2081,7 @@
     {(uint8_t)TXT2BYTE_CompassCalib, 	{text_EN_CompassCalib, text_DE_CompassCalib, text_FR_CompassCalib, text_IT_CompassCalib, text_ES_CompassCalib}},
 	{(uint8_t)TXT2BYTE_CompassInertia,	{text_EN_CompassInertia, text_DE_CompassInertia, text_FR_CompassInertia, text_IT_CompassInertia, text_ES_CompassInertia}},
 	{(uint8_t)TXT2BYTE_CompassDeclination,	{text_EN_CompassDeclination, text_DE_CompassDeclination, text_FR_CompassDeclination, text_IT_CompassDeclination, text_ES_CompassDeclination}},
+	{(uint8_t)TXT2BYTE_Autofocus	,	{text_EN_Autofocus, text_DE_Autofocus, text_FR_Autofocus, text_IT_Autofocus, text_ES_Autofocus}},
 	{(uint8_t)TXT2BYTE_UseSensor,		{text_EN_UseSensor, text_DE_UseSensor, text_FR_UseSensor, text_IT_UseSensor, text_ES_UseSensor}},
 	{(uint8_t)TXT2BYTE_AutomaticSP,		{text_EN_AutomaticSP, text_DE_AutomaticSP, text_FR_AutomaticSP, text_IT_AutomaticSP, text_ES_AutomaticSP}},
     {(uint8_t)TXT2BYTE_WarnDecoMissed,  {text_EN_WarnDecoMissed, text_DE_WarnDecoMissed, text_FR_WarnDecoMissed, text_IT_WarnDecoMissed, text_ES_WarnDecoMissed}},
@@ -2141,6 +2174,7 @@
     {(uint8_t)TXT2BYTE_Sensor,			{text_EN_SensorList, text_DE_SensorList, text_FR_SensorList, text_IT_SensorList, text_ES_SensorList}},
     {(uint8_t)TXT2BYTE_Maintenance,		{text_EN_Maintenance, text_DE_Maintenance, text_FR_Maintenance, text_IT_Maintenance, text_ES_Maintenance}},
     {(uint8_t)TXT2BYTE_SetBatteryCharge,{text_EN_SetBatteryCharge, text_DE_SetBatteryCharge, text_FR_SetBatteryCharge, text_IT_SetBatteryCharge, text_ES_SetBatteryCharge}},
+	{(uint8_t)TXT2BYTE_AdjustAmbPressure,{text_EN_AdjustAmbPressure, text_DE_AdjustAmbPressure, text_FR_AdjustAmbPressure, text_IT_AdjustAmbPressure, text_ES_AdjustAmbPressure}},
     {(uint8_t)TXT2BYTE_SetFactoryDefaults,{text_EN_SetFactoryDefaults, text_DE_SetFactoryDefaults, text_FR_SetFactoryDefaults, text_IT_SetFactoryDefaults, text_ES_SetFactoryDefaults}},
 	{(uint8_t)TXT2BYTE_SetSampleIndex,  {text_EN_SetSampleIndex, text_DE_SetSampleIndex, text_FR_SetSampleIndex, text_IT_SetSampleIndex, text_ES_SetSampleIndex}},
 
@@ -2192,6 +2226,9 @@
 	{(uint8_t)TXT2BYTE_Clear, 	{text_EN_Clear, text_DE_Clear, text_FR_Clear, text_IT_Clear, text_ES_Clear}},
 	{(uint8_t)TXT2BYTE_Reset, 	{text_EN_Reset, text_DE_Reset, text_FR_Reset, text_IT_Reset, text_ES_Reset}},
 
+	{(uint8_t)TXT2BYTE_CounterLung, 	{text_EN_CounterLung, text_DE_CounterLung, text_FR_CounterLung, text_IT_CounterLung, text_ES_CounterLung}},
+	{(uint8_t)TXT2BYTE_Pressure, 	{text_EN_Pressure, text_DE_Pressure, text_FR_Pressure, text_IT_Pressure, text_ES_Pressure}},
+
 	{(uint8_t)TXT2BYTE_Timer, 	{text_EN_Timer, text_DE_Timer, text_FR_Timer, text_IT_Timer, text_ES_Timer}},
 	{(uint8_t)TXT2BYTE_Starting, 	{text_EN_Starting, text_DE_Starting, text_FR_Starting, text_IT_Starting, text_ES_Starting}},
 	{(uint8_t)TXT2BYTE_Finished, 	{text_EN_Finished, text_DE_Finished, text_FR_Finished, text_IT_Finished, text_ES_Finished}},
--- a/Discovery/Src/vpm.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Discovery/Src/vpm.c	Wed Aug 14 16:44:46 2024 +0200
@@ -165,7 +165,7 @@
 
 static float r_int(float *x)
 {
-    return( (*x>0) ? floorf(*x) : -floorf(- *x) );
+    return( (*x>0.0) ? floorf(*x) : -floorf(- *x) );
 }
 
 /** private functions
@@ -460,10 +460,12 @@
 
     for (i = 1; i < BUEHLMANN_STRUCT_MAX_GASES; i++)
     {
-        if(pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero  >= depth_change[0] + 1)
+        if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero  >= depth_change[0] + 1)
+        		&& (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc))
             continue;
 
-        if(pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero <= 0)
+        if((pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero <= 0)
+        	|| (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0))
             break;
 
         j++;
@@ -636,8 +638,8 @@
         {
             for (i = 0; i < 16; i++)
             {
-                tissue_He_saturation[i] = helium_pressure[i] / 10;
-                tissue_N2_saturation[i] = nitrogen_pressure[i] / 10;
+                tissue_He_saturation[i] = helium_pressure[i] / 10.0;
+                tissue_N2_saturation[i] = nitrogen_pressure[i] / 10.0;
             }
 
             if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_stop_depth / 10.0f) + pInput->pressure_surface_bar))
@@ -645,7 +647,7 @@
 
                 vpm_violates_buehlmann = true;
                 do {
-                    deco_stop_depth += 3;
+                    deco_stop_depth += 3.0;
                 } while (!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_stop_depth / 10.0f) + pInput->pressure_surface_bar));
             }
         }
@@ -702,7 +704,7 @@
     /*     ASSIGN VARIABLES FOR ASCENT FROM START OF DECO ZONE TO FIRST STOP.  SAVE */
     /*     FIRST STOP DEPTH FOR LATER USE WHEN COMPUTING THE FINAL ASCENT PROFILE */
     /* =============================================================================== */
-        deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10);
+        deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10.0);
         starting_depth = depth_start_of_deco_calc;
         first_stop_depth = deco_stop_depth;
         first_stop = true;
@@ -753,12 +755,12 @@
         decompression_stop(&deco_stop_depth, &step_size, false);
         starting_depth = deco_stop_depth;
 
-        if(deco_stop_depth == (float)pDiveSettings->last_stop_depth_bar * 10)
+        if(deco_stop_depth == (float)pDiveSettings->last_stop_depth_bar * 10.0)
             deco_stop_depth = 0;
         else
         {
             deco_stop_depth = deco_stop_depth - step_size;
-            deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10);
+            deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10.0);
         }
 
         count++;
@@ -895,7 +897,7 @@
     // _Bool first_stop = false;
     float tissue_He_saturation[16];
     float tissue_N2_saturation[16];
-    float vpm_buehlmann_safety_gradient = 1.0f - (((float)pDiveSettings->vpm_conservatism) / 40);
+    float vpm_buehlmann_safety_gradient = 1.0f - (((float)pDiveSettings->vpm_conservatism) / 40.0);
     //max_first_stop_depth = fmaxf(first_stop_depth,max_first_stop_depth);
 
     /** CALC DECO Ceiling ******************************************************************/
@@ -923,13 +925,12 @@
         {
             for (i = 0; i < 16; i++)
             {
-                tissue_He_saturation[i] = helium_pressure[i] / 10;
-                tissue_N2_saturation[i] = nitrogen_pressure[i] / 10;
+                tissue_He_saturation[i] = helium_pressure[i] / 10.0;
+                tissue_N2_saturation[i] = nitrogen_pressure[i] / 10.0;
             }
 
             if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar))
             {
-
                 vpm_violates_buehlmann = true;
                 do {
                     deco_ceiling_depth += 0.1f;
@@ -961,13 +962,12 @@
         {
             for (i = 0; i < 16; i++)
             {
-                tissue_He_saturation[i] = helium_pressure[i] / 10;
-                tissue_N2_saturation[i] = nitrogen_pressure[i] / 10;
+                tissue_He_saturation[i] = helium_pressure[i] / 10.0;
+                tissue_N2_saturation[i] = nitrogen_pressure[i] / 10.0;
             }
 
             if(!decom_tissue_test_tolerance(tissue_N2_saturation, tissue_He_saturation, vpm_buehlmann_safety_gradient, (deco_ceiling_depth / 10.0f) + pInput->pressure_surface_bar))
             {
-
                 vpm_violates_buehlmann = true;
                 do {
                     deco_ceiling_depth += 0.1f;
@@ -981,12 +981,12 @@
     }
     else
     {
-         pDecoInfo->output_ceiling_meter = 0;
+         pDecoInfo->output_ceiling_meter = 0.0;
     }
 
     // fix hw 160627
-    if(pDecoInfo->output_ceiling_meter < 0)
-        pDecoInfo->output_ceiling_meter = 0;
+    if(pDecoInfo->output_ceiling_meter < 0.0)
+        pDecoInfo->output_ceiling_meter = 0.0;
 
     /*** End CALC ceiling    ***************************************************/
 }
@@ -1005,6 +1005,9 @@
     static int dp_max;
     static float surfacetime;
     _Bool first_stop = false;
+
+    short stop_time_seconds;
+
     max_first_stop_depth = fmaxf(first_stop_depth,max_first_stop_depth);
     if(begin)
     {
@@ -1103,16 +1106,21 @@
             }
             else
             {
-                    dp = 1 + (int)((deco_stop_depth - (pDiveSettings->input_second_to_last_stop_depth_bar * 10)) / step_size);
+                dp = 1 + (unsigned short)((deco_stop_depth - (pDiveSettings->input_second_to_last_stop_depth_bar * 10.0)) / step_size);
             }
-            dp_max = (int)fmaxf(dp_max,dp);
+
+            //dp_max = (int)fmaxf(dp_max,dp);
+            if(dp > dp_max)
+            {
+            	dp_max = dp;
+            }
             if(dp < DECOINFO_STRUCT_MAX_STOPS)
             {
-                int stop_time_seconds = fminf((999 * 60), (int)(stop_time *60));
+                stop_time_seconds = (short) fminf((999.9 * 60.0), (stop_time *60.0));
                 //
 
                 //if(vpm_calc_what == DECOSTOPS)
-                    pDecoInfo->output_stop_length_seconds[dp] = (unsigned short)stop_time_seconds;
+                    pDecoInfo->output_stop_length_seconds[dp] = stop_time_seconds;
                 //else
                     //decostop_bailout[dp] = (unsigned short)stop_time_seconds;
             }
@@ -1131,12 +1139,12 @@
         /* =============================================================================== */
 
         starting_depth = deco_stop_depth;
-        if(deco_stop_depth == (float)pDiveSettings->last_stop_depth_bar * 10)
-            deco_stop_depth = 0;
+        if(deco_stop_depth == (float)pDiveSettings->last_stop_depth_bar * 10.0)
+            deco_stop_depth = 0.0;
         else
         {
             deco_stop_depth = deco_stop_depth - step_size;
-            deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10);
+            deco_stop_depth = fmaxf(deco_stop_depth,(float)pDiveSettings->last_stop_depth_bar * 10.0);
         }
 
         last_run_time = run_time;
@@ -1156,7 +1164,7 @@
                 //decostop_bailout[dp] = 0;
         }
     }
-    pDecoInfo->output_time_to_surface_seconds = (int)(surfacetime * 60);
+    pDecoInfo->output_time_to_surface_seconds = (int)(surfacetime * 60.0);
     pDecoInfo->output_ndl_seconds = 0;
 
     vpm_calc_deco_ceiling();
@@ -1407,8 +1415,8 @@
         /*     the vacuum of outer space! */
         /* =============================================================================== */
 
-        if (tolerated_ambient_pressure < 0) {
-            tolerated_ambient_pressure = 0;
+        if (tolerated_ambient_pressure < 0.0) {
+            tolerated_ambient_pressure = 0.0;
         }
         compartment_deco_ceiling[i - 1] =
         tolerated_ambient_pressure - barometric_pressure;
@@ -1736,8 +1744,8 @@
     ending_ambient_pressure = starting_ambient_pressure/2;
 
     time_test = (ending_ambient_pressure - starting_ambient_pressure) / *rate;
-    decom_get_inert_gases(starting_ambient_pressure / 10, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_begin, &fraction_helium_begin );
-    decom_get_inert_gases(ending_ambient_pressure   / 10, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_end, &fraction_helium_end );
+    decom_get_inert_gases(starting_ambient_pressure / 10.0, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_begin, &fraction_helium_begin );
+    decom_get_inert_gases(ending_ambient_pressure   / 10.0, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_end, &fraction_helium_end );
     initial_inspired_he_pressure =	(starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin;
     initial_inspired_n2_pressure =	(starting_ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_nitrogen_begin;
     helium_rate = ((ending_ambient_pressure  - WATER_VAPOR_PRESSURE)* fraction_helium_end - initial_inspired_he_pressure)/time_test;
@@ -1768,7 +1776,7 @@
     /*     and high bound function values. */
     /* =============================================================================== */
 
-    low_bound = 0.;
+    low_bound = 0.0;
     high_bound = starting_ambient_pressure / *rate * -1.0f;
     for (i = 1; i <= 16; ++i)
     {
@@ -1983,7 +1991,7 @@
     _Bool buehlmann_wait = false;
     float tissue_He_saturation[16];
     float tissue_N2_saturation[16];
-    float vpm_buehlmann_safety_gradient = 1.0f - (((float)pDiveSettings->vpm_conservatism) / 40);
+    float vpm_buehlmann_safety_gradient = 1.0f - (((float)pDiveSettings->vpm_conservatism) / 40.0);
     /* loop */
     /* =============================================================================== */
     /*     CALCULATIONS */
@@ -1995,12 +2003,12 @@
     //ending_ambient_pressure = ambient_pressure;
     decom_get_inert_gases(ambient_pressure / 10, (&pDiveSettings->decogaslist[mix_number]), &fraction_nitrogen_begin, &fraction_helium_begin );
 
-    if(*deco_stop_depth == (float)(pDiveSettings->last_stop_depth_bar * 10))
+    if(*deco_stop_depth == (pDiveSettings->last_stop_depth_bar * 10.0))
         next_stop = 0;
     else
     {
         next_stop = *deco_stop_depth - *step_size;
-        next_stop = fmaxf(next_stop,(float)pDiveSettings->last_stop_depth_bar * 10);
+        next_stop = fmaxf(next_stop, pDiveSettings->last_stop_depth_bar * 10.0);
     }
 
     inspired_helium_pressure =
@@ -2020,17 +2028,17 @@
     }
     else
     {
-        deco_ceiling_depth = next_stop + 1;
+        deco_ceiling_depth = next_stop + 1.0;
     }
         if(deco_ceiling_depth > next_stop)
         {
             while (deco_ceiling_depth > next_stop)
             {
 
-                segment_time  +=  60;
-                if(segment_time >= 999 )
+                segment_time  +=  60.0;
+                if(segment_time >= 999.0 )
                 {
-                    segment_time = 999 ;
+                    segment_time = 999.0 ;
                     run_time += segment_time;
                     return;
                 }
@@ -2048,7 +2056,7 @@
             }
             if(deco_ceiling_depth < next_stop)
             {
-                segment_time  -=  60;
+                segment_time  -=  60.0;
                 gCNS_VPM = initial_CNS;
                 for (i = 0; i < 16; i++)
                 {
@@ -2088,17 +2096,17 @@
             while (buehlmann_wait || (deco_ceiling_depth > next_stop))
             {
                 //time_counter = temp_segment_time;
-                segment_time  +=  1;
+                segment_time  +=  1.0;
 
-                if(segment_time >= 999 )
+                if(segment_time >= 999.0 )
                 {
-                    segment_time = 999 ;
+                    segment_time = 999.0 ;
                     run_time += segment_time;
                     return;
                 }
                 //goto L700;
                 initial_CNS = gCNS_VPM;
-                decom_oxygen_calculate_cns_exposure(60*1,&pDiveSettings->decogaslist[mix_number],ambient_pressure/10,&gCNS_VPM);
+                decom_oxygen_calculate_cns_exposure(60*1,&pDiveSettings->decogaslist[mix_number],ambient_pressure/10.0, &gCNS_VPM);
                 for (i = 0; i < 16; i++)
                 {
                     initial_helium_pressure[i] = helium_pressure[i];
@@ -2300,14 +2308,14 @@
 
         for(i = 0; i < 16;i++)
         {
-            future_helium_pressure[i] =  pInput->tissue_helium_bar[i] * 10;//tissue_He_saturation[st_dive][i] * 10;
-            future_nitrogen_pressure[i] = pInput->tissue_nitrogen_bar[i] * 10;
+            future_helium_pressure[i] =  pInput->tissue_helium_bar[i] * 10.0;//tissue_He_saturation[st_dive][i] * 10;
+            future_nitrogen_pressure[i] = pInput->tissue_nitrogen_bar[i] * 10.0;
         }
         temp_segment_time = 0;
 
         mix_number = 0;
-        ambient_pressure = pInput->pressure_ambient_bar  * 10;
-        decom_get_inert_gases( ambient_pressure / 10,  (&pDiveSettings->decogaslist[mix_number]) , &fraction_nitrogen_begin, &fraction_helium_begin );
+        ambient_pressure = pInput->pressure_ambient_bar  * 10.0;
+        decom_get_inert_gases( ambient_pressure / 10.0,  (&pDiveSettings->decogaslist[mix_number]) , &fraction_nitrogen_begin, &fraction_helium_begin );
         inspired_helium_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) * fraction_helium_begin;
         inspired_nitrogen_pressure =(ambient_pressure - WATER_VAPOR_PRESSURE) *fraction_nitrogen_begin;
 
--- a/OtherSources/system_stm32f4xx.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/OtherSources/system_stm32f4xx.c	Wed Aug 14 16:44:46 2024 +0200
@@ -74,6 +74,8 @@
   #define HSI_VALUE    ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
 #endif /* HSI_VALUE */
 
+
+const uint8_t APBPrescTable[8]  = {0, 0, 0, 0, 1, 2, 3, 4};
 /**
   * @}
   */
--- a/RefPrj/Firmware/.cproject	Tue Aug 13 13:24:54 2024 +0200
+++ b/RefPrj/Firmware/.cproject	Wed Aug 14 16:44:46 2024 +0200
@@ -50,7 +50,7 @@
 								<option id="gnu.cpp.compiler.option.debugging.level.1733485526" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
 							</tool>
 							<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.1908756987" name="MCU GCC Linker" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker">
-								<option id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script.1377166494" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script" useByScannerDiscovery="false" value="${ProjDirPath}/../../Common/CPU1-F429.ld" valueType="string"/>
+								<option id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script.1377166494" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script" useByScannerDiscovery="false" value="${ProjDirPath}\..\ostc4\Common\CPU1-F429.ld" valueType="string"/>
 								<option id="gnu.c.link.option.ldflags.1166539479" name="Linker flags" superClass="gnu.c.link.option.ldflags" useByScannerDiscovery="false" value="-u _printf_float " valueType="string"/>
 								<option id="gnu.c.link.option.other.2080432652" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" useByScannerDiscovery="false"/>
 								<option id="gnu.c.link.option.paths.1365621909" name="Library search path (-L)" superClass="gnu.c.link.option.paths" useByScannerDiscovery="false"/>
@@ -101,6 +101,9 @@
 		</cconfiguration>
 		<cconfiguration id="fr.ac6.managedbuild.config.gnu.cross.exe.release.1554475450">
 			<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="fr.ac6.managedbuild.config.gnu.cross.exe.release.1554475450" moduleId="org.eclipse.cdt.core.settings" name="Release">
+				<macros>
+					<stringMacro name="ProjDirPath" type="VALUE_TEXT" value="D:\Projekte\OSTC\workspace\OSTC4_Firmware"/>
+				</macros>
 				<externalSettings/>
 				<extensions>
 					<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
@@ -148,7 +151,7 @@
 								<option id="gnu.cpp.compiler.option.debugging.level.1273410642" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
 							</tool>
 							<tool id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.1139299269" name="MCU GCC Linker" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker">
-								<option id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script.920748377" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script" useByScannerDiscovery="false" value="${ProjDirPath}/../../Common/CPU1-F429.ld" valueType="string"/>
+								<option id="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script.920748377" name="Linker Script (-T)" superClass="fr.ac6.managedbuild.tool.gnu.cross.c.linker.script" useByScannerDiscovery="false" value="${ProjDirPath}\..\ostc4\Common\CPU1-F429.ld" valueType="string"/>
 								<option id="gnu.c.link.option.strip.1057056433" name="Omit all symbol information (-s)" superClass="gnu.c.link.option.strip" useByScannerDiscovery="false" value="false" valueType="boolean"/>
 								<option id="gnu.c.link.option.ldflags.1124840583" name="Linker flags" superClass="gnu.c.link.option.ldflags" useByScannerDiscovery="false" value="-u _printf_float" valueType="string"/>
 								<option id="gnu.c.link.option.nostart.543218958" name="Do not use standard start files (-nostartfiles)" superClass="gnu.c.link.option.nostart" useByScannerDiscovery="false" value="false" valueType="boolean"/>
--- a/Small_CPU/Inc/batteryCharger.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Small_CPU/Inc/batteryCharger.h	Wed Aug 14 16:44:46 2024 +0200
@@ -51,7 +51,6 @@
  } chargerState_t;
 
 
-uint8_t get_charge_status(void);
 void init_battery_charger_status(void);
 void set_charge_state(chargerState_t newState);
 uint8_t get_charge_state(void);
--- a/Small_CPU/Inc/externalInterface.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Small_CPU/Inc/externalInterface.h	Wed Aug 14 16:44:46 2024 +0200
@@ -43,6 +43,16 @@
 #define COMMON_SENSOR_STATE_INIT	(0x0u)	/* All individual state definitions shall start with a INIT state = 0 */
 #define COMMON_SENSOR_STATE_INVALID (0xFFu) /* All individual state definitions shall not use 0xFF for operation control */
 
+
+enum									/* Definitions for supported UART protocols */
+{
+	EXT_INTERFACE_UART_OFF	= 0,
+	EXT_INTERFACE_UART_CO2,
+	EXT_INTERFACE_UART_SENTINEL,
+	EXT_INTERFACE_UART_O2
+};
+
+
  typedef enum
  {
     DETECTION_OFF = 0,		/* no detection requested */
--- a/Small_CPU/Inc/uart.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Small_CPU/Inc/uart.h	Wed Aug 14 16:44:46 2024 +0200
@@ -48,6 +48,7 @@
 void UART_ReadData(uint8_t sensorType);
 void UART_FlushRxBuffer(void);
 void UART_ChangeBaudrate(uint32_t newBaudrate);
+uint8_t UART_isComActive(uint8_t sensorId);
 
 void StringToInt(char *pstr, uint32_t *puInt32);
 void StringToUInt64(char *pstr, uint64_t *puint64);
--- a/Small_CPU/Inc/uartProtocol_Co2.h	Tue Aug 13 13:24:54 2024 +0200
+++ b/Small_CPU/Inc/uartProtocol_Co2.h	Wed Aug 14 16:44:46 2024 +0200
@@ -43,24 +43,24 @@
 
   typedef enum
   {
-  	RX_Ready= 0,					/* Initial state */
- 	RX_DetectStart,					/* validate start byte */
- 	RX_SelectData,					/* Data contained in this frame */
-  	RX_Data0,						/* Process incoming data */
- 	RX_Data1,
- 	RX_Data2,
- 	RX_Data3,
- 	RX_Data4,
- 	RX_Data5,
- 	RX_Data6,
- 	RX_Data7,
- 	RX_Data8,
- 	RX_Data9,
- 	RX_Data10,
- 	RX_Data11,
- 	RX_Data12,
- 	RX_DataComplete
-  } receiveState_t;
+  	CO2RX_Ready= 0,					/* Initial state */
+ 	CO2RX_DetectStart,					/* validate start byte */
+ 	CO2RX_SelectData,					/* Data contained in this frame */
+  	CO2RX_Data0,						/* Process incoming data */
+ 	CO2RX_Data1,
+ 	CO2RX_Data2,
+ 	CO2RX_Data3,
+ 	CO2RX_Data4,
+ 	CO2RX_Data5,
+ 	CO2RX_Data6,
+ 	CO2RX_Data7,
+ 	CO2RX_Data8,
+ 	CO2RX_Data9,
+ 	CO2RX_Data10,
+ 	CO2RX_Data11,
+ 	CO2RX_Data12,
+ 	CO2RX_DataComplete
+  } receiveStateCO2_t;
 
 
  typedef enum
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Small_CPU/Inc/uartProtocol_Sentinel.h	Wed Aug 14 16:44:46 2024 +0200
@@ -0,0 +1,68 @@
+/**
+  ******************************************************************************
+  * @file    uartProtocol_Sentinel.h
+  * @author  heinrichs weikamp gmbh
+  * @version V0.0.1
+  * @date    15-Jan-2024
+  * @brief	 Interface functionality read data from Sentinel rebreather
+  *
+  @verbatim
+  ==============================================================================
+                        ##### How to use #####
+  ==============================================================================
+  @endverbatim
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT(c) 2014 heinrichs weikamp</center></h2>
+  *
+  ******************************************************************************
+  */
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef UART_PROTOCOL_SENTINEL_H
+#define UART_PROTOCOL_SENTINEL_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "configuration.h"
+#include "stm32f4xx_hal.h"
+
+ typedef enum
+  {
+	UART_SENTINEL_INIT = 0,		/* Default Status for every sensor type */
+	UART_SENTINEL_IDLE,			/* sensor detected and no communication pending */
+	UART_SENTINEL_ERROR,
+  	UART_SENTINEL_OPERATING,		/* normal operation */
+  } uartSentinelStatus_t;
+
+  typedef enum
+  {
+  	SENTRX_Ready= 0,					/* Initial state */
+ 	SENTRX_DetectStart,					/* validate start byte */
+ 	SENTRX_SelectData,					/* Data contained in this frame */
+  	SENTRX_Data0,						/* Process incoming data */
+ 	SENTRX_Data1,
+ 	SENTRX_Data2,
+ 	SENTRX_Data3,
+ 	SENTRX_Data4,
+ 	SENTRX_Data5,
+ 	SENTRX_Data6,
+ 	SENTRX_Data7,
+ 	SENTRX_Data8,
+ 	SENTRX_Data9,
+ 	SENTRX_Data10,
+ 	SENTRX_Data11,
+ 	SENTRX_Data12,
+ 	SENTRX_DataComplete
+  } receiveStateSentinel_t;
+
+
+void uartSentinel_Control(void);
+void uartSentinel_ProcessData(uint8_t data);
+uint8_t uartSentinel_isSensorConnected();
+
+#endif /* UART_PROTOCOL_SENTINEL_H */
--- a/Small_CPU/Src/baseCPU2.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Small_CPU/Src/baseCPU2.c	Wed Aug 14 16:44:46 2024 +0200
@@ -166,9 +166,9 @@
 // See CPU2-RTE.ld
 const SFirmwareData cpu2_FirmwareData __attribute__(( section(".firmware_data") ))= {
 		.versionFirst = 3,
-		.versionSecond = 2,
+		.versionSecond = 3,
 		.versionThird = 0,
-		.versionBeta = 0,
+		.versionBeta = 1,
 
 /* 4 bytes with trailing 0 */
 		.signature = "mh",
@@ -494,7 +494,7 @@
 			 */
 
 			EXTI_Test_Button_DeInit();
-			externalInterface_SwitchUART(0);
+			externalInterface_SwitchUART(EXT_INTERFACE_UART_OFF);
 			externalInterface_SwitchPower33(false);
 			if (hasExternalClock())
 				SystemClock_Config_HSI();
--- a/Small_CPU/Src/batteryCharger.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Small_CPU/Src/batteryCharger.c	Wed Aug 14 16:44:46 2024 +0200
@@ -34,36 +34,17 @@
 #include "scheduler.h"
 
 
-/* Use This compile switch to select the new charger status control implementation */
-#define ENABLE_CHARGER_STATUS_V2
-
 #define CHARGER_DEBOUNCE_SECONDS	(6u)		/* 6 seconds used to avoid problems with charger interrupts / disconnections */
 
-static uint8_t battery_i_charge_status = 0;
 static uint16_t battery_charger_counter = 0;
-
-#ifdef ENABLE_CHARGER_STATUS_V2
 static chargerState_t batteryChargerState = Charger_NotConnected;
-#endif
-
-/* can be 0, 1 or 255
- * 0 is disconnected
- * 1 is charging
- * 255 is full
- */
-uint8_t get_charge_status(void)
-{
-	return battery_i_charge_status;
-}
 
 void set_charge_state(uint8_t newState)
 {
-#ifdef ENABLE_CHARGER_STATUS_V2
 	if(newState < Charger_END)
 	{
 		batteryChargerState = newState;
 	}
-#endif
 }
 
 uint8_t get_charge_state(void)
@@ -124,36 +105,20 @@
   HAL_GPIO_Init(CHARGE_OUT_GPIO_PORT, &GPIO_InitStructure); 
 }
 
-/* static counter is used to avoid multiple counts of charge startings
-	 and after that it is used, starting at 127 to count for the charge full signal
-
-	there a short disconnections with the QI charger
-	therefore the battery_charger_counter has a countdown instead of = 0.
-
-	battery_gas_gauge_set_charge_full and  scheduleUpdateDeviceDataChargerFull are
-	set after disconnection as the charging process continues as long as not disconnected
-  to prevent the short disconnections the battery_charger_counter is used too including
-	upcounting again while battery_i_charge_status == 255 and the connection is established
-
- */
-
 void battery_charger_get_status_and_contral_battery_gas_gauge(uint8_t cycleTimeBase)
 {
-#ifdef ENABLE_CHARGER_STATUS_V2
 	static uint8_t notifyChargeComplete = 0;
-#endif 
 
 	#ifdef OSTC_ON_DISCOVERY_HARDWARE
 		return;
 	#endif
 	
-#ifdef ENABLE_CHARGER_STATUS_V2
-
 	if(batteryChargerState == Charger_ColdStart)	/* wait for the first valid voltage meassurement */
 	{
-		if((global.lifeData.battery_voltage != BATTERY_DEFAULT_VOLTAGE) && (global.lifeData.battery_voltage < BATTERY_CHARGER_CONNECTED_VOLTAGE))
+		if(global.lifeData.battery_voltage != BATTERY_DEFAULT_VOLTAGE)	/* wait for first valid voltage value */
 		{
-			if(global.lifeData.battery_voltage > BATTERY_ENDOF_CHARGE_VOLTAGE) 						/* Voltage close to full state => maybe new battery inserted 	*/
+			if((global.lifeData.battery_voltage < BATTERY_CHARGER_CONNECTED_VOLTAGE)
+					&& (global.lifeData.battery_voltage > BATTERY_ENDOF_CHARGE_VOLTAGE)) 	/* Voltage close to full state => maybe new battery inserted 	*/
 			{
 				battery_gas_gauge_set_charge_full();
 			}
@@ -179,7 +144,13 @@
 														battery_charger_counter = CHARGER_DEBOUNCE_SECONDS;
 													}
 											break;
-				case Charger_Finished:				battery_charger_counter = 0;
+				case Charger_Finished:				if((get_voltage() >= BATTERY_ENDOF_CHARGE_VOLTAGE) && (get_voltage() < BATTERY_CHARGER_CONNECTED_VOLTAGE)) /* stopping does not necessarily mean battery is full */
+													{
+														global.dataSendToMaster.chargeStatus = CHARGER_complete;
+														global.deviceDataSendToMaster.chargeStatus = CHARGER_complete;
+														notifyChargeComplete = 1;
+													}
+													battery_charger_counter = 10;
 													batteryChargerState = Charger_LostConnection;
 					/* no break */
 				case Charger_LostConnection:		/* the charger stops charging when charge current is 1/10 	*/
@@ -188,10 +159,6 @@
 													{
 														notifyChargeComplete = 1;
 													}
-													else
-													{
-														notifyChargeComplete = 0;
-													}
 													if(battery_charger_counter >= cycleTimeBase)
 													{
 														battery_charger_counter -= cycleTimeBase;
@@ -199,7 +166,7 @@
 													else
 													{
 														battery_charger_counter = 0;
-														battery_i_charge_status = 0;
+
 														global.dataSendToMaster.chargeStatus = CHARGER_off;
 														global.deviceDataSendToMaster.chargeStatus = CHARGER_off;
 
@@ -207,12 +174,13 @@
 														{
 															battery_gas_gauge_set_charge_full();
 															scheduleUpdateDeviceDataChargerFull();
-															notifyChargeComplete = 0;
 														}
+														notifyChargeComplete = 0;
 														batteryChargerState = Charger_NotConnected;
 													}
 											break;
-				default: break;
+				default:				 			batteryChargerState = Charger_NotConnected; 	/* unexpected state => reinitialize state machine */
+					break;
 			}
 		}
 		else
@@ -221,8 +189,7 @@
 			/* wait for disconnection to write and reset */
 			switch(batteryChargerState)
 			{
-					case Charger_NotConnected:		battery_i_charge_status = 1;
-													battery_charger_counter = 0;
+					case Charger_NotConnected:		battery_charger_counter = 0;
 													batteryChargerState = Charger_WarmUp;
 											break;
 					case Charger_LostConnection:		batteryChargerState = Charger_Active;
@@ -230,7 +197,6 @@
 					case Charger_WarmUp:			battery_charger_counter += cycleTimeBase;
 													if(battery_charger_counter >= CHARGER_DEBOUNCE_SECONDS )
 													{
-														battery_i_charge_status = 2;
 														scheduleUpdateDeviceDataChargerCharging();
 														batteryChargerState = Charger_Active;
 													}
@@ -251,11 +217,8 @@
 
 													if(HAL_GPIO_ReadPin(CHARGE_IN_GPIO_PORT,CHARGE_IN_PIN))		/* high => charger stopped charging */
 													{
+														battery_charger_counter = 30;
 														batteryChargerState = Charger_Finished;
-														global.dataSendToMaster.chargeStatus = CHARGER_complete;
-														global.deviceDataSendToMaster.chargeStatus = CHARGER_complete;
-														battery_charger_counter = 30;
-														notifyChargeComplete = 1;
 													}
 													else
 													{
@@ -279,117 +242,11 @@
 													HAL_Delay(1);
 											break;
 
-					default:						/* wait for disconnection */
+					default:						batteryChargerState = Charger_NotConnected; 	/* unexpected state => reinitialize state machine */
 						break;
 			}
 		}
 	}
-#else
-	/* on disconnection or while disconnected */
-	if(HAL_GPIO_ReadPin(CHARGE_IN_GPIO_PORT,CHARGE_IN_PIN))
-	{
-		if(battery_charger_counter)
-		{
-			battery_charger_counter--;
-			global.dataSendToMaster.chargeStatus = CHARGER_lostConnection;
-			global.deviceDataSendToMaster.chargeStatus = CHARGER_lostConnection;
-		}
-		/* max count down to 127+5 or 127+20 */
-		if((battery_i_charge_status == 255) && battery_charger_counter < 127)
-		{
-//			battery_gas_gauge_set_charge_full();
-//			scheduleUpdateDeviceDataChargerFull();
-			battery_charger_counter = 0;
-		}
-		
-		if(battery_charger_counter == 0)
-		{
-			battery_i_charge_status = 0;
-			global.dataSendToMaster.chargeStatus = CHARGER_off;
-			global.deviceDataSendToMaster.chargeStatus = CHARGER_off;
-
-		}
-		return;
-	}
-
-	/* connected */
-	
-	/* wait for disconnection to write and reset */
-	if(battery_i_charge_status == 255)
-	{
-		global.dataSendToMaster.chargeStatus = CHARGER_complete;
-		global.deviceDataSendToMaster.chargeStatus = CHARGER_complete;
-		
-		if(((cycleTimeBase > 1) && (battery_charger_counter < 127+5)) || (battery_charger_counter < 127+20))
-		battery_charger_counter++;
-		return;
-	}
-
-	if(battery_charger_counter == 0)
-		battery_i_charge_status = 1;
-
-	/* charger is connected and didn't signal full yet */
-	global.dataSendToMaster.chargeStatus = CHARGER_running;
-	global.deviceDataSendToMaster.chargeStatus = CHARGER_running;
-
-	GPIO_InitTypeDef   GPIO_InitStructure;
-    GPIO_InitStructure.Pin = CHARGE_OUT_PIN;
-    GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
-    GPIO_InitStructure.Pull = GPIO_NOPULL;
-    GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
-    HAL_GPIO_Init(CHARGE_OUT_GPIO_PORT, &GPIO_InitStructure); 
-	HAL_GPIO_WritePin(CHARGE_OUT_GPIO_PORT, CHARGE_OUT_PIN,GPIO_PIN_SET);
-	HAL_Delay(1);
-
-	
-	if(battery_charger_counter < 120)
-	{
-		if(cycleTimeBase == 1)
-			battery_charger_counter++;
-		else
-		{
-			battery_charger_counter += 30;
-			if(battery_charger_counter >= 127)
-				battery_charger_counter = 126;
-		}
-	}
-	else
-	if(battery_charger_counter < 127)
-	{
-		battery_charger_counter = 127;
-		if(battery_i_charge_status < 2)
-		{
-			battery_i_charge_status = 2;
-			scheduleUpdateDeviceDataChargerCharging();
-		}
-	}
-
-	if(battery_charger_counter >= 127)
-	{
-		if(HAL_GPIO_ReadPin(CHARGE_IN_GPIO_PORT,CHARGE_IN_PIN) || (get_voltage() >= 4.1f))
-		{
-			battery_charger_counter++;
-			if(((cycleTimeBase > 1) && (battery_charger_counter > 127+5)) || (battery_charger_counter > 127+20))
-			{
-				battery_charger_counter = 127;
-				if(get_voltage() >= 4.1f)
-				{
-					battery_i_charge_status = 255;
-					battery_gas_gauge_set_charge_full();
-					scheduleUpdateDeviceDataChargerFull();
-				}					
-			}
-		}
-		else
-			battery_charger_counter = 127;
-	}
-
-  GPIO_InitStructure.Pin = CHARGE_OUT_PIN;
-  GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;
-  GPIO_InitStructure.Pull = GPIO_NOPULL;
-  GPIO_InitStructure.Speed = GPIO_SPEED_LOW;
-  HAL_GPIO_Init(CHARGE_OUT_GPIO_PORT, &GPIO_InitStructure); 
-#endif
 }
 
 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
--- a/Small_CPU/Src/externalInterface.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Small_CPU/Src/externalInterface.c	Wed Aug 14 16:44:46 2024 +0200
@@ -34,6 +34,7 @@
 #include "pressure.h"
 #include "uartProtocol_O2.h"
 #include "uartProtocol_Co2.h"
+#include "uartProtocol_Sentinel.h"
 
 extern SGlobal global;
 extern UART_HandleTypeDef huart1;
@@ -67,6 +68,7 @@
 static uint8_t recBuf[ADC_ANSWER_LENGTH];
 static uint8_t timeoutCnt = 0;
 static uint8_t externalInterfacePresent = 0;
+static uint8_t delayAdcConversion = 0;
 
 float externalChannel_mV[MAX_ADC_CHANNEL];
 static uint8_t  externalV33_On = 0;
@@ -103,6 +105,7 @@
 	activeChannel = 0;
 	timeoutCnt = 0;
 	externalInterfacePresent = 0;
+	delayAdcConversion = 0;
 	if(externalInterface_StartConversion(activeChannel) == HAL_OK)
 	{
 		externalInterfacePresent = 1;
@@ -170,7 +173,15 @@
 
 	if(externalADC_On)
 	{
-		if(I2C_Master_Receive(DEVICE_EXTERNAL_ADC, recBuf, ADC_ANSWER_LENGTH) == HAL_OK)
+		if(delayAdcConversion)
+		{
+			if(UART_isComActive(activeUartChannel) == 0)
+			{
+				externalInterface_StartConversion(activeChannel);
+				delayAdcConversion = 0;
+			}
+		}
+		else if(I2C_Master_Receive(DEVICE_EXTERNAL_ADC, recBuf, ADC_ANSWER_LENGTH) == HAL_OK)
 		{
 			if((recBuf[ANSWER_CONFBYTE_INDEX] & ADC_START_CONVERSION) == 0)		/* !ready set => received data contains new value */
 			{
@@ -194,25 +205,23 @@
 				}
 
 				activeChannel = nextChannel;
-				externalInterface_StartConversion(activeChannel);
-				timeoutCnt = 0;
-			}
-			else
-			{
-				if(timeoutCnt++ >= ADC_TIMEOUT)
+				if(UART_isComActive(activeUartChannel) == 0)
 				{
 					externalInterface_StartConversion(activeChannel);
-					timeoutCnt = 0;
 				}
-			}
-		}
-		else		/* take also i2c bus disturb into account */
-		{
-			if(timeoutCnt++ >= ADC_TIMEOUT)
-			{
-				externalInterface_StartConversion(activeChannel);
+				else
+				{
+					delayAdcConversion = 1;
+				}
 				timeoutCnt = 0;
 			}
+
+		}
+		if(timeoutCnt++ >= ADC_TIMEOUT)
+		{
+			externalInterface_StartConversion(activeChannel);
+			delayAdcConversion = 0;
+			timeoutCnt = 0;
 		}
 	}
 	return retval;
@@ -368,18 +377,18 @@
 {
 	switch(protocol)
 	{
-		case 0:
-		case (EXT_INTERFACE_UART_CO2 >> 8):
-		case (EXT_INTERFACE_UART_O2 >> 8):
-		case (EXT_INTERFACE_UART_SENTINEL >> 8):
+		case EXT_INTERFACE_UART_OFF:
+		case EXT_INTERFACE_UART_CO2:
+		case EXT_INTERFACE_UART_O2:
+		case EXT_INTERFACE_UART_SENTINEL:
 				if((externalAutoDetect <= DETECTION_START)
-					|| ((protocol == EXT_INTERFACE_UART_O2 >> 8) && (externalAutoDetect >= DETECTION_UARTMUX) && (externalAutoDetect <= DETECTION_DIGO2_3))
+					|| ((protocol == EXT_INTERFACE_UART_O2) && (externalAutoDetect >= DETECTION_UARTMUX) && (externalAutoDetect <= DETECTION_DIGO2_3))
 
 #ifdef ENABLE_CO2_SUPPORT
 					|| ((externalAutoDetect >= DETECTION_CO2_0) && (externalAutoDetect <= DETECTION_CO2_3))
 #endif
 #ifdef ENABLE_SENTINEL_MODE
-														   || ((protocol == EXT_INTERFACE_UART_SENTINEL >> 8) && (externalAutoDetect == DETECTION_SENTINEL))
+														   || ((protocol == EXT_INTERFACE_UART_SENTINEL) && (externalAutoDetect == DETECTION_SENTINEL))
 #endif
 					)
 				{
@@ -599,6 +608,16 @@
 			}
 		}
 	}
+#ifdef ENABLE_SENTINEL_MODE
+	if(pMap[EXT_INTERFACE_MUX_OFFSET] == SENSOR_SENTINEL)
+	{
+		for(index2 = 0; index2 < MAX_ADC_CHANNEL; index2++)
+		{
+				pMap[index2] = SENSOR_SENTINELM;		/* store a mirror instance needed for visualization */
+				Mux2ADCMap[index2] = index2 + EXT_INTERFACE_MUX_OFFSET;
+		}
+	}
+#endif
 }
 
 uint8_t* externalInterface_GetSensorMapPointer(uint8_t finalMap)
@@ -651,7 +670,7 @@
 									if(externalInterfacePresent)
 									{
 										externalInterface_SwitchPower33(0);
-										externalInterface_SwitchUART(0);
+										externalInterface_SwitchUART(EXT_INTERFACE_UART_OFF);
 										for(index = 0; index < MAX_ADC_CHANNEL; index++)
 										{
 											externalChannel_mV[index] = 0;
@@ -686,7 +705,7 @@
 									}
 									externalInterfaceMuxReqIntervall = 1100;
 									externalAutoDetect = DETECTION_UARTMUX;
-									externalInterface_SwitchUART(EXT_INTERFACE_UART_O2 >> 8);
+									externalInterface_SwitchUART(EXT_INTERFACE_UART_O2);
 									UART_MUX_SelectAddress(MAX_MUX_CHANNEL);
 									uartO2_SetChannel(MAX_MUX_CHANNEL);
 									activeUartChannel = MAX_MUX_CHANNEL;
@@ -707,7 +726,7 @@
 										activeUartChannel = 0;
 										tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_DIGO2;
 										externalInterface_SensorState[EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT;
-										externalInterface_SwitchUART(EXT_INTERFACE_UART_O2 >> 8);
+										externalInterface_SwitchUART(EXT_INTERFACE_UART_O2);
 										if(foundSensorMap[EXT_INTERFACE_SENSOR_CNT-1] == SENSOR_MUX)
 										{
 											UART_MUX_SelectAddress(0);
@@ -724,7 +743,7 @@
 									tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_NONE;
 									if(uartMuxChannel)
 									{
-										externalInterface_SwitchUART(EXT_INTERFACE_UART_O2 >> 8);
+										externalInterface_SwitchUART(EXT_INTERFACE_UART_O2);
 										UART_MUX_SelectAddress(uartMuxChannel);
 										externalInterface_SensorState[uartMuxChannel + EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT;
 										uartO2_SetChannel(uartMuxChannel);
@@ -789,32 +808,40 @@
 									}
 									else
 									{
+#ifdef ENABLE_SENTINEL_MODE
+										externalAutoDetect = DETECTION_SENTINEL;
+#else
 										externalAutoDetect = DETECTION_DONE;
+#endif
 									}
 #endif
 #ifdef ENABLE_SENTINEL_MODE
 									if(externalAutoDetect == DETECTION_SENTINEL)
 									{
-										externalInterface_SwitchUART(EXT_INTERFACE_UART_SENTINEL >> 8);
+										externalInterface_SensorState[EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT;
+										uartO2_SetChannel(0);
+										activeUartChannel = 0;
+										tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_SENTINEL;
+										externalInterface_SwitchUART(EXT_INTERFACE_UART_SENTINEL);
+										externalInterface_CheckBaudrate(SENSOR_SENTINEL);
 										UART_StartDMA_Receiption();
 									}
 				break;
 
 			case DETECTION_SENTINEL:
 			case DETECTION_SENTINEL2:
-									if(UART_isSentinelConnected())
+									if(uartSentinel_isSensorConnected())
 									{
-										for(index = 0; index < 3; index++)	/* Sentinel is occupiing all sensor slots */
+										for(index = EXT_INTERFACE_MUX_OFFSET; index < EXT_INTERFACE_MUX_OFFSET+3; index++)
 										{
-											tmpSensorMap[index] = SENSOR_SENTINEL;
+											foundSensorMap[index] = SENSOR_SENTINEL;
 										}
-										sensorIndex = 3;
 									}
 									externalAutoDetect++;
 #endif
 				break;
 			case DETECTION_DONE:	externalAutoDetect = DETECTION_OFF;
-									externalInterface_SwitchUART(0);
+									externalInterface_SwitchUART(EXT_INTERFACE_UART_OFF);
 									activeUartChannel = 0xFF;
 									cntSensor = 0;
 									cntUARTSensor = 0;
@@ -829,6 +856,14 @@
 										{
 											cntUARTSensor++;
 										}
+#ifdef ENABLE_SENTINEL_MODE
+										if(foundSensorMap[index] == SENSOR_SENTINEL)		/* The Sentinel has a fixed setup */
+										{
+											cntSensor = 3;
+											cntUARTSensor = 1;
+											break;
+										}
+#endif
 									}
 									externalInface_MapUartToLegacyADC(foundSensorMap);
 									externalInterfaceMuxReqIntervall = 0xFFFF;
@@ -941,6 +976,7 @@
 
 	switch(sensorType)
 	{
+			case SENSOR_SENTINEL:
 			case SENSOR_CO2:		newBaudrate = 9600;
 				break;
 			case SENSOR_DIGO2:
@@ -976,6 +1012,8 @@
 
 			switch(pmap[activeUartChannel + EXT_INTERFACE_MUX_OFFSET])
 			{
+				case SENSOR_SENTINEL: externalInterface_CheckBaudrate(SENSOR_SENTINEL);
+					break;
 				case SENSOR_CO2: externalInterface_CheckBaudrate(SENSOR_CO2);
 					break;
 				default:
@@ -1067,6 +1105,10 @@
 				case SENSOR_CO2:	uartCo2_Control();
 					break;
 #endif
+#ifdef ENABLE_SENTINEL_MODE
+				case SENSOR_SENTINEL: uartSentinel_Control();
+				break;
+#endif
 				default:
 					break;
 			}
@@ -1077,7 +1119,7 @@
 
 #if 0
 #ifdef ENABLE_SENTINEL_MODE
-		if(externalInterface_GetUARTProtocol() & (EXT_INTERFACE_UART_SENTINEL >> 8))
+		if(externalInterface_GetUARTProtocol() & (EXT_INTERFACE_UART_SENTINEL))
 		{
 			UART_HandleSentinelData();
 		}
--- a/Small_CPU/Src/pressure.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Small_CPU/Src/pressure.c	Wed Aug 14 16:44:46 2024 +0200
@@ -130,6 +130,7 @@
 		for(int i=0; i<PRESSURE_SURFACE_QUE; i++)
 			surface_ring_mbar[i] = ambient_pressure_mbar;
 		surface_pressure_mbar = ambient_pressure_mbar;
+		surface_pressure_stable_value = surface_pressure_mbar;
 		surface_pressure_writeIndex = 0;			/* index of the oldest value in the ring buffer */
 	}
 }
@@ -236,8 +237,9 @@
 
 			secondCounterSurfaceRing = 0;
 			avgCount = 1;	/* use the current value as starting point but restart the weight decrement of the measurements */
+
+			evaluate_surface_pressure();
 		}
-		evaluate_surface_pressure();
 	}
 }
 
@@ -529,12 +531,17 @@
 
 
 #ifdef SIMULATE_PRESSURE
+
+#define SECDIV		10		/* update every 100ms */
+
 void pressure_simulation()
 {
 	static uint32_t tickstart = 0;
 	static float pressure_sim_mbar = 0;
 	static uint32_t passedSecond = 0;
 	static uint32_t secondtick = 0;
+	static uint32_t lastsecondtick = 0;
+	static float delta_mbar = 0.0;
 
 	uint32_t lasttick = 0;
 
@@ -548,11 +555,16 @@
 	}
 
 	lasttick = HAL_GetTick();
-	if(time_elapsed_ms(secondtick,lasttick) > 1000) /* one second passed since last tick */
+	if(time_elapsed_ms(secondtick,lasttick) >= (1000 / SECDIV)) /* one second passed since last tick */
 	{
+		if(time_elapsed_ms(lastsecondtick,lasttick) > 1000)
+		{
+			passedSecond++;
+			lastsecondtick = lasttick;
+		}
 		secondtick = lasttick;
-		passedSecond++;
 
+#define DIVE_AT_SPEED 1
 #ifdef DIVE_AFTER_LANDING
 		if(passedSecond < 10) pressure_sim_mbar = 1000.0;	 /* stay stable for 10 seconds */
 		else if(passedSecond < 300) pressure_sim_mbar -= 1.0; /* decrease pressure in 5 minutes target 770mbar => delta 330 */
@@ -563,6 +575,26 @@
 		else if(passedSecond < 2300) pressure_sim_mbar += 0.0;  /* stay on depth */
 		else if(passedSecond < 2500) pressure_sim_mbar -= 10.0; /* return to surface */
 		else pressure_sim_mbar = 1000.0;					/* final state */
+#endif
+#ifdef DIVE_AT_SPEED
+		if(passedSecond < 10) pressure_sim_mbar = 1000.0;	   /* stay stable for 10 seconds */
+		else if(passedSecond < 20) delta_mbar = 200.0 / SECDIV; /* Start dive */
+		else if(passedSecond < 30) delta_mbar = 0.0;	/*stay on depth*/
+		else if(passedSecond < 45) delta_mbar -= 0.2 / SECDIV;	/* return to surface */
+		else if(passedSecond < 40) delta_mbar -= 0.4 / SECDIV;   /* stay */
+		else if(passedSecond < 50) delta_mbar += 0.3 / SECDIV; /* get ready for second dive */
+		else if(passedSecond < 60) delta_mbar -= 0.4;	/*stay on depth*/
+		else if(passedSecond < 70) delta_mbar = 0.2;
+		else if(passedSecond < 1060) pressure_sim_mbar -= 10.0/ SECDIV;	/* return to surface */
+		else if(passedSecond < 1200) pressure_sim_mbar += 0.0;   /* stay */
+		else { pressure_sim_mbar = 1000.0;	delta_mbar = 0.0;}				/* final state */
+
+		pressure_sim_mbar += delta_mbar;
+		if(pressure_sim_mbar < surface_pressure_mbar)
+		{
+			pressure_sim_mbar = surface_pressure_mbar;
+		}
+
 #else	/* short dive */
 		if(passedSecond < 10) pressure_sim_mbar = 1000.0;	   /* stay stable for 10 seconds */
 		else if(passedSecond < 180) pressure_sim_mbar += 10.0; /* Start dive */
@@ -685,7 +717,7 @@
 
 	if(ambient_pressure_mbar < PRESSURE_MINIMUM)
 	{
-		ambient_pressure_mbar = 1000.0;
+		ambient_pressure_mbar = 1000.0 + pressure_offset;
 	}
 }
 
--- a/Small_CPU/Src/scheduler.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Small_CPU/Src/scheduler.c	Wed Aug 14 16:44:46 2024 +0200
@@ -142,7 +142,7 @@
 
 	global.dataSendToMaster.RTE_VERSION_high = firmwareVersionHigh();//RTE_VERSION_HIGH;;
 	global.dataSendToMaster.RTE_VERSION_low = firmwareVersionLow();//RTE_VERSION_LOW;;
-	global.dataSendToMaster.chargeStatus = 0;
+	global.dataSendToMaster.chargeStatus = CHARGER_off;
 	
 	global.dataSendToMaster.power_on_reset = 0;
 	global.dataSendToMaster.header.checkCode[0] = 0xA1;
@@ -160,7 +160,7 @@
 
 	global.deviceDataSendToMaster.RTE_VERSION_high = firmwareVersionHigh();//RTE_VERSION_HIGH;
 	global.deviceDataSendToMaster.RTE_VERSION_low = firmwareVersionLow();//RTE_VERSION_LOW;
-	global.deviceDataSendToMaster.chargeStatus = 0;
+	global.deviceDataSendToMaster.chargeStatus = CHARGER_off;
 
 	global.deviceDataSendToMaster.power_on_reset = 0;
 	global.deviceDataSendToMaster.header.checkCode[0] = 0xDF;
@@ -480,6 +480,8 @@
 {
 	uint32_t ticksdiff = 0; 
 	uint32_t lasttick = 0;
+	uint32_t lastPressureTick = 0;
+	uint32_t tickPressureDiff = 0;
 	uint8_t extAdcChannel = 0;
 	uint8_t counterAscentRate = 0;
 	float lastPressure_bar = 0.0f;
@@ -552,18 +554,21 @@
 						global.lifeData.counterSecondsShallowDepth = (global.settings.timeoutDiveReachedZeroDepth - 10);
 				}
 #endif
-				
-				//Calc ascentrate every two second (20 * 100 ms)
+
 				counterAscentRate++;
-				if(counterAscentRate == 20)
+				if(counterAscentRate == 4)
 				{
-					global.lifeData.pressure_ambient_bar = get_pressure_mbar() / 1000.0f;
-					if(lastPressure_bar >= 0)
+					tickPressureDiff = time_elapsed_ms(lastPressureTick,lasttick); /* Calculate ascent rate every 400ms use timer to take care for small time shifts */
+					if(tickPressureDiff != 0)
 					{
-							//2 seconds * 30 == 1 minute, bar * 10 = meter
-							global.lifeData.ascent_rate_meter_per_min = (lastPressure_bar - global.lifeData.pressure_ambient_bar)  * 30 * 10;
+						global.lifeData.pressure_ambient_bar = get_pressure_mbar() / 1000.0f;
+						if(lastPressure_bar >= 0)
+						{
+							global.lifeData.ascent_rate_meter_per_min = (lastPressure_bar - global.lifeData.pressure_ambient_bar)  * (60000.0 / tickPressureDiff) * 10; /* bar * 10 = meter */
+						}
 					}
 					lastPressure_bar = global.lifeData.pressure_ambient_bar;
+					lastPressureTick = lasttick;
 					counterAscentRate = 0;
 				}
 				copyPressureData();
--- a/Small_CPU/Src/uart.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Small_CPU/Src/uart.c	Wed Aug 14 16:44:46 2024 +0200
@@ -22,6 +22,7 @@
 #include "uart.h"
 #include "uartProtocol_O2.h"
 #include "uartProtocol_Co2.h"
+#include "uartProtocol_Sentinel.h"
 #include "externalInterface.h"
 #include "data_exchange.h"
 #include <string.h>	/* memset */
@@ -44,9 +45,6 @@
 static uint8_t dmaActive;								/* Indicator if DMA reception needs to be started */
 
 
-static uint8_t SentinelConnected = 0;					/* Binary indicator if a sensor is connected or not */
-
-
 /* Exported functions --------------------------------------------------------*/
 
 
@@ -72,9 +70,6 @@
   lastCmdIndex = 0;
   rxWriteIndex = 0;
   dmaActive = 0;
-
-  SentinelConnected = 0;
-
 }
 
 void MX_USART1_UART_DeInit(void)
@@ -166,28 +161,6 @@
 	}
 	*puint64 = result;
 }
-void ConvertByteToHexString(uint8_t byte, char* str)
-{
-	uint8_t worker = 0;
-	uint8_t digit = 0;
-	uint8_t digitCnt = 1;
-
-	worker = byte;
-	while((worker!=0) && (digitCnt != 255))
-	{
-		digit = worker % 16;
-		if( digit < 10)
-		{
-			digit += '0';
-		}
-		else
-		{
-			digit += 'A' - 10;
-		}
-		str[digitCnt--]= digit;
-		worker = worker / 16;
-	}
-}
 
 void UART_StartDMA_Receiption()
 {
@@ -223,164 +196,6 @@
 	}
 }
 
-#ifdef ENABLE_SENTINEL_MODE
-void UART_HandleSentinelData(void)
-{
-	uint8_t localRX = rxReadIndex;
-	static uint8_t dataType = 0;
-	static uint32_t dataValue[3];
-	static uint8_t dataValueIdx = 0;
-	static receiveState_t rxState = RX_Ready;
-	static uint32_t lastReceiveTick = 0;
-	static uint8_t lastAlive = 0;
-	static uint8_t curAlive = 0;
-	static uint8_t checksum = 0;
-	static char checksum_str[]="00";
-
-	while((rxBuffer[localRX]!=0))
-	{
-		lastReceiveTick = HAL_GetTick();
-
-		switch(rxState)
-		{
-			case RX_Ready:	if((rxBuffer[localRX] >= 'a') && (rxBuffer[localRX] <= 'z'))
-							{
-								rxState = RX_DetectStart;
-								curAlive = rxBuffer[localRX];
-								checksum = 0;
-							}
-					break;
-
-			case RX_DetectStart: 	checksum += rxBuffer[localRX];
-									if(rxBuffer[localRX] == '1')
-								 	{
-								 		rxState = RX_SelectData;
-								 		dataType = 0xFF;
-
-								 	}
-									else
-									{
-										rxState = RX_Ready;
-									}
-					break;
-
-			case RX_SelectData:		checksum += rxBuffer[localRX];
-									switch(rxBuffer[localRX])
-									{
-										case 'T':	dataType = rxBuffer[localRX];
-											break;
-										case '0': 	if(dataType != 0xff)
-													{
-														rxState = RX_Data0;
-														dataValueIdx = 0;
-														dataValue[0] = 0;
-
-													}
-													else
-													{
-														rxState = RX_Ready;
-													}
-											break;
-										default:	rxState = RX_Ready;
-									}
-					break;
-
-			case RX_Data0:
-			case RX_Data1:
-			case RX_Data2:
-			case RX_Data4:
-			case RX_Data5:
-			case RX_Data6:
-			case RX_Data8:
-			case RX_Data9:
-			case RX_Data10: checksum += rxBuffer[localRX];
-							if((rxBuffer[localRX] >= '0') && (rxBuffer[localRX] <= '9'))
-							{
-								dataValue[dataValueIdx] = dataValue[dataValueIdx] * 10 + (rxBuffer[localRX] - '0');
-								rxState++;
-							}
-							else
-							{
-								rxState = RX_Ready;
-							}
-					break;
-
-			case RX_Data3:
-			case RX_Data7:	checksum += rxBuffer[localRX];
-							if(rxBuffer[localRX] == '0')
-							{
-								rxState++;
-								dataValueIdx++;
-								dataValue[dataValueIdx] = 0;
-							}
-							else
-							{
-								rxState = RX_Ready;
-							}
-					break;
-			case RX_Data11: rxState = RX_DataComplete;
-							ConvertByteToHexString(checksum,checksum_str);
-							if(rxBuffer[localRX] == checksum_str[0])
-							{
-								rxState = RX_DataComplete;
-							}
-							else
-							{
-								rxState = RX_Ready;
-							}
-
-				break;
-
-			case RX_DataComplete:	if(rxBuffer[localRX] == checksum_str[1])
-									{
-										setExternalInterfaceChannel(0,(float)(dataValue[0] / 10.0));
-										setExternalInterfaceChannel(1,(float)(dataValue[1] / 10.0));
-										setExternalInterfaceChannel(2,(float)(dataValue[2] / 10.0));
-										SentinelConnected = 1;
-									}
-									rxState = RX_Ready;
-				break;
-
-
-			default:				rxState = RX_Ready;
-				break;
-
-		}
-		localRX++;
-		rxReadIndex++;
-		if(rxReadIndex >= CHUNK_SIZE * CHUNKS_PER_BUFFER)
-		{
-			localRX = 0;
-			rxReadIndex = 0;
-		}
-	}
-
-	if(time_elapsed_ms(lastReceiveTick,HAL_GetTick()) > 4000)	/* check for communication timeout */
-	{
-		if(curAlive == lastAlive)
-		{
-			setExternalInterfaceChannel(0,0.0);
-			setExternalInterfaceChannel(1,0.0);
-			setExternalInterfaceChannel(2,0.0);
-			SentinelConnected = 0;
-		}
-		lastAlive = curAlive;
-	}
-
-	if((dmaActive == 0)	&& (externalInterface_isEnabledPower33()))	/* Should never happen in normal operation => restart in case of communication error */
-	{
-		UART_StartDMA_Receiption();
-	}
-}
-#endif
-
-
-
-uint8_t UART_isSentinelConnected()
-{
-	return SentinelConnected;
-}
-
 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
 {
     if(huart == &huart1)
@@ -413,6 +228,10 @@
 			case SENSOR_CO2:	uartCo2_ProcessData(rxBuffer[localRX]);
 				break;
 #endif
+#ifdef ENABLE_SENTINEL_MODE
+			case SENSOR_SENTINEL:	uartSentinel_ProcessData(rxBuffer[localRX]);
+				break;
+#endif
 			default:
 				break;
 		}
@@ -441,6 +260,17 @@
 	}
 }
 
+uint8_t UART_isComActive(uint8_t sensorId)
+{
+	uint8_t active = 1;
 
+	uint8_t ComState = externalInterface_GetSensorState(sensorId + EXT_INTERFACE_MUX_OFFSET);
+
+	if((ComState == UART_COMMON_INIT) || (ComState == UART_COMMON_IDLE) || (ComState == UART_COMMON_ERROR))
+	{
+		active = 0;
+	}
+	return active;
+}
 
 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
--- a/Small_CPU/Src/uartProtocol_Co2.c	Tue Aug 13 13:24:54 2024 +0200
+++ b/Small_CPU/Src/uartProtocol_Co2.c	Wed Aug 14 16:44:46 2024 +0200
@@ -27,7 +27,7 @@
 
 #ifdef ENABLE_CO2_SUPPORT
 static uint8_t CO2Connected = 0;						/* Binary indicator if a sensor is connected or not */
-static receiveState_t rxState = RX_Ready;
+static receiveStateCO2_t rxState = CO2RX_Ready;
 
 
 
@@ -137,7 +137,7 @@
 	uint8_t activeSensor = externalInterface_GetActiveUartSensor();
 	uartCO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET);
 
-	if(rxState == RX_Ready)		/* identify data content */
+	if(rxState == CO2RX_Ready)		/* identify data content */
 	{
 		switch(data)
 		{
@@ -146,7 +146,7 @@
 			case 'D':
 			case 'Z':
 			case '.':			dataType = data;
-								rxState = RX_Data0;
+								rxState = CO2RX_Data0;
 								dataValue = 0;
 				break;
 			case '?':			localComState = UART_CO2_ERROR;
@@ -157,26 +157,26 @@
 	}
 	else if((data >= '0') && (data <= '9'))
 	{
-		if((rxState >= RX_Data0) && (rxState <= RX_Data4))
+		if((rxState >= CO2RX_Data0) && (rxState <= CO2RX_Data4))
 		{
 			dataValue = dataValue * 10 + (data - '0');
 			rxState++;
-			if(rxState == RX_Data5)
+			if(rxState == CO2RX_Data5)
 			{
-				rxState = RX_DataComplete;
+				rxState = CO2RX_DataComplete;
 			}
 		}
 		else	/* protocol error data has max 5 digits */
 		{
-			if(rxState != RX_DataComplete)	/* commands will not answer with number values */
+			if(rxState != CO2RX_DataComplete)	/* commands will not answer with number values */
 			{
-				rxState = RX_Ready;
+				rxState = CO2RX_Ready;
 			}
 		}
 	}
 	if((data == ' ') || (data == '\n'))	/* Abort data detection */
 	{
-		if(rxState == RX_DataComplete)
+		if(rxState == CO2RX_DataComplete)
 		{
 			CO2Connected = 1;
 			if(localComState == UART_CO2_SETUP)
@@ -204,13 +204,13 @@
 					break;
 				case '.':			externalInterface_SetCO2Scale(dataValue);
 					break;
-				default:			rxState = RX_Ready;
+				default:			rxState = CO2RX_Ready;
 					break;
 			}
 		}
-		if(rxState != RX_Data0)	/* reset state machine because message in wrong format */
+		if(rxState != CO2RX_Data0)	/* reset state machine because message in wrong format */
 		{
-			rxState = RX_Ready;
+			rxState = CO2RX_Ready;
 		}
 	}
 	externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Small_CPU/Src/uartProtocol_Sentinel.c	Wed Aug 14 16:44:46 2024 +0200
@@ -0,0 +1,195 @@
+/**
+  ******************************************************************************
+  * @file    uartProtocol_Co2.c
+  * @author  heinrichs weikamp gmbh
+  * @version V0.0.1
+  * @date    15-Jan-2024
+  * @brief   Interface functionality to read data from Sentinel rebreather
+  *
+  @verbatim
+
+
+  @endverbatim
+  ******************************************************************************
+  * @attention
+  *
+  * <h2><center>&copy; COPYRIGHT(c) 2024 heinrichs weikamp</center></h2>
+  *
+  ******************************************************************************
+  */
+/* Includes ------------------------------------------------------------------*/
+
+#include <string.h>
+#include <uartProtocol_Sentinel.h>
+#include "uart.h"
+#include "externalInterface.h"
+
+
+#ifdef ENABLE_SENTINEL_MODE
+static uint8_t SentinelConnected = 0;						/* Binary indicator if a sensor is connected or not */
+static receiveStateSentinel_t rxState = SENTRX_Ready;
+
+void ConvertByteToHexString(uint8_t byte, char* str)
+{
+	uint8_t worker = 0;
+	uint8_t digit = 0;
+	uint8_t digitCnt = 1;
+
+	worker = byte;
+	while((worker!=0) && (digitCnt != 255))
+	{
+		digit = worker % 16;
+		if( digit < 10)
+		{
+			digit += '0';
+		}
+		else
+		{
+			digit += 'A' - 10;
+		}
+		str[digitCnt--]= digit;
+		worker = worker / 16;
+	}
+}
+
+void uartSentinel_Control(void)
+{
+	uint8_t activeSensor = externalInterface_GetActiveUartSensor();
+	uartSentinelStatus_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET);
+
+	if(localComState == UART_SENTINEL_INIT)
+	{
+		SentinelConnected = 0;
+		UART_StartDMA_Receiption();
+		localComState = UART_SENTINEL_IDLE;
+	}
+	externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState);
+}
+
+void uartSentinel_ProcessData(uint8_t data)
+{
+	static uint8_t dataType = 0;
+	static uint32_t dataValue[3];
+	static uint8_t dataValueIdx = 0;
+
+	static uint8_t checksum = 0;
+	static char checksum_str[]="00";
+
+	uint8_t activeSensor = externalInterface_GetActiveUartSensor();
+	uartSentinelStatus_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET);
+
+	switch(rxState)
+	{
+			case SENTRX_Ready:	if((data >= 'a') && (data <= 'z'))
+							{
+								rxState = SENTRX_DetectStart;
+								checksum = 0;
+							}
+					break;
+
+			case SENTRX_DetectStart: 	checksum += data;
+									if(data == '1')
+								 	{
+								 		rxState = SENTRX_SelectData;
+								 		dataType = 0xFF;
+
+								 	}
+									else
+									{
+										rxState = SENTRX_Ready;
+									}
+					break;
+
+			case SENTRX_SelectData:		checksum += data;
+									switch(data)
+									{
+										case 'T':	dataType = data;
+											break;
+										case '0': 	if(dataType != 0xff)
+													{
+														rxState = SENTRX_Data0;
+														dataValueIdx = 0;
+														dataValue[0] = 0;
+
+													}
+													else
+													{
+														rxState = SENTRX_Ready;
+													}
+											break;
+										default:	rxState = SENTRX_Ready;
+									}
+					break;
+
+			case SENTRX_Data0:
+			case SENTRX_Data1:
+			case SENTRX_Data2:
+			case SENTRX_Data4:
+			case SENTRX_Data5:
+			case SENTRX_Data6:
+			case SENTRX_Data8:
+			case SENTRX_Data9:
+			case SENTRX_Data10: checksum += data;
+							if((data >= '0') && (data <= '9'))
+							{
+								dataValue[dataValueIdx] = dataValue[dataValueIdx] * 10 + (data - '0');
+								rxState++;
+							}
+							else
+							{
+								rxState = SENTRX_Ready;
+							}
+					break;
+
+			case SENTRX_Data3:
+			case SENTRX_Data7:	checksum += data;
+							if(data == '0')
+							{
+								rxState++;
+								dataValueIdx++;
+								dataValue[dataValueIdx] = 0;
+							}
+							else
+							{
+								rxState = SENTRX_Ready;
+							}
+					break;
+			case SENTRX_Data11: rxState = SENTRX_DataComplete;
+							ConvertByteToHexString(checksum,checksum_str);
+							if(data == checksum_str[0])
+							{
+								rxState = SENTRX_DataComplete;
+							}
+							else
+							{
+								rxState = SENTRX_Ready;
+							}
+
+				break;
+
+			case SENTRX_DataComplete:	if(data == checksum_str[1])
+									{
+										setExternalInterfaceChannel(0,(float)(dataValue[0] / 10.0));
+										setExternalInterfaceChannel(1,(float)(dataValue[1] / 10.0));
+										setExternalInterfaceChannel(2,(float)(dataValue[2] / 10.0));
+										SentinelConnected = 1;
+										localComState = UART_SENTINEL_OPERATING;
+									}
+									rxState = SENTRX_Ready;
+				break;
+
+
+			default:				rxState = SENTRX_Ready;
+				break;
+
+	}
+	externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState);
+}
+
+uint8_t uartSentinel_isSensorConnected()
+{
+	return SentinelConnected;
+}
+
+#endif
+