Files
onepilot/sunnypilot/system/params_migration.py
T
github-actions[bot] 6f34f74e9b sunnypilot v2026.001.000 release
date: 2026-04-10T22:07:44
master commit: 4ba0c4b574bff994e9a8f7266b4969b39380a8b1
2026-04-10 22:07:52 +08:00

28 lines
1.1 KiB
Python

"""
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.
"""
from openpilot.common.swaglog import cloudlog
ONROAD_BRIGHTNESS_MIGRATION_VERSION: str = "1.0"
def run_migration(_params):
# migrate OnroadScreenOffBrightness
if _params.get("OnroadScreenOffBrightnessMigrated") != ONROAD_BRIGHTNESS_MIGRATION_VERSION:
try:
val = _params.get("OnroadScreenOffBrightness")
if val >= 2: # old: 5%, new: Screen Off
new_val = val + 1
_params.put("OnroadScreenOffBrightness", new_val)
log_str = f"Successfully migrated OnroadScreenOffBrightness from {val} to {new_val}."
else:
log_str = "Migration not required for OnroadScreenOffBrightness."
_params.put("OnroadScreenOffBrightnessMigrated", ONROAD_BRIGHTNESS_MIGRATION_VERSION)
cloudlog.info(log_str + f" Setting OnroadScreenOffBrightnessMigrated to {ONROAD_BRIGHTNESS_MIGRATION_VERSION}")
except Exception as e:
cloudlog.exception(f"Error migrating OnroadScreenOffBrightness: {e}")