comparison Discovery/Src/base.c @ 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 b1091e183d52
children adc4ccbebbb5
comparison
equal deleted inserted replaced
445:ee1434824c3f 446:f1257a32f2d4
197 */ 197 */
198 198
199 /* Includes ------------------------------------------------------------------*/ 199 /* Includes ------------------------------------------------------------------*/
200 #include "stdio.h" 200 #include "stdio.h"
201 #include <string.h> // for memcopy 201 #include <string.h> // for memcopy
202 #include "configuration.h"
202 203
203 #include "stm32f4xx_hal.h" 204 #include "stm32f4xx_hal.h"
204 #include "ostc.h" 205 #include "ostc.h"
205 #include "base.h" 206 #include "base.h"
206 #include "display.h" 207 #include "display.h"
325 ITM_Port8(0) = ch; 326 ITM_Port8(0) = ch;
326 } 327 }
327 return(ch); 328 return(ch);
328 } 329 }
329 */ 330 */
330 /* #define DEBUG_RUNTIME TRUE */
331 #ifdef DEBUG_RUNTIME
332 #define MEASURECNT 60 /* number of measuremets to be stored */
333 static uint32_t loopcnt[MEASURECNT];
334 #endif
335
336 static uint8_t ButtonAction = ACTION_END; 331 static uint8_t ButtonAction = ACTION_END;
337 332
338 static void StoreButtonAction(uint8_t action) 333 static void StoreButtonAction(uint8_t action)
339 { 334 {
340 ButtonAction = action; 335 ButtonAction = action;
348 // =============================================================================== 343 // ===============================================================================
349 int main(void) 344 int main(void)
350 { 345 {
351 uint32_t pLayerInvisible; 346 uint32_t pLayerInvisible;
352 uint16_t totalDiveCounterFound; 347 uint16_t totalDiveCounterFound;
353 #ifdef DEBUG_RUNTIME
354 RTC_TimeTypeDef Stime;
355 uint8_t measurementindex = 0;
356 uint8_t lastsecond = 0xFF;
357 #endif
358 348
359 SStateList status; 349 SStateList status;
360 detectionState_t pitchstate; 350 detectionState_t pitchstate;
361 set_globalState( StBoot0 ); 351 set_globalState( StBoot0 );
362 LastButtonPressed = 0; 352 LastButtonPressed = 0;
525 StoreButtonAction((uint8_t)ACTION_PITCH_POS); 515 StoreButtonAction((uint8_t)ACTION_PITCH_POS);
526 } 516 }
527 } 517 }
528 518
529 519
530 // Enable this to make the simulator write a logbook entry
531 // #define SIM_WRITES_LOGBOOK 1
532
533 #ifdef SIM_WRITES_LOGBOOK 520 #ifdef SIM_WRITES_LOGBOOK
534 if(stateUsed == stateSimGetPointer()) 521 if(stateUsed == stateSimGetPointer())
535 logbook_InitAndWrite(stateUsed); 522 logbook_InitAndWrite(stateUsed);
536 #endif 523 #endif
537 if(stateUsed == stateRealGetPointer()) /* Handle log entries while in dive mode*/ 524 if(stateUsed == stateRealGetPointer()) /* Handle log entries while in dive mode*/
538 logbook_InitAndWrite(stateUsed); 525 logbook_InitAndWrite(stateUsed);
539 } 526 }
540
541 #ifdef DEBUG_RUNTIME
542 translateTime(stateUsed->lifeData.timeBinaryFormat, &Stime);
543 if(lastsecond == 0xFF)
544 {
545 measurementindex = 0;
546 loopcnt[measurementindex] = 0;
547 lastsecond = Stime.Seconds;
548 }
549 loopcnt[measurementindex]++;
550
551 if(lastsecond != Stime.Seconds)
552 {
553 measurementindex++;
554 if (measurementindex == MEASURECNT) measurementindex = 0;
555 loopcnt[measurementindex] = 0;
556 lastsecond = Stime.Seconds;
557 if(measurementindex +1 < MEASURECNT) loopcnt[measurementindex +1] = 0xffff; /* helps to identify the latest value */
558 }
559 #endif
560
561 } 527 }
562 } 528 }
563 529
564 530
565 531