Skip to content

Commit a3f6454

Browse files
committed
add GBOY mode
1 parent 2ae4d81 commit a3f6454

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

adafruit_pycamera/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class PyCamera: # pylint: disable=too-many-instance-attributes,too-many-public-
170170
"Sepia",
171171
"Solarize",
172172
)
173-
modes = ("JPEG", "GIF", "STOP")
173+
modes = ("JPEG", "GIF", "GBOY", "STOP")
174174

175175
_INIT_SEQUENCE = (
176176
b"\x01\x80\x78" # _SWRESET and Delay 120ms
@@ -488,7 +488,7 @@ def mode(self, setting):
488488
self._mode_label.text = self.modes[setting]
489489
if self.modes[setting] == "STOP":
490490
self.stop_motion_frame = 0
491-
if self.modes[setting] == "GIF":
491+
if self.modes[setting] in ("GIF", "GBOY"):
492492
self._res_label.text = ""
493493
else:
494494
self.resolution = self.resolution # kick it to reset the display

examples/camera/code.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
onionskin, last_frame, new_frame, displayio.Colorspace.RGB565_SWAPPED
3131
)
3232
pycam.blit(onionskin)
33+
elif pycam.mode_text == "GBOY":
34+
bitmaptools.dither(
35+
last_frame, pycam.continuous_capture(), displayio.Colorspace.RGB565_SWAPPED
36+
)
37+
pycam.blit(last_frame)
3338
else:
3439
pycam.blit(pycam.continuous_capture())
3540
# print("\t\t", capture_time, blit_time)
@@ -57,6 +62,23 @@
5762
time.sleep(0.5)
5863
pycam.live_preview_mode()
5964

65+
if pycam.mode_text == "GBOY":
66+
try:
67+
f = pycam.open_next_image("gif")
68+
except RuntimeError as e:
69+
pycam.display_message("Error\nNo SD Card", color=0xFF0000)
70+
time.sleep(0.5)
71+
continue
72+
73+
with gifio.GifWriter(
74+
f,
75+
pycam.camera.width,
76+
pycam.camera.height,
77+
displayio.Colorspace.RGB565_SWAPPED,
78+
dither=True,
79+
) as g:
80+
g.add_frame(last_frame, 1)
81+
6082
if pycam.mode_text == "GIF":
6183
try:
6284
f = pycam.open_next_image("gif")

0 commit comments

Comments
 (0)