Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ else:
f"#third_party/acados/{arch}/lib",
f"{brew_prefix}/lib",
f"{brew_prefix}/opt/[email protected]/lib",
f"{brew_prefix}/opt/llvm/lib/c++",
"/System/Library/Frameworks/OpenGL.framework/Libraries",
]

Expand Down
3 changes: 3 additions & 0 deletions selfdrive/assets/fonts/NotoColorEmoji-Regular.ttf
Git LFS file not shown
5 changes: 4 additions & 1 deletion selfdrive/ui/onroad/augmented_road_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,13 @@ def _render(self, rect):

# Handle click events if no HUD interaction occurred
if not self._hud_renderer.handle_mouse_event():
if self._click_callback and rl.is_mouse_button_pressed(rl.MouseButton.MOUSE_BUTTON_LEFT):
if self._click_callback is not None and rl.is_mouse_button_pressed(rl.MouseButton.MOUSE_BUTTON_LEFT):
if rl.check_collision_point_rec(rl.get_mouse_position(), self._content_rect):
self._click_callback()

def _handle_mouse_release(self, _):
pass

def _draw_border(self, rect: rl.Rectangle):
border_color = BORDER_COLORS.get(ui_state.status, BORDER_COLORS[UIStatus.DISENGAGED])
rl.draw_rectangle_lines_ex(rect, UI_BORDER_SIZE, border_color)
Expand Down
33 changes: 20 additions & 13 deletions system/ui/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ class Widget(abc.ABC):
def __init__(self):
self._rect: rl.Rectangle = rl.Rectangle(0, 0, 0, 0)
self._parent_rect: rl.Rectangle = rl.Rectangle(0, 0, 0, 0)
self._is_pressed = [False] * MAX_TOUCH_SLOTS
self.__is_pressed = [False] * MAX_TOUCH_SLOTS
# if current mouse/touch down started within the widget's rectangle
self._tracking_is_pressed = [False] * MAX_TOUCH_SLOTS
self.__tracking_is_pressed = [False] * MAX_TOUCH_SLOTS
self._enabled: bool | Callable[[], bool] = True
self._is_visible: bool | Callable[[], bool] = True
self._touch_valid_callback: Callable[[], bool] | None = None
self._click_callback: Callable[[], None] | None = None
self._multi_touch = False

@property
Expand All @@ -40,7 +41,7 @@ def set_parent_rect(self, parent_rect: rl.Rectangle) -> None:

@property
def is_pressed(self) -> bool:
return any(self._is_pressed)
return any(self.__is_pressed)

@property
def enabled(self) -> bool:
Expand All @@ -56,6 +57,10 @@ def is_visible(self) -> bool:
def set_visible(self, visible: bool | Callable[[], bool]) -> None:
self._is_visible = visible

def set_click_callback(self, click_callback: Callable[[], None] | None) -> None:
"""Set a callback to be called when the widget is clicked."""
self._click_callback = click_callback

def set_touch_valid_callback(self, touch_callback: Callable[[], bool]) -> None:
"""Set a callback to determine if the widget can be clicked."""
self._touch_valid_callback = touch_callback
Expand Down Expand Up @@ -91,28 +96,28 @@ def render(self, rect: rl.Rectangle = None) -> bool | int | None:
# Allows touch to leave the rect and come back in focus if mouse did not release
if mouse_event.left_pressed and self._touch_valid():
if rl.check_collision_point_rec(mouse_event.pos, self._rect):
self._is_pressed[mouse_event.slot] = True
self._tracking_is_pressed[mouse_event.slot] = True
self.__is_pressed[mouse_event.slot] = True
self.__tracking_is_pressed[mouse_event.slot] = True

# Callback such as scroll panel signifies user is scrolling
elif not self._touch_valid():
self._is_pressed[mouse_event.slot] = False
self._tracking_is_pressed[mouse_event.slot] = False
self.__is_pressed[mouse_event.slot] = False
self.__tracking_is_pressed[mouse_event.slot] = False

elif mouse_event.left_released:
if self._is_pressed[mouse_event.slot] and rl.check_collision_point_rec(mouse_event.pos, self._rect):
if self.__is_pressed[mouse_event.slot] and rl.check_collision_point_rec(mouse_event.pos, self._rect):
self._handle_mouse_release(mouse_event.pos)
self._is_pressed[mouse_event.slot] = False
self._tracking_is_pressed[mouse_event.slot] = False
self.__is_pressed[mouse_event.slot] = False
self.__tracking_is_pressed[mouse_event.slot] = False

# Mouse/touch is still within our rect
elif rl.check_collision_point_rec(mouse_event.pos, self._rect):
if self._tracking_is_pressed[mouse_event.slot]:
self._is_pressed[mouse_event.slot] = True
if self.__tracking_is_pressed[mouse_event.slot]:
self.__is_pressed[mouse_event.slot] = True

# Mouse/touch left our rect but may come back into focus later
elif not rl.check_collision_point_rec(mouse_event.pos, self._rect):
self._is_pressed[mouse_event.slot] = False
self.__is_pressed[mouse_event.slot] = False

return ret

Expand All @@ -128,6 +133,8 @@ def _update_layout_rects(self) -> None:

def _handle_mouse_release(self, mouse_pos: MousePos) -> bool:
"""Optionally handle mouse release events."""
if self._click_callback:
self._click_callback()
return False

