comparison Discovery/Src/data_exchange_main.c @ 1014:8c0134a287da GasConsumption

Add a log data event to the scrubber timer at the start of the dive and every time the timer (in minutes) is decremented. The event contains a 12 bit signed integer for the remaining scrubber duration, and two flags for scrubber warning (0x2000, <= 30 minutes remaining) and scrubber error (0x4000, <= 0 minutes remaining). (mikeller)
author heinrichsweikamp
date Sun, 11 May 2025 16:18:20 +0200
parents d9290c76b840
children
comparison
equal deleted inserted replaced
1013:fa1af49319e5 1014:8c0134a287da
847 static uint16_t getDeviceDataAfterStartOfMainCPU = 20; 847 static uint16_t getDeviceDataAfterStartOfMainCPU = 20;
848 848
849 SDiveState *pStateReal = stateRealGetPointerWrite(); 849 SDiveState *pStateReal = stateRealGetPointerWrite();
850 uint8_t idx; 850 uint8_t idx;
851 float meter = 0; 851 float meter = 0;
852 SSettings *pSettings; 852
853
854 #ifdef ENABLE_EXTERNAL_PRESSURE 853 #ifdef ENABLE_EXTERNAL_PRESSURE
855 float CO2Corr = 0.0; 854 float CO2Corr = 0.0;
856 #endif 855 #endif
857 856
858 // wireless - �ltere daten aufr�umen 857 // wireless - �ltere daten aufr�umen
912 dataOut.getDeviceDataNow = 1; 911 dataOut.getDeviceDataNow = 1;
913 getDeviceDataAfterStartOfMainCPU = 10*60*10; /* * 100ms = 60 second => update device data every 10 minutes */ 912 getDeviceDataAfterStartOfMainCPU = 10*60*10; /* * 100ms = 60 second => update device data every 10 minutes */
914 } 913 }
915 } 914 }
916 915
916 SSettings *pSettings = settingsGetPointer();
917 if((requestNecessary.uw != 0) && (dataIn.confirmRequest.uw != 0)) 917 if((requestNecessary.uw != 0) && (dataIn.confirmRequest.uw != 0))
918 { 918 {
919 if(((dataIn.confirmRequest.uw) & CRBUTTON) != 0) 919 if(((dataIn.confirmRequest.uw) & CRBUTTON) != 0)
920 { 920 {
921 requestNecessary.ub.button = 0; 921 requestNecessary.ub.button = 0;
949 requestNecessary.ub.accident = 0; 949 requestNecessary.ub.accident = 0;
950 } 950 }
951 951
952 if(requestNecessary.ub.button == 1) /* send button values to RTE */ 952 if(requestNecessary.ub.button == 1) /* send button values to RTE */
953 { 953 {
954 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); 954 setButtonResponsiveness(pSettings->ButtonResponsiveness);
955 } 955 }
956 } 956 }
957 957
958 /* uint8_t IAmStolenPleaseKillMe; 958 /* uint8_t IAmStolenPleaseKillMe;
959 */ 959 */
960 pSettings = settingsGetPointer();
961
962 if(pSettings->IAmStolenPleaseKillMe > 3) 960 if(pSettings->IAmStolenPleaseKillMe > 3)
963 { 961 {
964 pSettings->salinity = 0; 962 pSettings->salinity = 0;
965 dataIn.data[dataIn.boolPressureData].surface_mbar = 999; 963 dataIn.data[dataIn.boolPressureData].surface_mbar = 999;
966 dataIn.data[dataIn.boolPressureData].pressure_mbar = 98971; 964 dataIn.data[dataIn.boolPressureData].pressure_mbar = 98971;
1044 simulation_exit(); 1042 simulation_exit();
1045 } 1043 }
1046 disableTimer(); 1044 disableTimer();
1047 1045
1048 // new 170508 1046 // new 170508
1049 settingsGetPointer()->bluetoothActive = 0; 1047 pSettings->bluetoothActive = 0;
1050 MX_Bluetooth_PowerOff(); 1048 MX_Bluetooth_PowerOff();
1051 //Init dive Mode 1049 //Init dive Mode
1052 decoLock = DECO_CALC_init_as_is_start_of_dive; 1050 decoLock = DECO_CALC_init_as_is_start_of_dive;
1053 pStateReal->lifeData.boolResetAverageDepth = 1; 1051 pStateReal->lifeData.boolResetAverageDepth = 1;
1054 1052
1374 } 1372 }
1375 1373
1376 return; 1374 return;
1377 } 1375 }
1378 1376
1377 bool isScrubberTimerEnabled(const SSettings *settings)
1378 {
1379 return settings->scrubberActiveId != 0x00 && isLoopMode(settings->dive_mode);
1380 }
1381
1382 bool isScrubberTimerRunning(const SDiveState *diveState, const SSettings *settings)
1383 {
1384 return isScrubberTimerEnabled(settings) && diveState->mode == MODE_DIVE && isLoopMode(diveState->diveSettings.diveMode);
1385 }