EV-16: hold the Car Why text while car_over holds and the guard floor flag toggles
Display only: the 'are at' / 'give all they can' text changes only when the other state has stood for 180 s (the car_over off hold); SoC unread is never 'are at'. Cleared when car_over drops, on unplug and with cover off. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1301,6 +1301,32 @@ def _car_why(key, c, good):
|
||||
return _t("car.why." + (key if key else "wait"))
|
||||
|
||||
|
||||
# EV-16: the Why of "car over the limit" follows the guard's floor flag, which
|
||||
# toggles cycle by cycle at the reserve. The text is held: it changes only when
|
||||
# the other state has stood for as long as the car_over row's own hold.
|
||||
WHY_HOLD_S = 180.0 # = ctl_car.OVER_OFF_HOLD_S (tested)
|
||||
|
||||
|
||||
def _over_why_is_floor(c, pg) -> bool:
|
||||
"""True: "are at {pct}"; False: "give all they can". Display only: the
|
||||
state lives in `c._car_why_hold` and nothing in control reads it."""
|
||||
mono = c.car_now()
|
||||
cand = (pg.floor_limited and pg.soc is not None) if pg is not None \
|
||||
else None
|
||||
h = getattr(c, "_car_why_hold", None)
|
||||
if h is None:
|
||||
h = [bool(cand), None] # shown, since when cand differs
|
||||
elif cand is None or cand == h[0]:
|
||||
h[1] = None
|
||||
else:
|
||||
if h[1] is None:
|
||||
h[1] = mono
|
||||
if mono - h[1] >= WHY_HOLD_S:
|
||||
h = [cand, None]
|
||||
c._car_why_hold = h
|
||||
return h[0]
|
||||
|
||||
|
||||
def _car_manual_why(c, key):
|
||||
"""The Why of Manual: what you set, and what the peak limit does about it.
|
||||
Plan lines: two sentences of at most 12 words."""
|
||||
@@ -1311,9 +1337,11 @@ def _car_manual_why(c, key):
|
||||
if c.car_over:
|
||||
pg = getattr(c, "peak_guard", None)
|
||||
if not c.car_cover:
|
||||
c._car_why_hold = None
|
||||
return _t("car.why.manual_nocover", a=a)
|
||||
return _t("car.why.manual_over" if pg is not None and pg.floor_limited
|
||||
return _t("car.why.manual_over" if _over_why_is_floor(c, pg)
|
||||
else "car.why.manual_full", a=a, pct=pct)
|
||||
c._car_why_hold = None
|
||||
if c.shadow:
|
||||
t, n = w.would if w.would is not None else (c.car_a, c.car_n)
|
||||
return _t("car.why.manual_would", a=f"{float(t):.0f}",
|
||||
|
||||
Reference in New Issue
Block a user