Mercurial > public > ostc4
changeset 446:f1257a32f2d4 minor_improvments
Introduced configuration header for variant managment:
At the moment several defines are distributed across the code allowing special SW builds (e.g. logging simulated dives). To make these options more transparent and easier to configurate a separate header has been added. With this header an new option for an optical pressure sensor was introduced.
author | ideenmodellierer |
---|---|
date | Thu, 05 Mar 2020 22:31:50 +0100 |
parents | ee1434824c3f |
children | adc4ccbebbb5 |
files | Discovery/Inc/configuration.h Discovery/Inc/t7.h Discovery/Src/base.c Discovery/Src/data_exchange_main.c Discovery/Src/simulation.c Discovery/Src/t7.c Discovery/Src/tCCR.c Discovery/Src/tMenuEditSystem.c |
diffstat | 8 files changed, 100 insertions(+), 63 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Discovery/Inc/configuration.h Thu Mar 05 22:31:50 2020 +0100 @@ -0,0 +1,37 @@ +/////////////////////////////////////////////////////////////////////////////// +/// -*- coding: UTF-8 -*- +/// +/// \file Discovery/Inc/configuration.h +/// \brief Header file for variant specific firmware adaptations at compile time +/// \author heinrichs weikamp gmbh +/// \date 29-February-2020 +/// +/// $Id$ +/////////////////////////////////////////////////////////////////////////////// +/// \par Copyright (c) 2014-2020 Heinrichs Weikamp gmbh +/// +/// This program is free software: you can redistribute it and/or modify +/// it under the terms of the GNU General Public License as published by +/// the Free Software Foundation, either version 3 of the License, or +/// (at your option) any later version. +/// +/// This program is distributed in the hope that it will be useful, +/// but WITHOUT ANY WARRANTY; without even the implied warranty of +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/// GNU General Public License for more details. +/// +/// You should have received a copy of the GNU General Public License +/// along with this program. If not, see <http://www.gnu.org/licenses/>. +////////////////////////////////////////////////////////////////////////////// + + +#ifndef CONFIGURATION_HEADER +#define CONFIGURATION_HEADER + +/* Enable this to make the simulator write a logbook entry */ +/* #define SIM_WRITES_LOGBOOK 1 */ + +/* Enable this for support of optical bottle pressure interface */ +#define ENABLE_BOTTLE_SENSOR + +#endif
--- a/Discovery/Inc/t7.h Thu Mar 05 22:27:55 2020 +0100 +++ b/Discovery/Inc/t7.h Thu Mar 05 22:31:50 2020 +0100 @@ -31,6 +31,7 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_hal.h" #include "gfx_engine.h" +#include "configuration.h" typedef enum @@ -44,7 +45,9 @@ LLC_FutureTTS, LLC_CNS, LLC_GF, +#ifdef ENABLE_BOTTLE_SENSOR LCC_BottleBar, +#endif LLC_END } customview_llc_t;
--- a/Discovery/Src/base.c Thu Mar 05 22:27:55 2020 +0100 +++ b/Discovery/Src/base.c Thu Mar 05 22:31:50 2020 +0100 @@ -199,6 +199,7 @@ /* Includes ------------------------------------------------------------------*/ #include "stdio.h" #include <string.h> // for memcopy +#include "configuration.h" #include "stm32f4xx_hal.h" #include "ostc.h" @@ -327,12 +328,6 @@ return(ch); } */ -/* #define DEBUG_RUNTIME TRUE */ -#ifdef DEBUG_RUNTIME -#define MEASURECNT 60 /* number of measuremets to be stored */ -static uint32_t loopcnt[MEASURECNT]; -#endif - static uint8_t ButtonAction = ACTION_END; static void StoreButtonAction(uint8_t action) @@ -350,11 +345,6 @@ { uint32_t pLayerInvisible; uint16_t totalDiveCounterFound; -#ifdef DEBUG_RUNTIME - RTC_TimeTypeDef Stime; - uint8_t measurementindex = 0; - uint8_t lastsecond = 0xFF; -#endif SStateList status; detectionState_t pitchstate; @@ -527,9 +517,6 @@ } -// Enable this to make the simulator write a logbook entry -// #define SIM_WRITES_LOGBOOK 1 - #ifdef SIM_WRITES_LOGBOOK if(stateUsed == stateSimGetPointer()) logbook_InitAndWrite(stateUsed); @@ -537,27 +524,6 @@ if(stateUsed == stateRealGetPointer()) /* Handle log entries while in dive mode*/ logbook_InitAndWrite(stateUsed); } - -#ifdef DEBUG_RUNTIME - translateTime(stateUsed->lifeData.timeBinaryFormat, &Stime); - if(lastsecond == 0xFF) - { - measurementindex = 0; - loopcnt[measurementindex] = 0; - lastsecond = Stime.Seconds; - } - loopcnt[measurementindex]++; - - if(lastsecond != Stime.Seconds) - { - measurementindex++; - if (measurementindex == MEASURECNT) measurementindex = 0; - loopcnt[measurementindex] = 0; - lastsecond = Stime.Seconds; - if(measurementindex +1 < MEASURECNT) loopcnt[measurementindex +1] = 0xffff; /* helps to identify the latest value */ - } -#endif - } }
--- a/Discovery/Src/data_exchange_main.c Thu Mar 05 22:27:55 2020 +0100 +++ b/Discovery/Src/data_exchange_main.c Thu Mar 05 22:31:50 2020 +0100 @@ -764,6 +764,7 @@ // wireless - �ltere daten aufr�umen +#if 0 for(int i=0;i<(2*NUM_GASES+1);i++) { if(pStateReal->lifeData.bottle_bar[i]) @@ -777,7 +778,12 @@ pStateReal->lifeData.bottle_bar_age_MilliSeconds[i] += 100; } } - +#else + if(stateRealGetPointer()->lifeData.bottle_bar_age_MilliSeconds[1] < 6000) /* max age after ten minutes */ + { + stateRealGetPointerWrite()->lifeData.bottle_bar_age_MilliSeconds[1]++; + } +#endif if(!DataEX_check_header_and_footer_ok()) { if(DataEX_check_header_and_footer_devicedata())
--- a/Discovery/Src/simulation.c Thu Mar 05 22:27:55 2020 +0100 +++ b/Discovery/Src/simulation.c Thu Mar 05 22:31:50 2020 +0100 @@ -128,7 +128,10 @@ pDiveState->lifeData.temperature_celsius = stateRealGetPointer()->lifeData.temperature_celsius; pDiveState->lifeData.compass_heading = stateRealGetPointer()->lifeData.compass_heading; pDiveState->lifeData.battery_charge = stateRealGetPointer()->lifeData.battery_charge; - +#ifdef ENABLE_BOTTLE_SENSOR + pDiveState->lifeData.bottle_bar[pDiveState->lifeData.actualGas.GasIdInSettings] = stateRealGetPointer()->lifeData.bottle_bar[stateRealGetPointer()->lifeData.actualGas.GasIdInSettings]; + pDiveState->lifeData.bottle_bar_age_MilliSeconds[pDiveState->lifeData.actualGas.GasIdInSettings] = stateRealGetPointer()->lifeData.bottle_bar_age_MilliSeconds[stateRealGetPointer()->lifeData.actualGas.GasIdInSettings]; +#endif int now = current_second(); if( last_second == now) return;
--- a/Discovery/Src/t7.c Thu Mar 05 22:27:55 2020 +0100 +++ b/Discovery/Src/t7.c Thu Mar 05 22:31:50 2020 +0100 @@ -2652,11 +2652,13 @@ headerText[2] = TXT_ActualGradient; snprintf(text,TEXTSIZE,"\020%.0f\016\016%%\017",100 * pDecoinfoStandard->super_saturation); break; +#ifdef ENABLE_BOTTLE_SENSOR case LCC_BottleBar: headerText[2] = TXT_AtemGasVorrat; tinyHeaderFont = 1; snprintf(text,TEXTSIZE,"%d\016\016\017", stateUsed->lifeData.bottle_bar[1]); break; +#endif } headerText[3] = 0; @@ -2666,7 +2668,10 @@ GFX_write_string(&FontT42,&t7l3,headerText,0); t7_colorscheme_mod(text); - if(selection_custom_field != LCC_BottleBar) +#ifndef ENABLE_BOTTLE_SENSOR + GFX_write_string(&FontT105,&t7l3,text,line); +#else + if(selection_custom_field != LCC_BottleBar) /* a changing color set is used for bar display */ { GFX_write_string(&FontT105,&t7l3,text,line); } @@ -2689,6 +2694,7 @@ GFX_write_string_color(&FontT105,&t7l3,text,line,agedColor); } +#endif } /* Private functions ---------------------------------------------------------*/
--- a/Discovery/Src/tCCR.c Thu Mar 05 22:27:55 2020 +0100 +++ b/Discovery/Src/tCCR.c Thu Mar 05 22:31:50 2020 +0100 @@ -33,6 +33,7 @@ #include "data_central.h" #include "data_exchange.h" #include "check_warning.h" +#include "configuration.h" /* Private types -------------------------------------------------------------*/ typedef struct @@ -350,6 +351,9 @@ void tCCR_control(void) { + uint16_t checksum = 0; + SDiveState *pLivedata = stateRealGetPointerWrite(); + if((UartReadyHUD == RESET) && StartListeningToUART_HUD && (time_elapsed_ms(LastReceivedTick_HUD, HAL_GetTick()) > HUD_RX_START_DELAY_MS)) { @@ -362,31 +366,41 @@ UartReadyHUD = RESET; StartListeningToUART_HUD = 1; - memcpy(&receiveHUD[!boolHUDdata], receiveHUDraw, 11); - receiveHUD[!boolHUDdata].battery_voltage_mV = receiveHUDraw[11] + (256 * receiveHUDraw[12]); - receiveHUD[!boolHUDdata].checksum = receiveHUDraw[13] + (256 * receiveHUDraw[14]); - - uint16_t checksum = 0; + /* check if received package is valid */ + for(int i=0;i<13;i++) + { + checksum += receiveHUDraw[i]; + } + receiveHUD[!boolHUDdata].checksum = receiveHUDraw[13] + (256 * receiveHUDraw[14]); + if(checksum == receiveHUD[!boolHUDdata].checksum) + { +#ifdef ENABLE_BOTTLE_SENSOR + if(receiveHUDraw[0] == 0xA5) /* code for pressure sensor */ + { + pLivedata->lifeData.bottle_bar[pLivedata->lifeData.actualGas.GasIdInSettings] = receiveHUDraw[10]; + pLivedata->lifeData.bottle_bar_age_MilliSeconds[pLivedata->lifeData.actualGas.GasIdInSettings] = 0; + } + else +#endif + /* handle O2 sensor data */ + { + memcpy(&receiveHUD[!boolHUDdata], receiveHUDraw, 11); + receiveHUD[!boolHUDdata].battery_voltage_mV = receiveHUDraw[11] + (256 * receiveHUDraw[12]); + } - for(int i=0;i<13;i++) - { - checksum += receiveHUDraw[i]; - } - if(checksum == receiveHUD[!boolHUDdata].checksum) - { - boolHUDdata = !boolHUDdata; - HUDTimeoutCount = 0; - data_old__lost_connection_to_HUD = 0; - } - else - { - if(data_old__lost_connection_to_HUD) /* we lost connection, maybe due to RX shift => start single byte read to resynchronize */ - { - HAL_UART_Receive_IT(&UartIR_HUD_Handle, receiveHUDraw, 1); - StartListeningToUART_HUD = 0; - } - } - memset(receiveHUDraw,0,sizeof(receiveHUDraw)); + boolHUDdata = !boolHUDdata; + HUDTimeoutCount = 0; + data_old__lost_connection_to_HUD = 0; + } + else + { + if(data_old__lost_connection_to_HUD) /* we lost connection, maybe due to RX shift => start single byte read to resynchronize */ + { + HAL_UART_Receive_IT(&UartIR_HUD_Handle, receiveHUDraw, 1); + StartListeningToUART_HUD = 0; + } + } + memset(receiveHUDraw,0,sizeof(receiveHUDraw)); } }
--- a/Discovery/Src/tMenuEditSystem.c Thu Mar 05 22:27:55 2020 +0100 +++ b/Discovery/Src/tMenuEditSystem.c Thu Mar 05 22:31:50 2020 +0100 @@ -906,11 +906,13 @@ case LLC_GF: text[4] = TXT_ActualGradient; break; +#ifdef ENABLE_BOTTLE_SENSOR case LCC_BottleBar: text[4] = TXT_AtemGasVorrat; break; +#endif /* none */ - case 0: + case LLC_Empty: text[4] = '-'; break; default: