-
Notifications
You must be signed in to change notification settings - Fork 3
Jpeg mode #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Jpeg mode #4
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
aa3e22a
add jpeg mode setting
jepler fc4b709
jpeg mode works
jepler e174e24
Add jpeg example
jepler 7bf9645
Remove incorrect comments
jepler 847178a
Get colorspace settings in a better way
jepler 8441f09
Add an LCD+SD display program for Kaluga
jepler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries | ||
# SPDX-FileCopyrightText: Copyright (c) 2021 Jeff Epler for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: Unlicense | ||
|
||
""" | ||
The Kaluga development kit comes in two versions (v1.2 and v1.3); this demo is | ||
tested on v1.3. | ||
|
||
The audio board must be mounted between the Kaluga and the LCD, it provides the | ||
I2C pull-ups(!) | ||
|
||
You also need to place ov2640_jpeg_kaluga1_3_boot.py at CIRCUITPY/boot.py | ||
and reset the board to make the internal flash readable by CircuitPython. | ||
You can make CIRCUITPY readable from your PC by booting CircuitPython in | ||
safe mode or holding the "MODE" button on the audio daughterboard while | ||
powering on or resetting the board. | ||
""" | ||
|
||
import board | ||
import busio | ||
import adafruit_ov2640 | ||
|
||
|
||
bus = busio.I2C(scl=board.CAMERA_SIOC, sda=board.CAMERA_SIOD) | ||
cam = adafruit_ov2640.OV2640( | ||
bus, | ||
data_pins=board.CAMERA_DATA, | ||
clock=board.CAMERA_PCLK, | ||
vsync=board.CAMERA_VSYNC, | ||
href=board.CAMERA_HREF, | ||
mclk=board.CAMERA_XCLK, | ||
mclk_frequency=20_000_000, | ||
size=adafruit_ov2640.OV2640_SIZE_QVGA, | ||
) | ||
|
||
pid = cam.product_id | ||
ver = cam.product_version | ||
print(f"Detected pid={pid:x} ver={ver:x}") | ||
# cam.test_pattern = True | ||
|
||
cam.colorspace = adafruit_ov2640.OV2640_COLOR_JPEG | ||
b = bytearray(cam.capture_buffer_size) | ||
jpeg = cam.capture(b) | ||
|
||
print(f"Captured {len(jpeg)} bytes of jpeg data") | ||
try: | ||
with open("/jpeg.jpg", "wb") as f: | ||
f.write(jpeg) | ||
except OSError as e: | ||
print(e) | ||
print( | ||
"A 'read-only filesystem' error occurs if you did not correctly install\nov2640_jpeg_kaluga1_3_boot.py as CIRCUITPY/boot.py and reset the board" | ||
) | ||
print("Wrote to CIRCUITPY/jpeg.jpg") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries | ||
# SPDX-FileCopyrightText: Copyright (c) 2021 Jeff Epler for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: Unlicense | ||
"""Use this file as CIRCUITPY/boot.py in conjunction with ov2640_jpeg_kaluga1_3.py | ||
|
||
It makes the CIRCUITPY filesystem writable to CircuitPython | ||
(and read-only to the PC) unless the "MODE" button on the audio | ||
daughterboard is held while the board is powered on or reset. | ||
""" | ||
|
||
import analogio | ||
import board | ||
import storage | ||
|
||
V_MODE = 1.98 | ||
V_RECORD = 2.41 | ||
|
||
a = analogio.AnalogIn(board.IO6) | ||
a_voltage = a.value * a.reference_voltage / 65535 | ||
if abs(a_voltage - V_MODE) > 0.05: # If mode is NOT pressed... | ||
print("storage writable by CircuitPython") | ||
storage.remount("/", readonly=False) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.