def show_event(self):
Expand Down
11 changes: 3 additions & 8 deletions system/ui/widgets/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def gui_button(
class Button(Widget):
def __init__(self,
text: str,
click_callback: Callable[[], None] = None,
click_callback: Callable[[], None] | None = None,
font_size: int = DEFAULT_BUTTON_FONT_SIZE,
font_weight: FontWeight = FontWeight.MEDIUM,
button_style: ButtonStyle = ButtonStyle.NORMAL,
Expand All @@ -190,10 +190,6 @@ def __init__(self,
def set_text(self, text):
self._label.set_text(text)

def _handle_mouse_release(self, mouse_pos: MousePos):
if self._click_callback and self.enabled:
self._click_callback()

def _update_state(self):
if self.enabled:
self._label.set_text_color(BUTTON_TEXT_COLOR[self._button_style])
Expand All @@ -215,7 +211,7 @@ class ButtonRadio(Button):
def __init__(self,
text: str,
icon,
click_callback: Callable[[], None] = None,
click_callback: Callable[[], None] | None = None,
font_size: int = DEFAULT_BUTTON_FONT_SIZE,
text_alignment: TextAlignment = TextAlignment.LEFT,
border_radius: int = 10,
Expand All @@ -230,9 +226,8 @@ def __init__(self,
self.selected = False

def _handle_mouse_release(self, mouse_pos: MousePos):
super()._handle_mouse_release(mouse_pos)
self.selected = not self.selected
if self._click_callback:
self._click_callback()

def _update_state(self):
if self.selected:
Expand Down
2 changes: 2 additions & 0 deletions system/updated/updated.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def setup_git_options(cwd: str) -> None:
("protocol.version", "2"),
("gc.auto", "0"),
("gc.autoDetach", "false"),
("remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*"),
]
for option, value in git_cfg:
run(["git", "config", option, value], cwd)
Expand Down Expand Up @@ -389,6 +390,7 @@ def fetch_update(self) -> None:
cloudlog.info("git reset in progress")
cmds = [
["git", "checkout", "--force", "--no-recurse-submodules", "-B", branch, "FETCH_HEAD"],
["git", "branch", "--set-upstream-to", f"origin/{branch}"],
["git", "reset", "--hard"],
["git", "clean", "-xdff"],
["git", "submodule", "sync"],
Expand Down
7 changes: 4 additions & 3 deletions system/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ def is_prebuilt(path: str = BASEDIR) -> bool:

@cache
def is_dirty(cwd: str = BASEDIR) -> bool:
origin = get_origin()
branch = get_branch()
if not origin or not branch:
if not get_origin() or not get_short_branch():
return True

dirty = False
Expand All @@ -52,6 +50,9 @@ def is_dirty(cwd: str = BASEDIR) -> bool:
except subprocess.CalledProcessError:
pass

branch = get_branch()
if not branch:
return True
dirty = (subprocess.call(["git", "diff-index", "--quiet", branch, "--"], cwd=cwd)) != 0
except subprocess.CalledProcessError:
cloudlog.exception("git subprocess failed while checking dirty")
Expand Down
25 changes: 12 additions & 13 deletions tools/install_ubuntu_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,43 @@ fi
# Install common packages
function install_ubuntu_common_requirements() {
$SUDO apt-get update

# normal stuff, mostly for the bare docker image
$SUDO apt-get install -y --no-install-recommends \
ca-certificates \
clang \
build-essential \
gcc-arm-none-eabi \
liblzma-dev \
capnproto \
libcapnp-dev \
curl \
libssl-dev \
libcurl4-openssl-dev \
locales \
git \
git-lfs \
xvfb

# TODO: vendor the rest of these in third_party/
$SUDO apt-get install -y --no-install-recommends \
gcc-arm-none-eabi \
capnproto \
libcapnp-dev \
ffmpeg \
libavformat-dev \
libavcodec-dev \
libavdevice-dev \
libavutil-dev \
libavfilter-dev \
libbz2-dev \
libeigen3-dev \
libffi-dev \
libglew-dev \
libgles2-mesa-dev \
libglfw3-dev \
libglib2.0-0 \
libjpeg-dev \
libqt5charts5-dev \
libncurses5-dev \
libssl-dev \
libusb-1.0-0-dev \
libzmq3-dev \
libzstd-dev \
libsqlite3-dev \
libsystemd-dev \
locales \
opencl-headers \
ocl-icd-libopencl1 \
ocl-icd-opencl-dev \
Expand All @@ -63,8 +65,7 @@ function install_ubuntu_common_requirements() {
libqt5svg5-dev \
libqt5serialbus5-dev \
libqt5x11extras5-dev \
libqt5opengl5-dev \
xvfb
libqt5opengl5-dev
}

# Install Ubuntu 24.04 LTS packages
Expand All @@ -74,8 +75,6 @@ function install_ubuntu_lts_latest_requirements() {
$SUDO apt-get install -y --no-install-recommends \
g++-12 \
qtbase5-dev \
qtchooser \
qt5-qmake \
qtbase5-dev-tools \
python3-dev \
python3-venv
Expand Down
3 changes: 0 additions & 3 deletions tools/mac_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ fi

brew bundle --file=- <<-EOS
brew "git-lfs"
brew "zlib"
brew "capnp"
brew "coreutils"
brew "eigen"
brew "ffmpeg"
brew "glfw"
brew "libarchive"
brew "libusb"
brew "libtool"
brew "llvm"
Expand All @@ -50,7 +48,6 @@ brew "zeromq"
cask "gcc-arm-embedded"
brew "portaudio"
brew "gcc@13"
cask "font-noto-color-emoji"
EOS

echo "[ ] finished brew install t=$SECONDS"
Expand Down