mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-04 14:25:08 +00:00
fix(display): schedule windows end at the end time; on-demand ending in off hours blanks at once (#714)
Schedule and dim windows are half-open [start, end): on from the start time, off at exactly the end time, whatever second the check runs. An on-demand session that ends in scheduled-off hours (expiry or stop) clears the once-a-minute schedule gate, so the panel blanks within about a second. Golden: schedule; two test_display_pending_changes.py tests now say end_time 23:00. Merged with #712 and #713: with all three in, docs/RUN_LOOP_REDESIGN.md's 'may be wrong' list is empty, so that section now records that all six items are fixed and by which PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -728,10 +728,18 @@ class DisplayController:
|
||||
|
||||
@staticmethod
|
||||
def _in_window(start, end, now) -> bool:
|
||||
"""Whether ``now`` is within [start, end], a window that may span midnight."""
|
||||
"""Whether ``now`` is within [start, end), a window that may span midnight.
|
||||
|
||||
Half-open: on from the start minute, off at exactly the end minute.
|
||||
A closed end made the end minute count as inside, and because ``now``
|
||||
carries seconds, only a check at hh:mm:00.000 saw it that way -- so
|
||||
whether the panel went off at the start or the end of that minute
|
||||
depended on when the minute's one check ran. ``start == end`` is an
|
||||
empty window, as it effectively was before.
|
||||
"""
|
||||
if start <= end:
|
||||
return start <= now <= end
|
||||
return now >= start or now <= end
|
||||
return start <= now < end
|
||||
return now >= start or now < end
|
||||
|
||||
def _check_schedule(self):
|
||||
"""Check if display should be active based on schedule."""
|
||||
@@ -1424,6 +1432,11 @@ class DisplayController:
|
||||
self.on_demand_expires_at = None
|
||||
self.on_demand_pinned = False
|
||||
self.on_demand_schedule_override = False
|
||||
# While the session ran, _evaluate_schedule may have forced
|
||||
# is_display_active on over a scheduled-off answer. Drop the minute
|
||||
# gate so the next _check_schedule recomputes it; otherwise the panel
|
||||
# stayed on until the next clock minute.
|
||||
self._schedule_checked_minute = None
|
||||
|
||||
def _advance_on_demand(self) -> None:
|
||||
"""Move an active on-demand session to its next mode and publish it.
|
||||
|
||||
Reference in New Issue
Block a user