Illumination Things for sangaboard and simulator

This commit is contained in:
jaknapper 2026-02-10 18:42:59 +00:00
parent 8435f6ae98
commit 5682b4d28d
3 changed files with 65 additions and 27 deletions

View file

@ -140,6 +140,7 @@ class SimulatedCamera(BaseCamera):
self._capture_thread: Optional[Thread] = None
self._capture_enabled = False
self.generate_sprites()
self.mult = 1
repeating: bool = lt.property(default=False)
@ -339,14 +340,20 @@ class SimulatedCamera(BaseCamera):
pl_img = Image.fromarray(np_img.astype("uint8"))
return pl_img.resize((self.shape[1], self.shape[0]), Image.Resampling.BILINEAR)
@lt.action
def set_led(self, led_on: bool = True, led_channel=None):
if led_on:
self.mult = 1
else:
self.mult = 0
def generate_frame(self) -> Image.Image:
"""Generate a frame with blobs based on the stage coordinates."""
pos = self._stage.instantaneous_position
frame = self.generate_image((pos["y"], pos["x"], pos["z"]))
# Simulate LED turning off by setting all channels to 0
if not self._stage.led_on:
frame = np.full((self.shape[0], self.shape[1], 3), 0, dtype=np.uint8)
return frame
return frame * self.mult
def __enter__(self) -> Self:
"""Start the capture thread when the Thing context manager is opened."""