diff --git a/src/groovylight/geom.py b/src/groovylight/geom.py index 8dbcb7f..91ca942 100644 --- a/src/groovylight/geom.py +++ b/src/groovylight/geom.py @@ -86,9 +86,14 @@ class DisplayDimensions: height: int mux: int = 2 # number of lines driven at once. + @property def addr_bits(self) -> int: return ceil(log2(self.height / self.mux)) + @property + def size(self) -> int: + return self.length * self.height + class DisplayRotation(Enum): """Display rotation enums. The names indicate the general direction @@ -162,13 +167,25 @@ class DisplayGeometry: self.strict = strict pass - def add_string(self, s: DisplayString): - """Add a new string to the display. This new string is located at - a specific point, and has a direction, along with dimension that reveal - the number of address lines (typically 64, with 1:32 selection so 5 address - bits) and the total length of the string which is used to size the line - buffers. + @property + def n_strings(self) -> int: + """Returns the number of strings in the display""" + return len(self._strings) + @property + def framebuffer_size(self) -> int: + """Returns the total size of the display, in pixels. + + NOTE: This currently only works with strict=true. + """ + sum = 0 + for s in self._strings: + sum += s.dimensions.size + + return sum + + def add_string(self, s: DisplayString): + """Add a new string to the display. When in strict mode, this method will throw an exception if this new string will overlap with an existing string. """