# HG changeset patch # User heinrichsweikamp # Date 1589873238 0 # Node ID 230aed360da00ab0acf55049dc8fbdf7b575cbb1 # Parent 8a375f0544d9f4b4bb27f76ebe6c60a34b988358# Parent 89f6857276f82bd10bb652fbcb9251681df24f8a Merged in Ideenmodellierer/ostc4/Improve_Button_Sleep (pull request #45) Improve Button Sleep diff -r 8a375f0544d9 -r 230aed360da0 Common/Inc/data_central.h --- a/Common/Inc/data_central.h Tue Apr 28 15:37:47 2020 +0000 +++ b/Common/Inc/data_central.h Tue May 19 07:27:18 2020 +0000 @@ -248,6 +248,9 @@ int8_t betterGas; int8_t fallback; int8_t betterSetpoint; +#ifdef ENABLE_BOTTLE_SENSOR + int8_t newPressure; +#endif } SWarnings; diff -r 8a375f0544d9 -r 230aed360da0 Discovery/Src/base.c --- a/Discovery/Src/base.c Tue Apr 28 15:37:47 2020 +0000 +++ b/Discovery/Src/base.c Tue May 19 07:27:18 2020 +0000 @@ -426,6 +426,7 @@ tInfoLog_init(); tComm_init(); DataEX_init(); + settingsHelperButtonSens_keepPercentageValues(settingsGetPointer()->ButtonResponsiveness[3], settingsGetPointer()->ButtonResponsiveness); setButtonResponsiveness( settingsGetPointer()->ButtonResponsiveness ); set_globalState_tHome(); diff -r 8a375f0544d9 -r 230aed360da0 Discovery/Src/check_warning.c --- a/Discovery/Src/check_warning.c Tue Apr 28 15:37:47 2020 +0000 +++ b/Discovery/Src/check_warning.c Tue May 19 07:27:18 2020 +0000 @@ -54,7 +54,9 @@ static int8_t check_BetterGas(SDiveState * pDiveState); static int8_t check_BetterSetpoint(SDiveState * pDiveState); static int8_t check_Battery(SDiveState * pDiveState); - +#ifdef ENABLE_BOTTLE_SENSOR +static int8_t check_pressureSensor(SDiveState * pDiveState); +#endif static int8_t check_helper_same_oxygen_and_helium_content(SGasLine * gas1, SGasLine * gas2); /* Exported functions --------------------------------------------------------*/ @@ -79,6 +81,9 @@ 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 } @@ -406,5 +411,21 @@ return pDiveState->warnings.aGf; } +#ifdef ENABLE_BOTTLE_SENSOR +static int8_t check_pressureSensor(SDiveState * pDiveState) +{ + int8_t ret = 0; + if(pDiveState->lifeData.bottle_bar_age_MilliSeconds[pDiveState->lifeData.actualGas.GasIdInSettings] < 50) /* we received a new value */ + { + pDiveState->warnings.newPressure = stateUsed->lifeData.bottle_bar[stateUsed->lifeData.actualGas.GasIdInSettings]; + ret = 1; + } + else + { + pDiveState->warnings.newPressure = 0; + } + return ret; +} +#endif /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ diff -r 8a375f0544d9 -r 230aed360da0 Discovery/Src/gfx_engine.c --- a/Discovery/Src/gfx_engine.c Tue Apr 28 15:37:47 2020 +0000 +++ b/Discovery/Src/gfx_engine.c Tue May 19 07:27:18 2020 +0000 @@ -3085,6 +3085,8 @@ 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 SSettings *pSettings; @@ -3102,6 +3104,22 @@ j = 0; while (*(char*)pText != 0)// und fehlend: Abfrage window / image size { + if(*(char*)pText == '\016') /* request font change */ + { + tinyState++; + } + if(*(char*)pText == '\017') /* request font reset */ + { + tinyState = 0; + } + if(tinyState > 1) + { + ptargetFont = (tFont *)cfg->TinyFont; + } + else + { + ptargetFont = (tFont *)cfg->font; + } if((*(char*)pText) & 0x80) /* Identify a UNICODE character other than standard ASCII using the highest bit */ { decodeUTF8 = ((*(char*)pText) & 0x1F) << 6; /* use 5bits of first byte for upper part of unicode */ @@ -3113,20 +3131,20 @@ decodeUTF8 = *(char*)pText; /* place ASCII char */ } - for(i=0;i<((tFont *)cfg->font)->length;i++) + for(i=0;ilength;i++) { - if(((tFont *)cfg->font)->chars[i].code == decodeUTF8) + if(ptargetFont->chars[i].code == decodeUTF8) { - Xsum += ((tFont *)cfg->font)->chars[i].image->width; + Xsum += ptargetFont->chars[i].image->width; break; } } pText++; j++; - if(((tFont *)cfg->font == &FontT144) && (*(char*)pText != 0)) + if((ptargetFont == &FontT144) && (*(char*)pText != 0)) Xsum += 3; else - if(((tFont *)cfg->font == &FontT105) && (*(char*)pText != 0)) + if((ptargetFont == &FontT105) && (*(char*)pText != 0)) Xsum += 2; } pText -= j; diff -r 8a375f0544d9 -r 230aed360da0 Discovery/Src/t7.c --- a/Discovery/Src/t7.c Tue Apr 28 15:37:47 2020 +0000 +++ b/Discovery/Src/t7.c Tue May 19 07:27:18 2020 +0000 @@ -789,16 +789,18 @@ { text[0] = '\001'; text[1] = '\004'; - text[2] = TXT_2BYTE; - text[3] = TXT2BYTE_Sunday; - text[4] = 0; + text[2] = '\016'; + text[3] = '\016'; + text[4] = TXT_2BYTE; + text[5] = TXT2BYTE_Sunday; + text[6] = 0; if(Sdate.WeekDay != RTC_WEEKDAY_SUNDAY) - text[3] += Sdate.WeekDay; + text[5] += Sdate.WeekDay; if(!(Stime.Seconds % 2) && (dateNotSet == 1)) text[1] = '\021'; - GFX_write_string(&FontT24,&t7surfaceR,text,4); + GFX_write_string(&FontT48,&t7surfaceR,text,4); } /* DEBUG uTick Pressure and Compass */ @@ -828,8 +830,7 @@ */ /* noFlyTime or DesaturationTime */ - - if((!display_count_high_time) && (stateUsed->lifeData.no_fly_time_minutes)) + if((stateUsed->lifeData.no_fly_time_minutes) && ((!display_count_high_time) || (stateUsed->lifeData.desaturation_time_minutes == 0))) { SSurfacetime NoFlyTime = {0,0,0,0}; t7_fill_surfacetime_helper(&NoFlyTime,stateUsed->lifeData.no_fly_time_minutes, 0); @@ -1321,6 +1322,12 @@ //count += stateUsed->warnings.lowBattery; count += stateUsed->warnings.sensorLinkLost; count += stateUsed->warnings.fallback; +#ifdef ENABLE_BOTTLE_SENSOR + if(stateUsed->warnings.newPressure) + { + count++; + } +#endif return count; } @@ -1331,6 +1338,12 @@ count = 0; count += stateUsed->cnsHigh_at_the_end_of_dive; count += stateUsed->decoMissed_at_the_end_of_dive; +#ifdef ENABLE_BOTTLE_SENSOR + if(stateUsed->warnings.newPressure) + { + count++; + } +#endif return count; } @@ -1369,6 +1382,14 @@ text[textpointer] = 0; lineFree--; } +#ifdef ENABLE_BOTTLE_SENSOR + if(stateUsed->warnings.newPressure) + { + sprintf(&text[textpointer] ," %u Bar\n", stateUsed->warnings.newPressure); + textpointer++; + lineFree--; + } +#endif if(textpointer != 0) GFX_write_string(&FontT48,&t7cW,text,1); } @@ -1438,6 +1459,14 @@ text[textpointer] = 0; lineFree--; } +#ifdef ENABLE_BOTTLE_SENSOR + if(stateUsed->warnings.newPressure) + { + sprintf(&text[textpointer]," %u Bar\n", stateUsed->warnings.newPressure); + textpointer++; + lineFree--; + } +#endif /* if(lineFree && stateUsed->warnings.lowBattery) { diff -r 8a375f0544d9 -r 230aed360da0 Small_CPU/Src/baseCPU2.c --- a/Small_CPU/Src/baseCPU2.c Tue Apr 28 15:37:47 2020 +0000 +++ b/Small_CPU/Src/baseCPU2.c Tue May 19 07:27:18 2020 +0000 @@ -343,29 +343,32 @@ init_battery_gas_gauge(); HAL_Delay(10); battery_gas_gauge_get_data(); - if(coldstart != 0xA5) + + MX_SPI3_Init(); + + if(coldstart != 0xA5) /* Not reading a 0xA5 means the memory cells has not been initialized before => cold start */ { coldstart = 0xA5; battery_gas_gauge_set(0); + global.dataSendToMaster.power_on_reset = 1; + global.deviceDataSendToMaster.power_on_reset = 1; + + if (!scheduleSetButtonResponsiveness()) + { + HAL_Delay(1); + if (!scheduleSetButtonResponsiveness()) // send again, if problem it's not my problem here. + { + HAL_Delay(1); + scheduleSetButtonResponsiveness(); // init + HAL_Delay(1); + } + } } global.lifeData.battery_voltage = get_voltage(); global.lifeData.battery_charge = get_charge(); copyBatteryData(); - MX_SPI3_Init(); - if (!scheduleSetButtonResponsiveness()) { - HAL_Delay(1); - scheduleSetButtonResponsiveness(); // init - HAL_Delay(1); - if (!scheduleSetButtonResponsiveness()) // send again, if problem it's not my problem here. - { - HAL_Delay(1); - scheduleSetButtonResponsiveness(); // init - HAL_Delay(1); - } - } - ADCx_Init(); GPIO_Power_MainCPU_Init(); global.mode = MODE_POWERUP; diff -r 8a375f0544d9 -r 230aed360da0 Small_CPU/Src/pressure.c --- a/Small_CPU/Src/pressure.c Tue Apr 28 15:37:47 2020 +0000 +++ b/Small_CPU/Src/pressure.c Tue May 19 07:27:18 2020 +0000 @@ -50,7 +50,6 @@ /* #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_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 */ @@ -100,8 +99,6 @@ 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; static uint8_t avgCount = 0; static float runningAvg = 0; @@ -137,14 +134,6 @@ } } -void init_pressure_history(void) -{ - for(int i=0; i