Skip to content

Improve comment and style for quality range checking #36

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
merged 2 commits into from
May 3, 2025

Conversation

casten
Copy link
Contributor

@casten casten commented Apr 12, 2025

Improve comment and style for quality range checking
Comments on lines: 1490, 1497 use range verbiage such as:
"""Controls the JPEG quality. Valid range is from 2..55 inclusive"""
However, 55 is not included.
Also, the check on 1495 uses the following checking style using '<':
if not 2 <= value < 55:

casten added 2 commits April 10, 2025 22:45
Fix comment and style for quality range checking
Comments on lines: 1490, 1497 use range verbiage such as:
        """Controls the JPEG quality.  Valid range is from 2..55 inclusive"""
However, 55 is not included.  
Also, the check on 1495 uses the following checking style using '<':
        if not 2 <= value < 55:
Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would 55 work? I wonder if the < 55 is a bug, as opposed to <= 55

@casten
Copy link
Contributor Author

casten commented Apr 13, 2025

Would 55 work? I wonder if the < 55 is a bug, as opposed to <= 55

I do not know if the hardware would be happy with 55. But the driver is certainly unhappy:

   cam.quality = 55
   print(f"Attempting to use quality {quality}.")
   b = bytearray(cam.capture_buffer_size)
   jpeg = cam.capture(b)

produces:

Traceback (most recent call last):
File "code.py", line 81, in <module>
File "adafruit_ov5640/__init__.py", line 1499, in quality
ValueError: Invalid quality value 55, use a value from 2..55 inclusive  

If we want to match the style used for saturation and 55 is invalid for quality, we should change the comment to say "54 inclusive" and use '<='.

@casten casten requested a review from dhalbert April 15, 2025 20:27
Copy link
Member

@ladyada ladyada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@ladyada ladyada merged commit 654fd7f into adafruit:main May 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants