diff --git a/village/devices/camera.py b/village/devices/camera.py index 8bef4c8a1..5454c20d9 100644 --- a/village/devices/camera.py +++ b/village/devices/camera.py @@ -83,14 +83,17 @@ def render_request(self, completed_request) -> None: self._frame_counter = 0 super().render_request(completed_request) - def paintEvent(self, event) -> None: - """Renders the camera frame then draws screen-only overlays.""" - super().paintEvent(event) - if self._cam is not None: - painter = QPainter(self) - self._cam.task_is_running = manager.state.task_is_running() - manager.camera_draw.draw_preview(self._cam, painter) - painter.end() + def drawForeground(self, painter: QPainter, rect) -> None: + """Draws screen-only overlays on top of the camera frame + (which is a QGraphicsView in QPicamera2!).""" + super().drawForeground(painter, rect) + if self._cam is None: + return + painter.save() + painter.resetTransform() + self._cam.task_is_running = manager.state.task_is_running() + manager.camera_draw.draw_preview(self._cam, painter) + painter.restore() # the camera class diff --git a/village/devices/led_strip.py b/village/devices/led_strip.py index 8b4a5ea23..9b508bc84 100644 --- a/village/devices/led_strip.py +++ b/village/devices/led_strip.py @@ -1,7 +1,7 @@ import traceback from typing import Any -from pi5neo import Pi5Neo +from pi5neo import Pi5Neo, EPixelType from village.classes.null_classes import NullLEDStrip from village.scripts.log import log @@ -12,7 +12,7 @@ def get_led_strip( spi_device: str = "/dev/spidev0.0", num_leds: int = 10, spi_speed_khz: int = 800, - pixel_type: str = "GRB", + pixel_type: EPixelType = EPixelType.RGB, quiet_mode: bool = True, ) -> Any | NullLEDStrip: """Factory function to get an instance of the LED strip. @@ -21,7 +21,9 @@ def get_led_strip( spi_device (str): SPI device path num_leds (int): Number of LEDs in the strip spi_speed_khz (int): SPI speed in kHz - pixel_type (str): Type of LED pixels 'GRB' or 'GRBW' or 'RGB' or 'RGBW' + pixel_type (EPixelType): Color channel order of the pixels. One of + EPixelType.RGB / GRB / RGBW / GRBW (RGB/GRB are 3-channel, + RGBW/GRBW have a dedicated white channel). quiet_mode (bool): Whether to suppress output Returns: NullLEDStrip: An instance of the LED strip class or @@ -48,6 +50,6 @@ def get_led_strip( spi_device=settings.get("SPI_DEVICE"), num_leds=settings.get("NUMBER_OF_LEDS"), spi_speed_khz=settings.get("SPI_SPEED_KHZ"), - pixel_type=settings.get("PIXEL_TYPE").value, + pixel_type=EPixelType[settings.get("PIXEL_TYPE").name], quiet_mode=True, )