camera test

This commit is contained in:
matteo porta 2022-10-05 16:00:43 +02:00
parent 0e3fa905ca
commit 61aa79033d

View File

@ -51,8 +51,6 @@ class NeoPixels(Component):
@Component.reconfig_on_error @Component.reconfig_on_error
def _set(self, data=None): def _set(self, data=None):
if not self.ready:
raise AssertionError("component not ready")
if not isinstance(data, dict): if not isinstance(data, dict):
raise ValueError(f"bad call data: {data!r}") raise ValueError(f"bad call data: {data!r}")
pixel = data.get("pixel", None) pixel = data.get("pixel", None)
@ -61,13 +59,10 @@ class NeoPixels(Component):
raise ValueError(f"the pixel parameter must be a int between 0 and {C_UINT32_MAX} (broadcast)") raise ValueError(f"the pixel parameter must be a int between 0 and {C_UINT32_MAX} (broadcast)")
if not isinstance(color, str) or not color.startswith("#") or len(color) != 7: if not isinstance(color, str) or not color.startswith("#") or len(color) != 7:
raise ValueError("the color parameter must be in the html hex format: '#RRGGBB'") raise ValueError("the color parameter must be in the html hex format: '#RRGGBB'")
try:
self.conn.write(int.to_bytes(pixel, length=4, byteorder="big") + bytes.fromhex(color[1:7]) + b"\n") self.conn.write(int.to_bytes(pixel, length=4, byteorder="big") + bytes.fromhex(color[1:7]) + b"\n")
response = self.conn.readline() response = self.conn.readline()
if response != b"ok\n": if response != b"ok\n":
self.log.error(response.strip()) self.log.error(response.strip())
except serial.serialutil.SerialException:
self.log.exception(traceback.format_exc())
def set(self, pixel, color): def set(self, pixel, color):
self.request.emit({"pixel": pixel, "color": color}) self.request.emit({"pixel": pixel, "color": color})