# HG changeset patch # User Ideenmodellierer # Date 1768071181 -3600 # Node ID 3c73180fde1db455220572d84eabc71beecf03b3 # Parent 24c1e3367a2ea3a34c1d4597352db760beb672d0 Added log entry for surface GF: The surface GF has been added to the logbook data. A function records the GF which is present while entering close to surface condition for later storage. This is needed to avoid that an already decreased GF (after dive mode exit time) GF is stored. The surface GF is shown at logbook page1 and is available in the header data for external logbook services. diff -r 24c1e3367a2e -r 3c73180fde1d Common/Inc/data_central.h --- a/Common/Inc/data_central.h Sat Jan 10 19:48:49 2026 +0100 +++ b/Common/Inc/data_central.h Sat Jan 10 19:53:01 2026 +0100 @@ -289,6 +289,8 @@ float ppo2Simulated_bar; /* GNSS data */ SGnssInfo gnssData; +/* last GF_Surf when shallow area was entered */ + uint8_t gf_surf_log; } SLifeData; diff -r 24c1e3367a2e -r 3c73180fde1d Common/Inc/settings.h --- a/Common/Inc/settings.h Sat Jan 10 19:48:49 2026 +0100 +++ b/Common/Inc/settings.h Sat Jan 10 19:53:01 2026 +0100 @@ -357,6 +357,7 @@ const SHardwareData* hardwareDataGetPointer(void); uint8_t firmwareVersion_16bit_high(void); uint8_t firmwareVersion_16bit_low(void); +void firmwareVersionfrom16bit(uint8_t high16, uint8_t low16, uint8_t* fw_first, uint8_t* fw_second, uint8_t* fw_third); void hardwareBatchCode(uint8_t *high, uint8_t *low); uint8_t RTEminimum_required_high(void); diff -r 24c1e3367a2e -r 3c73180fde1d Discovery/Inc/logbook.h --- a/Discovery/Inc/logbook.h Sat Jan 10 19:48:49 2026 +0100 +++ b/Discovery/Inc/logbook.h Sat Jan 10 19:53:01 2026 +0100 @@ -30,6 +30,11 @@ #include "data_central.h" #include "settings.h" +/* FW requirement for GF_Surf data entry */ +#define GF_SURF_FW_FIRST (1) +#define GF_SURF_FW_SECOND (7) +#define GF_SURF_FW_THIRD (5) + typedef struct { uint8_t setpoint_cbar; diff -r 24c1e3367a2e -r 3c73180fde1d Discovery/Src/data_exchange_main.c --- a/Discovery/Src/data_exchange_main.c Sat Jan 10 19:48:49 2026 +0100 +++ b/Discovery/Src/data_exchange_main.c Sat Jan 10 19:53:01 2026 +0100 @@ -845,6 +845,7 @@ void DataEX_copy_to_LifeData(_Bool *modeChangeFlag) { static uint16_t getDeviceDataAfterStartOfMainCPU = 20; + static uint16_t lastcounterSecondsShallowDepth = 0; SDiveState *pStateReal = stateRealGetPointerWrite(); uint8_t idx; @@ -1189,6 +1190,20 @@ #endif } + /* close to surface ? */ + if((pStateReal->lifeData.counterSecondsShallowDepth != 0) && (lastcounterSecondsShallowDepth == 0)) + { + if( (pStateReal->decolistBuehlmann.gf_surf * 100.0) < 255.0) + { + pStateReal->lifeData.gf_surf_log = pStateReal->decolistBuehlmann.gf_surf * 100.0; + } + else + { + pStateReal->lifeData.gf_surf_log = 255; + } + } + lastcounterSecondsShallowDepth = pStateReal->lifeData.counterSecondsShallowDepth; + /* apnea specials */ if(pStateReal->diveSettings.diveMode == DIVEMODE_Apnea) diff -r 24c1e3367a2e -r 3c73180fde1d Discovery/Src/logbook.c --- a/Discovery/Src/logbook.c Sat Jan 10 19:48:49 2026 +0100 +++ b/Discovery/Src/logbook.c Sat Jan 10 19:53:01 2026 +0100 @@ -269,6 +269,7 @@ gheader.decoModel = 1; gheader.gfLow_or_Vpm_conservatism = pInfo->diveSettings.gf_low; gheader.gfHigh = pInfo->diveSettings.gf_high; + gheader.gfAtEnd = 0x0FF; } else { @@ -1468,6 +1469,14 @@ { gheader.batteryCharge = 0.0; } + if(pStateReal->diveSettings.deco_type.ub.standard == GF_MODE) + { + gheader.gfAtEnd = pStateReal->lifeData.gf_surf_log; + } + else + { + gheader.gfAtEnd = 0; + } logbook_EndDive(); bDiveMode = 0; } else diff -r 24c1e3367a2e -r 3c73180fde1d Discovery/Src/settings.c --- a/Discovery/Src/settings.c Sat Jan 10 19:48:49 2026 +0100 +++ b/Discovery/Src/settings.c Sat Jan 10 19:53:01 2026 +0100 @@ -2008,6 +2008,12 @@ } } +void firmwareVersionfrom16bit(uint8_t high16, uint8_t low16, uint8_t* fw_first, uint8_t* fw_second, uint8_t* fw_third) +{ + *fw_first = (high16 >> 3); + *fw_second = ((high16 & 0x3) << 2) | (low16 >> 6); + *fw_third = (low16 & 0x1F) >> 1; /* discard beta information */ +} uint8_t firmwareVersion_16bit_high(void) { diff -r 24c1e3367a2e -r 3c73180fde1d Discovery/Src/show_logbook.c --- a/Discovery/Src/show_logbook.c Sat Jan 10 19:48:49 2026 +0100 +++ b/Discovery/Src/show_logbook.c Sat Jan 10 19:53:01 2026 +0100 @@ -435,6 +435,9 @@ wintemp.bottom = 479 - 40; char timeSuffix; uint8_t hoursToDisplay; + uint8_t fw_first = 0; + uint8_t fw_second = 0; + uint8_t fw_third = 0; SLogbookHeader logbookHeader; logbook_getHeader(StepBackwards ,&logbookHeader); @@ -679,6 +682,29 @@ Gfx_write_label_var(hgfx, start, 300,top, &FontT42,CLUT_GasSensor4,text); + if(logbookHeader.decoModel == GF_MODE) + { + firmwareVersionfrom16bit(logbookHeader.firmwareVersionHigh, logbookHeader.firmwareVersionLow, &fw_first, &fw_second, &fw_third); + if((fw_first >= GF_SURF_FW_FIRST) && (fw_second >= GF_SURF_FW_SECOND) && (fw_third >= GF_SURF_FW_THIRD)) + { + top+= 50; + start = 30; + snprintf(text,20,"%u",logbookHeader.gfAtEnd); + Gfx_write_label_var(hgfx, start, 300,top, &FontT42,CLUT_GasSensor1,text); + start += FontT42.spacesize2Monospaced + 5; + if(logbookHeader.gfAtEnd > 99) + { + start += FontT42.spacesize2Monospaced * 2; + } + if(logbookHeader.gfAtEnd > 9) + { + start += FontT42.spacesize2Monospaced; + } + snprintf(text,20,"%c%c",TXT_2BYTE,TXT2BYTE_GFSurf); + Gfx_write_label_var(hgfx, start, 300,top, &FontT24,CLUT_GasSensor4,text); + } + } + // CNS snprintf(text,20,"CNS: %i %%",logbookHeader.maxCNS); Gfx_write_label_var(hgfx, 30, 250,440, &FontT42,CLUT_GasSensor1,text); diff -r 24c1e3367a2e -r 3c73180fde1d Discovery/Src/simulation.c --- a/Discovery/Src/simulation.c Sat Jan 10 19:48:49 2026 +0100 +++ b/Discovery/Src/simulation.c Sat Jan 10 19:53:01 2026 +0100 @@ -300,7 +300,20 @@ if(!(stateSimGetPointer()->lifeData.counterSecondsShallowDepth)) { if(pDiveState->diveSettings.diveMode != DIVEMODE_Apnea) + { pDiveState->lifeData.counterSecondsShallowDepth = settingsGetPointer()->timeoutDiveReachedZeroDepth - 15; + if(pDiveState->diveSettings.deco_type.ub.standard == GF_MODE) + { + if((stateDeco.decolistBuehlmann.gf_surf * 100.0) < 255.0) + { + pDiveState->lifeData.gf_surf_log = stateDeco.decolistBuehlmann.gf_surf *100.0; + } + else + { + pDiveState->lifeData.gf_surf_log = 255; + } + } + } else { pDiveState->lifeData.apnea_last_dive_time_seconds = pDiveState->lifeData.dive_time_seconds; @@ -351,7 +364,13 @@ { stateSimGetPointerWrite()->lifeData.counterSecondsShallowDepth += 1; if(stateSimGetPointer()->lifeData.counterSecondsShallowDepth >= settingsGetPointer()->timeoutDiveReachedZeroDepth) + { +#ifdef SIM_WRITES_LOGBOOK + pDiveState->mode = MODE_SURFACE; + logbook_InitAndWrite((SDiveState*)pDiveState); +#endif simulation_exit(); + } } vpm_crush(pDiveState); }