Skip to content

Commit

Permalink
ensure ints not floats
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Aug 16, 2024
1 parent 56b8562 commit b9ec3d1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ovos_gui_plugin_shell_companion/brightness.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def get_brightness(self) -> int:
brightness_level = line.decode("utf-8").strip()
self._brightness_level = int(brightness_level) * 100 / 255 # convert from 0-255 to 0-100 range

return self._brightness_level
return int(self._brightness_level)

def handle_get_brightness(self, message: Message):
"""
Expand All @@ -166,14 +166,15 @@ def set_brightness(self, level: int):
if self.device_interface is None:
LOG.error("brightness control interface not available, can not change brightness")
return
LOG.debug("Setting brightness level")
level = int(level)
LOG.debug(f"Setting brightness level: {level}")
if self.device_interface == "HDMI":
subprocess.Popen(
[self.ddcutil, "setvcp", self.ddcutil_brightness_code,
"--bus", self.ddcutil_detected_bus, str(level)]
)
elif self.device_interface == "DSI":
level = level * 255 / 100 # DSI goes from 0 to 255, HDMI from o to 100
level = int(level * 255 / 100) # DSI goes from 0 to 255, HDMI from o to 100
subprocess.call(
f"echo {level} > /sys/class/backlight/rpi_backlight/brightness", shell=True
)
Expand Down

0 comments on commit b9ec3d1

Please sign in to comment.