comparison Discovery/Src/base.c @ 116:b848056057ce FlipDisplay

Added small helper for runtime evaluation Moved initialisation of settings before GFX init to have parameters available during init phase
author Ideenmodellierer
date Sun, 06 Jan 2019 22:27:46 +0100
parents 3834b6272ee5
children 135eae957389
comparison
equal deleted inserted replaced
115:3834b6272ee5 116:b848056057ce
323 ITM_Port8(0) = ch; 323 ITM_Port8(0) = ch;
324 } 324 }
325 return(ch); 325 return(ch);
326 } 326 }
327 */ 327 */
328 328 /* #define DEBUG_RUNTIME TRUE */
329 #ifdef DEBUG_RUNTIME
330 #define MEASURECNT 60 /* number of measuremets to be stored */
331 static uint32_t loopcnt[MEASURECNT];
332 #endif
329 // =============================================================================== 333 // ===============================================================================
330 // main 334 // main
331 /// @brief This function makes initializations and has the nonIRQ endless loop 335 /// @brief This function makes initializations and has the nonIRQ endless loop
332 /// for bluetooth and deco calculations 336 /// for bluetooth and deco calculations
333 /// 337 ///
334 // =============================================================================== 338 // ===============================================================================
335 int main(void) 339 int main(void)
336 { 340 {
337 uint32_t pLayerInvisible; 341 uint32_t pLayerInvisible;
338 uint16_t totalDiveCounterFound; 342 uint16_t totalDiveCounterFound;
343 #ifdef DEBUG_RUNTIME
344 RTC_TimeTypeDef Stime;
345 uint8_t measurementindex = 0;
346 uint8_t lastsecond = 0xFF;
347 #endif
348
339 349
340 set_globalState( StBoot0 ); 350 set_globalState( StBoot0 );
341 351
342 HAL_Init(); 352 HAL_Init();
343 HAL_NVIC_SetPriorityGrouping( NVIC_PRIORITYGROUP_2 ); 353 HAL_NVIC_SetPriorityGrouping( NVIC_PRIORITYGROUP_2 );
348 // MX_SmallCPU_NO_Reset_Helper(); //161116 hw 358 // MX_SmallCPU_NO_Reset_Helper(); //161116 hw
349 MX_SPI_Init(); 359 MX_SPI_Init();
350 MX_UART_Init(); 360 MX_UART_Init();
351 SDRAM_Config(); 361 SDRAM_Config();
352 HAL_Delay( 100 ); 362 HAL_Delay( 100 );
363
364 stateRealGetPointerWrite()->lastKnownBatteryPercentage = 0; // damit das nicht in settings kopiert wird.
365 set_settings_to_Standard();
366 mod_settings_for_first_start_with_empty_ext_flash();
367 ext_flash_read_settings();
368 if( newFirmwareVersionCheckViaSettings() ) // test for old firmware version in loaded settings
369 {
370 wasFirmwareUpdateCheckBattery = 1;
371 set_settings_button_to_standard_with_individual_buttonBalance(); // will adapt individual values
372 }
373 //settingsGetPointer()->bluetoothActive = 0; /* MX_Bluetooth_PowerOff(); unnecessary as part of MX_GPIO_Init() */
374 //settingsGetPointer()->compassBearing = 0;
375 set_new_settings_missing_in_ext_flash(); // inlcudes update of firmware version 161121
376
353 GFX_init( &pLayerInvisible ); 377 GFX_init( &pLayerInvisible );
354 378
355 TIM_init(); 379 TIM_init();
356 TIM_BACKLIGHT_init(); 380 TIM_BACKLIGHT_init();
357 381
363 GFX_helper_font_memory_list(&FontT84); 387 GFX_helper_font_memory_list(&FontT84);
364 GFX_helper_font_memory_list(&FontT105); 388 GFX_helper_font_memory_list(&FontT105);
365 GFX_helper_font_memory_list(&FontT144); 389 GFX_helper_font_memory_list(&FontT144);
366 */ 390 */
367 391
368 stateRealGetPointerWrite()->lastKnownBatteryPercentage = 0; // damit das nicht in settings kopiert wird. 392
369 set_settings_to_Standard();
370 mod_settings_for_first_start_with_empty_ext_flash();
371 ext_flash_read_settings();
372 if( newFirmwareVersionCheckViaSettings() ) // test for old firmware version in loaded settings
373 {
374 wasFirmwareUpdateCheckBattery = 1;
375 set_settings_button_to_standard_with_individual_buttonBalance(); // will adapt individual values
376 }
377 //settingsGetPointer()->bluetoothActive = 0; /* MX_Bluetooth_PowerOff(); unnecessary as part of MX_GPIO_Init() */
378 //settingsGetPointer()->compassBearing = 0;
379 set_new_settings_missing_in_ext_flash(); // inlcudes update of firmware version 161121
380 393
381 // new 170508: bluetooth on at start 394 // new 170508: bluetooth on at start
382 settingsGetPointer()->bluetoothActive = 1; 395 settingsGetPointer()->bluetoothActive = 1;
383 MX_Bluetooth_PowerOn(); 396 MX_Bluetooth_PowerOn();
384 397
498 updateMenu(); 511 updateMenu();
499 ext_flash_write_settings(); 512 ext_flash_write_settings();
500 } 513 }
501 } 514 }
502 */ 515 */
516
517 #ifdef DEBUG_RUNTIME
518 translateTime(stateUsed->lifeData.timeBinaryFormat, &Stime);
519 if(lastsecond == 0xFF)
520 {
521 measurementindex = 0;
522 loopcnt[measurementindex] = 0;
523 lastsecond = Stime.Seconds;
524 }
525 loopcnt[measurementindex]++;
526
527 if(lastsecond != Stime.Seconds)
528 {
529 measurementindex++;
530 if (measurementindex == MEASURECNT) measurementindex = 0;
531 loopcnt[measurementindex] = 0;
532 lastsecond = Stime.Seconds;
533 if(measurementindex +1 < MEASURECNT) loopcnt[measurementindex +1] = 0xffff; /* helps to identify the latest value */
534 }
535 #endif
536
503 } 537 }
504 } 538 }
505 539
506 // =============================================================================== 540 // ===============================================================================
507 // timer IRQ 541 // timer IRQ