# HG changeset patch # User heinrichsweikamp # Date 1739293920 -3600 # Node ID c6c781a2e85b86d041dc994f795361c9d33c3db0 # Parent f7318457df4d5ddf4621c40c89ade4a41cee8ab6# Parent 7149f372b0ba70aa25152f52981afc25f0ee2118 Merge into default diff -r f7318457df4d -r c6c781a2e85b BootLoader/CPU1-F429_boot.ld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BootLoader/CPU1-F429_boot.ld Tue Feb 11 18:12:00 2025 +0100 @@ -0,0 +1,602 @@ +/***************************************************************************** + * -*- 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 . + ***************************************************************************** + * 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 + + .bootloader_hardware_data 0x0800A040 : { + PROVIDE( bootloader_HardwareData = . ); + KEEP( *(.bootloader_hardware_data) ) + } > ROM_BOOT + + .text 0x08001000 : + { + . = ALIGN(4); + *(.text.HAL*) + . = ALIGN(4); + *(.text*sprint*) + *(.text.MX*) + } >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 0x08004300 : { + *(.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) } +} diff -r f7318457df4d -r c6c781a2e85b BootLoader/Inc/base_bootloader.h --- a/BootLoader/Inc/base_bootloader.h Tue Aug 13 13:24:54 2024 +0200 +++ b/BootLoader/Inc/base_bootloader.h Tue Feb 11 18:12:00 2025 +0100 @@ -59,9 +59,6 @@ #define BASE_BOOTLOADER_H /* Includes ------------------------------------------------------------------*/ - -#define STM32F429xx - #include "stm32f4xx_hal.h" #include "tStructure.h" diff -r f7318457df4d -r c6c781a2e85b BootLoader/Src/base_bootlader.c --- a/BootLoader/Src/base_bootlader.c Tue Aug 13 13:24:54 2024 +0200 +++ b/BootLoader/Src/base_bootlader.c Tue Feb 11 18:12:00 2025 +0100 @@ -39,7 +39,7 @@ ============================================================================== 151130 hw sleep on button3 - (MX_tell_reset_logik_alles_ok() + DataEX_call() in endlos loop) + (MX_tell_reset_logik_alles_ok() + DataEX_call() in endless loop) ============================================================================== ##### bootloader specific ##### @@ -89,7 +89,7 @@ ============================================================================== ##### MainTask ##### ============================================================================== - [..] For everthing slow without importance to be 'in time'. + [..] For everything slow without importance to be 'in time'. Like VPM and Buehlmann. No sprintf and probably no GFX_SetFramesTopBottom() stuff neither. If sprintf is called while sprintf is executed it blows up everything. @@ -99,7 +99,7 @@ ============================================================================== [..] The SDRAM is handled by getFrame() and releaseFrame(). Each frame with 800*480*2 Bytes. - Be carefull to release every frame + Be careful to release every frame otherwise there will be a memory leakage over time. housekeepingFrame() in the MainTask takes care of cleaning the frames. All frames are filled with 0x00. This will be transparent with color of @@ -127,7 +127,7 @@ GFX_SetFrameTop() + GFX_SetFrameBottom() Those do not change anything on the display but give commands to.. (#) GFX_change_LTDC() The only place that changes the pointer. - This prevents erratic behaviour if several changes + This prevents erratic behavior if several changes are made within one refresh rate of the screen. Is called in IRQ by PD4 and HAL_GPIO_EXTI_IRQHandler from VSYNC signal. @@ -142,7 +142,7 @@ with automatic language switch by selected_language in SSettings see openEdit_Language() in tMenuEditSystem.c - Therefore there are differnent functions + Therefore there are different functions for example: write_label_fix() for single char multilanguage write_label_var() for strings that could include @@ -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" @@ -252,11 +265,11 @@ .versionBeta = 1, /* 4 bytes with trailing 0 */ - .signature = "cw", + .signature = "mh", - .release_year = 16, - .release_month = 4, - .release_day = 8, + .release_year = 25, + .release_month = 1, + .release_day = 13, .release_sub = 0, /* max 48 with trailing 0 */ @@ -269,24 +282,29 @@ .magic[3] = FIRMWARE_MAGIC_END }; - -const SHardwareData HardwareData __attribute__((at(HARDWAREDATA_ADDRESS))) = { +const SHardwareData HardwareData __attribute__((section(".bootloader_hardware_data"))) = +{ // first 52 bytes .primarySerial = 0xFFFF, - .primaryLicence = 0xFF, - .revision8bit = 0xFF, - .production_year = 0xFF, - .production_month = 0xFF, - .production_day = 0xFF, + .primaryLicence = 0x00, + .revision8bit = 0x02, + .production_year = 0x19, + .production_month = 0x01, + .production_day = 0x10, .production_bluetooth_name_set = 0xFF, .production_info = { - 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x4F,0x53,0x54,0x43, + 0x20,0x35,0x20,0x65,0x6E,0x64,0x2D,0x32,0x30,0x32,0x34, + 0x20,0x68,0x61,0x72,0x64,0x77,0x61,0x72,0x65,0x20,0x20, + 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20}, + +/* 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, - +*/ // other 12 bytes (64 in total) .secondarySerial = 0xFFFF, .secondaryLicence = 0xFF, @@ -418,16 +436,15 @@ uint8_t ptr; uint32_t pOffset; + const SHardwareData* HardwareData = hardwareDataGetPointer(); + set_globalState(StBoot0); HAL_Init(); HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_2); + SystemClock_Config(); - /* feedback for the user - * aber sehr unsch�n beim Warmstart - * da das letzte Bild noch lange nachleuchtet */ -// MX_GPIO_Backlight_max_static_only_Init(); - + MX_GPIO_Init(); /* button press is only 40 to 50 us low */ MX_GPIO_One_Button_only_Init(); @@ -442,8 +459,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 +512,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); @@ -574,7 +587,7 @@ /* here comes the variable upper firmware loader */ if((i == 0) && (status == HAL_OK)) { - tInfo_newpage("load firmware2 data"); + tInfo_newpage("load fontpack data"); uint8_t* pBuffer = (uint8_t*)((uint32_t)0xD0000000); /* blocked via GFX_init1_no_DMA */ firmware_load_result = ext_flash_read_firmware2(&pOffset, pBuffer,768000*2,0,0); @@ -646,16 +659,16 @@ if((i == 0) && (status == HAL_OK)) { - tInfo_newpage("Done."); - tInfo_write("Cleaning."); + tInfo_newpage("done."); + tInfo_write("cleaning."); ext_flash_erase_firmware_if_not_empty(); ext_flash_erase_firmware2_if_not_empty(); - tInfo_write("Reset device."); + tInfo_write("reset device."); reset_to_firmware_using_Watchdog(); } ptr = 0; - textVersion[ptr++] = '\021'; + textVersion[ptr++] = '\020'; textVersion[ptr++] = 's'; textVersion[ptr++] = 'e'; textVersion[ptr++] = 'r'; @@ -663,7 +676,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 +686,51 @@ 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; - tInfo_button_text("Exit","","Sleep"); - tInfo_newpage("Bootloader 160602"); + TIM_init(); + MX_UART_Init(); + MX_Bluetooth_PowerOn(); + tComm_init(); + + tInfo_button_text("exit","","sleep"); + tInfo_newpage("bootloader 250113"); tInfo_write("start bluetooth"); tInfo_write(""); tInfo_write(textVersion); - tInfo_write(""); + if(tComm_Set_Bluetooth_Name(0) == 0xFF) + { + tInfo_write("init bluetooth"); + if(isNewDisplay()) + { + tComm_StartBlueModBaseInit(); + } + else + { + tComm_StartBlueModConfig(); + } + } + else + { + tInfo_write("bluetooth set"); + tComm_StartBlueModConfig(); + } - TIM_init(); - MX_UART_Init(); - MX_Bluetooth_PowerOn(); - tComm_Set_Bluetooth_Name(0); - - tComm_init(); set_globalState_Base(); GFX_start_VSYNC_IRQ(); @@ -753,7 +781,7 @@ tComm_exit(); returnFromCommCleanUpRequest = 0; GFX_hwBackgroundOn(); - tInfo_button_text("Exit","","Sleep"); + tInfo_button_text("exit","","sleep"); tInfo_newpage("bluetooth disonnected"); tInfo_write(""); tInfo_write(""); @@ -799,13 +827,13 @@ if(GFX_logoStatus() != 0) return; - if(GPIO_Pin == BUTTON_BACK_PIN) // links + if(GPIO_Pin == BUTTON_BACK_PIN) // left action = ACTION_BUTTON_BACK; else - if(GPIO_Pin == BUTTON_ENTER_PIN) // mitte + if(GPIO_Pin == BUTTON_ENTER_PIN) // center action = ACTION_BUTTON_ENTER; else - if(GPIO_Pin == BUTTON_NEXT_PIN) // rechts + if(GPIO_Pin == BUTTON_NEXT_PIN) // right action = ACTION_BUTTON_NEXT; #ifdef BUTTON_CUSTOM_PIN else @@ -816,42 +844,40 @@ action = 0; get_globalStateList(&status); - switch(status.base) + if(status.base == BaseComm) { - case BaseComm: if(action == ACTION_BUTTON_BACK) { reset_to_firmware_using_Watchdog(); } - break; - - default: - if((action == ACTION_BUTTON_NEXT) && (counterToPreventSleep == 255) && (get_globalState() == StS)) - { - while(1) - { - MX_tell_reset_logik_alles_ok(); - DataEX_call(); - HAL_Delay(100); - } - } - else - if(action == ACTION_BUTTON_BACK) - { - reset_to_firmware_using_Watchdog(); - } - else - if(action == ACTION_BUTTON_CUSTOM) - { - if(get_globalState() == StS) - gotoSleep(); - } - else - if(action == ACTION_BUTTON_ENTER) - { - reset_to_update_using_system_reset(); - } - break; + } + else + { + switch (action) + { + case ACTION_BUTTON_NEXT: if((counterToPreventSleep == 255) && (get_globalState() == StS)) + { + while(1) + { + MX_tell_reset_logik_alles_ok(); + DataEX_call(); + HAL_Delay(100); + } + } + break; + case ACTION_BUTTON_BACK: reset_to_firmware_using_Watchdog(); + break; + case ACTION_BUTTON_CUSTOM: if(get_globalState() == StS) + { + gotoSleep(); + } + break; + case ACTION_BUTTON_ENTER: /* reset_to_update_using_system_reset(); old function */ + tComm_StartBlueModBaseInit(); /* new: factory reset bluetooth */ + break; + default: + break; + } } } @@ -1153,54 +1179,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 ); } @@ -1219,7 +1256,7 @@ } /** - * @brief Perform the SDRAM exernal memory inialization sequence + * @brief Perform the SDRAM external memory initialization sequence * @param hsdram: SDRAM handle * @param Command: Pointer to SDRAM command structure * @retval None @@ -1283,7 +1320,7 @@ static void DualBoot(void) { // Set BFB2 bit to enable boot from Flash Bank2 - // Allow Access to Flash control registers and user Falsh + // Allow Access to Flash control registers and user Flash HAL_FLASH_Unlock(); // Allow Access to option bytes sector @@ -1333,7 +1370,7 @@ /** * @brief DMA2D configuration. - * @note This function Configure tha DMA2D peripheral : + * @note This function Configure the DMA2D peripheral : * 1) Configure the transfer mode : memory to memory W/ pixel format conversion * 2) Configure the output color mode as ARGB4444 * 3) Configure the output memory address at SRAM memory @@ -1503,7 +1540,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); } diff -r f7318457df4d -r c6c781a2e85b Common/Drivers/STM32F4xx/Include/system_stm32f4xx.h --- a/Common/Drivers/STM32F4xx/Include/system_stm32f4xx.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Common/Drivers/STM32F4xx/Include/system_stm32f4xx.h Tue Feb 11 18:12:00 2025 +0100 @@ -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 */ /** diff -r f7318457df4d -r c6c781a2e85b Common/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h --- 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 Tue Feb 11 18:12:00 2025 +0100 @@ -44,6 +44,9 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx.h" + +extern __IO const uint8_t AHBPrescTable[16]; + /** @addtogroup STM32F4xx_LL_Driver * @{ */ diff -r f7318457df4d -r c6c781a2e85b Common/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c --- 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 Tue Feb 11 18:12:00 2025 +0100 @@ -93,6 +93,8 @@ * @{ */ + +extern __IO const uint8_t AHBPrescTable[16]; #ifdef HAL_RCC_MODULE_ENABLED /* Private typedef -----------------------------------------------------------*/ diff -r f7318457df4d -r c6c781a2e85b Common/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c --- a/Common/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Common/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c Tue Feb 11 18:12:00 2025 +0100 @@ -182,8 +182,6 @@ static void UART_EndRxTransfer(UART_HandleTypeDef *huart); static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma); static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma); -static void UART_DMATxHalfCplt(DMA_HandleTypeDef *hdma); -static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma); static void UART_DMAError(DMA_HandleTypeDef *hdma); static void UART_DMAAbortOnError(DMA_HandleTypeDef *hdma); static void UART_DMATxAbortCallback(DMA_HandleTypeDef *hdma); @@ -896,7 +894,7 @@ huart->hdmatx->XferCpltCallback = UART_DMATransmitCplt; /* Set the UART DMA Half transfer complete callback */ - huart->hdmatx->XferHalfCpltCallback = UART_DMATxHalfCplt; + huart->hdmatx->XferHalfCpltCallback = NULL; /* Set the DMA error callback */ huart->hdmatx->XferErrorCallback = UART_DMAError; @@ -960,7 +958,7 @@ huart->hdmarx->XferCpltCallback = UART_DMAReceiveCplt; /* Set the UART DMA Half transfer complete callback */ - huart->hdmarx->XferHalfCpltCallback = UART_DMARxHalfCplt; + huart->hdmarx->XferHalfCpltCallback = NULL; /* Set the DMA error callback */ huart->hdmarx->XferErrorCallback = UART_DMAError; @@ -2012,6 +2010,7 @@ } } +#ifdef HALF_COMPLETE_NEEDED /** * @brief DMA UART transmit process half complete callback * @param hdma pointer to a DMA_HandleTypeDef structure that contains @@ -2024,7 +2023,7 @@ HAL_UART_TxHalfCpltCallback(huart); } - +#endif /** * @brief DMA UART receive process complete callback. * @param hdma DMA handle @@ -2058,12 +2057,14 @@ * the configuration information for the specified DMA module. * @retval None */ +#if 0 static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma) { UART_HandleTypeDef* huart = (UART_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; HAL_UART_RxHalfCpltCallback(huart); } +#endif /** * @brief DMA UART communication error callback. diff -r f7318457df4d -r c6c781a2e85b Common/Inc/configuration.h --- a/Common/Inc/configuration.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Common/Inc/configuration.h Tue Feb 11 18:12:00 2025 +0100 @@ -34,7 +34,7 @@ /* #define ENABLE_BOTTLE_SENSOR */ /* Enable this to show voltage in parallel to charge state */ -/* #define ALWAYS_SHOW_VOLTAGE */ +#define ALWAYS_SHOW_VOLTAGE /* Enable this to skip coplete scan of dive log during startup */ #define TRUST_LOG_CONSISTENCY @@ -48,6 +48,12 @@ /* 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 runtime information displayed in t7 debug view */ +/* #define T7_DEBUG_RUNTIME */ + +/* Enable to have event based warnings being displayed as warning messages when they occur */ +/* #define HAVE_DEBUG_WARNINGS */ + /* Enable to have access to the motion control selection menu */ /* #define ENABLE_MOTION_CONTROL */ @@ -64,7 +70,10 @@ #define ENABLE_PSCR_MODE /* Enable to have CO2 sensor functionality available */ -/* #define ENABLE_CO2_SUPPORT */ +#define ENABLE_CO2_SUPPORT + +/* Enable to have GPS sensor functionality available */ +/* #define ENABLE_GNSS_SUPPORT */ /* Enable to have Sentinel rebreather interface available */ /* #define ENABLE_SENTINEL_MODE */ @@ -75,4 +84,17 @@ /* Enable if an external pressure sensor is connected at ADC channel3 (used for sensor verification) */ /* #define ENABLE_EXTERNAL_PRESSURE */ +/* Enable if the menu item predive check shall be available */ +/* #define ENABLE_PREDIVE_CHECK */ + +/* Enable to have a faster transfer speed between bluetooth module and CPU */ +#define ENABLE_FAST_COMM + +/* Enable to have position sensor support active */ +/* #define ENABLE_GPIO_V2 */ + +/* Enable RTE sleep mode debugging */ +/* #define ENABLE_SLEEP_DEBUG */ + + #endif diff -r f7318457df4d -r c6c781a2e85b Common/Inc/data_central.h --- a/Common/Inc/data_central.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Common/Inc/data_central.h Tue Feb 11 18:12:00 2025 +0100 @@ -44,6 +44,10 @@ #define EXT_INTERFACE_SENSOR_CNT (8u) /* 1 MUX + 7 sensors may be connected to the external interface (1 MUX + 3 ADC + 4 UART) */ #define EXT_INTERFACE_MUX_OFFSET (3u) /* the sensor struct starts with 3 ADC sensors */ +#define EXT_INTERFACE_BUZZER_ON_TIME_MS (2000u) /* max time the buzzer should be active without break */ +#define EXT_INTERFACE_BUZZER_STABLE_TIME_MS (500u) /* min time a state (ON / OFF) should be stable before it may be changed */ + + /* Helper structs ------------------------------------------------------------*/ //struct SGas @@ -165,6 +169,42 @@ } SDeviceState; */ +typedef struct +{ + float fLat; + float fLon; +}SGnssCoord; + + +typedef struct +{ + uint8_t year; + uint8_t month; + uint8_t day; + uint8_t hour; + uint8_t min; + uint8_t sec; +}SDateTime; + +typedef struct +{ + SGnssCoord coord; + uint8_t alive; + uint8_t fixType; + uint8_t numSat; /* number of available satellites */ + uint8_t signalQual[4]; /* signal quality indicator for x sats */ + SDateTime DateTime; /* UTC time information */ +} SGnssInfo; + +typedef enum +{ + SE_INIT = 0, + SE_REINIT, + SE_ACTIVE, + SE_END +} SSlowExitState; + + /* struct SLifeData * contains data all actual data (pressure, stuturation, etc. as received from second ship * and has actualGas to be send to Small CPU (second chip) @@ -245,6 +285,9 @@ /* for PSCR Mode */ float ppo2Simulated_bar; +/* GNSS data */ + SGnssInfo gnssData; + } SLifeData; @@ -276,6 +319,9 @@ #ifdef ENABLE_BOTTLE_SENSOR int8_t newPressure; #endif +#ifdef HAVE_DEBUG_WARNINGS + int8_t debug; +#endif } SWarnings; @@ -293,7 +339,11 @@ int16_t bailout; int16_t info_bailoutHe; int16_t info_bailoutO2; -} SEvents; + int16_t compassHeadingUpdate; + uint16_t info_compassHeadingUpdate; + int16_t gnssPositionUpdate; + SGnssCoord info_gnssPosition; +} SEvents; @@ -324,6 +374,10 @@ */ uint8_t vpm_conservatism; + /* VPM table mode, do not change during dive!!! + */ + uint8_t vpm_tableMode; + /* B�hlmann GF * and a variable that is used by Buehlmann during the dive * to remember the position of GF low during ascend @@ -351,6 +405,8 @@ uint8_t pscr_o2_drop; uint8_t pscr_lung_ratio; + + uint32_t activeAFViews; } SDiveSettings; enum CHARGE_STATUS{ @@ -401,6 +457,8 @@ timerState_e timerState; int timerStartedS; + + SScrubberData scrubberDataDive[2]; } SDiveState; @@ -446,9 +504,12 @@ SENSOR_DIGO2, SENSOR_DIGO2M, SENSOR_SENTINEL, + SENSOR_SENTINELM, SENSOR_TYPE_O2_END, SENSOR_CO2, SENSOR_CO2M, + SENSOR_GNSS, + SENSOR_GNSSM, SENSOR_MUX, SENSOR_END } externalInterfaceSensorType; @@ -520,9 +581,20 @@ uint8_t isLoopMode(uint8_t Mode); bool isCompassCalibrated(void); +void logCompassHeading(uint16_t heading); +void clearCompassHeading(void); void setCompassHeading(uint16_t heading); const SDecoinfo *getDecoInfo(void); void disableTimer(void); + +uint8_t drawingColor_from_ascentspeed(float speed); + +void convertStringOfDate_DDMMYY(char* pString, uint8_t strLen, uint8_t day, uint8_t month, uint8_t year); +void getStringOfFormat_DDMMYY(char* pString, uint8_t strLen); +void convertUTCToLocal(uint8_t utcHours, uint8_t utcMinutes, uint8_t* pLocalHours, uint8_t* pLocalMinutes); + +uint8_t calculateSlowExit(uint16_t* pCountDownSec, float* pExitDepthMeter, uint8_t* pColor); + #endif // DATA_CENTRAL_H diff -r f7318457df4d -r c6c781a2e85b Common/Inc/data_exchange.h --- a/Common/Inc/data_exchange.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Common/Inc/data_exchange.h Tue Feb 11 18:12:00 2025 +0100 @@ -33,15 +33,12 @@ /* Command definitions for control of external interface */ /* 1st nibble binary on/off states */ -/* 2nd nibble UART protocol selection */ -/* 3rd nibble reserve */ -/* 4th nibble command channel */ +/* 2nd nibble target sensor ID (if sensor command is active) */ +/* 3rd nibble sensor commands */ +/* 4th nibble control 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) */ +#define EXT_INTERFACE_BUZZER_ON (0x2000u) /* Bit set to enable the buzzer */ /* Command subset */ #define EXT_INTERFACE_AUTODETECT (0x0001u) /* Start auto detection of connected sensors */ @@ -57,6 +54,10 @@ #define CO2_WARNING_LEVEL_PPM (2000u) /* Early warning to indicate unexpected high co2 concentration (yellow) */ #define CO2_ALARM_LEVEL_PPM (5000u) /* starting by this level CO2 has a negative impact on health (long exposure) */ +#define GNSS_ALIVE_STATE_ALIVE (0x01u) /* Communication to module active */ +#define GNSS_ALIVE_STATE_TIME (0x02u) /* Time information valid */ +#define GNSS_ALIVE_BACKUP_POS (0x04u) /* Backup position not older than x hours */ + enum MODE { MODE_SURFACE = 0, @@ -202,6 +203,7 @@ //debug uint32_t pressure_uTick; uint32_t compass_uTick; + SGnssInfo gnssInfo; } SExchangeData; diff -r f7318457df4d -r c6c781a2e85b Common/Inc/settings.h --- a/Common/Inc/settings.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Common/Inc/settings.h Tue Feb 11 18:12:00 2025 +0100 @@ -120,7 +120,10 @@ uint8_t deco:1; uint8_t travel:1; uint8_t off:1; -uint8_t spare:3; +#ifdef ENABLE_DECOCALC_OPTION +uint8_t decocalc:1; +#endif +uint8_t spare:2; } gasubit8_t; typedef union{ @@ -183,6 +186,14 @@ uint8_t Corrections; } SSettingsStatus; + +typedef struct +{ + int8_t hours; + uint8_t minutes; +} StimeZone; + + /* SSettings * gas[0] and setpoint[0] are the special ones configurable during the dive */ @@ -311,6 +322,11 @@ 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; + uint8_t slowExitTime; + /* new in 0xFFFF002c */ + StimeZone timeZone; + uint8_t warningBuzzer; } SSettings; typedef struct diff -r f7318457df4d -r c6c781a2e85b Common/Src/decom.c --- a/Common/Src/decom.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Common/Src/decom.c Tue Feb 11 18:12:00 2025 +0100 @@ -37,10 +37,11 @@ #include "decom.h" #include +#include #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) { diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/base.h --- a/Discovery/Inc/base.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/base.h Tue Feb 11 18:12:00 2025 +0100 @@ -123,6 +123,12 @@ void StoreButtonAction(uint8_t action); SButtonLock get_ButtonLock(void); +#ifdef T7_DEBUG_RUNTIME +uint32_t getMainLoopTime(); +uint32_t getDecoLoopTime(); +uint32_t getGfxLoopTime(); +#endif + #endif /* BASE_H */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/check_warning.h --- a/Discovery/Inc/check_warning.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/check_warning.h Tue Feb 11 18:12:00 2025 +0100 @@ -45,4 +45,6 @@ uint8_t getSetpointHighId(void); uint8_t getSetpointLowId(void); uint8_t getSetpointDecoId(void); +void requestBuzzerActivation(uint8_t active); +uint8_t getBuzzerActivationState(); #endif // CHECK_WARNING_H diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/data_exchange_main.h --- a/Discovery/Inc/data_exchange_main.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/data_exchange_main.h Tue Feb 11 18:12:00 2025 +0100 @@ -56,6 +56,6 @@ uint16_t DataEX_debug_data(uint16_t *dataOut20x5); -void DataEX_setExtInterface_Cmd(uint16_t Cmd); +void DataEX_setExtInterface_Cmd(uint16_t Cmd,uint8_t sensorId); #endif /* DATA_EXCHANGE_MAIN_H */ diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/display.h --- a/Discovery/Inc/display.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/display.h Tue Feb 11 18:12:00 2025 +0100 @@ -29,8 +29,12 @@ void display_power_on__1_of_2__pre_RGB(void); void display_power_on__2_of_2__post_RGB(void); - void display_power_off(void); +void display_1_brightness_max(void); +void display_1_brightness_high(void); +void display_1_brightness_std(void); +void display_1_brightness_eco(void); +void display_1_brightness_cave(void); void display_sleep(void); void display_sleep_release(void); diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/gfx_engine.h --- a/Discovery/Inc/gfx_engine.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/gfx_engine.h Tue Feb 11 18:12:00 2025 +0100 @@ -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 diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/gfx_fonts.h --- a/Discovery/Inc/gfx_fonts.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/gfx_fonts.h Tue Feb 11 18:12:00 2025 +0100 @@ -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; diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/logbook.h --- a/Discovery/Inc/logbook.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/logbook.h Tue Feb 11 18:12:00 2025 +0100 @@ -212,9 +212,9 @@ uint8_t logbook_getHeader(uint8_t StepBackwards,SLogbookHeader* pLogbookHeader); uint16_t logbook_readSampleData(uint8_t StepBackwards, uint16_t length,uint16_t* depth, uint8_t* gasid, int16_t* temperature, uint16_t* ppo2, uint16_t* setpoint, uint16_t* sensor1, uint16_t* sensor2, uint16_t* sensor3, uint16_t* cns, uint8_t* bailout, - uint16_t* decostopDepth, uint16_t* tank, uint8_t* event); + uint16_t* decostopDepth, uint16_t* tank, SGnssCoord* pPosition, uint8_t* event); void logbook_test(void); -void logbook_InitAndWrite(const SDiveState* pStateReal); +void logbook_InitAndWrite(SDiveState* pStateReal); void logbook_recover_brokenlog(uint8_t headerId); uint16_t logbook_lastDive_diveNumber(void); diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/ostc.h --- a/Discovery/Inc/ostc.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/ostc.h Tue Feb 11 18:12:00 2025 +0100 @@ -57,6 +57,9 @@ #define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) #define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) +#define DISPLAY_VERSION_LCD (0u) +#define DISPLAY_VERSION_NEW (1u) + /* Exported variables --------------------------------------------------------*/ extern SPI_HandleTypeDef hspiDisplay; @@ -98,6 +101,8 @@ void MX_TestPin_High(void); void MX_TestPin_Low(void); -uint8_t hardwareDisplay; //< either OSTC4 LCD (=0) or new Screen (=1) +void SetDisplayVersion(uint8_t version); +uint8_t isNewDisplay(void); + #endif // OSTC_H diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/ostc_hw2.h --- a/Discovery/Inc/ostc_hw2.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/ostc_hw2.h Tue Feb 11 18:12:00 2025 +0100 @@ -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 diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/stm32f4xx_hal_conf.h --- a/Discovery/Inc/stm32f4xx_hal_conf.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/stm32f4xx_hal_conf.h Tue Feb 11 18:12:00 2025 +0100 @@ -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 diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/t3.h --- a/Discovery/Inc/t3.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/t3.h Tue Feb 11 18:12:00 2025 +0100 @@ -42,7 +42,8 @@ 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); +int printScrubberText(char *text, size_t size, const SScrubberData *scrubberData, SSettings *settings); #endif /* T3_H */ diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/tComm.h --- a/Discovery/Inc/tComm.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/tComm.h Tue Feb 11 18:12:00 2025 +0100 @@ -42,9 +42,35 @@ BM_CONFIG_BAUD, BM_CONFIG_SILENCE, BM_CONFIG_DONE, - BM_CONFIG_RETRY + BM_CONFIG_RETRY, + BM_INIT_TRIGGER_ON = 100, + BM_INIT_TRIGGER_OFF, + BM_INIT_ECHO, + 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 } BlueModTmpConfig_t; + +typedef enum +{ + BT_CMD_ECHO, + BT_CMD_ESCAPE_DELAY, + BT_CMD_SIGNAL_POLL, + BT_CMD_BAUDRATE_115, + BT_CMD_BAUDRATE_460, + BT_CMD_SILENCE, + BT_CMD_NAME, + BT_CMD_EXIT_CMD +} BTCmd; /* Exported functions --------------------------------------------------------*/ void tComm_init(void); @@ -53,6 +79,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); diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/tHome.h --- a/Discovery/Inc/tHome.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/tHome.h Tue Feb 11 18:12:00 2025 +0100 @@ -80,7 +80,8 @@ 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_Position, + CVIEW_END /* The ID is used in shift operation => 31 is the max number of supported views */ }; enum CUSTOMVIEWS_BF diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/tInfo.h --- a/Discovery/Inc/tInfo.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/tInfo.h Tue Feb 11 18:12:00 2025 +0100 @@ -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); diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/tInfoPreDive.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Discovery/Inc/tInfoPreDive.h Tue Feb 11 18:12:00 2025 +0100 @@ -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 . +////////////////////////////////////////////////////////////////////////////// + +/* 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 */ diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/tMenu.h --- a/Discovery/Inc/tMenu.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/tMenu.h Tue Feb 11 18:12:00 2025 +0100 @@ -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); diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/tMenuEdit.h --- a/Discovery/Inc/tMenuEdit.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/tMenuEdit.h Tue Feb 11 18:12:00 2025 +0100 @@ -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); @@ -75,6 +78,7 @@ void clean_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font); void write_content(uint16_t XleftGimpStyle, uint16_t XrightGimpStyle, uint16_t YtopGimpStyle, const tFont *Font, const char *text, uint8_t color); +uint8_t togglePlusMinus(uint8_t input); void write_topline( char *text); void write_buttonTextline( uint8_t left2ByteCode, char middle2ByteCode, char right2ByteCode); void write_field_udigit(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); diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/tMenuEditCustom.h --- a/Discovery/Inc/tMenuEditCustom.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/tMenuEditCustom.h Tue Feb 11 18:12:00 2025 +0100 @@ -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 */ diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/tMenuEditSystem.h --- a/Discovery/Inc/tMenuEditSystem.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/tMenuEditSystem.h Tue Feb 11 18:12:00 2025 +0100 @@ -38,5 +38,6 @@ void refresh_InformationPage(void); void refresh_Design(void); void refresh_Customviews(void); +void refresh_DateTime(void); #endif /* TMENU_EDIT_SYSTEM_H */ diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/tMenuEditXtra.h --- a/Discovery/Inc/tMenuEditXtra.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/tMenuEditXtra.h Tue Feb 11 18:12:00 2025 +0100 @@ -33,6 +33,5 @@ void openEdit_Xtra(uint8_t line); void refresh_CompassHeading(void); -void refresh_CO2Data(void); #endif /* TMENU_EDIT_XTRA_H */ diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/tMenuSystem.h --- a/Discovery/Inc/tMenuSystem.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/tMenuSystem.h Tue Feb 11 18:12:00 2025 +0100 @@ -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 */ diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/tMenuXtra.h --- a/Discovery/Inc/tMenuXtra.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/tMenuXtra.h Tue Feb 11 18:12:00 2025 +0100 @@ -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 diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/tStructure.h --- a/Discovery/Inc/tStructure.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/tStructure.h Tue Feb 11 18:12:00 2025 +0100 @@ -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) @@ -201,8 +204,10 @@ /* DIVE MODE */ #define StMXTRA_ResetStopwatch _MB(2,4,1,1,0) #define StMXTRA_CompassHeading _MB(2,4,2,1,0) -#define StMXTRA_CompassHeadingClear _MB(2,4,2,2,0) -#define StMXTRA_CompassHeadingReset _MB(2,4,2,3,0) +#define StMXTRA_CompassHeadingReverse _MB(2,4,2,2,0) +#define StMXTRA_CompassHeadingClear _MB(2,4,2,3,0) +#define StMXTRA_CompassHeadingReset _MB(2,4,2,4,0) +#define StMXTRA_CompassHeadingLog _MB(2,4,2,5,0) /* SURFACE MODE */ @@ -212,11 +217,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) + @@ -243,17 +247,19 @@ #define StMDECO3_PPO2Max _MB(2,5,2,1,0) #define StMDECO4_SafetyStop _MB(2,5,3,1,0) -#define StMDECO5_FUTURE _MB(2,5,4,1,0) -#define StMDECO6_SALINITY _MB(2,5,5,1,0) +#define StMDECO_SlowExit _MB(2,5,4,1,0) +#define StMDECO5_FUTURE _MB(2,5,5,1,0) +#define StMDECO6_SALINITY _MB(2,5,6,1,0) /* PAGE 6 */ #define StMDECOP _MB(2,6,0,0,0) #define StMDECOP1_Algorithm _MB(2,6,1,1,0) -#define StMDECOP2_VPM _MB(2,6,2,1,0) -#define StMDECOP3_GF _MB(2,6,3,1,0) -#define StMDECOP4_AltGF _MB(2,6,4,1,0) +#define StMDECOP2_VPM _MB(2,6,2,1,0) +#define StMDECOP3_GF _MB(2,6,3,1,0) +#define StMDECOP4_AltGF _MB(2,6,4,1,0) #define StMDECOP5_LASTSTOP _MB(2,6,5,1,0) +#define StMDECOP6_VPMTable _MB(2,6,6,1,0) #define StMDECOP7_ActiveGF _MB(2,6,7,1,0) #define StMDECOP8_ActiveVPM _MB(2,6,8,1,0) @@ -267,6 +273,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) @@ -303,13 +310,16 @@ #define StMSYS _MB(2,8,0,0,0) /* PAGE 8 EDIT FIELD CONTENT */ -#define StMSYS1_Date _MB(2,8,1,1,0) -#define StMSYS1_Time _MB(2,8,1,2,0) -#define StMSYS1_DDMMYY _MB(2,8,1,3,0) -#define StMSYS1_MMDDYY _MB(2,8,1,4,0) -#define StMSYS1_YYMMDD _MB(2,8,1,5,0) -#define StMSYS1_DST _MB(2,8,1,6,0) -#define StMSYS1_12HR _MB(2,8,1,7,0) +#define StMSYS1_DateTime _MB(2,8,1,0,0) +#define StMSYS1_Date _MB(2,8,1,1,0) +#define StMSYS1_Time _MB(2,8,1,2,0) +#define StMSYS1_FORMAT _MB(2,8,1,3,0) +#define StMSYS1_DDMMYY _MB(2,8,1,3,1) +#define StMSYS1_MMDDYY _MB(2,8,1,3,2) +#define StMSYS1_YYMMDD _MB(2,8,1,3,3) +#define StMSYS1_12HR _MB(2,8,1,4,0) +#define StMSYS1_GNSSDT _MB(2,8,1,5,0) +#define StMSYS1_ZONE _MB(2,8,1,6,0) #define StMSYS_Timer _MB(2,8,2,1,0) @@ -339,6 +349,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 +368,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) @@ -371,12 +383,16 @@ #define StMCustom4_CViewSelection1 _MB(2,9,4,1,0) +#ifdef ENABLE_MOTION_CONTROL #define StMCustom5_CViewPortCalib _MB(2,9,5,1,0) #define StMCustom5_CViewPortSpotSize _MB(2,9,5,2,0) #define StMCustom5_CViewPortLayout _MB(2,9,5,3,0) #define StMCustom5_CViewPortAmbient _MB(2,9,5,4,0) #define StMCustom5_CViewPortControl _MB(2,9,5,5,0) - +#endif +#ifdef ENABLE_GPIO_V2 +#define StMCustom5_CViewWarningBuz _MB(2,9,5,1,0) +#endif /* PAGE 10 */ #define StMPLAN _MB(2,10,0,0,0) diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/text_multilanguage.h --- a/Discovery/Inc/text_multilanguage.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/text_multilanguage.h Tue Feb 11 18:12:00 2025 +0100 @@ -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, @@ -343,6 +346,7 @@ TXT2BYTE_Navigation, TXT2BYTE_DepthData, TXT2BYTE_DecoTTS, + TXT2BYTE_SlowExit, TXT2BYTE_Minimum, TXT2BYTE_Normal, @@ -370,12 +374,28 @@ TXT2BYTE_Clear, TXT2BYTE_Reset, + TXT2BYTE_CounterLung, + TXT2BYTE_Pressure, + TXT2BYTE_Timer, TXT2BYTE_Starting, TXT2BYTE_Finished, + TXT2BYTE_Position, + TXT2BYTE_VpmTable, TXT2BYTE_Page, + TXT2BYTE_Current, + TXT2BYTE_Log, + TXT2BYTE_Reverse, + + TXT2BYTE_DDMMYY, + TXT2BYTE_MMDDYY, + TXT2BYTE_YYMMDD, + TXT2BYTE_TIMEZONE, + + TXT2BYTE_BUZZER, + TXT2BYTE_END, }; diff -r f7318457df4d -r c6c781a2e85b Discovery/Inc/vpm.h --- a/Discovery/Inc/vpm.h Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Inc/vpm.h Tue Feb 11 18:12:00 2025 +0100 @@ -34,6 +34,14 @@ enum DECOLIST{DECOSTOPS,FUTURESTOPS,BAILOUTSTOPS, OFF = -1}; // order is important!! enum VPM_CALC_STATUS{CALC_END, CALC_BEGIN, CALC_CRITICAL, CALC_FINAL_DECO, CALC_NDL }; +typedef enum +{ + VPM_TABLE_INIT = 0, + VPM_TABLE_ACTIVE, + VPM_TABLE_WARNING, + VPM_TABLE_MISSED +} SvpmTableState; + float schreiner_equation__2(float *initial_inspired_gas_pressure,float *rate_change_insp_gas_pressure,float *interval_time_minutes, const float *gas_time_constant,float *initial_gas_pressure); int vpm_calc(SLifeData* pINPUT, SDiveSettings* diveSettings, SVpm* pVPM, SDecoinfo* pDECOINFO, int calc_what); @@ -43,5 +51,9 @@ float vpm_get_CNS(void); +void vpm_table_init(void); +uint8_t vpm_get_decozone(void); +SvpmTableState vpm_get_TableState(void); + #endif /* VPM_H */ diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/base.c --- a/Discovery/Src/base.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/base.c Tue Feb 11 18:12:00 2025 +0100 @@ -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" @@ -297,6 +298,14 @@ static uint8_t DoHousekeeping = 0; /* trigger to cleanup the frame buffers */ static SButtonLock ButtonLockState = LOCK_OFF; /* Used for button unlock sequence */ +#ifdef T7_DEBUG_RUNTIME +static uint32_t startTimeMainLoop = 0; +static uint32_t startTimeDecoLoop = 0; +static uint32_t startTimeGfxLoop = 0; +static uint32_t timeMainLoop = 0; +static uint32_t timeDecoLoop = 0; +static uint32_t timeGfxLoop = 0; +#endif /* Private function prototypes -----------------------------------------------*/ static void SystemClock_Config(void); @@ -486,6 +495,9 @@ */ while( 1 ) { +#ifdef T7_DEBUG_RUNTIME + startTimeMainLoop = HAL_GetTick(); +#endif if( bootToBootloader ) resetToFirmwareUpdate(); @@ -530,8 +542,13 @@ } check_warning(); updateMiniLiveLogbook(1); - +#ifdef T7_DEBUG_RUNTIME + startTimeGfxLoop = HAL_GetTick(); +#endif RefreshDisplay(); +#ifdef T7_DEBUG_RUNTIME + timeGfxLoop = time_elapsed_ms(startTimeGfxLoop, HAL_GetTick()); +#endif TimeoutControl(); /* exit menus if needed */ #ifdef ENABLE_MOTION_CONTROL @@ -544,14 +561,21 @@ 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); #endif if(stateUsed == stateRealGetPointer()) /* Handle log entries while in dive mode*/ - logbook_InitAndWrite(stateUsed); + logbook_InitAndWrite((SDiveState*)stateUsed); } +#ifdef T7_DEBUG_RUNTIME + timeMainLoop = time_elapsed_ms(startTimeMainLoop, HAL_GetTick()); +#endif } } @@ -894,6 +918,8 @@ break; case InfoPageSensor: sendActionToInfoSensor(action); break; + case InfoPagePreDive: sendActionToInfoPreDive(action); + break; default: sendActionToInfo(action); break; } @@ -995,7 +1021,8 @@ { /* not at the moment of testing */ // ext_flash_erase_firmware_if_not_empty(); - GFX_logoAutoOff(); + GFX_logoAutoOff(); + display_power_off(); ext_flash_write_devicedata(true); /* write data at default position */ ext_flash_write_settings(true); /* write data at default position */ set_globalState(StStop); @@ -1250,10 +1277,12 @@ case 0: /* Cave */ levelMax = 3000;/* max 25 % (x2) */ levelMin = 1500; + if( isNewDisplay()) display_1_brightness_cave(); break; case 1: /* Eco */ levelMax = 6000;/* max 50 % (x2) */ levelMin = 3000; + if ( isNewDisplay()) display_1_brightness_eco(); break; case 2: /* Std */ levelAmbient += 1000; @@ -1261,6 +1290,7 @@ levelMin = 4500; levelUpStep_100ms += levelUpStep_100ms/2; // 4500 instead of 3000 levelDnStep_100ms += levelDnStep_100ms/2; + if ( isNewDisplay()) display_1_brightness_std(); break; case 3: /* High */ default: @@ -1269,6 +1299,7 @@ levelMin = 6000; levelUpStep_100ms += levelUpStep_100ms; // 6000 instead of 3000 levelDnStep_100ms += levelDnStep_100ms; + if ( isNewDisplay()) display_1_brightness_high(); break; case 4: /* New Max */ levelAmbient = 12000; @@ -1276,6 +1307,7 @@ levelMin = 12000; levelUpStep_100ms += 12000; levelDnStep_100ms += 0; + if ( isNewDisplay()) display_1_brightness_max(); break; } @@ -1338,7 +1370,7 @@ sConfig.OCMode = TIM_OCMODE_PWM1; sConfig.OCPolarity = TIM_OCPOLARITY_HIGH; sConfig.OCFastMode = TIM_OCFAST_DISABLE; - sConfig.Pulse = 100; /* Initial brigthness of display */ + sConfig.Pulse = 100; /* Initial brightness of display */ HAL_TIM_PWM_ConfigChannel(&TimBacklightHandle, &sConfig, TIM_BACKLIGHT_CHANNEL); HAL_TIM_PWM_Start(&TimBacklightHandle, TIM_BACKLIGHT_CHANNEL); @@ -1709,7 +1741,13 @@ switch(what) { case CALC_VPM: +#ifdef T7_DEBUG_RUNTIME + startTimeDecoLoop = HAL_GetTick(); +#endif vpm_calc(&stateDeco.lifeData,&stateDeco.diveSettings,&stateDeco.vpm,&stateDeco.decolistVPM, DECOSTOPS); +#ifdef T7_DEBUG_RUNTIME + timeDecoLoop = time_elapsed_ms(startTimeDecoLoop, HAL_GetTick()); +#endif decoLock = DECO_CALC_FINSHED_vpm; return; case CALC_VPM_FUTURE: @@ -1903,6 +1941,21 @@ } RequestModeChange = 0; } + +#ifdef T7_DEBUG_RUNTIME +uint32_t getMainLoopTime() +{ + return timeMainLoop; +} +uint32_t getDecoLoopTime() +{ + return timeDecoLoop; +} +uint32_t getGfxLoopTime() +{ + return timeGfxLoop; +} +#endif // debugging by https://blog.feabhas.com/2013/02/developing-a-generic-hard-fault-handler-for-arm-cortex-m3cortex-m4/ /* diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/buehlmann.c --- a/Discovery/Src/buehlmann.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/buehlmann.c Tue Feb 11 18:12:00 2025 +0100 @@ -258,8 +258,14 @@ 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) +#ifdef ENABLE_DECOCALC_OPTION + || (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0) +#endif + ) + { break; + } float pressureChange = ((float)pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero) / 10; if(gStop.depth <= pressureChange + 0.00001f) { @@ -458,8 +464,14 @@ 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) +#ifdef ENABLE_DECOCALC_OPTION + || (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0) +#endif + ) + { break; + } pressureChange = gSurface_pressure_bar + ((float)pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero) / 10; if(pressureBottom <= pressureChange) { @@ -473,8 +485,15 @@ } 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) +#ifdef ENABLE_DECOCALC_OPTION + || (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0) +#endif + ) + { break; + } + pressureChange = gSurface_pressure_bar + ((float)pDiveSettings->decogaslist[i].change_during_ascent_depth_meter_otherwise_zero)/ 10; if((pressureChange < pressureBottom) && (pressureChange > pressureTop)) { diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/check_warning.c --- a/Discovery/Src/check_warning.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/check_warning.c Tue Feb 11 18:12:00 2025 +0100 @@ -43,6 +43,7 @@ #define DEBOUNCE_FALLBACK_TIME_MS (5000u) /* set warning after 5 seconds of pending error condition */ +#define GUI_BUZZER_TIMEOUT_MS (200u) /* the buzzer should be active while Warning string is shown, but diver may be in a menu... */ #define SETPOINT_DECO_START_RANGE_M 3.0 #define SWITCH_DEPTH_LOW_MINIMUM_M 1.0 @@ -53,6 +54,7 @@ static uint8_t betterSetpointId = 1; static int8_t fallback = 0; static uint16_t debounceFallbackTimeMS = 0; +static uint8_t buzzerRequestActive = 0; /* Private function prototypes -----------------------------------------------*/ static int8_t check_fallback(SDiveState * pDiveState); @@ -72,9 +74,70 @@ 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 +static uint8_t buzzerOn = 0; /* current state of the buzzer */ +static void setBuzzer(int8_t warningActive); /* Exported functions --------------------------------------------------------*/ +void requestBuzzerActivation(uint8_t active) +{ + buzzerRequestActive = active; +} + +uint8_t getBuzzerActivationState() +{ + return buzzerOn; +} + +static void setBuzzer(int8_t warningActive) +{ + static uint32_t guiTimeoutCnt = 0; /* max delay till buzzer will be activated independend from gui request */ + static uint32_t stateTick = 0; /* activation tick of current state */ + static uint8_t lastWarningState = 0; /* the parameter value of the last call*/ + + uint32_t tick = HAL_GetTick(); + + if(warningActive) + { + if(!lastWarningState) /* init structures */ + { + guiTimeoutCnt = tick; + stateTick = tick; + } + if(buzzerOn) + { + if(time_elapsed_ms(stateTick, tick) > EXT_INTERFACE_BUZZER_STABLE_TIME_MS) /* buzzer has to be on for a certain time */ + { + if((!buzzerRequestActive) || (time_elapsed_ms(stateTick, tick) > EXT_INTERFACE_BUZZER_ON_TIME_MS)) + { + buzzerOn = 0; + stateTick = tick; + guiTimeoutCnt = tick; + } + } + } + else + { + if(time_elapsed_ms(stateTick, tick) > EXT_INTERFACE_BUZZER_STABLE_TIME_MS) /* buzzer has to be off for a certain time */ + { + if((buzzerRequestActive) || (time_elapsed_ms(guiTimeoutCnt, tick) > EXT_INTERFACE_BUZZER_ON_TIME_MS + GUI_BUZZER_TIMEOUT_MS)) + { + buzzerOn = 1; + stateTick = tick; + } + } + } + } + else + { + buzzerOn = 0; + } + lastWarningState = warningActive; +} + void check_warning(void) { check_warning2(stateUsedWrite); @@ -85,21 +148,33 @@ { pDiveState->warnings.numWarnings = 0; - pDiveState->warnings.numWarnings += check_aGF(pDiveState); +/* Warnings checked before the SetBuzzer call will activate the buzzer */ pDiveState->warnings.numWarnings += check_AscentRate(pDiveState); - pDiveState->warnings.numWarnings += check_CNS(pDiveState); pDiveState->warnings.numWarnings += check_Deco(pDiveState); pDiveState->warnings.numWarnings += check_ppO2(pDiveState); pDiveState->warnings.numWarnings += check_O2_sensors(pDiveState); + pDiveState->warnings.numWarnings += check_fallback(pDiveState); +#ifdef ENABLE_CO2_SUPPORT + pDiveState->warnings.numWarnings += check_co2(pDiveState); +#endif + + if(settingsGetPointer()->warningBuzzer) + { + setBuzzer(pDiveState->warnings.numWarnings); + } + +/* Warnings checked after this line will not cause activation of the buzzer */ + pDiveState->warnings.numWarnings += check_aGF(pDiveState); + pDiveState->warnings.numWarnings += check_CNS(pDiveState); pDiveState->warnings.numWarnings += check_BetterGas(pDiveState); pDiveState->warnings.numWarnings += check_BetterSetpoint(pDiveState); pDiveState->warnings.numWarnings += check_Battery(pDiveState); - pDiveState->warnings.numWarnings += check_fallback(pDiveState); #ifdef ENABLE_BOTTLE_SENSOR pDiveState->warnings.numWarnings += check_pressureSensor(pDiveState); #endif -#ifdef ENABLE_CO2_SUPPORT - pDiveState->warnings.numWarnings += check_co2(pDiveState); + +#ifdef HAVE_DEBUG_WARNINGS + pDiveState->warnings.numWarnings += check_debug(pDiveState); #endif } @@ -157,7 +232,7 @@ static int8_t check_ppO2(SDiveState * pDiveState) { - if((pDiveState->mode != MODE_DIVE) || (pDiveState->warnings.fallback)) + if((pDiveState->mode != MODE_DIVE) || ((isLoopMode(pDiveState->diveSettings.diveMode) && (pDiveState->warnings.fallback)))) { pDiveState->warnings.ppO2Low = 0; pDiveState->warnings.ppO2High = 0; @@ -201,7 +276,7 @@ pDiveState->warnings.sensorOutOfBounds[2] = 0; if(isLoopMode(pDiveState->diveSettings.diveMode) && (pDiveState->diveSettings.CCR_Mode == CCRMODE_Sensors)) - + { if(settingsGetPointer()->ppo2sensors_source == O2_SENSOR_SOURCE_OPTIC) { { @@ -209,7 +284,8 @@ pDiveState->warnings.sensorLinkLost = 1; } } - test_O2_sensor_values_outOfBounds(&pDiveState->warnings.sensorOutOfBounds[0], &pDiveState->warnings.sensorOutOfBounds[1], &pDiveState->warnings.sensorOutOfBounds[2]); + test_O2_sensor_values_outOfBounds(&pDiveState->warnings.sensorOutOfBounds[0], &pDiveState->warnings.sensorOutOfBounds[1], &pDiveState->warnings.sensorOutOfBounds[2]); + } return pDiveState->warnings.sensorLinkLost + pDiveState->warnings.sensorOutOfBounds[0] + pDiveState->warnings.sensorOutOfBounds[1] @@ -220,9 +296,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 +308,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.9f )) + && (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 +341,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 +373,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 +654,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 +673,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; diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/data_central.c --- a/Discovery/Src/data_central.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/data_central.c Tue Feb 11 18:12:00 2025 +0100 @@ -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 }; @@ -345,6 +347,7 @@ stateReal.diveSettings.input_next_stop_increment_depth_bar = ((float)pSettings->stop_increment_depth_meter) / 10.0f; stateReal.diveSettings.last_stop_depth_bar = ((float)pSettings->last_stop_depth_meter) / 10.0f; stateReal.diveSettings.vpm_conservatism = pSettings->VPM_conservatism.ub.standard; + stateReal.diveSettings.vpm_tableMode = pSettings->VPM_conservatism.ub.alternative; stateReal.diveSettings.deco_type.uw = pSettings->deco_type.uw; stateReal.diveSettings.fallbackOption = pSettings->fallbackToFixedSetpoint; stateReal.diveSettings.ppo2sensors_deactivated = pSettings->ppo2sensors_deactivated; @@ -375,6 +378,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); + } } @@ -875,13 +892,38 @@ return stateUsed->lifeData.compass_heading != -1; } +static void internalLogCompassHeading(uint16_t heading, bool applyHeading, bool clearHeading) +{ + uint16_t compassHeading = 0; + if (clearHeading) { + compassHeading |= 0x8000; + } else { + compassHeading = heading & 0x1FF; + } + if (applyHeading) { + compassHeading |= 0x4000; + } + + stateUsedWrite->events.compassHeadingUpdate = 1; + stateUsedWrite->events.info_compassHeadingUpdate = compassHeading; +} + +void logCompassHeading(uint16_t heading) { + internalLogCompassHeading(heading, false, false); +} + +void clearCompassHeading(void) { + uint16_t clearHeading = 0; + stateUsedWrite->diveSettings.compassHeading = clearHeading; + + internalLogCompassHeading(clearHeading, true, true); +} void setCompassHeading(uint16_t heading) { + stateUsedWrite->diveSettings.compassHeading = ((heading - 360) % 360) + 360; - // if heading == 0 set compassHeading to 360, because compassHeading == 0 means 'off' - - stateUsedWrite->diveSettings.compassHeading = ((heading - 360) % 360) + 360; + internalLogCompassHeading(heading, true, false); } @@ -902,3 +944,182 @@ { stateUsedWrite->timerState = TIMER_STATE_OFF; } + +#define SPEED_SLOW (5.1f) +#define SPEED_MEDIUM (10.1f) +#define SPEED_HIGH (15.1f) +#define SPEED_HYSTERESE (1.0f) + +uint8_t drawingColor_from_ascentspeed(float speed) +{ + static uint8_t lastColor = 0; + + uint8_t color = CLUT_Font020; + + if((speed >= SPEED_HIGH) || ((lastColor == CLUT_WarningRed) && (speed >= SPEED_HIGH - SPEED_HYSTERESE))) + { + color = CLUT_WarningRed; + } + else if((speed >= SPEED_MEDIUM) || ((lastColor == CLUT_WarningYellow) && (speed >= SPEED_MEDIUM - SPEED_HYSTERESE))) + { + color = CLUT_WarningYellow; + } + else if((speed >= SPEED_SLOW) || ((lastColor == CLUT_NiceGreen) && (speed >= SPEED_SLOW - SPEED_HYSTERESE))) + { + color = CLUT_NiceGreen; + } + lastColor = color; + return color; +} + +/* returns the date in the order defined by the settings DDMMYY => X */ +void convertStringOfDate_DDMMYY(char* pString, uint8_t strLen, uint8_t day, uint8_t month, uint8_t year) +{ + if(strLen > 10) + { + switch(settingsGetPointer()->date_format) + { + default: + case DDMMYY: snprintf(pString,strLen,"%02d.%02d.%02d",day,month,year); + break; + case MMDDYY: snprintf(pString,strLen,"%02d.%02d.%02d",month,day,year); + break; + case YYMMDD: snprintf(pString,strLen,"%02d.%02d.%02d",year,month,day); + break; + } + } +} +/* returns the format in the order defined by the settings DDMMYY => X */ +void getStringOfFormat_DDMMYY(char* pString, uint8_t strLen) +{ + if(strLen > 10) + { + switch(settingsGetPointer()->date_format) + { + default: + case DDMMYY: snprintf(pString,strLen,"%c%c",TXT_2BYTE,TXT2BYTE_DDMMYY); + break; + case MMDDYY: snprintf(pString,strLen,"%c%c",TXT_2BYTE,TXT2BYTE_MMDDYY); + break; + case YYMMDD: snprintf(pString,strLen,"%c%c",TXT_2BYTE,TXT2BYTE_YYMMDD); + break; + } + } +} + +uint8_t calculateSlowExit(uint16_t* pCountDownSec, float* pExitDepthMeter, uint8_t* pColor) /* this function is only called if diver is below last last stop depth */ +{ + static SSlowExitState slowExitState = SE_END; + static uint16_t countDownSec = 0; + static float exitDepthMeter = 0.0; + static uint32_t exitSecTick = 0; + static uint32_t lastSecTick = 0; + static uint8_t color = 0; + static uint8_t drawingActive = 0; + + SSettings* pSettings; + pSettings = settingsGetPointer(); + + if((stateUsed->lifeData.max_depth_meter < pSettings->last_stop_depth_meter) /* start of dive => reinit timer */ + || (slowExitState == SE_REINIT)) + { + if(slowExitState != SE_INIT) + { + countDownSec = pSettings->slowExitTime * 60; + slowExitState = SE_INIT; + exitDepthMeter = pSettings->last_stop_depth_meter; + color = 0; + drawingActive = 0; + } + } + else + { + if(slowExitState != SE_END) + { + if((slowExitState == SE_INIT) && (stateUsed->lifeData.dive_time_seconds > 900)) /* min 15min divetime */ + { + slowExitState = SE_ACTIVE; + exitSecTick = HAL_GetTick(); + lastSecTick = exitSecTick; + } + else if(slowExitState == SE_ACTIVE) + { + if(time_elapsed_ms(lastSecTick, HAL_GetTick()) > 60000) /* restart timer if diver go below exit zone */ + { + slowExitState = SE_REINIT; + } + else if(time_elapsed_ms(exitSecTick, HAL_GetTick()) > 1000) + { + exitSecTick = HAL_GetTick(); + lastSecTick = exitSecTick; + /* select depth digit color */ + if(fabsf(stateUsed->lifeData.depth_meter - exitDepthMeter) < 0.5 ) + { + color = CLUT_NiceGreen; + } + else if(fabsf(stateUsed->lifeData.depth_meter - exitDepthMeter) <= 1.5) + { + color = CLUT_WarningYellow; + } + else if(stateUsed->lifeData.depth_meter - exitDepthMeter < -1.5 ) + { + color = CLUT_WarningRed; + } + else + { + color = 0; + } + + if((fabsf(stateUsed->lifeData.depth_meter - exitDepthMeter) <= 1.6 ) /* only decrease counter if diver is close to target depth */ + || (color == CLUT_WarningRed)) /* or if diver is far ahead */ + { + countDownSec--; + if(countDownSec == 0) + { + slowExitState = SE_END; + color = 0; + exitDepthMeter = 0; + } + else + { + exitDepthMeter -= (pSettings->last_stop_depth_meter / (float)(pSettings->slowExitTime * 60)); + } + } + drawingActive = 1; + } + } + } + } + *pCountDownSec = countDownSec; + *pExitDepthMeter = exitDepthMeter; + *pColor = color; + return drawingActive; +} + +void convertUTCToLocal(uint8_t utcHours, uint8_t utcMinutes, uint8_t* pLocalHours, uint8_t* pLocalMinutes) +{ + int8_t localHours = 0; + int8_t localMinutes = 0; + SSettings* pSettings = settingsGetPointer(); + + localHours = utcHours + pSettings->timeZone.hours; + if(localHours < 0) + { + localHours += 24; + } + if(localHours > 24) + { + localHours -= 24; + } + localMinutes = utcMinutes + pSettings->timeZone.minutes; + if(localMinutes < 0) + { + localMinutes += 60; + } + if(localMinutes > 60) + { + localMinutes -= 60; + } + *pLocalHours = localHours; + *pLocalMinutes = localMinutes; +} diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/data_exchange_main.c --- a/Discovery/Src/data_exchange_main.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/data_exchange_main.c Tue Feb 11 18:12:00 2025 +0100 @@ -72,6 +72,8 @@ #include "timer.h" #include "buehlmann.h" #include "externLogbookFlash.h" +#include "vpm.h" +#include "check_warning.h" /* #define TESTBENCH */ @@ -410,6 +412,10 @@ break; case SENSOR_CO2: SensorActive[SENSOR_CO2] = 1; break; +#if defined ENABLE_GPIO_V2 || defined ENABLE_GNSS_SUPPORT + case SENSOR_GNSS: SensorActive[SENSOR_GNSS] = 1; + break; +#endif #ifdef ENABLE_SENTINEL_MODE case SENSOR_SENTINEL: SensorActive[SENSOR_SENTINEL] = 1; break; @@ -423,23 +429,26 @@ { externalInterface_Cmd |= EXT_INTERFACE_ADC_ON | EXT_INTERFACE_33V_ON; } - if(SensorActive[SENSOR_DIGO2]) + if((SensorActive[SENSOR_DIGO2]) || (SensorActive[SENSOR_CO2])|| (SensorActive[SENSOR_GNSS])) { - 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 +#ifdef ENABLE_GPIO_V2 + if(getBuzzerActivationState()) + { + externalInterface_Cmd |= EXT_INTERFACE_BUZZER_ON; + } +#endif + dataOut.data.externalInterface_Cmd = externalInterface_Cmd; externalInterface_Cmd = 0; @@ -473,7 +482,7 @@ settingsHelperButtonSens_keepPercentageValues(settingsGetPointerStandard()->ButtonResponsiveness[3], settings->ButtonResponsiveness); setButtonResponsiveness(settings->ButtonResponsiveness); - DataEX_setExtInterface_Cmd(EXT_INTERFACE_COPY_SENSORMAP); + DataEX_setExtInterface_Cmd(EXT_INTERFACE_COPY_SENSORMAP, 0); } } @@ -483,16 +492,17 @@ if(decoLock == DECO_CALC_running) return; - if(decoLock == DECO_CALC_init_as_is_start_of_dive) - { + if(decoLock == DECO_CALC_init_as_is_start_of_dive) + { + vpm_table_init(); vpm_init(&stateUsedWrite->vpm, stateUsedWrite->diveSettings.vpm_conservatism, 0, 0); buehlmann_init(); timer_init(); resetEvents(stateUsedWrite); stateUsedWrite->diveSettings.internal__pressure_first_stop_ambient_bar_as_upper_limit_for_gf_low_otherwise_zero = 0; - } + } - if(decoLock == DECO_CALC_FINSHED_Buehlmann) + if(decoLock == DECO_CALC_FINSHED_Buehlmann) { } @@ -534,6 +544,7 @@ //Copy Inputdata from stateReal to stateDeco memcpy(&stateDeco.lifeData,&stateUsedWrite->lifeData,sizeof(SLifeData)); memcpy(&stateDeco.diveSettings,&stateUsedWrite->diveSettings,sizeof(SDiveSettings)); + memcpy(&stateDeco.decolistVPM,&stateUsedWrite->decolistVPM,sizeof(SDecoinfo)); stateDeco.vpm.deco_zone_reached = stateUsedWrite->vpm.deco_zone_reached; // memcpy(&stateDeco.vpm,&pStateUsed->vpm,sizeof(SVpm)); @@ -544,7 +555,7 @@ stateDeco.vpm.adjusted_critical_radius_he[i] = stateUsedWrite->vpm.adjusted_critical_radius_he[i]; stateDeco.vpm.adjusted_critical_radius_n2[i] = stateUsedWrite->vpm.adjusted_critical_radius_n2[i]; } - decoLock = DECO_CALC_ready; + decoLock = DECO_CALC_ready; } @@ -580,13 +591,16 @@ RTC_DateTypeDef sdatestructure; RTC_TimeTypeDef stimestructure; + const SFirmwareData *pFirmwareInfo; + pFirmwareInfo = firmwareDataGetPointer(); + stimestructure.Hours = UNKNOWN_TIME_HOURS; stimestructure.Minutes = UNKNOWN_TIME_MINUTES; stimestructure.Seconds = UNKNOWN_TIME_SECOND; sdatestructure.Date = UNKNOWN_DATE_DAY; sdatestructure.Month = UNKNOWN_DATE_MONTH; - sdatestructure.Year = UNKNOWN_DATE_YEAR; + sdatestructure.Year = pFirmwareInfo->release_year; setWeekday(&sdatestructure); DataEX_helper_SetTime(stimestructure, &lineWrite->time_rtc_tr); @@ -1010,6 +1024,8 @@ pStateReal->lifeData.dateBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_dr; pStateReal->lifeData.timeBinaryFormat = dataIn.data[dataIn.boolTimeData].localtime_rtc_tr; + + memcpy(&pStateReal->lifeData.gnssData, &dataIn.data[0].gnssInfo, sizeof(dataIn.data[0].gnssInfo)); } if(pStateReal->data_old__lost_connection_to_slave == 0) @@ -1033,6 +1049,8 @@ //Init dive Mode decoLock = DECO_CALC_init_as_is_start_of_dive; pStateReal->lifeData.boolResetAverageDepth = 1; + + memcpy(pStateReal->scrubberDataDive, pSettings->scrubberData, sizeof(pStateReal->scrubberDataDive)); } pStateReal->lifeData.cns = dataIn.data[dataIn.boolToxicData].cns; @@ -1060,6 +1078,8 @@ } if(pStateReal->warnings.decoMissed) dataOut.setAccidentFlag += ACCIDENT_DECOSTOP; + + memcpy(pSettings->scrubberData, pStateReal->scrubberDataDive, sizeof(pStateReal->scrubberDataDive)); /* Store value of current usage */ } pStateReal->mode = dataIn.mode; pStateReal->chargeStatus = dataIn.chargeStatus; @@ -1159,7 +1179,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 @@ -1343,9 +1363,14 @@ return retval; } -void DataEX_setExtInterface_Cmd(uint16_t Cmd) +void DataEX_setExtInterface_Cmd(uint16_t Cmd, uint8_t sensorId) { - externalInterface_Cmd = Cmd; + if(sensorId < EXT_INTERFACE_SENSOR_CNT - 1) + { + externalInterface_Cmd |= Cmd; + externalInterface_Cmd |= sensorId << 8; + } + return; } diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/display.c --- a/Discovery/Src/display.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/display.c Tue Feb 11 18:12:00 2025 +0100 @@ -43,13 +43,20 @@ #define OLED_POWER_SET 0x23 // VC1OUT = VCI X 0.98 (default) = 0x00 #define OLED_POWER_SET2 0x24 // VREG2OUT = 5,4V, VREG1OUT = 4,2V =0x77 #define OLED_DISPLAY_CONDITION_SET_26h 0x26 // 0x00A0 -#define OLED_STB_BY_OFF 0x1D // 00A0 + 300ms wait -#define OLED_DDISP_ON 0x14 // 0003 +#define OLED_STB_BY_OFF_1Dh 0x1D // 00A0 + 300ms wait +#define OLED_DDISP_ON_14h 0x14 // 0003 static void Display_Error_Handler(void); static void display_power_on__2_of_2__post_RGB_display0(void); static void display_power_on__2_of_2__post_RGB_display1(void); +void display_1_brightness_max(void); +void display_1_brightness_high(void); +void display_1_brightness_std(void); +void display_1_brightness_eco(void); +void display_1_brightness_cave(void); + static uint8_t receive_screen(); +uint8_t brightness_screen1; void display_power_on__1_of_2__pre_RGB(void) { @@ -61,13 +68,22 @@ HAL_Delay(10); HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_SET); HAL_Delay(25); + // check for new screen - hardwareDisplay=0; // default is old screen aTxBuffer[0] = 0x71; // Read internal register if (receive_screen((uint8_t*)aTxBuffer) == 0x27) // chip Index (=0x27 for new screen) - { - hardwareDisplay=1; - } + { + SetDisplayVersion(DISPLAY_VERSION_NEW); + } + 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); + + SetDisplayVersion(DISPLAY_VERSION_LCD); + } /* RGB signals should be now for 2 frames or more (datasheet) */ } @@ -150,9 +166,38 @@ return outputlength; } +void display_power_off(void) +{ + if (isNewDisplay()) + { + uint8_t aTxBuffer[3]; + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_DDISP_ON_14h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + HAL_Delay(25); + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_STB_BY_OFF_1Dh; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0xA1; + send((uint8_t*)aTxBuffer, 2); + HAL_Delay(200); + HAL_GPIO_WritePin(DISPLAY_RESETB_GPIO_PORT,DISPLAY_RESETB_PIN,GPIO_PIN_RESET); + } + else + { + // display 0 + } +} + + void display_power_on__2_of_2__post_RGB(void) { - if (hardwareDisplay == 1) + if (isNewDisplay()) { display_power_on__2_of_2__post_RGB_display1(); } @@ -320,13 +365,14 @@ aTxBuffer[1] = 0x08;//8 send((uint8_t*)aTxBuffer, 2); - //debug read + /*//debug read aTxBuffer[0] = 0x70; aTxBuffer[1] = OLED_SCTE_SET_31h; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x73; // Read internal register aTxBuffer[1] = 0x00; // Dummy write - reads out 0x08 (The just-set OLED_SCTE_SET value) send((uint8_t*)aTxBuffer, 2); + */ aTxBuffer[0] = 0x70; aTxBuffer[1] = OLED_WCWE_SET_32h; @@ -437,7 +483,272 @@ aTxBuffer[1] = 0x44;//44 send((uint8_t*)aTxBuffer, 2); - // GAMMA L=250 + + display_1_brightness_std(); // boot brightness + + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_BOOSTING_FREQ; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x22; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_AMP_SET_18h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x22; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_GAMMA_AMP_19h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x02; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_POWER_CONTROL2_1Ah; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + /* + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_POWER_CONTROL2_1Bh; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x4B; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_POWER_CONTROL2_1Ch; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x05; + send((uint8_t*)aTxBuffer, 2); + */ + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_INTERNAL_LOGIC_VOLTAGE; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0xA2; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_POWER_SET; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_POWER_SET2; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x77; + send((uint8_t*)aTxBuffer, 2); + + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_DISPLAY_CONDITION_SET_26h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0xA0; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_STB_BY_OFF_1Dh; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0xA0; + send((uint8_t*)aTxBuffer, 2); + + HAL_Delay(250); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = OLED_DDISP_ON_14h; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x03; + send((uint8_t*)aTxBuffer, 2); +} + +void display_1_brightness_max(void) +{ + uint8_t aTxBuffer[3]; + + if (brightness_screen1 == 4) + { + // do nothing + } + else + { + // GAMMA L=250 + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x40; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x41; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x3F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x42; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2A; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x43; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x27; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x44; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x27; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x45; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x1F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x46; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x44; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x50; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x51; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x52; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x17; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x53; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x24; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x54; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x26; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x55; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x1F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x56; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x43; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x60; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x61; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x3F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x62; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2A; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x63; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x25; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x64; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x24; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x65; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x1B; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x66; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x5C; + send((uint8_t*)aTxBuffer, 2); + + brightness_screen1=4; + } +} + +void display_1_brightness_high(void) +{ + uint8_t aTxBuffer[3]; + if (brightness_screen1 == 3) + { + // do nothing + } + else + { + // GAMMA L=200 aTxBuffer[0] = 0x70; aTxBuffer[1] = 0x40; send((uint8_t*)aTxBuffer, 2); @@ -585,7 +896,21 @@ aTxBuffer[1] = 0x5C; send((uint8_t*)aTxBuffer, 2); - /* + brightness_screen1=3; + } +} + + +void display_1_brightness_std(void) +{ + uint8_t aTxBuffer[3]; + + if (brightness_screen1 == 2) + { + // do nothing + } + else + { // GAMMA L=150 aTxBuffer[0] = 0x70; aTxBuffer[1] = 0x40; @@ -733,97 +1058,333 @@ aTxBuffer[0] = 0x72; aTxBuffer[1] = 0x4A; send((uint8_t*)aTxBuffer, 2); - */ + + brightness_screen1=2; + } +} + +void display_1_brightness_eco(void) +{ + uint8_t aTxBuffer[3]; + + if (brightness_screen1 == 1) + { + // do nothing + } + else + { + // GAMMA L=100 + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x40; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x41; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x3F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x42; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x30; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x43; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2A; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x44; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2B; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x45; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x24; + send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x70; - aTxBuffer[1] = OLED_BOOSTING_FREQ; + aTxBuffer[1] = 0x46; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x50; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x51; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x52; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x72; - aTxBuffer[1] = 0x22; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x53; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x25; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x54; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x29; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x55; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x24; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x56; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2E; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x60; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x70; - aTxBuffer[1] = OLED_AMP_SET_18h; + aTxBuffer[1] = 0x61; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x3F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x62; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x63; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x29; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x64; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x29; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x65; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x21; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x66; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x3F; + send((uint8_t*)aTxBuffer, 2); + + brightness_screen1=1; + } +} + +void display_1_brightness_cave(void) +{ + uint8_t aTxBuffer[3]; + + if (brightness_screen1 == 0) + { + // do nothing + } + else + { + // GAMMA L=50 + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x40; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x41; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x3F; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x42; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x3C; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x43; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2C; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x44; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x2D; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x45; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x27; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x46; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x24; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x50; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x51; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x52; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x00; + send((uint8_t*)aTxBuffer, 2); + + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x53; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x72; aTxBuffer[1] = 0x22; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x70; - aTxBuffer[1] = OLED_GAMMA_AMP_19h; + aTxBuffer[1] = 0x54; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x72; - aTxBuffer[1] = 0x02; + aTxBuffer[1] = 0x2A; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x70; - aTxBuffer[1] = OLED_POWER_CONTROL2_1Ah; + aTxBuffer[1] = 0x55; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x72; - aTxBuffer[1] = 0x00; - send((uint8_t*)aTxBuffer, 2); - - /* - aTxBuffer[0] = 0x70; - aTxBuffer[1] = OLED_POWER_CONTROL2_1Bh; - send((uint8_t*)aTxBuffer, 2); - aTxBuffer[0] = 0x72; - aTxBuffer[1] = 0x4B; + aTxBuffer[1] = 0x27; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x70; - aTxBuffer[1] = OLED_POWER_CONTROL2_1Ch; + aTxBuffer[1] = 0x56; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x72; - aTxBuffer[1] = 0x05; - send((uint8_t*)aTxBuffer, 2); - */ - - aTxBuffer[0] = 0x70; - aTxBuffer[1] = OLED_INTERNAL_LOGIC_VOLTAGE; - send((uint8_t*)aTxBuffer, 2); - aTxBuffer[0] = 0x72; - aTxBuffer[1] = 0xA2; + aTxBuffer[1] = 0x23; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x70; - aTxBuffer[1] = OLED_POWER_SET; + aTxBuffer[1] = 0x60; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x72; aTxBuffer[1] = 0x00; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x70; - aTxBuffer[1] = OLED_POWER_SET2; + aTxBuffer[1] = 0x61; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x72; - aTxBuffer[1] = 0x77; + aTxBuffer[1] = 0x3F; send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x62; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x3B; + send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x70; - aTxBuffer[1] = OLED_DISPLAY_CONDITION_SET_26h; + aTxBuffer[1] = 0x63; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x72; - aTxBuffer[1] = 0xA0; + aTxBuffer[1] = 0x2C; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x70; - aTxBuffer[1] = OLED_STB_BY_OFF; + aTxBuffer[1] = 0x64; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x72; - aTxBuffer[1] = 0xA0; + aTxBuffer[1] = 0x2B; send((uint8_t*)aTxBuffer, 2); - HAL_Delay(250); + aTxBuffer[0] = 0x70; + aTxBuffer[1] = 0x65; + send((uint8_t*)aTxBuffer, 2); + aTxBuffer[0] = 0x72; + aTxBuffer[1] = 0x24; + send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x70; - aTxBuffer[1] = OLED_DDISP_ON; + aTxBuffer[1] = 0x66; send((uint8_t*)aTxBuffer, 2); aTxBuffer[0] = 0x72; - aTxBuffer[1] = 0x03; + aTxBuffer[1] = 0x31; send((uint8_t*)aTxBuffer, 2); + brightness_screen1=0; + } } static void Display_Error_Handler(void) diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/externLogbookFlash.c --- a/Discovery/Src/externLogbookFlash.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/externLogbookFlash.c Tue Feb 11 18:12:00 2025 +0100 @@ -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; -}*/ +} diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/gfx_colors.c --- a/Discovery/Src/gfx_colors.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/gfx_colors.c Tue Feb 11 18:12:00 2025 +0100 @@ -14,7 +14,7 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT(c) 2014 heinrichs weikamp

