# HG changeset patch # User Ideenmodellierer # Date 1570739163 -7200 # Node ID 14fd5f35cb508e7776639d0478b8c500752a8e1e # Parent 695434a6dcf6e70c3efd3eaa73cee94dbce7b8fe# Parent afa55a50cc724b11b959fa81567d59ede251ef22 merge default diff -r 695434a6dcf6 -r 14fd5f35cb50 .hgtags --- a/.hgtags Thu Oct 10 22:11:59 2019 +0200 +++ b/.hgtags Thu Oct 10 22:26:03 2019 +0200 @@ -1,2 +1,3 @@ 1b9be6040d8279117c7fc99d528790611638f10b V1.4.7 release ba9d99a2e310da601a948ff11ad665260c600e18 v1.4.8 release +143fe85f82a2e2aca50eb0c29bc55066cb4fe497 v1.5.0 release diff -r 695434a6dcf6 -r 14fd5f35cb50 Current build/OSTC4update_190804.bin Binary file Current build/OSTC4update_190804.bin has changed diff -r 695434a6dcf6 -r 14fd5f35cb50 Current build/OSTC4update_191009.bin Binary file Current build/OSTC4update_191009.bin has changed diff -r 695434a6dcf6 -r 14fd5f35cb50 Discovery/Inc/tStructure.h --- a/Discovery/Inc/tStructure.h Thu Oct 10 22:11:59 2019 +0200 +++ b/Discovery/Inc/tStructure.h Thu Oct 10 22:26:03 2019 +0200 @@ -123,7 +123,6 @@ #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_Wireless _MB(2,1,255,6,0) #define StMOG_MOD _MB(2,1,255,9,0) diff -r 695434a6dcf6 -r 14fd5f35cb50 Discovery/Inc/text_multilanguage.h --- a/Discovery/Inc/text_multilanguage.h Thu Oct 10 22:11:59 2019 +0200 +++ b/Discovery/Inc/text_multilanguage.h Thu Oct 10 22:26:03 2019 +0200 @@ -166,6 +166,7 @@ TXT2BYTE_ResetStopwatch, TXT2BYTE_SetMarker, TXT2BYTE_CompassHeading, + TXT2BYTE_EndDiveMode, /* */ TXT2BYTE_Simulator, TXT2BYTE_StartSimulator, @@ -237,8 +238,6 @@ TXT2BYTE_AmbientTemperature, /* */ TXT2BYTE_Bottle, - TXT2BYTE_WirelessSender, - TXT2BYTE_WirelessDisconnect, /* */ TXT2BYTE_Gaslist, TXT2BYTE_Clock, diff -r 695434a6dcf6 -r 14fd5f35cb50 Discovery/Src/base.c --- a/Discovery/Src/base.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Discovery/Src/base.c Thu Oct 10 22:26:03 2019 +0200 @@ -565,6 +565,8 @@ /// to be called /// // =============================================================================== + +//#define NO_TIMEOUT void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { #ifdef DEMOMODE diff -r 695434a6dcf6 -r 14fd5f35cb50 Discovery/Src/data_exchange_main.c --- a/Discovery/Src/data_exchange_main.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Discovery/Src/data_exchange_main.c Thu Oct 10 22:26:03 2019 +0200 @@ -693,40 +693,31 @@ } } -#define AVERAGE_COUNT 4 static float getSampleDepth(SDataExchangeSlaveToMaster *d, SDiveState *ds) { - static uint8_t c = 0; - static float ambient[AVERAGE_COUNT] = {0}; - static float surface[AVERAGE_COUNT]= {0}; - static float depth[AVERAGE_COUNT]= {0}; - - ambient[c] = d->data[d->boolPressureData].pressure_mbar / 1000.0f; - surface[c] = d->data[d->boolPressureData].surface_mbar / 1000.0f; - float density = ((float)( 100 + settingsGetPointer()->salinity)) / 100.0f; + float ambient = 0; + float surface = 0; + float depth = 0; + float density = 0; - ds->lifeData.pressure_ambient_bar = (ambient[0] + ambient[1] + ambient[2] + ambient[3])/4.0f; - ds->lifeData.pressure_surface_bar = (surface[0] + surface[1] + surface[2] + surface[3])/4.0f; - depth[c] = (ambient[c] - surface[c]) / (0.09807f * density); + ambient = d->data[d->boolPressureData].pressure_mbar / 1000.0f; + surface = d->data[d->boolPressureData].surface_mbar / 1000.0f; + density = ((float)( 100 + settingsGetPointer()->salinity)) / 100.0f; - c++; - if (c == AVERAGE_COUNT) c = 0; + ds->lifeData.pressure_ambient_bar = ambient; + ds->lifeData.pressure_surface_bar = surface; + depth = (ambient - surface) / (0.09807f * density); + ds->lifeData.bool_temp1 = d->data[d->boolPressureData].SPARE1; - return (depth[0] + depth[1] + depth[2] + depth[3])/4.0f; + return depth; } -#define TEMP_AVERAGE_COUNT 3 static float getTemperature(SDataExchangeSlaveToMaster *d) { - static uint8_t c = 0; - static float temp[TEMP_AVERAGE_COUNT] = {0}; - - temp[c] = d->data[d->boolPressureData].temperature; + float temp = 0; + temp = d->data[d->boolPressureData].temperature; - c++; - if (c == TEMP_AVERAGE_COUNT) c = 0; - - return (temp[0] + temp[1] + temp[2])/3.0f; + return temp; } void DataEX_copy_to_LifeData(_Bool *modeChangeFlag) diff -r 695434a6dcf6 -r 14fd5f35cb50 Discovery/Src/settings.c --- a/Discovery/Src/settings.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Discovery/Src/settings.c Thu Oct 10 22:26:03 2019 +0200 @@ -56,15 +56,15 @@ { .versionFirst = 1, .versionSecond = 5, - .versionThird = 0, + .versionThird = 1, .versionBeta = 0, /* 4 bytes with trailing 0 */ .signature = "mh", .release_year = 19, - .release_month = 8, - .release_day = 5, + .release_month = 10, + .release_day = 6, .release_sub = 0, /* max 48 with trailing 0 */ diff -r 695434a6dcf6 -r 14fd5f35cb50 Discovery/Src/t7.c --- a/Discovery/Src/t7.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Discovery/Src/t7.c Thu Oct 10 22:26:03 2019 +0200 @@ -1148,73 +1148,8 @@ draw_frame(0,0, CLUT_pluginboxSurface, CLUT_Font020); } -void t7_refresh_surface_debugmode_wireless_info(void) -{ - char text[400]; - uint8_t colorDataLost = 0; - int txtPointer = 0; - uint8_t numberOfBytes = 0; - - GFX_DrawCfgWindow textWindow = - { - .Image = &t7screen, - .WindowNumberOfTextLines = 5, - .WindowLineSpacing = 70, - .WindowTab = 220, - .WindowX0 = 10, - .WindowX1 = 790, - .WindowY0 = 10, - .WindowY1 = 380 - }; - - Gfx_write_label_var(&t7screen, 10,600, 10,&FontT42,CLUT_DiveMainLabel,"Wireless Data"); - - if(stateUsed->data_old__lost_connection_to_slave) - { - Gfx_write_label_var(&t7screen, 600,800,10,&FontT42,CLUT_Font020,"CPU2?"); - colorDataLost = 1; - } - - txtPointer = 0; - for(int i=0;i<4;i++) - { - if((!stateUsed->lifeData.wireless_data[i].ageInMilliSeconds) || colorDataLost) - text[txtPointer++] = '\021'; - - numberOfBytes = stateUsed->lifeData.wireless_data[i].numberOfBytes; - if((numberOfBytes > 0) && (numberOfBytes <= 10)) - { - txtPointer += snprintf(&text[txtPointer],20,"%02u s %02u\t" - ,(stateUsed->lifeData.wireless_data[i].ageInMilliSeconds)/1000 - ,stateUsed->lifeData.wireless_data[i].status - ); - if(numberOfBytes > 8) ///< lifeData.wireless_data[i].data[j] has only size of 8 - numberOfBytes = 8; - for(int j=0;jlifeData.wireless_data[i].data[j] - ); - } - } - text[txtPointer++] = '\n'; - text[txtPointer++] = '\r'; - text[txtPointer++] = '\020'; - text[txtPointer] = 0; - } - GFX_write_string(&FontT48,&textWindow,text,1); - -} - - void t7_refresh_surface_debugmode(void) { - if(selection_customview%2 == 1) - { - t7_refresh_surface_debugmode_wireless_info(); - return; - } - // could be warning, now just to set RTE variables DataEX_check_RTE_version__needs_update(); @@ -1316,6 +1251,16 @@ // Gfx_write_label_var(&t7screen, 601,800,310,&FontT42,CLUT_DiveMainLabel,"Light"); // Gfx_write_label_var(&t7screen, 601,800,355,&FontT48,CLUT_Font020,TextL1); +/* show surface pressure state */ + if(stateUsed->lifeData.bool_temp1 ) + { + snprintf(TextL1,TEXTSIZE,"stable"); + } + else + { + snprintf(TextL1,TEXTSIZE,"unstable"); + } + Gfx_write_label_var(&t7screen, 500,800,400,&FontT48,CLUT_Font020,TextL1); if(Sdate.Year < 15) diff -r 695434a6dcf6 -r 14fd5f35cb50 Discovery/Src/tMenuEditGasOC.c --- a/Discovery/Src/tMenuEditGasOC.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Discovery/Src/tMenuEditGasOC.c Thu Oct 10 22:26:03 2019 +0200 @@ -44,19 +44,15 @@ uint8_t setpoint; } SEditGasPage; -#define MAX_SENDER_AT_ONCE 5 /* Private variables ---------------------------------------------------------*/ SEditGasPage editGasPage; -uint16_t wirelessSender[MAX_SENDER_AT_ONCE]; - /* Private function prototypes -----------------------------------------------*/ void create_text_with_u8(char *text, const char *text1, uint8_t inputU8, const char *text2); void openEdit_Gas(uint8_t line, uint8_t ccr); void openEdit_GasType(void); -void openEdit_Wireless(void); void openEdit_DiveGasSelect(uint8_t line, uint8_t ccr); void openEdit_SpecialDiveGasMenu(uint8_t ccr); @@ -70,16 +66,12 @@ uint8_t OnAction_ChangeDepth (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_SetToMOD (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_BottleSize (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); -uint8_t OnAction_Wireless (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); uint8_t OnAction_Deco (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_Travel (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_Inactive (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); -uint8_t OnAction_WirelessID (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); -uint8_t OnAction_NoWireless (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); - uint8_t OnAction_DM_Active (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); uint8_t OnAction_DM_Mix (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); @@ -344,8 +336,7 @@ /* surface mode */ void openEdit_Gas(uint8_t line, uint8_t ccr) { - uint8_t gasID, oxygen, helium, depthDeco, active, first, depthMOD, deco, travel, inactive;//, bottleSizeLiter;, bottleWirelessStatus; - //uint16_t bottleWirelessId;//, bottleWirelessIdSmall; + uint8_t gasID, oxygen, helium, depthDeco, active, first, depthMOD, deco, travel, inactive;//, bottleSizeLiter; char text[32]; char textMOD[32]; @@ -385,9 +376,6 @@ travel = editGasPage.pGasLine[gasID].note.ub.travel; //bottleSizeLiter = editGasPage.pGasLine[gasID].bottle_size_liter; -// bottleWirelessStatus = editGasPage.pGasLine[gasID].bottle_wireless_status; - //bottleWirelessId = editGasPage.pGasLine[gasID].bottle_wireless_id; - //bottleWirelessIdSmall = bottleWirelessId & 0x0F; if(active) inactive = 0; @@ -487,14 +475,6 @@ write_label_var( 20 ,800, ME_Y_LINE5, &FontT48, text); write_field_2digit(StMOG_Bottle, 600, 710, ME_Y_LINE5, &FontT48,"## ltr", (uint32_t)bottleSizeLiter, 0, 0, 0); - txtptr = 0; - text[txtptr++] = TXT_2BYTE; - text[txtptr++] = TXT2BYTE_WirelessSender; - text[txtptr++] = ' '; - if(!bottleWirelessId) - text[txtptr++] = '\021'; - txtptr += snprintf(&text[txtptr],20,"%u (%04X)",bottleWirelessIdSmall, bottleWirelessId); - write_field_button(StMOG_Wireless, 20, 710, ME_Y_LINE6, &FontT48, text); */ stop_cursor_fields(); @@ -522,7 +502,6 @@ } /* setEvent(StMOG_Bottle, (uint32_t)OnAction_BottleSize); - setEvent(StMOG_Wireless, (uint32_t)OnAction_Wireless); */ write_buttonTextline(TXT2BYTE_ButtonBack,TXT2BYTE_ButtonEnter,TXT2BYTE_ButtonNext); } @@ -606,205 +585,6 @@ return UNSPECIFIC_RETURN; } -void openEdit_Wireless(void) -{ - uint8_t gasID, wirelessSenderAvailable, isNotMatched, isMatchedWithThis, wirelessSenderActive[MAX_SENDER_AT_ONCE], senderCount, isInList; //, wirelessStatus; - uint16_t wirelessId, wirelessSenderIdSmall, wirelessIdTemp; - char text[32]; - uint8_t txtptr; - - if(editGasPage.ccr) - { - resetMenuEdit(CLUT_MenuPageGasCC); - setBackMenu((uint32_t)openEdit_GasCC, editGasPage.gasID - NUM_OFFSET_DILUENT, 5); - } - else - { - resetMenuEdit(CLUT_MenuPageGasOC); - setBackMenu((uint32_t)openEdit_GasOC, editGasPage.gasID, 5); - } - - gasID = editGasPage.gasID; - wirelessId = editGasPage.pGasLine[gasID].bottle_wireless_id; -// wirelessStatus = editGasPage.pGasLine[gasID].bottle_wireless_status; - - - /* header */ - int i = 0; - if(gasID >= 10) - { - i = 1; - strcpy(text, "\001" "Gas #10 X"); - } - else - strcpy(text, "\001" "Gas #0 X"); - - if(editGasPage.ccr) - text[8+i] = TXT_Diluent_Gas_Edit; - else - text[8+i] = TXT_OC_Gas_Edit; - - if(gasID >= 10) - text[6+i] += gasID - 10; - else - text[6+i] += gasID; - write_topline(text); - - senderCount = 0; - wirelessSenderAvailable = 0; - if(wirelessId) - { - wirelessSender[senderCount] = wirelessId; - wirelessSenderActive[senderCount] = 0; - wirelessSenderAvailable++; - senderCount++; - } - - for(int i=0;i<4;i++) - { - if((stateUsed->lifeData.wireless_data[i].ageInMilliSeconds) && (stateUsed->lifeData.wireless_data[i].ageInMilliSeconds <= 60000) && ((stateUsed->lifeData.wireless_data[i].data[1] & 0x0F) != 0)) - { - wirelessIdTemp = stateUsed->lifeData.wireless_data[i].data[0] * 256; - wirelessIdTemp += stateUsed->lifeData.wireless_data[i].data[1]; - if(wirelessId && (wirelessId == wirelessIdTemp)) - wirelessSenderActive[0] = 1; - else - { - isInList = 0; - for(int j=0;j MAX_SENDER_AT_ONCE) - wirelessSenderAvailable = MAX_SENDER_AT_ONCE; - - isNotMatched = 1; - - for(int i=0;igas[j].bottle_wireless_id == wirelessSender[i])) - { - txtptr += snprintf(&text[txtptr],20," used by Gas #%i",i); - break; - } - } - } - write_field_on_off(StMOG_Transmitter1 + i, 30, 710, ME_Y_LINE1 + (i * ME_Y_LINE_STEP), &FontT48, text, isMatchedWithThis); - } - - - txtptr = 0; - text[txtptr++] = TXT_2BYTE; - text[txtptr++] = TXT2BYTE_WirelessDisconnect; - text[txtptr++] = 0; - write_field_on_off(StMOG_NoTransmitter, 30, 400, ME_Y_LINE6, &FontT48, text, isNotMatched); - - // setEvent has to be _after_ all fields are written - for(int i=0;i StMOG_Transmitter5)) - return UNSPECIFIC_RETURN; - - uint8_t line, isMatched; - - line = editId - StMOG_Transmitter1; - - - if(editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_id == wirelessSender[line]) - isMatched = 1; - else - isMatched = 0; - - editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_id = wirelessSender[line]; -// editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_status = 0; - - for(int i=0;i<5;i++) - { - if((StMOG_Transmitter1 + i) != editId) - tMenuEdit_set_on_off(StMOG_Transmitter1 + i, 0); - } - tMenuEdit_set_on_off(editId, 1); - tMenuEdit_set_on_off(StMOG_NoTransmitter, 0); - - if(!isMatched) - return UPDATE_DIVESETTINGS; - else - return UPDATE_AND_EXIT_TO_MENU; -} - - -uint8_t OnAction_NoWireless (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) -{ - uint8_t isNotMatched; - - if(editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_id == 0) - isNotMatched = 1; - else - isNotMatched = 1; - - editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_id = 0; -// editGasPage.pGasLine[editGasPage.gasID].bottle_wireless_status = 0; - - tMenuEdit_set_on_off(StMOG_Transmitter1, 0); - tMenuEdit_set_on_off(StMOG_Transmitter2, 0); - tMenuEdit_set_on_off(StMOG_Transmitter3, 0); - tMenuEdit_set_on_off(StMOG_Transmitter4, 0); - tMenuEdit_set_on_off(StMOG_Transmitter5, 0); - tMenuEdit_set_on_off(StMOG_NoTransmitter, 1); - - if(!isNotMatched) - return UPDATE_DIVESETTINGS; - else - return UPDATE_AND_EXIT_TO_MENU; -} - - uint8_t OnAction_Mix(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action) { uint8_t digitContentNew; diff -r 695434a6dcf6 -r 14fd5f35cb50 Discovery/Src/tMenuEditSystem.c --- a/Discovery/Src/tMenuEditSystem.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Discovery/Src/tMenuEditSystem.c Thu Oct 10 22:26:03 2019 +0200 @@ -43,10 +43,11 @@ #define CV_SUBPAGE_MAX (2u) /* max number of customer view selection pages */ -/* Private variables ---------------------------------------------------------*/ +/*#define HAVE_DEBUG_VIEW */ static uint8_t infoPage = 0; +static uint8_t infoPage = 0; /* Private function prototypes -----------------------------------------------*/ void openEdit_DateTime(void); @@ -610,10 +611,14 @@ write_field_button(StMSYS3_Units, 400, 700, ME_Y_LINE1, &FontT48, ""); write_field_button(StMSYS3_Colors, 400, 700, ME_Y_LINE2, &FontT48, ""); -// write_field_button(StMSYS3_Debug, 400, 700, ME_Y_LINE3, &FontT48, ""); +#ifdef HAVE_DEBUG_VIEW + write_field_button(StMSYS3_Debug, 400, 700, ME_Y_LINE3, &FontT48, ""); +#endif setEvent(StMSYS3_Units, (uint32_t)OnAction_Units); setEvent(StMSYS3_Colors, (uint32_t)OnAction_Colorscheme); -// setEvent(StMSYS3_Debug, (uint32_t)OnAction_DebugInfo); +#ifdef HAVE_DEBUG_VIEW + setEvent(StMSYS3_Debug, (uint32_t)OnAction_DebugInfo); +#endif } @@ -654,7 +659,7 @@ text[1] = 0; write_label_var( 400, 700, ME_Y_LINE2, &FontT48, text); -/* +#ifdef HAVE_DEBUG_VIEW // specials text[0] = TXT_2BYTE; text[1] = TXT2BYTE_ShowDebug; @@ -667,7 +672,7 @@ text[0] = '\006'; text[1] = 0; write_label_var( 400, 700, ME_Y_LINE3, &FontT48, text); -*/ +#endif // design text[0] = TXT_Depth; diff -r 695434a6dcf6 -r 14fd5f35cb50 Discovery/Src/tMenuEditXtra.c --- a/Discovery/Src/tMenuEditXtra.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Discovery/Src/tMenuEditXtra.c Thu Oct 10 22:26:03 2019 +0200 @@ -33,12 +33,15 @@ #include "simulation.h" #include "timer.h" #include "tMenuEdit.h" +#include "data_exchange_main.h" + /* Private function prototypes -----------------------------------------------*/ void openEdit_CompassHeading(void); void openEdit_ResetStopwatch(void); void openEdit_SimFollowDecostops(void); void openEdit_SetManualMarker(void); +void openEdit_SetEndDive(void); /* Announced function prototypes -----------------------------------------------*/ uint8_t OnAction_CompassHeading (uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action); @@ -63,7 +66,14 @@ openEdit_SetManualMarker(); break; case 4: - openEdit_SimFollowDecostops(); + if(is_stateUsedSetToSim()) + { + openEdit_SimFollowDecostops(); + } + else + { + openEdit_SetEndDive(); + } break; } } @@ -81,6 +91,12 @@ exitMenuEdit_to_Home(); } +void openEdit_SetEndDive(void) +{ + dataOutGetPointer()->setEndDive = 1; + exitMenuEdit_to_Home(); +} + void openEdit_SimFollowDecostops(void) { simulation_set_heed_decostops(!simulation_get_heed_decostops()); diff -r 695434a6dcf6 -r 14fd5f35cb50 Discovery/Src/tMenuGas.c --- a/Discovery/Src/tMenuGas.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Discovery/Src/tMenuGas.c Thu Oct 10 22:26:03 2019 +0200 @@ -74,7 +74,7 @@ { const SGasLine * pGasLine; - uint8_t gasId, oxygen, helium, depthUp, active, first, typeDeco, wirelessId; + uint8_t gasId, oxygen, helium, depthUp, active, first, typeDeco; float fPpO2limitHigh = 0; float fPpO2ofGasAtThisDepth = 0; //uint8_t senderCode, depthDown,; @@ -142,7 +142,6 @@ typeDeco = pGasLine[gasId].note.ub.deco; mod = calc_MOD(gasId); ltr = pGasLine[gasId].bottle_size_liter; - wirelessId = pGasLine[gasId].bottle_wireless_id; //bar = stateUsed->lifeData.bottle_bar[gasId]; if(active) @@ -224,12 +223,6 @@ if(ltr) color[2] = '\020'; /* bar */ - if(wirelessId) - color[3] = '\020'; - /* wireless */ - if(wirelessId) - color[4] = '\020'; - /* ltr, bar */ if(mod < depthUp) { @@ -302,18 +295,6 @@ color[3], bar ); */ - /* wireless */ -/* - if(wirelessId) - { - textPointer += snprintf(&text[textPointer], 8,\ - "%c" - " *" - "%u", - color[4], (wirelessId%0x0F) - ); - } -*/ text[textPointer++] = '\035'; text[textPointer++] = '\n'; text[textPointer++] = '\r'; diff -r 695434a6dcf6 -r 14fd5f35cb50 Discovery/Src/tMenuXtra.c --- a/Discovery/Src/tMenuXtra.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Discovery/Src/tMenuXtra.c Thu Oct 10 22:26:03 2019 +0200 @@ -94,6 +94,16 @@ strcpy(&text[textPointer],"\n\r"); textPointer += 2; } + else + { + if((line == 0) || (line == 4)) /* end dive mode only used during real dives */ + { + text[textPointer++] = TXT_2BYTE; + text[textPointer++] = TXT2BYTE_EndDiveMode; + } + strcpy(&text[textPointer],"\n\r"); + textPointer += 2; + } return StMXTRA; } diff -r 695434a6dcf6 -r 14fd5f35cb50 Discovery/Src/text_multilanguage.c --- a/Discovery/Src/text_multilanguage.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Discovery/Src/text_multilanguage.c Thu Oct 10 22:26:03 2019 +0200 @@ -1,4 +1,4 @@ -/////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// /// -*- coding: UTF-8 -*- /// /// \file Discovery/Src/text_multilanguage.c @@ -722,6 +722,13 @@ static uint8_t text_IT_CompassHeading[] = "Direzione bussola"; static uint8_t text_ES_CompassHeading[] = "Rumbo brújula"; +// Dive Menu +static uint8_t text_EN_EndDiveMode[] = "End dive"; +static uint8_t text_DE_EndDiveMode[] = "Tauchgang beenden"; +static uint8_t text_FR_EndDiveMode[] = "End dive"; +static uint8_t text_IT_EndDiveMode[] = "End dive"; +static uint8_t text_ES_EndDiveMode[] = "End dive"; + // Menu SIM static uint8_t text_EN_Simulator[] = "Simulator"; static uint8_t text_DE_Simulator[] = ""; @@ -1542,18 +1549,6 @@ static uint8_t text_IT_GasVorrat[] = ""; static uint8_t text_ES_GasVorrat[] = ""; -static uint8_t text_EN_WirelessSender[] = "wireless id"; -static uint8_t text_DE_WirelessSender[] = "Sender ID"; -static uint8_t text_FR_WirelessSender[] = ""; -static uint8_t text_IT_WirelessSender[] = "Numero di serie"; -static uint8_t text_ES_WirelessSender[] = "wireless id"; - -static uint8_t text_EN_WirelessDisconnect[] = "Disconnect"; -static uint8_t text_DE_WirelessDisconnect[] = "Nicht verbunden"; -static uint8_t text_FR_WirelessDisconnect[] = ""; -static uint8_t text_IT_WirelessDisconnect[] = "Disconnesso"; -static uint8_t text_ES_WirelessDisconnect[] = "Desconectado"; - static uint8_t text_EN_FlipDisplay[] = "Flip display"; static uint8_t text_DE_FlipDisplay[] = "Anzeige spiegeln"; static uint8_t text_FR_FlipDisplay[] = ""; @@ -1659,7 +1654,8 @@ {(uint8_t)TXT2BYTE_ResetStopwatch, {text_EN_ResetStopwatch, text_DE_ResetStopwatch, text_FR_ResetStopwatch, text_IT_ResetStopwatch, text_ES_ResetStopwatch}}, {(uint8_t)TXT2BYTE_SetMarker, {text_EN_SetMarker, text_DE_SetMarker, text_FR_SetMarker, text_IT_SetMarker, text_ES_SetMarker}}, {(uint8_t)TXT2BYTE_CompassHeading, {text_EN_CompassHeading, text_DE_CompassHeading, text_FR_CompassHeading, text_IT_CompassHeading, text_ES_CompassHeading}}, - {(uint8_t)TXT2BYTE_Simulator, {text_EN_Simulator, text_DE_Simulator, text_FR_Simulator, text_IT_Simulator, text_ES_Simulator}}, + {(uint8_t)TXT2BYTE_EndDiveMode, {text_EN_EndDiveMode, text_DE_EndDiveMode, text_FR_EndDiveMode, text_IT_EndDiveMode, text_ES_EndDiveMode}}, + {(uint8_t)TXT2BYTE_Simulator, {text_EN_Simulator, text_DE_Simulator, text_FR_Simulator, text_IT_Simulator, text_ES_Simulator}}, {(uint8_t)TXT2BYTE_StartSimulator, {text_EN_StartSimulator, text_DE_StartSimulator, text_FR_StartSimulator, text_IT_StartSimulator, text_ES_StartSimulator}}, {(uint8_t)TXT2BYTE_Intervall, {text_EN_Intervall, text_DE_Intervall, text_FR_Intervall, text_IT_Intervall, text_ES_Intervall}}, {(uint8_t)TXT2BYTE_SimDiveTime, {text_EN_SimDiveTime, text_DE_SimDiveTime, text_FR_SimDiveTime, text_IT_SimDiveTime, text_ES_SimDiveTime}}, @@ -1721,8 +1717,6 @@ {(uint8_t)TXT2BYTE_NumberOfDives, {text_EN_NumberOfDives, text_DE_NumberOfDives, text_FR_NumberOfDives, text_IT_NumberOfDives, text_ES_NumberOfDives}}, {(uint8_t)TXT2BYTE_AmbientTemperature,{text_EN_AmbientTemperature, text_DE_AmbientTemperature, text_FR_AmbientTemperature, text_IT_AmbientTemperature, text_ES_AmbientTemperature}}, {(uint8_t)TXT2BYTE_Bottle, {text_EN_Bottle, text_DE_Bottle, text_FR_Bottle, text_IT_Bottle, text_ES_Bottle}}, - {(uint8_t)TXT2BYTE_WirelessSender,{text_EN_WirelessSender, text_DE_WirelessSender, text_FR_WirelessSender, text_IT_WirelessSender, text_ES_WirelessSender}}, - {(uint8_t)TXT2BYTE_WirelessDisconnect,{text_EN_WirelessDisconnect, text_DE_WirelessDisconnect, text_FR_WirelessDisconnect, text_IT_WirelessDisconnect, text_ES_WirelessDisconnect}}, {(uint8_t)TXT2BYTE_Gaslist, {text_EN_Gaslist, text_DE_Gaslist, text_FR_Gaslist, text_IT_Gaslist, text_ES_Gaslist}}, {(uint8_t)TXT2BYTE_Clock, {text_EN_Clock, text_DE_Clock, text_FR_Clock, text_IT_Clock, text_ES_Clock}}, {(uint8_t)TXT2BYTE_Sunday, {text_EN_Sunday, text_DE_Sunday, text_FR_Sunday, text_IT_Sunday, text_ES_Sunday}}, diff -r 695434a6dcf6 -r 14fd5f35cb50 RefPrj/Firmware/.cproject diff -r 695434a6dcf6 -r 14fd5f35cb50 RefPrj/RTE/.cproject diff -r 695434a6dcf6 -r 14fd5f35cb50 Small_CPU/Inc/pressure.h --- a/Small_CPU/Inc/pressure.h Thu Oct 10 22:11:59 2019 +0200 +++ b/Small_CPU/Inc/pressure.h Thu Oct 10 22:26:03 2019 +0200 @@ -20,6 +20,9 @@ float get_pressure_mbar(void); float get_surface_mbar(void); +uint8_t is_surface_pressure_stable(void); +float set_last_surface_pressure_stable(void); + void init_surface_ring(uint8_t force); void update_surface_pressure(uint8_t call_rhythm_seconds); diff -r 695434a6dcf6 -r 14fd5f35cb50 Small_CPU/Src/baseCPU2.c --- a/Small_CPU/Src/baseCPU2.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Small_CPU/Src/baseCPU2.c Thu Oct 10 22:26:03 2019 +0200 @@ -161,8 +161,8 @@ // SHALL LOAD AT 0x08000000 + 0x00005000 = 0x08005000. // See CPU2-RTE.ld const SFirmwareData cpu2_FirmwareData __attribute__(( section(".firmware_data") ))= { - .versionFirst = 1, - .versionSecond = 9, + .versionFirst = 2, + .versionSecond = 0, .versionThird = 0, .versionBeta = 0, @@ -170,8 +170,8 @@ .signature = "mh", .release_year = 19, - .release_month = 8, - .release_day = 5, + .release_month = 10, + .release_day = 6, .release_sub = 0, /* max 48 with trailing 0 */ diff -r 695434a6dcf6 -r 14fd5f35cb50 Small_CPU/Src/pressure.c --- a/Small_CPU/Src/pressure.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Small_CPU/Src/pressure.c Thu Oct 10 22:26:03 2019 +0200 @@ -46,11 +46,20 @@ #define CMD_ADC_4096 0x08 // ADC OSR=4096 #define CMD_PROM_RD 0xA0 // Prom read command -#define PRESSURE_SURFACE_MAX_MBAR (1070.0f) /* It is very unlikely that pressure at surface is greater than this value => clip to it */ -#define PRESSURE_HISTORY_SIZE (8u) -#define PRESSURE_JUMP_VALID_MBAR (500.0f) /* values are measure several times a second => jumps > 5m very unlikely */ +/* remove comment to use a predefined profile for pressure changes instead of real world data */ +/* #define SIMULATE_PRESSURE */ + +#define PRESSURE_SURFACE_MAX_MBAR (1030.0f) /* It is unlikely that pressure at surface is greater than this value => clip to it */ +#define PRESSURE_HISTORY_SIZE (8u) +#define PRESSURE_JUMP_VALID_MBAR (500.0f) /* values are measure several times a second => jumps > 5m very unlikely */ -#define PRESSURE_SURFACE_QUE (30u) /* history buffer [minutes] for past pressure measurements */ +#define PRESSURE_SURFACE_QUE (30u) /* history buffer [minutes] for past pressure measurements */ +#define PRESSURE_SURFACE_EVA_WINDOW (15u) /* Number of entries evaluated during instability test. Used to avoid detection while dive enters water */ +#define PRESSURE_SURFACE_STABLE_LIMIT (10u) /* Define pressure as stable if delta (mBar) is below this value */ +#define PRESSURE_SURFACE_DETECT_STABLE_CNT (5u) /* Event count to detect stable condition */ +#define PRESSURE_SURFACE_UNSTABLE_LIMIT (50u) /* Define pressure as not stable if delta (mBar) is larger than this value */ +#define PRESSURE_SURFACE_DETECT_UNSTABLE_CNT (3u) /* Event count to detect unstable condition */ + static uint16_t get_ci_by_coef_num(uint8_t coef_num); //void pressure_calculation_new(void); @@ -86,6 +95,10 @@ static float surface_pressure_mbar = 1000.0; static float surface_ring_mbar[PRESSURE_SURFACE_QUE] = { 0 }; +static uint8_t surface_pressure_writeIndex = 0; +static float surface_pressure_stable_value = 0; +static uint8_t surface_pressure_stable = 0; + static float pressure_history_mbar[PRESSURE_HISTORY_SIZE]; static uint8_t secondCounterSurfaceRing = 0; @@ -119,6 +132,7 @@ for(int i=0; i PRESSURE_SURFACE_UNSTABLE_LIMIT)) /* unusual change during last 30 minutes */ + { + unstablecnt++; + if(unstablecnt > PRESSURE_SURFACE_DETECT_UNSTABLE_CNT) + { + surface_pressure_stable = 0; + } + } + /* search for a value which does not change for several iterations */ + if (fabs(lastvalue - surface_ring_mbar[index]) < PRESSURE_SURFACE_STABLE_LIMIT) + { + stablecnt++; + } + else + { + stablecnt = 0; + } + if ((stablecnt >= PRESSURE_SURFACE_DETECT_STABLE_CNT) && (surface_pressure_stable == 0)&&(surface_pressure_stable_value == surface_ring_mbar[surface_pressure_writeIndex])) /* pressure is unstable => search for new stable value */ + { + surface_pressure_stable_value = surface_ring_mbar[index]; + unstablecnt = 0; + } + + lastvalue = surface_ring_mbar[index]; + + if(index == 0) + { + index = PRESSURE_SURFACE_QUE - 1; + } + else + { + index = index - 1; + } + EvaluatedValues++; + } while (index != surface_pressure_writeIndex); +} void update_surface_pressure(uint8_t call_rhythm_seconds) { - static uint8_t writeIndex = 0; /* Reinitialization will reset all entries to the same value => no need to reinit write index */ if(is_init_pressure_done()) @@ -146,24 +231,25 @@ { if(runningAvg < PRESSURE_SURFACE_MAX_MBAR) { - surface_ring_mbar[writeIndex] = runningAvg; + surface_ring_mbar[surface_pressure_writeIndex] = runningAvg; } else { - surface_ring_mbar[writeIndex] = PRESSURE_SURFACE_MAX_MBAR; + surface_ring_mbar[surface_pressure_writeIndex] = PRESSURE_SURFACE_MAX_MBAR; } - writeIndex++; /* the write index is now pointing to the oldest value in the buffer which will be overwritten next time */ + surface_pressure_writeIndex++; /* the write index is now pointing to the oldest value in the buffer which will be overwritten next time */ - if(writeIndex == PRESSURE_SURFACE_QUE) + if(surface_pressure_writeIndex == PRESSURE_SURFACE_QUE) { - writeIndex = 0; + surface_pressure_writeIndex = 0; } - surface_pressure_mbar = surface_ring_mbar[writeIndex]; /* 30 minutes old measurement */ + surface_pressure_mbar = surface_ring_mbar[surface_pressure_writeIndex]; /* 30 minutes old measurement */ secondCounterSurfaceRing = 0; avgCount = 1; /* use the current value as starting point but restart the weight decrement of the measurements */ } + evaluate_surface_pressure(); } } @@ -425,12 +511,74 @@ } +#ifdef SIMULATE_PRESSURE +void pressure_simulation() +{ + static uint32_t tickstart = 0; + static float pressure_sim_mbar = 0; + static uint32_t passedSecond = 0; + static uint32_t secondtick = 0; + + uint32_t lasttick = 0; + + + + if( tickstart == 0) + { + tickstart = HAL_GetTick(); /* init time stamp */ + secondtick = tickstart; + pressure_sim_mbar = 1000; + } + + lasttick = HAL_GetTick(); + if(time_elapsed_ms(secondtick,lasttick) > 1000) /* one second passed since last tick */ + { + secondtick = lasttick; + passedSecond++; + +#ifdef DIVE_AFTER_LANDING + if(passedSecond < 10) pressure_sim_mbar = 1000.0; /* stay stable for 10 seconds */ + else if(passedSecond < 300) pressure_sim_mbar -= 1.0; /* decrease pressure in 5 minutes target 770mbar => delta 330 */ + else if(passedSecond < 900) pressure_sim_mbar += 0.0; /*stay stable 10 minutes*/ + else if(passedSecond < 1500) pressure_sim_mbar += 0.5; /* return to 1 bar in 10 Minutes*/ + else if(passedSecond < 1800) pressure_sim_mbar += 0.0; /* 5 minutes break */ + else if(passedSecond < 2000) pressure_sim_mbar += 10.0; /* start dive */ + else if(passedSecond < 2300) pressure_sim_mbar += 0.0; /* stay on depth */ + else if(passedSecond < 2500) pressure_sim_mbar -= 10.0; /* return to surface */ + else pressure_sim_mbar = 1000.0; /* final state */ +#else /* short dive */ + if(passedSecond < 10) pressure_sim_mbar = 1000.0; /* stay stable for 10 seconds */ + else if(passedSecond < 180) pressure_sim_mbar += 10.0; /* Start dive */ + else if(passedSecond < 300) pressure_sim_mbar += 0.0; /*stay on depth*/ + else if(passedSecond < 460) pressure_sim_mbar -= 10.0; /* return to surface */ + else if(passedSecond < 600) pressure_sim_mbar += 0.0; /* stay */ + else if(passedSecond < 610) pressure_sim_mbar = 1000.0; /* get ready for second dive */ + else if(passedSecond < 780) pressure_sim_mbar += 10.0; /* Start dive */ + else if(passedSecond < 900) pressure_sim_mbar += 0.0; /*stay on depth*/ + else if(passedSecond < 1060) pressure_sim_mbar -= 10.0; /* return to surface */ + else if(passedSecond < 1200) pressure_sim_mbar += 0.0; /* stay */ + else pressure_sim_mbar = 1000.0; /* final state */ +#endif + } + + + ambient_pressure_mbar = pressure_sim_mbar; + ambient_temperature = 25.0; + return; +} + +#endif + void pressure_calculation(void) { if(global.I2C_SystemStatus != HAL_OK) return; - + +#ifdef SIMULATE_PRESSURE + pressure_simulation(); +#else pressure_calculation_AN520_004_mod_MS5803_30BA__09_2015(); +#endif } static uint8_t pressure_plausible(float pressurevalue) @@ -554,156 +702,6 @@ } -/* -void pressure_calculation_new(void) -{ -#define POW2_8 (256) -#define POW2_17 (131072) -#define POW2_6 (64) -#define POW2_16 (65536) -#define POW2_7 (128) -#define POW2_23 (8388608) -#define POW2_21 (2097152) -#define POW2_15 (32768) -#define POW2_13 (8192) -#define POW2_37 (137438953472) -#define POW2_4 (16) -#define POW2_33 (8589934592) -#define POW2_3 (8) - - int32_t P; // compensated pressure value - int32_t T; // compensated temperature value - int32_t dT; // difference between actual and measured temperature - int64_t OFF; // offset at actual temperature - int64_t SENS; - - int32_t T2; - int64_t OFF2; - int64_t SENS2; - - dT = ((int32_t)D2) - ((int32_t)C[5]) * POW2_8; - OFF = ((int64_t)C[2]) * POW2_16 + ((int64_t)dT) * ((int64_t)C[4]) / POW2_7; - SENS = ((int64_t)C[1]) * POW2_15 + ((int64_t)dT) * ((int64_t)C[3]) / POW2_8; - - T = 2000 + (dT * ((int32_t)C[6])) / POW2_23; - - -if(T < 2000) // low temperature - { - T2 = 3 * dT * dT; - T2 /= POW2_33; - OFF2 = ((int64_t)T) - 2000; - OFF2 *= OFF2; - OFF2 *= 3; - OFF2 /= 2; - SENS2 = ((int64_t)T) - 2000; - SENS2 *= SENS2; - SENS2 *= 5; - SENS2 /= POW2_3; - } - else // high temperature - { - T2 = 7 * dT * dT; - T2 /= POW2_37; - OFF2 = ((int64_t)T) - 2000; - OFF2 *= OFF2; - OFF2 /= POW2_4; - SENS2 = 0; - } - - T = T - T2; - OFF = OFF - OFF2; - SENS = SENS - SENS2; - - P = (int32_t)(((((int64_t)D1) * SENS) / POW2_21 - OFF) / POW2_13); - - ambient_temperature = ((float)T) / 100; - ambient_pressure_mbar = ((float)P) / 10; -} -*/ - -/* -void pressure_calculation_old(void) { - // - double ambient_temperature_centigrad = 0; - double ambient_pressure_decimbar = 0; - - // static for debug - static int64_t dt = 0; - static int64_t temp = 0; - static int64_t ms_off = 0; - static int64_t sens = 0; - // - static int64_t ms_off2 = 0; - static int64_t sens2 = 0; - static int64_t t2 = 0; - - if((D2 == 0) || (D1 == 0)) - return; - // - - // dT = D2 - C[5] * POW2_8; - // T = 2000 + (dT * C[6]) / POW2_23; - dt = (int64_t)D2 - C5_x_2p8; - //temp ; // in 10 milliGrad Celcius - ambient_temperature_centigrad = 2000 + dt * C[6] / 8388608; - - - if(ambient_temperature_centigrad < 2000) // low temperature - { - t2 = 3 * dt; - t2 *= dt; - t2 /= 8589934592; - ms_off2 = ambient_temperature_centigrad - 2000; - ms_off2 *= ms_off2; - sens2 = ms_off2; - ms_off2 *= 3; - ms_off2 /= 2; - sens2 *= 5; - sens2 /= 8; - } - else // high temperature - { - t2 = 7 * dt; - t2 *= dt; - t2 /= 137438953472; - ms_off2 = ambient_temperature_centigrad - 2000; - ms_off2 *= ms_off2; - ms_off2 /= 16; - sens2 = 0; - } - - - // - - // pressure - // OFF = C[2] * POW2_16 + dT * C[4] / POW2_7; - // SENS = C[1] * POW2_15 + dT * C[3] / POW2_8; - ms_off = C[4] * dt; - ms_off /= 128; - ms_off += C2_x_2p16; - // - sens = C[3] * dt; - sens /= 256; - sens += C1_x_2p15; - - // 2nd order correction - ambient_temperature_centigrad -= t2; - ms_off -= ms_off2; - sens -= sens2; - - ambient_temperature = ambient_temperature_centigrad / 100; - // P = (D1 * SENS / POW2_21 - OFF) / POW2_13; - temp = D1 * sens; - temp /= 2097152; - temp -= ms_off; - temp /= 8192; - ambient_pressure_decimbar = temp; // to float/double - ambient_pressure_mbar = ambient_pressure_decimbar / 10; -} -*/ - - /* taken from AN520 by meas-spec.com dated 9. Aug. 2011 * short and int are both 16bit according to AVR/GCC google results */ diff -r 695434a6dcf6 -r 14fd5f35cb50 Small_CPU/Src/scheduler.c --- a/Small_CPU/Src/scheduler.c Thu Oct 10 22:11:59 2019 +0200 +++ b/Small_CPU/Src/scheduler.c Thu Oct 10 22:26:03 2019 +0200 @@ -57,6 +57,8 @@ uint8_t deviceDataSubSeconds = 0; /* Private variables ---------------------------------------------------------*/ +static uint16_t ManualExitDiveCounter = 0; /* The computer will exit dive mode in shallow area immediately. Increase depth to restart dive while counter is active */ + /* can be lost while in sleep */ uint8_t clearDecoNow = 0; uint8_t setButtonsNow = 0; @@ -262,6 +264,11 @@ } } + if(global.dataSendToSlave.setEndDive) + { + ManualExitDiveCounter = 30 * 60; /* This will cause the computer to leave dive mode if in shallow area and increase the depth to enter dive mode for the next 30 minutes */ + } + if((global.mode == MODE_SURFACE) && (global.dataSendToSlave.mode == MODE_SHUTDOWN)) { global.mode = MODE_SHUTDOWN; @@ -461,6 +468,14 @@ scheduleSetDate(&global.deviceData.diveCycles); global.lifeData.counterSecondsShallowDepth = 0; + /* Get the last stable value in case of an unstable surface history condition */ + if(!is_surface_pressure_stable()) + { + set_last_surface_pressure_stable(); + } + global.lifeData.pressure_surface_bar = get_surface_mbar() / 1000.0f; + ManualExitDiveCounter = 0; /* reset early exit request */ + Scheduler.tickstart = HAL_GetTick(); while(global.mode == MODE_DIVE) { @@ -556,11 +571,12 @@ global.demo_mode = 0; } } - + if(is_ambient_pressure_close_to_surface(&global.lifeData)) { global.lifeData.counterSecondsShallowDepth++; - if((global.lifeData.counterSecondsShallowDepth >= global.settings.timeoutDiveReachedZeroDepth) || ((global.lifeData.dive_time_seconds < 60) && (global.demo_mode == 0)) || (global.dataSendToSlave.setEndDive)) + if((global.lifeData.counterSecondsShallowDepth >= global.settings.timeoutDiveReachedZeroDepth) || ((global.lifeData.dive_time_seconds < 60) && (global.demo_mode == 0)) + || (ManualExitDiveCounter)) { global.seconds_since_last_dive = 1; // start counter schedule_update_timer_helper(0); // zum starten :-) @@ -600,7 +616,7 @@ { global.lifeData.dive_time_seconds = 0; // this apnea dive ends here } - if((global.lifeData.counterSecondsShallowDepth >= global.settings.timeoutDiveReachedZeroDepth) || (global.dataSendToSlave.setEndDive)) + if((global.lifeData.counterSecondsShallowDepth >= global.settings.timeoutDiveReachedZeroDepth) || (ManualExitDiveCounter)) { global.dataSendToMaster.mode = MODE_ENDDIVE; global.deviceDataSendToMaster.mode = MODE_ENDDIVE; @@ -814,6 +830,11 @@ clearDecoNow = 0; } + if(ManualExitDiveCounter) + { + ManualExitDiveCounter--; + } + if(global.seconds_since_last_dive) { schedule_update_timer_helper(-1); @@ -1381,6 +1402,7 @@ global.dataSendToMaster.data[boolPressureData].ascent_rate_meter_per_min = global.lifeData.ascent_rate_meter_per_min; global.dataSendToMaster.data[boolPressureData].pressure_uTick = HAL_GetTick(); global.dataSendToMaster.boolPressureData = boolPressureData; + global.dataSendToMaster.data[boolPressureData].SPARE1 = is_surface_pressure_stable(); } @@ -1587,16 +1609,25 @@ /* same as in data_central.c */ _Bool is_ambient_pressure_close_to_surface(SLifeData *lifeData) { - if(lifeData->pressure_ambient_bar == INVALID_PREASURE_VALUE) /* as long as no valid data is available expect we are close to surface */ + _Bool retval = true; + + if(lifeData->pressure_ambient_bar != INVALID_PREASURE_VALUE) /* as long as no valid data is available expect we are close to surface */ { - return true; + /* this will e.g. apply in case of a significant pressure change during last 30 minutes => use increased offset for surface detection */ + if (lifeData->pressure_ambient_bar > START_DIVE_IMMEDIATLY_BAR) + { + retval = false; + } + else if(is_surface_pressure_stable()) /* this is the expected start condition */ + { + if((lifeData->pressure_ambient_bar >= (lifeData->pressure_surface_bar + 0.1f)) + && (ManualExitDiveCounter == 0)) /* only if diver did not request to exit dive mode */ + { + retval = false; + } + } } - if (lifeData->pressure_ambient_bar > START_DIVE_IMMEDIATLY_BAR) - return false; - else if(lifeData->pressure_ambient_bar < (lifeData->pressure_surface_bar + 0.1f)) // hw 161121 now 1 mter, before 0.04f - return true; - else - return false; + return retval; } diff -r 695434a6dcf6 -r 14fd5f35cb50 ostc4pack/OSTC4_Firmware.bin diff -r 695434a6dcf6 -r 14fd5f35cb50 ostc4pack/OSTC4_firmware_upload.bin