mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-01 05:33:49 +08:00
436ff5aa42
* param to control stock vs sp ui * init styles * SP Toggles * Lint * optimizations * sp raylib preview * fix callback * fix ui preview * dialog txt * compare vs what used to be done before InputDialog * merge origin raylib toggles * tree dialog * less trees for the planet * the heck * save the trees we got icons * Update process.py * Remove 'sunnypilot_ui' Removed 'sunnypilot_ui' parameter from params_keys.h * Update raylib_screenshots.py Removed the parameter setting for 'sunnypilot_ui' in the test. * ui: fuzzy search helper * better tree. fully dynamic and stuff * rm * more indent * Squashed commit of the following: commit 6b5b686fa5f1b6c8ba05cb98606bcb5e22fdcfd9 Author: discountchubbs <alexgrant990@gmail.com> Date: Mon Nov 24 17:16:17 2025 -0800 more indent commit 76bc538ac74898e026ee67502ddcb2a2a78eb429 Merge: 53eb821dc4c53e2134e2Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Mon Nov 24 17:15:48 2025 -0800 Merge branch 'master' into rl-tree-dialog commit 53eb821dc41a09f0bbe5ddbc6957ddfb6023c979 Merge: 82e1ebe97e844f4cbc74Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Mon Nov 24 11:54:55 2025 -0800 Merge branch 'master' into rl-tree-dialog commit 82e1ebe97ecae94f14adadcf77ac7a68d55cc0fe Author: discountchubbs <alexgrant990@gmail.com> Date: Mon Nov 24 10:23:35 2025 -0800 rm commit da3ff45bb6efe5f0bbd06eb6e4f61a7a3dd844b0 Merge: 41da513fca a829a1b972 Author: discountchubbs <alexgrant990@gmail.com> Date: Mon Nov 24 10:19:08 2025 -0800 Merge remote-tracking branch 'origin/rl-tree-dialog' into rl-tree-dialog commit 41da513fcaf5a5ff302427734813b005b6385f0b Author: discountchubbs <alexgrant990@gmail.com> Date: Mon Nov 24 10:18:43 2025 -0800 better tree. fully dynamic and stuff commit b2950149fbafda7d58bb5ed2b316f59ccc8a47eb Merge: 4fb8e4beed 924e5a3211 Author: discountchubbs <alexgrant990@gmail.com> Date: Mon Nov 24 10:17:51 2025 -0800 Merge remote-tracking branch 'origin/input-dialog' into rl-tree-dialog commit a829a1b97269de24dc707188808ad5b623968dfa Merge: 848290d07e9edc36ca66Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Mon Nov 24 10:16:28 2025 -0800 Merge branch 'master' into rl-tree-dialog commit 4fb8e4beede0e6771c25aaac7c8b8f90b2f21c03 Merge: 848290d07e af4f0f8372 Author: discountchubbs <alexgrant990@gmail.com> Date: Mon Nov 24 10:16:20 2025 -0800 Merge remote-tracking branch 'origin/fuzzy-dialog' into rl-tree-dialog commit af4f0f8372a63fdaeb94fe3b64703fbcca057b9c Merge: 1d5f0ab2823cd55260d9Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Mon Nov 24 06:39:29 2025 -0800 Merge branch 'master' into fuzzy-dialog commit 1d5f0ab282a01419d03e856b4a5a205f3bfb02aa Author: discountchubbs <alexgrant990@gmail.com> Date: Sun Nov 23 11:28:59 2025 -0800 ui: fuzzy search helper commit 848290d07eaab2ed5ba948bc8dd63338dc070ac1 Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Fri Nov 21 21:08:07 2025 -0800 Update raylib_screenshots.py Removed the parameter setting for 'sunnypilot_ui' in the test. commit 6694928a467641d500bf7b81ad82308ff1652eb7 Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Fri Nov 21 21:06:57 2025 -0800 Remove 'sunnypilot_ui' Removed 'sunnypilot_ui' parameter from params_keys.h commit b3c90ef7b2bdd0328442cdbeff7b13bcb260744e Merge: 0d3bc959c8457b6634fdAuthor: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Fri Nov 21 21:06:04 2025 -0800 Merge branch 'master' into rl-tree-dialog commit 924e5a3211b3db71d785cd578ee2bdc31de5f495 Merge: a4ee4ba76dd92d2cb683Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Fri Nov 21 19:33:18 2025 -0800 Merge branch 'master' into input-dialog commit a4ee4ba76d238fbb8da5261056da649e1dfbaab9 Merge: e911de59684f13a0f775Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Fri Nov 21 16:24:31 2025 -0800 Merge branch 'master' into input-dialog commit e911de59684c44e02784ca98937cbdeb76401e05 Merge: cea6e008190ba5cbea91Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Fri Nov 21 13:50:33 2025 -0800 Merge branch 'master' into input-dialog commit cea6e00819af66f3b46b9d72282a4e550c325798 Merge: d7b8ce86ed8184cd8a6aAuthor: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Fri Nov 21 12:01:45 2025 -0800 Merge branch 'master' into input-dialog commit 0d3bc959c8547d97b14503cec73a67f5760ffb99 Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Wed Nov 19 20:29:30 2025 -0800 Update process.py commit 4f3c19ffb54db603528280e9aa941f719c764185 Author: James Vecellio <alexgrant990@gmail.com> Date: Wed Nov 19 20:28:59 2025 -0800 save the trees we got icons commit ae5c44355db6a625f9e257db2f62b2a5691a827f Author: discountchubbs <alexgrant990@gmail.com> Date: Wed Nov 19 13:38:04 2025 -0800 the heck commit 066438ad107ce9a3e9b4b2a1c0de062c523bc747 Merge: 9532675814 e74460f3a8 Author: discountchubbs <alexgrant990@gmail.com> Date: Wed Nov 19 12:18:17 2025 -0800 Merge remote-tracking branch 'origin/rl-tree-dialog' into rl-tree-dialog commit 95326758146bfe690b826d319c40f3bc7140392c Author: discountchubbs <alexgrant990@gmail.com> Date: Wed Nov 19 12:17:52 2025 -0800 less trees for the planet commit e74460f3a82d1338edb667bdf3423560270cbeab Merge: c347db376a 423a7d2ed0 Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Wed Nov 19 09:37:44 2025 -0800 Merge branch 'rl-sp-toggles' into rl-tree-dialog commit c347db376a08d3f3ee6d5cd66176bc12ec842582 Author: discountchubbs <alexgrant990@gmail.com> Date: Wed Nov 19 09:36:33 2025 -0800 tree dialog commit c9bd67b26121fce0637aeec924b777ef73a66575 Author: discountchubbs <alexgrant990@gmail.com> Date: Wed Nov 19 09:34:08 2025 -0800 merge origin raylib toggles commit d7b8ce86edaccb89452db51f4f69cf67643a0824 Author: discountchubbs <alexgrant990@gmail.com> Date: Mon Nov 17 20:21:33 2025 -0800 compare vs what used to be done before InputDialog commit 2d3d104658d660e8f9f7c12e312544c419a5d406 Merge: ded02895f4f1025f6ee9Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Mon Nov 17 19:24:20 2025 -0800 Merge branch 'master' into input-dialog commit ded02895f44a241afd3c9857760a18ec5e1406c4 Author: discountchubbs <alexgrant990@gmail.com> Date: Mon Nov 17 19:22:01 2025 -0800 dialog txt commit 9778a925b09438c7eb9618dfb0fc38eb13d53a39 Merge:cb03d0839708e85808c5Author: Jason Wen <haibin.wen3@gmail.com> Date: Sun Nov 16 03:16:58 2025 -0500 input dialog commit 423a7d2ed0249e12743c2b36e1053d5a446f8d33 Author: nayan <nayan8teen@gmail.com> Date: Sun Nov 16 11:15:28 2025 -0500 fix ui preview commit e4e10d4b87d0bdf4fe2e766122935e5ee3706a5b Author: nayan <nayan8teen@gmail.com> Date: Sun Nov 16 11:15:22 2025 -0500 fix callback commit 362e9ce04becc1ef1d16d2f23daa01cb2d5303c4 Author: nayan <nayan8teen@gmail.com> Date: Sun Nov 16 09:53:28 2025 -0500 sp raylib preview commit 3946e643f68fdb5784a2b42839162903a5f4a592 Author: nayan <nayan8teen@gmail.com> Date: Sat Nov 15 20:24:20 2025 -0500 optimizations commit 0c37a385967c201d7db6e23ca3506bc21a22d698 Author: nayan <nayan8teen@gmail.com> Date: Sat Nov 15 09:42:12 2025 -0500 Lint commit 9c5acf61c047c81fd17bd02e9354225aabf5f7e8 Author: nayan <nayan8teen@gmail.com> Date: Sat Nov 15 09:29:07 2025 -0500 SP Toggles commit 121b304fe0dcd8bfad02a05aaba6d3e0c9d3029e Author: nayan <nayan8teen@gmail.com> Date: Sat Nov 15 09:28:58 2025 -0500 init styles commit 47d848293b54a6adf83c964120ed74dfbdf58359 Author: nayan <nayan8teen@gmail.com> Date: Sat Nov 15 09:28:43 2025 -0500 param to control stock vs sp ui * Squashed commit of the following: commit 70ad001add04810c6d30fd27e44299245b2b5c86 Merge: 142663c490844f4cbc74Author: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Mon Nov 24 11:54:58 2025 -0800 Merge branch 'master' into rl-progress-bar commit 142663c490b8ec88770fc0d8bc16cfcfff3f7a62 Author: discountchubbs <alexgrant990@gmail.com> Date: Sat Nov 22 20:12:44 2025 -0800 smoother updating commit 4476e418dd5cbd84e7ef1c65bc85c21a7806c6c7 Author: discountchubbs <alexgrant990@gmail.com> Date: Sat Nov 22 09:55:17 2025 -0800 easier to see commit ad66c22e88569c86f64095fab56a3c79310b63a3 Merge: 0c46ef5948457b6634fdAuthor: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Sat Nov 22 07:45:05 2025 -0800 Merge branch 'master' into rl-progress-bar commit 0c46ef59482f678ec944ce772ac4202d257d29fd Author: discountchubbs <alexgrant990@gmail.com> Date: Sat Nov 22 07:42:59 2025 -0800 freaking test dir commit 11c19aad246b1e0bba02f49347517cf9af41a9d8 Merge: 7785238d548184cd8a6aAuthor: James Vecellio-Grant <159560811+Discountchubbs@users.noreply.github.com> Date: Fri Nov 21 12:01:36 2025 -0800 Merge branch 'master' into rl-progress-bar commit 7785238d54e60f537418aea319e449ebccccbeac Author: discountchubbs <alexgrant990@gmail.com> Date: Wed Nov 19 07:47:10 2025 -0800 raylib: progress bar * OSM panel * fetching * only show if fav_param is used in the call * flattened and custom search query * conditional for mypy * sunny's new x,y makes this even easier! * download all * add back the rough estimate * not sure i like the 'Download' * simplify the path * actual size as of today * format * more simple * only show on download or delete * loathing loathing, unadulterated loathing, i loathe it all * loathing loathing, unadulterated loathing, i loathe it all * # Conflicts: # system/ui/sunnypilot/lib/styles.py # system/ui/sunnypilot/widgets/tree_dialog.py * search * st * Update osm.py * one second updates: its heavy process, which isnt really noticeable during downloads ayways. the once a second ensures responsiveness on the ui, while also maintaining 20fps on device for country/state downloads. * efficient? i hope * big boi texts * big boi texts * use our own classes * need to clear all params when delete all * more * collateral lol * do not behave as selected if canceled during US->States dialog * more * instead of timestamp, let's just show formatted time * disable button when downloading dbs * should be the buttons being disabled * well gotta re-enable them too * empty country * might be bigger now * fixes for mapd manager * should stay as a json * sanitize it a bit * revert * only nuke if the cancel button is called * always try to update the labels * Revert "always try to update the labels" This reverts commit ba0988fc06734234598f8235fdfe10270e1a3025. * re-enable button after download is complete * disable all while downloading (till we could cancel and re-download) * fix progress bar not filling up as intended for smaller total counts * revert * use new --------- Co-authored-by: nayan <nayan8teen@gmail.com> Co-authored-by: Jason Wen <haibin.wen3@gmail.com>
145 lines
5.0 KiB
Python
Executable File
145 lines
5.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
|
|
|
This file is part of sunnypilot and is licensed under the MIT License.
|
|
See the LICENSE.md file in the root directory for more details.
|
|
"""
|
|
import json
|
|
import platform
|
|
import os
|
|
import glob
|
|
import shutil
|
|
from datetime import datetime
|
|
|
|
from openpilot.common.params import Params
|
|
from openpilot.common.realtime import Ratekeeper, config_realtime_process
|
|
from openpilot.common.swaglog import cloudlog
|
|
from openpilot.selfdrive.selfdrived.alertmanager import set_offroad_alert
|
|
from openpilot.sunnypilot.mapd.live_map_data.osm_map_data import OsmMapData
|
|
from openpilot.system.hardware.hw import Paths
|
|
from openpilot.sunnypilot.mapd import MAPD_PATH
|
|
from openpilot.sunnypilot.mapd.mapd_installer import VERSION, update_installed_version
|
|
|
|
# PFEIFER - MAPD {{
|
|
params = Params()
|
|
mem_params = Params("/dev/shm/params") if platform.system() != "Darwin" else params
|
|
# }} PFEIFER - MAPD
|
|
|
|
|
|
def get_files_for_cleanup() -> list[str]:
|
|
paths = [
|
|
f"{Paths.mapd_root()}/db",
|
|
f"{Paths.mapd_root()}/v*"
|
|
]
|
|
files_to_remove = []
|
|
for path in paths:
|
|
if os.path.exists(path):
|
|
files = glob.glob(path + '/**', recursive=True)
|
|
files_to_remove.extend(files)
|
|
# check for version and mapd files
|
|
if not os.path.isfile(MAPD_PATH):
|
|
files_to_remove.append(MAPD_PATH)
|
|
return files_to_remove
|
|
|
|
|
|
def cleanup_old_osm_data(files_to_remove: list[str]) -> None:
|
|
for file in files_to_remove:
|
|
# Remove trailing slash if path is file
|
|
if file.endswith('/') and os.path.isfile(file[:-1]):
|
|
file = file[:-1]
|
|
# Try to remove as file or symbolic link first
|
|
if os.path.islink(file) or os.path.isfile(file):
|
|
os.remove(file)
|
|
elif os.path.isdir(file): # If it's a directory
|
|
shutil.rmtree(file, ignore_errors=False)
|
|
|
|
|
|
def request_refresh_osm_location_data(nations: list[str], states: list[str] = None) -> None:
|
|
params.put("OsmDownloadedDate", str(datetime.now().timestamp()))
|
|
params.put_bool("OsmDbUpdatesCheck", False)
|
|
|
|
osm_download_locations = {
|
|
"nations": nations,
|
|
"states": states or []
|
|
}
|
|
|
|
print(f"Downloading maps for {json.dumps(osm_download_locations)}")
|
|
mem_params.put("OSMDownloadLocations", osm_download_locations)
|
|
|
|
|
|
def filter_nations_and_states(nations: list[str], states: list[str] = None) -> tuple[list[str], list[str]]:
|
|
"""Filters and prepares nation and state data for OSM map download.
|
|
|
|
If the nation is 'US' and a specific state is provided, the nation 'US' is removed from the list.
|
|
If the nation is 'US' and the state is 'All', the 'All' is removed from the list.
|
|
The idea behind these filters is that if a specific state in the US is provided,
|
|
there's no need to download map data for the entire US. Conversely,
|
|
if the state is unspecified (i.e., 'All'), we intend to download map data for the whole US,
|
|
and 'All' isn't a valid state name, so it's removed.
|
|
|
|
Parameters:
|
|
nations (list): A list of nations for which the map data is to be downloaded.
|
|
states (list, optional): A list of states for which the map data is to be downloaded. Defaults to None.
|
|
|
|
Returns:
|
|
tuple: Two lists. The first list is filtered nations and the second list is filtered states.
|
|
"""
|
|
|
|
if "US" in nations and states and not any(x.lower() == "all" for x in states):
|
|
# If a specific state in the US is provided, remove 'US' from nations
|
|
nations.remove("US")
|
|
elif "US" in nations and states and any(x.lower() == "all" for x in states):
|
|
# If 'All' is provided as a state (case invariant), remove those instances from states
|
|
states = [x for x in states if x.lower() != "all"]
|
|
elif "US" not in nations and states and any(x.lower() == "all" for x in states):
|
|
states.remove("All")
|
|
return nations, states or []
|
|
|
|
|
|
def update_osm_db() -> None:
|
|
if params.get_bool("OsmDbUpdatesCheck"):
|
|
cleanup_old_osm_data(get_files_for_cleanup())
|
|
country = params.get("OsmLocationName", return_default=True)
|
|
state = params.get("OsmStateName", return_default=True)
|
|
filtered_nations, filtered_states = filter_nations_and_states([country], [state])
|
|
request_refresh_osm_location_data(filtered_nations, filtered_states)
|
|
|
|
if not mem_params.get("OSMDownloadBounds"):
|
|
mem_params.put("OSMDownloadBounds", "")
|
|
|
|
if not mem_params.get("LastGPSPosition"):
|
|
mem_params.put("LastGPSPosition", "{}")
|
|
|
|
|
|
def main_thread():
|
|
update_installed_version(VERSION, params)
|
|
config_realtime_process([0, 1, 2, 3], 5)
|
|
|
|
rk = Ratekeeper(1, print_delay_threshold=None)
|
|
live_map_sp = OsmMapData()
|
|
|
|
# Create folder needed for OSM
|
|
try:
|
|
os.mkdir(Paths.mapd_root())
|
|
except FileExistsError:
|
|
pass
|
|
except PermissionError:
|
|
cloudlog.exception(f"mapd: failed to make {Paths.mapd_root()}")
|
|
|
|
while True:
|
|
show_alert = get_files_for_cleanup() and params.get_bool("OsmLocal")
|
|
set_offroad_alert("Offroad_OSMUpdateRequired", show_alert, "This alert will be cleared when new maps are downloaded.")
|
|
|
|
update_osm_db()
|
|
live_map_sp.tick()
|
|
rk.keep_time()
|
|
|
|
|
|
def main():
|
|
main_thread()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|