Mercurial > public > ostc4
comparison Discovery/Src/logbook.c @ 194:f23b9055436f div-fixes-cleanup-1
cleanup: more trivial cleanup (logbook.c/h)
Kick out unused code, commented code. Corrected some comments, and
most relevant: make things static where we can.
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
author | Jan Mulder <jlmulder@xs4all.nl> |
---|---|
date | Tue, 19 Mar 2019 11:42:00 +0100 |
parents | e1d66bc78f9a |
children | ac58a9fb92ac |
comparison
equal
deleted
inserted
replaced
193:255326edf00b | 194:f23b9055436f |
---|---|
76 } SDivisor; | 76 } SDivisor; |
77 | 77 |
78 /* Exported variables --------------------------------------------------------*/ | 78 /* Exported variables --------------------------------------------------------*/ |
79 | 79 |
80 /* Private variables ---------------------------------------------------------*/ | 80 /* Private variables ---------------------------------------------------------*/ |
81 uint8_t data_store[10000]; | 81 static SLogbookHeader header; |
82 SLogbookHeader header; | 82 static SLogbookHeaderOSTC3 headerOSTC3; |
83 SLogbookHeaderOSTC3 headerOSTC3; | 83 static SLogbookHeaderOSTC3compact headerOSTC3compact; |
84 SLogbookHeaderOSTC3compact headerOSTC3compact; | 84 static SSmallHeader smallHeader; |
85 SSmallHeader smallHeader; | 85 static SDivisor divisor; |
86 SDivisor divisor; | 86 static SDivisor divisorBackup; |
87 SDivisor divisorBackup; | |
88 | 87 |
89 /* Private function prototypes -----------------------------------------------*/ | 88 /* Private function prototypes -----------------------------------------------*/ |
90 void clear_divisor(void); | 89 static void clear_divisor(void); |
91 void logbook_SetAverageDepth(float average_depth_meter); | 90 static void logbook_SetAverageDepth(float average_depth_meter); |
92 void logbook_SetMinTemperature(float min_temperature_celsius); | 91 static void logbook_SetMinTemperature(float min_temperature_celsius); |
93 void logbook_SetMaxCNS(float max_cns_percentage); | 92 static void logbook_SetMaxCNS(float max_cns_percentage); |
94 void logbook_SetCompartmentDesaturation(void); | 93 static void logbook_SetCompartmentDesaturation(void); |
95 void logbook_SetLastStop(float last_stop_depth_bar); | 94 static void logbook_SetLastStop(float last_stop_depth_bar); |
96 void logbook_writedata(void * data, int length_byte); | 95 static void logbook_writedata(void * data, int length_byte); |
97 void logbook_UpdateHeader(void); | 96 static void logbook_UpdateHeader(void); |
98 | 97 |
99 /* Exported functions --------------------------------------------------------*/ | 98 /* Exported functions --------------------------------------------------------*/ |
100 | 99 |
101 /** used by test_vpm.c at the moment */ | |
102 void logbook_EndDive(void) | 100 void logbook_EndDive(void) |
103 { | 101 { |
104 ext_flash_close_new_dive_log((uint8_t*) &header); | 102 ext_flash_close_new_dive_log((uint8_t*) &header); |
105 } | 103 } |
106 | 104 |
138 */ | 136 */ |
139 SLogbookHeader* logbook_getCurrentHeader(void) | 137 SLogbookHeader* logbook_getCurrentHeader(void) |
140 { | 138 { |
141 return &header; | 139 return &header; |
142 } | 140 } |
143 | |
144 /** | |
145 ****************************************************************************** | |
146 * @brief logbook_getHeaderOSTC3. / | |
147 * @author heinrichs weikamp gmbh | |
148 * @version V0.0.1 | |
149 * @date 26-Nov-2014 | |
150 ****************************************************************************** | |
151 * | |
152 * @param StepBackwards : 0 Last lokbook entry, 1 second to last entry, etc. | |
153 * @param SSLogbookHeader* pLogbookHeader: Output found LogbookHeader | |
154 * @return uint8_t : 1 = success | |
155 */ | |
156 /* | |
157 SLogbookHeaderOSTC3 * logbook_getHeaderOSTC3(uint8_t StepBackwards) | |
158 { | |
159 if(!logbook_getHeader(StepBackwards, &header)) | |
160 return 0; | |
161 else | |
162 { | |
163 logbook_build_ostc3header(); | |
164 return &headerOSTC3; | |
165 } | |
166 } | |
167 */ | |
168 | 141 |
169 /** | 142 /** |
170 ****************************************************************************** | 143 ****************************************************************************** |
171 * @brief logbook_getNumberOfHeaders. / | 144 * @brief logbook_getNumberOfHeaders. / |
172 * @author heinrichs weikamp gmbh | 145 * @author heinrichs weikamp gmbh |
348 * @version V0.0.1 | 321 * @version V0.0.1 |
349 * @date 22-April-2014 | 322 * @date 22-April-2014 |
350 ****************************************************************************** | 323 ****************************************************************************** |
351 * | 324 * |
352 */ | 325 */ |
353 void clear_divisor(void) | 326 static void clear_divisor(void) |
354 { | 327 { |
355 divisor.cns = smallHeader.cnsDivisor - 1; | 328 divisor.cns = smallHeader.cnsDivisor - 1; |
356 divisor.decoplan = smallHeader.decoplanDivisor - 1; | 329 divisor.decoplan = smallHeader.decoplanDivisor - 1; |
357 divisor.deco_ndl = smallHeader.deco_ndlDivisor - 1; | 330 divisor.deco_ndl = smallHeader.deco_ndlDivisor - 1; |
358 divisor.gradientFactor = smallHeader.gfDivisor -1 ; | 331 divisor.gradientFactor = smallHeader.gfDivisor -1 ; |
371 ****************************************************************************** | 344 ****************************************************************************** |
372 * | 345 * |
373 * @param uint8_t *pos: Output 8 bit array | 346 * @param uint8_t *pos: Output 8 bit array |
374 * @param uint16_t var: 16 bit variable | 347 * @param uint16_t var: 16 bit variable |
375 */ | 348 */ |
376 void addU16(uint8_t *pos, uint16_t var) | 349 static void addU16(uint8_t *pos, uint16_t var) |
377 { | 350 { |
378 *((uint16_t*)pos) = var; | 351 *((uint16_t*)pos) = var; |
379 } | 352 } |
380 | 353 |
381 void addS16(uint8_t *pos, int16_t var) | 354 static void addS16(uint8_t *pos, int16_t var) |
382 { | 355 { |
383 *((int16_t*)pos) = var; | 356 *((int16_t*)pos) = var; |
384 } | 357 } |
385 | 358 |
386 /** | 359 /** |
653 sample[2] = profileByteFlag.uw; | 626 sample[2] = profileByteFlag.uw; |
654 logbook_writedata((void *) sample,length); | 627 logbook_writedata((void *) sample,length); |
655 | 628 |
656 } | 629 } |
657 | 630 |
658 | |
659 | |
660 uint16_t actual_depth1; | |
661 uint16_t actual_depth2; | |
662 uint16_t actual_length1; | |
663 uint16_t actual_length2; | |
664 uint16_t actual_inum; | |
665 | |
666 /** | 631 /** |
667 ****************************************************************************** | 632 ****************************************************************************** |
668 * @brief readSample. / Reads data of one logbook sample | 633 * @brief readSample. / Reads data of one logbook sample |
669 * @author Peter Ryser | 634 * @author Peter Ryser |
670 * @version V0.0.1 | 635 * @version V0.0.1 |
676 * @param int32_t* temperature: output Value | 641 * @param int32_t* temperature: output Value |
677 * @param int32_t* sensor1, sensor2, sensor3: output Value | 642 * @param int32_t* sensor1, sensor2, sensor3: output Value |
678 * @param int32_t* cns: output Value | 643 * @param int32_t* cns: output Value |
679 * @return bytes read / 0 = reading Error | 644 * @return bytes read / 0 = reading Error |
680 */ | 645 */ |
681 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) | 646 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) |
682 { | 647 { |
683 int length = 0; | 648 int length = 0; |
684 _Bool bEvent = 0; | 649 _Bool bEvent = 0; |
685 bit8_Type eventByte1, eventByte2; | 650 bit8_Type eventByte1, eventByte2; |
686 bit8_Type profileByteFlag; | 651 bit8_Type profileByteFlag; |
1252 ext_flash_close_new_dive_log() in externLogbookFlash.c | 1217 ext_flash_close_new_dive_log() in externLogbookFlash.c |
1253 * @author heinrichs weikamp gmbh | 1218 * @author heinrichs weikamp gmbh |
1254 * @version V0.0.1 | 1219 * @version V0.0.1 |
1255 * @date 27-Nov-2014 | 1220 * @date 27-Nov-2014 |
1256 *********************************************************************************/ | 1221 *********************************************************************************/ |
1257 void logbook_UpdateHeader(void) | 1222 static void logbook_UpdateHeader(void) |
1258 { | 1223 { |
1259 const SDiveState * pStateReal = stateRealGetPointer(); | 1224 const SDiveState * pStateReal = stateRealGetPointer(); |
1260 | 1225 |
1261 // uint16_t secondsAtShallow = 0; | 1226 // uint16_t secondsAtShallow = 0; |
1262 RTC_DateTypeDef Sdate; | 1227 RTC_DateTypeDef Sdate; |
1352 memcpy(header.heCompartments, pStateReal->lifeData.tissue_helium_bar, 64); | 1317 memcpy(header.heCompartments, pStateReal->lifeData.tissue_helium_bar, 64); |
1353 | 1318 |
1354 } | 1319 } |
1355 | 1320 |
1356 | 1321 |
1357 void logbook_SetAverageDepth(float average_depth_meter) | 1322 static void logbook_SetAverageDepth(float average_depth_meter) |
1358 { | 1323 { |
1359 header.averageDepth_mbar = (uint16_t)(average_depth_meter * 100); | 1324 header.averageDepth_mbar = (uint16_t)(average_depth_meter * 100); |
1360 } | 1325 } |
1361 | 1326 |
1362 | 1327 |
1363 void logbook_SetMinTemperature(float min_temperature_celsius) | 1328 static void logbook_SetMinTemperature(float min_temperature_celsius) |
1364 { | 1329 { |
1365 header.minTemp = (int16_t)((min_temperature_celsius * 10.0f) + 0.5f); | 1330 header.minTemp = (int16_t)((min_temperature_celsius * 10.0f) + 0.5f); |
1366 } | 1331 } |
1367 | 1332 |
1368 | 1333 |
1369 void logbook_SetMaxCNS(float max_cns_percentage) | 1334 static void logbook_SetMaxCNS(float max_cns_percentage) |
1370 { | 1335 { |
1371 if(max_cns_percentage < 9999) | 1336 if(max_cns_percentage < 9999) |
1372 header.maxCNS = (uint16_t)(max_cns_percentage); | 1337 header.maxCNS = (uint16_t)(max_cns_percentage); |
1373 else | 1338 else |
1374 header.maxCNS = 9999; | 1339 header.maxCNS = 9999; |
1375 } | 1340 } |
1376 | 1341 |
1377 | 1342 |
1378 void logbook_SetDesaturationTime(void) | 1343 static void logbook_SetCompartmentDesaturation(void) |
1379 { | |
1380 header.desaturationTime = 48 * 60; | |
1381 } | |
1382 | |
1383 | |
1384 void logbook_SetCompartmentDesaturation(void) | |
1385 { | 1344 { |
1386 const SDiveState * pStateReal = stateRealGetPointer(); | 1345 const SDiveState * pStateReal = stateRealGetPointer(); |
1387 | 1346 |
1388 decom_tissues_desaturation_time(&pStateReal->lifeData, &secondaryInformation); | 1347 decom_tissues_desaturation_time(&pStateReal->lifeData, &secondaryInformation); |
1389 for(int i=0;i<16;i++) | 1348 for(int i=0;i<16;i++) |
1397 else | 1356 else |
1398 header.heCompartDesatTime_min[i] = 255; | 1357 header.heCompartDesatTime_min[i] = 255; |
1399 } | 1358 } |
1400 } | 1359 } |
1401 | 1360 |
1402 void logbook_SetLastStop(float last_stop_depth_bar) | 1361 static void logbook_SetLastStop(float last_stop_depth_bar) |
1403 { | 1362 { |
1404 header.lastDecostop_m = (uint8_t)(last_stop_depth_bar / 10.0f); | 1363 header.lastDecostop_m = (uint8_t)(last_stop_depth_bar / 10.0f); |
1405 } | 1364 } |
1406 | 1365 |
1407 void logbook_writedata(void * data, int length_byte) | 1366 static void logbook_writedata(void * data, int length_byte) |
1408 { | 1367 { |
1409 ext_flash_write_sample(data, length_byte); | 1368 ext_flash_write_sample(data, length_byte); |
1410 } | 1369 } |
1411 | 1370 |
1412 | 1371 |