forked from runezor/PiArtFrame
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
52 lines (42 loc) · 1.18 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from mandelbrot import Mandelbrot
from PIL import Image as im
import numpy as np
import sys
# Set to the name of your e-ink device (https://github.com/robweber/omni-epd#displays-implemented)
DISPLAY_TYPE = "waveshare_epd.epd7in5_V2"
# Disable when running the waveshare panel
DEBUG = False
if not DEBUG:
from omni_epd import displayfactory, EPDNotFoundError
mandelbrot = Mandelbrot()
# default height and width - need to hardcode for debug mode
WIDTH = 800
HEIGHT = 480
if not DEBUG:
try:
epd = displayfactory.load_display_driver(DISPLAY_TYPE)
except EPDNotFoundError:
print(f"Couldn't find {DISPLAY_TYPE}")
sys.exit()
WIDTH = epd.width
HEIGHT = epd.height
epd.prepare()
epd.clear()
epd.sleep()
while True:
print("Starting render...")
mandelbrot.render(WIDTH,HEIGHT)
print("Done!")
arr = mandelbrot.get_render()
arr = (np.asarray(arr)*255).astype(np.uint8)
image = im.fromarray(arr)
# Save the image as BMP
image = image.convert("1")
if DEBUG:
image.show()
else:
epd.prepare()
epd.clear()
epd.display(image)
epd.sleep()
mandelbrot.zoom_on_interesting_area()