+ * COPYRIGHT(c) 2014 heinrichs weikamp * ****************************************************************************** */ @@ -25,35 +25,35 @@ /* Exported variables --------------------------------------------------------*/ /* - 0x0000FF00, gr�n - 0x00FF0000, rot - 0x000000FF, blau - 0x00FFFF00, gelb + 0x0000FF00, green + 0x00FF0000, red + 0x000000FF, blue + 0x00FFFF00, yellow 0x0000FFFF, cyan 0x00000000, black - 0x000092D0, hw hellblau f�r Beschriftun + 0x000092D0, hw light blue */ uint32_t ColorLUT[] = { // ARGB - 0x00FFFFFF, // \020 wei� + 0x00FFFFFF, // \020 white 0x00333333, // \021 dark grey 0x0050FF50, // \022 units - 0x003060FF, // \023 blau + 0x003060FF, // \023 blue 0x00FFFF00, // \024 + CLUT_WarningYellow 0x00FF0000, // \025 + CLUT_WarningRed 0x0000FF00, // \026 + CLUT_NiceGreen 0x00FFFFFF, // \027 DIVE_MainColorIfNotWhite\020 0x00FFFFFF, // \030 DIVE_PluginBoxMainColor - 0x00777777, // \031 DIVE_PluginBoxGrey also used to display deactivation + 0x00AAAAAA, // \031 DIVE_PluginBoxGrey also used to display deactivation 0x0050FF50, // \032 DIVE_LabelColor 0x00FFFFFF, // CLUT_DIVE_FieldSeperatorLines 0x0050FF50, // CLUT_DIVE_pluginbox // old pink 0x00FF20FF 0x00FF00FF, // CLUT_NiceBlue descent graph (apnoe) 0x00FFFFFF, // CLUT_DIVE_SPARE22 - UNUSED - 0x0000FF00, // CLUT_DiveMainLabel - fast nur Debugmode + 0x0000FF00, // CLUT_DiveMainLabel - mainly Debug mode 0x00555555, // CLUT_pluginboxSurface 0x00101010, // CLUT_MenuLineUnselected 0x00000000, // CLUT_MenuLineUnselectedSeperator @@ -142,7 +142,7 @@ 0x00FF8000, // CLUT_BatteryProblem 0x00FFFFFF, // \027 CLUT_MainColor ---------- colorscheme 0 0x00FFFFFF, // \030 DIVE_PluginBoxMainColor colorscheme 0 - 0x00777777, // \031 DIVE_PluginBoxGrey colorscheme 0 + 0x00AAAAAA, // \031 DIVE_PluginBoxGrey colorscheme 0 0x0050FF50, // \032 DIVE_LabelColor colorscheme 0 0x00FFFFFF, // CLUT_DIVE_FieldSeperatorLines colorscheme 0 0x0050FF50, // CLUT_DIVE_pluginbox colorscheme 0 @@ -166,7 +166,7 @@ 0x00FFFFFF, // CLUT_DIVE_SPARE22 colorscheme 2 0x0033A1D6, // CLUT_MainColor --------------- colorscheme 3 0x00FFFFFF, // \030 DIVE_PluginBoxMainColor colorscheme 3 - 0x00777777, // \031 DIVE_PluginBoxGrey colorscheme 3 + 0x00AAAAAA, // \031 DIVE_PluginBoxGrey colorscheme 3 0x000000FF, // \032 DIVE_LabelColor colorscheme 3 0x0033A1D6, // CLUT_DIVE_FieldSeperatorLines colorscheme 3 0x000000FF, // CLUT_DIVE_pluginbox colorscheme 3 diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/gfx_engine.c --- a/Discovery/Src/gfx_engine.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/gfx_engine.c Tue Feb 11 18:12:00 2025 +0100 @@ -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= '\020') && (*pText <= '\032') && !minimal) settings.color = *pText - '\020'; else @@ -2190,15 +2247,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 +2262,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 +2293,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 +2311,7 @@ else if(*(char*)pText == 0) pText = (uint32_t)text_array2[j].text[0]; +#endif } // ----------------------------- @@ -2687,7 +2750,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 +3074,7 @@ return cfg->Xdelta + width; } +#ifndef BOOTLOADER_STANDALONE /** ****************************************************************************** @@ -3107,7 +3174,7 @@ return counter; } - +#endif /** ****************************************************************************** * @brief GFX write Modify Ydelta for align. / calc Ydelta for start @@ -3128,23 +3195,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) + if(gfx_selected_language >= LANGUAGE_END) gfx_selected_language = 0; #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 +3287,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) + if(gfx_selected_language >= LANGUAGE_END) gfx_selected_language = 0; +#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; @@ -3325,48 +3392,48 @@ void GFX_LTDC_Init(void) { - if (hardwareDisplay == 1) - { + if (isNewDisplay()) + { GFX_LTDC_Init_display1(); - } - else - { + } + else + { GFX_LTDC_Init_display0(); - } + } } void GFX_LTDC_Init_display0(void) { /* 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 +4067,7 @@ */ } +#ifndef BOOTLOADER_STANDALONE tFont* GFX_Check_Extra_Font(uint8_t character, tFont *Font) { uint32_t i; @@ -4029,11 +4097,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;ilength;i++) { @@ -4043,6 +4113,7 @@ } } +#ifndef BOOTLOADER_STANDALONE found = 0; if (Font == &FontT54) { @@ -4070,6 +4141,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++; + } +} + diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/logbook.c --- a/Discovery/Src/logbook.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/logbook.c Tue Feb 11 18:12:00 2025 +0100 @@ -405,6 +405,7 @@ length++; eventByte1.uw = 0; eventByte2.uw = 0; + uint8_t* pdata; //uint16_t tmpU16 = 0; const SDecoinfo * pDecoinfo; // new hw 160620 @@ -458,6 +459,15 @@ eventByte1.ub.bit7 = 1; eventByte2.ub.bit0 = 1; } + if (state->events.compassHeadingUpdate) { + eventByte1.ub.bit7 = 1; + eventByte2.ub.bit1 = 1; + } + if (state->events.gnssPositionUpdate) { + eventByte1.ub.bit7 = 1; + eventByte2.ub.bit2 = 1; + } + //Add EventByte 1 if(eventByte1.uw > 0) { @@ -498,7 +508,23 @@ sample[length] = state->events.info_bailoutHe; length += 1; } - + if (state->events.compassHeadingUpdate) { + // New heading and type of heading + sample[length++] = state->events.info_compassHeadingUpdate & 0xFF; + sample[length++] = (state->events.info_compassHeadingUpdate & 0xFF00) >> 8; + } + if (state->events.gnssPositionUpdate) { + pdata = (uint8_t*)&state->events.info_gnssPosition.fLon; + sample[length++] = *pdata++; + sample[length++] = *pdata++; + sample[length++] = *pdata++; + sample[length++] = *pdata++; + pdata = (uint8_t*)&state->events.info_gnssPosition.fLat; + sample[length++] = *pdata++; + sample[length++] = *pdata++; + sample[length++] = *pdata++; + sample[length++] = *pdata++; + } if(divisor.temperature == 0) { @@ -679,7 +705,8 @@ * @return bytes read / 0 = reading Error */ static uint16_t readSample(int32_t* depth, int16_t * gasid, int16_t* setpoint_cbar, int32_t* temperature, int32_t* sensor1, int32_t* sensor2, - int32_t* sensor3, int32_t* cns, SManualGas* manualGas, int16_t* bailout, int16_t* decostopDepth, uint16_t* tank, uint8_t* event) + int32_t* sensor3, int32_t* cns, SManualGas* manualGas, int16_t* bailout, int16_t* decostopDepth, uint16_t* tank, + SGnssCoord* pPosition, uint8_t* event) { int length = 0; _Bool bEvent = 0; @@ -691,6 +718,8 @@ uint8_t tempU8 = 0; uint16_t temp = 0; uint16_t bytesRead = 0; + uint32_t tempU32 = 0; + uint8_t index = 0; if(gasid) *gasid = -1; @@ -807,6 +836,34 @@ if(gasid) *gasid = 0; } + /* gnss position start dive */ + if(eventByte2.ub.bit2) + { + tempU32 = 0; + for(index = 0; index < 4; index++) + { + ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1); + bytesRead +=1; + length -= 1; + tempU32 |= (tempU8 << (index * 8)); + } + if(tempU32 != 0xffffffff) + { + memcpy(&pPosition->fLon, &tempU32, 4); + } + tempU32 = 0; + for(index = 0; index < 4; index++) + { + ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1); + bytesRead +=1; + length -= 1; + tempU32 |= (tempU8 << (index * 8)); + } + if(tempU32 != 0xffffffff) + { + memcpy(&pPosition->fLat, &tempU32, 4); + } + } } if(divisor.temperature == 0) @@ -949,7 +1006,7 @@ */ uint16_t logbook_readSampleData(uint8_t StepBackwards, uint16_t length,uint16_t* depth, uint8_t* gasid, int16_t* temperature, uint16_t* ppo2, uint16_t* setpoint, uint16_t* sensor1, uint16_t* sensor2, uint16_t* sensor3, uint16_t* cns, uint8_t* bailout, - uint16_t* decostopDepth, uint16_t* tank, uint8_t* event) + uint16_t* decostopDepth, uint16_t* tank, SGnssCoord* pPosition, uint8_t* event) { //Test read //SLogbookHeader header; @@ -986,6 +1043,9 @@ uint16_t tankVal = 0; uint32_t small_profileLength = 0; uint8_t eventdata; + SGnssCoord posCoord; + posCoord.fLat = 0.0; + posCoord.fLon = 0.0; SManualGas manualGasVal; SManualGas manualGasLast; @@ -1066,7 +1126,7 @@ ext_flash_set_entry_point(); divisorBackup = divisor; retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, - &bailoutVal, &decostepDepthVal, &tankVal, &eventdata); + &bailoutVal, &decostepDepthVal, &tankVal, &posCoord, &eventdata); if(retVal == 0) { @@ -1074,7 +1134,7 @@ ext_flash_reopen_read_sample_at_entry_point(); divisor = divisorBackup; retVal = readSample(&depthVal,&gasidVal,&setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, - &manualGasVal, &bailoutVal, &decostepDepthVal, &tankVal, &eventdata); + &manualGasVal, &bailoutVal, &decostepDepthVal, &tankVal, &posCoord, &eventdata); if(retVal == 0) break; @@ -1214,6 +1274,10 @@ } } } + if(pPosition) + { + memcpy(pPosition, &posCoord, sizeof(posCoord)); + } } else { @@ -1242,7 +1306,7 @@ * and finishes logbook after end of dive *********************************************************************************/ -void logbook_InitAndWrite(const SDiveState *pStateReal) +void logbook_InitAndWrite(SDiveState *pStateReal) { SSettings *pSettings = settingsGetPointer(); static uint8_t bDiveMode = 0; @@ -1259,6 +1323,7 @@ pSettings->totalDiveCounter++; logbook_initNewdiveProfile(pStateReal,settingsGetPointer()); min_temperature_float_celsius = pStateReal->lifeData.temperature_celsius; + //Write logbook sample logbook_writeSample(pStateReal); resetEvents(pStateReal); @@ -1295,6 +1360,21 @@ ext_flash_CloseSector(); /* this is just a repair function which invalidates a not used sector in case a log maintenance was called before dive */ bDiveMode = 3; + +#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 + pStateReal->events.gnssPositionUpdate = 1; + + if(pStateReal->lifeData.gnssData.alive & GNSS_ALIVE_BACKUP_POS) + { + pStateReal->events.info_gnssPosition = pStateReal->lifeData.gnssData.coord; + } + else /* no pos => define dummy */ + { + pStateReal->events.info_gnssPosition.fLon = 47.77; + pStateReal->events.info_gnssPosition.fLat = 8.99; + } +#endif + } if(bDiveMode == 3) logbook_UpdateHeader(pStateReal); @@ -1789,7 +1869,11 @@ int32_t sensor2Val = 0; int32_t sensor3Val = 0; int32_t cnsVal = 0; - SManualGas manualGasVal; + SManualGas manualGasVal; + int16_t decostepDepthVal = 0; + uint16_t tankVal = 0; + uint8_t eventdata; + SGnssCoord posCoord; //uint16_t* ppo2, uint16_t* cns# uint32_t bytesRead = 0; @@ -1809,21 +1893,22 @@ ext_flash_set_entry_point(); divisorBackup = divisor; - retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL, NULL); + retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, + &bailoutVal, &decostepDepthVal,&tankVal, &posCoord, &eventdata); if(retVal == 0) { //Error try to read again!!! ext_flash_reopen_read_sample_at_entry_point(); divisor = divisorBackup; - retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL, NULL); - + retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, + &bailoutVal, &decostepDepthVal, &tankVal, &posCoord, &eventdata); if(retVal == 0) { //Error try to read again!!! ext_flash_reopen_read_sample_at_entry_point(); divisor = divisorBackup; - retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL, NULL); - + retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, + &bailoutVal, &decostepDepthVal,&tankVal, &posCoord, &eventdata); if(retVal == 0) { ext_flash_reopen_read_sample_at_entry_point(); diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/logbook_miniLive.c --- a/Discovery/Src/logbook_miniLive.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/logbook_miniLive.c Tue Feb 11 18:12:00 2025 +0100 @@ -367,7 +367,7 @@ ReplayDataOffset = StepBackwards; logbook_getHeader(StepBackwards ,&logbookHeader); - dataLength = logbook_readSampleData(StepBackwards, DEPTH_DATA_LENGTH, ReplayDepthData,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ReplayMarkerData); + dataLength = logbook_readSampleData(StepBackwards, DEPTH_DATA_LENGTH, ReplayDepthData,NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ReplayMarkerData); /* check if a marker is provided. If not disable marker functionality for the replay block */ for(index = 0; index < dataLength; index++) @@ -383,14 +383,7 @@ ReplayMarkerData[0] = 0xFF; } - if( dataLength == DEPTH_DATA_LENGTH) /* log data has been compressed to fit into buffer */ - { - ReplayDataResolution = (logbookHeader.diveTimeMinutes * 60 + logbookHeader.diveTimeSeconds) / dataLength; - } - else - { - ReplayDataResolution = logbookHeader.samplingRate; - } + ReplayDataResolution = logbookHeader.total_diveTime_seconds / dataLength; ReplayDataLength = dataLength; ReplayDataMaxDepth = logbookHeader.maxDepth; ReplayDataMinutes = logbookHeader.diveTimeMinutes; diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/ostc.c --- a/Discovery/Src/ostc.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/ostc.c Tue Feb 11 18:12:00 2025 +0100 @@ -46,13 +46,14 @@ UART_HandleTypeDef UartIR_HUD_Handle; __IO ITStatus UartReady = RESET; +__IO ITStatus UartReadyHUD = RESET; /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private variables with external access via get_xxx() function -------------*/ - +static uint8_t hardwareDisplay = 0; //< either OSTC4 LCD (=0) or new Screen (=1) /* Private function prototypes -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ @@ -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; @@ -101,6 +138,7 @@ SMALLCPU_CSB_GPIO_ENABLE(); OSCILLOSCOPE_GPIO_ENABLE(); OSCILLOSCOPE2_GPIO_ENABLE(); + BLE_UBLOX_DSR_GPIO_ENABLE(); GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; @@ -193,6 +231,13 @@ GPIO_InitStruct.Pin = BLE_NENABLE_PIN; HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct); HAL_GPIO_WritePin(BLE_NENABLE_GPIO_PORT,BLE_NENABLE_PIN,GPIO_PIN_RESET); + + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_PULLDOWN; + GPIO_InitStruct.Speed = GPIO_SPEED_LOW; + GPIO_InitStruct.Pin = BLE_UBLOX_DSR_PIN; + HAL_GPIO_Init(BLE_UBLOX_DSR_GPIO_PORT, &GPIO_InitStruct); + HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_RESET); } @@ -203,6 +248,7 @@ GPIO_InitStruct.Pin = BLE_NENABLE_PIN; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct); + HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_RESET); } @@ -228,6 +274,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 +314,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 +394,10 @@ else if(huart == &UartIR_HUD_Handle) { +#ifndef BOOTLOADER_STANDALONE tCCR_SetRXIndication(); +#endif + UartReadyHUD = SET; } } @@ -336,7 +422,22 @@ HAL_GPIO_Init(RESET_LOGIC_ALLES_OK_GPIO_PORT, &GPIO_InitStruct); #endif } - +void SetDisplayVersion(uint8_t version) +{ + if(version < 2) + { + hardwareDisplay = version; + } +} +uint8_t isNewDisplay() +{ + uint8_t ret = 0; + if(hardwareDisplay == DISPLAY_VERSION_NEW) + { + ret = 1; + } + return ret; +} #ifndef BOOTLOADER_STANDALONE void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart) diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/settings.c --- a/Discovery/Src/settings.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/settings.c Tue Feb 11 18:12:00 2025 +0100 @@ -43,7 +43,7 @@ SSettings Settings; const uint8_t RTErequiredHigh = 3; -const uint8_t RTErequiredLow = 2; +const uint8_t RTErequiredLow = 4; const uint8_t FONTrequiredHigh = 1; const uint8_t FONTrequiredLow = 0; @@ -62,15 +62,15 @@ { .versionFirst = 1, .versionSecond = 6, - .versionThird = 5, + .versionThird = 9, .versionBeta = 0, /* 4 bytes with trailing 0 */ .signature = "mh", - .release_year = 23, - .release_month = 8, - .release_day = 26, + .release_year = 25, + .release_month = 1, + .release_day = 18, .release_sub = 0, /* max 48 with trailing 0 */ @@ -89,7 +89,7 @@ * There might even be entries with fixed values that have no range */ const SSettings SettingsStandard = { - .header = 0xFFFF0028, + .header = 0xFFFF002C, .warning_blink_dsec = 8 * 2, .lastDiveLogId = 0, .logFlashNextSampleStartAddress = SAMPLESTART, @@ -339,6 +339,11 @@ .compassDeclinationDeg = 0, .delaySetpointLow = false, .timerDurationS = 180, + .cvAutofocus = 0, + .slowExitTime = 0, + .timeZone.hours = 0, + .timeZone.minutes = 0, + .warningBuzzer = 0 }; /* Private function prototypes -----------------------------------------------*/ @@ -581,7 +586,33 @@ 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: +#ifdef ENABLE_DECOCALC_OPTION + /* 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; + } + } +#endif + // no break; + case 0xFFFF0029: + Settings.cvAutofocus = 0; + // no break; + case 0xFFFF002A: + Settings.slowExitTime = 0; + // no break; + case 0xFFFF002B: + Settings.timeZone.hours = 0; + Settings.timeZone.minutes = 0; + Settings.warningBuzzer = 0; // no break; default: pSettings->header = pStandard->header; @@ -1284,6 +1315,23 @@ setFirstCorrection(parameterId); } parameterId++; + if(Settings.slowExitTime > 9) + { + Settings.divetimeToCreateLogbook = 0; + corrections++; + setFirstCorrection(parameterId); + } + parameterId++; + + if(Settings.warningBuzzer > 1) + { + Settings.warningBuzzer = 0; + corrections++; + setFirstCorrection(parameterId); + } + parameterId++; + + /* uint8_t serialHigh; */ @@ -1821,6 +1869,21 @@ setFirstCorrection(parameterId); } parameterId++; + if(Settings.cvAutofocus > 1) + { + corrections++; + Settings.cvAutofocus = 0; + } + parameterId++; + if((Settings.timeZone.hours > 14) + || (Settings.timeZone.hours < -12) + || (Settings.timeZone.minutes > 45)) + { + Settings.timeZone.hours = 0; + Settings.timeZone.minutes = 0; + corrections++; + } + parameterId++; if(corrections) { settingsWarning = 1; @@ -1836,7 +1899,7 @@ return (uint8_t)corrections; } - +#ifndef BOOTLOADER_STANDALONE /* always at 0x8080000, do not move -> bootloader access */ const SFirmwareData* firmwareDataGetPointer(void) { @@ -1850,7 +1913,7 @@ return (SHardwareData *)HARDWAREDATA_ADDRESS; } #endif - +#endif const SSettings* settingsGetPointerStandard(void) { return &SettingsStandard; @@ -2989,7 +3052,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 +3072,7 @@ { return hardwareDataGetPointer()->primaryLicence; } - +#endif void firmwareGetDate(RTC_DateTypeDef *SdateOutput) { diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/show_logbook.c --- a/Discovery/Src/show_logbook.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/show_logbook.c Tue Feb 11 18:12:00 2025 +0100 @@ -444,6 +444,10 @@ int16_t tempdata[1000] = { 0 }; uint16_t tankdata[1000] = { 0 }; + SGnssCoord posCoord; + posCoord.fLat = 0.0; + posCoord.fLon = 0.0; + #ifdef ENABLE_BOTTLE_SENSOR uint16_t bottlePressureStart = 0; uint16_t bottlePressureEnd = 0; @@ -451,7 +455,7 @@ #endif uint16_t dataLength = 0; - dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, tempdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tankdata,NULL); + dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, tempdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tankdata, &posCoord, NULL); //Print Date uint8_t year = logbookHeader.dateYear; @@ -462,6 +466,14 @@ Gfx_write_label_var(hgfx, 30, 250,10, &FontT42,CLUT_GasSensor1,text); +#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 + if((posCoord.fLat != 0.0) || (posCoord.fLon != 0.0)) + { + snprintf(text, 20, "%2.4f - %2.4f", posCoord.fLat, posCoord.fLon ); + Gfx_write_label_var(hgfx, 300, 500,10, &FontT42,CLUT_GasSensor1,text); + } +#endif + // Print logbook number with offset if(settingsGetPointer()->logbookOffset) @@ -740,7 +752,7 @@ uint16_t decoDepthdata[1000]; uint16_t *pDecoDepthData = 0; - dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, tempdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, decoDepthdata, NULL, NULL); + dataLength = logbook_readSampleData(StepBackwards, 1000, depthdata,gasdata, tempdata, NULL, NULL, NULL, NULL, NULL, NULL, NULL, decoDepthdata, NULL, NULL, NULL); for(int i = 0; ivpm, stateSimGetPointerWrite()->diveSettings.vpm_conservatism, 0, 0); stateSimGetPointerWrite()->lifeData.counterSecondsShallowDepth = 0; stateSimGetPointerWrite()->mode = MODE_DIVE; if(aim_depth <= 0) aim_depth = 20; + sim_descent_rate_meter_per_min = 20; simulation_set_aim_depth(aim_depth); sim_aim_time_minutes = aim_time_minutes; timer_init(); @@ -98,7 +110,14 @@ decoLock = DECO_CALC_init_as_is_start_of_dive; stateSim.lifeData.apnea_total_max_depth_meter = 0; + + memcpy(stateSim.scrubberDataDive, settingsGetPointer()->scrubberData, sizeof(stateSim.scrubberDataDive)); memset(simSensmVOffset,0,sizeof(simSensmVOffset)); + if(getReplayOffset() != 0xFFFF) + { + simReplayActive = 1; + getReplayInfo(&pReplayData, &pReplayMarker, &replayDataLength, &max_depth, &diveMinutes); + } } /** @@ -137,7 +156,11 @@ static _Bool two_second = 0; static float lastPressure_bar = 0; - if (sim_aim_time_minutes && sim_aim_time_minutes * 60 <= pDiveState->lifeData.dive_time_seconds) { + pSettings = settingsGetPointer(); + + if ((sim_aim_time_minutes && sim_aim_time_minutes * 60 <= pDiveState->lifeData.dive_time_seconds) + && (!simReplayActive)) + { simulation_set_aim_depth(0); } @@ -146,25 +169,42 @@ if(checkOncePerSecond) { + int now = current_second(); + if( last_second == now) + return; + last_second = now; - pSettings = settingsGetPointer(); + if(!two_second) + two_second = 1; + else + { + two_second = 0; + } + for(index = 0; index < 3; index++) { - localCalibCoeff[index] = pSettings->ppo2sensors_calibCoeff[index]; - if(localCalibCoeff[index] < 0.01) + if(pDiveState->lifeData.extIf_sensor_map[index] == SENSOR_DIGO2M) + { + localCalibCoeff[index] = 0.01; + } + else { - for(index2 = 0; index2 < 3; index2++) /* no valid coeff => check other entries */ - { - if(pSettings->ppo2sensors_calibCoeff[index2] > 0.01) - { - localCalibCoeff[index] = pSettings->ppo2sensors_calibCoeff[index2]; - break; - } - if(index2 == 3) /* no coeff at all => use default */ - { - localCalibCoeff[index] = 0.02; - } - } + localCalibCoeff[index] = pSettings->ppo2sensors_calibCoeff[index]; + if(localCalibCoeff[index] < 0.01) + { + for(index2 = 0; index2 < 3; index2++) /* no valid coeff => check other entries */ + { + if(pSettings->ppo2sensors_calibCoeff[index2] > 0.01) + { + localCalibCoeff[index] = pSettings->ppo2sensors_calibCoeff[index2]; + break; + } + if(index2 == 3) /* no coeff at all => use default */ + { + localCalibCoeff[index] = 0.02; + } + } + } } } @@ -183,29 +223,48 @@ pDiveState->lifeData.bottle_bar[pDiveState->lifeData.actualGas.GasIdInSettings] = pRealState->lifeData.bottle_bar[pRealState->lifeData.actualGas.GasIdInSettings]; pDiveState->lifeData.bottle_bar_age_MilliSeconds[pDiveState->lifeData.actualGas.GasIdInSettings] = pRealState->lifeData.bottle_bar_age_MilliSeconds[pRealState->lifeData.actualGas.GasIdInSettings]; #endif - int now = current_second(); - if( last_second == now) - return; - last_second = now; - - if(!two_second) - two_second = 1; - else - { - two_second = 0; - if(lastPressure_bar >= 0) - { - //2 seconds * 30 == 1 minute, bar * 10 = meter - pDiveState->lifeData.ascent_rate_meter_per_min = (lastPressure_bar - pDiveState->lifeData.pressure_ambient_bar) * 30 * 10; - } - lastPressure_bar = pDiveState->lifeData.pressure_ambient_bar; - } } else if(pDiveState->lifeData.depth_meter <= (float)(decom_get_actual_deco_stop(pDiveState) + 0.001)) - sim_reduce_deco_time_one_second(pDiveState); + { + if(decoLock == DECO_CALC_FINSHED_vpm) + { + sim_reduce_deco_time_one_second(&stateDeco); + } + else + { + sim_reduce_deco_time_one_second(pDiveState); + } + } pDiveState->lifeData.dive_time_seconds += 1; pDiveState->lifeData.pressure_ambient_bar = sim_get_ambient_pressure(pDiveState); + if(pDiveState->lifeData.depth_meter < 1.5) + { + lastPressure_bar = 0; + pDiveState->lifeData.ascent_rate_meter_per_min = 0; + } + + if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (isLoopMode(pSettings->dive_mode)) && (pDiveState->mode == MODE_DIVE) && isLoopMode(pDiveState->diveSettings.diveMode)) + { + simScrubberTimeoutCount++; + if(simScrubberTimeoutCount >= 60) /* resolution is minutes */ + { + simScrubberTimeoutCount = 0; + if(pDiveState->scrubberDataDive[pSettings->scubberActiveId].TimerCur > MIN_SCRUBBER_TIME) + { + pDiveState->scrubberDataDive[pSettings->scubberActiveId].TimerCur--; + } + translateDate(stateUsed->lifeData.dateBinaryFormat, &pDiveState->scrubberDataDive[pSettings->scubberActiveId].lastDive); + } + } + + + if(lastPressure_bar > 0) + { + //1 second * 60 == 1 minute, bar * 10 = meter + pDiveState->lifeData.ascent_rate_meter_per_min = (lastPressure_bar - pDiveState->lifeData.pressure_ambient_bar) * 600.0; + } + lastPressure_bar = pDiveState->lifeData.pressure_ambient_bar; pDiveState->lifeData.sensorVoltage_mV[0] = pRealState->lifeData.sensorVoltage_mV[0] + simSensmVOffset[0]; if(pDiveState->lifeData.sensorVoltage_mV[0] < 0.0) { pDiveState->lifeData.sensorVoltage_mV[0] = 0.0; } @@ -349,6 +408,35 @@ uint8_t actual_deco_stop = decom_get_actual_deco_stop(pDiveState); float depth_meter = pDiveState->lifeData.depth_meter; float surface_pressure_bar = pDiveState->lifeData.pressure_surface_bar; + static uint8_t sampleToggle = 0; + static float sim_ascent_rate_meter_per_min_local = 0; + uint8_t sampleTime = getReplayDataResolution(); + + if(simReplayActive) /* precondition: function is called once per second, sample rate is a multiple of second */ + { + if(sampleToggle == 0) + { + sampleToggle = sampleTime - 1; + sim_aim_depth_meter = (float)(*pReplayData++/100.0); + if(sim_aim_depth_meter > depth_meter) + { + sim_descent_rate_meter_per_min = (sim_aim_depth_meter - depth_meter) * (60 / sampleTime); + } + else + { + sim_ascent_rate_meter_per_min_local = (depth_meter - sim_aim_depth_meter) * (60 / sampleTime); + } + } + else + { + sampleToggle--; + } + } + else + { + sim_ascent_rate_meter_per_min_local = pDiveState->diveSettings.ascentRate_meterperminute; + } + if(depth_meter < sim_aim_depth_meter) { depth_meter = depth_meter + sim_descent_rate_meter_per_min / 60; @@ -358,16 +446,16 @@ else if(depth_meter > sim_aim_depth_meter) { - depth_meter -= pDiveState->diveSettings.ascentRate_meterperminute / 60; + depth_meter -= sim_ascent_rate_meter_per_min_local / 60; if(depth_meter < sim_aim_depth_meter) depth_meter = sim_aim_depth_meter; if(sim_heed_decostops && depth_meter < actual_deco_stop) { - if(actual_deco_stop < (depth_meter + pDiveState->diveSettings.ascentRate_meterperminute / 60)) + if(actual_deco_stop < (depth_meter + sim_ascent_rate_meter_per_min_local / 60)) depth_meter = actual_deco_stop; else - depth_meter += pDiveState->diveSettings.ascentRate_meterperminute / 60; + depth_meter += sim_ascent_rate_meter_per_min_local / 60; } } @@ -387,31 +475,53 @@ static void sim_reduce_deco_time_one_second(SDiveState* pDiveState) { SDecoinfo* pDecoinfo; + int8_t index = 0; + + if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE) pDecoinfo = &pDiveState->decolistBuehlmann; else pDecoinfo = &pDiveState->decolistVPM; //Reduce deco time of deepest stop by one second - for(int i = DECOINFO_STRUCT_MAX_STOPS -1 ;i >= 0; i--) + for(index = DECOINFO_STRUCT_MAX_STOPS -1 ;index >= 0; index--) { - if(pDecoinfo->output_stop_length_seconds[i] > 0) + if(pDecoinfo->output_stop_length_seconds[index] > 0) { - pDecoinfo->output_stop_length_seconds[i]--; + pDecoinfo->output_stop_length_seconds[index]--; break; } } + /* update TTS */ + if(pDecoinfo->output_time_to_surface_seconds) + { + pDecoinfo->output_time_to_surface_seconds--; + } } SDecoinfo* simulation_decoplaner(uint16_t depth_meter, uint16_t intervall_time_minutes, uint16_t dive_time_minutes, uint8_t *gasChangeListDepthGas20x2) { uint8_t ptrGasChangeList = 0; // new hw 160704 - +#ifdef ENABLE_DECOCALC_OPTION + uint8_t index = 0; +#endif for (int i = 0; i < 40; i++) gasChangeListDepthGas20x2[i] = 0; SDiveState * pDiveState = &stateSim; copyDiveSettingsToSim(); + +#ifdef ENABLE_DECOCALC_OPTION + /* activate deco calculation for all deco gases */ + for(index = 0; index < 1 + (2*NUM_GASES); index++) + { + if(pDiveState->diveSettings.gas[index].note.ub.deco) + { + pDiveState->diveSettings.gas[index].note.ub.decocalc = 1; + } + } +#endif + vpm_init(&pDiveState->vpm, pDiveState->diveSettings.vpm_conservatism, 0, 0); //buehlmann_init(); //timer_init(); @@ -466,7 +576,11 @@ // 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) +#ifdef ENABLE_DECOCALC_OPTION + || (pDiveState->diveSettings.gas[pDiveState->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0) +#endif + ) break; gasChangeListDepthGas20x2[ptrGasChangeList++] = pDiveState->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; gasChangeListDepthGas20x2[ptrGasChangeList++] = pDiveState->diveSettings.decogaslist[i].GasIdInSettings; @@ -487,6 +601,11 @@ /* this does modify the cns now 11.06.2015 */ vpm_calc(&pDiveState->lifeData,&pDiveState->diveSettings,&pDiveState->vpm,&pDiveState->decolistVPM, DECOSTOPS); pDiveState->lifeData.cns += vpm_get_CNS(); + + while(decoLock == DECO_CALC_FINSHED_vpm) + { + HAL_Delay(2); /* The deco data is copied during the timer ISR => wait till this has happened */ + } return &pDiveState->decolistVPM; } } @@ -639,24 +758,14 @@ outputSummary->timeToFirstStop = (uint16_t)timeSummary; outputSummary->depthMeterFirstStop = actualDepthPoint; - //ascent - nextDepthPoint = 0; - timeThis = 0; - if(actualDepthPoint > nextDepthPoint) // only if deco + if(decoInfoInput->output_time_to_surface_seconds) { - // ascent time - timeThis = ((float)(actualDepthPoint - nextDepthPoint)) / sim_ascent_rate_meter_per_min_local; - - // deco stop time - for(ptrDecoInfo=0;ptrDecoInfo < DECOINFO_STRUCT_MAX_STOPS; ptrDecoInfo++) - { - timeThis += decoInfoInput->output_stop_length_seconds[ptrDecoInfo] / 60; - if(!decoInfoInput->output_stop_length_seconds[ptrDecoInfo]) break; - } + outputSummary->timeToSurface = outputSummary->timeAtBottom + (decoInfoInput->output_time_to_surface_seconds / 60); } - timeSummary += timeThis; - outputSummary->timeToSurface = (uint16_t)timeSummary; - + else + { + outputSummary->timeToSurface = outputSummary->timeToFirstStop; + } } diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/t3.c --- a/Discovery/Src/t3.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/t3.c Tue Feb 11 18:12:00 2025 +0100 @@ -28,6 +28,7 @@ /* Includes ------------------------------------------------------------------*/ #include +#include #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,8 @@ 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); +uint8_t t3_drawSlowExitGraph(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1); /* this function is only called if diver is below last last stop depth */ /* Exported functions --------------------------------------------------------*/ @@ -101,7 +94,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 +165,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) @@ -396,15 +391,28 @@ { char text[256]; uint8_t textPointer; - uint8_t color; + uint8_t color = 0; uint8_t depthChangeRate; uint8_t depthChangeAscent; point_t start, stop, startZeroLine; SDivetime Divetime = {0,0,0,0}; + uint16_t nextstopLengthSeconds = 0; + uint8_t nextstopDepthMeter = 0; SSettings* pSettings; pSettings = settingsGetPointer(); + const SDecoinfo * pDecoinfo = getDecoInfo(); + if(pDecoinfo->output_time_to_surface_seconds) + { + tHome_findNextStop(pDecoinfo->output_stop_length_seconds, &nextstopDepthMeter, &nextstopLengthSeconds); + } + else + { + nextstopDepthMeter = 0; + nextstopLengthSeconds = 0; + } + start.x = 0; stop.x = 799; stop.y = start.y = BigFontSeperationTopBottom; @@ -417,7 +425,6 @@ GFX_draw_line(tXscreen, start, stop, CLUT_Font020); } - start.y = BigFontSeperationTopBottom; stop.y = 479; @@ -431,39 +438,6 @@ GFX_draw_line(tXscreen, start, stop, CLUT_Font020); } - /* depth */ - float depth = unit_depth_float(stateUsed->lifeData.depth_meter); - - if(depth <= 0.3f) - depth = 0; - - if(settingsGetPointer()->nonMetricalSystem) - snprintf(text,TEXTSIZE,"\032\f[feet]"); - else - snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth); - GFX_write_string(&FontT42,tXl1,text,0); - - if( ((mode == DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 4) || (stateUsed->lifeData.ascent_rate_meter_per_min < -4 ))) - || ((mode != DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10))) - ) - { - snprintf(text,TEXTSIZE,"\f\002%.0f %c%c/min " - , unit_depth_float(stateUsed->lifeData.ascent_rate_meter_per_min) - , unit_depth_char1() - , unit_depth_char2() - ); - GFX_write_string(&FontT42,tXl1,text,0); - } - - if( depth < 100) - snprintf(text,TEXTSIZE,"\020\003\016%01.1f",depth); - else - snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth); - - t3_basics_colorscheme_mod(text); - GFX_write_string(&FontT105,tXl1,text,1); - - /* ascentrate graph */ if(mode == DIVEMODE_Apnea) { @@ -561,69 +535,109 @@ } else { - /* ascentrate graph -standard mode */ - if(stateUsed->lifeData.ascent_rate_meter_per_min > 0) - { - if(!pSettings->FlipDisplay) - { - start.y = tXl1->WindowY0 - 1; - } - else - { - start.y = tXl1->WindowY1 + 1; - } + color = 0xff; + if((pSettings->slowExitTime != 0) && (nextstopDepthMeter == 0) && (stateUsed->lifeData.depth_meter < pSettings->last_stop_depth_meter)) + { + color = t3_drawSlowExitGraph(tXscreen, tXl1, tXr1); + } + if(color == 0xff) /* no slow exit => continue with common ascent graph */ + { + if(stateUsed->lifeData.ascent_rate_meter_per_min > 0) /* ascentrate graph -standard mode */ + { + if(!pSettings->FlipDisplay) + { + start.y = tXl1->WindowY0 - 1; + } + else + { + start.y = tXl1->WindowY1 + 1; + } + + for(int i = 0; i<4;i++) + { + start.y += 5*8; + stop.y = start.y; + if(!pSettings->FlipDisplay) + { + start.x = tXl1->WindowX1 - 1; + } + else + { + start.x = tXr1->WindowX1 + 3; + } + stop.x = start.x - 17; + GFX_draw_line(tXscreen, start, stop, 0); + } + // new thick bar design Sept. 2015 + if(!pSettings->FlipDisplay) + { + start.x = tXl1->WindowX1 - 3 - 5; + } + else + { + start.x = tXr1->WindowX1 - 3 - 5; + } - for(int i = 0; i<4;i++) - { - start.y += 5*8; - stop.y = start.y; - if(!pSettings->FlipDisplay) - { - start.x = tXl1->WindowX1 - 1; - } - else - { - start.x = tXr1->WindowX1 - 1; - } - stop.x = start.x - 17; - GFX_draw_line(tXscreen, start, stop, 0); - } - // new thick bar design Sept. 2015 - if(!pSettings->FlipDisplay) - { - start.x = tXl1->WindowX1 - 3 - 5; - } - else - { - start.x = tXr1->WindowX1 - 3 - 5; - } + stop.x = start.x; + if(!pSettings->FlipDisplay) + { + start.y = tXl1->WindowY0 - 1; + } + else + { + start.y = tXl1->WindowY1 + 1; + } + + stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 8); + stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9 + 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; - stop.x = start.x; - if(!pSettings->FlipDisplay) - { - start.y = tXl1->WindowY0 - 1; - } - else - { - start.y = tXl1->WindowY1 + 1; - } + GFX_draw_thick_line(12,tXscreen, start, stop, color); + } + color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min); + } + } + /* depth */ + float depth = unit_depth_float(stateUsed->lifeData.depth_meter); + + if(depth <= 0.3f) + depth = 0; + + if(settingsGetPointer()->nonMetricalSystem) + snprintf(text,TEXTSIZE,"\032\f[feet]"); + else + snprintf(text,TEXTSIZE,"\032\f%c",TXT_Depth); + GFX_write_string(&FontT42,tXl1,text,0); - stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 8); - stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9 - 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( ((mode == DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 4) || (stateUsed->lifeData.ascent_rate_meter_per_min < -4 ))) + || ((mode != DIVEMODE_Apnea) && ((stateUsed->lifeData.ascent_rate_meter_per_min > 8) || (stateUsed->lifeData.ascent_rate_meter_per_min < -10))) + ) + { + snprintf(text,TEXTSIZE,"\f\002%.0f %c%c/min " + , unit_depth_float(stateUsed->lifeData.ascent_rate_meter_per_min) + , unit_depth_char1() + , unit_depth_char2() + ); + GFX_write_string(&FontT42,tXl1,text,0); + } - GFX_draw_thick_line(12,tXscreen, start, stop, color); - } - } + if( depth < 100) + snprintf(text,TEXTSIZE,"\020\003\016%01.1f",depth); + else + snprintf(text,TEXTSIZE,"\020\003\016%01.0f",depth); + + Gfx_colorsscheme_mod(text,color); + GFX_write_string(&FontT105,tXl1,text,1); + // divetime if(mode == DIVEMODE_Apnea) @@ -655,7 +669,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 +740,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; } @@ -749,10 +763,14 @@ customview_warnings = t3_test_customview_warnings(); if(customview_warnings && warning_count_high_time) + { t3_basics_show_customview_warnings(&t3c1); + } else + { t3_refresh_customview(depth_meter); - + requestBuzzerActivation(0); + } if(stateUsed->warnings.lowBattery) t3_basics_battery_low_customview_extra(&t3r1); //t3c1); } @@ -831,7 +849,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 +876,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 +898,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 +920,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 +989,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 +1015,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 +1030,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 +1220,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 +1231,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 +1242,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 +1258,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 +1267,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 +1313,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)) { @@ -1303,7 +1341,7 @@ textpointer = 0; text[textpointer++] = '\002'; - textpointer += printScrubberText(&text[textpointer], 10, pSettings); + textpointer += printScrubberText(&text[textpointer], 10, stateUsed->scrubberDataDive, pSettings); GFX_write_string(&FontT105,tXc1,text,1); } } @@ -1327,7 +1365,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 +1392,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 +1401,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 +1413,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 +1479,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 +1539,9 @@ { char text[256], textMain[256]; uint8_t textpointer, textpointerMain, lineFree, more; +#ifdef HAVE_DEBUG_WARNINGS + uint8_t index = 0; +#endif snprintf(text,TEXTSIZE,"\025\f%c",TXT_Warning); GFX_write_string(&FontT42,&t3c1,text,0); @@ -1622,7 +1663,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; @@ -1634,6 +1687,7 @@ { GFX_write_string(&FontT48,&t3c2,text,0); } + requestBuzzerActivation(1); } uint8_t t3_customview_disabled(uint8_t view) @@ -1655,7 +1709,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 +1721,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 +1742,7 @@ if (tX_customviews[index] == *tX_selection_customview) { curViewIdx = index; + break; } index++; } @@ -1731,7 +1786,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 +1843,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 +1976,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; @@ -1951,9 +1996,9 @@ return t3_selection_customview; } -int printScrubberText(char *text, size_t size, SSettings *settings) +int printScrubberText(char *text, size_t size, const SScrubberData *scrubberData, SSettings *settings) { - int16_t currentTimerMinutes = settings->scrubberData[settings->scubberActiveId].TimerCur; + int16_t currentTimerMinutes = scrubberData[settings->scubberActiveId].TimerCur; char colour = '\020'; if (currentTimerMinutes <= 0) { colour = '\025'; @@ -1967,3 +2012,232 @@ 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; + } + } + } +} + +#define ASCENT_GRAPH_YPIXEL 220 +uint8_t t3_drawSlowExitGraph(GFX_DrawCfgScreen *tXscreen, GFX_DrawCfgWindow* tXl1, GFX_DrawCfgWindow* tXr1) /* this function is only called if diver is below last last stop depth */ +{ + static uint16_t countDownSec = 0; + uint8_t drawingMeterStep; + static float exitDepthMeter = 0.0; + + + uint8_t index = 0; + uint8_t color = 0; + point_t start, stop; + + SSettings* pSettings; + pSettings = settingsGetPointer(); + + + if(calculateSlowExit(&countDownSec, &exitDepthMeter, &color)) /* graph to be drawn? */ + { + if(!pSettings->FlipDisplay) + { + start.y = tXl1->WindowY0 - 1; + } + else + { + start.y = tXl1->WindowY1 + 1; + } + + drawingMeterStep = ASCENT_GRAPH_YPIXEL / pSettings->last_stop_depth_meter; /* based on 120 / 4 = 30 of standard ascent graph */ + + for(index = 0; index < pSettings->last_stop_depth_meter; index++) /* draw meter indicators */ + { + start.y += drawingMeterStep; + stop.y = start.y; + if(!pSettings->FlipDisplay) + { + start.x = tXl1->WindowX1 - 1; + } + else + { + start.x = tXr1->WindowX1 + 3; + } + stop.x = start.x - 43; + GFX_draw_line(tXscreen, start, stop, 0); + } + + /* draw cntdown bar */ + + if(!pSettings->FlipDisplay) + { + start.x -= 20; + start.y = tXl1->WindowY0 + ASCENT_GRAPH_YPIXEL + 2; + } + else + { + start.x -= 25; + start.y = tXl1->WindowY1 + ASCENT_GRAPH_YPIXEL + 5; + } + stop.x = start.x; + stop.y = start.y - countDownSec * (ASCENT_GRAPH_YPIXEL / (float)(pSettings->slowExitTime * 60.0)); + if(stop.y >= 470) stop.y = 470; + if(!pSettings->FlipDisplay) + { + stop.y += 5; + } + GFX_draw_thick_line(15,tXscreen, start, stop, 3); + /* mark diver depth */ + if(!pSettings->FlipDisplay) + { + start.x = tXl1->WindowX1 - 32; + stop.x = start.x + 24; + } + else + { + start.x = tXr1->WindowX1 - 33; + stop.x = start.x + 24; + } + + + start.y = start.y - (stateUsed->lifeData.depth_meter * (ASCENT_GRAPH_YPIXEL) / pSettings->last_stop_depth_meter); + stop.y = start.y; + GFX_draw_thick_line(10,tXscreen, start, stop, 9); + } + else + { + color = 0xff; + } + return color; +} diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/t4_tetris.c --- a/Discovery/Src/t4_tetris.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/t4_tetris.c Tue Feb 11 18:12:00 2025 +0100 @@ -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); } diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/t5_gauge.c --- a/Discovery/Src/t5_gauge.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/t5_gauge.c Tue Feb 11 18:12:00 2025 +0100 @@ -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, diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/t6_apnea.c --- a/Discovery/Src/t6_apnea.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/t6_apnea.c Tue Feb 11 18:12:00 2025 +0100 @@ -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 }; diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/t7.c --- a/Discovery/Src/t7.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/t7.c Tue Feb 11 18:12:00 2025 +0100 @@ -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" @@ -46,6 +47,7 @@ #include "configuration.h" #include "base.h" #include "tMenuEditSetpoint.h" +#include "vpm.h" #define TIMER_ACTION_DELAY_S 10 @@ -69,7 +71,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); @@ -79,6 +80,10 @@ uint8_t t7_customtextPrepare(char * text); +static void t7_drawAcentGraph(uint8_t color); +static uint8_t t7_drawSlowExitGraph(void); +static void t7_showPosition(void); + /* Imported function prototypes ---------------------------------------------*/ extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium); @@ -120,22 +125,7 @@ /* 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[] = { @@ -149,13 +139,16 @@ CVIEW_Charger, CVIEW_CcrSummary, CVIEW_Timer, +#if defined ENABLE_GPIO_V2 || defined ENABLE_GNSS_SUPPORT + CVIEW_Position, +#endif CVIEW_END }; 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 @@ -215,7 +208,7 @@ t7l2.Image = &t7screen; t7l2.WindowNumberOfTextLines = 2; - t7l2.WindowLineSpacing = 22; // Abstand von Y0 + t7l2.WindowLineSpacing = 12; // Abstand von Y0 t7l2.WindowTab = 100; // vermtl. ohne Verwendung in diesem Fenster t7l2.WindowX0 = 0; t7l2.WindowX1 = t7l1.WindowX1; @@ -382,7 +375,7 @@ t7l2.Image = &t7screen; t7l2.WindowNumberOfTextLines = 2; - t7l2.WindowLineSpacing = 22; // Abstand von Y0 + t7l2.WindowLineSpacing = 12; // Abstand von Y0 t7l2.WindowTab = 100; // vermtl. ohne Verwendung in diesem Fenster t7l2.WindowX0 = t7l1.WindowX0; t7l2.WindowX1 = t7l1.WindowX1; @@ -580,42 +573,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 +590,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 +1428,9 @@ count++; } #endif +#ifdef HAVE_DEBUG_WARNINGS + count += stateUsed->warnings.debug; +#endif return count; } @@ -1505,6 +1502,9 @@ { char text[256]; uint8_t textpointer, lineFree; +#ifdef HAVE_DEBUG_WARNINGS + uint8_t index = 0; +#endif text[0] = '\025'; text[1] = '\f'; @@ -1591,6 +1591,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) { @@ -1603,6 +1616,7 @@ } */ GFX_write_string(&FontT48,&t7cW,text,1); + requestBuzzerActivation(1); } @@ -1948,7 +1962,7 @@ data[dataIndex++] = '\n'; data[dataIndex++] = '\r'; data[dataIndex++] = '\t'; - dataIndex += printScrubberText(&data[dataIndex], 10, settings); + dataIndex += printScrubberText(&data[dataIndex], 10, settings->scrubberData, settings); } heading[headingIndex++] = '\017'; @@ -1977,7 +1991,7 @@ t7cY0free.WindowX1 += 10; } - t7_colorscheme_mod(data); + Gfx_colorsscheme_mod(data, 0); GFX_write_string(&FontT42, &t7cY0free, data, 1); } @@ -2131,11 +2145,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); } @@ -2165,6 +2179,7 @@ SSettingsStatus SettingsStatus; SSettings* pSettings; pSettings = settingsGetPointer(); + uint8_t decoPlanEntries = 6; uint8_t local_ppo2sensors_deactivated = 0; @@ -2174,7 +2189,7 @@ } else { - local_ppo2sensors_deactivated = pSettings->ppo2sensors_deactivated; + local_ppo2sensors_deactivated = pSettings->ppo2sensors_deactivated; } if(last_customview != selection_customview) /* check if current selection is disabled and should be skipped */ @@ -2619,7 +2634,27 @@ break; case CVIEW_Decolist: - snprintf(text,100,"\032\f\001 %c%c", TXT_2BYTE, TXT2BYTE_Decolist); + + + if(settingsGetPointer()->VPM_conservatism.ub.alternative == 0) + { + text[0] = '\032'; + } + else + { + switch(vpm_get_TableState()) + { + case VPM_TABLE_MISSED: text[0] = '\025'; + break; + case VPM_TABLE_WARNING: text[0] = '\024'; + break; + case VPM_TABLE_ACTIVE: + case VPM_TABLE_INIT: + default: text[0] = '\032'; + break; + } + } + snprintf(&text[1],100,"\f\001 %c%c", TXT_2BYTE, TXT2BYTE_Decolist); GFX_write_string(&FontT42,&t7cH,text,0); uint8_t depthNext, depthLast, depthSecond, depthInc; @@ -2634,15 +2669,19 @@ depthSecond = (uint8_t)unit_depth_integer(depthSecond); depthInc = (uint8_t)unit_depth_integer(depthInc); } + if(stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) /* show additional VPM data in last slot */ + { + decoPlanEntries = 5; + } const SDecoinfo * pDecoinfo = getDecoInfo(); for(start=DECOINFO_STRUCT_MAX_STOPS-1; start>0; start--) if(pDecoinfo->output_stop_length_seconds[start]) break; - start -= 6; + start -= decoPlanEntries; if(start < 0) start = 0; textpointer = 0; - for(int i=start;i<6+start;i++) + for(int i=start;i 200) break; } + if(decoPlanEntries == 5) /* add VPM deco zone */ + { + textpointer += snprintf(&text[textpointer],30,"\031\034 Zone %2u\016\016%c%c\017\n\r",vpm_get_decozone(), unit_depth_char1(), unit_depth_char2()); + } if(!pSettings->FlipDisplay) { t7cY0free.WindowY0 = t7cC.WindowY0 - 10; @@ -2672,9 +2715,7 @@ case CVIEW_CcrSummary: snprintf(text, 100, "\032\f\001%c%c", TXT_2BYTE, TXT2BYTE_CcrSummary); GFX_write_string(&FontT42, &t7cH, text, 0); - t7_CcrSummary(pSettings); - break; case CVIEW_Timer: snprintf(text, 100, "\032\f\001%c%c", TXT_2BYTE, TXT2BYTE_Timer); @@ -2687,6 +2728,11 @@ showTimer(pSettings, nowS); break; + + case CVIEW_Position: + snprintf(text, 100, "\032\f\001%c%c", TXT_2BYTE, TXT2BYTE_Position); + GFX_write_string(&FontT42, &t7cH, text, 0); + t7_showPosition(); } last_customview = selection_customview; @@ -2708,8 +2754,7 @@ char TextC2[TEXTSIZE]; uint8_t textPointer; - point_t start, stop; - uint8_t color; + uint8_t color = 0; int textlength; uint16_t nextstopLengthSeconds = 0; @@ -2731,8 +2776,8 @@ SafetyStopTime.Minutes = SafetyStopTime.Total / 60; SafetyStopTime.Seconds = SafetyStopTime.Total - (SafetyStopTime.Minutes * 60); - TimeoutTime.Total = settingsGetPointer()->timeoutDiveReachedZeroDepth - stateUsed->lifeData.counterSecondsShallowDepth; - if(TimeoutTime.Total > settingsGetPointer()->timeoutDiveReachedZeroDepth) + TimeoutTime.Total = pSettings->timeoutDiveReachedZeroDepth - stateUsed->lifeData.counterSecondsShallowDepth; + if(TimeoutTime.Total > pSettings->timeoutDiveReachedZeroDepth) { TimeoutTime.Total = 0; } @@ -2750,6 +2795,35 @@ nextstopLengthSeconds = 0; } + + /* max depth */ + snprintf(TextL2,TEXTSIZE,"\032\f%c",TXT_MaxDepth); + GFX_write_string(&FontT42,&t7l2,TextL2,0); + + if(unit_depth_float(stateUsed->lifeData.max_depth_meter) < 100) + snprintf(TextL2,TEXTSIZE,"\020%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); + else + snprintf(TextL2,TEXTSIZE,"\020%01.0f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); + + Gfx_colorsscheme_mod(TextL2, 0); + GFX_write_string(&FontT105,&t7l2,TextL2,1); + +/* ascent rate graph */ + color = 0xff; + if((pSettings->slowExitTime != 0) && (nextstopDepthMeter == 0) && (stateUsed->lifeData.depth_meter < pSettings->last_stop_depth_meter)) + { + color = t7_drawSlowExitGraph(); + } + if(color == 0xff) + { + color = drawingColor_from_ascentspeed(stateUsed->lifeData.ascent_rate_meter_per_min); + if(stateUsed->lifeData.ascent_rate_meter_per_min > 1) /* a value < 1 would cause a bar in negative direction brush rectangle of 12 and step width of 6 */ + { + + t7_drawAcentGraph(color); + } + } + /* depth */ float depth = unit_depth_float(stateUsed->lifeData.depth_meter); @@ -2760,6 +2834,7 @@ snprintf(TextL1,TEXTSIZE,"\032\f[feet]"); else snprintf(TextL1,TEXTSIZE,"\032\f%c",TXT_Depth); + 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,73 +2852,11 @@ else snprintf(TextL1,TEXTSIZE,"\020%01.0f",depth); - t7_colorscheme_mod(TextL1); - GFX_write_string(&FontT144,&t7l1,TextL1,1); - - /* max depth */ - snprintf(TextL2,TEXTSIZE,"\032\f%c",TXT_MaxDepth); - GFX_write_string(&FontT42,&t7l2,TextL2,0); - - if(unit_depth_float(stateUsed->lifeData.max_depth_meter) < 100) - snprintf(TextL2,TEXTSIZE,"\020%01.1f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); - else - snprintf(TextL2,TEXTSIZE,"\020%01.0f",unit_depth_float(stateUsed->lifeData.max_depth_meter)); - - t7_colorscheme_mod(TextL2); - GFX_write_string(&FontT105,&t7l2,TextL2,1); - - /* ascent rate graph */ - if(stateUsed->lifeData.ascent_rate_meter_per_min > 1) /* a value < 1 would cause a bar in negative direction brush rectangle of 12 and step width of 6 */ - { - if(!pSettings->FlipDisplay) - { - start.y = t7l1.WindowY0 - 1; - } - else - { - start.y = t7l3.WindowY0 - 25; - } - - for(int i = 0; i<4;i++) - { - start.y += 5*6; - stop.y = start.y; - start.x = CUSTOMBOX_LINE_LEFT - 1; - stop.x = start.x - 17; - GFX_draw_line(&t7screen, start, stop, 0); -// start.x = CUSTOMBOX_LINE_RIGHT + 2; old right too -// stop.x = start.x + 17; -// GFX_draw_line(&t7screen, start, stop, 0); - } - // new thick bar design Sept. 2015 - start.x = CUSTOMBOX_LINE_LEFT - CUSTOMBOX_OUTSIDE_OFFSET - 3 - 5; - stop.x = start.x; - if(!pSettings->FlipDisplay) - { - start.y = t7l1.WindowY0 - 1; - } - else - { - start.y = t7l3.WindowY0 - 25; - } - stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 6); - stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9 - 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; - - GFX_draw_thick_line(12,&t7screen, start, stop, color); - } - //snprintf(TextL2,TEXTSIZE,"\f%.1f m/min",stateUsed->lifeData.ascent_rate_meter_per_min); - - /* divetime */ + Gfx_colorsscheme_mod(TextL1, color); + + GFX_write_string(&FontT144,&t7l1,TextL1,0); + +/* divetime */ if(stateUsed->lifeData.counterSecondsShallowDepth) { snprintf(TextR1,TEXTSIZE,"\f\002\136 %u:%02u",TimeoutTime.Minutes, TimeoutTime.Seconds); @@ -2859,20 +2872,33 @@ 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 */ if(nextstopDepthMeter) { - snprintf(TextR2,TEXTSIZE,"\032\f\002%c",TXT_Decostop); - GFX_write_string(&FontT42,&t7r2,TextR2,0); - textlength = snprintf(TextR2,TEXTSIZE,"\020\002%u%c%c %u'" + snprintf(TextR2,TEXTSIZE,"\032\f\002%c",TXT_Decostop); + GFX_write_string(&FontT42,&t7r2,TextR2,0); + + if((stateUsed->diveSettings.deco_type.ub.standard == VPM_MODE) && (pSettings->VPM_conservatism.ub.alternative) + && (fabs(stateUsed->lifeData.depth_meter - nextstopDepthMeter)) < 1.5) + { + TextR2[0] = '\026'; + textlength = 1; + } + else + { + TextR2[0] = '\020'; + textlength = 1; + } + + textlength += snprintf(&TextR2[textlength],TEXTSIZE,"\002%u%c%c %u'" , unit_depth_integer(nextstopDepthMeter) , 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 +2913,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 +2928,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 +2941,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); @@ -2955,13 +2981,15 @@ if (isLoopMode(stateUsed->diveSettings.diveMode)) { textPointer = snprintf(TextR1, TEXTSIZE, "\a\001 %c%c ", TXT_2BYTE, TXT2BYTE_BailoutShort); textPointer += tHome_gas_writer(stateUsed->diveSettings.gas[actualBetterBailoutGasId()].oxygen_percentage, stateUsed->diveSettings.gas[actualBetterBailoutGasId()].helium_percentage, &TextR1[textPointer]); + TextR1[textPointer++] = '?'; TextR1[textPointer++] = ' '; - TextR1[textPointer++] = '?'; + TextR1[textPointer++] = 0; } else { textPointer = snprintf(TextR1, TEXTSIZE, "\a\001 %c%c %01.2f/", TXT_2BYTE, TXT2BYTE_LoopShort, stateUsed->diveSettings.setpoint[actualBetterSetpointId()].setpoint_cbar / 100.0); textPointer += tHome_gas_writer(stateUsed->diveSettings.gas[stateUsed->lifeData.lastDiluent_GasIdInSettings].oxygen_percentage, stateUsed->diveSettings.gas[stateUsed->lifeData.lastDiluent_GasIdInSettings].helium_percentage, &TextR1[textPointer]); + TextR1[textPointer++] = '?'; TextR1[textPointer++] = ' '; - TextR1[textPointer++] = '?'; + TextR1[textPointer++] = 0; } GFX_write_string_color(&FontT48, &t7c2, TextR1, 0, CLUT_WarningYellow); @@ -3061,7 +3089,7 @@ } else { - t7_colorscheme_mod(TextC2); + Gfx_colorsscheme_mod(TextC2, 0); GFX_write_string(&FontT48,&t7c2,TextC2,0); // T54 has only numbers } @@ -3078,7 +3106,7 @@ } else { - t7_colorscheme_mod(TextC2); + Gfx_colorsscheme_mod(TextC2, 0); GFX_write_string(&FontT48,&t7c2,TextC2,0); } } @@ -3086,7 +3114,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 +3201,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 } } @@ -3197,7 +3225,10 @@ if(customview_warnings && warning_count_high_time) t7_show_customview_warnings(); else + { t7_refresh_customview(); + requestBuzzerActivation(0); + } /* the frame */ draw_frame(1,1, CLUT_DIVE_pluginbox, CLUT_DIVE_FieldSeperatorLines); @@ -3227,6 +3258,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; @@ -3357,7 +3396,7 @@ tinyHeaderFont = 1; headerText[2] = TXT_ScrubTime; - printScrubberText(text, TEXTSIZE, pSettings); + printScrubberText(text, TEXTSIZE, stateUsed->scrubberDataDive, pSettings); break; #ifdef ENABLE_PSCR_MODE @@ -3483,7 +3522,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 +3645,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; @@ -3980,6 +4010,12 @@ t7cY0free.WindowY0 = t7cH.WindowY0 - 5 - 2 * t7cY0free.WindowLineSpacing; t7cY0free.WindowNumberOfTextLines = 3; +#ifdef T7_DEBUG_RUNTIME + textpointer += snprintf(&text[textpointer],50,"Main loop %ld\n\r",getMainLoopTime()); + textpointer += snprintf(&text[textpointer],50,"Grafic loop %ld\n\r",getGfxLoopTime()); + textpointer += snprintf(&text[textpointer],50,"Decoloop %ld\n\r",getDecoLoopTime()); + GFX_write_string(&FontT24, &t7cY0free, text, 1); +#else textpointer += snprintf(&text[textpointer],50,"Ambient [bar]\n\r"); textpointer += snprintf(&text[textpointer],50,"Surface [bar] + salt\n\r"); // textpointer += snprintf(&text[textpointer],50,"Difference [mbar]\n\r"); @@ -3997,9 +4033,110 @@ ,settingsGetPointer()->salinity ,stateUsed->lifeData.counterSecondsShallowDepth); GFX_write_string(&FontT42, &t7cY0free, text, 1); +#endif } - +void t7_showPosition(void) +{ + char text[256+50]; + uint8_t textpointer = 0; + point_t start, stop; + uint8_t index = 0; + uint8_t color = 0; + SSettings* pSettings = settingsGetPointer(); + + t7cY0free.WindowLineSpacing = 28 + 48 + 14; + t7cY0free.WindowY0 = t7cH.WindowY0 - 5 - 2 * t7cY0free.WindowLineSpacing; + t7cY0free.WindowNumberOfTextLines = 3; + t7cY0free.WindowY0 -= 20; + + t7cY0free.WindowX0 = CUSTOMBOX_LINE_LEFT + CUSTOMBOX_INSIDE_OFFSET; + t7cY0free.WindowX1 = CUSTOMBOX_LINE_RIGHT - CUSTOMBOX_INSIDE_OFFSET; + + if(pSettings->FlipDisplay) + { + t7cY0free.WindowY0 = t7cH.WindowY0 + 15; + t7cY0free.WindowY1 = t7cY0free.WindowY0 + 250; + } + + if(stateUsed->lifeData.gnssData.fixType < 2) + { + textpointer += snprintf(&text[textpointer],50,"\001Satellites\n\r"); + if(stateUsed->lifeData.gnssData.alive & GNSS_ALIVE_STATE_ALIVE) + { + textpointer += snprintf(&text[textpointer],50,"\001\020Status\n\r"); + } + else + { + textpointer += snprintf(&text[textpointer],50,"\001\021Status\n\r"); + } + } + else + { + textpointer += snprintf(&text[textpointer],50,"\001Longitude\n\r"); + textpointer += snprintf(&text[textpointer],50,"\001Latitude\n\r"); + } + GFX_write_string(&FontT24, &t7cY0free, text, 1); + + if(!pSettings->FlipDisplay) + { + t7cY0free.WindowY0 -= 52; + } + else + { + t7cY0free.WindowY1 = 370; + } + + if(stateUsed->lifeData.gnssData.fixType < 2) + { + snprintf(text,60,"\001%d\n\r",stateUsed->lifeData.gnssData.numSat); + } + else + { + snprintf(text,60, + "\001%0.5f\n\r" + "\001%0.5f\n\r" + ,stateUsed->lifeData.gnssData.coord.fLat ,stateUsed->lifeData.gnssData.coord.fLon); + } + GFX_write_string(&FontT42, &t7cY0free, text, 1); + + if(stateUsed->lifeData.gnssData.fixType < 2) /* draw status bars */ + { + if(!pSettings->FlipDisplay) + { + start.x = t7cY0free.WindowX0 + 85; + stop.x = start.x; + start.y = t7cY0free.WindowY0 + 75; + stop.y = start.y + 20; + } + else + { + start.x = t7cY0free.WindowX0 - 50; + stop.x = start.x; + start.y = t7cY0free.WindowY0 - 75; + stop.y = start.y - 20; + } + + while((index < stateUsed->lifeData.gnssData.numSat) && (index < 4)) + { + if(stateUsed->lifeData.gnssData.signalQual[index] > 4) color = CLUT_NiceGreen; + if((stateUsed->lifeData.gnssData.signalQual[index] > 2) && (stateUsed->lifeData.gnssData.signalQual[index] <= 4)) color = CLUT_WarningYellow; + if(stateUsed->lifeData.gnssData.signalQual[index] <= 2) color = CLUT_WarningRed; + GFX_draw_thick_line(20, &t7screen, start, stop, color); + start.x += 40; + stop.x += 40; + + index++; + } + if(stateUsed->lifeData.gnssData.alive & GNSS_ALIVE_BACKUP_POS) + { + snprintf(text,50,"\001%2.2f %2.2f", stateUsed->lifeData.gnssData.coord.fLat,stateUsed->lifeData.gnssData.coord.fLon); + GFX_write_string(&FontT24, &t7cY0free, text, 3); + } + } + + +} void t7_SummaryOfLeftCorner(void) { char text[256+60]; @@ -4110,10 +4247,10 @@ text[textpointer++] = '\r'; text[textpointer++] = '\t'; - textpointer += printScrubberText(&text[textpointer], 10, pSettings); + textpointer += printScrubberText(&text[textpointer], 10, stateUsed->scrubberDataDive, pSettings); } text[textpointer++] = 0; - t7_colorscheme_mod(text); + Gfx_colorsscheme_mod(text, 0); GFX_write_string(&FontT42, &t7cY0free, text, 1); } @@ -4495,6 +4632,10 @@ { level = 10; } + if(curIndex > 1) + { + level = (level + ChargerLog[curIndex - 1]) / 2; /* smooth small jumps */ + } if(curIndex < 59) { ChargerLog[curIndex++] = level; @@ -4504,7 +4645,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 +4702,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"); @@ -4605,7 +4744,7 @@ } else { - t7cY0free.WindowY1 += 52; + t7cY0free.WindowY1 += 52; } if((stateUsed->lifeData.battery_charge > 0) && (stateUsed->chargeStatus != CHARGER_off)) @@ -4664,6 +4803,126 @@ return selection_customview == CVIEW_Compass || selection_custom_field == LLC_Compass; } +void t7_drawAcentGraph(uint8_t color) +{ + point_t start, stop; + + SSettings* pSettings; + pSettings = settingsGetPointer(); + + + if(!pSettings->FlipDisplay) + { + start.y = t7l1.WindowY0 - 1; + } + else + { + start.y = t7l3.WindowY0 - 25; + } + + for(int i = 0; i<4;i++) + { + start.y += 5*6; + stop.y = start.y; + start.x = CUSTOMBOX_LINE_LEFT - 1; + stop.x = start.x - 17; + GFX_draw_line(&t7screen, start, stop, 0); +// start.x = CUSTOMBOX_LINE_RIGHT + 2; old right too +// stop.x = start.x + 17; +// GFX_draw_line(&t7screen, start, stop, 0); + } + // new thick bar design Sept. 2015 + start.x = CUSTOMBOX_LINE_LEFT - CUSTOMBOX_OUTSIDE_OFFSET - 3 - 5; + stop.x = start.x; + if(!pSettings->FlipDisplay) + { + start.y = t7l1.WindowY0 - 1; + } + else + { + start.y = t7l3.WindowY0 - 25; + } + stop.y = start.y + (uint16_t)(stateUsed->lifeData.ascent_rate_meter_per_min * 6); + stop.y -= 3; // wegen der Liniendicke von 12 anstelle von 9 + if(stop.y >= 470) + stop.y = 470; + start.y += 7; // starte etwas weiter oben + if(color == 0) + { + color = CLUT_EverythingOkayGreen; /* do not use white color for drawing graph */ + } + + GFX_draw_thick_line(12,&t7screen, start, stop, color); +} + +#define ASCENT_GRAPH_YPIXEL 110 + + +uint8_t t7_drawSlowExitGraph() /* this function is only called if diver is below last last stop depth */ +{ + static uint16_t countDownSec = 0; + uint8_t drawingMeterStep; + static float exitDepthMeter = 0.0; + + uint8_t index = 0; + uint8_t color = 0; + point_t start, stop; + + SSettings* pSettings; + pSettings = settingsGetPointer(); + + + if(calculateSlowExit(&countDownSec, &exitDepthMeter, &color)) /* graph to be drawn? */ + { + if(!pSettings->FlipDisplay) + { + start.y = t7l1.WindowY0 - 1; + } + else + { + start.y = t7l3.WindowY0 - 25; + } + drawingMeterStep = ASCENT_GRAPH_YPIXEL / pSettings->last_stop_depth_meter; /* based on 120 / 4 = 30 of standard ascent graph */ + for(index = 0; index < pSettings->last_stop_depth_meter; index++) /* draw meter indicators */ + { + start.y += drawingMeterStep; + stop.y = start.y; + start.x = CUSTOMBOX_LINE_LEFT - 1; + stop.x = start.x - 38; + GFX_draw_line(&t7screen, start, stop, 0); + } + + start.x = CUSTOMBOX_LINE_LEFT - CUSTOMBOX_OUTSIDE_OFFSET - 20; + stop.x = start.x; + if(!pSettings->FlipDisplay) + { + start.y = t7l1.WindowY0 + ASCENT_GRAPH_YPIXEL + 5; + } + else + { + start.y = t7l3.WindowY0 - 25 + ASCENT_GRAPH_YPIXEL + 5; + } + stop.y = start.y - countDownSec * (ASCENT_GRAPH_YPIXEL / (float)(pSettings->slowExitTime * 60.0)); + if(stop.y >= 470) stop.y = 470; + if(!pSettings->FlipDisplay) + { + stop.y += 5; + } + GFX_draw_thick_line(15,&t7screen, start, stop, 3); + /* mark diver depth */ + start.x = CUSTOMBOX_LINE_LEFT - CUSTOMBOX_OUTSIDE_OFFSET - 30; + stop.x = start.x + 24; + + start.y = start.y - (stateUsed->lifeData.depth_meter * (ASCENT_GRAPH_YPIXEL) / pSettings->last_stop_depth_meter); + stop.y = start.y; + GFX_draw_thick_line(10,&t7screen, start, stop, 9); + } + else + { + color = 0xff; + } + return color; +} void t7_tick(void) { diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tCCR.c --- a/Discovery/Src/tCCR.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tCCR.c Tue Feb 11 18:12:00 2025 +0100 @@ -337,19 +337,22 @@ } } - /* decrease scrubber timer only in real dive mode, and if we are not bailed out */ - if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (isLoopMode(pSettings->dive_mode)) && (stateUsed->mode == MODE_DIVE) && isLoopMode(stateUsed->diveSettings.diveMode)) // && (stateUsed == stateRealGetPointer())) - { - ScrubberTimeoutCount++; - if(ScrubberTimeoutCount >= 600) /* resolution is minutes */ - { - ScrubberTimeoutCount = 0; - if(pSettings->scrubberData[pSettings->scubberActiveId].TimerCur > MIN_SCRUBBER_TIME) - { - pSettings->scrubberData[pSettings->scubberActiveId].TimerCur--; - } - translateDate(stateUsed->lifeData.dateBinaryFormat, &pSettings->scrubberData[pSettings->scubberActiveId].lastDive); - } + // If we are in the simulator the counter is updated in `simulator.c` + if (!is_stateUsedSetToSim()) { + /* decrease scrubber timer only if we are not bailed out */ + if((pSettings->scrubTimerMode != SCRUB_TIMER_OFF) && (isLoopMode(pSettings->dive_mode)) && (stateUsed->mode == MODE_DIVE) && isLoopMode(stateUsed->diveSettings.diveMode)) + { + ScrubberTimeoutCount++; + if(ScrubberTimeoutCount >= 600) /* resolution is minutes */ + { + ScrubberTimeoutCount = 0; + if(stateUsed->scrubberDataDive[pSettings->scubberActiveId].TimerCur > MIN_SCRUBBER_TIME) + { + stateUsedWrite->scrubberDataDive[pSettings->scubberActiveId].TimerCur--; + } + translateDate(stateUsed->lifeData.dateBinaryFormat, &stateUsedWrite->scrubberDataDive[pSettings->scubberActiveId].lastDive); + } + } } } diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tComm.c --- a/Discovery/Src/tComm.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tComm.c Tue Feb 11 18:12:00 2025 +0100 @@ -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); @@ -136,6 +139,7 @@ static uint8_t openComm(uint8_t aRxByte); uint8_t HW_Set_Bluetooth_Name(uint16_t serial, uint8_t withEscapeSequence); uint8_t prompt4D4C(uint8_t mode); +uint8_t tComm_GetBTCmdStr(BTCmd cmdId, char* pCmdStr); #ifdef BOOTLOADER_STANDALONE static uint8_t receive_update_data_cpu2(void); @@ -367,6 +371,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; } @@ -375,13 +386,16 @@ { uint8_t answer = HAL_OK; uint8_t aRxBuffer[50]; + char aTxBufferName[50]; // char aTxFactoryDefaults[50] = "AT&F1\r"; - char aTxBufferEscapeSequence[50] = "+++"; + char aTxBufferEscapeSequence[50] = "+++"; /* factory default */ // limit is 19 chars, with 7 chars shown in BLE advertising mode //________________________123456789012345678901 - char aTxBufferName[50] = "AT+BNAME=OSTC4-12345\r"; + + tComm_GetBTCmdStr(BT_CMD_NAME, aTxBufferName); + char answerOkay[6] = "\r\nOK\r\n"; gfx_number_to_string(5,1,&aTxBufferName[15],serial); @@ -436,17 +450,18 @@ answer = HAL_OK; return answer; } - +#ifndef BOOTLOADER_STANDALONE void tComm_Disconnect() { uint8_t answer; uint8_t retrycnt = 3; char aTxDisconnect[] ="ATH\r"; - char aTxBufferEnd[] = "ATO\r"; + char aTxBufferEnd[10]; char aTxBufferEscapeSequence[] = "+++"; uint8_t sizeDisconnect = sizeof(aTxDisconnect) -1; + tComm_GetBTCmdStr(BT_CMD_EXIT_CMD, aTxBufferEnd); HAL_UART_AbortReceive_IT(&UartHandle); do { @@ -482,7 +497,7 @@ MX_Bluetooth_PowerOff(); } } - +#endif uint8_t openComm(uint8_t aRxByte) { @@ -586,6 +601,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 +610,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 +1466,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) { @@ -2028,9 +2043,11 @@ { do { - answer = HAL_UART_Receive(&UartHandle, (uint8_t*)&aRxBuffer[indexBuf], 1, 10); + answer = HAL_ERROR; if (indexBuf < UART_CMD_BUF_SIZE) { + answer = HAL_UART_Receive(&UartHandle, (uint8_t*)&aRxBuffer[indexBuf], 1, 10); + if(answerOkay[indexRef] == aRxBuffer[indexBuf]) { indexRef++; @@ -2044,7 +2061,7 @@ } indexBuf++; } - }while(answer == HAL_OK); + }while((answer == HAL_OK) && (indexRef != sizeAnswer)); if(indexRef != sizeAnswer) { result = HAL_ERROR; @@ -2138,6 +2155,94 @@ } } +#ifdef BOOTLOADER_STANDALONE +void tComm_StartBlueModBaseInit() +{ + BmTmpConfig = BM_INIT_TRIGGER_ON; +} +#endif + + +uint8_t tComm_GetBTCmdStr(BTCmd cmdId, char* pCmdStr) +{ + uint8_t ret = 0; + uint8_t oldModule = 1; + + if(isNewDisplay()) + { + oldModule = 0; + } + + switch (cmdId) + { + case BT_CMD_ECHO: sprintf(pCmdStr,"ATE0\r"); + ret = 1; + break; + case BT_CMD_SILENCE: if(oldModule) + { + strcpy(pCmdStr,"ATS30=0\r"); + ret = 1; + } + break; + case BT_CMD_ESCAPE_DELAY: if(oldModule) + { + strcpy(pCmdStr,"ATS12=10\r"); + ret = 1; + } + break; + case BT_CMD_SIGNAL_POLL: if(oldModule) + { + strcpy(pCmdStr,"AT+BSTPOLL=100\r"); + ret = 1; + } + break; + case BT_CMD_BAUDRATE_115: if(oldModule) + { + strcpy(pCmdStr,"AT%B8\r"); + } + else + { + strcpy(pCmdStr,"AT+UMRS=115200,1,8,1,1,1\r"); + } + ret = 1; + break; + + case BT_CMD_BAUDRATE_460: if(oldModule) + { + strcpy(pCmdStr,"AT%B22\r"); + } + else + { + strcpy(pCmdStr,"AT+UMRS=460800,1,8,1,1,1\r"); + } + ret = 1; + break; + case BT_CMD_NAME: if(oldModule) + { + strcpy(pCmdStr,"AT+BNAME=OSTC4-12345\r"); + } + else + { + strcpy(pCmdStr,"AT+UBTLN=OSTC5-12345\r"); + } + ret = 1; + break; + case BT_CMD_EXIT_CMD: if(oldModule) + { + strcpy(pCmdStr,"ATO\r"); + } + else + { + strcpy(pCmdStr,"ATO1\r"); + } + ret = 1; + break; + default: + break; + } + return ret; +} + void tComm_StartBlueModConfig() { uint8_t answer = HAL_OK; @@ -2162,19 +2267,24 @@ uint8_t result = HAL_OK; - TxBuffer[0] = 0; + memset(TxBuffer, 0, sizeof(TxBuffer)); switch (BmTmpConfig) { - case BM_CONFIG_ECHO: sprintf(TxBuffer,"ATE0\r"); + case BM_CONFIG_ECHO: tComm_GetBTCmdStr (BT_CMD_ECHO, TxBuffer); break; - case BM_CONFIG_SILENCE: sprintf(TxBuffer,"ATS30=0\r"); + case BM_CONFIG_SILENCE: tComm_GetBTCmdStr (BT_CMD_SILENCE, TxBuffer); + break; + case BM_CONFIG_ESCAPE_DELAY: tComm_GetBTCmdStr (BT_CMD_ESCAPE_DELAY, TxBuffer); break; - case BM_CONFIG_ESCAPE_DELAY: sprintf(TxBuffer,"ATS12=10\r"); + case BM_CONFIG_SIGNAL_POLL: tComm_GetBTCmdStr(BT_CMD_SIGNAL_POLL, TxBuffer); break; - case BM_CONFIG_SIGNAL_POLL: sprintf(TxBuffer,"AT+BSTPOLL=100\r"); - break; - case BM_CONFIG_BAUD: sprintf(TxBuffer,"AT%%B22\r"); + case BM_CONFIG_BAUD: +#ifdef ENABLE_FAST_COMM + tComm_GetBTCmdStr(BT_CMD_BAUDRATE_460, TxBuffer); +#else + BmTmpConfig = BM_CONFIG_DONE; +#endif break; case BM_CONFIG_RETRY: ConfigRetryCnt--; HAL_Delay(1); @@ -2189,6 +2299,45 @@ ConfigRetryCnt = 0; RestartModule = 1; break; +#ifdef BOOTLOADER_STANDALONE /* the procedure below is just needed for the initial bluetooth module initialization */ + 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_ECHO: sprintf(TxBuffer,"ATE0\r"); + 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=OSTC5-12345\r"); /* Bluetooth name */ + if(hardwareDataGetPointer()->primarySerial != 0xFFFF) /* module reinit? => restore old name */ + { + gfx_number_to_string(5,1,&TxBuffer[15],hardwareDataGetPointer()->primarySerial); + } + 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; } @@ -2206,9 +2355,10 @@ UartHandle.Init.BaudRate = 460800; HAL_UART_Init(&UartHandle); } - if((BmTmpConfig == BM_CONFIG_BAUD) && (result == HAL_OK) && (UartHandle.Init.BaudRate == 460800)) /* This shut not happen because default speed is 115200 => update module configuration */ + else if((BmTmpConfig == BM_CONFIG_BAUD) && (result == HAL_OK) && (UartHandle.Init.BaudRate == 460800)) /* This shut not happen because default speed is 115200 => update module configuration */ { - sprintf(TxBuffer,"AT%%B8\r"); /* set default baudrate */ + tComm_GetBTCmdStr(BT_CMD_BAUDRATE_115, TxBuffer); + CmdSize = strlen(TxBuffer); HAL_UART_Transmit(&UartHandle, (uint8_t*)TxBuffer,CmdSize, 2000); HAL_UART_DeInit(&UartHandle); @@ -2222,14 +2372,26 @@ if(result == HAL_OK) { BmTmpConfig++; + if(BmTmpConfig == BM_CONFIG_RETRY) + { + BmTmpConfig = BM_CONFIG_DONE; + } } - if(BmTmpConfig == BM_CONFIG_DONE) + if(BmTmpConfig == BM_CONFIG_ECHO) { + BmTmpConfig = BM_CONFIG_DONE; ConfigRetryCnt = 0; RestartModule = 1; } } } + else /* no command for the configuration step found => skip step */ + { + if((BmTmpConfig > BM_CONFIG_OFF) && (BmTmpConfig < BM_CONFIG_DONE)) + { + BmTmpConfig++; + } + } if(result != HAL_OK) { ConfigRetryCnt++; @@ -2241,7 +2403,7 @@ RestartModule = 0; /* only one try */ ConfigRetryCnt = 200; /* used for delay to startup module again */ - if(BmTmpConfig == BM_CONFIG_ECHO) /* the module did not answer even once => try again with alternative baud rate */ + if((BmTmpConfig == BM_CONFIG_ECHO) || (BmTmpConfig == BM_INIT_ECHO)) /* the module did not answer even once => try again with alternative baud rate */ { HAL_UART_DeInit(&UartHandle); HAL_Delay(1); diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tHome.c --- a/Discovery/Src/tHome.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tHome.c Tue Feb 11 18:12:00 2025 +0100 @@ -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()) diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tInfo.c --- a/Discovery/Src/tInfo.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tInfo.c Tue Feb 11 18:12:00 2025 +0100 @@ -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); + } +} diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tInfoPreDive.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Discovery/Src/tInfoPreDive.c Tue Feb 11 18:12:00 2025 +0100 @@ -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 . +////////////////////////////////////////////////////////////////////////////// + +/* 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 +#include + +#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; + } +} + diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tInfoSensor.c --- a/Discovery/Src/tInfoSensor.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tInfoSensor.c Tue Feb 11 18:12:00 2025 +0100 @@ -34,6 +34,7 @@ #include "tInfo.h" #include "tInfoSensor.h" #include "tMenuEdit.h" +#include "data_exchange_main.h" #include #include @@ -60,12 +61,12 @@ case 0: setBackMenu((uint32_t)openEdit_O2Sensors,0,1); break; } - sensorActive = 1; if(pSettings->ppo2sensors_deactivated & (1 << (activeSensorId))) { sensorActive = 0; } + DataEX_setExtInterface_Cmd(EXT_INTERFACE_O2_INDICATE, activeSensorId); } @@ -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, activeSensorId); + } + break; case ACTION_TIMEOUT: case ACTION_MODE_CHANGE: case ACTION_IDLE_TICK: diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenu.c --- a/Discovery/Src/tMenu.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenu.c Tue Feb 11 18:12:00 2025 +0100 @@ -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); @@ -854,6 +864,8 @@ if((page == 0) || (line == 0)) return; + requestBuzzerActivation(0); + menu.pageMemoryForNavigation = page; /* new test for 3button design */ if(freshWithFlipPages) @@ -931,6 +943,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 +974,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)); diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuCustom.c --- a/Discovery/Src/tMenuCustom.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuCustom.c Tue Feb 11 18:12:00 2025 +0100 @@ -118,6 +118,26 @@ strcpy(&text[textPointer],"\n\r"); textPointer += 2; #endif + +#ifdef ENABLE_GPIO_V2 + if((line == 0) || (line == 5)) + { + /* MotionCtrl */ + text[textPointer++] = TXT_2BYTE; + text[textPointer++] = TXT2BYTE_BUZZER; + text[textPointer++] = ' '; + text[textPointer++] = TXT_Warning; + text[textPointer++] = '\t'; + if(settingsGetPointer()->warningBuzzer) + text[textPointer++] = '\005'; + else + text[textPointer++] = '\006'; + } + + strcpy(&text[textPointer],"\n\r"); + textPointer += 2; +#endif + return StMCustom; } diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuDeco.c --- a/Discovery/Src/tMenuDeco.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuDeco.c Tue Feb 11 18:12:00 2025 +0100 @@ -134,6 +134,33 @@ if((line == 0) || (line == 4)) { + if(settingsGetPointer()->slowExitTime != 0) + { + textPointer += snprintf(&text[textPointer], 60,\ + "%c%c\t%u\016\016 %c\017 ^ %u\016\016 %c%c\017" + , TXT_2BYTE + , TXT2BYTE_SlowExit + , settingsGetPointer()->slowExitTime + ,TXT_Minutes + , unit_depth_integer(settingsGetPointer()->last_stop_depth_meter) + , unit_depth_char1() + , unit_depth_char2() + ); + } + else + { + textPointer += snprintf(&text[textPointer], 60, "%c%c\t%c%c" + , TXT_2BYTE + , TXT2BYTE_SlowExit + , TXT_2BYTE + , TXT2BYTE_MoCtrlNone + ); + } + } + strcpy(&text[textPointer],"\n\r"); + textPointer += 2; + if((line == 0) || (line == 5)) + { textPointer += snprintf(&text[textPointer], 60,\ "%c" "\t" @@ -149,7 +176,7 @@ strcpy(&text[textPointer],"\n\r"); textPointer += 2; - if((line == 0) || (line == 5)) + if((line == 0) || (line == 6)) { textPointer += snprintf(&text[textPointer], 60,\ "%c" diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuDecoParameter.c --- a/Discovery/Src/tMenuDecoParameter.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuDecoParameter.c Tue Feb 11 18:12:00 2025 +0100 @@ -147,7 +147,7 @@ textPointer += snprintf(&text[textPointer], 60,\ "%c" - "\t" + "\t " "%c" , TXT_DecoAlgorithm , decotypeTxtId @@ -160,7 +160,7 @@ { textPointer += snprintf(&text[textPointer], 60,\ "VPM" - "\t" + "\t " "+" "%u" , VpmConsveratism @@ -176,7 +176,7 @@ "\016\016" "low/high" "\017" - "\t" + "\t " "%u" "/" "%u" @@ -193,7 +193,7 @@ "\016\016" "low/high" "\017" - "\t" + "\t " "%u" "/" "%u" @@ -207,7 +207,7 @@ { textPointer += snprintf(&text[textPointer], 60,\ "%c" - "\t" + "\t " "%u" "\016\016" " %c%c" @@ -220,6 +220,17 @@ } strcpy(&text[textPointer],"\n\r"); textPointer += 2; + if((line == 0) || (line == 6)) + { + textPointer+= snprintf(&text[textPointer], 60, "%c%c\t ",TXT_2BYTE,TXT2BYTE_VpmTable); + if(settingsGetPointer()->VPM_conservatism.ub.alternative) + text[textPointer++] = '\005'; + else + text[textPointer++] = '\006'; + text[textPointer] = 0; + } + strcpy(&text[textPointer],"\n\r"); + textPointer += 2; return StMDECOP; } diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuEdit.c --- a/Discovery/Src/tMenuEdit.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuEdit.c Tue Feb 11 18:12:00 2025 +0100 @@ -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; @@ -237,6 +242,8 @@ case (StMHARD5_Button1 & MaskFieldDigit): // will not be executed in EditFieldMode as global state is different refreshFct = refresh_ButtonValuesFromPIC; break; + case StMSYS1_DateTime: refreshFct = refresh_DateTime; + break; case (StMSYS3_Units & MaskFieldDigit): refreshFct = refresh_Design; break; case (StMCustom1_CViewTimeout & MaskFieldDigit):refreshFct = refresh_Customviews; @@ -249,10 +256,12 @@ case StMCustom3_CViewSelection5: case StMCustom3_CViewSelection6: refreshFct = CustomviewDivemode_refresh; break; +#ifdef ENABLE_MOTION_CONTROL case (StMCustom5_CViewPortCalib & MaskFieldDigit): case StMCustom5_CViewPortLayout: case StMCustom5_CViewPortAmbient: refreshFct = refresh_ViewPort; break; +#endif default: /* no menu has been updated */ break; } @@ -394,20 +403,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 +433,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 +458,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 +492,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 +510,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 +529,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 +549,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 +569,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 +632,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 +649,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 +659,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 +681,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 +702,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 +753,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 +796,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 +826,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 +870,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 +882,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 +922,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 +957,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 +969,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 +1024,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 +1052,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 +1077,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 +1090,8 @@ if(id_local <= idLast) { - id = id_local; - set_cursorNew(id); + actualId = id_local; + set_cursorNew(id_local); } } @@ -1140,10 +1149,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 +1194,7 @@ } } else - if(get_globalState() == event[evid].callerID) + if(get_globalState() == event[actualevid].callerID) { switch(sendAction) { @@ -1233,70 +1242,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,17 +1324,33 @@ } +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); } +uint8_t togglePlusMinus(uint8_t input) +{ + if (input == '+') { + return '-'; + } else { + return '+'; + } +} 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) { @@ -1375,13 +1409,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 +1492,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 +1530,7 @@ write_content_without_Id(); else { - write_content_of_actual_Id(); + write_content_of_Id(id); if(!tME_stop) idLast = id; id++; @@ -1534,7 +1568,7 @@ write_content_without_Id(); else { - write_content_of_actual_Id(); + write_content_of_Id(id); if(!tME_stop) idLast = id; id++; @@ -1560,7 +1594,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 +1653,7 @@ write_content_without_Id(); else { - write_content_of_actual_Id(); + write_content_of_Id(id); if(!tME_stop) idLast = id; id++; @@ -1652,7 +1686,7 @@ write_content_without_Id(); else { - write_content_of_actual_Id(); + write_content_of_Id(id); if(!tME_stop) idLast = id; id++; @@ -1673,12 +1707,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; diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuEditCustom.c --- a/Discovery/Src/tMenuEditCustom.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuEditCustom.c Tue Feb 11 18:12:00 2025 +0100 @@ -56,13 +56,16 @@ void openEdit_BigScreen(void); void openEdit_MotionCtrl(void); void openEdit_ViewPort(void); +void openEdit_WarningBuz(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 +118,15 @@ 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; @@ -363,8 +375,14 @@ break; case 4: openEdit_CustomviewDivemode(cv_changelist_BS); break; +#ifdef ENABLE_MOTION_CONTROL case 5: openEdit_ViewPort(); break; +#endif +#ifdef ENABLE_GPIO_V2 + case 5: openEdit_WarningBuz(); + break; +#endif } } @@ -377,14 +395,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); } @@ -438,6 +456,7 @@ void openEdit_ViewPort(void) { +#ifdef ENABLE_MOTION_CONTROL resetMenuEdit(CLUT_MenuPageCustomView); refresh_ViewPort(); @@ -452,8 +471,22 @@ setEvent(StMCustom5_CViewPortLayout, (uint32_t)OnAction_CViewPortLayout); setEvent(StMCustom5_CViewPortAmbient, (uint32_t)OnAction_CViewPortAmbient); setEvent(StMCustom5_CViewPortControl, (uint32_t)OnAction_CViewPortControl); +#endif } +void openEdit_WarningBuz(void) +{ + SSettings *pSettings = settingsGetPointer(); + if(pSettings->warningBuzzer == 0) + { + pSettings->warningBuzzer = 1; + } + else + { + pSettings->warningBuzzer = 0; + } + exitMenuEdit_to_Menu_with_Menu_Update_do_not_write_settings_for_this_only(); +} char customview_TXT2BYTE_helper(uint8_t customViewId) { @@ -491,6 +524,9 @@ case CVIEW_Timer: text = TXT2BYTE_Timer; break; + case CVIEW_Position: + text = TXT2BYTE_Position; + break; case CVIEW_noneOrDebug: text = TXT2BYTE_DispNoneDbg; break; @@ -522,6 +558,9 @@ text = TXT2BYTE_Profile; break; #endif + case CVIEW_T3_Temperature: + text = TXT2BYTE_AmbientTemperature; + break; case CVIEW_T3_GasList: text = TXT2BYTE_Gaslist; break; @@ -646,6 +685,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 +786,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 +890,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 +941,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 +998,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 +1074,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 +1094,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; } diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuEditDeco.c --- a/Discovery/Src/tMenuEditDeco.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuEditDeco.c Tue Feb 11 18:12:00 2025 +0100 @@ -42,6 +42,7 @@ static void openEdit_DiveMode(void); static void openEdit_ppO2max(void); static void openEdit_SafetyStop(void); +static void openEdit_ExitTime(void); static void openEdit_FutureTTS(void); static void openEdit_Salinity(void); @@ -50,6 +51,7 @@ static uint8_t OnAction_FutureTTS (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); static uint8_t OnAction_ppO2Max (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); static uint8_t OnAction_SafetyStop (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +static uint8_t OnAction_SlowExitTime (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); static uint8_t OnAction_Salinity (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); /* Exported functions --------------------------------------------------------*/ @@ -73,9 +75,12 @@ openEdit_SafetyStop(); break; case 4: + openEdit_ExitTime(); + break; + case 5: openEdit_FutureTTS(); break; - case 5: + case 6: openEdit_Salinity(); break; } @@ -259,6 +264,44 @@ } +static void openEdit_ExitTime(void) +{ + uint32_t SlowExitTime; + char text[64]; + uint16_t y_line; + + SlowExitTime = settingsGetPointer()->slowExitTime; + + y_line = ME_Y_LINE_BASE + (lineSelected * ME_Y_LINE_STEP); + + text[0] = '\001'; + text[1] = TXT_2BYTE; + text[2] = TXT2BYTE_SlowExit; + text[3] = 0; + write_topline(text); + + write_label_var( 20, 800, y_line, &FontT48, &text[1]); + + strcpy(text,"\016\016"); + text[2] = TXT_Minutes; + if(settingsGetPointer()->nonMetricalSystem) + { + sprintf(&text[3], "\017 ^ %u\016\016 ft\017", unit_depth_integer(settingsGetPointer()->last_stop_depth_meter)); + } + else + { + sprintf(&text[3], "\017 ^ %u\016\016 m\017", settingsGetPointer()->last_stop_depth_meter); + } + write_label_var( 410, 800, y_line, &FontT48, text); + + write_field_udigit(StMDECO_SlowExit, 370, 800, y_line, &FontT48, "#", SlowExitTime, 0, 0, 0); + write_buttonTextline(TXT2BYTE_ButtonMinus,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonPlus); + + setEvent(StMDECO_SlowExit, (uint32_t)OnAction_SlowExitTime); + startEdit(); +} + + static uint8_t OnAction_SafetyStop (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { uint8_t digitContentNew; @@ -346,6 +389,48 @@ return EXIT_TO_MENU; } +static uint8_t OnAction_SlowExitTime (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + uint8_t digitContentNew; + uint32_t newExitTime; + + if(action == ACTION_BUTTON_ENTER) + { + return digitContent; + } + if(action == ACTION_BUTTON_ENTER_FINAL) + { + evaluateNewString(editId, &newExitTime, 0, 0, 0); + + settingsGetPointer()->slowExitTime = newExitTime; + + tMenuEdit_newInput(editId, newExitTime, 0, 0, 0); + return UPDATE_AND_EXIT_TO_MENU; + } + if(action == ACTION_BUTTON_NEXT) + { + digitContentNew = digitContent + 1; + if(blockNumber == 0) + { + if(digitContentNew > '9') + digitContentNew = '0'; + } + + return digitContentNew; + } + if(action == ACTION_BUTTON_BACK) + { + digitContentNew = digitContent - 1; + if(blockNumber == 0) + { + if(digitContentNew < '0') + digitContentNew = '9'; + } + + return digitContentNew; + } + return EXIT_TO_MENU; +} static void openEdit_Salinity(void) { diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuEditDecoParameter.c --- a/Discovery/Src/tMenuEditDecoParameter.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuEditDecoParameter.c Tue Feb 11 18:12:00 2025 +0100 @@ -33,7 +33,7 @@ #include "tMenuEdit.h" #include "unit.h" // last stop in meter and feet -#define MEDP_TAB (380) +#define MEDP_TAB (525) /* Private function prototypes -----------------------------------------------*/ static void openEdit_DecoAlgorithm(void); @@ -41,6 +41,7 @@ static void openEdit_DecoAltGF(void); static void openEdit_DecoVPM(void); static void openEdit_DecoLastStop(void); +static void openEdit_DecoVpmTable(void); static void openEdit_DM_SwitchAlgorithm(uint8_t line); //void openEdit_DecoGasUsage(void); @@ -81,6 +82,7 @@ openEdit_DecoLastStop(); break; case 6: + openEdit_DecoVpmTable(); break; } } @@ -231,6 +233,21 @@ startEdit(); } +static void openEdit_DecoVpmTable(void) +{ + SSettings *pSettings = settingsGetPointer(); + + if(pSettings->VPM_conservatism.ub.alternative == 0) + { + pSettings->VPM_conservatism.ub.alternative = 1; + } + else + { + pSettings->VPM_conservatism.ub.alternative = 0; + } + exitEditWithUpdate(); +} + uint8_t OnAction_VPM(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { SSettings *pSettings; diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuEditGasOC.c --- a/Discovery/Src/tMenuEditGasOC.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuEditGasOC.c Tue Feb 11 18:12:00 2025 +0100 @@ -66,6 +66,9 @@ 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); +#ifdef ENABLE_DECOCALC_OPTION +uint8_t OnAction_CalcDeco (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +#endif 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 +207,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 +385,11 @@ /* 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 ;//, bottleSizeLiter; + +#ifdef ENABLE_DECOCALC_OPTION + uint8_t decocalc; +#endif char text[32]; char textMOD[32]; @@ -424,6 +428,9 @@ deco = editGasPage.pGasLine[gasID].note.ub.deco; travel = editGasPage.pGasLine[gasID].note.ub.travel; off = editGasPage.pGasLine[gasID].note.ub.off; +#ifdef ENABLE_DECOCALC_OPTION + decocalc = editGasPage.pGasLine[gasID].note.ub.decocalc; +#endif //bottleSizeLiter = editGasPage.pGasLine[gasID].bottle_size_liter; if(active) @@ -480,11 +487,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 +516,17 @@ text[txtptr++] = TXT2BYTE_SetToMOD; text[txtptr++] = 0; write_field_button(StMOG_SetToMOD, 20, 710, ME_Y_LINE4, &FontT48,text); +#ifdef ENABLE_DECOCALC_OPTION + 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); + } +#endif } else { @@ -547,11 +573,17 @@ 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); } +#ifdef ENABLE_DECOCALC_OPTION + if(deco) + { + setEvent(StMOG_CalcDeco, (uint32_t)OnAction_CalcDeco); + } +#endif /* setEvent(StMOG_Bottle, (uint32_t)OnAction_BottleSize); */ @@ -1091,13 +1123,34 @@ { 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; } +#ifdef ENABLE_DECOCALC_OPTION +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; +} +#endif uint8_t OnAction_ChangeDepth(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { uint8_t digitContentNew; @@ -1117,7 +1170,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; } diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuEditHardware.c --- a/Discovery/Src/tMenuEditHardware.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuEditHardware.c Tue Feb 11 18:12:00 2025 +0100 @@ -159,17 +159,6 @@ exitMenuEdit_to_Home(); } - -static uint8_t togglePlusMinus(uint8_t input) -{ - if (input == '+') { - return '-'; - } else { - return '+'; - } -} - - static uint8_t OnAction_CompassDeclination(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { SSettings *settings = settingsGetPointer(); @@ -285,6 +274,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 +313,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 +384,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 +410,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: @@ -461,10 +460,16 @@ case SENSOR_CO2: case SENSOR_CO2M: strSensorId[3] = 'C'; strSensorId[4] = 'O'; + strSensorId[5] = '2'; break; - case SENSOR_SENTINEL: strSensorId[3] = 'S'; - strSensorId[4] = 'e'; + case SENSOR_SENTINEL: + case SENSOR_SENTINELM: strSensorId[3] = 'S'; + strSensorId[4] = 'e'; break; + case SENSOR_GNSS: + case SENSOR_GNSSM: strSensorId[3] = 'G'; + strSensorId[4] = 'N'; + break; default: strSensorId[5] = 0; break; @@ -524,15 +529,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); } @@ -554,6 +559,7 @@ uint8_t sensorActive[3]; uint8_t index = 0; char text[3]; + uint32_t firstSensorId = 0; set_globalState(StMHARD3_Sensors); resetMenuEdit(CLUT_MenuPageHardware); @@ -573,26 +579,50 @@ if(((pSettings->ext_sensor_map[0] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[0] >= SENSOR_TYPE_O2_END))) { pSettings->ppo2sensors_deactivated |= 1; + if(pSettings->ext_sensor_map[0] == SENSOR_CO2M) + { + write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", pSettings->co2_sensor_active); + } } else { write_field_on_off(StMHARD3_O2_Sensor1, 30, 95, ME_Y_LINE1, &FontT48, "", sensorActive[0]); + if(firstSensorId == 0) + { + firstSensorId = StMHARD3_O2_Sensor1; + } } if(((pSettings->ext_sensor_map[1] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[1] >= SENSOR_TYPE_O2_END))) { pSettings->ppo2sensors_deactivated |= 2; + if(pSettings->ext_sensor_map[1] == SENSOR_CO2M) + { + write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", pSettings->co2_sensor_active); + } } else { write_field_on_off(StMHARD3_O2_Sensor2, 30, 95, ME_Y_LINE2, &FontT48, "", sensorActive[1]); + if(firstSensorId == 0) + { + firstSensorId = StMHARD3_O2_Sensor2; + } } if(((pSettings->ext_sensor_map[2] < SENSOR_OPTIC) || (pSettings->ext_sensor_map[2] >= SENSOR_TYPE_O2_END))) { pSettings->ppo2sensors_deactivated |= 4; + if(pSettings->ext_sensor_map[2] == SENSOR_CO2M) + { + write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", pSettings->co2_sensor_active); + } } else { write_field_on_off(StMHARD3_O2_Sensor3, 30, 95, ME_Y_LINE3, &FontT48, "", sensorActive[2]); + if(firstSensorId == 0) + { + firstSensorId = StMHARD3_O2_Sensor3; + } } stateRealGetPointerWrite()->diveSettings.ppo2sensors_deactivated = pSettings->ppo2sensors_deactivated; @@ -627,15 +657,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); } @@ -654,6 +684,15 @@ setEvent(StMHARD3_Sensor_Detect, (uint32_t)OnAction_Sensor_Detect); } write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); + + switch(firstSensorId) + { + case StMHARD3_O2_Sensor2: tMenuEdit_select(StMHARD3_O2_Sensor2); + break; + case StMHARD3_O2_Sensor3: tMenuEdit_select(StMHARD3_O2_Sensor3); + break; + default: break; + } } @@ -661,7 +700,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 +726,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 +751,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; } @@ -805,7 +844,7 @@ uint8_t OnAction_Sensor_Detect(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { - DataEX_setExtInterface_Cmd(EXT_INTERFACE_AUTODETECT); + DataEX_setExtInterface_Cmd(EXT_INTERFACE_AUTODETECT, 0); return UNSPECIFIC_RETURN; } @@ -895,7 +934,7 @@ } snprintf(text,32,"%c",TXT_ButtonLock); - write_field_on_off(StMHARD5_ButtonLock, 30, 95, ME_Y_LINE5, &FontT48, text, settingsGetPointer()->buttonLockActive); + write_field_on_off(StMHARD5_ButtonLock, 30, 700, ME_Y_LINE5, &FontT48, text, settingsGetPointer()->buttonLockActive); setEvent(StMHARD5_Button1, (uint32_t)OnAction_Button); @@ -934,7 +973,7 @@ sens[i] = settingsHelperButtonSens_translate_hwOS_values_to_percentage(stateRealGetPointer()->lifeData.buttonPICdata[i]); } snprintf(text,64,"\020\016\016%c%c \017 (%03u %03u %03u)",TXT_2BYTE,TXT2BYTE_LowerIsLess,sens[2],sens[1],sens[0]); - write_label_var( 20, 340, ME_Y_LINE6, &FontT42, text); + write_label_var( 20, 700, ME_Y_LINE6, &FontT42, text); tMenuEdit_refresh_field(StMHARD5_Button1); tMenuEdit_refresh_field(StMHARD5_ButtonBalance1); diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuEditPlanner.c --- a/Discovery/Src/tMenuEditPlanner.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuEditPlanner.c Tue Feb 11 18:12:00 2025 +0100 @@ -407,6 +407,7 @@ text[2] = 0; write_field_button(StMPLAN5_ExitResult, 30, 800, ME_Y_LINE6, &FontT48, text); setEvent(StMPLAN5_ExitResult, (uint32_t)OnAction_PlanResultExit); + tMenuEdit_select(StMPLAN5_ExitResult); } @@ -449,7 +450,11 @@ 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) +#ifdef ENABLE_DECOCALC_OPTION + || (stateSimGetPointer()->diveSettings.gas[stateSimGetPointer()->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0) +#endif + ) break; depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; if(depthPrev <= depthChange) @@ -464,7 +469,11 @@ 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) +#ifdef ENABLE_DECOCALC_OPTION + || (stateSimGetPointer()->diveSettings.gas[stateSimGetPointer()->diveSettings.decogaslist[i].GasIdInSettings].note.ub.decocalc == 0) +#endif + ) break; depthChange = stateSimGetPointer()->diveSettings.decogaslist[i].change_during_ascent_depth_meter_otherwise_zero; if((depthChange < depthPrev) && (depthChange >= depthNext)) diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuEditSystem.c --- a/Discovery/Src/tMenuEditSystem.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuEditSystem.c Tue Feb 11 18:12:00 2025 +0100 @@ -41,6 +41,7 @@ #include "tMenuEditCustom.h" #include "motion.h" #include "t7.h" +#include "math.h" /*#define HAVE_DEBUG_VIEW */ @@ -48,10 +49,12 @@ /* Private function prototypes -----------------------------------------------*/ void openEdit_DateTime(void); +void openEdit_DateFormat(void); void openEdit_Language(void); void openEdit_Design(void); void openEdit_Information(void); void openEdit_Reset(void); +void openEdit_Maintenance(void); //void openEdit_ShowDebugInfo(void); //void openEdit_Salinity(void); @@ -59,10 +62,13 @@ uint8_t OnAction_Date (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_Time (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_12HR (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +uint8_t OnAction_Format (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_DDMMYY (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_MMDDYY (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_YYMMDD (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_DST (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +uint8_t OnAction_UTC (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); +uint8_t OnAction_SetGnss (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_English (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_German (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_French (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); @@ -78,6 +84,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 +94,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 @@ -230,18 +238,24 @@ /* Private functions ---------------------------------------------------------*/ -void openEdit_DateTime(void) +void refresh_DateTime() { RTC_DateTypeDef Sdate; RTC_TimeTypeDef Stime; - uint8_t day,month,year,hour,minute, dateFormat, ddmmyy, mmddyy, yymmdd; + uint8_t day,month,year,hour,minute; char text[32]; + char formatStr[20]; SSettings *pSettings; const SFirmwareData *pFirmwareInfo; +#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 + uint8_t localHours = 0; + uint8_t localMinutes = 0; +#endif pFirmwareInfo = firmwareDataGetPointer(); const SDiveState * pStateReal = stateRealGetPointer(); pSettings = settingsGetPointer(); + translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); year = Sdate.Year; @@ -259,19 +273,7 @@ if(day < 1) day = 1; -// daylightsaving = Stime.DayLightSaving; - dateFormat = pSettings->date_format; - ddmmyy = 0; - mmddyy = 0; - yymmdd = 0; - - if(dateFormat == DDMMYY) - ddmmyy = 1; - else - if(dateFormat == MMDDYY) - mmddyy = 1; - else - yymmdd = 1; + getStringOfFormat_DDMMYY(formatStr, 20); text[0] = '\001'; text[1] = TXT_DateAndTime; @@ -282,26 +284,131 @@ write_label_fix( 20, 340, ME_Y_LINE1, &FontT42, TXT_TimeConfig); write_label_fix( 20, 340, ME_Y_LINE2, &FontT42, TXT_Format); write_label_fix( 20, 340, ME_Y_LINE3, &FontT42, TXT_DateConfig); - write_label_var( 600, 800, ME_Y_LINE4, &FontT48, "\016\016DDMMYY\017"); - write_label_fix( 20, 790, ME_Y_LINE5, &FontT42, TXT_Format); -// write_label_fix( 350 ,580, 250, &FontT42, TXT_Daylightsaving); + write_label_fix( 20, 790, ME_Y_LINE4, &FontT42, TXT_Format); +#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 + write_label_var( 20, 340, ME_Y_LINE5, &FontT42, "GNSS"); + snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_TIMEZONE); + write_label_var( 20, 340, ME_Y_LINE6, &FontT42, text); +#endif + + + tMenuEdit_newInput(StMSYS1_Time, hour, minute, 0, 0); + tMenuEdit_set_on_off(StMSYS1_12HR, pSettings->amPMTime); + + switch(pSettings->date_format) + { + default: + case DDMMYY: tMenuEdit_newInput(StMSYS1_Date, day, month, year, 0); + break; + case MMDDYY: tMenuEdit_newInput(StMSYS1_Date, month, day, year, 0); + break; + case YYMMDD: tMenuEdit_newInput(StMSYS1_Date, year, month, day, 0); + break; + } + tMenuEdit_newButtonText(StMSYS1_FORMAT, formatStr); + +#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 + if(pStateReal->lifeData.gnssData.alive & GNSS_ALIVE_STATE_TIME) + { + convertUTCToLocal(pStateReal->lifeData.gnssData.DateTime.hour, pStateReal->lifeData.gnssData.DateTime.min, &localHours, &localMinutes); + convertStringOfDate_DDMMYY(formatStr, 20, pStateReal->lifeData.gnssData.DateTime.day + , pStateReal->lifeData.gnssData.DateTime.month + , pStateReal->lifeData.gnssData.DateTime.year); + snprintf(text, 32, "%02d:%02d - %s", localHours, localMinutes, formatStr); + tMenuEdit_newButtonText(StMSYS1_GNSSDT, text); + } + else + { + snprintf(text, 32, "--:--"); + write_label_var( 320, 790, ME_Y_LINE5, &FontT42, text); + } + tMenuEdit_newInput(StMSYS1_ZONE, pSettings->timeZone.hours, pSettings->timeZone.minutes, 0, 0); +#endif + write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); +} +void openEdit_DateTime(void) +{ + RTC_DateTypeDef Sdate; + RTC_TimeTypeDef Stime; + uint8_t day,month,year,hour,minute; + char text[32]; + char formatStr[20]; + SSettings *pSettings; + const SFirmwareData *pFirmwareInfo; + + pFirmwareInfo = firmwareDataGetPointer(); + const SDiveState * pStateReal = stateRealGetPointer(); + + pSettings = settingsGetPointer(); + + set_globalState(StMSYS1_DateTime); + resetMenuEdit(CLUT_MenuPageSystem); + + translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); + translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); + year = Sdate.Year; + month = Sdate.Month; + day = Sdate.Date; + hour = Stime.Hours; + minute= Stime.Minutes; + + if(year < pFirmwareInfo->release_year) + year = pFirmwareInfo->release_year; + + if(month < 1) + month = 1; + + if(day < 1) + day = 1; + + getStringOfFormat_DDMMYY(formatStr, 20); + + text[0] = '\001'; + text[1] = TXT_DateAndTime; + text[2] = 0; + + write_topline(text); + + write_label_fix( 20, 340, ME_Y_LINE1, &FontT42, TXT_TimeConfig); + write_label_fix( 20, 340, ME_Y_LINE2, &FontT42, TXT_Format); + write_label_fix( 20, 340, ME_Y_LINE3, &FontT42, TXT_DateConfig); + write_label_fix( 20, 790, ME_Y_LINE4, &FontT42, TXT_Format); +#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 + write_label_var( 20, 340, ME_Y_LINE5, &FontT42, "GNSS"); + snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_TIMEZONE); + write_label_var( 20, 340, ME_Y_LINE6, &FontT42, text); +#endif write_field_2digit(StMSYS1_Time, 320, 780, ME_Y_LINE1, &FontT48, "##:##", (uint32_t)hour, (uint32_t)minute, 0, 0); - write_field_on_off(StMSYS1_12HR, 320, 790, ME_Y_LINE2, &FontT48, "12 HR", pSettings->amPMTime); - write_field_2digit(StMSYS1_Date, 320, 780, ME_Y_LINE3, &FontT48, "##-##-20##", (uint32_t)day, (uint32_t)month, (uint32_t)year, 0); - write_field_on_off(StMSYS1_DDMMYY, 320, 790, ME_Y_LINE4, &FontT48, "DDMMYY", ddmmyy); - write_field_on_off(StMSYS1_MMDDYY, 320, 790, ME_Y_LINE5, &FontT48, "MMDDYY", mmddyy); - write_field_on_off(StMSYS1_YYMMDD, 320, 790, ME_Y_LINE6, &FontT48, "YYMMDD", yymmdd); -// write_field_on_off(StMSYS1_DST, 350, 580, 310, &FontT48, "Active", daylightsaving); + write_field_on_off(StMSYS1_12HR, 320, 790, ME_Y_LINE2, &FontT48, "12 HR", pSettings->amPMTime); + + switch(pSettings->date_format) + { + default: + case DDMMYY: write_field_2digit(StMSYS1_Date, 320, 780, ME_Y_LINE3, &FontT48, "##-##-20##", (uint32_t)day, (uint32_t)month, (uint32_t)year, 0); + break; + case MMDDYY: write_field_2digit(StMSYS1_Date, 320, 780, ME_Y_LINE3, &FontT48, "##-##-20##", (uint32_t)month, (uint32_t)day, (uint32_t)year, 0); + break; + case YYMMDD: write_field_2digit(StMSYS1_Date, 320, 780, ME_Y_LINE3, &FontT48, "20##-##-##", (uint32_t)year, (uint32_t)month, (uint32_t)day, 0); + break; + } + + write_field_button(StMSYS1_FORMAT, 320, 790, ME_Y_LINE4, &FontT48, formatStr); + +#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 + snprintf(text, 32, "--:--"); + write_field_button(StMSYS1_GNSSDT, 320, 790, ME_Y_LINE5, &FontT48, text); + write_field_sdigit(StMSYS1_ZONE, 320, 780, ME_Y_LINE6, &FontT48, "UTC: ###:###", pSettings->timeZone.hours, pSettings->timeZone.minutes,0,0); +#endif setEvent(StMSYS1_Date, (uint32_t)OnAction_Date); setEvent(StMSYS1_Time, (uint32_t)OnAction_Time); setEvent(StMSYS1_12HR, (uint32_t)OnAction_12HR); - setEvent(StMSYS1_DDMMYY, (uint32_t)OnAction_DDMMYY); - setEvent(StMSYS1_MMDDYY, (uint32_t)OnAction_MMDDYY); - setEvent(StMSYS1_YYMMDD, (uint32_t)OnAction_YYMMDD); -// setEvent(StMSYS1_DST, (uint32_t)OnAction_DST); - + setEvent(StMSYS1_FORMAT, (uint32_t)OnAction_Format); +#if defined ENABLE_GNSS_SUPPORT || defined ENABLE_GPIO_V2 + setEvent(StMSYS1_GNSSDT, (uint32_t)OnAction_SetGnss); + setEvent(StMSYS1_ZONE, (uint32_t)OnAction_UTC); +#endif write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); } @@ -315,13 +422,41 @@ const SFirmwareData *pFirmwareInfo; pFirmwareInfo = firmwareDataGetPointer(); + uint8_t mapDMY[3]; + switch(settingsGetPointer()->date_format) + { + default: + case DDMMYY: mapDMY[0] = 0; + mapDMY[1] = 1; + mapDMY[2] = 2; + break; + case MMDDYY: mapDMY[0] = 1; + mapDMY[1] = 0; + mapDMY[2] = 2; + break; + case YYMMDD: mapDMY[0] = 2; + mapDMY[1] = 1; + mapDMY[2] = 0; + break; + } + if(action == ACTION_BUTTON_ENTER) { return digitContent; } if(action == ACTION_BUTTON_ENTER_FINAL) { - evaluateNewString(editId, &newDay, &newMonth, &newYear, 0); + switch(settingsGetPointer()->date_format) + { + default: + case DDMMYY: evaluateNewString(editId, &newDay, &newMonth, &newYear, 0); + break; + case MMDDYY: evaluateNewString(editId, &newMonth, &newDay, &newYear, 0); + break; + case YYMMDD: evaluateNewString(editId, &newYear, &newMonth, &newDay, 0); + break; + } + if(newDay == 0) newDay = 1; if(newDay > 31) @@ -346,29 +481,52 @@ setDate(sdatestructure); - tMenuEdit_newInput(editId, newDay, newMonth, newYear, 0); + switch(settingsGetPointer()->date_format) + { + default: + case DDMMYY: tMenuEdit_newInput(editId, newDay, newMonth, newYear, 0); + break; + case MMDDYY: tMenuEdit_newInput(editId, newMonth, newDay, newYear, 0); + break; + case YYMMDD: tMenuEdit_newInput(editId, newYear, newMonth, newDay, 0); + break; + } + return UNSPECIFIC_RETURN; } if(action == ACTION_BUTTON_NEXT) /* clip values to a specific range e.g. 12 months */ { digitContentNew = digitContent + 1; - if((blockNumber == 0) && (digitContentNew > '0' + 31)) + + if((blockNumber == mapDMY[0]) && (digitContentNew > '0' + 31)) + { digitContentNew = '1'; - if((blockNumber == 1) && (digitContentNew > '0' + 12)) + } + if((blockNumber == mapDMY[1]) && (digitContentNew > '0' + 12)) + { digitContentNew = '1'; - if((blockNumber == 2) && (digitContentNew > '0' + pFirmwareInfo->release_year + 10)) + } + if((blockNumber == mapDMY[2]) && (digitContentNew > '0' + pFirmwareInfo->release_year + 10)) + { digitContentNew = '0' + pFirmwareInfo->release_year; + } return digitContentNew; } if(action == ACTION_BUTTON_BACK) /* clip values to a specific range e.g. 12 months */ { digitContentNew = digitContent - 1; - if((blockNumber == 0) && (digitContentNew < '1')) + if((blockNumber == mapDMY[0]) && (digitContentNew < '1')) + { digitContentNew = '0' + 31; - if((blockNumber == 1) && (digitContentNew < '1')) + } + if((blockNumber == mapDMY[1]) && (digitContentNew < '1')) + { digitContentNew = '0' + 12; - if((blockNumber == 2) && (digitContentNew < '0' + pFirmwareInfo->release_year)) + } + if((blockNumber == mapDMY[2]) && (digitContentNew < '0' + pFirmwareInfo->release_year)) + { digitContentNew = '0' + pFirmwareInfo->release_year + 10; + } return digitContentNew; } /* @@ -487,6 +645,85 @@ return UNSPECIFIC_RETURN; } +uint8_t OnAction_SetGnss(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + RTC_DateTypeDef sdatestructure; + RTC_TimeTypeDef stimestructure; + uint8_t localHours = 0; + uint8_t localMinutes = 0; + + const SDiveState * pStateReal = stateRealGetPointer(); + + if(pStateReal->lifeData.gnssData.alive & GNSS_ALIVE_STATE_TIME) + { + convertUTCToLocal(pStateReal->lifeData.gnssData.DateTime.hour, pStateReal->lifeData.gnssData.DateTime.min, &localHours, &localMinutes); + stimestructure.Hours = localHours; + stimestructure.Minutes = localMinutes; + stimestructure.Seconds = 0; + setTime(stimestructure); + + sdatestructure.Date = pStateReal->lifeData.gnssData.DateTime.day; + sdatestructure.Month = pStateReal->lifeData.gnssData.DateTime.month; + sdatestructure.Year = pStateReal->lifeData.gnssData.DateTime.year; + setWeekday(&sdatestructure); + setDate(sdatestructure); + } + return UNSPECIFIC_RETURN; +} + +void openEdit_DateFormat(void) +{ + char text[32]; + SSettings *pSettings; + + uint8_t ddmmyy = 0; + uint8_t mmddyy= 0; + uint8_t yymmdd = 0; + + pSettings = settingsGetPointer(); + + + set_globalState(StMSYS1_FORMAT); + resetMenuEdit(CLUT_MenuPageSystem); + setBackMenu((uint32_t)openEdit_DateTime,0,4); + + switch(pSettings->date_format) + { + default: + case DDMMYY: ddmmyy = 1; + break; + case MMDDYY: mmddyy = 1; + break; + case YYMMDD: yymmdd = 1; + break; + }; + + text[0] = '\001'; + text[1] = TXT_Format; + text[2] = 0; + + write_topline(text); + + write_label_fix( 20, 790, ME_Y_LINE2, &FontT42, TXT_Format); + + write_field_on_off(StMSYS1_DDMMYY, 320, 790, ME_Y_LINE1, &FontT48, "DDMMYY", ddmmyy); + write_field_on_off(StMSYS1_MMDDYY, 320, 790, ME_Y_LINE2, &FontT48, "MMDDYY", mmddyy); + write_field_on_off(StMSYS1_YYMMDD, 320, 790, ME_Y_LINE3, &FontT48, "YYMMDD", yymmdd); + + setEvent(StMSYS1_DDMMYY, (uint32_t)OnAction_DDMMYY); + setEvent(StMSYS1_MMDDYY, (uint32_t)OnAction_MMDDYY); + setEvent(StMSYS1_YYMMDD, (uint32_t)OnAction_YYMMDD); + + write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); +} + +uint8_t OnAction_Format(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + openEdit_DateFormat(); + + return UNSPECIFIC_RETURN; +} + uint8_t OnAction_DDMMYY(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { SSettings *pSettings; @@ -531,6 +768,81 @@ return UNSPECIFIC_RETURN; } +uint8_t OnAction_UTC(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + SSettings *settings = settingsGetPointer(); + const SDiveState * pStateReal = stateRealGetPointer(); + int32_t utcHour; + uint32_t utcMinutes; + uint8_t digitContentNew; + uint8_t localHours = 0; + uint8_t localMinutes = 0; + char text[32]; + char timeStr[20]; + + switch (action) { + case ACTION_BUTTON_ENTER: + + return digitContent; + case ACTION_BUTTON_ENTER_FINAL: + { + + evaluateNewString(editId, (uint32_t *)&utcHour, &utcMinutes, NULL, NULL); + + if (utcHour > 14) { + utcHour = 14; + } else if (utcHour < -12) { + utcHour = -12; + } + + if (utcMinutes % 15 != 0) + { + utcMinutes = (utcMinutes / 15) * 15; + } + if(utcMinutes > 45) + { + utcMinutes = 45; + } else if (utcMinutes < 0) { + utcMinutes = 0; + } + settings->timeZone.hours = utcHour; + settings->timeZone.minutes = utcMinutes; + + tMenuEdit_newInput(editId, ((input_u)utcHour).uint32, utcMinutes, 0, 0); + convertUTCToLocal(pStateReal->lifeData.gnssData.DateTime.hour, pStateReal->lifeData.gnssData.DateTime.min, &localHours, &localMinutes); + convertStringOfDate_DDMMYY(timeStr, 20, pStateReal->lifeData.gnssData.DateTime.day + , pStateReal->lifeData.gnssData.DateTime.month + , pStateReal->lifeData.gnssData.DateTime.year); + snprintf(text, 32, "%2d:%2d - %s", localHours, localMinutes, timeStr); + tMenuEdit_newButtonText(StMSYS1_GNSSDT, text); + } + + break; + case ACTION_BUTTON_NEXT: + if ((blockNumber == 0) && (digitNumber == 0)) { + digitContentNew = togglePlusMinus(digitContent); + } else { + digitContentNew = digitContent + 1; + if (digitContentNew > '9') { + digitContentNew = '0'; + } + } + + return digitContentNew; + case ACTION_BUTTON_BACK: + if ((blockNumber == 0) && (digitNumber == 0)) { + digitContentNew = togglePlusMinus(digitContent); + } else { + digitContentNew = digitContent - 1; + if (digitContentNew < '0') { + digitContentNew = '9'; + } + } + return digitContentNew; + } + return UNSPECIFIC_RETURN; +} + uint8_t OnAction_DST(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { @@ -734,7 +1046,7 @@ write_content( 30, 700, ME_Y_LINE4 + 30 + 70, &FontT48, "___________", CLUT_DIVE_FieldSeperatorLines); write_content(280, 700, ME_Y_LINE4 + 30 + 70 - 3, &FontT48, "|", CLUT_DIVE_pluginbox); write_content(290, 700, ME_Y_LINE4 + 30 + 70 - 37, &FontT48, "_______________", CLUT_DIVE_pluginbox); - write_content( 30, 700, ME_Y_LINE4 + 30, &FontT144, "24.7", CLUT_Font027); + write_content( 30, 700, ME_Y_LINE4 + 42, &FontT144, "24.7", CLUT_Font027); write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); } @@ -835,6 +1147,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 +1388,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 +1463,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 +1604,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 +1682,54 @@ 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; + float orgpressure_surface_mbar; + float DiveO2_mbar; + int8_t newOffset_mbar = 0; + + + char text[32]; + + + + for (index = 0; index < 3; index++) + { + if(settingsGetPointer()->ext_sensor_map[index] == SENSOR_DIGO2M) + { + pDiveO2Data = (SSensorDataDiveO2*)stateRealGetPointer()->lifeData.extIf_sensor_data[index]; + DiveO2_mbar = (pDiveO2Data->pressure/1000.0); + + orgpressure_surface_mbar = (pDiveState->lifeData.pressure_surface_bar * 1000) - (settingsGetPointer()->offsetPressure_mbar); + newOffset_mbar = DiveO2_mbar - orgpressure_surface_mbar; + + if(fabs(orgpressure_surface_mbar + ((float)newOffset_mbar) - DiveO2_mbar) > 0.5) /* there might be a rounding difference => compensate */ + { + if((orgpressure_surface_mbar + ((float)newOffset_mbar)) - (pDiveO2Data->pressure/1000.0) > 0.0) + { + newOffset_mbar -=1; + } + else + { + newOffset_mbar +=1; + } + } + + pSettings->offsetPressure_mbar = newOffset_mbar; + snprintf(text,32,"%c%c (%1.3lf => %1.3f)\016\016Bar",TXT_2BYTE,TXT2BYTE_AdjustAmbPressure,(float)(pDiveO2Data->pressure/1000000.0), (orgpressure_surface_mbar + 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) { diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuEditXtra.c --- a/Discovery/Src/tMenuEditXtra.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuEditXtra.c Tue Feb 11 18:12:00 2025 +0100 @@ -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 --------------------------------------------------------*/ @@ -98,10 +91,14 @@ case 3: openEdit_SetManualMarker(); break; +#ifdef ENABLE_MOTION_CONTROL case 4: openEdit_CalibViewport(); break; case 5: +#else + case 4: +#endif if(is_stateUsedSetToSim()) { openEdit_SimFollowDecostops(); @@ -115,11 +112,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,8 +124,8 @@ case 4: openEdit_PSCR(); break; #endif -#ifdef ENABLE_CO2_SUPPORT - case 6: openEdit_CO2Sensor(); +#ifdef ENABLE_PREDIVE_CHECK + case 5: openInfo_PreDive(); break; #endif default: @@ -321,46 +313,20 @@ } -#ifdef ENABLE_CO2_SUPPORT -static void openEdit_CO2Sensor() + +static uint8_t OnAction_CompassHeadingReverse(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { - char text[32]; - - resetMenuEdit(CLUT_MenuPageXtra); - - snprintf(text,32,"\001%c",TXT_CO2Sensor); - write_topline(text); + setCompassHeading((stateUsed->diveSettings.compassHeading + 180) % 360); - refresh_CO2Data(); - if(settingsGetPointer()->co2_sensor_active) - { - text[0] = '\005'; - } - else - { - text[0] = '\006'; - } - text[0] = TXT_CO2Sensor; - text[1] = 0; + exitMenuEdit_to_Home_with_Menu_Update(); - 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); + return EXIT_TO_HOME; } -#endif static uint8_t OnAction_CompassHeadingClear(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { - stateUsedWrite->diveSettings.compassHeading = 0; + clearCompassHeading(); exitMenuEdit_to_Home_with_Menu_Update(); @@ -370,7 +336,17 @@ static uint8_t OnAction_CompassHeadingReset(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { - stateUsedWrite->diveSettings.compassHeading = settingsGetPointer()->compassBearing; + setCompassHeading(settingsGetPointer()->compassBearing); + + exitMenuEdit_to_Home_with_Menu_Update(); + + return EXIT_TO_HOME; +} + + +static uint8_t OnAction_CompassHeadingLog(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) +{ + logCompassHeading((uint16_t)stateUsed->lifeData.compass_heading); exitMenuEdit_to_Home_with_Menu_Update(); @@ -386,6 +362,13 @@ snprintf(text, 32, "\001%c%c", TXT_2BYTE, TXT2BYTE_CompassHeading); write_topline(text); + if (!isRefresh) { + snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_Set); + write_field_button(StMXTRA_CompassHeading, 20, 800, ME_Y_LINE1, &FontT48, text); + } else { + tMenuEdit_refresh_field(StMXTRA_CompassHeading); + } + uint16_t heading; if (settings->compassInertia) { heading = (uint16_t)compass_getCompensated(); @@ -395,14 +378,18 @@ snprintf(text,32,"\001%03i`",heading); write_label_var(0, 800, ME_Y_LINE1, &FontT54, text); - if (!isRefresh) { - snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_Set); - write_field_button(StMXTRA_CompassHeading, 20, 800, ME_Y_LINE2, &FontT48, text); + bool headingIsSet = stateUsed->diveSettings.compassHeading; + snprintf(text, 32, "%s%c%c", makeGrey(!headingIsSet), TXT_2BYTE, TXT2BYTE_Reverse); + if (headingIsSet) { + if (!isRefresh) { + write_field_button(StMXTRA_CompassHeadingReverse, 20, 800, ME_Y_LINE2, &FontT48, text); + } else { + tMenuEdit_refresh_field(StMXTRA_CompassHeadingReverse); + } } else { - tMenuEdit_refresh_field(StMXTRA_CompassHeading); + write_label_var(20, 800, ME_Y_LINE2, &FontT48, text); } - bool headingIsSet = stateUsed->diveSettings.compassHeading; snprintf(text, 32, "%s%c%c", makeGrey(!headingIsSet), TXT_2BYTE, TXT2BYTE_Clear); if (headingIsSet) { if (!isRefresh) { @@ -427,10 +414,24 @@ write_label_var(20, 800, ME_Y_LINE4, &FontT48, text); } + snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_Log); + if (!isRefresh) { + write_field_button(StMXTRA_CompassHeadingLog, 20, 800, ME_Y_LINE5, &FontT48, text); + } else { + tMenuEdit_refresh_field(StMXTRA_CompassHeadingLog); + } + + if (headingIsSet) { + snprintf(text, 32, "%s%c%c (%03u`)", makeGrey(true), TXT_2BYTE, TXT2BYTE_Current, stateUsed->diveSettings.compassHeading); + write_label_var(20, 800, ME_Y_LINE6, &FontT48, text); + } + if (!isRefresh) { setEvent(StMXTRA_CompassHeading, (uint32_t)OnAction_CompassHeading); + setEvent(StMXTRA_CompassHeadingReverse, (uint32_t)OnAction_CompassHeadingReverse); setEvent(StMXTRA_CompassHeadingClear, (uint32_t)OnAction_CompassHeadingClear); setEvent(StMXTRA_CompassHeadingReset, (uint32_t)OnAction_CompassHeadingReset); + setEvent(StMXTRA_CompassHeadingLog, (uint32_t)OnAction_CompassHeadingLog); } write_buttonTextline(TXT2BYTE_ButtonBack, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonNext); @@ -443,23 +444,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 +668,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 diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuHardware.c --- a/Discovery/Src/tMenuHardware.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuHardware.c Tue Feb 11 18:12:00 2025 +0100 @@ -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] diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuSystem.c --- a/Discovery/Src/tMenuSystem.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuSystem.c Tue Feb 11 18:12:00 2025 +0100 @@ -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; @@ -48,7 +49,6 @@ SSettings *data; int i; uint8_t textPointer; - uint8_t dateFormat; uint8_t RTEhigh, RTElow; RTC_DateTypeDef Sdate; RTC_TimeTypeDef Stime; @@ -58,6 +58,7 @@ textPointer = 0; *tab = 300; *subtext = 0; + char tmpString[15]; resetLineMask(StMSYS); @@ -127,49 +128,11 @@ translateDate(pStateReal->lifeData.dateBinaryFormat, &Sdate); translateTime(pStateReal->lifeData.timeBinaryFormat, &Stime); - dateFormat = data->date_format; - - textPointer += snprintf(&text[textPointer], 40, - "Date" - "\016\016" - " " - ); - - if(dateFormat == DDMMYY) - { - textPointer += snprintf(&text[textPointer], 40, - "DDMMYY" - "\017" - "\t" - "%02d-%02d-%02d" - " " - , Sdate.Date, Sdate.Month, 2000 + Sdate.Year - ); - } - else - if(dateFormat == MMDDYY) - { - textPointer += snprintf(&text[textPointer], 40, - "MMDDYY" - "\017" - "\t" - "%02d-%02d-%02d" - " " - ,Sdate.Month, Sdate.Date, 2000 + Sdate.Year - ); - } - else - if(dateFormat == YYMMDD) - { - textPointer += snprintf(&text[textPointer], 40, - "YYMMDD" - "\017" - "\t" - "%02d-%02d-%02d" - " " - , 2000 + Sdate.Year, Sdate.Month, Sdate.Date - ); - } + text[textPointer++] = TXT_Date; + getStringOfFormat_DDMMYY(tmpString,15); + textPointer += snprintf(&text[textPointer], 40,"\016\016 %s ",tmpString); + convertStringOfDate_DDMMYY(tmpString,15,Sdate.Date, Sdate.Month, Sdate.Year); + textPointer += snprintf(&text[textPointer], 40,"\017\t%s ",tmpString); textPointer += snprintf(&text[textPointer], 60, "%02d:%02d:%02d" @@ -183,9 +146,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 +278,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 ---------------------------------------------------------*/ diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/tMenuXtra.c --- a/Discovery/Src/tMenuXtra.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/tMenuXtra.c Tue Feb 11 18:12:00 2025 +0100 @@ -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,68 @@ } #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 +#ifdef ENABLE_PREDIVE_CHECK + 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; + } +#endif } 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(); + } +} + diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/text_multilanguage.c --- a/Discovery/Src/text_multilanguage.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/text_multilanguage.c Tue Feb 11 18:12:00 2025 +0100 @@ -116,7 +116,7 @@ // dive mode static uint8_t text_EN_Temperature[] = "Temp."; static uint8_t text_DE_Temperature[] = "Temperatur"; -static uint8_t text_FR_Temperature[] = "Temp."; // Température (ist zu lang) +static uint8_t text_FR_Temperature[] = "Temp."; // Température (Does not fit) static uint8_t text_IT_Temperature[] = "Temp."; static uint8_t text_ES_Temperature[] = "Temp."; @@ -158,9 +158,9 @@ // dive mode static uint8_t text_EN_ActualGradient[] = "Saturation"; static uint8_t text_DE_ActualGradient[] = "Sättigung"; -static uint8_t text_FR_ActualGradient[] = ""; -static uint8_t text_IT_ActualGradient[] = ""; -static uint8_t text_ES_ActualGradient[] = ""; +static uint8_t text_FR_ActualGradient[] = "Saturation"; +static uint8_t text_IT_ActualGradient[] = "Saturazione"; +static uint8_t text_ES_ActualGradient[] = "Saturación"; // dive mode static uint8_t text_EN_Stopwatch[] = "Stopwatch"; @@ -174,34 +174,39 @@ static uint8_t text_DE_CompassCalib[] = "Kompass kalibrieren"; static uint8_t text_FR_CompassCalib[] = "Calibration boussole"; static uint8_t text_IT_CompassCalib[] = "Calibrazione bussola"; -static uint8_t text_ES_CompassCalib[] = "Calibrar brújula"; +static uint8_t text_ES_CompassCalib[] = "Calibrar brujula"; static uint8_t text_EN_CompassInertia[] = "Compass inertia level"; static uint8_t text_DE_CompassInertia[] = "Kompass Trägheitsfaktor"; -static uint8_t text_FR_CompassInertia[] = ""; -static uint8_t text_IT_CompassInertia[] = ""; -static uint8_t text_ES_CompassInertia[] = ""; +static uint8_t text_FR_CompassInertia[] = "Facteur d'inertie"; +static uint8_t text_IT_CompassInertia[] = "Inerzia della bussola"; +static uint8_t text_ES_CompassInertia[] = "inercia de la brujula"; -static uint8_t text_EN_CompassDeclination[] = "Compass declination"; -static uint8_t text_DE_CompassDeclination[] = "Kompass Deklination"; +static uint8_t text_EN_CompassDeclination[] = "Declination"; +static uint8_t text_DE_CompassDeclination[] = "Deklination"; static uint8_t text_FR_CompassDeclination[] = "Déclinaison"; 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[] = "Automatique"; +static uint8_t text_IT_Autofocus[] = "Automatico"; +static uint8_t text_ES_Autofocus[] = "Automático"; // Menu SYS1 and Customview header static uint8_t text_EN_Compass[] = "Compass"; static uint8_t text_DE_Compass[] = "Kompass"; static uint8_t text_FR_Compass[] = "Boussole"; static uint8_t text_IT_Compass[] = "Bussola"; -static uint8_t text_ES_Compass[] = "Brújula"; +static uint8_t text_ES_Compass[] = "Brujula"; // Menu SYS1 -static uint8_t text_EN_o2Sensors[] = "Oxygen sensors"; -static uint8_t text_DE_o2Sensors[] = "O2-Sensoren"; -static uint8_t text_FR_o2Sensors[] = "Cellules O2"; -static uint8_t text_IT_o2Sensors[] = "Sensore O2"; -static uint8_t text_ES_o2Sensors[] = "Sensores de O2"; +static uint8_t text_EN_o2Sensors[] = "External sensors"; +static uint8_t text_DE_o2Sensors[] = "Externe Sensoren"; +static uint8_t text_FR_o2Sensors[] = "Capteurs externes"; +static uint8_t text_IT_o2Sensors[] = "Sensori esterni"; +static uint8_t text_ES_o2Sensors[] = "Sensores externos"; // Menu SYS1 static uint8_t text_EN_Brightness[] = "Brightness"; @@ -288,11 +293,11 @@ static uint8_t text_ES_Deco[] = "Deco"; // Menu Gas -static uint8_t text_EN_Travel[] = "Travel"; -static uint8_t text_DE_Travel[] = "Reise"; -static uint8_t text_FR_Travel[] = "Travel"; -static uint8_t text_IT_Travel[] = "Viaggio"; -static uint8_t text_ES_Travel[] = "Viaje"; +static uint8_t text_EN_Travel[] = "Work"; +static uint8_t text_DE_Travel[] = "Arbeit"; +static uint8_t text_FR_Travel[] = "Travail"; +static uint8_t text_IT_Travel[] = "Lavaro"; +static uint8_t text_ES_Travel[] = "Labor"; // Menu Gas static uint8_t text_EN_Inactive[] = "Inactive"; @@ -304,9 +309,9 @@ // Menu Gas static uint8_t text_EN_Off[] = "Off"; static uint8_t text_DE_Off[] = "Ausblenden"; -static uint8_t text_FR_Off[] = ""; -static uint8_t text_IT_Off[] = ""; -static uint8_t text_ES_Off[] = ""; +static uint8_t text_FR_Off[] = "Masquer"; +static uint8_t text_IT_Off[] = "Nascondere"; +static uint8_t text_ES_Off[] = "Ocultar"; // Menu Gas static uint8_t text_EN_ChangeDepth[] = "Change depth"; @@ -348,7 +353,7 @@ static uint8_t text_DE_SafetyStop[] = "Sicherheitsstop"; static uint8_t text_FR_SafetyStop[] = "Palier sécurité"; static uint8_t text_IT_SafetyStop[] = "Sicurezza"; -static uint8_t text_ES_SafetyStop[] = "Parada de seguridad"; +static uint8_t text_ES_SafetyStop[] = "Parada segurid."; // Menu DECO1 (CCR mode only) static uint8_t text_EN_CCRmode[] = "CCR mode"; @@ -383,7 +388,7 @@ static uint8_t text_DE_LastDecostop[] = "Letzter Stopp"; static uint8_t text_FR_LastDecostop[] = "Dern. palier"; static uint8_t text_IT_LastDecostop[] = "Ultima deco"; -static uint8_t text_ES_LastDecostop[] = "Última parada"; +static uint8_t text_ES_LastDecostop[] = "Ultima parada"; // Menu DECO2 and Dive Menu static uint8_t text_EN_ZHL16GF[] = "ZH-L16+GF"; @@ -424,13 +429,13 @@ static uint8_t text_DE_Maximum[] = "Maximum"; static uint8_t text_FR_Maximum[] = "Maximum"; static uint8_t text_IT_Maximum[] = "Massimo"; -static uint8_t text_ES_Maximum[] = "Max"; +static uint8_t text_ES_Maximum[] = "Máximo"; static uint8_t text_EN_Minimum[] = "Minimum"; static uint8_t text_DE_Minimum[] = "Minimum"; static uint8_t text_FR_Minimum[] = "Minimum"; static uint8_t text_IT_Minimum[] = "Minimo"; -static uint8_t text_ES_Minimum[] = "Min"; +static uint8_t text_ES_Minimum[] = "Mínimo"; static uint8_t text_EN_Salinity[] = "Salinity"; static uint8_t text_DE_Salinity[] = "Salzgehalt"; @@ -465,11 +470,17 @@ 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[] = ""; -static uint8_t text_IT_ChargeHour[] = ""; -static uint8_t text_ES_ChargeHour[] = ""; +static uint8_t text_FR_ChargeHour[] = "Hour(s) jusqu'à 100"; +static uint8_t text_IT_ChargeHour[] = "Ore fino al 100%"; +static uint8_t text_ES_ChargeHour[] = "Hora(s) hasta el 100%"; static uint8_t text_EN_Date[] = "Date"; static uint8_t text_DE_Date[] = "Datum"; @@ -602,24 +613,24 @@ // Menu SYS2 static uint8_t text_EN_Information[] = "Information"; -static uint8_t text_DE_Information[] = ""; -static uint8_t text_FR_Information[] = ""; // Information -static uint8_t text_IT_Information[] = "Info"; +static uint8_t text_DE_Information[] = "Information"; +static uint8_t text_FR_Information[] = "Information"; // Information +static uint8_t text_IT_Information[] = "Informazioni"; static uint8_t text_ES_Information[] = "Información"; // Menu SYS2 static uint8_t text_EN_ResetMenu[] = "Reset menu"; static uint8_t text_DE_ResetMenu[] = "Reset-Menü"; static uint8_t text_FR_ResetMenu[] = "Menu RaZ"; // RaZ -static uint8_t text_IT_ResetMenu[] = "Reset"; -static uint8_t text_ES_ResetMenu[] = "Restaurar"; +static uint8_t text_IT_ResetMenu[] = "Menu di reset"; +static uint8_t text_ES_ResetMenu[] = "Menu de reinicio"; // Menu SYS2 sub static uint8_t text_EN_LogbookOffset[] = "Logbook offset"; static uint8_t text_DE_LogbookOffset[] = "Logbuch-Versatz"; static uint8_t text_FR_LogbookOffset[] = "Num. 1er plongée"; static uint8_t text_IT_LogbookOffset[] = "Logbook offset"; -static uint8_t text_ES_LogbookOffset[] = "Diario: iniciar numeración en"; +static uint8_t text_ES_LogbookOffset[] = "Logbook offset"; // Menu SYS2 sub @@ -632,23 +643,30 @@ // Menu SYS2 sub static uint8_t text_EN_SetBatteryCharge[] = "Restore Battery Charge"; static uint8_t text_DE_SetBatteryCharge[] = "Batterie zurücksetzen"; -static uint8_t text_FR_SetBatteryCharge[] = ""; +static uint8_t text_FR_SetBatteryCharge[] = "Réinit. l'état de charge"; static uint8_t text_IT_SetBatteryCharge[] = "Ricaricare batteria"; 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[] = "Ajuster la pression"; +static uint8_t text_IT_AdjustAmbPressure[] = "Regolare pressione"; +static uint8_t text_ES_AdjustAmbPressure[] = "Ajustar la presión"; + +// 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[] = ""; +static uint8_t text_FR_SetFactoryDefaults[] = "Réinitialiser le bouton"; static uint8_t text_IT_SetFactoryDefaults[] = "Impostazioni pulsante"; static uint8_t text_ES_SetFactoryDefaults[] = "Restablecer ajustes de fábrica"; // Menu SYS2 sub static uint8_t text_EN_SetSampleIndex[] = "Analyse log memory"; static uint8_t text_DE_SetSampleIndex[] = "Prüfe Logbuchspeicher"; -static uint8_t text_FR_SetSampleIndex[] = "Maintain log memory"; -static uint8_t text_IT_SetSampleIndex[] = "Maintain log memory"; -static uint8_t text_ES_SetSampleIndex[] = "Maintain log memory"; +static uint8_t text_FR_SetSampleIndex[] = "Vérifier carnet"; +static uint8_t text_IT_SetSampleIndex[] = "Controllare registro"; +static uint8_t text_ES_SetSampleIndex[] = "Comprobar del diario"; // Menu SYS2 sub @@ -730,7 +748,7 @@ // Surface warning static uint8_t text_EN_Fonts[] = "fonts"; // Character fonts!! -static uint8_t text_DE_Fonts[] = ""; +static uint8_t text_DE_Fonts[] = "schrift"; static uint8_t text_FR_Fonts[] = "polices"; static uint8_t text_IT_Fonts[] = "Carattere"; static uint8_t text_ES_Fonts[] = "Tipos de letra"; @@ -766,7 +784,7 @@ static uint8_t text_DE_CompassHeading[] = "Kompasskurs"; static uint8_t text_FR_CompassHeading[] = "Cap"; static uint8_t text_IT_CompassHeading[] = "Direzione bussola"; -static uint8_t text_ES_CompassHeading[] = "Rumbo brújula"; +static uint8_t text_ES_CompassHeading[] = "Rumbo brujula"; // Dive Menu static uint8_t text_EN_CalibView[] = "Calibrate View"; @@ -803,9 +821,22 @@ 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[] = "Poumon opposé"; +static uint8_t text_IT_CounterLung[] = "Contropolmone"; +static uint8_t text_ES_CounterLung[] = "Contrapulmón"; + +static uint8_t text_EN_Pressure[] = "Pressure"; +static uint8_t text_DE_Pressure[] = "Druck"; +static uint8_t text_FR_Pressure[] = "Pression"; +static uint8_t text_IT_Pressure[] = "Pressione"; +static uint8_t text_ES_Pressure[] = "Presión"; + + // Menu SIM static uint8_t text_EN_Simulator[] = "Simulator"; -static uint8_t text_DE_Simulator[] = ""; +static uint8_t text_DE_Simulator[] = "Simulator"; static uint8_t text_FR_Simulator[] = "Simulateur"; static uint8_t text_IT_Simulator[] = "Simulazione"; static uint8_t text_ES_Simulator[] = "Simulador"; @@ -856,7 +887,7 @@ static uint8_t text_EN_SimDecTo[] = "Dec to"; static uint8_t text_DE_SimDecTo[] = "Abst."; static uint8_t text_FR_SimDecTo[] = "Desc a"; -static uint8_t text_IT_SimDecTo[] = ""; +static uint8_t text_IT_SimDecTo[] = "Scen a"; static uint8_t text_ES_SimDecTo[] = "Desc a"; // Menu SIM sub @@ -870,13 +901,13 @@ static uint8_t text_EN_SimAscTo[] = "Asc to"; static uint8_t text_DE_SimAscTo[] = "Aufst."; static uint8_t text_FR_SimAscTo[] = "Rem. a"; -static uint8_t text_IT_SimAscTo[] = ""; +static uint8_t text_IT_SimAscTo[] = "Asce a"; static uint8_t text_ES_SimAscTo[] = "Asc a"; // Menu SIM sub static uint8_t text_EN_SimSurface[] = "Surface"; static uint8_t text_DE_SimSurface[] = "Oberfl."; -static uint8_t text_FR_SimSurface[] = ""; // Surface +static uint8_t text_FR_SimSurface[] = "Surface"; static uint8_t text_IT_SimSurface[] = "Superficie"; static uint8_t text_ES_SimSurface[] = "Superficie"; @@ -918,21 +949,21 @@ // static uint8_t text_EN_SpecialDiveGas[] = "Free configurable"; static uint8_t text_DE_SpecialDiveGas[] = "Frei einstellbar"; -static uint8_t text_FR_SpecialDiveGas[] = ""; +static uint8_t text_FR_SpecialDiveGas[] = "Réglage libre"; static uint8_t text_IT_SpecialDiveGas[] = "Configurazione libera"; static uint8_t text_ES_SpecialDiveGas[] = "Configuración libre"; // Dive Menu static uint8_t text_EN_SpecialDiveGasMenu[] = "Lost gas and extra gas"; static uint8_t text_DE_SpecialDiveGasMenu[] = "Verlorene Gase und Extra-Gas"; -static uint8_t text_FR_SpecialDiveGasMenu[] = ""; +static uint8_t text_FR_SpecialDiveGasMenu[] = "Gaz perdus et extra-gaz"; static uint8_t text_IT_SpecialDiveGasMenu[] = "Gas perso e extra gas"; static uint8_t text_ES_SpecialDiveGasMenu[] = "Gas perdido y gas extra"; // Dive Menu (CCR mode) static uint8_t text_EN_SpecialDiveGasMenuCCR[] = "Lost Gas"; static uint8_t text_DE_SpecialDiveGasMenuCCR[] = "Verlorene Gase"; -static uint8_t text_FR_SpecialDiveGasMenuCCR[] = ""; +static uint8_t text_FR_SpecialDiveGasMenuCCR[] = "Gaz perdus"; static uint8_t text_IT_SpecialDiveGasMenuCCR[] = "Gas perso"; static uint8_t text_ES_SpecialDiveGasMenuCCR[] = "Gas perdido"; @@ -946,20 +977,20 @@ // Dive Menu (CCR mode) static uint8_t text_EN_AutomaticSP[] = "Switch SP automatically"; static uint8_t text_DE_AutomaticSP[] = "Automatischer SP Wechsel"; -static uint8_t text_FR_AutomaticSP[] = ""; -static uint8_t text_IT_AutomaticSP[] = ""; -static uint8_t text_ES_AutomaticSP[] = ""; +static uint8_t text_FR_AutomaticSP[] = "Changement automatique de SP"; +static uint8_t text_IT_AutomaticSP[] = "Cambio automatico di SP"; +static uint8_t text_ES_AutomaticSP[] = "Cambio automático de SP"; // Warning static uint8_t text_EN_WarnDecoMissed[] = "Deco stop"; -static uint8_t text_DE_WarnDecoMissed[] = "Deco Stopp"; -static uint8_t text_FR_WarnDecoMissed[] = ""; +static uint8_t text_DE_WarnDecoMissed[] = "Deko Stopp"; +static uint8_t text_FR_WarnDecoMissed[] = "Palier déco"; static uint8_t text_IT_WarnDecoMissed[] = "Deco stop"; static uint8_t text_ES_WarnDecoMissed[] = "Deco stop"; // Warning static uint8_t text_EN_WarnFallback[] = "Fallback"; -static uint8_t text_DE_WarnFallback[] = ""; +static uint8_t text_DE_WarnFallback[] = "Fallback"; static uint8_t text_FR_WarnFallback[] = "Fallback"; // NEED to more specific here I guess... static uint8_t text_IT_WarnFallback[] = "Fallback"; static uint8_t text_ES_WarnFallback[] = "Fallback"; @@ -1015,7 +1046,7 @@ // Tissue Graph static uint8_t text_EN_Helium[] = "Helium"; -static uint8_t text_DE_Helium[] = ""; +static uint8_t text_DE_Helium[] = "Helium"; static uint8_t text_FR_Helium[] = "Hélium"; static uint8_t text_IT_Helium[] = "Helio"; static uint8_t text_ES_Helium[] = "Helio"; @@ -1039,7 +1070,7 @@ static uint8_t text_DE_SafetyStop2[] = "Sicherheit"; static uint8_t text_FR_SafetyStop2[] = "Palier sécurité"; static uint8_t text_IT_SafetyStop2[] = "Sicurezza"; -static uint8_t text_ES_SafetyStop2[] = "Parada de seguridad"; +static uint8_t text_ES_SafetyStop2[] = "Parada seguridad"; // Surface mode static uint8_t text_EN_noFly[] = "noFly"; @@ -1060,7 +1091,7 @@ static uint8_t text_DE_TimeSinceLastDive[] = "Tauchpause"; static uint8_t text_FR_TimeSinceLastDive[] = "Intervalle"; static uint8_t text_IT_TimeSinceLastDive[] = "Ultima immersione"; -static uint8_t text_ES_TimeSinceLastDive[] = "Última inmersión"; +static uint8_t text_ES_TimeSinceLastDive[] = "Ultima inmersión"; // Button label (tiny line) static uint8_t text_EN_ButtonLogbook[] = "Logbook"; @@ -1081,7 +1112,7 @@ static uint8_t text_DE_ButtonMenu[] = "Menü"; static uint8_t text_FR_ButtonMenu[] = "Menu"; static uint8_t text_IT_ButtonMenu[] = "Menu"; -static uint8_t text_ES_ButtonMenu[] = "Menú"; +static uint8_t text_ES_ButtonMenu[] = "Menu"; // Button label (tiny line) static uint8_t text_EN_ButtonBack[] = "Back"; @@ -1122,8 +1153,8 @@ static uint8_t text_EN_SimFollowDecoStops[] = "Ascent follows decostops"; static uint8_t text_DE_SimFollowDecoStops[] = "Sim-Aufstieg folgt Stopps"; static uint8_t text_FR_SimFollowDecoStops[] = "Remonté selon paliers"; -static uint8_t text_IT_SimFollowDecoStops[] = ""; -static uint8_t text_ES_SimFollowDecoStops[] = "Ascenso según paradas deco"; +static uint8_t text_IT_SimFollowDecoStops[] = "Sim ascenso sigue paradas"; +static uint8_t text_ES_SimFollowDecoStops[] = "Ascenso segUn paradas deco"; // Menu SYS1 static uint8_t text_EN_Bluetooth[] = "Bluetooth"; @@ -1155,15 +1186,15 @@ // Customview Header static uint8_t text_EN_Gaslist[] = "Gaslist OC"; -static uint8_t text_DE_Gaslist[] = ""; +static uint8_t text_DE_Gaslist[] = "OC Gasliste"; static uint8_t text_FR_Gaslist[] = "Liste gaz OC"; static uint8_t text_IT_Gaslist[] = "Lista gas OC"; -static uint8_t text_ES_Gaslist[] = "lista de gases OC"; +static uint8_t text_ES_Gaslist[] = "lista gases OC"; // Customview Header static uint8_t text_EN_Info[] = "Info"; -static uint8_t text_DE_Info[] = ""; -static uint8_t text_FR_Info[] = ""; // Info +static uint8_t text_DE_Info[] = "Info"; +static uint8_t text_FR_Info[] = "Info"; static uint8_t text_IT_Info[] = "Info"; static uint8_t text_ES_Info[] = "Info"; @@ -1177,9 +1208,9 @@ // Customview Header static uint8_t text_EN_Charging[] = "Charging"; static uint8_t text_DE_Charging[] = "Ladezyklus"; -static uint8_t text_FR_Charging[] = ""; -static uint8_t text_IT_Charging[] = ""; -static uint8_t text_ES_Charging[] = ""; +static uint8_t text_FR_Charging[] = "Cycle de charge"; +static uint8_t text_IT_Charging[] = "Ciclo di carica"; +static uint8_t text_ES_Charging[] = "Ciclo de carga"; // Menu SYS2 sub Information static uint8_t text_EN_Usage_Battery[] = "Battery life"; @@ -1228,7 +1259,7 @@ static uint8_t text_DE_NumberOfDives[] = "Anzahl Tauchgänge (max. Tiefe)"; static uint8_t text_FR_NumberOfDives[] = "Nombre total de plongées (prof. max)"; static uint8_t text_IT_NumberOfDives[] = "Numero totale di immersioni (prof. max)"; -static uint8_t text_ES_NumberOfDives[] = "Número total de inmersiones (prof. max)"; +static uint8_t text_ES_NumberOfDives[] = "NUmero total de inmersiones (prof. max)"; // Menu SYS2 sub Information static uint8_t text_EN_AmbientTemperature[] = "Ambient temperature range"; @@ -1302,40 +1333,40 @@ static uint8_t text_ES_HUDBattery[] = "Carga del HUD"; static uint8_t text_EN_SensorDetect[] = "Auto detection"; -static uint8_t text_DE_SensorDetect[] = "Sensor suchen"; -static uint8_t text_FR_SensorDetect[] = ""; -static uint8_t text_IT_SensorDetect[] = ""; -static uint8_t text_ES_SensorDetect[] = ""; +static uint8_t text_DE_SensorDetect[] = "Sensoren suchen"; +static uint8_t text_FR_SensorDetect[] = "Chercher capteurs"; +static uint8_t text_IT_SensorDetect[] = "Ricerca sensori"; +static uint8_t text_ES_SensorDetect[] = "BUsqueda sensores"; -static uint8_t text_EN_O2Calib[] = "Calibrate"; +static uint8_t text_EN_O2Calib[] = "Calibration"; static uint8_t text_DE_O2Calib[] = "Kalibrierung"; -static uint8_t text_FR_O2Calib[] = ""; -static uint8_t text_IT_O2Calib[] = ""; -static uint8_t text_ES_O2Calib[] = ""; +static uint8_t text_FR_O2Calib[] = "Calibrage"; +static uint8_t text_IT_O2Calib[] = "Calibrazione"; +static uint8_t text_ES_O2Calib[] = "Calibración"; static uint8_t text_EN_O2Interface[] = "O2 Interface"; static uint8_t text_DE_O2Interface[] = "O2 Interface"; -static uint8_t text_FR_O2Interface[] = ""; -static uint8_t text_IT_O2Interface[] = ""; -static uint8_t text_ES_O2Interface[] = ""; +static uint8_t text_FR_O2Interface[] = "Interface O2"; +static uint8_t text_IT_O2Interface[] = "Interfaccia O2"; +static uint8_t text_ES_O2Interface[] = "Interfaz O2"; static uint8_t text_EN_O2IFOptic[] = "optical"; static uint8_t text_DE_O2IFOptic[] = "optisch"; -static uint8_t text_FR_O2IFOptic[] = ""; -static uint8_t text_IT_O2IFOptic[] = ""; -static uint8_t text_ES_O2IFOptic[] = ""; +static uint8_t text_FR_O2IFOptic[] = "optique"; +static uint8_t text_IT_O2IFOptic[] = "ottico"; +static uint8_t text_ES_O2IFOptic[] = "óptico"; static uint8_t text_EN_O2IFAnalog[] = "analog"; static uint8_t text_DE_O2IFAnalog[] = "analog"; -static uint8_t text_FR_O2IFAnalog[] = ""; -static uint8_t text_IT_O2IFAnalog[] = ""; -static uint8_t text_ES_O2IFAnalog[] = ""; +static uint8_t text_FR_O2IFAnalog[] = "analogique"; +static uint8_t text_IT_O2IFAnalog[] = "analogico"; +static uint8_t text_ES_O2IFAnalog[] = "analógico"; static uint8_t text_EN_O2IFDigital[] = "digital"; static uint8_t text_DE_O2IFDigital[] = "digital"; -static uint8_t text_FR_O2IFDigital[] = ""; -static uint8_t text_IT_O2IFDigital[] = ""; -static uint8_t text_ES_O2IFDigital[] = ""; +static uint8_t text_FR_O2IFDigital[] = "digitale"; +static uint8_t text_IT_O2IFDigital[] = "digital"; +static uint8_t text_ES_O2IFDigital[] = "digital"; // Menu SYS1 sub (buttons) static uint8_t text_EN_LowerIsLess[] = "Lower is less sensitive"; @@ -1347,9 +1378,9 @@ // Dive Mode YELLOW TEXT under Customview static uint8_t text_EN_DiveMenuQ[] = " Menu? "; static uint8_t text_DE_DiveMenuQ[] = " Menü? "; -static uint8_t text_FR_DiveMenuQ[] = ""; -static uint8_t text_IT_DiveMenuQ[] = "Menu?"; -static uint8_t text_ES_DiveMenuQ[] = "Menú"; +static uint8_t text_FR_DiveMenuQ[] = " Menu "; +static uint8_t text_IT_DiveMenuQ[] = " Menu? "; +static uint8_t text_ES_DiveMenuQ[] = " Menu "; // Dive Mode YELLOW TEXT under Customview static uint8_t text_EN_DiveQuitQ[] = " Quit? "; @@ -1361,7 +1392,7 @@ // Dive Mode YELLOW TEXT under Customview static uint8_t text_EN_DiveBearingQ[] = "Bearing"; static uint8_t text_DE_DiveBearingQ[] = "Peilung"; -static uint8_t text_FR_DiveBearingQ[] = ""; +static uint8_t text_FR_DiveBearingQ[] = "Gisement"; static uint8_t text_IT_DiveBearingQ[] = ""; static uint8_t text_ES_DiveBearingQ[] = "Rumbo"; @@ -1382,15 +1413,15 @@ // Menu SYS2 static uint8_t text_EN_ExtraBigFont[] = "Optional"; static uint8_t text_DE_ExtraBigFont[] = "Optional"; -static uint8_t text_FR_ExtraBigFont[] = "si"; -static uint8_t text_IT_ExtraBigFont[] = "si"; -static uint8_t text_ES_ExtraBigFont[] = "si"; +static uint8_t text_FR_ExtraBigFont[] = "En option"; +static uint8_t text_IT_ExtraBigFont[] = "Opzionale"; +static uint8_t text_ES_ExtraBigFont[] = "Opcional"; static uint8_t text_EN_ExtraBFActive[] = "Start screen"; -static uint8_t text_DE_ExtraBFActive[] = "Start Bildschirm"; -static uint8_t text_FR_ExtraBFActive[] = ""; -static uint8_t text_IT_ExtraBFActive[] = ""; -static uint8_t text_ES_ExtraBFActive[] = ""; +static uint8_t text_DE_ExtraBFActive[] = "Startbildschirm"; +static uint8_t text_FR_ExtraBFActive[] = "Écran démarrage"; +static uint8_t text_IT_ExtraBFActive[] = "Schermata iniziale"; +static uint8_t text_ES_ExtraBFActive[] = "Pantalla de inicio"; // Menu SYS2 (future feature) static uint8_t text_EN_ExtraDecoGame[] = "Deco game"; @@ -1441,7 +1472,7 @@ static uint8_t text_EN_DecoDataLost[] = "Decompression data will be lost"; static uint8_t text_DE_DecoDataLost[] = "Dekompressionsdaten verloren!"; static uint8_t text_FR_DecoDataLost[] = "RaZ de la décompression"; // RaZ -static uint8_t text_IT_DecoDataLost[] = ""; +static uint8_t text_IT_DecoDataLost[] = "Dati di decompressione persi!"; static uint8_t text_ES_DecoDataLost[] = "Se perderá la información de descompresión"; // Menu SYS1 sub and Dive Menu @@ -1459,9 +1490,9 @@ // Menu SYS1, sub static uint8_t text_EN_SensorList[] = "Sensor"; -static uint8_t text_DE_SensorList[] = ""; -static uint8_t text_FR_SensorList[] = "Cellule"; -static uint8_t text_IT_SensorList[] = ""; +static uint8_t text_DE_SensorList[] = "Sensor"; +static uint8_t text_FR_SensorList[] = "Capteur"; +static uint8_t text_IT_SensorList[] = "Sensore"; static uint8_t text_ES_SensorList[] = "Sensor"; // Menu SYS1, sub @@ -1498,15 +1529,15 @@ static uint8_t text_EN_ApneaTotal[] = "total"; static uint8_t text_DE_ApneaTotal[] = "gesamt"; -static uint8_t text_FR_ApneaTotal[] = ""; +static uint8_t text_FR_ApneaTotal[] = "total"; static uint8_t text_IT_ApneaTotal[] = "Completo"; static uint8_t text_ES_ApneaTotal[] = "Total"; static uint8_t text_EN_ApneaLast[] = "last"; static uint8_t text_DE_ApneaLast[] = "letzter"; static uint8_t text_FR_ApneaLast[] = "dernier"; -static uint8_t text_IT_ApneaLast[] = ""; -static uint8_t text_ES_ApneaLast[] = "último"; +static uint8_t text_IT_ApneaLast[] = "ultimo"; +static uint8_t text_ES_ApneaLast[] = "Ultimo"; static uint8_t text_EN_ApneaSurface[] = "Surface time"; static uint8_t text_DE_ApneaSurface[] = "Oberflächenzeit"; @@ -1531,6 +1562,7 @@ static uint8_t text_FR_FocusSpotSize[] = ""; static uint8_t text_IT_FocusSpotSize[] = ""; static uint8_t text_ES_FocusSpotSize[] = ""; + /* static uint8_t text_EN_ApneaCount[] = ""; static uint8_t text_DE_ApneaCount[] = ""; @@ -1560,7 +1592,7 @@ static uint8_t text_EN_Default[] = "Default"; -static uint8_t text_DE_Default[] = ""; +static uint8_t text_DE_Default[] = "Standard"; static uint8_t text_FR_Default[] = "Défaut"; static uint8_t text_IT_Default[] = "Standard"; static uint8_t text_ES_Default[] = "Por defecto"; @@ -1572,7 +1604,7 @@ static uint8_t text_ES_LiterproMinute[] = "Litros/Minuto"; static uint8_t text_EN_Reserve[] = "Reserve"; -static uint8_t text_DE_Reserve[] = ""; +static uint8_t text_DE_Reserve[] = "Reserve"; static uint8_t text_FR_Reserve[] = "Réserve"; static uint8_t text_IT_Reserve[] = "Riserva"; static uint8_t text_ES_Reserve[] = "Reserva"; @@ -1580,7 +1612,7 @@ static uint8_t text_EN_Daylightsaving[] = "Daylight sav."; static uint8_t text_DE_Daylightsaving[] = "Sommerzeit"; static uint8_t text_FR_Daylightsaving[] = "Heure d'été"; -static uint8_t text_IT_Daylightsaving[] = ""; +static uint8_t text_IT_Daylightsaving[] = "L'ora legale"; static uint8_t text_ES_Daylightsaving[] = "Horario de verano"; static uint8_t text_EN_ShowDebug[] = "Debug info"; @@ -1589,11 +1621,11 @@ static uint8_t text_IT_ShowDebug[] = "Informazioni Debug"; static uint8_t text_ES_ShowDebug[] = "Información de depuración"; -static uint8_t text_EN_SimTravelGas[] = "Travel Gas"; -static uint8_t text_DE_SimTravelGas[] = "Reise Gas"; -static uint8_t text_FR_SimTravelGas[] = "Gaz Travel"; -static uint8_t text_IT_SimTravelGas[] = "Gas da viaggio"; -static uint8_t text_ES_SimTravelGas[] = "Gas de viaje"; +static uint8_t text_EN_SimTravelGas[] = "Work Gas"; +static uint8_t text_DE_SimTravelGas[] = "Arbeitsgas"; +static uint8_t text_FR_SimTravelGas[] = "Gaz Travail"; +static uint8_t text_IT_SimTravelGas[] = "Gas da Lavaro"; +static uint8_t text_ES_SimTravelGas[] = "Gas de Labor"; static uint8_t text_EN_SimDecoGas[] = "Deco Gas"; static uint8_t text_DE_SimDecoGas[] = "Deko Gas"; @@ -1745,6 +1777,12 @@ static uint8_t text_IT_DecoTTS[] = ""; static uint8_t text_ES_DecoTTS[] = ""; +static uint8_t text_EN_SlowExit[] = "Slow exit"; +static uint8_t text_DE_SlowExit[] = "Ausstieg"; +static uint8_t text_FR_SlowExit[] = ""; +static uint8_t text_IT_SlowExit[] = "Ascensione"; +static uint8_t text_ES_SlowExit[] = "Salida lenta"; + static uint8_t text_EN_ScrubTime[] = "Scrubber time"; static uint8_t text_DE_ScrubTime[] = "Kalkstandzeit"; static uint8_t text_FR_ScrubTime[] = "Scrubber time"; @@ -1801,9 +1839,9 @@ static uint8_t text_EN_KeyLock[] = "Key lock"; static uint8_t text_DE_KeyLock[] = "Tastensperre"; -static uint8_t text_FR_KeyLock[] = ""; -static uint8_t text_IT_KeyLock[] = ""; -static uint8_t text_ES_KeyLock[] = ""; +static uint8_t text_FR_KeyLock[] = "Verrouillage du clavier"; +static uint8_t text_IT_KeyLock[] = "Serratura a chiave"; +static uint8_t text_ES_KeyLock[] = "Cerradura de llave"; static uint8_t text_EN_NotCalibrated[] = "not calibrated"; static uint8_t text_DE_NotCalibrated[] = "nicht kalibriert"; @@ -1901,12 +1939,72 @@ static uint8_t text_IT_Finished[] = "Finito"; static uint8_t text_ES_Finished[] = "Terminado"; +static uint8_t text_EN_Position[] = "Position"; +static uint8_t text_DE_Position[] = "Position"; +static uint8_t text_FR_Position[] = ""; +static uint8_t text_IT_Position[] = ""; +static uint8_t text_ES_Position[] = ""; + +static uint8_t text_EN_VpmTable[] = "VPM table mode"; +static uint8_t text_DE_VpmTable[] = "VPM Tabellenmodus"; +static uint8_t text_FR_VpmTable[] = ""; +static uint8_t text_IT_VpmTable[] = ""; +static uint8_t text_ES_VpmTable[] = ""; + static uint8_t text_EN_Page[] = "Page"; static uint8_t text_DE_Page[] = "Blättern"; static uint8_t text_FR_Page[] = "Défiler"; static uint8_t text_IT_Page[] = "Scorrere"; static uint8_t text_ES_Page[] = "Desplazarse"; +static uint8_t text_EN_Current[] = "Current"; +static uint8_t text_DE_Current[] = "Aktuell"; +static uint8_t text_FR_Current[] = "Actuel"; +static uint8_t text_IT_Current[] = "Attuale"; +static uint8_t text_ES_Current[] = "Actual"; + +static uint8_t text_EN_Log[] = "Log"; +static uint8_t text_DE_Log[] = "Aufzeichnen"; +static uint8_t text_FR_Log[] = "Enregistrer"; +static uint8_t text_IT_Log[] = "Registrare"; +static uint8_t text_ES_Log[] = "Registrar"; + +static uint8_t text_EN_DDMMYY[] = "DDMMYY"; +static uint8_t text_DE_DDMMYY[] = "TTMMJJ"; +static uint8_t text_FR_DDMMYY[] = ""; +static uint8_t text_IT_DDMMYY[] = ""; +static uint8_t text_ES_DDMMYY[] = ""; + +static uint8_t text_EN_MMDDYY[] = "MMDDYY"; +static uint8_t text_DE_MMDDYY[] = "MMTTJJ"; +static uint8_t text_FR_MMDDYY[] = ""; +static uint8_t text_IT_MMDDYY[] = ""; +static uint8_t text_ES_MMDDYY[] = ""; + +static uint8_t text_EN_YYMMDD[] = "YYMMDD"; +static uint8_t text_DE_YYMMDD[] = "JJMMTT"; +static uint8_t text_FR_YYMMDD[] = ""; +static uint8_t text_IT_YYMMDD[] = ""; +static uint8_t text_ES_YYMMDD[] = ""; + +static uint8_t text_EN_TIMEZONE[] = "Time zone"; +static uint8_t text_DE_TIMEZONE[] = "Zeitzone"; +static uint8_t text_FR_TIMEZONE[] = ""; +static uint8_t text_IT_TIMEZONE[] = ""; +static uint8_t text_ES_TIMEZONE[] = ""; + +static uint8_t text_EN_BUZZER[] = "Buzzer"; +static uint8_t text_DE_BUZZER[] = "Vibration"; +static uint8_t text_FR_BUZZER[] = ""; +static uint8_t text_IT_BUZZER[] = ""; +static uint8_t text_ES_BUZZER[] = ""; + +static uint8_t text_EN_Reverse[] = "Reverse"; +static uint8_t text_DE_Reverse[] = "Umkehren"; +static uint8_t text_FR_Reverse[] = "Inverser"; +static uint8_t text_IT_Reverse[] = "Invertire"; +static uint8_t text_ES_Reverse[] = "Invertir"; + /* Lookup Table -------------------------------------------------------------*/ const tText text_array[] = @@ -1975,6 +2073,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}}, @@ -1996,7 +2095,7 @@ {(uint8_t)TXT_PSCRLungRatio, {text_EN_LungRatio, text_DE_LungRatio, text_FR_LungRatio, text_IT_LungRatio, text_ES_LungRatio}}, {(uint8_t)TXT_SimPpo2, {text_EN_SimPpo2, text_DE_SimPpo2, text_FR_SimPpo2, text_IT_SimPpo2, text_ES_SimPpo2}}, {(uint8_t)TXT_CO2Sensor, {text_EN_CO2Sensor, text_DE_CO2Sensor, text_FR_CO2Sensor, text_IT_CO2Sensor, text_ES_CO2Sensor}}, - {(uint8_t)TXT_ButtonLock, {text_EN_KeyLock, text_DE_KeyLock, text_FR_KeyLock, text_IT_KeyLock, text_ES_KeyLock}}, + {(uint8_t)TXT_ButtonLock, {text_EN_KeyLock, text_DE_KeyLock, text_FR_KeyLock, text_IT_KeyLock, text_ES_KeyLock}}, }; const tText text_array2[] = @@ -2020,7 +2119,7 @@ {(uint8_t)TXT2BYTE_SetMarkerShort, {text_EN_SetMarkerShort, text_DE_SetMarkerShort, text_FR_SetMarkerShort, text_IT_SetMarkerShort, text_ES_SetMarkerShort}}, {(uint8_t)TXT2BYTE_CheckMarker, {text_EN_CheckMarker, text_DE_CheckMarker, text_FR_CheckMarker, text_IT_CheckMarker, text_ES_CheckMarker}}, {(uint8_t)TXT2BYTE_CompassHeading, {text_EN_CompassHeading, text_DE_CompassHeading, text_FR_CompassHeading, text_IT_CompassHeading, text_ES_CompassHeading}}, - {(uint8_t)TXT2BYTE_CalibView, {text_EN_CalibView, text_DE_CalibView, text_FR_CalibView, text_IT_CalibView, text_ES_CalibView}}, + {(uint8_t)TXT2BYTE_CalibView, {text_EN_CalibView, text_DE_CalibView, text_FR_CalibView, text_IT_CalibView, text_ES_CalibView}}, {(uint8_t)TXT2BYTE_IndicateFrame, {text_EN_IndicateFrame, text_DE_IndicateFrame, text_FR_IndicateFrame, text_IT_IndicateFrame, text_ES_IndicateFrame}}, {(uint8_t)TXT2BYTE_BoostBacklight, {text_EN_BoostBacklight, text_DE_BoostBacklight, text_FR_BoostBacklight, text_IT_BoostBacklight, text_ES_BoostBacklight}}, {(uint8_t)TXT2BYTE_FocusSpotSize, {text_EN_FocusSpotSize, text_DE_FocusSpotSize, text_FR_FocusSpotSize, text_IT_FocusSpotSize, text_ES_FocusSpotSize}}, @@ -2049,6 +2148,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 +2241,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}}, @@ -2165,6 +2266,7 @@ {(uint8_t)TXT2BYTE_Navigation, {text_EN_Navigation, text_DE_Navigation, text_FR_Navigation, text_IT_Navigation, text_ES_Navigation}}, {(uint8_t)TXT2BYTE_DepthData, {text_EN_DepthData, text_DE_DepthData, text_FR_DepthData, text_IT_DepthData, text_ES_DepthData}}, {(uint8_t)TXT2BYTE_DecoTTS, {text_EN_DecoTTS, text_DE_DecoTTS, text_FR_DecoTTS, text_IT_DecoTTS, text_ES_DecoTTS}}, + {(uint8_t)TXT2BYTE_SlowExit, {text_EN_SlowExit, text_DE_SlowExit, text_FR_SlowExit, text_IT_SlowExit, text_ES_SlowExit}}, {(uint8_t)TXT2BYTE_Minimum, {text_EN_Minimum, text_DE_Minimum, text_FR_Minimum, text_IT_Minimum, text_ES_Minimum}}, {(uint8_t)TXT2BYTE_Normal, {text_EN_Normal, text_DE_Normal, text_FR_Normal, text_IT_Normal, text_ES_Normal}}, @@ -2173,11 +2275,11 @@ {(uint8_t)TXT2BYTE_CheckSettings, {text_EN_CheckSettings, text_DE_CheckSettings, text_FR_CheckSettings, text_IT_CheckSettings, text_ES_CheckSettings}}, {(uint8_t)TXT2BYTE_NotCalibrated, {text_EN_NotCalibrated, text_DE_NotCalibrated, text_FR_NotCalibrated, text_IT_NotCalibrated, text_ES_NotCalibrated}}, - {(uint8_t)TXT2BYTE_CcrSummary, {text_EN_CcrSummary, text_DE_CcrSummary, text_FR_CcrSummary, text_IT_CcrSummary, text_ES_CcrSummary}}, - {(uint8_t)TXT2BYTE_Setpoint, {text_EN_Setpoint, text_DE_Setpoint, text_FR_Setpoint, text_IT_Setpoint, text_ES_Setpoint}}, - {(uint8_t)TXT2BYTE_Scrubber, {text_EN_Scrubber, text_DE_Scrubber, text_FR_Scrubber, text_IT_Scrubber, text_ES_Scrubber}}, + {(uint8_t)TXT2BYTE_CcrSummary, {text_EN_CcrSummary, text_DE_CcrSummary, text_FR_CcrSummary, text_IT_CcrSummary, text_ES_CcrSummary}}, + {(uint8_t)TXT2BYTE_Setpoint, {text_EN_Setpoint, text_DE_Setpoint, text_FR_Setpoint, text_IT_Setpoint, text_ES_Setpoint}}, + {(uint8_t)TXT2BYTE_Scrubber, {text_EN_Scrubber, text_DE_Scrubber, text_FR_Scrubber, text_IT_Scrubber, text_ES_Scrubber}}, {(uint8_t)TXT2BYTE_BailoutShort, {text_EN_BailoutShort, text_DE_BailoutShort, text_FR_BailoutShort, text_IT_BailoutShort, text_ES_BailoutShort}}, - {(uint8_t)TXT2BYTE_LoopShort, {text_EN_LoopShort, text_DE_LoopShort, text_FR_LoopShort, text_IT_LoopShort, text_ES_LoopShort}}, + {(uint8_t)TXT2BYTE_LoopShort, {text_EN_LoopShort, text_DE_LoopShort, text_FR_LoopShort, text_IT_LoopShort, text_ES_LoopShort}}, {(uint8_t)TXT2BYTE_SetpointShort, {text_EN_SetpointShort, text_DE_SetpointShort, text_FR_SetpointShort, text_IT_SetpointShort, text_ES_SetpointShort}}, {(uint8_t)TXT2BYTE_SetpointLow, {text_EN_SetpointLow, text_DE_SetpointLow, text_FR_SetpointLow, text_IT_SetpointLow, text_ES_SetpointLow}}, @@ -2185,16 +2287,38 @@ {(uint8_t)TXT2BYTE_SetpointDeco, {text_EN_SetpointDeco, text_DE_SetpointDeco, text_FR_SetpointDeco, text_IT_SetpointDeco, text_ES_SetpointDeco}}, {(uint8_t)TXT2BYTE_SetpointDelayed, {text_EN_SetpointDelayed, text_DE_SetpointDelayed, text_FR_SetpointDelayed, text_IT_SetpointDelayed, text_ES_SetpointDelayed}}, - {(uint8_t)TXT2BYTE_Enabled, {text_EN_Enabled, text_DE_Enabled, text_FR_Enabled, text_IT_Enabled, text_ES_Enabled}}, - {(uint8_t)TXT2BYTE_Custom, {text_EN_Custom, text_DE_Custom, text_FR_Custom, text_IT_Custom, text_ES_Custom}}, + {(uint8_t)TXT2BYTE_Enabled, {text_EN_Enabled, text_DE_Enabled, text_FR_Enabled, text_IT_Enabled, text_ES_Enabled}}, + {(uint8_t)TXT2BYTE_Custom, {text_EN_Custom, text_DE_Custom, text_FR_Custom, text_IT_Custom, text_ES_Custom}}, + + {(uint8_t)TXT2BYTE_Set, {text_EN_Set, text_DE_Set, text_FR_Set, text_IT_Set, text_ES_Set}}, + {(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_Set, {text_EN_Set, text_DE_Set, text_FR_Set, text_IT_Set, text_ES_Set}}, - {(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}}, + + {(uint8_t)TXT2BYTE_Position, {text_EN_Position, text_DE_Position, text_FR_Position, text_IT_Position, text_ES_Position}}, + {(uint8_t)TXT2BYTE_VpmTable, {text_EN_VpmTable, text_DE_VpmTable, text_FR_VpmTable, text_IT_VpmTable, text_ES_VpmTable}}, - {(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}}, + {(uint8_t)TXT2BYTE_Page, {text_EN_Page, text_DE_Page, text_FR_Page, text_IT_Page, text_ES_Page}}, + + {(uint8_t)TXT2BYTE_Current, {text_EN_Current, text_DE_Current, text_FR_Current, text_IT_Current, text_ES_Current}}, + {(uint8_t)TXT2BYTE_Log, {text_EN_Log, text_DE_Log, text_FR_Log, text_IT_Log, text_ES_Log}}, + {(uint8_t)TXT2BYTE_DDMMYY, {text_EN_DDMMYY, text_DE_DDMMYY, text_FR_DDMMYY, text_IT_DDMMYY, text_ES_DDMMYY}}, + {(uint8_t)TXT2BYTE_MMDDYY, {text_EN_MMDDYY, text_DE_MMDDYY, text_FR_MMDDYY, text_IT_MMDDYY, text_ES_MMDDYY}}, + {(uint8_t)TXT2BYTE_YYMMDD, {text_EN_YYMMDD, text_DE_YYMMDD, text_FR_YYMMDD, text_IT_YYMMDD, text_ES_YYMMDD}}, + {(uint8_t)TXT2BYTE_TIMEZONE, {text_EN_TIMEZONE, text_DE_TIMEZONE, text_FR_TIMEZONE, text_IT_TIMEZONE, text_ES_TIMEZONE}}, - {(uint8_t)TXT2BYTE_Page, {text_EN_Page, text_DE_Page, text_FR_Page, text_IT_Page, text_ES_Page}}, + {(uint8_t)TXT2BYTE_BUZZER, {text_EN_BUZZER, text_DE_BUZZER, text_FR_BUZZER, text_IT_BUZZER, text_ES_BUZZER}}, + + {(uint8_t)TXT2BYTE_Current, {text_EN_Current, text_DE_Current, text_FR_Current, text_IT_Current, text_ES_Current}}, + {(uint8_t)TXT2BYTE_Log, {text_EN_Log, text_DE_Log, text_FR_Log, text_IT_Log, text_ES_Log}}, + {(uint8_t)TXT2BYTE_Reverse, {text_EN_Reverse, text_DE_Reverse, text_FR_Reverse, text_IT_Reverse, text_ES_Reverse}}, + + + }; diff -r f7318457df4d -r c6c781a2e85b Discovery/Src/vpm.c --- a/Discovery/Src/vpm.c Tue Aug 13 13:24:54 2024 +0200 +++ b/Discovery/Src/vpm.c Tue Feb 11 18:12:00 2025 +0100 @@ -132,6 +132,9 @@ static const _Bool vpm_b = true; +static SvpmTableState vpmTableState = VPM_TABLE_INIT; +static SDecoinfo vpmTable; + extern const float float_buehlmann_N2_factor_expositon_20_seconds[]; extern const float float_buehlmann_He_factor_expositon_20_seconds[]; extern const float float_buehlmann_N2_factor_expositon_one_minute[]; @@ -165,7 +168,7 @@ static float r_int(float *x) { - return( (*x>0) ? floorf(*x) : -floorf(- *x) ); + return( (*x>0.0) ? floorf(*x) : -floorf(- *x) ); } /** private functions @@ -191,6 +194,8 @@ static void vpm_init_1(void); static void vpm_calc_deco_ceiling(void); +uint8_t vpm_get_decozone(void); + static void vpm_init_1(void) { units_equal_msw = true; @@ -219,6 +224,50 @@ return gCNS_VPM; } + +void vpm_maintainTable(SLifeData* pLifeData,SDecoinfo* pDecoInfo) +{ + static uint32_t lastDiveSecond = 0; + uint8_t actual_deco_stop = 0; + int8_t index = 0; + uint8_t decreaseStopTime = 1; + + if(lastDiveSecond < pLifeData->dive_time_seconds) + { + lastDiveSecond = pLifeData->dive_time_seconds; + actual_deco_stop = decom_get_actual_deco_stop((SDiveState*)stateUsed); + + pDecoInfo->output_time_to_surface_seconds = 0; + for(index = DECOINFO_STRUCT_MAX_STOPS -1 ;index >= 0; index--) + { + if(pDecoInfo->output_stop_length_seconds[index] > 0) + { + if(decreaseStopTime) + { + if((pLifeData->depth_meter > (float)(actual_deco_stop - 1.5)) + && (pLifeData->depth_meter < (float)actual_deco_stop + 1.5)) + { + pDecoInfo->output_stop_length_seconds[index]--; + decreaseStopTime = 0; + } + else if (pLifeData->depth_meter < (float)(actual_deco_stop - 1.5)) /* missed deco stop */ + { + vpmTableState = VPM_TABLE_MISSED; + pDecoInfo->output_stop_length_seconds[index] = 0; + decreaseStopTime = 0; + } + } + pDecoInfo->output_time_to_surface_seconds += pDecoInfo->output_stop_length_seconds[index]; + } + } + pDecoInfo->output_time_to_surface_seconds += pLifeData->depth_meter / 10.0 * 60.0; + } + else if(lastDiveSecond > pLifeData->dive_time_seconds) + { + lastDiveSecond = pLifeData->dive_time_seconds; + } +} + int vpm_calc(SLifeData* pINPUT, SDiveSettings* pSettings, SVpm* pVPM, @@ -226,10 +275,17 @@ pDECOINFO, int calc_what) { + static uint8_t vpmTableActive = 0; + vpm_init_1(); //decom_CreateGasChangeList(pSettings, pINPUT); vpm_calc_what = calc_what; /**clear decoInfo*/ + + if((vpmTableActive) && (vpm_calc_what == DECOSTOPS)) + { + memcpy(&vpmTable, pDECOINFO, sizeof(SDecoinfo)); /* save changes done by e.g. the simulator */ + } pDECOINFO->output_time_to_surface_seconds = 0; pDECOINFO->output_ndl_seconds = 0; pDECOINFO->output_ceiling_meter = 0; @@ -280,7 +336,33 @@ //Only Decostops not futute stops if(vpm_calc_what == DECOSTOPS) + { vpm_calc_status = tmp_calc_status; + if(pSettings->vpm_tableMode) /* store the most conservative deco plan and stick to it. */ + { + if((int16_t)(pDECOINFO->output_time_to_surface_seconds - vpmTable.output_time_to_surface_seconds) > 60) + { + memcpy(&vpmTable, pDECOINFO, sizeof(SDecoinfo)); + vpmTableActive = 1; + if(pVpm->deco_zone_reached) /* table should not change after deco zone was entered */ + { + if(vpmTableState != VPM_TABLE_MISSED) + { + vpmTableState = VPM_TABLE_WARNING; + } + } + } + else + { + if(vpmTable.output_time_to_surface_seconds > 0) + { + vpm_maintainTable(pINPUT, &vpmTable); + vpmTable.output_ceiling_meter = pDECOINFO->output_ceiling_meter; + memcpy(pDECOINFO, &vpmTable, sizeof(SDecoinfo)); + } + } + } + } return vpm_calc_status; } @@ -460,10 +542,18 @@ 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) +#ifdef ENABLE_DECOCALC_OPTION + && (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc) +#endif + ) 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) +#ifdef ENABLE_DECOCALC_OPTION + || (pDiveSettings->gas[pDiveSettings->decogaslist[i].GasIdInSettings].note.ub.decocalc == 0) +#endif + ) break; j++; @@ -636,8 +726,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 +735,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)); } } @@ -923,13 +1013,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 +1050,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 +1069,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 +1093,10 @@ static int dp_max; static float surfacetime; _Bool first_stop = false; + float roundingValue = 0.0; + + uint16_t stop_time_seconds; + max_first_stop_depth = fmaxf(first_stop_depth,max_first_stop_depth); if(begin) { @@ -1103,16 +1195,22 @@ } else { - dp = 1 + (int)((deco_stop_depth - (pDiveSettings->input_second_to_last_stop_depth_bar * 10)) / step_size); + roundingValue = (deco_stop_depth - (pDiveSettings->input_second_to_last_stop_depth_bar * 10.0)) / step_size; + dp = 1 + r_nint(&roundingValue); } - 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 = (uint16_t)(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; } @@ -1156,7 +1254,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 +1505,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 +1834,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 +1866,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) { @@ -2020,17 +2118,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 +2146,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,11 +2186,11 @@ 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; } @@ -2300,8 +2398,8 @@ 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; @@ -2409,3 +2507,18 @@ else return CALC_BEGIN; } + +void vpm_table_init() +{ + vpmTable.output_time_to_surface_seconds = 0; + vpmTableState = VPM_TABLE_INIT; +} +uint8_t vpm_get_decozone(void) +{ + return((uint8_t)pVpm->depth_start_of_deco_zone_save); +} +SvpmTableState vpm_get_TableState(void) +{ + return vpmTableState; +} + diff -r f7318457df4d -r c6c781a2e85b OtherSources/system_stm32f4xx.c --- a/OtherSources/system_stm32f4xx.c Tue Aug 13 13:24:54 2024 +0200 +++ b/OtherSources/system_stm32f4xx.c Tue Feb 11 18:12:00 2025 +0100 @@ -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}; /** * @} */ diff -r f7318457df4d -r c6c781a2e85b RefPrj/Firmware/.cproject --- a/RefPrj/Firmware/.cproject Tue Aug 13 13:24:54 2024 +0200 +++ b/RefPrj/Firmware/.cproject Tue Feb 11 18:12:00 2025 +0100 @@ -50,7 +50,7 @@