comparison Discovery/Src/base.c @ 670:7a352b449055 Betatest

Reduce display brightness in case the charger is connected: A high display brigthness causes also a higher current consumption and as a result a slower charge speed shown in the charger time estimation. In order to have a reproducable value the display brightness is reduced in case the charger is connected.
author Ideenmodellierer
date Sat, 12 Mar 2022 22:54:26 +0100
parents 1b995079c045
children d55817a11f4c
comparison
equal deleted inserted replaced
669:c1e203ffb478 670:7a352b449055
1151 SSettings *pSettings = settingsGetPointer(); 1151 SSettings *pSettings = settingsGetPointer();
1152 /* 300 - 4000 */ 1152 /* 300 - 4000 */
1153 /* important levelAmbient 300 - 1200 */ 1153 /* important levelAmbient 300 - 1200 */
1154 levelAmbient = 10 * pStateReal->lifeData.ambient_light_level; 1154 levelAmbient = 10 * pStateReal->lifeData.ambient_light_level;
1155 1155
1156 if((pStateReal->chargeStatus == CHARGER_running) || (pStateReal->chargeStatus == CHARGER_lostConnection))
1157 {
1158 levelMax = 1000;
1159 levelMin = 500;
1160 }
1161 else
1162 {
1156 switch( pSettings->brightness + blBoost) 1163 switch( pSettings->brightness + blBoost)
1157 { 1164 {
1158 case 0: /* Cave */ 1165 case 0: /* Cave */
1159 levelMax = 3000;/* max 25 % (x2) */ 1166 levelMax = 3000;/* max 25 % (x2) */
1160 levelMin = 1500; 1167 levelMin = 1500;
1192 levelActual = levelAmbient; 1199 levelActual = levelAmbient;
1193 brightnessModeLast = pSettings->brightness; 1200 brightnessModeLast = pSettings->brightness;
1194 // wasLostConnection = 0; 1201 // wasLostConnection = 0;
1195 } 1202 }
1196 // } 1203 // }
1204 }
1197 1205
1198 if(levelAmbient > levelActual) 1206 if(levelAmbient > levelActual)
1199 levelActual += levelUpStep_100ms; 1207 levelActual += levelUpStep_100ms;
1200 else 1208 else
1201 if((levelAmbient < levelActual) && (levelActual > levelMin) && (levelActual > levelDnStep_100ms)) 1209 if((levelAmbient < levelActual) && (levelActual > levelMin) && (levelActual > levelDnStep_100ms))
1203 1211
1204 if(levelActual > levelMax) 1212 if(levelActual > levelMax)
1205 levelActual = levelMax; 1213 levelActual = levelMax;
1206 else 1214 else
1207 if(levelActual < levelMin) 1215 if(levelActual < levelMin)
1216 {
1208 levelActual = levelMin; 1217 levelActual = levelMin;
1209 1218 }
1210 // sConfig.Pulse = levelActual / 20; 1219 // sConfig.Pulse = levelActual / 20;
1211 sConfig.Pulse = (levelMin + ((levelMax - levelMin)/2)) / 20; // added 170306 1220 sConfig.Pulse = (levelMin + ((levelMax - levelMin)/2)) / 20; // added 170306
1212 1221
1213 /* xx - 600 */ 1222 /* xx - 600 */
1214 if(sConfig.Pulse > 600) 1223 if(sConfig.Pulse > 600)
1215 sConfig.Pulse = 600; 1224 sConfig.Pulse = 600;
1216 else 1225 else
1217 if(sConfig.Pulse < 100) 1226 if(sConfig.Pulse < 25)
1218 sConfig.Pulse = 100; 1227 sConfig.Pulse = 25;
1219 1228
1220 HAL_TIM_PWM_ConfigChannel(&TimBacklightHandle, &sConfig, TIM_BACKLIGHT_CHANNEL); 1229 HAL_TIM_PWM_ConfigChannel(&TimBacklightHandle, &sConfig, TIM_BACKLIGHT_CHANNEL);
1221 HAL_TIM_PWM_Start(&TimBacklightHandle, TIM_BACKLIGHT_CHANNEL); 1230 HAL_TIM_PWM_Start(&TimBacklightHandle, TIM_BACKLIGHT_CHANNEL);
1222 1231
1223 return levelActual; 1232 return levelActual;
1716 else /* surface mode */ 1725 else /* surface mode */
1717 { 1726 {
1718 switch(status.base) 1727 switch(status.base)
1719 { 1728 {
1720 case BaseHome: 1729 case BaseHome:
1721 // 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 */
1722 if(!(stateRealGetPointer()->warnings.lowBattery) && (stateRealGetPointer()->lifeData.battery_charge > 9)) 1731 // if(!(stateRealGetPointer()->warnings.lowBattery) && ((stateRealGetPointer()->lifeData.battery_charge > 9) || (wasFirmwareUpdateCheckBattery)))
1723 { 1732 {
1724 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 }
1725 } 1747 }
1726 else if((wasFirmwareUpdateCheckBattery) && (timeout_in_seconds > 3)) 1748 if((wasFirmwareUpdateCheckBattery) && (timeout_in_seconds > 3))
1727 { 1749 {
1728 wasFirmwareUpdateCheckBattery = 0; 1750 wasFirmwareUpdateCheckBattery = 0;
1729 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); // added 170306 1751 setButtonResponsiveness(settingsGetPointer()->ButtonResponsiveness); // added 170306
1730 if( (settingsGetPointer()->lastKnownBatteryPercentage > 0) 1752 if( (settingsGetPointer()->lastKnownBatteryPercentage > 0)
1731 && (settingsGetPointer()->lastKnownBatteryPercentage <= 100) 1753 && (settingsGetPointer()->lastKnownBatteryPercentage <= 101.0)
1732 && (stateRealGetPointer()->warnings.lowBattery)) 1754 && (stateRealGetPointer()->warnings.lowBattery))
1733 { 1755 {
1734 setBatteryPercentage(settingsGetPointer()->lastKnownBatteryPercentage); 1756 setBatteryPercentage(settingsGetPointer()->lastKnownBatteryPercentage);
1735 } 1757 }
1736 } 1758 }