add geom properties
All checks were successful
Unit Tests / Test (push) Successful in 2m19s

This commit is contained in:
Saji 2024-09-28 14:34:38 -05:00
parent 5ae230ac00
commit 95ca2447cb

View file

@ -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.
"""