mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 01:39:30 +02:00
Add negative SOC scaling
This commit is contained in:
parent
9a8c1f1f77
commit
efabac4b8e
3 changed files with 11 additions and 4 deletions
|
@ -427,6 +427,12 @@ void update_calculated_values() {
|
|||
calc_soc = 10000 * (calc_soc - datalayer.battery.settings.min_percentage);
|
||||
calc_soc = calc_soc / (datalayer.battery.settings.max_percentage - datalayer.battery.settings.min_percentage);
|
||||
datalayer.battery.status.reported_soc = calc_soc;
|
||||
//Extra safety since we allow scaling negatively, if real% is < 1.00%, zero it out
|
||||
if (datalayer.battery.status.real_soc < 100) {
|
||||
datalayer.battery.status.reported_soc = 0;
|
||||
} else {
|
||||
datalayer.battery.status.reported_soc = calc_soc;
|
||||
}
|
||||
|
||||
// Calculate the scaled remaining capacity in Wh
|
||||
if (datalayer.battery.info.total_capacity_Wh > 0 && datalayer.battery.status.real_soc > 0) {
|
||||
|
|
|
@ -113,7 +113,7 @@ typedef struct {
|
|||
/** Minimum percentage setting. Set this value to the lowest real SOC
|
||||
* you want the inverter to be able to use. At this real SOC, the inverter
|
||||
* will "see" 0% */
|
||||
uint16_t min_percentage = BATTERY_MINPERCENTAGE;
|
||||
int16_t min_percentage = BATTERY_MINPERCENTAGE;
|
||||
/** Maximum percentage setting. Set this value to the highest real SOC
|
||||
* you want the inverter to be able to use. At this real SOC, the inverter
|
||||
* will "see" 100% */
|
||||
|
|
|
@ -209,10 +209,11 @@ String settings_processor(const String& var) {
|
|||
"100.0');}}}";
|
||||
content +=
|
||||
"function editSocMin(){var value=prompt('Inverter will see completely discharged (0pct)SOC when this value is "
|
||||
"reached. Enter new minimum SOC value that battery will discharge to "
|
||||
"(0-50.0):');if(value!==null){if(value>=0&&value<=50){var xhr=new "
|
||||
"reached. Advanced users can set to negative values. Enter new minimum SOC value that battery will discharge "
|
||||
"to "
|
||||
"(-10.0to50.0):');if(value!==null){if(value>=-10&&value<=50){var xhr=new "
|
||||
"XMLHttpRequest();xhr.onload=editComplete;xhr.onerror=editError;xhr.open('GET','/"
|
||||
"updateSocMin?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between 0 and "
|
||||
"updateSocMin?value='+value,true);xhr.send();}else{alert('Invalid value. Please enter a value between -10 and "
|
||||
"50.0');}}}";
|
||||
content +=
|
||||
"function editMaxChargeA(){var value=prompt('Some inverters needs to be artificially limited. Enter new "
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue