Skip to content

Commit

Permalink
Add resolution parameter to InkyMockImpression.__init__
Browse files Browse the repository at this point in the history
This permits simpler setting of the size of the Inky Impression being mocked.

For example, this allows:
``` python
display = InkyMockImpression((800, 480))
```
which will ensure that the buffer size gets set up correctly.

Fixes pimoroni#168.
  • Loading branch information
corranwebster committed May 20, 2023
1 parent 98383c5 commit 2208264
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions library/inky/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,14 @@ class InkyMockImpression(InkyMock):
WIDTH = 600
HEIGHT = 448

def __init__(self):
"""Initialize a new mock Inky Impression."""
def __init__(self, resolution=None):
"""Initialize a new mock Inky Impression.
:param resolution: (width, height) in pixels, default: (600, 448)
"""
if resolution is not None:
self.WIDTH, self.HEIGHT = resolution
InkyMock.__init__(self, 'multi')

def _simulate(self, region):
Expand Down

0 comments on commit 2208264

Please sign in to comment.