# HG changeset patch # User Ideenmodellierer # Date 1553373136 -3600 # Node ID adc1e7d628be2aeeade4125acf57c23fe7f2de8b # Parent 7116c0ffb862909c18d3d28d5c34790a768de188# Parent d328abe2e44e30e93d9a36abf02965b5430f0764 merge fork diff -r d328abe2e44e -r adc1e7d628be Discovery/Inc/logbook.h --- a/Discovery/Inc/logbook.h Sun Mar 17 19:16:59 2019 +0100 +++ b/Discovery/Inc/logbook.h Sat Mar 23 21:32:16 2019 +0100 @@ -200,7 +200,6 @@ } SManualGas; void logbook_writeSample(SDiveState state); -//void logbook_writeSampleFinalBytes(void); void logbook_initNewdiveProfile(const SDiveState* pInfo, SSettings* pSettings); void logbook_EndDive(void); diff -r d328abe2e44e -r adc1e7d628be Discovery/Inc/t9.h --- a/Discovery/Inc/t9.h Sun Mar 17 19:16:59 2019 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -/// -*- coding: UTF-8 -*- -/// -/// \file Discovery/Inc/t9.h -/// \brief Header file of Divemode with 9 windows, based on t7 -/// \author heinrichs weikamp gmbh -/// \date 7-July-2016 -/// -/// $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 . -////////////////////////////////////////////////////////////////////////////// - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef T9_H -#define T9_H - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_hal.h" -#include "gfx_engine.h" - -/* Exported functions --------------------------------------------------------*/ -void t9_init(void); - -void t9_refresh(void); -void t9_refresh_sleepmode_fun(void); -void t9_refresh_customview_old(void); - -void t9_change_field(void); -void t9_change_customview(void); - -void t9_set_field_to_primary(void); -void t9_set_customview_to_primary(void); - -void init_t9_compass(void); - -/* - void t9c_refresh(uint32_t FramebufferStartAddress); -*/ - -#endif /* T9_H */ diff -r d328abe2e44e -r adc1e7d628be Discovery/Src/data_exchange_main.c --- a/Discovery/Src/data_exchange_main.c Sun Mar 17 19:16:59 2019 +0100 +++ b/Discovery/Src/data_exchange_main.c Sat Mar 23 21:32:16 2019 +0100 @@ -38,7 +38,7 @@ second small CPU gets request to send its device data - on receiption the data is merged with the data in externLogbookFlash, + on reception the data is merged with the data in externLogbookFlash, stored on the externLogbookFlash and from now on send to small CPU ============================================================================== @@ -56,7 +56,7 @@ /* Includes ------------------------------------------------------------------*/ #include -#include // for memcopy +#include // for memcpy #include "stm32f4xx_hal.h" #include "stdio.h" #include "ostc.h" @@ -74,63 +74,41 @@ /* Exported variables --------------------------------------------------------*/ -uint8_t wasPowerOn = 0; -confirmbit8_Type requestNecessary = { .uw = 0 }; -uint8_t wasUpdateNotPowerOn = 0; +static uint8_t wasPowerOn = 0; +static confirmbit8_Type requestNecessary = { .uw = 0 }; +static uint8_t wasUpdateNotPowerOn = 0; /* Private variables with external access ------------------------------------*/ - /* Private variables ---------------------------------------------------------*/ -uint8_t told_reset_logik_alles_ok = 0; +static uint8_t told_reset_logik_alles_ok = 0; -SDataReceiveFromMaster dataOut; -SDataExchangeSlaveToMaster dataIn; +static SDataReceiveFromMaster dataOut; +static SDataExchangeSlaveToMaster dataIn; -uint8_t data_old__lost_connection_to_slave_counter_temp = 0; -uint8_t data_old__lost_connection_to_slave_counter_retry = 0; -uint32_t data_old__lost_connection_to_slave_counter_total = 0; +static uint8_t data_old__lost_connection_to_slave_counter_temp = 0; +static uint8_t data_old__lost_connection_to_slave_counter_retry = 0; +static uint32_t data_old__lost_connection_to_slave_counter_total = 0; /* Private types -------------------------------------------------------------*/ -typedef enum -{ - CPU2_TRANSFER_STOP = 0x00, /*!< */ - CPU2_TRANSFER_TEST_REQUEST = 0x01, /*!< */ - CPU2_TRANSFER_TEST_RECEIVE = 0x02, /*!< */ - CPU2_TRANSFER_SEND_OK = 0x03, /*!< */ - CPU2_TRANSFER_SEND_FALSE = 0x04, /*!< */ - CPU2_TRANSFER_DATA = 0x05, /*!< */ -}CPU2_TRANSFER_StatusTypeDef; - -const uint8_t header_test_request[4] = {0xBB, 0x00, 0x00, 0xBB}; -const uint8_t header_test_receive[4] = {0xBB, 0x01, 0x01, 0xBB}; -const uint8_t header_false[4] = {0xBB, 0xFF, 0xFF, 0xBB}; -const uint8_t header_correct[4] = {0xBB, 0xCC, 0xCC, 0xBB}; -const uint8_t header_data[4] = {0xAA, 0x01, 0x01, 0xAA}; - /* Private function prototypes -----------------------------------------------*/ -uint8_t DataEX_check_header_and_footer_ok(void); -uint8_t DataEX_check_header_and_footer_shifted(void); -uint8_t DataEX_check_header_and_footer_devicedata(void); -void DataEX_check_DeviceData(void); +static uint8_t DataEX_check_header_and_footer_ok(void); +static uint8_t DataEX_check_header_and_footer_shifted(void); +static uint8_t DataEX_check_header_and_footer_devicedata(void); +static void DataEX_check_DeviceData(void); /* Exported functions --------------------------------------------------------*/ -void DataEX_set_update_RTE_not_power_on(void) -{ - wasUpdateNotPowerOn = 1; -} - uint8_t DataEX_was_power_on(void) { return wasPowerOn; } -uint8_t count_DataEX_Error_Handler = 0; -uint8_t last_error_DataEX_Error_Handler = 0; +static uint8_t count_DataEX_Error_Handler = 0; +static uint8_t last_error_DataEX_Error_Handler = 0; -void DataEX_Error_Handler(uint8_t answer) +static void DataEX_Error_Handler(uint8_t answer) { count_DataEX_Error_Handler++; last_error_DataEX_Error_Handler = answer; @@ -152,21 +130,7 @@ } -uint32_t DataEX_time_elapsed_ms(uint32_t ticksstart,uint32_t ticksnow) -{ - - if(ticksstart <= ticksnow) - { - return ticksnow - ticksstart; - } - else - { - return 0xFFFFFFFF - ticksstart + ticksnow; - } - -} - -SDataReceiveFromMaster * dataOutGetPointer(void) +SDataReceiveFromMaster *dataOutGetPointer(void) { return &dataOut; } @@ -179,8 +143,6 @@ data_old__lost_connection_to_slave_counter_total = 0; memset((void *)&dataOut, 0, sizeof(SDataReceiveFromMaster)); - // old 160307: for(int i=0;ivpm.adjusted_critical_radius_he[i]; - dataOut.data.VPM_adjusted_critical_radius_n2[i] = pStateReal->vpm.adjusted_critical_radius_n2[i]; - dataOut.data.VPM_adjusted_crushing_pressure_he[i] = pStateReal->vpm.adjusted_crushing_pressure_he[i]; - dataOut.data.VPM_adjusted_crushing_pressure_n2[i] = pStateReal->vpm.adjusted_crushing_pressure_n2[i]; - dataOut.data.VPM_initial_allowable_gradient_he[i] = pStateReal->vpm.initial_allowable_gradient_he[i]; - dataOut.data.VPM_initial_allowable_gradient_n2[i] = pStateReal->vpm.initial_allowable_gradient_n2[i]; - dataOut.data.VPM_max_actual_gradient[i] = pStateReal->vpm.max_actual_gradient[i]; - } -*/ if(DataEX_check_header_and_footer_ok() && !told_reset_logik_alles_ok) { @@ -477,8 +423,6 @@ */ } - - if(decoLock == DECO_CALC_FINSHED_Buehlmann) { @@ -535,16 +479,14 @@ } -void DataEX_helper_copy_deviceData(SDeviceLine *lineWrite, const SDeviceLine *lineRead) +static void DataEX_helper_copy_deviceData(SDeviceLine *lineWrite, const SDeviceLine *lineRead) { lineWrite->date_rtc_dr = lineRead->date_rtc_dr; lineWrite->time_rtc_tr = lineRead->time_rtc_tr; lineWrite->value_int32 = lineRead->value_int32; } - - -void DataEX_helper_SetTime(RTC_TimeTypeDef inStimestructure, uint32_t *outTimetmpreg) +static void DataEX_helper_SetTime(RTC_TimeTypeDef inStimestructure, uint32_t *outTimetmpreg) { inStimestructure.TimeFormat = RTC_HOURFORMAT_24; @@ -555,7 +497,7 @@ } -void DataEX_helper_SetDate(RTC_DateTypeDef inSdatestructure, uint32_t *outDatetmpreg) +static void DataEX_helper_SetDate(RTC_DateTypeDef inSdatestructure, uint32_t *outDatetmpreg) { *outDatetmpreg = (((uint32_t)RTC_ByteToBcd2(inSdatestructure.Year) << 16U) | \ ((uint32_t)RTC_ByteToBcd2(inSdatestructure.Month) << 8U) | \ @@ -565,7 +507,7 @@ -void DataEX_helper_set_Unknown_Date_deviceData(SDeviceLine *lineWrite) +static void DataEX_helper_set_Unknown_Date_deviceData(SDeviceLine *lineWrite) { RTC_DateTypeDef sdatestructure; RTC_TimeTypeDef stimestructure; @@ -584,7 +526,7 @@ } -uint8_t DataEX_helper_Check_And_Correct_Date_deviceData(SDeviceLine *lineWrite) +static uint8_t DataEX_helper_Check_And_Correct_Date_deviceData(SDeviceLine *lineWrite) { RTC_DateTypeDef sdatestructure; RTC_TimeTypeDef stimestructure; @@ -604,7 +546,7 @@ } -uint8_t DataEX_helper_Check_And_Correct_Value_deviceData(SDeviceLine *lineWrite, int32_t from, int32_t to) +static uint8_t DataEX_helper_Check_And_Correct_Value_deviceData(SDeviceLine *lineWrite, int32_t from, int32_t to) { if(lineWrite->value_int32 >= from && lineWrite->value_int32 <= to) return 0; @@ -619,7 +561,7 @@ } -void DataEX_check_DeviceData(void) +static void DataEX_check_DeviceData(void) { SDevice *DeviceData = stateDeviceGetPointerWrite(); @@ -643,7 +585,7 @@ } -void DataEX_merge_DeviceData_and_store(void) +static void DataEX_merge_DeviceData_and_store(void) { uint16_t dataLengthRead; SDevice DeviceDataFlash; @@ -657,16 +599,6 @@ return; } -/* - SDeviceLine batteryChargeCycles; - SDeviceLine batteryChargeCompleteCycles; - SDeviceLine temperatureMinimum; - SDeviceLine temperatureMaximum; - SDeviceLine depthMaximum; - SDeviceLine diveCycles; - SDeviceLine voltageMinimum; -*/ - /* max values */ if(DeviceData->batteryChargeCompleteCycles.value_int32 < DeviceDataFlash.batteryChargeCompleteCycles.value_int32) { @@ -708,7 +640,7 @@ } -void DataEX_copy_to_DeviceData(void) +static void DataEX_copy_to_DeviceData(void) { SDataExchangeSlaveToMasterDeviceData * dataInDevice = (SDataExchangeSlaveToMasterDeviceData *)&dataIn; SDevice * pDeviceState = stateDeviceGetPointerWrite(); @@ -717,7 +649,7 @@ } -void DataEX_copy_to_VpmRepetitiveData(void) +static void DataEX_copy_to_VpmRepetitiveData(void) { SDataExchangeSlaveToMasterDeviceData * dataInDevice = (SDataExchangeSlaveToMasterDeviceData *)&dataIn; SVpmRepetitiveData * pVpmState = stateVpmRepetitiveDataGetPointerWrite(); @@ -920,6 +852,11 @@ pStateReal->lifeData.boolResetStopwatch = 1; } + pStateReal->lifeData.cns = dataIn.data[dataIn.boolToxicData].cns; + pStateReal->lifeData.otu = dataIn.data[dataIn.boolToxicData].otu; + pStateReal->lifeData.no_fly_time_minutes = dataIn.data[dataIn.boolToxicData].no_fly_time_minutes; + pStateReal->lifeData.desaturation_time_minutes = dataIn.data[dataIn.boolToxicData].desaturation_time_minutes; + //End of diveMode? if(pStateReal->mode == MODE_DIVE && dataIn.mode != MODE_DIVE) { @@ -971,7 +908,6 @@ pStateReal->lifeData.counterSecondsShallowDepth = dataIn.data[dataIn.boolTimeData].counterSecondsShallowDepth; pStateReal->lifeData.surface_time_seconds = (int32_t)dataIn.data[dataIn.boolTimeData].surfacetime_seconds; - pStateReal->lifeData.compass_heading = dataIn.data[dataIn.boolCompassData].compass_heading; if(settingsGetPointer()->FlipDisplay) /* consider that diver is targeting into the opposite direction */ { @@ -990,11 +926,6 @@ pStateReal->compass_uTick_new = dataIn.data[dataIn.boolCompassData].compass_uTick; pStateReal->compass_uTick_local_new = HAL_GetTick(); - pStateReal->lifeData.cns = dataIn.data[dataIn.boolToxicData].cns; - pStateReal->lifeData.otu = dataIn.data[dataIn.boolToxicData].otu; - pStateReal->lifeData.no_fly_time_minutes = dataIn.data[dataIn.boolToxicData].no_fly_time_minutes; - pStateReal->lifeData.desaturation_time_minutes = dataIn.data[dataIn.boolToxicData].desaturation_time_minutes; - memcpy(pStateReal->lifeData.tissue_nitrogen_bar, dataIn.data[dataIn.boolTisssueData].tissue_nitrogen_bar,sizeof(pStateReal->lifeData.tissue_nitrogen_bar)); memcpy(pStateReal->lifeData.tissue_helium_bar, dataIn.data[dataIn.boolTisssueData].tissue_helium_bar,sizeof(pStateReal->lifeData.tissue_helium_bar)); @@ -1015,25 +946,6 @@ pStateReal->lifeData.battery_charge = dataIn.data[dataIn.boolBatteryData].battery_charge; pStateReal->lifeData.battery_voltage = dataIn.data[dataIn.boolBatteryData].battery_voltage; } -/* now in ext_flash_write_settings() // hw 161027 - * if((pStateReal->lifeData.battery_charge > 1) && !DataEX_was_power_on() && ((uint8_t)(pStateReal->lifeData.battery_charge) != 0x10)) // get rid of 16% (0x10) - * pSettings->lastKnownBatteryPercentage = (uint8_t)(pStateReal->lifeData.battery_charge); - */ - - /* OC and CCR but no sensors -> moved to updateSetpointStateUsed(); - float oxygen = 0; - if(pStateReal->diveSettings.diveMode == 0) - { - oxygen = 1.00f; - oxygen -= ((float)pStateReal->lifeData.actualGas.nitrogen_percentage)/100.0f; - oxygen -= ((float)pStateReal->lifeData.actualGas.helium_percentage)/100.0f; - pStateReal->lifeData.ppO2 = pStateReal->lifeData.pressure_ambient_bar * oxygen; - } - else if(pStateReal->diveSettings.diveMode == 1) - { - pStateReal->lifeData.ppO2 = ((float)pStateReal->lifeData.actualGas.setPoint_cbar) /100; - } - */ /* apnea specials */ @@ -1120,44 +1032,6 @@ pStateReal->lifeData.wireless_data[i].data[j] = dataIn.data[dataIn.boolWirelessData].wireless_data[i].data[j]; } - /* old stuff - // crc - is done in RTE 160325 - // size at the moment 4 bytes + one empty + crc -> minimum 5 bytes (+ crc) - // kopieren: Id, Wert, Alter - for(int i=0;i<4;i++) - { - uint8_t numberOfBytes = pStateReal->lifeData.wireless_data[i].numberOfBytes - 1; - - if((numberOfBytes < 5) || (numberOfBytes > 7)) - { - wirelessData[i][0] = 0; - wirelessData[i][1] = 0; - wirelessData[i][2] = 0; - } - else - { - if((crc32c_checksum(pStateReal->lifeData.wireless_data[i].data, numberOfBytes, 0, 0) & 0xFF)!= pStateReal->lifeData.wireless_data[i].data[numberOfBytes]) - { -// no crc is send at the moment -wirelessData[i][0] = (pStateReal->lifeData.wireless_data[i].data[0] * 256) + pStateReal->lifeData.wireless_data[i].data[1]; -wirelessData[i][1] = (pStateReal->lifeData.wireless_data[i].data[3] * 256) + pStateReal->lifeData.wireless_data[i].data[4]; -wirelessData[i][2] = pStateReal->lifeData.wireless_data[i].ageInMilliSeconds; - -// wirelessData[i][0] = 0; -// wirelessData[i][1] = 0; -// wirelessData[i][2] = 0; - - } - - else - { - wirelessData[i][0] = (pStateReal->lifeData.wireless_data[i].data[0] * 256) + pStateReal->lifeData.wireless_data[i].data[1]; - wirelessData[i][1] = (pStateReal->lifeData.wireless_data[i].data[3] * 256) + pStateReal->lifeData.wireless_data[i].data[4]; - wirelessData[i][2] = pStateReal->lifeData.wireless_data[i].ageInMilliSeconds; - } - } - } -*/ // neu 160412 for(int i=0;i<4;i++) { @@ -1197,67 +1071,7 @@ } } } -/* - // neu 160325 - for(int i=0;i<4;i++) - { - if(pStateReal->lifeData.wireless_data[i].numberOfBytes == 10) - { - wirelessData[i][0] = (pStateReal->lifeData.wireless_data[i].data[0] * 256) + pStateReal->lifeData.wireless_data[i].data[1]; - wirelessData[i][1] = (pStateReal->lifeData.wireless_data[i].data[3] * 256) + pStateReal->lifeData.wireless_data[i].data[4]; - wirelessData[i][2] = pStateReal->lifeData.wireless_data[i].ageInMilliSeconds; - } - else - { - wirelessData[i][0] = 0; - wirelessData[i][1] = 0; - wirelessData[i][2] = 0; - } - } - // aussortieren doppelte ids, j�ngster datensatz ist relevant - for(int i=0;i<3;i++) - { - if(wirelessData[i][0]) - { - for(int j=i+1; j<4; j++) - { - if(wirelessData[i][0] == wirelessData[j][0]) - { - if(wirelessData[i][2] > wirelessData[j][2]) - { - wirelessData[i][0] = wirelessData[j][0]; - wirelessData[i][1] = wirelessData[j][1]; - wirelessData[i][2] = wirelessData[j][2]; - } - wirelessData[j][0] = 0; - wirelessData[j][1] = 0; - wirelessData[j][2] = 0; - } - } - } - } -*/ -/* old - // copy to lifeData - for(int i=0;i<4;i++) - { - if((wirelessData[i][0]) && (wirelessData[i][2]) && (wirelessData[i][2] < 60000)) - { - for(int j=1;j<=(2*NUM_GASES+1);j++) - { - if(pStateReal->diveSettings.gas[j].bottle_wireless_id == wirelessData[i][0]) - { - pStateReal->lifeData.bottle_bar[j] = wirelessData[i][1]; - pStateReal->lifeData.bottle_bar_age_MilliSeconds[j] = wirelessData[i][2]; - break; - } - } - } - } -*/ - - /* PIC data */ for(int i=0;i<4;i++) @@ -1297,10 +1111,10 @@ /* Private functions ---------------------------------------------------------*/ -/* Check if there is an empty frame providec by RTE (all 0) or even no data provided by RTE (all 0xFF) +/* Check if there is an empty frame provided by RTE (all 0) or even no data provided by RTE (all 0xFF) * If that is not the case the DMA is somehow not in sync */ -uint8_t DataEX_check_header_and_footer_shifted() +static uint8_t DataEX_check_header_and_footer_shifted() { uint8_t ret = 1; if((dataIn.footer.checkCode[0] == 0x00) @@ -1316,7 +1130,7 @@ return ret; } -uint8_t DataEX_check_header_and_footer_ok(void) +static uint8_t DataEX_check_header_and_footer_ok(void) { if(dataIn.header.checkCode[0] != 0xA1) return 0; @@ -1340,7 +1154,7 @@ return 1; } -uint8_t DataEX_check_header_and_footer_devicedata(void) +static uint8_t DataEX_check_header_and_footer_devicedata(void) { if(dataIn.header.checkCode[0] != 0xDF) return 0; @@ -1361,6 +1175,3 @@ return 1; } - - - diff -r d328abe2e44e -r adc1e7d628be Discovery/Src/logbook.c --- a/Discovery/Src/logbook.c Sun Mar 17 19:16:59 2019 +0100 +++ b/Discovery/Src/logbook.c Sat Mar 23 21:32:16 2019 +0100 @@ -78,27 +78,25 @@ /* Exported variables --------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ -uint8_t data_store[10000]; -SLogbookHeader header; -SLogbookHeaderOSTC3 headerOSTC3; -SLogbookHeaderOSTC3compact headerOSTC3compact; -SSmallHeader smallHeader; -SDivisor divisor; -SDivisor divisorBackup; +static SLogbookHeader header; +static SLogbookHeaderOSTC3 headerOSTC3; +static SLogbookHeaderOSTC3compact headerOSTC3compact; +static SSmallHeader smallHeader; +static SDivisor divisor; +static SDivisor divisorBackup; /* Private function prototypes -----------------------------------------------*/ -void clear_divisor(void); -void logbook_SetAverageDepth(float average_depth_meter); -void logbook_SetMinTemperature(float min_temperature_celsius); -void logbook_SetMaxCNS(float max_cns_percentage); -void logbook_SetCompartmentDesaturation(void); -void logbook_SetLastStop(float last_stop_depth_bar); -void logbook_writedata(void * data, int length_byte); -void logbook_UpdateHeader(void); +static void clear_divisor(void); +static void logbook_SetAverageDepth(float average_depth_meter); +static void logbook_SetMinTemperature(float min_temperature_celsius); +static void logbook_SetMaxCNS(float max_cns_percentage); +static void logbook_SetCompartmentDesaturation(void); +static void logbook_SetLastStop(float last_stop_depth_bar); +static void logbook_writedata(void * data, int length_byte); +static void logbook_UpdateHeader(void); /* Exported functions --------------------------------------------------------*/ -/** used by test_vpm.c at the moment */ void logbook_EndDive(void) { ext_flash_close_new_dive_log((uint8_t*) &header); @@ -143,31 +141,6 @@ /** ****************************************************************************** - * @brief logbook_getHeaderOSTC3. / - * @author heinrichs weikamp gmbh - * @version V0.0.1 - * @date 26-Nov-2014 - ****************************************************************************** - * - * @param StepBackwards : 0 Last lokbook entry, 1 second to last entry, etc. - * @param SSLogbookHeader* pLogbookHeader: Output found LogbookHeader - * @return uint8_t : 1 = success -*/ -/* -SLogbookHeaderOSTC3 * logbook_getHeaderOSTC3(uint8_t StepBackwards) -{ - if(!logbook_getHeader(StepBackwards, &header)) - return 0; - else - { - logbook_build_ostc3header(); - return &headerOSTC3; - } -} -*/ - -/** - ****************************************************************************** * @brief logbook_getNumberOfHeaders. / * @author heinrichs weikamp gmbh * @version V0.0.1 @@ -265,7 +238,7 @@ header.dateDay = Sdate.Date; header.timeHour = Stime.Hours; header.timeMinute = Stime.Minutes; - header.cnsAtBeginning = (uint16_t)((pInfo->lifeData.cns * 100) + 0.5f); + header.cnsAtBeginning = (uint16_t)pInfo->lifeData.cns; header.surfacePressure_mbar = (uint16_t)(pInfo->lifeData.pressure_surface_bar * 1000); header.firmwareVersionHigh = firmwareVersion_16bit_high(); header.firmwareVersionLow = firmwareVersion_16bit_low(); @@ -350,7 +323,7 @@ ****************************************************************************** * */ -void clear_divisor(void) +static void clear_divisor(void) { divisor.cns = smallHeader.cnsDivisor - 1; divisor.decoplan = smallHeader.decoplanDivisor - 1; @@ -373,12 +346,12 @@ * @param uint8_t *pos: Output 8 bit array * @param uint16_t var: 16 bit variable */ -void addU16(uint8_t *pos, uint16_t var) +static void addU16(uint8_t *pos, uint16_t var) { *((uint16_t*)pos) = var; } -void addS16(uint8_t *pos, int16_t var) +static void addS16(uint8_t *pos, int16_t var) { *((int16_t*)pos) = var; } @@ -636,8 +609,7 @@ if(divisor.cns == 0) { divisor.cns = smallHeader.cnsDivisor - 1; - //addU16(&sample[length], (uint16_t)(state.lifeData.cns * 100.0f + 0.5f)); - addU16(&sample[length], (uint16_t)(state.lifeData.cns)); // hw 151110 cns is 0 to 100 % and more (not 0 to 1.00 and more) + addU16(&sample[length], (uint16_t)state.lifeData.cns); length += 2; } else @@ -655,14 +627,6 @@ } - - -uint16_t actual_depth1; -uint16_t actual_depth2; -uint16_t actual_length1; -uint16_t actual_length2; -uint16_t actual_inum; - /** ****************************************************************************** * @brief readSample. / Reads data of one logbook sample @@ -678,7 +642,7 @@ * @param int32_t* cns: output Value * @return bytes read / 0 = reading Error */ -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) +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) { int length = 0; _Bool bEvent = 0; @@ -1254,7 +1218,7 @@ * @version V0.0.1 * @date 27-Nov-2014 *********************************************************************************/ -void logbook_UpdateHeader(void) +static void logbook_UpdateHeader(void) { const SDiveState * pStateReal = stateRealGetPointer(); @@ -1354,19 +1318,19 @@ } -void logbook_SetAverageDepth(float average_depth_meter) +static void logbook_SetAverageDepth(float average_depth_meter) { header.averageDepth_mbar = (uint16_t)(average_depth_meter * 100); } -void logbook_SetMinTemperature(float min_temperature_celsius) +static void logbook_SetMinTemperature(float min_temperature_celsius) { header.minTemp = (int16_t)((min_temperature_celsius * 10.0f) + 0.5f); } -void logbook_SetMaxCNS(float max_cns_percentage) +static void logbook_SetMaxCNS(float max_cns_percentage) { if(max_cns_percentage < 9999) header.maxCNS = (uint16_t)(max_cns_percentage); @@ -1375,13 +1339,7 @@ } -void logbook_SetDesaturationTime(void) -{ - header.desaturationTime = 48 * 60; -} - - -void logbook_SetCompartmentDesaturation(void) +static void logbook_SetCompartmentDesaturation(void) { const SDiveState * pStateReal = stateRealGetPointer(); @@ -1399,12 +1357,12 @@ } } -void logbook_SetLastStop(float last_stop_depth_bar) +static void logbook_SetLastStop(float last_stop_depth_bar) { header.lastDecostop_m = (uint8_t)(last_stop_depth_bar / 10.0f); } -void logbook_writedata(void * data, int length_byte) +static void logbook_writedata(void * data, int length_byte) { ext_flash_write_sample(data, length_byte); } diff -r d328abe2e44e -r adc1e7d628be Discovery/Src/t7.c --- a/Discovery/Src/t7.c Sun Mar 17 19:16:59 2019 +0100 +++ b/Discovery/Src/t7.c Sat Mar 23 21:32:16 2019 +0100 @@ -58,7 +58,7 @@ void t7_miniLiveLogProfile(void); //void t7_clock(void); void t7_logo_OSTC(void); -void t7_colorscheme_mod(char *text); +static void t7_colorscheme_mod(char *text); uint8_t t7_test_customview_warnings(void); void t7_show_customview_warnings(void); @@ -68,7 +68,7 @@ uint8_t t7_customtextPrepare(char * text); -/* Importend function prototypes ---------------------------------------------*/ +/* Imported function prototypes ---------------------------------------------*/ extern uint8_t write_gas(char *text, uint8_t oxygen, uint8_t helium); /* Exported variables --------------------------------------------------------*/ @@ -1016,11 +1016,22 @@ } /* dive mode */ - if(stateUsed->diveSettings.diveMode == DIVEMODE_CCR) - GFX_write_string(&FontT24,&t7c1,"\f\002" "CCR",0); - else - GFX_write_string(&FontT24,&t7c1,"\f\002" "OC",0); -// GFX_write_string(&FontT24,&t7c1,"\f\177\177\x80" "CCR",0); + switch (stateUsed->diveSettings.diveMode) { + case DIVEMODE_CCR: + GFX_write_string(&FontT24, &t7c1, "\f\002" "CCR", 0); + break; + case DIVEMODE_OC: + GFX_write_string(&FontT24, &t7c1, "\f\002" "OC", 0); + break; + case DIVEMODE_Gauge: + GFX_write_string(&FontT24, &t7c1, "\f\002" "Gauge", 0); + break; + case DIVEMODE_Apnea: + GFX_write_string(&FontT24, &t7c1, "\f\002" "Apnea", 0); + break; + default: + GFX_write_string(&FontT24, &t7c1, "\f\002" "OC", 0); + } /*battery */ @@ -1196,7 +1207,7 @@ uint32_t color; // uint8_t gasIdFirst; SSettings* pSettings = settingsGetPointer(); - extern SDataExchangeSlaveToMaster dataIn; + SDataExchangeSlaveToMaster *dataIn = get_dataInPointer(); SWindowGimpStyle windowGimp; @@ -1210,7 +1221,7 @@ if(stateUsed->data_old__lost_connection_to_slave) { Gfx_write_label_var(&t7screen, 500,800, 0,&FontT42,CLUT_DiveMainLabel,"old"); - snprintf(TextL1,TEXTSIZE,"%X %X %X %X",dataIn.header.checkCode[0],dataIn.header.checkCode[1],dataIn.header.checkCode[2],dataIn.header.checkCode[3]); + snprintf(TextL1,TEXTSIZE,"%X %X %X %X",dataIn->header.checkCode[0],dataIn->header.checkCode[1],dataIn->header.checkCode[2],dataIn->header.checkCode[3]); Gfx_write_label_var(&t7screen, 500,800, 45,&FontT48,CLUT_Font020,TextL1); } else @@ -1250,7 +1261,7 @@ Gfx_write_label_var(&t7screen, 0,400,355,&FontT48,CLUT_Font020,TextL1); // gasIdFirst = stateUsed->lifeData.actualGas.GasIdInSettings; - snprintf(TextL1,TEXTSIZE,"%u.%u",dataIn.RTE_VERSION_high,dataIn.RTE_VERSION_low); + snprintf(TextL1,TEXTSIZE,"%u.%u",dataIn->RTE_VERSION_high,dataIn->RTE_VERSION_low); Gfx_write_label_var(&t7screen, 320,500,100,&FontT42,CLUT_DiveMainLabel,"RTE"); Gfx_write_label_var(&t7screen, 320,500,145,&FontT48,CLUT_Font020,TextL1); @@ -2628,14 +2639,13 @@ return lineCount; } -/* could be extended to search for \020 inside - */ -void t7_colorscheme_mod(char *text) -{ - if((text[0] == '\020') && !GFX_is_colorschemeDiveStandard()) - { - text[0] = '\027'; - } +static void t7_colorscheme_mod(char *text) { + char *p = text; + while (*p) { + if ((*p == '\020') && !GFX_is_colorschemeDiveStandard()) + *p = '\027'; + p++; + } } @@ -3095,6 +3105,7 @@ text[textpointer++] = '\t'; textpointer += snprintf(&text[textpointer],10,"\020%i'", pDecoinfoFuture->output_time_to_surface_seconds / 60); text[textpointer++] = 0; + t7_colorscheme_mod(text); GFX_write_string(&FontT42, &t7cY0free, text, 1); } diff -r d328abe2e44e -r adc1e7d628be Discovery/Src/tHome.c --- a/Discovery/Src/tHome.c Sun Mar 17 19:16:59 2019 +0100 +++ b/Discovery/Src/tHome.c Sat Mar 23 21:32:16 2019 +0100 @@ -36,7 +36,6 @@ #include "t5_gauge.h" #include "t6_apnea.h" #include "t7.h" -#include "t9.h" #include "tDebug.h" #include "timer.h" // for timer_Stopwatch_Restart #include "tMenu.h" diff -r d328abe2e44e -r adc1e7d628be Small_CPU/Src/compass.c --- a/Small_CPU/Src/compass.c Sun Mar 17 19:16:59 2019 +0100 +++ b/Small_CPU/Src/compass.c Sat Mar 23 21:32:16 2019 +0100 @@ -34,6 +34,7 @@ #include "compass_LSM303D.h" #include "compass_LSM303DLHC.h" +#include "spi.h" #include "i2c.h" #include "RTE_FlashAccess.h" // to store compass_calib_data