comparison Discovery/Src/base.c @ 267:cf6ad20380fb

Merged in Ideenmodellierer/ostc4/IPC_Sync_Improvment_2 (pull request #18) IPC Sync Improvment 2
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Fri, 26 Apr 2019 10:36:11 +0000
parents a6c0375bc950
children 2e58a4094770
comparison
equal deleted inserted replaced
262:f4c16ea0354a 267:cf6ad20380fb
264 TIM_HandleTypeDef TimDemoHandle; /* used in stm32f4xx_it.c too */ 264 TIM_HandleTypeDef TimDemoHandle; /* used in stm32f4xx_it.c too */
265 #endif 265 #endif
266 266
267 uint8_t LastButtonPressed; 267 uint8_t LastButtonPressed;
268 uint32_t LastButtonPressedTick; 268 uint32_t LastButtonPressedTick;
269 uint32_t BaseTick100ms; /* Tick at last 100ms cycle */
269 270
270 /* 271 /*
271 uint32_t time_before; 272 uint32_t time_before;
272 uint32_t time_between; 273 uint32_t time_between;
273 uint32_t time_after; 274 uint32_t time_after;
382 //settingsGetPointer()->bluetoothActive = 0; /* MX_Bluetooth_PowerOff(); unnecessary as part of MX_GPIO_Init() */ 383 //settingsGetPointer()->bluetoothActive = 0; /* MX_Bluetooth_PowerOff(); unnecessary as part of MX_GPIO_Init() */
383 //settingsGetPointer()->compassBearing = 0; 384 //settingsGetPointer()->compassBearing = 0;
384 set_new_settings_missing_in_ext_flash(); // inlcudes update of firmware version 161121 385 set_new_settings_missing_in_ext_flash(); // inlcudes update of firmware version 161121
385 386
386 GFX_init( &pLayerInvisible ); 387 GFX_init( &pLayerInvisible );
387
388 TIM_init();
389 TIM_BACKLIGHT_init(); 388 TIM_BACKLIGHT_init();
390 389
391 /* 390 /*
392 GFX_helper_font_memory_list(&FontT24); 391 GFX_helper_font_memory_list(&FontT24);
393 GFX_helper_font_memory_list(&FontT42); 392 GFX_helper_font_memory_list(&FontT42);
473 settingsGetPointer()->debugModeOnStart = 0; 472 settingsGetPointer()->debugModeOnStart = 0;
474 ext_flash_write_settings(); 473 ext_flash_write_settings();
475 setDebugMode(); 474 setDebugMode();
476 openInfo( StIDEBUG ); 475 openInfo( StIDEBUG );
477 } 476 }
477
478 TIM_init(); /* start cylic 100ms task */
478 479
479 /* @brief main LOOP 480 /* @brief main LOOP
480 * 481 *
481 * this is executed while no IRQ interrupts it 482 * this is executed while no IRQ interrupts it
482 * - deco calculation 483 * - deco calculation
504 TriggerButtonAction(); 505 TriggerButtonAction();
505 if(DoDisplayRefresh) 506 if(DoDisplayRefresh)
506 { 507 {
507 DoDisplayRefresh = 0; 508 DoDisplayRefresh = 0;
508 RefreshDisplay(); 509 RefreshDisplay();
510
511 if(stateUsed == stateRealGetPointer()) /* Handle log entries while in dive mode*/
512 logbook_InitAndWrite();
509 } 513 }
510 514
511 #ifdef DEBUG_RUNTIME 515 #ifdef DEBUG_RUNTIME
512 translateTime(stateUsed->lifeData.timeBinaryFormat, &Stime); 516 translateTime(stateUsed->lifeData.timeBinaryFormat, &Stime);
513 if(lastsecond == 0xFF) 517 if(lastsecond == 0xFF)
559 563
560 SStateList status; 564 SStateList status;
561 uint32_t timeout_in_seconds; 565 uint32_t timeout_in_seconds;
562 uint32_t timeout_limit_Surface_in_seconds; 566 uint32_t timeout_limit_Surface_in_seconds;
563 567
568
569 BaseTick100ms = HAL_GetTick(); /* store start of 100ms cycle */
570
564 _Bool InDiveMode = 0; 571 _Bool InDiveMode = 0;
565 _Bool modeChange = 0; // to exit from menu and logbook 572 _Bool modeChange = 0; // to exit from menu and logbook
566 573
567 if(stateUsed->mode == MODE_DIVE) 574 if(stateUsed->mode == MODE_DIVE)
568 InDiveMode = 1; 575 InDiveMode = 1;
592 //foto session :-) stateSimGetPointerWrite()->lifeData.battery_charge = 99; 599 //foto session :-) stateSimGetPointerWrite()->lifeData.battery_charge = 99;
593 DataEX_copy_to_deco(); 600 DataEX_copy_to_deco();
594 DataEX_call(); 601 DataEX_call();
595 602
596 if(stateUsed == stateSimGetPointer()) 603 if(stateUsed == stateSimGetPointer())
604 {
597 simulation_UpdateLifeData(1); 605 simulation_UpdateLifeData(1);
606 }
607
598 check_warning(); 608 check_warning();
599 if(stateUsed == stateRealGetPointer())
600 logbook_InitAndWrite();
601 updateMiniLiveLogbook(1); 609 updateMiniLiveLogbook(1);
602 timer_UpdateSecond(1); 610 timer_UpdateSecond(1);
603 base_tempLightLevel = TIM_BACKLIGHT_adjust(); 611 base_tempLightLevel = TIM_BACKLIGHT_adjust();
604 tCCR_tick(); 612 tCCR_tick();
605 tHome_tick(); 613 tHome_tick();
1336 HAL_TIM_PWM_Init(&TimBacklightHandle); 1344 HAL_TIM_PWM_Init(&TimBacklightHandle);
1337 1345
1338 sConfig.OCMode = TIM_OCMODE_PWM1; 1346 sConfig.OCMode = TIM_OCMODE_PWM1;
1339 sConfig.OCPolarity = TIM_OCPOLARITY_HIGH; 1347 sConfig.OCPolarity = TIM_OCPOLARITY_HIGH;
1340 sConfig.OCFastMode = TIM_OCFAST_DISABLE; 1348 sConfig.OCFastMode = TIM_OCFAST_DISABLE;
1341 sConfig.Pulse = 50 * 6; 1349 sConfig.Pulse = 100; /* Initial brigthness of display */
1342 1350
1343 HAL_TIM_PWM_ConfigChannel(&TimBacklightHandle, &sConfig, TIM_BACKLIGHT_CHANNEL); 1351 HAL_TIM_PWM_ConfigChannel(&TimBacklightHandle, &sConfig, TIM_BACKLIGHT_CHANNEL);
1344 HAL_TIM_PWM_Start(&TimBacklightHandle, TIM_BACKLIGHT_CHANNEL); 1352 HAL_TIM_PWM_Start(&TimBacklightHandle, TIM_BACKLIGHT_CHANNEL);
1345 } 1353 }
1346 #endif 1354 #endif