diff --git a/cpdctrl/led_script.py b/cpdctrl/led_script.py index ecb01df..ffce452 100644 --- a/cpdctrl/led_script.py +++ b/cpdctrl/led_script.py @@ -159,8 +159,10 @@ class LedScript: def _get_current_index(script, dt:float) -> int: if script.shape[0] == 1: return 0 + if dt > script["dtsum"][-1]: # if time is past the last index + return script["dtsum"].shape[0] - 1 distance = script["dtsum"] - dt - idx = np.where(distance >= 0, distance, np.inf).argmin() + idx = int(np.where(distance >= 0, distance, np.inf).argmin()) return idx def get_current_index(self, dt:float) -> int: