From 45082c8b3feafa113a6c8e16559b3ad4390bb7e6 Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 4 Apr 2025 08:50:01 +0200 Subject: [PATCH] chore: follow-up to #20183 --- core/circuit/circuit.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/circuit/circuit.go b/core/circuit/circuit.go index c77b463b1..c2ff6f85f 100644 --- a/core/circuit/circuit.go +++ b/core/circuit/circuit.go @@ -326,9 +326,9 @@ func (c *Circuit) ValidatePower(old, new float64, charging bool) float64 { var capped float64 if charging { - capped = min(maxPower, new, max(0, potential+old)) + capped = min(new, maxPower, max(0, potential+old)) } else { - capped = max(0, min(new, potential)) + capped = min(new, max(0, potential)) } if new > capped { c.log.DEBUG.Printf("validate power: %.5gW + (%.5gW -> %.5gW) > %.5gW capped at %.5gW", c.power, old, new, maxPower, capped) @@ -350,9 +350,9 @@ func (c *Circuit) ValidateCurrent(old, new float64, charging bool) float64 { var capped float64 if charging { - capped = min(maxCurrent, new, max(0, potential+old)) + capped = min(new, maxCurrent, max(0, potential+old)) } else { - capped = max(0, min(new, potential)) + capped = min(new, max(0, potential)) } if new > capped { c.log.DEBUG.Printf("validate current: %.3gA + (%.3gA -> %.3gA) > %.3gA capped at %.3gA", c.current, old, new, maxCurrent, capped)