Mercurial > public > ostc4
comparison Discovery/Src/base.c @ 696:cc542448fb28
Merge
author | heinrichsweikamp |
---|---|
date | Fri, 19 Aug 2022 11:30:24 +0200 |
parents | 7a352b449055 |
children | d55817a11f4c |
comparison
equal
deleted
inserted
replaced
661:87bee7cc77b3 | 696:cc542448fb28 |
---|---|
505 } | 505 } |
506 if(DoDisplayRefresh) /* set every 100ms by timer interrupt */ | 506 if(DoDisplayRefresh) /* set every 100ms by timer interrupt */ |
507 { | 507 { |
508 DoDisplayRefresh = 0; | 508 DoDisplayRefresh = 0; |
509 | 509 |
510 updateSetpointStateUsed(); | |
510 if(stateUsed == stateSimGetPointer()) | 511 if(stateUsed == stateSimGetPointer()) |
511 { | 512 { |
512 simulation_UpdateLifeData(1); | 513 simulation_UpdateLifeData(1); |
513 } | 514 } |
514 check_warning(); | 515 check_warning(); |
586 switch(status.base) | 587 switch(status.base) |
587 { | 588 { |
588 case BaseHome: | 589 case BaseHome: |
589 case BaseMenu: | 590 case BaseMenu: |
590 case BaseInfo: | 591 case BaseInfo: |
591 updateSetpointStateUsed(); | |
592 | |
593 DateEx_copy_to_dataOut(); | 592 DateEx_copy_to_dataOut(); |
594 DataEX_copy_to_LifeData(&modeChange); | 593 DataEX_copy_to_LifeData(&modeChange); |
595 //foto session :-) stateRealGetPointerWrite()->lifeData.battery_charge = 99; | 594 //foto session :-) stateRealGetPointerWrite()->lifeData.battery_charge = 99; |
596 //foto session :-) stateSimGetPointerWrite()->lifeData.battery_charge = 99; | 595 //foto session :-) stateSimGetPointerWrite()->lifeData.battery_charge = 99; |
597 DataEX_copy_to_deco(); | 596 DataEX_copy_to_deco(); |
767 { | 766 { |
768 pSettings->design = 7; // auto switch to 9 if necessary | 767 pSettings->design = 7; // auto switch to 9 if necessary |
769 } | 768 } |
770 } else if ((status.page == PageDive) && (status.line != 0)) | 769 } else if ((status.page == PageDive) && (status.line != 0)) |
771 { | 770 { |
772 if (pSettings->extraDisplay == EXTRADISPLAY_BIGFONT) | 771 if(get_globalState() == StDMENU) |
773 { | 772 { |
774 pSettings->design = 3; | 773 if (pSettings->extraDisplay == EXTRADISPLAY_BIGFONT) |
775 if(pSettings->MotionDetection == MOTION_DETECT_SECTOR) | |
776 { | 774 { |
777 DefineSectorCount(CUSTOMER_DEFINED_VIEWS); | 775 pSettings->design = 3; |
778 MapCVToSector(); | 776 if(pSettings->MotionDetection == MOTION_DETECT_SECTOR) |
777 { | |
778 DefineSectorCount(CUSTOMER_DEFINED_VIEWS); | |
779 MapCVToSector(); | |
780 } | |
779 } | 781 } |
782 else if (pSettings->extraDisplay == EXTRADISPLAY_DECOGAME) | |
783 pSettings->design = 4; | |
780 } | 784 } |
781 else if (pSettings->extraDisplay == EXTRADISPLAY_DECOGAME) | |
782 pSettings->design = 4; | |
783 set_globalState(StD); | 785 set_globalState(StD); |
784 } | 786 } |
785 else | 787 else |
786 { | 788 { |
787 tHome_change_field_button_pressed(); | 789 tHome_change_field_button_pressed(); |
1149 SSettings *pSettings = settingsGetPointer(); | 1151 SSettings *pSettings = settingsGetPointer(); |
1150 /* 300 - 4000 */ | 1152 /* 300 - 4000 */ |
1151 /* important levelAmbient 300 - 1200 */ | 1153 /* important levelAmbient 300 - 1200 */ |
1152 levelAmbient = 10 * pStateReal->lifeData.ambient_light_level; | 1154 levelAmbient = 10 * pStateReal->lifeData.ambient_light_level; |
1153 | 1155 |
1156 if((pStateReal->chargeStatus == CHARGER_running) || (pStateReal->chargeStatus == CHARGER_lostConnection)) | |
1157 { | |
1158 levelMax = 1000; | |
1159 levelMin = 500; | |
1160 } | |
1161 else | |
1162 { | |
1154 switch( pSettings->brightness + blBoost) | 1163 switch( pSettings->brightness + blBoost) |
1155 { | 1164 { |
1156 case 0: /* Cave */ | 1165 case 0: /* Cave */ |
1157 levelMax = 3000;/* max 25 % (x2) */ | 1166 levelMax = 3000;/* max 25 % (x2) */ |
1158 levelMin = 1500; | 1167 levelMin = 1500; |
1190 levelActual = levelAmbient; | 1199 levelActual = levelAmbient; |
1191 brightnessModeLast = pSettings->brightness; | 1200 brightnessModeLast = pSettings->brightness; |
1192 // wasLostConnection = 0; | 1201 // wasLostConnection = 0; |
1193 } | 1202 } |
1194 // } | 1203 // } |
1204 } | |
1195 | 1205 |
1196 if(levelAmbient > levelActual) | 1206 if(levelAmbient > levelActual) |
1197 levelActual += levelUpStep_100ms; | 1207 levelActual += levelUpStep_100ms; |
1198 else | 1208 else |
1199 if((levelAmbient < levelActual) && (levelActual > levelMin) && (levelActual > levelDnStep_100ms)) | 1209 if((levelAmbient < levelActual) && (levelActual > levelMin) && (levelActual > levelDnStep_100ms)) |
1201 | 1211 |
1202 if(levelActual > levelMax) | 1212 if(levelActual > levelMax) |
1203 levelActual = levelMax; | 1213 levelActual = levelMax; |
1204 else | 1214 else |
1205 if(levelActual < levelMin) | 1215 if(levelActual < levelMin) |
1216 { | |
1206 levelActual = levelMin; | 1217 levelActual = levelMin; |
1207 | 1218 } |
1208 // sConfig.Pulse = levelActual / 20; | 1219 // sConfig.Pulse = levelActual / 20; |
1209 sConfig.Pulse = (levelMin + ((levelMax - levelMin)/2)) / 20; // added 170306 | 1220 sConfig.Pulse = (levelMin + ((levelMax - levelMin)/2)) / 20; // added 170306 |
1210 | 1221 |
1211 /* xx - 600 */ | 1222 /* xx - 600 */ |
1212 if(sConfig.Pulse > 600) | 1223 if(sConfig.Pulse > 600) |
1213 sConfig.Pulse = 600; | 1224 sConfig.Pulse = 600; |
1214 else | 1225 else |
1215 if(sConfig.Pulse < 100) | 1226 if(sConfig.Pulse < 25) |
1216 sConfig.Pulse = 100; | 1227 sConfig.Pulse = 25; |
1217 | 1228 |
1218 HAL_TIM_PWM_ConfigChannel(&TimBacklightHandle, &sConfig, TIM_BACKLIGHT_CHANNEL); | 1229 HAL_TIM_PWM_ConfigChannel(&TimBacklightHandle, &sConfig, TIM_BACKLIGHT_CHANNEL); |
1219 HAL_TIM_PWM_Start(&TimBacklightHandle, TIM_BACKLIGHT_CHANNEL); | 1230 HAL_TIM_PWM_Start(&TimBacklightHandle, TIM_BACKLIGHT_CHANNEL); |
1220 | 1231 |
1221 return levelActual; | 1232 return levelActual; |
1714 else /* surface mode */ | 1725 else /* surface mode */ |
1715 { | 1726 { |
1716 switch(status.base) | 1727 switch(status.base) |
1717 { | 1728 { |
1718 case BaseHome: | 1729 case BaseHome: |
1719 // added hw 161027 | 1730 /* The RTE will mark a charge value as suspect after startup. Main know the update condition and may confirm that the value is most likely valid */ |
1720 if(!(stateRealGetPointer()->warnings.lowBattery) && (stateRealGetPointer()->lifeData.battery_charge > 9)) | 1731 // if(!(stateRealGetPointer()->warnings.lowBattery) && ((stateRealGetPointer()->lifeData.battery_charge > 9) || (wasFirmwareUpdateCheckBattery))) |
1721 { | 1732 { |
1722 stateRealGetPointerWrite()->lastKnownBatteryPercentage = stateRealGetPointer()->lifeData.battery_charge; | 1733 if(stateRealGetPointer()->lifeData.battery_charge < 0.0) |
1734 { | |
1735 if(fabs(stateRealGetPointerWrite()->lastKnownBatteryPercentage - fabs(stateRealGetPointer()->lifeData.battery_charge)) < 1.0) | |
1736 { | |
1737 setBatteryPercentage(settingsGetPointer()->lastKnownBatteryPercentage); /* confirm that value provided by RTE is valid (maybe reset happened) */ | |
1738 } | |
1739 } | |
1740 else | |
1741 { | |
1742 if(!(stateRealGetPointer()->warnings.lowBattery) && (stateRealGetPointer()->lifeData.battery_charge > 9)) | |
1743 { | |
1744 stateRealGetPointerWrite()->lastKnownBatteryPercentage = stateRealGetPointer()->lifeData.battery_charge; | |
1745 } | |
1746 } | |
1723 } | 1747 } |
1724 else if((wasFirmwareUpdateCheckBattery) && (timeout_in_seconds > 3)) | 1748 if((wasFirmwareUpdateCheckBattery) && (timeout_in_seconds > 3)) |
1725 { | 1749 { |
1726 wasFirmwareUpdateCheckBattery = 0; | 1750 wasFirmwareUpdateCheckBattery = 0; |
1727 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); // added 170306 | 1751 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); // added 170306 |
1728 if( (settingsGetPointer()->lastKnownBatteryPercentage > 0) | 1752 if( (settingsGetPointer()->lastKnownBatteryPercentage > 0) |
1729 && (settingsGetPointer()->lastKnownBatteryPercentage <= 100) | 1753 && (settingsGetPointer()->lastKnownBatteryPercentage <= 101.0) |
1730 && (stateRealGetPointer()->warnings.lowBattery)) | 1754 && (stateRealGetPointer()->warnings.lowBattery)) |
1731 { | 1755 { |
1732 setBatteryPercentage(settingsGetPointer()->lastKnownBatteryPercentage); | 1756 setBatteryPercentage(settingsGetPointer()->lastKnownBatteryPercentage); |
1733 } | 1757 } |
1734 } | 1758 } |
1735 // stuff before and new @161121 CCR-sensor limit 10 minutes | 1759 // stuff before and new @161121 CCR-sensor limit 10 minutes |
1736 if((settingsGetPointer()->dive_mode == DIVEMODE_CCR) && (settingsGetPointer()->CCR_Mode == CCRMODE_Sensors)) | 1760 if(isLoopMode(settingsGetPointer()->dive_mode) && (settingsGetPointer()->CCR_Mode == CCRMODE_Sensors)) |
1737 { | 1761 { |
1738 timeout_limit_Surface_in_seconds = settingsGetPointer()->timeoutSurfacemodeWithSensors; | 1762 timeout_limit_Surface_in_seconds = settingsGetPointer()->timeoutSurfacemodeWithSensors; |
1739 } | 1763 } |
1740 else | 1764 else |
1741 { | 1765 { |