Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement local display detection on rpi #1890

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 4 additions & 2 deletions packages/helpermodules/update_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ class UpdateConfig:
"^openWB/optional/et/get/prices$",
"^openWB/optional/et/provider$",
"^openWB/optional/int_display/active$",
"^openWB/optional/int_display/detected$",
"^openWB/optional/int_display/on_if_plugged_in$",
"^openWB/optional/int_display/pin_active$",
"^openWB/optional/int_display/pin_code$",
Expand Down Expand Up @@ -488,12 +489,13 @@ class UpdateConfig:
("openWB/internal_chargepoint/0/data/parent_cp", None),
("openWB/internal_chargepoint/1/data/parent_cp", None),
("openWB/optional/et/provider", NO_MODULE),
("openWB/optional/int_display/active", False),
("openWB/optional/int_display/active", True),
("openWB/optional/int_display/detected", True),
("openWB/optional/int_display/on_if_plugged_in", True),
("openWB/optional/int_display/pin_active", False),
("openWB/optional/int_display/pin_code", "0000"),
("openWB/optional/int_display/standby", 60),
("openWB/optional/int_display/rotation", 180),
("openWB/optional/int_display/rotation", 0),
("openWB/optional/int_display/theme", dataclass_utils.asdict(CardsDisplayTheme())),
("openWB/optional/int_display/only_local_charge_points", False),
("openWB/optional/led/active", False),
Expand Down
19 changes: 19 additions & 0 deletions runs/atreboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,25 @@ chmod 666 "$LOGFILE"
echo "cleaning obsolete python cache folders..."
"$OPENWBBASEDIR/runs/cleanPythonCache.sh"

# detect connected displays
# set default to "true" as fallback if "tvservice" is missing
displayDetected="true"
if which tvservice >/dev/null; then
echo "detected 'tvservice', query for connected displays"
output=$(tvservice -l)
echo "$output"
if [[ ! $output =~ "HDMI" ]] && [[ ! $output =~ "LCD" ]]; then
echo "no display detected"
displayDetected="false"
else
echo "detected HDMI or LCD display(s)"
fi
else
echo "'tvservice' not found, assuming a display is present"
fi
echo "displayDetected: $displayDetected"
mosquitto_pub -p 1886 -t "openWB/optional_int_display/detected" -r -m "$displayDetected"
benderl marked this conversation as resolved.
Show resolved Hide resolved

# display setup
echo "display setup..."
displaySetupModified=0
Expand Down
4 changes: 2 additions & 2 deletions runs/update_local_display.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sudo sed -i "s/^xset s .*$/xset s ${timeout}/" "/home/openwb/.config/lxsession/L

# enable/disable display
default_target=$(systemctl get-default)
if display_active=$(mosquitto_sub -p 1886 -t "openWB/optional/int_display/active" -C 1 -W 1) && [[ $display_active == "true" ]]; then
if display_active=$(mosquitto_sub -p 1886 -t "openWB/optional/int_display/active" -C 1 -W 1) && [[ $display_active == "true" ]] && display_detected=$(mosquitto_sub -p 1886 -t "openWB/optional/int_display/detected" -C 1 -W 1) && [[ $display_detected == "true" ]]; then
benderl marked this conversation as resolved.
Show resolved Hide resolved
if [[ $default_target == "graphical.target" ]]; then
echo "graphical target already configured"
else
Expand All @@ -37,7 +37,7 @@ else
fi

if rotation=$(mosquitto_sub -p 1886 -t "openWB/optional/int_display/rotation" -C 1 -W 1); then
rotationValue=$(((rotation / 90 + 4) % 4)) # this allows negative rotation angles
rotationValue=$(((rotation / 90 + 4) % 4)) # this allows negative rotation angles
LKuemmel marked this conversation as resolved.
Show resolved Hide resolved
current_rotation=$(grep "^lcd_rotate=[0-3]$" /boot/config.txt | grep -o "[0-3]$")
echo "current display rotation: $current_rotation"
echo "new display rotation: '$rotation' -> $rotationValue"
Expand Down