From 0203bf7214fa0145d101875006bbae2e8157d6d6 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Wed, 25 Jun 2025 15:14:57 -0700 Subject: [PATCH] hmm --- system/ui/lib/application.py | 2 +- system/ui/lib/scroll_panel.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/system/ui/lib/application.py b/system/ui/lib/application.py index d6300c52d0..4bd4b49ddd 100644 --- a/system/ui/lib/application.py +++ b/system/ui/lib/application.py @@ -9,7 +9,7 @@ from importlib.resources import as_file, files from openpilot.common.swaglog import cloudlog from openpilot.system.hardware import HARDWARE -DEFAULT_FPS = 60 +DEFAULT_FPS = 240 FPS_LOG_INTERVAL = 5 # Seconds between logging FPS drops FPS_DROP_THRESHOLD = 0.9 # FPS drop threshold for triggering a warning FPS_CRITICAL_THRESHOLD = 0.5 # Critical threshold for triggering strict actions diff --git a/system/ui/lib/scroll_panel.py b/system/ui/lib/scroll_panel.py index df20034a48..8b1a74b6af 100644 --- a/system/ui/lib/scroll_panel.py +++ b/system/ui/lib/scroll_panel.py @@ -5,7 +5,7 @@ from enum import IntEnum # Scroll constants for smooth scrolling behavior MOUSE_WHEEL_SCROLL_SPEED = 30 INERTIA_FRICTION = 0.92 # The rate at which the inertia slows down -MIN_VELOCITY = 0.5 # Minimum velocity before stopping the inertia +MIN_VELOCITY = 0.5 * 60 # Minimum velocity before stopping the inertia DRAG_THRESHOLD = 12 # Pixels of movement to consider it a drag, not a click BOUNCE_FACTOR = 0.2 # Elastic bounce when scrolling past boundaries BOUNCE_RETURN_SPEED = 0.15 # How quickly it returns from the bounce @@ -44,6 +44,7 @@ class GuiScrollPanel: # Calculate time delta current_time = rl.get_time() + fps_scale = 60.0 / rl.get_fps() mouse_pos = rl.get_mouse_position() max_scroll_y = max(content.height - bounds.height, 0) @@ -74,7 +75,7 @@ class GuiScrollPanel: # Track velocity for inertia time_since_last_drag = current_time - self._last_drag_time if time_since_last_drag > 0: - drag_velocity = delta_y / time_since_last_drag / 60.0 + drag_velocity = delta_y / time_since_last_drag # / 60.0 * fps_scale self._velocity_history.append(drag_velocity) self._last_drag_time = current_time @@ -134,7 +135,7 @@ class GuiScrollPanel: # Apply inertia (continue scrolling after mouse release) if self._scroll_state == ScrollState.IDLE: if abs(self._velocity_y) > MIN_VELOCITY: - self._offset.y += self._velocity_y + self._offset.y += self._velocity_y * rl.get_frame_time() self._velocity_y *= INERTIA_FRICTION if self._offset.y > 0 or self._offset.y < -max_scroll_y: @@ -149,9 +150,9 @@ class GuiScrollPanel: target_y = -max_scroll_y distance = target_y - self._offset.y - bounce_step = distance * BOUNCE_RETURN_SPEED + bounce_step = distance * BOUNCE_RETURN_SPEED * fps_scale self._offset.y += bounce_step - self._velocity_y *= INERTIA_FRICTION * 0.8 + self._velocity_y *= pow(INERTIA_FRICTION, fps_scale) * 0.8 if abs(distance) < 0.5 and abs(self._velocity_y) < MIN_VELOCITY: self._offset.y = target_y