Mercurial > public > ostc4
comparison Discovery/Src/base.c @ 1028:3d9552e4997c GasConsumption
Code improvment: line <=> menu id function:
In generell the structure of the menus is defined by the tStructure.h using global state defines. In some implementation hardcoded line numbers are used. Risk: In case the order of menu items change the update of other code sections could be forgotten (in the case the update of the top menu) causing unintended behavior. To avoid this the hard coded lines have been replaced by a function connecting the intended function to the menu item defined in the tstructure.h.
| author | Ideenmodellierer |
|---|---|
| date | Sun, 07 Sep 2025 19:08:43 +0200 |
| parents | 5a690195b6b7 |
| children | 2af07aa38531 |
comparison
equal
deleted
inserted
replaced
| 1027:158100a84ebd | 1028:3d9552e4997c |
|---|---|
| 382 MX_UART_Init(); | 382 MX_UART_Init(); |
| 383 SDRAM_Config(); | 383 SDRAM_Config(); |
| 384 HAL_Delay( 100 ); | 384 HAL_Delay( 100 ); |
| 385 | 385 |
| 386 stateRealGetPointerWrite()->lastKnownBatteryPercentage = 0; // damit das nicht in settings kopiert wird. | 386 stateRealGetPointerWrite()->lastKnownBatteryPercentage = 0; // damit das nicht in settings kopiert wird. |
| 387 set_settings_to_Standard(); /* initialize setting structure with default value => will be overwritten by flash read operation */ | 387 set_settings_to_Standard(EF_SETTINGS); /* initialize setting structure with default value => will be overwritten by flash read operation */ |
| 388 mod_settings_for_first_start_with_empty_ext_flash(); | 388 mod_settings_for_first_start_with_empty_ext_flash(); |
| 389 ext_flash_read_settings(); | 389 ext_flash_read_settings(EF_SETTINGS); |
| 390 if( newFirmwareVersionCheckViaSettings() ) // test for old firmware version in loaded settings | 390 if( newFirmwareVersionCheckViaSettings() ) // test for old firmware version in loaded settings |
| 391 { | 391 { |
| 392 wasFirmwareUpdateCheckBattery = 1; | 392 wasFirmwareUpdateCheckBattery = 1; |
| 393 set_settings_button_to_factory_with_individual_buttonBalance(); // will adapt individual values | 393 set_settings_button_to_factory_with_individual_buttonBalance(); // will adapt individual values |
| 394 } | 394 } |
| 395 | 395 |
| 396 set_new_settings_missing_in_ext_flash(); // includes update of firmware version 161121 | 396 set_new_settings_missing_in_ext_flash(EF_SETTINGS); // includes update of firmware version 161121 |
| 397 | 397 |
| 398 GFX_init( &pLayerInvisible ); | 398 GFX_init( &pLayerInvisible ); |
| 399 TIM_BACKLIGHT_init(); | 399 TIM_BACKLIGHT_init(); |
| 400 | 400 |
| 401 // new 170508: bluetooth on at start | 401 // new 170508: bluetooth on at start |
| 410 { | 410 { |
| 411 MX_Bluetooth_PowerOn(); | 411 MX_Bluetooth_PowerOn(); |
| 412 tComm_Set_Bluetooth_Name(1); | 412 tComm_Set_Bluetooth_Name(1); |
| 413 } | 413 } |
| 414 */ | 414 */ |
| 415 errorsInSettings = check_and_correct_settings(); | 415 errorsInSettings = check_and_correct_settings(EF_SETTINGS); |
| 416 createDiveSettings(); | 416 createDiveSettings(); |
| 417 | 417 |
| 418 #ifdef QUICK_SLEEP | 418 #ifdef QUICK_SLEEP |
| 419 settingsGetPointer()->timeoutSurfacemode = 20; | 419 settingsGetPointer()->timeoutSurfacemode = 20; |
| 420 #else | 420 #else |
| 469 settingsGetPointer()->totalDiveCounter = totalDiveCounterFound; | 469 settingsGetPointer()->totalDiveCounter = totalDiveCounterFound; |
| 470 | 470 |
| 471 if( settingsGetPointer()->debugModeOnStart ) | 471 if( settingsGetPointer()->debugModeOnStart ) |
| 472 { | 472 { |
| 473 settingsGetPointer()->debugModeOnStart = 0; | 473 settingsGetPointer()->debugModeOnStart = 0; |
| 474 ext_flash_write_settings(0); | 474 ext_flash_write_settings(EF_SETTINGS,0); |
| 475 setDebugMode(); | 475 setDebugMode(); |
| 476 openInfo( StIDEBUG ); | 476 openInfo( StIDEBUG ); |
| 477 } | 477 } |
| 478 InitMotionDetection(); | 478 InitMotionDetection(); |
| 479 | 479 |
| 503 tCCR_control(); | 503 tCCR_control(); |
| 504 if( tComm_control() )// will stop while loop if tComm Mode started until exit from UART | 504 if( tComm_control() )// will stop while loop if tComm Mode started until exit from UART |
| 505 { | 505 { |
| 506 createDiveSettings(); | 506 createDiveSettings(); |
| 507 updateMenu(); | 507 updateMenu(); |
| 508 ext_flash_write_settings(0); | 508 ext_flash_write_settings(EF_SETTINGS,0); |
| 509 } | 509 } |
| 510 | 510 |
| 511 /* check if tasks depending on global state are pending */ | 511 /* check if tasks depending on global state are pending */ |
| 512 get_globalStateList(&status); | 512 get_globalStateList(&status); |
| 513 if(status.base == BaseHome) | 513 if(status.base == BaseHome) |
| 1021 /* not at the moment of testing */ | 1021 /* not at the moment of testing */ |
| 1022 // ext_flash_erase_firmware_if_not_empty(); | 1022 // ext_flash_erase_firmware_if_not_empty(); |
| 1023 GFX_logoAutoOff(); | 1023 GFX_logoAutoOff(); |
| 1024 display_power_off(); | 1024 display_power_off(); |
| 1025 ext_flash_write_devicedata(true); /* write data at default position */ | 1025 ext_flash_write_devicedata(true); /* write data at default position */ |
| 1026 ext_flash_write_settings(true); /* write data at default position */ | 1026 ext_flash_write_settings(EF_SETTINGS,true); /* write data at default position */ |
| 1027 set_globalState(StStop); | 1027 set_globalState(StStop); |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 | 1030 |
| 1031 // ----------------------------- | 1031 // ----------------------------- |
| 1051 output->base = (uint8_t)((id >> 28) & 0x0F); | 1051 output->base = (uint8_t)((id >> 28) & 0x0F); |
| 1052 output->page = (uint8_t)((id >> 24) & 0x0F); | 1052 output->page = (uint8_t)((id >> 24) & 0x0F); |
| 1053 output->line = (uint8_t)((id >> 16) & 0xFF); | 1053 output->line = (uint8_t)((id >> 16) & 0xFF); |
| 1054 output->field = (uint8_t)((id >> 8) & 0xFF); | 1054 output->field = (uint8_t)((id >> 8) & 0xFF); |
| 1055 output->mode = (uint8_t)((id ) & 0xFF); | 1055 output->mode = (uint8_t)((id ) & 0xFF); |
| 1056 } | |
| 1057 | |
| 1058 uint8_t get_lineOfID(uint32_t id) | |
| 1059 { | |
| 1060 uint8_t ret = (uint8_t)((id >> 16) & 0xFF); | |
| 1061 if(ret > 6) | |
| 1062 { | |
| 1063 ret = 0; | |
| 1064 } | |
| 1065 return ret; | |
| 1056 } | 1066 } |
| 1057 | 1067 |
| 1058 SButtonLock get_ButtonLock(void) | 1068 SButtonLock get_ButtonLock(void) |
| 1059 { | 1069 { |
| 1060 return ButtonLockState; | 1070 return ButtonLockState; |
