diff --git a/src/groovylight/common.py b/src/groovylight/common.py index b3b8c30..7dae2c3 100644 --- a/src/groovylight/common.py +++ b/src/groovylight/common.py @@ -24,9 +24,11 @@ Rgb111Layout = RGBLayout(1, 1, 1) class RGBView(data.View): - def bit_depth(self) -> int: - return max(self.red.shape(), self.green.shape(), self.blue.shape()) + return max( + self.red.shape().width, self.green.shape().width, self.blue.shape().width + ) + def channel_slice(self, bit: int) -> Rgb111Layout: """Select bits from each channel and use it to form an Rgb111Layout. This is useful for BCM stuff, since the bits are sliced to form a bitplane. diff --git a/src/groovylight/hub75.py b/src/groovylight/hub75.py index b2deb52..23c10e9 100644 --- a/src/groovylight/hub75.py +++ b/src/groovylight/hub75.py @@ -1,4 +1,4 @@ -from amaranth import Module, Cat, Mux, Print, ShapeLike, Signal, Assert, Array +from amaranth import Module, Cat, Mux, ShapeLike, Signal, Assert, Array from amaranth.build import Platform from amaranth.lib import wiring, data from amaranth.lib.wiring import In, Out @@ -313,7 +313,6 @@ class Hub75DataDriver(wiring.Component): return m - class Hub75Coordinator(wiring.Component): """A shared-control hub75 driver""" diff --git a/src/groovylight/tests/test_common.py b/src/groovylight/tests/test_common.py index a180063..f30dac5 100644 --- a/src/groovylight/tests/test_common.py +++ b/src/groovylight/tests/test_common.py @@ -7,14 +7,14 @@ from groovylight.common import Rgb888Layout, Rgb666Layout, RGBView def test_rgbview(): rgb = Rgb888Layout(0xAABBCC) - assert rgb.channel_size() == unsigned(8) + assert rgb.bit_depth() == 8 rgb18 = Rgb666Layout(0x2DEFD) slice = rgb.channel_slice(1) assert isinstance(slice, RGBView), "channel_slice should return another rgbview" - assert slice.channel_size() == unsigned(1), "channel_slice channel size should be 1" + assert slice.bit_depth() == 1, "channel_slice channel size should be 1" assert isinstance( rgb18.channel_slice(5), RGBView ), "channel_slice should return another rgbview"